From 2f432b42da0256b380bed28cea458607c090eb79 Mon Sep 17 00:00:00 2001 From: rebornix Date: Wed, 8 Jun 2022 11:36:30 -0700 Subject: [PATCH 1/2] Remove noop from external dependencies --- .eslintrc.js | 2 +- src/kernels/execution/notebookUpdater.ts | 2 +- src/notebooks/controllers/remoteSwitcher.ts | 2 +- src/platform/api/pythonApi.ts | 2 +- src/test/datascience/helpers.ts | 3 +-- src/test/datascience/mockCommandManager.ts | 2 +- src/test/datascience/raw-kernel/rawKernel.functional.test.ts | 1 - 7 files changed, 6 insertions(+), 8 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 69e0ca63b9d..91dafb7190d 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -265,7 +265,7 @@ module.exports = { ], 'react/jsx-uses-vars': 'error', 'react/jsx-uses-react': 'error', - 'no-restricted-imports': ['error', { paths: ['lodash', 'rxjs'] }], + 'no-restricted-imports': ['error', { paths: ['lodash', 'rxjs', 'lodash/noop'] }], 'import/no-restricted-paths': [ 'error', { diff --git a/src/kernels/execution/notebookUpdater.ts b/src/kernels/execution/notebookUpdater.ts index 6d263497f0e..b18b93c948b 100644 --- a/src/kernels/execution/notebookUpdater.ts +++ b/src/kernels/execution/notebookUpdater.ts @@ -1,10 +1,10 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -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'; +import { noop } from '../../platform/common/utils/misc'; /** * Use this class to perform updates on all cells. diff --git a/src/notebooks/controllers/remoteSwitcher.ts b/src/notebooks/controllers/remoteSwitcher.ts index 570dd8ecf9d..08a6fe95ecb 100644 --- a/src/notebooks/controllers/remoteSwitcher.ts +++ b/src/notebooks/controllers/remoteSwitcher.ts @@ -2,7 +2,6 @@ // Licensed under the MIT License. import { inject, injectable } from 'inversify'; -import noop = require('lodash/noop'); import { StatusBarAlignment, StatusBarItem } from 'vscode'; import { IExtensionSingleActivationService } from '../../platform/activation/types'; import { @@ -19,6 +18,7 @@ import { INotebookControllerManager } from '../types'; import { IJupyterServerUriStorage } from '../../kernels/jupyter/types'; import { Settings } from '../../platform/common/constants'; import { isJupyterNotebook } from '../../platform/common/utils'; +import { noop } from '../../platform/common/utils/misc'; @injectable() export class RemoteSwitcher implements IExtensionSingleActivationService { diff --git a/src/platform/api/pythonApi.ts b/src/platform/api/pythonApi.ts index 27f50c64493..6b4de5baed5 100644 --- a/src/platform/api/pythonApi.ts +++ b/src/platform/api/pythonApi.ts @@ -18,7 +18,6 @@ import { } from './types'; import * as localize from '../common/utils/localize'; import { injectable, inject } from 'inversify'; -import { noop } from 'rxjs/util/noop'; import { captureTelemetry, sendTelemetryEvent } from '../../telemetry'; import { IWorkspaceService, IApplicationShell, ICommandManager } from '../common/application/types'; import { isCI, PythonExtension, Telemetry } from '../common/constants'; @@ -30,6 +29,7 @@ import { IInterpreterSelector, IInterpreterQuickPickItem } from '../interpreter/ import { IInterpreterService } from '../interpreter/contracts'; import { areInterpreterPathsSame } from '../pythonEnvironments/info/interpreter'; import { TraceOptions } from '../logging/types'; +import { noop } from '../common/utils/misc'; export function deserializePythonEnvironment( pythonVersion: Partial | undefined diff --git a/src/test/datascience/helpers.ts b/src/test/datascience/helpers.ts index 42d0b4c04ca..1b9bc67e471 100644 --- a/src/test/datascience/helpers.ts +++ b/src/test/datascience/helpers.ts @@ -6,7 +6,6 @@ import { assert } from 'chai'; import * as vscode from 'vscode'; import { getFilePath } from '../../platform/common/platform/fs-paths'; import { traceInfo } from '../../platform/logging'; -import noop = require('lodash/noop'); import { IPythonApiProvider } from '../../platform/api/types'; import { IJupyterSettings, Resource } from '../../platform/common/types'; import { InteractiveWindow } from '../../interactive-window/interactiveWindow'; @@ -20,7 +19,7 @@ import { import { IDataScienceCodeLensProvider } from '../../interactive-window/editor-integration/types'; import { IInteractiveWindowProvider, IInteractiveWindow } from '../../interactive-window/types'; import { Commands } from '../../platform/common/constants'; -import { sleep } from '../core'; +import { noop, sleep } from '../core'; import { arePathsSame } from '../../platform/common/platform/fileUtils'; import { IS_REMOTE_NATIVE_TEST } from '../constants'; import { isWeb } from '../../platform/common/utils/misc'; diff --git a/src/test/datascience/mockCommandManager.ts b/src/test/datascience/mockCommandManager.ts index e0aafa6ef19..29730d0cdcd 100644 --- a/src/test/datascience/mockCommandManager.ts +++ b/src/test/datascience/mockCommandManager.ts @@ -1,11 +1,11 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. 'use strict'; -import noop = require('lodash/noop'); import { Disposable, TextEditor, TextEditorEdit } from 'vscode'; import { ICommandNameArgumentTypeMapping } from '../../platform/common/application/commands'; import { ICommandManager } from '../../platform/common/application/types'; +import { noop } from '../core'; /* eslint-disable @typescript-eslint/no-explicit-any, , no-multi-str, */ export class MockCommandManager implements ICommandManager { diff --git a/src/test/datascience/raw-kernel/rawKernel.functional.test.ts b/src/test/datascience/raw-kernel/rawKernel.functional.test.ts index 60e44b1db80..ac60fa15409 100644 --- a/src/test/datascience/raw-kernel/rawKernel.functional.test.ts +++ b/src/test/datascience/raw-kernel/rawKernel.functional.test.ts @@ -8,7 +8,6 @@ suite('Dummy13', () => { }); }); // import { assert } from 'chai'; -// import { noop } from 'jquery'; // import * as portfinder from 'portfinder'; // import * as uuid from 'uuid/v4'; // import { IPythonExtensionChecker } from '../../../platform/api/types'; From 8a80abe701528cd5f574ce542c2c075832c889b4 Mon Sep 17 00:00:00 2001 From: rebornix Date: Wed, 8 Jun 2022 13:09:31 -0700 Subject: [PATCH 2/2] update noop restricted import rule --- .eslintrc.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.eslintrc.js b/.eslintrc.js index 91dafb7190d..5eff2bcac4c 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -265,7 +265,7 @@ module.exports = { ], 'react/jsx-uses-vars': 'error', 'react/jsx-uses-react': 'error', - 'no-restricted-imports': ['error', { paths: ['lodash', 'rxjs', 'lodash/noop'] }], + 'no-restricted-imports': ['error', { paths: ['lodash', 'rxjs', 'lodash/noop', 'rxjs/util/noop'] }], 'import/no-restricted-paths': [ 'error', {