Skip to content

Commit f332ba7

Browse files
committed
Reorganizes path & vscode utils
Updates lint rules to catch invalid imports
1 parent 46b1e6c commit f332ba7

File tree

80 files changed

+538
-536
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+538
-536
lines changed

eslint.config.mjs

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -252,23 +252,27 @@ export default ts.config(
252252
'util',
253253
'vm',
254254
'zlib',
255-
],
256-
patterns: [
257-
{
258-
group: ['**/env/**/*'],
259-
message: 'Use @env/ instead',
260-
},
261255
{
262-
group: ['react-dom'],
256+
name: 'react-dom',
263257
importNames: ['Container'],
264258
message: 'Use our Container instead',
265259
},
266260
{
267-
group: ['vscode'],
261+
name: 'vscode',
268262
importNames: ['CancellationError'],
269263
message: 'Use our CancellationError instead',
270264
},
271265
],
266+
patterns: [
267+
{
268+
group: ['**/env/**/*'],
269+
message: 'Use @env/ instead',
270+
},
271+
{
272+
group: ['**/webview/**/*'],
273+
message: "Can't use any `webview`-only modules in extension",
274+
},
275+
],
272276
},
273277
],
274278
'@typescript-eslint/no-unnecessary-condition': 'off',
@@ -339,14 +343,14 @@ export default ts.config(
339343
'@typescript-eslint/no-restricted-imports': [
340344
'error',
341345
{
342-
patterns: [
346+
paths: [
343347
{
344-
group: ['react-dom'],
348+
name: 'react-dom',
345349
importNames: ['Container'],
346350
message: 'Use our Container instead',
347351
},
348352
{
349-
group: ['vscode'],
353+
name: 'vscode',
350354
importNames: ['CancellationError'],
351355
message: 'Use our CancellationError instead',
352356
},
@@ -412,15 +416,23 @@ export default ts.config(
412416
'@typescript-eslint/no-restricted-imports': [
413417
'error',
414418
{
419+
paths: [
420+
{
421+
name: 'vscode',
422+
message: "Can't use `vscode` in webviews",
423+
allowTypeImports: true,
424+
},
425+
],
415426
patterns: [
416427
{
417-
group: ['Container'],
428+
group: ['container'],
429+
importNames: ['Container'],
418430
message: "Can't use `Container` in webviews",
419431
allowTypeImports: true,
420432
},
421433
{
422-
group: ['vscode'],
423-
message: "Can't use `vscode` in webviews",
434+
group: ['**/-webview/**/*'],
435+
message: "Can't use any `-webview` modules in webviews",
424436
allowTypeImports: true,
425437
},
426438
],

src/ai/aiProviderService.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { assertsCommitHasFullDetails } from '../git/utils/commit.utils';
1414
import { showAIModelPicker } from '../quickpicks/aiModelPicker';
1515
import { configuration } from '../system/-webview/configuration';
1616
import type { Storage } from '../system/-webview/storage';
17-
import { supportedInVSCodeVersion } from '../system/-webview/utils';
17+
import { supportedInVSCodeVersion } from '../system/-webview/vscode';
1818
import { getSettledValue } from '../system/promise';
1919
import { getPossessiveForm } from '../system/string';
2020
import type { TelemetryService } from '../telemetry/telemetry';

src/annotations/annotationProvider.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { Disposable, window } from 'vscode';
33
import type { FileAnnotationType } from '../config';
44
import type { AnnotationStatus } from '../constants';
55
import type { Container } from '../container';
6-
import { getTabUri } from '../system/-webview/utils';
6+
import { getTabUri } from '../system/-webview/vscode';
77
import { Logger } from '../system/logger';
88
import type { Deferred } from '../system/promise';
99
import { defer } from '../system/promise';

src/annotations/fileAnnotationController.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import { configuration } from '../system/-webview/configuration';
3030
import { setContext } from '../system/-webview/context';
3131
import type { KeyboardScope } from '../system/-webview/keyboard';
3232
import { UriSet } from '../system/-webview/uriMap';
33-
import { isTrackableTextEditor } from '../system/-webview/utils';
33+
import { isTrackableTextEditor } from '../system/-webview/vscode';
3434
import { debug, log } from '../system/decorators/log';
3535
import { once } from '../system/event';
3636
import type { Deferrable } from '../system/function';

src/annotations/lineAnnotationController.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { CommitFormatter } from '../git/formatters/commitFormatter';
66
import type { PullRequest } from '../git/models/pullRequest';
77
import { detailsMessage } from '../hovers/hovers';
88
import { configuration } from '../system/-webview/configuration';
9-
import { isTrackableTextEditor } from '../system/-webview/utils';
9+
import { isTrackableTextEditor } from '../system/-webview/vscode';
1010
import { debug, log } from '../system/decorators/log';
1111
import { once } from '../system/event';
1212
import { debounce } from '../system/function';

src/api/actionRunners.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import type { Container } from '../container';
66
import { registerCommand } from '../system/-webview/command';
77
import { configuration } from '../system/-webview/configuration';
88
import { setContext } from '../system/-webview/context';
9-
import { getQuickPickIgnoreFocusOut } from '../system/-webview/utils';
9+
import { getQuickPickIgnoreFocusOut } from '../system/-webview/vscode';
1010
import { getScopedCounter } from '../system/counter';
1111
import { sortCompare } from '../system/string';
1212
import type { Action, ActionContext, ActionRunner } from './gitlens';

src/codelens/codeLensProvider.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import type { GitCommit } from '../git/models/commit';
2828
import { RemoteResourceType } from '../git/models/remoteResource';
2929
import { createCommand, executeCoreCommand } from '../system/-webview/command';
3030
import { configuration } from '../system/-webview/configuration';
31-
import { isVirtualUri } from '../system/-webview/utils';
31+
import { isVirtualUri } from '../system/-webview/vscode';
3232
import { is, once } from '../system/function';
3333
import { filterMap, find, first, join, map } from '../system/iterable';
3434
import { getLoggableName, Logger } from '../system/logger';

src/commands/browseRepoAtRevision.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import type { Container } from '../container';
44
import { GitUri } from '../git/gitUri';
55
import { showGenericErrorMessage } from '../messages';
66
import { command, executeCoreCommand } from '../system/-webview/command';
7-
import { openWorkspace } from '../system/-webview/utils';
7+
import { openWorkspace } from '../system/-webview/vscode';
88
import { Logger } from '../system/logger';
99
import { basename } from '../system/path';
1010
import { ActiveEditorCommand } from './commandBase';

src/commands/diffWith.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { deletedOrMissing } from '../git/models/revision';
99
import { isShaLike, isUncommitted, shortenRevision } from '../git/utils/revision.utils';
1010
import { showGenericErrorMessage } from '../messages';
1111
import { command } from '../system/-webview/command';
12-
import { openDiffEditor } from '../system/-webview/utils';
12+
import { openDiffEditor } from '../system/-webview/vscode';
1313
import { createMarkdownCommandLink } from '../system/commands';
1414
import { Logger } from '../system/logger';
1515
import { basename } from '../system/path';

src/commands/diffWithPrevious.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import type { GitCommit } from '../git/models/commit';
66
import { deletedOrMissing } from '../git/models/revision';
77
import { showCommitHasNoPreviousCommitWarningMessage, showGenericErrorMessage } from '../messages';
88
import { command, executeCommand } from '../system/-webview/command';
9-
import { findOrOpenEditor } from '../system/-webview/utils';
9+
import { findOrOpenEditor } from '../system/-webview/vscode';
1010
import { Logger } from '../system/logger';
1111
import { ActiveEditorCommand } from './commandBase';
1212
import { getCommandUri } from './commandBase.utils';

0 commit comments

Comments
 (0)