Skip to content

Commit

Permalink
chore: use consistent type imports VSCODE-410 (#579)
Browse files Browse the repository at this point in the history
  • Loading branch information
alenakhineika authored Aug 15, 2023
1 parent 353ec5f commit 30624c5
Show file tree
Hide file tree
Showing 83 changed files with 216 additions and 212 deletions.
4 changes: 4 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ module.exports = {
'@typescript-eslint/no-unsafe-call': 0,
'@typescript-eslint/no-unsafe-return': 0,
'@typescript-eslint/no-unsafe-argument': 0,
'@typescript-eslint/consistent-type-imports': [
'error',
{ prefer: 'type-imports' },
],
},
parserOptions: {
project: ['./tsconfig.json'], // Specify it only for TypeScript files.
Expand Down
2 changes: 1 addition & 1 deletion src/commands/launchMongoShell.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as vscode from 'vscode';

import ConnectionController from '../connectionController';
import type ConnectionController from '../connectionController';

const launchMongoDBShellWithEnv = (
shellCommand: string,
Expand Down
19 changes: 11 additions & 8 deletions src/connectionController.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import * as vscode from 'vscode';
import {
convertConnectionModelToInfo,
ConnectionInfo,
ConnectionOptions,
getConnectionTitle,
extractSecrets,
mergeSecrets,
connect,
} from 'mongodb-data-service';
import type { DataService } from 'mongodb-data-service';
import type {
DataService,
ConnectionInfo,
ConnectionOptions,
} from 'mongodb-data-service';
import ConnectionString from 'mongodb-connection-string-url';
import { EventEmitter } from 'events';
import type { MongoClientOptions } from 'mongodb';
Expand All @@ -18,15 +20,16 @@ import { CONNECTION_STATUS } from './views/webview-app/extension-app-message-con
import { createLogger } from './logging';
import { ext } from './extensionConstants';
import formatError from './utils/formatError';
import LegacyConnectionModel from './views/webview-app/connection-model/legacy-connection-model';
import type LegacyConnectionModel from './views/webview-app/connection-model/legacy-connection-model';
import type { SecretStorageLocationType } from './storage/storageController';
import {
StorageLocation,
SecretStorageLocationType,
SecretStorageLocation,
} from './storage/storageController';
import { StorageController, StorageVariables } from './storage';
import { StatusView } from './views';
import TelemetryService from './telemetry/telemetryService';
import type { StorageController } from './storage';
import { StorageVariables } from './storage';
import type { StatusView } from './views';
import type TelemetryService from './telemetry/telemetryService';
import LINKS from './utils/links';
// eslint-disable-next-line @typescript-eslint/no-var-requires
const packageJSON = require('../package.json');
Expand Down
4 changes: 2 additions & 2 deletions src/editors/activeConnectionCodeLensProvider.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as vscode from 'vscode';
import { TextEditor } from 'vscode';
import type { TextEditor } from 'vscode';
import EXTENSION_COMMANDS from '../commands';
import ConnectionController from '../connectionController';
import type ConnectionController from '../connectionController';
import { isPlayground } from '../utils/playground';

export default class ActiveConnectionCodeLensProvider
Expand Down
2 changes: 1 addition & 1 deletion src/editors/collectionDocumentsCodeLensProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { URLSearchParams } from 'url';
import * as vscode from 'vscode';
import EXTENSION_COMMANDS from '../commands';

import CollectionDocumentsOperationStore from './collectionDocumentsOperationsStore';
import type CollectionDocumentsOperationStore from './collectionDocumentsOperationsStore';
import {
CONNECTION_ID_URI_IDENTIFIER,
NAMESPACE_URI_IDENTIFIER,
Expand Down
8 changes: 4 additions & 4 deletions src/editors/collectionDocumentsProvider.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import * as vscode from 'vscode';
import { URLSearchParams } from 'url';

import CollectionDocumentsOperationsStore from './collectionDocumentsOperationsStore';
import ConnectionController from '../connectionController';
import EditDocumentCodeLensProvider from './editDocumentCodeLensProvider';
import type CollectionDocumentsOperationsStore from './collectionDocumentsOperationsStore';
import type ConnectionController from '../connectionController';
import type EditDocumentCodeLensProvider from './editDocumentCodeLensProvider';
import formatError from '../utils/formatError';
import { StatusView } from '../views';
import type { StatusView } from '../views';

export const NAMESPACE_URI_IDENTIFIER = 'namespace';
export const OPERATION_ID_URI_IDENTIFIER = 'operationId';
Expand Down
2 changes: 1 addition & 1 deletion src/editors/editDocumentCodeLensProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as vscode from 'vscode';
import { EJSON } from 'bson';
import type { Document } from 'bson';

import ConnectionController from '../connectionController';
import type ConnectionController from '../connectionController';
import { DocumentSource } from '../documentSource';
import type { EditDocumentInfo } from '../types/editDocumentInfoType';
import EXTENSION_COMMANDS from '../commands';
Expand Down
19 changes: 9 additions & 10 deletions src/editors/editorsController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import * as vscode from 'vscode';
import { EJSON } from 'bson';
import type { Document } from 'bson';

import ActiveConnectionCodeLensProvider from './activeConnectionCodeLensProvider';
import ExportToLanguageCodeLensProvider from './exportToLanguageCodeLensProvider';
import type ActiveConnectionCodeLensProvider from './activeConnectionCodeLensProvider';
import type ExportToLanguageCodeLensProvider from './exportToLanguageCodeLensProvider';
import PlaygroundSelectedCodeActionProvider from './playgroundSelectedCodeActionProvider';
import PlaygroundDiagnosticsCodeActionProvider from './playgroundDiagnosticsCodeActionProvider';
import ConnectionController from '../connectionController';
import type ConnectionController from '../connectionController';
import CollectionDocumentsCodeLensProvider from './collectionDocumentsCodeLensProvider';
import CollectionDocumentsOperationsStore from './collectionDocumentsOperationsStore';
import CollectionDocumentsProvider, {
Expand All @@ -17,8 +17,8 @@ import CollectionDocumentsProvider, {
} from './collectionDocumentsProvider';
import { createLogger } from '../logging';
import DocumentIdStore from './documentIdStore';
import { DocumentSource } from '../documentSource';
import EditDocumentCodeLensProvider from './editDocumentCodeLensProvider';
import type { DocumentSource } from '../documentSource';
import type EditDocumentCodeLensProvider from './editDocumentCodeLensProvider';
import type { EditDocumentInfo } from '../types/editDocumentInfoType';
import formatError from '../utils/formatError';
import { MemoryFileSystemProvider } from './memoryFileSystemProvider';
Expand All @@ -27,12 +27,11 @@ import MongoDBDocumentService, {
DOCUMENT_SOURCE_URI_IDENTIFIER,
VIEW_DOCUMENT_SCHEME,
} from './mongoDBDocumentService';
import PlaygroundController from './playgroundController';
import PlaygroundResultProvider, {
PLAYGROUND_RESULT_SCHEME,
} from './playgroundResultProvider';
import type PlaygroundController from './playgroundController';
import type PlaygroundResultProvider from './playgroundResultProvider';
import { PLAYGROUND_RESULT_SCHEME } from './playgroundResultProvider';
import { StatusView } from '../views';
import TelemetryService from '../telemetry/telemetryService';
import type TelemetryService from '../telemetry/telemetryService';

const log = createLogger('editors controller');

Expand Down
2 changes: 1 addition & 1 deletion src/editors/exportToLanguageCodeLensProvider.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import * as vscode from 'vscode';

import EXTENSION_COMMANDS from '../commands';
import type { ExportToLanguageAddons } from '../types/playgroundType';
import {
ExportToLanguageMode,
ExportToLanguageAddons,
ExportToLanguages,
} from '../types/playgroundType';

Expand Down
8 changes: 4 additions & 4 deletions src/editors/mongoDBDocumentService.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import * as vscode from 'vscode';
import type * as vscode from 'vscode';
import { EJSON } from 'bson';
import type { Document } from 'bson';

import ConnectionController from '../connectionController';
import type ConnectionController from '../connectionController';
import { createLogger } from '../logging';
import { DocumentSource } from '../documentSource';
import type { EditDocumentInfo } from '../types/editDocumentInfoType';
import formatError from '../utils/formatError';
import { StatusView } from '../views';
import TelemetryService from '../telemetry/telemetryService';
import type { StatusView } from '../views';
import type TelemetryService from '../telemetry/telemetryService';

const log = createLogger('document controller');

Expand Down
30 changes: 16 additions & 14 deletions src/editors/playgroundController.ts
Original file line number Diff line number Diff line change
@@ -1,41 +1,43 @@
import * as vscode from 'vscode';
import path from 'path';
import { OutputChannel, ProgressLocation, TextEditor } from 'vscode';
import type { OutputChannel, TextEditor } from 'vscode';
import { ProgressLocation } from 'vscode';
import vm from 'vm';
import os from 'os';
import transpiler from 'bson-transpilers';

import ActiveConnectionCodeLensProvider from './activeConnectionCodeLensProvider';
import PlaygroundSelectedCodeActionProvider from './playgroundSelectedCodeActionProvider';
import ConnectionController, {
DataServiceEventTypes,
} from '../connectionController';
import type ActiveConnectionCodeLensProvider from './activeConnectionCodeLensProvider';
import type PlaygroundSelectedCodeActionProvider from './playgroundSelectedCodeActionProvider';
import type ConnectionController from '../connectionController';
import { DataServiceEventTypes } from '../connectionController';
import { createLogger } from '../logging';
import { ConnectionTreeItem, DatabaseTreeItem } from '../explorer';
import ExportToLanguageCodeLensProvider from './exportToLanguageCodeLensProvider';
import type { ConnectionTreeItem } from '../explorer';
import { DatabaseTreeItem } from '../explorer';
import type ExportToLanguageCodeLensProvider from './exportToLanguageCodeLensProvider';
import formatError from '../utils/formatError';
import { LanguageServerController } from '../language';
import type { LanguageServerController } from '../language';
import playgroundCreateIndexTemplate from '../templates/playgroundCreateIndexTemplate';
import playgroundCreateCollectionTemplate from '../templates/playgroundCreateCollectionTemplate';
import playgroundCloneDocumentTemplate from '../templates/playgroundCloneDocumentTemplate';
import playgroundInsertDocumentTemplate from '../templates/playgroundInsertDocumentTemplate';
import {
import type {
PlaygroundResult,
ShellEvaluateResult,
ExportToLanguageAddons,
ExportToLanguageNamespace,
ExportToLanguageMode,
ThisDiagnosticFix,
AllDiagnosticFixes,
} from '../types/playgroundType';
import PlaygroundResultProvider, {
import { ExportToLanguageMode } from '../types/playgroundType';
import type PlaygroundResultProvider from './playgroundResultProvider';
import {
PLAYGROUND_RESULT_SCHEME,
PLAYGROUND_RESULT_URI,
} from './playgroundResultProvider';
import playgroundSearchTemplate from '../templates/playgroundSearchTemplate';
import playgroundTemplate from '../templates/playgroundTemplate';
import { StatusView } from '../views';
import TelemetryService from '../telemetry/telemetryService';
import type { StatusView } from '../views';
import type TelemetryService from '../telemetry/telemetryService';
import {
isPlayground,
getPlaygroundExtensionForTelemetry,
Expand Down
7 changes: 4 additions & 3 deletions src/editors/playgroundResultProvider.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import * as vscode from 'vscode';

import ConnectionController from '../connectionController';
import EditDocumentCodeLensProvider from './editDocumentCodeLensProvider';
import { PlaygroundResult, ExportToLanguages } from '../types/playgroundType';
import type ConnectionController from '../connectionController';
import type EditDocumentCodeLensProvider from './editDocumentCodeLensProvider';
import type { PlaygroundResult } from '../types/playgroundType';
import { ExportToLanguages } from '../types/playgroundType';

export const PLAYGROUND_RESULT_SCHEME = 'PLAYGROUND_RESULT_SCHEME';

Expand Down
2 changes: 1 addition & 1 deletion src/editors/playgroundSelectedCodeActionProvider.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as vscode from 'vscode';
import { TextEditor } from 'vscode';
import type { TextEditor } from 'vscode';

import EXTENSION_COMMANDS from '../commands';
import { ExportToLanguageMode } from '../types/playgroundType';
Expand Down
2 changes: 1 addition & 1 deletion src/explorer/collectionTreeItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import DocumentListTreeItem, {
import formatError from '../utils/formatError';
import { getImagesPath } from '../extensionConstants';
import IndexListTreeItem from './indexListTreeItem';
import TreeItemParent from './treeItemParentInterface';
import type TreeItemParent from './treeItemParentInterface';
import SchemaTreeItem from './schemaTreeItem';

function getIconPath(
Expand Down
4 changes: 2 additions & 2 deletions src/explorer/connectionTreeItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import * as vscode from 'vscode';
import path from 'path';

import DatabaseTreeItem from './databaseTreeItem';
import ConnectionController from '../connectionController';
import type ConnectionController from '../connectionController';
import formatError from '../utils/formatError';
import { getImagesPath } from '../extensionConstants';
import TreeItemParent from './treeItemParentInterface';
import type TreeItemParent from './treeItemParentInterface';

export enum ConnectionItemContextValues {
disconnected = 'disconnectedConnectionTreeItem',
Expand Down
2 changes: 1 addition & 1 deletion src/explorer/databaseTreeItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import CollectionTreeItem from './collectionTreeItem';
import type { CollectionDetailsType } from './collectionTreeItem';
import formatError from '../utils/formatError';
import { getImagesPath } from '../extensionConstants';
import TreeItemParent from './treeItemParentInterface';
import type TreeItemParent from './treeItemParentInterface';

function getIconPath(): { light: string; dark: string } {
const LIGHT = path.join(getImagesPath(), 'light');
Expand Down
2 changes: 1 addition & 1 deletion src/explorer/documentListTreeItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { createLogger } from '../logging';
import DocumentTreeItem from './documentTreeItem';
import formatError from '../utils/formatError';
import { getImagesPath } from '../extensionConstants';
import TreeItemParent from './treeItemParentInterface';
import type TreeItemParent from './treeItemParentInterface';
import type { DataService } from 'mongodb-data-service';

const log = createLogger('documents tree item');
Expand Down
5 changes: 2 additions & 3 deletions src/explorer/explorerController.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import * as vscode from 'vscode';

import ConnectionController, {
DataServiceEventTypes,
} from '../connectionController';
import type ConnectionController from '../connectionController';
import { DataServiceEventTypes } from '../connectionController';
import ExplorerTreeController from './explorerTreeController';

export default class ExplorerController {
Expand Down
7 changes: 3 additions & 4 deletions src/explorer/explorerTreeController.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import * as vscode from 'vscode';

import ConnectionController, {
DataServiceEventTypes,
StoreConnectionInfo,
} from '../connectionController';
import type { StoreConnectionInfo } from '../connectionController';
import type ConnectionController from '../connectionController';
import { DataServiceEventTypes } from '../connectionController';
import ConnectionTreeItem from './connectionTreeItem';
import { createLogger } from '../logging';
import { DOCUMENT_ITEM } from './documentTreeItem';
Expand Down
2 changes: 1 addition & 1 deletion src/explorer/fieldTreeItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as vscode from 'vscode';
import path from 'path';

import { getImagesPath } from '../extensionConstants';
import TreeItemParent from './treeItemParentInterface';
import type TreeItemParent from './treeItemParentInterface';

// Loosely based on bson types. These values match with the
// types returned by `parseSchema` with `mongodb-schema`.
Expand Down
2 changes: 1 addition & 1 deletion src/explorer/helpExplorer.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as vscode from 'vscode';
import HelpTree from './helpTree';
import { TelemetryService } from '../telemetry';
import type { TelemetryService } from '../telemetry';

export default class HelpExplorer {
_treeController: HelpTree;
Expand Down
2 changes: 1 addition & 1 deletion src/explorer/helpTree.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as vscode from 'vscode';
import path from 'path';
import { getImagesPath } from '../extensionConstants';
import { TelemetryService } from '../telemetry';
import type { TelemetryService } from '../telemetry';
import { openLink } from '../utils/linkHelper';
import LINKS from '../utils/links';

Expand Down
7 changes: 4 additions & 3 deletions src/explorer/indexListTreeItem.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import * as vscode from 'vscode';
import { DataService } from 'mongodb-data-service';
import type { DataService } from 'mongodb-data-service';
import path from 'path';

import formatError from '../utils/formatError';
import { getImagesPath } from '../extensionConstants';
import IndexTreeItem, { IndexModel } from './indexTreeItem';
import type { IndexModel } from './indexTreeItem';
import IndexTreeItem from './indexTreeItem';
import { sortTreeItemsByLabel } from './treeItemUtils';
import TreeItemParent from './treeItemParentInterface';
import type TreeItemParent from './treeItemParentInterface';

const ITEM_LABEL = 'Indexes';

Expand Down
2 changes: 1 addition & 1 deletion src/explorer/indexTreeItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as vscode from 'vscode';
import path from 'path';

import { getImagesPath } from '../extensionConstants';
import TreeItemParent from './treeItemParentInterface';
import type TreeItemParent from './treeItemParentInterface';

export enum IndexKeyType {
ASCENDING = 1,
Expand Down
4 changes: 2 additions & 2 deletions src/explorer/playgroundsTreeHeader.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as vscode from 'vscode';
import TreeItemParent from './treeItemParentInterface';
import PlaygroundsTreeItem from './playgroundsTreeItem';
import type TreeItemParent from './treeItemParentInterface';
import type PlaygroundsTreeItem from './playgroundsTreeItem';
import { sortTreeItemsByLabel } from './treeItemUtils';

export default class PlaygroundsTreeHeader
Expand Down
4 changes: 2 additions & 2 deletions src/explorer/schemaTreeItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import { createLogger } from '../logging';
import FieldTreeItem from './fieldTreeItem';
import formatError from '../utils/formatError';
import { getImagesPath } from '../extensionConstants';
import TreeItemParent from './treeItemParentInterface';
import type TreeItemParent from './treeItemParentInterface';
import { MAX_DOCUMENTS_VISIBLE } from './documentListTreeItem';
import { DataService } from 'mongodb-data-service';
import type { DataService } from 'mongodb-data-service';

const log = createLogger('schema tree item');

Expand Down
2 changes: 1 addition & 1 deletion src/explorer/treeItemParentInterface.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as vscode from 'vscode';
import type * as vscode from 'vscode';

export default interface TreeItemParentInterface extends vscode.TreeItem {
isExpanded: boolean;
Expand Down
Loading

0 comments on commit 30624c5

Please sign in to comment.