Skip to content

Commit

Permalink
lint: fix runtime-import-check plugin (#11212)
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
vince-fugnitto authored May 27, 2022
1 parent cd1ed9a commit dbc5742
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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.`
Expand Down
2 changes: 1 addition & 1 deletion packages/debug/src/common/debug-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
3 changes: 1 addition & 2 deletions packages/debug/src/node/debug-service-impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion packages/variable-resolver/src/browser/variable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
23 changes: 23 additions & 0 deletions packages/variable-resolver/src/common/variable-types.ts
Original file line number Diff line number Diff line change
@@ -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
}

0 comments on commit dbc5742

Please sign in to comment.