Skip to content

Commit

Permalink
fix(vscode): Allow VsCode extension without espree detection
Browse files Browse the repository at this point in the history
  • Loading branch information
kpanot committed Dec 23, 2024
1 parent c8834dc commit 34533ca
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 79 deletions.
2 changes: 1 addition & 1 deletion .yarnrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ packageExtensions:
"@swc/types": "*"
"@typescript-eslint/rule-tester@*":
dependencies:
"@typescript-eslint/parser": ~8.17.0
"@typescript-eslint/parser": ~8.18.0
"@angular-eslint/eslint-plugin-template@*":
dependencies:
"@typescript-eslint/types": "^8.0.0"
Expand Down
1 change: 1 addition & 0 deletions apps/vscode-extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,7 @@
"@types/node": "^20.0.0",
"@types/vscode": "^1.67.0",
"@typescript-eslint/parser": "~8.18.0",
"@typescript-eslint/utils": "~8.18.0",
"@vscode/vsce": "^2.16.0",
"angular-eslint": "~18.4.0",
"cpy-cli": "^5.0.0",
Expand Down
4 changes: 3 additions & 1 deletion apps/vscode-extension/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {
commands,
ExtensionContext,
languages,
window,
} from 'vscode';
import {
extractAllToVariable,
Expand Down Expand Up @@ -60,10 +61,11 @@ import {
* @param context
*/
export function activate(context: ExtensionContext) {
const channel = window.createOutputChannel('Otter');
const designTokenProviders = designTokenCompletionItemAndHoverProviders();

context.subscriptions.push(
languages.registerCompletionItemProvider(['javascript', 'typescript'], configurationCompletionItemProvider(), configurationCompletionTriggerChar),
languages.registerCompletionItemProvider(['javascript', 'typescript'], configurationCompletionItemProvider({ channel }), configurationCompletionTriggerChar),
languages.registerCompletionItemProvider(['scss'], stylingCompletionItemProvider(), stylingCompletionTriggerChar),
languages.registerCompletionItemProvider(['scss', 'css'], designTokenProviders),
languages.registerHoverProvider(['scss', 'css'], designTokenProviders),
Expand Down
17 changes: 11 additions & 6 deletions apps/vscode-extension/src/intellisense/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {
CompletionItem,
CompletionItemKind,
CompletionItemProvider,
type OutputChannel,
SnippetString,
} from 'vscode';
import type {
Expand All @@ -11,9 +12,6 @@ import type {
import type {
TSESLint,
} from '@typescript-eslint/utils';
import {
ESLint,
} from 'eslint';

interface ConfigurationTags {
/** @see CompletionItem.documentation */
Expand Down Expand Up @@ -115,8 +113,15 @@ const getConfigurationTagsFromEslintConfig = (eslintConfig: TSESLint.FlatConfig.
};
};

export const configurationCompletionItemProvider = (): CompletionItemProvider<CompletionItem> => {
const eslint = new ESLint();
export const configurationCompletionItemProvider = (options: { channel: OutputChannel }): CompletionItemProvider<CompletionItem> => {
const eslint = import('eslint')
// eslint-disable-next-line @typescript-eslint/naming-convention -- External package defined name
.then(({ ESLint }) => new ESLint())
.catch((err) => {
options.channel.appendLine('error during EsLint loading');
options.channel.appendLine(JSON.stringify(err));
return undefined;
});

return {
provideCompletionItems: async (doc, pos) => {
Expand Down Expand Up @@ -150,7 +155,7 @@ export const configurationCompletionItemProvider = (): CompletionItemProvider<Co
return [];
}

const config = (await eslint.calculateConfigForFile(doc.fileName)) as TSESLint.FlatConfig.Config;
const config = (await (await eslint)?.calculateConfigForFile(doc.fileName) || {}) as TSESLint.FlatConfig.Config;
const configurationTags = getConfigurationTagsFromEslintConfig(config, match[0], fileText);

return getCompletionsItemsFromConfigurationTags(configurationTags);
Expand Down
2 changes: 1 addition & 1 deletion packages/@ama-sdk/schematics/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@
"@swc/helpers": "~0.5.0",
"@commitlint/cli": "^19.0.0",
"@commitlint/config-conventional": "^19.0.0",
"@typescript-eslint/eslint-plugin": "~8.17.0",
"@typescript-eslint/eslint-plugin": "~8.18.0",
"jest-junit": "~16.0.0",
"lint-staged": "^15.0.0",
"minimist": "^1.2.6",
Expand Down
6 changes: 3 additions & 3 deletions packages/@o3r/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,8 @@
"@o3r/store-sync": "workspace:^",
"@stylistic/eslint-plugin": "~2.7.0",
"@types/jest": "~29.5.2",
"@typescript-eslint/eslint-plugin": "~8.17.0",
"@typescript-eslint/parser": "~8.17.0",
"@typescript-eslint/eslint-plugin": "~8.18.0",
"@typescript-eslint/parser": "~8.18.0",
"angular-eslint": "~18.4.0",
"cpy-cli": "^5.0.0",
"eslint": "~9.14.0",
Expand All @@ -176,7 +176,7 @@
"jest-preset-angular": "~14.2.0",
"jsonc-eslint-parser": "~2.4.0",
"nx": "~19.8.0",
"typescript-eslint": "~8.17.0",
"typescript-eslint": "~8.18.0",
"zone.js": "~0.14.2"
},
"engines": {
Expand Down
6 changes: 3 additions & 3 deletions packages/@o3r/eslint-config-otter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@
"typescript": "^5.5.4"
},
"generatorDependencies": {
"@typescript-eslint/eslint-plugin": "~8.17.0",
"@typescript-eslint/parser": "~8.17.0",
"@typescript-eslint/utils": "~8.17.0",
"@typescript-eslint/eslint-plugin": "~8.18.0",
"@typescript-eslint/parser": "~8.18.0",
"@typescript-eslint/utils": "~8.18.0",
"eslint": "~9.14.0",
"eslint-plugin-jsdoc": "~50.2.0",
"eslint-plugin-unicorn": "^56.0.0"
Expand Down
65 changes: 1 addition & 64 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -14892,24 +14892,6 @@ __metadata:
languageName: node
linkType: hard

"@typescript-eslint/parser@npm:~8.17.0":
version: 8.17.0
resolution: "@typescript-eslint/parser@npm:8.17.0"
dependencies:
"@typescript-eslint/scope-manager": "npm:8.17.0"
"@typescript-eslint/types": "npm:8.17.0"
"@typescript-eslint/typescript-estree": "npm:8.17.0"
"@typescript-eslint/visitor-keys": "npm:8.17.0"
debug: "npm:^4.3.4"
peerDependencies:
eslint: ^8.57.0 || ^9.0.0
peerDependenciesMeta:
typescript:
optional: true
checksum: 10/464981e1424e4a7849ca7253b54092a67d33130d28ecf492efd56d5ce69e640a876b7f84e59f1e368e763125432c34e7de28d78c0eef1bda4e9a9d52de0ccac5
languageName: node
linkType: hard

"@typescript-eslint/rule-tester@npm:~8.18.0":
version: 8.18.1
resolution: "@typescript-eslint/rule-tester@npm:8.18.1"
Expand All @@ -14926,16 +14908,6 @@ __metadata:
languageName: node
linkType: hard

"@typescript-eslint/scope-manager@npm:8.17.0":
version: 8.17.0
resolution: "@typescript-eslint/scope-manager@npm:8.17.0"
dependencies:
"@typescript-eslint/types": "npm:8.17.0"
"@typescript-eslint/visitor-keys": "npm:8.17.0"
checksum: 10/fa934d9fd88070833c57a3e79c0f933d0b68884c00293a1d571889b882e5c9680ccfdc5c77a7160d5a4b8b46657f93db2468a4726a517fce4d3bc764b66f1995
languageName: node
linkType: hard

"@typescript-eslint/scope-manager@npm:8.18.1":
version: 8.18.1
resolution: "@typescript-eslint/scope-manager@npm:8.18.1"
Expand All @@ -14961,39 +14933,13 @@ __metadata:
languageName: node
linkType: hard

"@typescript-eslint/types@npm:8.17.0":
version: 8.17.0
resolution: "@typescript-eslint/types@npm:8.17.0"
checksum: 10/46baf69ab30dd814a390590b94ca64c407ac725cb0143590ddcaf72fa43c940cec180539752ce4af26ac7e0ae2f5f921cfd0d07b088ca680f8a28800d4d33a5f
languageName: node
linkType: hard

"@typescript-eslint/types@npm:8.18.1, @typescript-eslint/types@npm:^8.0.0":
version: 8.18.1
resolution: "@typescript-eslint/types@npm:8.18.1"
checksum: 10/57a6141ba17be929291a644991f3a76f94fce330376f6a079decb20fb53378d636ad6878f8f9b6fcb8244cf1ca8b118f9e8901ae04cf3de2aa9f9ff57791d97a
languageName: node
linkType: hard

"@typescript-eslint/typescript-estree@npm:8.17.0":
version: 8.17.0
resolution: "@typescript-eslint/typescript-estree@npm:8.17.0"
dependencies:
"@typescript-eslint/types": "npm:8.17.0"
"@typescript-eslint/visitor-keys": "npm:8.17.0"
debug: "npm:^4.3.4"
fast-glob: "npm:^3.3.2"
is-glob: "npm:^4.0.3"
minimatch: "npm:^9.0.4"
semver: "npm:^7.6.0"
ts-api-utils: "npm:^1.3.0"
peerDependenciesMeta:
typescript:
optional: true
checksum: 10/8a1f8be767b82e75d41eedda7fdb5135787ceaab480671b6d9891b5f92ee3a13f19ad6f48d5abf5e4f2afc4dd3317c621c1935505ef098f22b67be2f9d01ab7b
languageName: node
linkType: hard

"@typescript-eslint/typescript-estree@npm:8.18.1":
version: 8.18.1
resolution: "@typescript-eslint/typescript-estree@npm:8.18.1"
Expand Down Expand Up @@ -15027,16 +14973,6 @@ __metadata:
languageName: node
linkType: hard

"@typescript-eslint/visitor-keys@npm:8.17.0":
version: 8.17.0
resolution: "@typescript-eslint/visitor-keys@npm:8.17.0"
dependencies:
"@typescript-eslint/types": "npm:8.17.0"
eslint-visitor-keys: "npm:^4.2.0"
checksum: 10/e7a3c3b9430ecefb8e720f735f8a94f87901f055c75dc8eec60052dfdf90cc28dd33f03c11cd8244551dc988bf98d1db9bd09ef8fd3c51236912cab3680b9c6b
languageName: node
linkType: hard

"@typescript-eslint/visitor-keys@npm:8.18.1":
version: 8.18.1
resolution: "@typescript-eslint/visitor-keys@npm:8.18.1"
Expand Down Expand Up @@ -30025,6 +29961,7 @@ __metadata:
"@types/node": "npm:^20.0.0"
"@types/vscode": "npm:^1.67.0"
"@typescript-eslint/parser": "npm:~8.18.0"
"@typescript-eslint/utils": "npm:~8.18.0"
"@vscode/vsce": "npm:^2.16.0"
angular-eslint: "npm:~18.4.0"
cpy-cli: "npm:^5.0.0"
Expand Down

0 comments on commit 34533ca

Please sign in to comment.