diff --git a/.vscode/settings.json b/.vscode/settings.json index c60272fe..3fbfce54 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -14,10 +14,10 @@ "typescript.tsc.autoDetect": "off", "typescript.tsserver.trace": "off", "typescript.tsserver.log": "off", - "eslint.enable": true, "editor.codeActionsOnSave": { "source.fixAll.eslint": true }, + "eslint.enable": true, "eslint.useESLintClass": true, "eslint.codeActionsOnSave.rules": [ "@typescript-eslint/semi", @@ -41,7 +41,11 @@ "eslintignore", "eslintr", "mydirectory", - "pnpm" + "onsave", + "pnpm", + "uinteger", + "Undispatched", + "unregistration" ], "task.allowAutomaticTasks": "on" } \ No newline at end of file diff --git a/client/package-lock.json b/client/package-lock.json index c94a3ac6..e3817a7e 100644 --- a/client/package-lock.json +++ b/client/package-lock.json @@ -9,7 +9,7 @@ "version": "2.2.5", "license": "MIT", "dependencies": { - "vscode-languageclient": "8.0.2" + "vscode-languageclient": "8.1.0-next.4" }, "devDependencies": { "@types/vscode": "1.68.0" @@ -25,24 +25,18 @@ "dev": true }, "node_modules/balanced-match": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", - "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=" + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==" }, "node_modules/brace-expansion": { - "version": "1.1.11", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", - "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", "dependencies": { - "balanced-match": "^1.0.0", - "concat-map": "0.0.1" + "balanced-match": "^1.0.0" } }, - "node_modules/concat-map": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", - "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=" - }, "node_modules/lru-cache": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", @@ -55,20 +49,20 @@ } }, "node_modules/minimatch": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", - "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.1.tgz", + "integrity": "sha512-362NP+zlprccbEt/SkxKfRMHnNY85V74mVnpUpNyr3F35covl09Kec7/sEFLt3RA4oXmewtoaanoIf67SE5Y5g==", "dependencies": { - "brace-expansion": "^1.1.7" + "brace-expansion": "^2.0.1" }, "engines": { - "node": "*" + "node": ">=10" } }, "node_modules/semver": { - "version": "7.3.5", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.5.tgz", - "integrity": "sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ==", + "version": "7.3.8", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.8.tgz", + "integrity": "sha512-NB1ctGL5rlHrPJtFDVIVzTyQylMLu9N9VICA6HSFJo8MCGVTMW6gfpicwKmmK/dAjTOrqu5l63JJOpDSrAis3A==", "dependencies": { "lru-cache": "^6.0.0" }, @@ -80,39 +74,39 @@ } }, "node_modules/vscode-jsonrpc": { - "version": "8.0.2", - "resolved": "https://registry.npmjs.org/vscode-jsonrpc/-/vscode-jsonrpc-8.0.2.tgz", - "integrity": "sha512-RY7HwI/ydoC1Wwg4gJ3y6LpU9FJRZAUnTYMXthqhFXXu77ErDd/xkREpGuk4MyYkk4a+XDWAMqe0S3KkelYQEQ==", + "version": "8.1.0-next.5", + "resolved": "https://registry.npmjs.org/vscode-jsonrpc/-/vscode-jsonrpc-8.1.0-next.5.tgz", + "integrity": "sha512-9l9lB8gXW1kPECKLC5Goc41pFztSCfODY3dvGaNTJ0KfRgwKIUyIhEBSdlWT2IU4uL4Tcl/zcitpb+Lj6QP7aQ==", "engines": { "node": ">=14.0.0" } }, "node_modules/vscode-languageclient": { - "version": "8.0.2", - "resolved": "https://registry.npmjs.org/vscode-languageclient/-/vscode-languageclient-8.0.2.tgz", - "integrity": "sha512-lHlthJtphG9gibGb/y72CKqQUxwPsMXijJVpHEC2bvbFqxmkj9LwQ3aGU9dwjBLqsX1S4KjShYppLvg1UJDF/Q==", + "version": "8.1.0-next.4", + "resolved": "https://registry.npmjs.org/vscode-languageclient/-/vscode-languageclient-8.1.0-next.4.tgz", + "integrity": "sha512-dwo3Vf1aAb3o62mDhLHRGqYaLAYWN5RXAbHKL85Cs+yCJghxYzseuGGBvOUOH3BF5scnCU2BFrghekyP1xCUmQ==", "dependencies": { - "minimatch": "^3.0.4", - "semver": "^7.3.5", - "vscode-languageserver-protocol": "3.17.2" + "minimatch": "^5.1.0", + "semver": "^7.3.7", + "vscode-languageserver-protocol": "3.17.3-next.4" }, "engines": { "vscode": "^1.67.0" } }, "node_modules/vscode-languageserver-protocol": { - "version": "3.17.2", - "resolved": "https://registry.npmjs.org/vscode-languageserver-protocol/-/vscode-languageserver-protocol-3.17.2.tgz", - "integrity": "sha512-8kYisQ3z/SQ2kyjlNeQxbkkTNmVFoQCqkmGrzLH6A9ecPlgTbp3wDTnUNqaUxYr4vlAcloxx8zwy7G5WdguYNg==", + "version": "3.17.3-next.4", + "resolved": "https://registry.npmjs.org/vscode-languageserver-protocol/-/vscode-languageserver-protocol-3.17.3-next.4.tgz", + "integrity": "sha512-G6XrjZGSe2LIo7uDa860JKX97sLKc1vQF4AU4SW8DI7NNVKxnCB+vEs8gYHmle7kD9v13PvFkDCBD5ApeONGNQ==", "dependencies": { - "vscode-jsonrpc": "8.0.2", - "vscode-languageserver-types": "3.17.2" + "vscode-jsonrpc": "8.1.0-next.5", + "vscode-languageserver-types": "3.17.3-next.1" } }, "node_modules/vscode-languageserver-types": { - "version": "3.17.2", - "resolved": "https://registry.npmjs.org/vscode-languageserver-types/-/vscode-languageserver-types-3.17.2.tgz", - "integrity": "sha512-zHhCWatviizPIq9B7Vh9uvrH6x3sK8itC84HkamnBWoDFJtzBf7SWlpLCZUit72b3os45h6RWQNC9xHRDF8dRA==" + "version": "3.17.3-next.1", + "resolved": "https://registry.npmjs.org/vscode-languageserver-types/-/vscode-languageserver-types-3.17.3-next.1.tgz", + "integrity": "sha512-i7HXZs5CdNibVHXZORZw9m5Bm0mfXiGhD/tZv6f7arBtz4iatgiiHu2qInxn0fKeahhMJoBbp6irhsL9+E3UAA==" }, "node_modules/yallist": { "version": "4.0.0", @@ -128,24 +122,18 @@ "dev": true }, "balanced-match": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", - "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=" + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==" }, "brace-expansion": { - "version": "1.1.11", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", - "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", "requires": { - "balanced-match": "^1.0.0", - "concat-map": "0.0.1" + "balanced-match": "^1.0.0" } }, - "concat-map": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", - "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=" - }, "lru-cache": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", @@ -155,49 +143,49 @@ } }, "minimatch": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", - "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.1.tgz", + "integrity": "sha512-362NP+zlprccbEt/SkxKfRMHnNY85V74mVnpUpNyr3F35covl09Kec7/sEFLt3RA4oXmewtoaanoIf67SE5Y5g==", "requires": { - "brace-expansion": "^1.1.7" + "brace-expansion": "^2.0.1" } }, "semver": { - "version": "7.3.5", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.5.tgz", - "integrity": "sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ==", + "version": "7.3.8", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.8.tgz", + "integrity": "sha512-NB1ctGL5rlHrPJtFDVIVzTyQylMLu9N9VICA6HSFJo8MCGVTMW6gfpicwKmmK/dAjTOrqu5l63JJOpDSrAis3A==", "requires": { "lru-cache": "^6.0.0" } }, "vscode-jsonrpc": { - "version": "8.0.2", - "resolved": "https://registry.npmjs.org/vscode-jsonrpc/-/vscode-jsonrpc-8.0.2.tgz", - "integrity": "sha512-RY7HwI/ydoC1Wwg4gJ3y6LpU9FJRZAUnTYMXthqhFXXu77ErDd/xkREpGuk4MyYkk4a+XDWAMqe0S3KkelYQEQ==" + "version": "8.1.0-next.5", + "resolved": "https://registry.npmjs.org/vscode-jsonrpc/-/vscode-jsonrpc-8.1.0-next.5.tgz", + "integrity": "sha512-9l9lB8gXW1kPECKLC5Goc41pFztSCfODY3dvGaNTJ0KfRgwKIUyIhEBSdlWT2IU4uL4Tcl/zcitpb+Lj6QP7aQ==" }, "vscode-languageclient": { - "version": "8.0.2", - "resolved": "https://registry.npmjs.org/vscode-languageclient/-/vscode-languageclient-8.0.2.tgz", - "integrity": "sha512-lHlthJtphG9gibGb/y72CKqQUxwPsMXijJVpHEC2bvbFqxmkj9LwQ3aGU9dwjBLqsX1S4KjShYppLvg1UJDF/Q==", + "version": "8.1.0-next.4", + "resolved": "https://registry.npmjs.org/vscode-languageclient/-/vscode-languageclient-8.1.0-next.4.tgz", + "integrity": "sha512-dwo3Vf1aAb3o62mDhLHRGqYaLAYWN5RXAbHKL85Cs+yCJghxYzseuGGBvOUOH3BF5scnCU2BFrghekyP1xCUmQ==", "requires": { - "minimatch": "^3.0.4", - "semver": "^7.3.5", - "vscode-languageserver-protocol": "3.17.2" + "minimatch": "^5.1.0", + "semver": "^7.3.7", + "vscode-languageserver-protocol": "3.17.3-next.4" } }, "vscode-languageserver-protocol": { - "version": "3.17.2", - "resolved": "https://registry.npmjs.org/vscode-languageserver-protocol/-/vscode-languageserver-protocol-3.17.2.tgz", - "integrity": "sha512-8kYisQ3z/SQ2kyjlNeQxbkkTNmVFoQCqkmGrzLH6A9ecPlgTbp3wDTnUNqaUxYr4vlAcloxx8zwy7G5WdguYNg==", + "version": "3.17.3-next.4", + "resolved": "https://registry.npmjs.org/vscode-languageserver-protocol/-/vscode-languageserver-protocol-3.17.3-next.4.tgz", + "integrity": "sha512-G6XrjZGSe2LIo7uDa860JKX97sLKc1vQF4AU4SW8DI7NNVKxnCB+vEs8gYHmle7kD9v13PvFkDCBD5ApeONGNQ==", "requires": { - "vscode-jsonrpc": "8.0.2", - "vscode-languageserver-types": "3.17.2" + "vscode-jsonrpc": "8.1.0-next.5", + "vscode-languageserver-types": "3.17.3-next.1" } }, "vscode-languageserver-types": { - "version": "3.17.2", - "resolved": "https://registry.npmjs.org/vscode-languageserver-types/-/vscode-languageserver-types-3.17.2.tgz", - "integrity": "sha512-zHhCWatviizPIq9B7Vh9uvrH6x3sK8itC84HkamnBWoDFJtzBf7SWlpLCZUit72b3os45h6RWQNC9xHRDF8dRA==" + "version": "3.17.3-next.1", + "resolved": "https://registry.npmjs.org/vscode-languageserver-types/-/vscode-languageserver-types-3.17.3-next.1.tgz", + "integrity": "sha512-i7HXZs5CdNibVHXZORZw9m5Bm0mfXiGhD/tZv6f7arBtz4iatgiiHu2qInxn0fKeahhMJoBbp6irhsL9+E3UAA==" }, "yallist": { "version": "4.0.0", diff --git a/client/package.json b/client/package.json index 1ef66bde..78df717d 100644 --- a/client/package.json +++ b/client/package.json @@ -20,7 +20,7 @@ "@types/vscode": "1.68.0" }, "dependencies": { - "vscode-languageclient": "8.0.2" + "vscode-languageclient": "8.1.0-next.4" }, "scripts": { "test": "node ../node_modules/mocha/bin/_mocha", diff --git a/client/src/client.ts b/client/src/client.ts index b91f3c9b..ca27be03 100644 --- a/client/src/client.ts +++ b/client/src/client.ts @@ -8,13 +8,14 @@ import * as path from 'path'; import { workspace as Workspace, window as Window, languages as Languages, Uri, TextDocument, CodeActionContext, Diagnostic, ProviderResult, - Command, CodeAction, MessageItem, ConfigurationTarget, env as Env, CodeActionKind, WorkspaceConfiguration, NotebookCell, commands, ExtensionContext, StatusBarAlignment, ThemeColor + Command, CodeAction, MessageItem, ConfigurationTarget, env as Env, CodeActionKind, WorkspaceConfiguration, NotebookCell, commands, + ExtensionContext, LanguageStatusItem, LanguageStatusSeverity, DocumentFilter as VDocumentFilter } from 'vscode'; import { - LanguageClient, LanguageClientOptions, TransportKind, ErrorHandler, ErrorHandlerResult, CloseAction, CloseHandlerResult, - RevealOutputChannelOn, ServerOptions, DocumentFilter, DidCloseTextDocumentNotification, DidOpenTextDocumentNotification, - State, VersionedTextDocumentIdentifier, ExecuteCommandParams, ExecuteCommandRequest, ConfigurationParams, NotebookDocumentSyncRegistrationType + LanguageClient, LanguageClientOptions, TransportKind, ErrorHandler, CloseAction, RevealOutputChannelOn, ServerOptions, DocumentFilter, + DidCloseTextDocumentNotification, DidOpenTextDocumentNotification, State, VersionedTextDocumentIdentifier, ExecuteCommandParams, + ExecuteCommandRequest, ConfigurationParams, NotebookDocumentSyncRegistrationType } from 'vscode-languageclient/node'; import { LegacyDirectoryItem, Migration, PatternItem, ValidateItem } from './settings'; @@ -141,15 +142,15 @@ export namespace ESLintClient { let notNow: boolean = false; // The client's status bar item. - const statusBarItem = Window.createStatusBarItem('generalStatus', StatusBarAlignment.Right, 0); + const languageStatus: LanguageStatusItem = Languages.createLanguageStatusItem('eslint.languageStatusItem', []); let serverRunning: boolean | undefined; const starting = 'ESLint server is starting.'; const running = 'ESLint server is running.'; const stopped = 'ESLint server stopped.'; - statusBarItem.name = 'ESLint'; - statusBarItem.text = 'ESLint'; - statusBarItem.command = 'eslint.showOutputChannel'; + languageStatus.name = 'ESLint'; + languageStatus.text = 'ESLint'; + languageStatus.command = { title: 'Open ESLint Output', command: 'eslint.showOutputChannel' }; const documentStatus: Map = new Map(); // If the workspace configuration changes we need to update the synced documents since the @@ -314,7 +315,7 @@ export namespace ESLintClient { client.onDidChangeState((event) => { if (event.newState === State.Starting) { - client.info('ESLint server is starting'); + client.info(starting); serverRunning = undefined; } else if (event.newState === State.Running) { client.info(running); @@ -333,6 +334,7 @@ export namespace ESLintClient { Workspace.onDidCloseTextDocument((document) => { const uri = document.uri.toString(); documentStatus.delete(uri); + updateLanguageStatusSelector(); updateStatusBar(undefined); }), commands.registerCommand('eslint.executeAutofix', async () => { @@ -413,10 +415,10 @@ export namespace ESLintClient { return false; }, errorHandler: { - error: (error, message, count): ErrorHandlerResult => { + error: (error, message, count) => { return defaultErrorHandler.error(error, message, count); }, - closed: (): CloseHandlerResult => { + closed: () => { if (serverCalledProcessExit) { return { action: CloseAction.DoNotRestart }; } @@ -428,6 +430,7 @@ export namespace ESLintClient { if (Languages.match(packageJsonFilter, document) || Languages.match(configFileFilter, document) || validator.check(document) !== Validate.off) { const result = next(document); syncedDocuments.set(document.uri.toString(), document); + return result; } }, @@ -766,10 +769,29 @@ export namespace ESLintClient { } function updateDocumentStatus(params: StatusParams): void { + const needsUpdate = !documentStatus.has(params.uri); documentStatus.set(params.uri, params.state); + if (needsUpdate) { + updateLanguageStatusSelector(); + } updateStatusBar(params.uri); } + function updateLanguageStatusSelector(): void { + const selector: VDocumentFilter[] = []; + for (const key of documentStatus.keys()) { + const uri: Uri = Uri.parse(key); + const document = syncedDocuments.get(key); + const filter: VDocumentFilter = { + scheme: uri.scheme, + pattern: uri.fsPath, + language: document?.languageId + }; + selector.push(filter); + } + languageStatus.selector = selector; + } + function updateStatusBar(uri: string | undefined) { const status = function() { if (serverRunning === false) { @@ -780,38 +802,20 @@ export namespace ESLintClient { } return (uri !== undefined ? documentStatus.get(uri) : undefined) ?? Status.ok; }(); - let icon: string| undefined; - let tooltip: string | undefined; let text: string = 'ESLint'; - let backgroundColor: ThemeColor | undefined; - let foregroundColor: ThemeColor | undefined; + let severity: LanguageStatusSeverity = LanguageStatusSeverity.Information; switch (status) { case Status.ok: - icon = undefined; - foregroundColor = new ThemeColor('statusBarItem.foreground'); - backgroundColor = new ThemeColor('statusBarItem.background'); break; case Status.warn: - icon = '$(alert)'; - foregroundColor = new ThemeColor('statusBarItem.warningForeground'); - backgroundColor = new ThemeColor('statusBarItem.warningBackground'); + severity = LanguageStatusSeverity.Warning; break; case Status.error: - icon = '$(issue-opened)'; - foregroundColor = new ThemeColor('statusBarItem.errorForeground'); - backgroundColor = new ThemeColor('statusBarItem.errorBackground'); + severity = LanguageStatusSeverity.Error; break; } - statusBarItem.text = icon !== undefined ? `${icon} ${text}` : text; - statusBarItem.color = foregroundColor; - statusBarItem.backgroundColor = backgroundColor; - statusBarItem.tooltip = tooltip ? tooltip : serverRunning === undefined ? starting : serverRunning === true ? running : stopped; - const alwaysShow = Workspace.getConfiguration('eslint').get('alwaysShowStatus', false); - if (alwaysShow || status !== Status.ok) { - statusBarItem.show(); - } else { - statusBarItem.hide(); - } + languageStatus.text = text; + languageStatus.severity = severity; } } } \ No newline at end of file diff --git a/package.json b/package.json index 92ae787f..c3c688cd 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "vscode-eslint", "displayName": "ESLint", "description": "Integrates ESLint JavaScript into VS Code.", - "version": "2.3.0", + "version": "2.3.1", "author": "Microsoft Corporation", "license": "MIT", "repository": { diff --git a/playgrounds/8.0/.vscode/settings.json b/playgrounds/8.0/.vscode/settings.json index f834099b..94b1e8c5 100644 --- a/playgrounds/8.0/.vscode/settings.json +++ b/playgrounds/8.0/.vscode/settings.json @@ -12,7 +12,7 @@ ], "eslint.packageManager": "yarn", "eslint.trace.server": { - "verbosity": "messages", + "verbosity": "off", "format": "text" }, "files.autoSave": "off", diff --git a/server/package-lock.json b/server/package-lock.json index 20c4798d..6cb14cfe 100644 --- a/server/package-lock.json +++ b/server/package-lock.json @@ -9,7 +9,7 @@ "version": "2.2.5", "license": "MIT", "dependencies": { - "vscode-languageserver": "8.0.2", + "vscode-languageserver": "8.1.0-next.4", "vscode-languageserver-textdocument": "1.0.5", "vscode-uri": "^3.0.3" }, @@ -18,31 +18,31 @@ } }, "node_modules/vscode-jsonrpc": { - "version": "8.0.2", - "resolved": "https://registry.npmjs.org/vscode-jsonrpc/-/vscode-jsonrpc-8.0.2.tgz", - "integrity": "sha512-RY7HwI/ydoC1Wwg4gJ3y6LpU9FJRZAUnTYMXthqhFXXu77ErDd/xkREpGuk4MyYkk4a+XDWAMqe0S3KkelYQEQ==", + "version": "8.1.0-next.5", + "resolved": "https://registry.npmjs.org/vscode-jsonrpc/-/vscode-jsonrpc-8.1.0-next.5.tgz", + "integrity": "sha512-9l9lB8gXW1kPECKLC5Goc41pFztSCfODY3dvGaNTJ0KfRgwKIUyIhEBSdlWT2IU4uL4Tcl/zcitpb+Lj6QP7aQ==", "engines": { "node": ">=14.0.0" } }, "node_modules/vscode-languageserver": { - "version": "8.0.2", - "resolved": "https://registry.npmjs.org/vscode-languageserver/-/vscode-languageserver-8.0.2.tgz", - "integrity": "sha512-bpEt2ggPxKzsAOZlXmCJ50bV7VrxwCS5BI4+egUmure/oI/t4OlFzi/YNtVvY24A2UDOZAgwFGgnZPwqSJubkA==", + "version": "8.1.0-next.4", + "resolved": "https://registry.npmjs.org/vscode-languageserver/-/vscode-languageserver-8.1.0-next.4.tgz", + "integrity": "sha512-W+sdV5sgOTgE1bmEBdCrCpjfYIwD7f0ykwoPOTkvaNFdsgbMIvq4VZLjGMVnFR7U2tPa/w0Kn7lXodlSJudNmQ==", "dependencies": { - "vscode-languageserver-protocol": "3.17.2" + "vscode-languageserver-protocol": "3.17.3-next.4" }, "bin": { "installServerIntoExtension": "bin/installServerIntoExtension" } }, "node_modules/vscode-languageserver-protocol": { - "version": "3.17.2", - "resolved": "https://registry.npmjs.org/vscode-languageserver-protocol/-/vscode-languageserver-protocol-3.17.2.tgz", - "integrity": "sha512-8kYisQ3z/SQ2kyjlNeQxbkkTNmVFoQCqkmGrzLH6A9ecPlgTbp3wDTnUNqaUxYr4vlAcloxx8zwy7G5WdguYNg==", + "version": "3.17.3-next.4", + "resolved": "https://registry.npmjs.org/vscode-languageserver-protocol/-/vscode-languageserver-protocol-3.17.3-next.4.tgz", + "integrity": "sha512-G6XrjZGSe2LIo7uDa860JKX97sLKc1vQF4AU4SW8DI7NNVKxnCB+vEs8gYHmle7kD9v13PvFkDCBD5ApeONGNQ==", "dependencies": { - "vscode-jsonrpc": "8.0.2", - "vscode-languageserver-types": "3.17.2" + "vscode-jsonrpc": "8.1.0-next.5", + "vscode-languageserver-types": "3.17.3-next.1" } }, "node_modules/vscode-languageserver-textdocument": { @@ -51,9 +51,9 @@ "integrity": "sha512-1ah7zyQjKBudnMiHbZmxz5bYNM9KKZYz+5VQLj+yr8l+9w3g+WAhCkUkWbhMEdC5u0ub4Ndiye/fDyS8ghIKQg==" }, "node_modules/vscode-languageserver-types": { - "version": "3.17.2", - "resolved": "https://registry.npmjs.org/vscode-languageserver-types/-/vscode-languageserver-types-3.17.2.tgz", - "integrity": "sha512-zHhCWatviizPIq9B7Vh9uvrH6x3sK8itC84HkamnBWoDFJtzBf7SWlpLCZUit72b3os45h6RWQNC9xHRDF8dRA==" + "version": "3.17.3-next.1", + "resolved": "https://registry.npmjs.org/vscode-languageserver-types/-/vscode-languageserver-types-3.17.3-next.1.tgz", + "integrity": "sha512-i7HXZs5CdNibVHXZORZw9m5Bm0mfXiGhD/tZv6f7arBtz4iatgiiHu2qInxn0fKeahhMJoBbp6irhsL9+E3UAA==" }, "node_modules/vscode-uri": { "version": "3.0.3", @@ -63,25 +63,25 @@ }, "dependencies": { "vscode-jsonrpc": { - "version": "8.0.2", - "resolved": "https://registry.npmjs.org/vscode-jsonrpc/-/vscode-jsonrpc-8.0.2.tgz", - "integrity": "sha512-RY7HwI/ydoC1Wwg4gJ3y6LpU9FJRZAUnTYMXthqhFXXu77ErDd/xkREpGuk4MyYkk4a+XDWAMqe0S3KkelYQEQ==" + "version": "8.1.0-next.5", + "resolved": "https://registry.npmjs.org/vscode-jsonrpc/-/vscode-jsonrpc-8.1.0-next.5.tgz", + "integrity": "sha512-9l9lB8gXW1kPECKLC5Goc41pFztSCfODY3dvGaNTJ0KfRgwKIUyIhEBSdlWT2IU4uL4Tcl/zcitpb+Lj6QP7aQ==" }, "vscode-languageserver": { - "version": "8.0.2", - "resolved": "https://registry.npmjs.org/vscode-languageserver/-/vscode-languageserver-8.0.2.tgz", - "integrity": "sha512-bpEt2ggPxKzsAOZlXmCJ50bV7VrxwCS5BI4+egUmure/oI/t4OlFzi/YNtVvY24A2UDOZAgwFGgnZPwqSJubkA==", + "version": "8.1.0-next.4", + "resolved": "https://registry.npmjs.org/vscode-languageserver/-/vscode-languageserver-8.1.0-next.4.tgz", + "integrity": "sha512-W+sdV5sgOTgE1bmEBdCrCpjfYIwD7f0ykwoPOTkvaNFdsgbMIvq4VZLjGMVnFR7U2tPa/w0Kn7lXodlSJudNmQ==", "requires": { - "vscode-languageserver-protocol": "3.17.2" + "vscode-languageserver-protocol": "3.17.3-next.4" } }, "vscode-languageserver-protocol": { - "version": "3.17.2", - "resolved": "https://registry.npmjs.org/vscode-languageserver-protocol/-/vscode-languageserver-protocol-3.17.2.tgz", - "integrity": "sha512-8kYisQ3z/SQ2kyjlNeQxbkkTNmVFoQCqkmGrzLH6A9ecPlgTbp3wDTnUNqaUxYr4vlAcloxx8zwy7G5WdguYNg==", + "version": "3.17.3-next.4", + "resolved": "https://registry.npmjs.org/vscode-languageserver-protocol/-/vscode-languageserver-protocol-3.17.3-next.4.tgz", + "integrity": "sha512-G6XrjZGSe2LIo7uDa860JKX97sLKc1vQF4AU4SW8DI7NNVKxnCB+vEs8gYHmle7kD9v13PvFkDCBD5ApeONGNQ==", "requires": { - "vscode-jsonrpc": "8.0.2", - "vscode-languageserver-types": "3.17.2" + "vscode-jsonrpc": "8.1.0-next.5", + "vscode-languageserver-types": "3.17.3-next.1" } }, "vscode-languageserver-textdocument": { @@ -90,9 +90,9 @@ "integrity": "sha512-1ah7zyQjKBudnMiHbZmxz5bYNM9KKZYz+5VQLj+yr8l+9w3g+WAhCkUkWbhMEdC5u0ub4Ndiye/fDyS8ghIKQg==" }, "vscode-languageserver-types": { - "version": "3.17.2", - "resolved": "https://registry.npmjs.org/vscode-languageserver-types/-/vscode-languageserver-types-3.17.2.tgz", - "integrity": "sha512-zHhCWatviizPIq9B7Vh9uvrH6x3sK8itC84HkamnBWoDFJtzBf7SWlpLCZUit72b3os45h6RWQNC9xHRDF8dRA==" + "version": "3.17.3-next.1", + "resolved": "https://registry.npmjs.org/vscode-languageserver-types/-/vscode-languageserver-types-3.17.3-next.1.tgz", + "integrity": "sha512-i7HXZs5CdNibVHXZORZw9m5Bm0mfXiGhD/tZv6f7arBtz4iatgiiHu2qInxn0fKeahhMJoBbp6irhsL9+E3UAA==" }, "vscode-uri": { "version": "3.0.3", diff --git a/server/package.json b/server/package.json index 45730d3d..5414abdf 100644 --- a/server/package.json +++ b/server/package.json @@ -15,7 +15,7 @@ "node": "*" }, "dependencies": { - "vscode-languageserver": "8.0.2", + "vscode-languageserver": "8.1.0-next.4", "vscode-languageserver-textdocument": "1.0.5", "vscode-uri": "^3.0.3" }, diff --git a/server/src/eslint.ts b/server/src/eslint.ts index 2f4a563c..111b28a7 100644 --- a/server/src/eslint.ts +++ b/server/src/eslint.ts @@ -15,7 +15,7 @@ import { } from 'vscode-languageserver/node'; import { URI } from 'vscode-uri'; -import { ProbeFailedParams, ProbeFailedRequest, NoESLintLibraryRequest, Status, ShowOutputChannel, NoConfigRequest } from './shared/customMessages'; +import { ProbeFailedParams, ProbeFailedRequest, NoESLintLibraryRequest, Status, NoConfigRequest } from './shared/customMessages'; import { ConfigurationSettings, DirectoryItem, ESLintSeverity, ModeEnum, ModeItem, PackageManagers, RuleCustomization, RuleSeverity, Validate } from './shared/settings'; import * as Is from './is'; @@ -506,7 +506,7 @@ export namespace SaveRuleConfigs { } /** - * Manages rule serverity overrides done using VS Code settings. + * Manages rule severity overrides done using VS Code settings. */ export namespace RuleSeverities { @@ -547,7 +547,7 @@ export namespace RuleSeverities { /** - * Creates LSP Diagnostis and captures code action information. + * Creates LSP Diagnostics and captures code action information. */ namespace Diagnostics { @@ -977,25 +977,28 @@ export namespace ESLint { void connection.sendRequest(ProbeFailedRequest.type, params); } } - if (settings.format && settings.validate === Validate.on && TextDocumentSettings.hasLibrary(settings)) { - const Uri = URI.parse(uri); - const isFile = Uri.scheme === 'file'; - let pattern: string = isFile - ? Uri.fsPath.replace(/\\/g, '/') - : Uri.fsPath; - pattern = pattern.replace(/[\[\]\{\}]/g, '?'); - - const filter: DocumentFilter = { scheme: Uri.scheme, pattern: pattern }; - const options: DocumentFormattingRegistrationOptions = { documentSelector: [filter] }; - if (!isFile) { - formatterRegistrations.set(uri, connection.client.register(DocumentFormattingRequest.type, options)); - } else { - const filePath = inferFilePath(uri)!; - await ESLint.withClass(async (eslintClass) => { - if (!await eslintClass.isPathIgnored(filePath)) { - formatterRegistrations.set(uri, connection.client.register(DocumentFormattingRequest.type, options)); - } - }, settings); + if (settings.validate === Validate.on) { + settings.silent = false; + if (settings.format && TextDocumentSettings.hasLibrary(settings)) { + const Uri = URI.parse(uri); + const isFile = Uri.scheme === 'file'; + let pattern: string = isFile + ? Uri.fsPath.replace(/\\/g, '/') + : Uri.fsPath; + pattern = pattern.replace(/[\[\]\{\}]/g, '?'); + + const filter: DocumentFilter = { scheme: Uri.scheme, pattern: pattern }; + const options: DocumentFormattingRegistrationOptions = { documentSelector: [filter] }; + if (!isFile) { + formatterRegistrations.set(uri, connection.client.register(DocumentFormattingRequest.type, options)); + } else { + const filePath = inferFilePath(uri)!; + await ESLint.withClass(async (eslintClass) => { + if (!await eslintClass.isPathIgnored(filePath)) { + formatterRegistrations.set(uri, connection.client.register(DocumentFormattingRequest.type, options)); + } + }, settings); + } } } return settings; @@ -1213,7 +1216,7 @@ export namespace ESLint { const noConfigReported: Map = new Map(); - export function clearNoConfigRepoerted(): void { + export function clearNoConfigReported(): void { noConfigReported.clear(); } @@ -1325,29 +1328,12 @@ export namespace ESLint { return undefined; } - const ignoredErrors: Set = new Set(); function showErrorMessage(error: any, document: TextDocument): Status { - const errorMessage = `ESLint: ${getMessage(error, document)}. Please see the 'ESLint' output channel for details.`; - const actions = [ - { title: 'Open Output', id: 1}, - { title: 'Ignore for this Session', id: 2} - ]; - if (!ignoredErrors.has(errorMessage)) { - void connection.window.showErrorMessage(errorMessage, ...actions).then((value) => { - if (value !== undefined) { - if (value.id === 1) { - void connection.sendNotification(ShowOutputChannel.type); - } else if (value.id === 2) { - ignoredErrors.add(errorMessage); - } - } - }); - } else { - connection.console.error(errorMessage); - } if (Is.string(error.stack)) { - connection.console.error('ESLint stack trace:'); + connection.console.error('An unexpected error occurred:'); connection.console.error(error.stack); + } else { + connection.console.error(`An unexpected error occurred: ${getMessage(error, document)}.`); } return Status.error; } diff --git a/server/src/eslintServer.ts b/server/src/eslintServer.ts index aa9b5400..c541f5d3 100644 --- a/server/src/eslintServer.ts +++ b/server/src/eslintServer.ts @@ -36,7 +36,7 @@ import LanguageDefaults from './languageDefaults'; // canceled. const connection: ProposedFeatures.Connection = createConnection(ProposedFeatures.all, { cancelUndispatched: (message: LMessage) => { - // Code actions can savely be cancel on request. + // Code actions can safely be cancel on request. if (LMessage.isRequest(message) && message.method === 'textDocument/codeAction') { const response: LResponseMessage = { jsonrpc: message.jsonrpc, @@ -153,7 +153,7 @@ ESLint.initialize(connection, documents, inferFilePath, loadNodeModule); SaveRuleConfigs.inferFilePath = inferFilePath; /** - * Special message queue implementatin to be able to invalidate requests. + * Special message queue implementation to be able to invalidate requests. * No necessary anymore when using diagnostic pull mode */ @@ -488,7 +488,7 @@ messageQueue.registerNotification(DidChangeWatchedFilesNotification.type, async // A .eslintrc has change. No smartness here. // Simply revalidate all file. RuleMetaData.clear(); - ESLint.ErrorHandlers.clearNoConfigRepoerted(); + ESLint.ErrorHandlers.clearNoConfigReported(); ESLint.ErrorHandlers.clearMissingModuleReported(); ESLint.clearSettings(); // config files can change plugins and parser. RuleSeverities.clear(); @@ -775,12 +775,12 @@ messageQueue.registerRequest(CodeActionRequest.type, async (params) => { const isSourceFixAll = (only === ESLintSourceFixAll || only === CodeActionKind.SourceFixAll); if (isSourceFixAll || isSource) { if (isSourceFixAll) { - const textDocumentIdentifer: VersionedTextDocumentIdentifier = { uri: textDocument.uri, version: textDocument.version }; - const edits = await computeAllFixes(textDocumentIdentifer, AllFixesMode.onSave); + const textDocumentIdentifier: VersionedTextDocumentIdentifier = { uri: textDocument.uri, version: textDocument.version }; + const edits = await computeAllFixes(textDocumentIdentifier, AllFixesMode.onSave); if (edits !== undefined) { result.fixAll.push(CodeAction.create( `Fix all fixable ESLint issues`, - { documentChanges: [ TextDocumentEdit.create(textDocumentIdentifer, edits )]}, + { documentChanges: [ TextDocumentEdit.create(textDocumentIdentifier, edits )]}, ESLintSourceFixAll )); }