From f3f99f6e9eb7ec27bc2491ccc97ae23fd2a59fb0 Mon Sep 17 00:00:00 2001 From: rebornix Date: Fri, 3 Jun 2022 14:09:54 -0700 Subject: [PATCH 1/5] Avoid loading full lodash. --- .eslintrc.js | 1 + src/kernels/jupyter/preferredRemoteKernelIdProvider.ts | 2 +- src/kernels/jupyter/serverSelector.ts | 2 +- src/notebooks/controllers/remoteSwitcher.ts | 2 +- src/notebooks/execution/notebookUpdater.ts | 2 +- .../datascience/editor-integration/hoverProvider.vscode.test.ts | 2 +- src/test/datascience/helpers.ts | 2 +- src/test/datascience/mockCommandManager.ts | 2 +- src/webviews/extension-side/dataviewer/dataViewerFactory.ts | 2 +- src/webviews/webview-side/data-explorer/mainPanel.tsx | 2 +- 10 files changed, 10 insertions(+), 9 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 8e8fb3c572e..7b6235cf983 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -265,6 +265,7 @@ module.exports = { ], 'react/jsx-uses-vars': 'error', 'react/jsx-uses-react': 'error', + 'no-restricted-imports': ['error', { "paths": ["lodash"] }], 'import/no-restricted-paths': [ 'error', { diff --git a/src/kernels/jupyter/preferredRemoteKernelIdProvider.ts b/src/kernels/jupyter/preferredRemoteKernelIdProvider.ts index e129bf41f99..15b62ebd2cb 100644 --- a/src/kernels/jupyter/preferredRemoteKernelIdProvider.ts +++ b/src/kernels/jupyter/preferredRemoteKernelIdProvider.ts @@ -2,7 +2,7 @@ // Licensed under the MIT License. import { inject, injectable, named } from 'inversify'; -import { cloneDeep } from 'lodash'; +import cloneDeep from 'lodash/cloneDeep'; import { Memento, Uri } from 'vscode'; import { traceInfo, traceVerbose } from '../../platform/logging'; import { getDisplayPath } from '../../platform/common/platform/fs-paths'; diff --git a/src/kernels/jupyter/serverSelector.ts b/src/kernels/jupyter/serverSelector.ts index 017de9c087d..79ad1da2c6f 100644 --- a/src/kernels/jupyter/serverSelector.ts +++ b/src/kernels/jupyter/serverSelector.ts @@ -4,7 +4,7 @@ 'use strict'; import { inject, injectable } from 'inversify'; -import { isNil } from 'lodash'; +import isNil from 'lodash/isNil'; import { EventEmitter, QuickPickItem, ThemeIcon, Uri } from 'vscode'; import { IApplicationShell, IClipboard } from '../../platform/common/application/types'; import { traceDecoratorError, traceError, traceWarning } from '../../platform/logging'; diff --git a/src/notebooks/controllers/remoteSwitcher.ts b/src/notebooks/controllers/remoteSwitcher.ts index 77a7484d1bb..af5d2a5f853 100644 --- a/src/notebooks/controllers/remoteSwitcher.ts +++ b/src/notebooks/controllers/remoteSwitcher.ts @@ -2,7 +2,7 @@ // Licensed under the MIT License. import { inject, injectable } from 'inversify'; -import { noop } from 'lodash'; +import noop from 'lodash/noop'; import { StatusBarAlignment, StatusBarItem } from 'vscode'; import { IExtensionSingleActivationService } from '../../platform/activation/types'; import { diff --git a/src/notebooks/execution/notebookUpdater.ts b/src/notebooks/execution/notebookUpdater.ts index 9665fdb6283..e61184fc9b0 100644 --- a/src/notebooks/execution/notebookUpdater.ts +++ b/src/notebooks/execution/notebookUpdater.ts @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -import { noop } from 'lodash'; +import noop from 'lodash/noop'; import { isPromise } from 'rxjs/internal-compatibility'; import { NotebookDocument, NotebookEditor, workspace, WorkspaceEdit, window } from 'vscode'; import { createDeferred } from '../../platform/common/utils/async'; diff --git a/src/test/datascience/editor-integration/hoverProvider.vscode.test.ts b/src/test/datascience/editor-integration/hoverProvider.vscode.test.ts index 58fc087efed..b05843e616e 100644 --- a/src/test/datascience/editor-integration/hoverProvider.vscode.test.ts +++ b/src/test/datascience/editor-integration/hoverProvider.vscode.test.ts @@ -1,5 +1,5 @@ import { assert } from 'chai'; -import { cloneDeep } from 'lodash'; +import cloneDeep from 'lodash/cloneDeep'; import * as sinon from 'sinon'; import * as path from '../../../platform/vscode-path/path'; import * as vscode from 'vscode'; diff --git a/src/test/datascience/helpers.ts b/src/test/datascience/helpers.ts index e2dcaafa362..8b24ff760b8 100644 --- a/src/test/datascience/helpers.ts +++ b/src/test/datascience/helpers.ts @@ -5,7 +5,7 @@ import * as vscode from 'vscode'; import { getFilePath } from '../../platform/common/platform/fs-paths'; import { traceInfo } from '../../platform/logging'; -import { noop } from 'lodash'; +import noop from 'lodash/noop'; import { IPythonApiProvider } from '../../platform/api/types'; import { IJupyterSettings, Resource } from '../../platform/common/types'; import { InteractiveWindow } from '../../interactive-window/interactiveWindow'; diff --git a/src/test/datascience/mockCommandManager.ts b/src/test/datascience/mockCommandManager.ts index eb9b5a1adf0..29b561adf59 100644 --- a/src/test/datascience/mockCommandManager.ts +++ b/src/test/datascience/mockCommandManager.ts @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. 'use strict'; -import { noop } from 'lodash'; +import noop from 'lodash/noop'; import { Disposable, TextEditor, TextEditorEdit } from 'vscode'; import { ICommandNameArgumentTypeMapping } from '../../platform/common/application/commands'; diff --git a/src/webviews/extension-side/dataviewer/dataViewerFactory.ts b/src/webviews/extension-side/dataviewer/dataViewerFactory.ts index c1b36de28d1..c6a2d18f81c 100644 --- a/src/webviews/extension-side/dataviewer/dataViewerFactory.ts +++ b/src/webviews/extension-side/dataviewer/dataViewerFactory.ts @@ -7,7 +7,7 @@ import { inject, injectable } from 'inversify'; import { captureTelemetry } from '../../../telemetry'; import { IDataViewer, IDataViewerDataProvider, IDataViewerFactory } from './types'; -import { debounce } from 'lodash'; +import debounce from 'lodash/debounce'; import { ICommandManager } from '../../../platform/common/application/types'; import { ContextKey } from '../../../platform/common/contextKey'; import { IAsyncDisposable, IAsyncDisposableRegistry, IDisposableRegistry } from '../../../platform/common/types'; diff --git a/src/webviews/webview-side/data-explorer/mainPanel.tsx b/src/webviews/webview-side/data-explorer/mainPanel.tsx index d645950655c..d5a4e504885 100644 --- a/src/webviews/webview-side/data-explorer/mainPanel.tsx +++ b/src/webviews/webview-side/data-explorer/mainPanel.tsx @@ -16,7 +16,7 @@ import { generateTestData } from './testData'; import '../react-common/codicon/codicon.css'; import '../react-common/seti/seti.less'; import { SliceControl } from './sliceControl'; -import { debounce } from 'lodash'; +import debounce from 'lodash/debounce'; import * as uuid from 'uuid/v4'; import { initializeIcons } from '@fluentui/react'; From f3ebb12b830f3662de5ea56d50da7268ca6773b4 Mon Sep 17 00:00:00 2001 From: rebornix Date: Fri, 3 Jun 2022 14:44:46 -0700 Subject: [PATCH 2/5] esModuleInterop --- tsconfig.datascience-ui.json | 1 + tsconfig.extension.node.json | 1 + tsconfig.json | 1 + 3 files changed, 3 insertions(+) diff --git a/tsconfig.datascience-ui.json b/tsconfig.datascience-ui.json index d53275b0e04..8ee929f7bd8 100644 --- a/tsconfig.datascience-ui.json +++ b/tsconfig.datascience-ui.json @@ -14,6 +14,7 @@ "*": ["types/*"] }, "experimentalDecorators": true, + "esModuleInterop": true, "allowSyntheticDefaultImports": true, "noImplicitThis": false, "noUnusedLocals": true, diff --git a/tsconfig.extension.node.json b/tsconfig.extension.node.json index 707fbe805e2..6b158ca8b0a 100644 --- a/tsconfig.extension.node.json +++ b/tsconfig.extension.node.json @@ -9,6 +9,7 @@ "sourceMap": true, "rootDir": "src", "experimentalDecorators": true, + "esModuleInterop": true, "allowSyntheticDefaultImports": true, "useUnknownInCatchVariables": false, "noImplicitThis": false diff --git a/tsconfig.json b/tsconfig.json index 39da68d83b5..14a9ca5ca39 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -12,6 +12,7 @@ "sourceMap": true, "rootDir": "src", "experimentalDecorators": true, + "esModuleInterop": true, "allowSyntheticDefaultImports": true, "strict": true, "noImplicitAny": true, From ff284821e99a63ccd02ca429734a79dc59f6e1b4 Mon Sep 17 00:00:00 2001 From: rebornix Date: Fri, 3 Jun 2022 14:52:54 -0700 Subject: [PATCH 3/5] Revert "esModuleInterop" This reverts commit f3ebb12b830f3662de5ea56d50da7268ca6773b4. --- tsconfig.datascience-ui.json | 1 - tsconfig.extension.node.json | 1 - tsconfig.json | 1 - 3 files changed, 3 deletions(-) diff --git a/tsconfig.datascience-ui.json b/tsconfig.datascience-ui.json index 8ee929f7bd8..d53275b0e04 100644 --- a/tsconfig.datascience-ui.json +++ b/tsconfig.datascience-ui.json @@ -14,7 +14,6 @@ "*": ["types/*"] }, "experimentalDecorators": true, - "esModuleInterop": true, "allowSyntheticDefaultImports": true, "noImplicitThis": false, "noUnusedLocals": true, diff --git a/tsconfig.extension.node.json b/tsconfig.extension.node.json index 6b158ca8b0a..707fbe805e2 100644 --- a/tsconfig.extension.node.json +++ b/tsconfig.extension.node.json @@ -9,7 +9,6 @@ "sourceMap": true, "rootDir": "src", "experimentalDecorators": true, - "esModuleInterop": true, "allowSyntheticDefaultImports": true, "useUnknownInCatchVariables": false, "noImplicitThis": false diff --git a/tsconfig.json b/tsconfig.json index 14a9ca5ca39..39da68d83b5 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -12,7 +12,6 @@ "sourceMap": true, "rootDir": "src", "experimentalDecorators": true, - "esModuleInterop": true, "allowSyntheticDefaultImports": true, "strict": true, "noImplicitAny": true, From 7a8f30ab761631cc413a6d6cadc4c58397975da0 Mon Sep 17 00:00:00 2001 From: rebornix Date: Fri, 3 Jun 2022 15:13:37 -0700 Subject: [PATCH 4/5] force require for modules no default export --- src/kernels/jupyter/preferredRemoteKernelIdProvider.ts | 3 ++- src/kernels/jupyter/serverSelector.ts | 2 +- src/notebooks/controllers/remoteSwitcher.ts | 2 +- src/notebooks/execution/notebookUpdater.ts | 2 +- .../editor-integration/hoverProvider.vscode.test.ts | 2 +- src/test/datascience/helpers.ts | 2 +- src/test/datascience/mockCommandManager.ts | 2 +- src/webviews/extension-side/dataviewer/dataViewerFactory.ts | 2 +- src/webviews/webview-side/data-explorer/mainPanel.tsx | 2 +- 9 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/kernels/jupyter/preferredRemoteKernelIdProvider.ts b/src/kernels/jupyter/preferredRemoteKernelIdProvider.ts index 15b62ebd2cb..5aa195fa267 100644 --- a/src/kernels/jupyter/preferredRemoteKernelIdProvider.ts +++ b/src/kernels/jupyter/preferredRemoteKernelIdProvider.ts @@ -2,7 +2,8 @@ // Licensed under the MIT License. import { inject, injectable, named } from 'inversify'; -import cloneDeep from 'lodash/cloneDeep'; +/* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/no-require-imports */ +import cloneDeep = require('lodash/cloneDeep'); import { Memento, Uri } from 'vscode'; import { traceInfo, traceVerbose } from '../../platform/logging'; import { getDisplayPath } from '../../platform/common/platform/fs-paths'; diff --git a/src/kernels/jupyter/serverSelector.ts b/src/kernels/jupyter/serverSelector.ts index 79ad1da2c6f..f1ac8e0f334 100644 --- a/src/kernels/jupyter/serverSelector.ts +++ b/src/kernels/jupyter/serverSelector.ts @@ -4,7 +4,7 @@ 'use strict'; import { inject, injectable } from 'inversify'; -import isNil from 'lodash/isNil'; +import isNil = require('lodash/isNil'); import { EventEmitter, QuickPickItem, ThemeIcon, Uri } from 'vscode'; import { IApplicationShell, IClipboard } from '../../platform/common/application/types'; import { traceDecoratorError, traceError, traceWarning } from '../../platform/logging'; diff --git a/src/notebooks/controllers/remoteSwitcher.ts b/src/notebooks/controllers/remoteSwitcher.ts index af5d2a5f853..eef1ad33506 100644 --- a/src/notebooks/controllers/remoteSwitcher.ts +++ b/src/notebooks/controllers/remoteSwitcher.ts @@ -2,7 +2,7 @@ // Licensed under the MIT License. import { inject, injectable } from 'inversify'; -import noop from 'lodash/noop'; +import noop = require('lodash/noop'); import { StatusBarAlignment, StatusBarItem } from 'vscode'; import { IExtensionSingleActivationService } from '../../platform/activation/types'; import { diff --git a/src/notebooks/execution/notebookUpdater.ts b/src/notebooks/execution/notebookUpdater.ts index e61184fc9b0..6d263497f0e 100644 --- a/src/notebooks/execution/notebookUpdater.ts +++ b/src/notebooks/execution/notebookUpdater.ts @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -import noop from 'lodash/noop'; +import noop = require('lodash/noop'); import { isPromise } from 'rxjs/internal-compatibility'; import { NotebookDocument, NotebookEditor, workspace, WorkspaceEdit, window } from 'vscode'; import { createDeferred } from '../../platform/common/utils/async'; diff --git a/src/test/datascience/editor-integration/hoverProvider.vscode.test.ts b/src/test/datascience/editor-integration/hoverProvider.vscode.test.ts index b05843e616e..0473d1011e7 100644 --- a/src/test/datascience/editor-integration/hoverProvider.vscode.test.ts +++ b/src/test/datascience/editor-integration/hoverProvider.vscode.test.ts @@ -1,5 +1,5 @@ import { assert } from 'chai'; -import cloneDeep from 'lodash/cloneDeep'; +import cloneDeep = require('lodash/cloneDeep'); import * as sinon from 'sinon'; import * as path from '../../../platform/vscode-path/path'; import * as vscode from 'vscode'; diff --git a/src/test/datascience/helpers.ts b/src/test/datascience/helpers.ts index 8b24ff760b8..d390e036dd7 100644 --- a/src/test/datascience/helpers.ts +++ b/src/test/datascience/helpers.ts @@ -5,7 +5,7 @@ import * as vscode from 'vscode'; import { getFilePath } from '../../platform/common/platform/fs-paths'; import { traceInfo } from '../../platform/logging'; -import noop from 'lodash/noop'; +import noop = require('lodash/noop'); import { IPythonApiProvider } from '../../platform/api/types'; import { IJupyterSettings, Resource } from '../../platform/common/types'; import { InteractiveWindow } from '../../interactive-window/interactiveWindow'; diff --git a/src/test/datascience/mockCommandManager.ts b/src/test/datascience/mockCommandManager.ts index 29b561adf59..e0aafa6ef19 100644 --- a/src/test/datascience/mockCommandManager.ts +++ b/src/test/datascience/mockCommandManager.ts @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. 'use strict'; -import noop from 'lodash/noop'; +import noop = require('lodash/noop'); import { Disposable, TextEditor, TextEditorEdit } from 'vscode'; import { ICommandNameArgumentTypeMapping } from '../../platform/common/application/commands'; diff --git a/src/webviews/extension-side/dataviewer/dataViewerFactory.ts b/src/webviews/extension-side/dataviewer/dataViewerFactory.ts index c6a2d18f81c..16cba85de5e 100644 --- a/src/webviews/extension-side/dataviewer/dataViewerFactory.ts +++ b/src/webviews/extension-side/dataviewer/dataViewerFactory.ts @@ -7,7 +7,7 @@ import { inject, injectable } from 'inversify'; import { captureTelemetry } from '../../../telemetry'; import { IDataViewer, IDataViewerDataProvider, IDataViewerFactory } from './types'; -import debounce from 'lodash/debounce'; +import debounce = require('lodash/debounce'); import { ICommandManager } from '../../../platform/common/application/types'; import { ContextKey } from '../../../platform/common/contextKey'; import { IAsyncDisposable, IAsyncDisposableRegistry, IDisposableRegistry } from '../../../platform/common/types'; diff --git a/src/webviews/webview-side/data-explorer/mainPanel.tsx b/src/webviews/webview-side/data-explorer/mainPanel.tsx index d5a4e504885..9a6e601e465 100644 --- a/src/webviews/webview-side/data-explorer/mainPanel.tsx +++ b/src/webviews/webview-side/data-explorer/mainPanel.tsx @@ -16,7 +16,7 @@ import { generateTestData } from './testData'; import '../react-common/codicon/codicon.css'; import '../react-common/seti/seti.less'; import { SliceControl } from './sliceControl'; -import debounce from 'lodash/debounce'; +import debounce = require('lodash/debounce'); import * as uuid from 'uuid/v4'; import { initializeIcons } from '@fluentui/react'; From 83a8eda2ff74bd99598a0f0c2d88cae3258726f3 Mon Sep 17 00:00:00 2001 From: rebornix Date: Fri, 3 Jun 2022 16:58:21 -0700 Subject: [PATCH 5/5] Use direct import in webview. --- src/webviews/webview-side/data-explorer/mainPanel.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/webviews/webview-side/data-explorer/mainPanel.tsx b/src/webviews/webview-side/data-explorer/mainPanel.tsx index 9a6e601e465..d5a4e504885 100644 --- a/src/webviews/webview-side/data-explorer/mainPanel.tsx +++ b/src/webviews/webview-side/data-explorer/mainPanel.tsx @@ -16,7 +16,7 @@ import { generateTestData } from './testData'; import '../react-common/codicon/codicon.css'; import '../react-common/seti/seti.less'; import { SliceControl } from './sliceControl'; -import debounce = require('lodash/debounce'); +import debounce from 'lodash/debounce'; import * as uuid from 'uuid/v4'; import { initializeIcons } from '@fluentui/react';