From dbc574288c95108581d15849df498625d0d81c18 Mon Sep 17 00:00:00 2001 From: Vincent Fugnitto Date: Fri, 27 May 2022 12:36:00 -0400 Subject: [PATCH] lint: fix `runtime-import-check` plugin (#11212) The commit fixes the `runtime-import-check` plugin which previously did not work well due to a recent change. The commit also fixes a `runtime-import-check` error present from `variable-resolver`. The previous interface `CommandIdVariables` was defined in `browser` but eventually used in `node`. The commit moves the interface to `common` so it is safely accessible for `browser` and `node`. Signed-off-by: vince-fugnitto --- .../rules/runtime-import-check.js | 4 +--- packages/debug/src/common/debug-service.ts | 2 +- packages/debug/src/node/debug-service-impl.ts | 3 +-- .../browser/debug/plugin-debug-service.ts | 2 +- .../src/browser/variable-resolver-service.ts | 9 +------- .../variable-resolver/src/browser/variable.ts | 2 +- .../src/common/variable-types.ts | 23 +++++++++++++++++++ 7 files changed, 29 insertions(+), 16 deletions(-) create mode 100644 packages/variable-resolver/src/common/variable-types.ts diff --git a/dev-packages/private-eslint-plugin/rules/runtime-import-check.js b/dev-packages/private-eslint-plugin/rules/runtime-import-check.js index c6e8797bf540a..c2d1d75549b17 100644 --- a/dev-packages/private-eslint-plugin/rules/runtime-import-check.js +++ b/dev-packages/private-eslint-plugin/rules/runtime-import-check.js @@ -108,9 +108,7 @@ module.exports = { }; function checkModuleImport(node) { const module = /** @type {string} */(node.value); - if (matchedImportRule.restricted.some( - restricted => restricted.includes(`/${restricted}/`) || restricted.endsWith(`/${restricted}`) - )) { + if (matchedImportRule.restricted.some(restricted => module.includes(`/${restricted}/`) || module.endsWith(`/${restricted}`))) { context.report({ node, message: `'${module}' cannot be imported in '${matchedFolder}', only '${matchedImportRule.allowed.join(', ')}' ${matchedImportRule.allowed.length === 1 ? 'is' : 'are'} allowed.` diff --git a/packages/debug/src/common/debug-service.ts b/packages/debug/src/common/debug-service.ts index 1a8ee9fce1e61..67b70d90387a9 100644 --- a/packages/debug/src/common/debug-service.ts +++ b/packages/debug/src/common/debug-service.ts @@ -19,7 +19,7 @@ import { Disposable } from '@theia/core'; import { ApplicationError } from '@theia/core/lib/common/application-error'; import { IJSONSchema, IJSONSchemaSnippet } from '@theia/core/lib/common/json-schema'; -import { CommandIdVariables } from '@theia/variable-resolver/lib/browser'; +import { CommandIdVariables } from '@theia/variable-resolver/lib/common/variable-types'; import { DebugConfiguration } from './debug-configuration'; export interface DebuggerDescription { diff --git a/packages/debug/src/node/debug-service-impl.ts b/packages/debug/src/node/debug-service-impl.ts index 8945aabd4099d..ef5290e93f1fe 100644 --- a/packages/debug/src/node/debug-service-impl.ts +++ b/packages/debug/src/node/debug-service-impl.ts @@ -17,9 +17,8 @@ import { injectable, inject } from '@theia/core/shared/inversify'; import { DebugConfiguration } from '../common/debug-configuration'; import { DebugService, DebuggerDescription } from '../common/debug-service'; - import { IJSONSchema, IJSONSchemaSnippet } from '@theia/core/lib/common/json-schema'; -import { CommandIdVariables } from '@theia/variable-resolver/lib/browser'; +import { CommandIdVariables } from '@theia/variable-resolver/lib/common/variable-types'; import { DebugAdapterSessionManager } from './debug-adapter-session-manager'; import { DebugAdapterContributionRegistry } from './debug-adapter-contribution-registry'; diff --git a/packages/plugin-ext/src/main/browser/debug/plugin-debug-service.ts b/packages/plugin-ext/src/main/browser/debug/plugin-debug-service.ts index df9d9b66513ea..5482f3c245089 100644 --- a/packages/plugin-ext/src/main/browser/debug/plugin-debug-service.ts +++ b/packages/plugin-ext/src/main/browser/debug/plugin-debug-service.ts @@ -23,7 +23,7 @@ import { PluginDebugConfigurationProvider } from './plugin-debug-configuration-p import { injectable, inject, postConstruct } from '@theia/core/shared/inversify'; import { WebSocketConnectionProvider } from '@theia/core/lib/browser/messaging/ws-connection-provider'; import { WorkspaceService } from '@theia/workspace/lib/browser'; -import { CommandIdVariables } from '@theia/variable-resolver/lib/browser'; +import { CommandIdVariables } from '@theia/variable-resolver/lib/common/variable-types'; import { DebugConfigurationProviderTriggerKind } from '../../../common/plugin-api-rpc'; import { DebuggerContribution } from '../../../common/plugin-protocol'; import { DebugRequestTypes } from '@theia/debug/lib/browser/debug-session-connection'; diff --git a/packages/variable-resolver/src/browser/variable-resolver-service.ts b/packages/variable-resolver/src/browser/variable-resolver-service.ts index f399809ee9c12..09ca8d659381e 100644 --- a/packages/variable-resolver/src/browser/variable-resolver-service.ts +++ b/packages/variable-resolver/src/browser/variable-resolver-service.ts @@ -20,14 +20,7 @@ import { injectable, inject } from '@theia/core/shared/inversify'; import { VariableRegistry } from './variable'; import URI from '@theia/core/lib/common/uri'; import { JSONExt, ReadonlyJSONValue } from '@theia/core/shared/@phosphor/coreutils'; - -/** - * Holds variable-names to command id mappings (e.g. Provided by specific plugins / extensions) - * see "variables": https://code.visualstudio.com/api/references/contribution-points#contributes.debuggers - */ -export interface CommandIdVariables { - [id: string]: string -} +import { CommandIdVariables } from '../common/variable-types'; export interface VariableResolveOptions { context?: URI; diff --git a/packages/variable-resolver/src/browser/variable.ts b/packages/variable-resolver/src/browser/variable.ts index a963399e1a8cc..43a1f16e75ac1 100644 --- a/packages/variable-resolver/src/browser/variable.ts +++ b/packages/variable-resolver/src/browser/variable.ts @@ -17,7 +17,7 @@ import { injectable } from '@theia/core/shared/inversify'; import { Disposable, DisposableCollection, MaybePromise } from '@theia/core'; import URI from '@theia/core/lib/common/uri'; -import { CommandIdVariables } from './variable-resolver-service'; +import { CommandIdVariables } from '../common/variable-types'; /** * Variable can be used inside of strings using ${variableName} syntax. diff --git a/packages/variable-resolver/src/common/variable-types.ts b/packages/variable-resolver/src/common/variable-types.ts new file mode 100644 index 0000000000000..08a2320e93607 --- /dev/null +++ b/packages/variable-resolver/src/common/variable-types.ts @@ -0,0 +1,23 @@ +// ***************************************************************************** +// Copyright (C) 2022 Ericsson and others. +// +// This program and the accompanying materials are made available under the +// terms of the Eclipse Public License v. 2.0 which is available at +// http://www.eclipse.org/legal/epl-2.0. +// +// This Source Code may also be made available under the following Secondary +// Licenses when the conditions for such availability set forth in the Eclipse +// Public License v. 2.0 are satisfied: GNU General Public License, version 2 +// with the GNU Classpath Exception which is available at +// https://www.gnu.org/software/classpath/license.html. +// +// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 +// ***************************************************************************** + +/** + * Holds variable-names to command id mappings (e.g. Provided by specific plugins / extensions) + * see "variables": https://code.visualstudio.com/api/references/contribution-points#contributes.debuggers + */ +export interface CommandIdVariables { + [id: string]: string +}