@knip/language-server 2.0.1 → 2.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +3 -3
- package/src/diagnostics.js +9 -6
- package/src/server.js +18 -8
- package/src/types.d.ts +3 -0
package/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@knip/language-server",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.3",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/webpro-nl/knip.git",
|
|
7
7
|
"directory": "packages/language-server"
|
|
8
8
|
},
|
|
9
|
-
"type": "module",
|
|
10
9
|
"bin": {
|
|
11
10
|
"knip-language-server": "./src/cli.js"
|
|
12
11
|
},
|
|
12
|
+
"type": "module",
|
|
13
13
|
"exports": {
|
|
14
14
|
".": {
|
|
15
15
|
"types": "./src/types.d.ts",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"vscode-languageserver": "^9.0.1",
|
|
22
22
|
"vscode-languageserver-textdocument": "^1.0.12",
|
|
23
|
-
"knip": "^5.
|
|
23
|
+
"knip": "^5.87.0"
|
|
24
24
|
},
|
|
25
25
|
"engines": {
|
|
26
26
|
"node": ">=18.20.0"
|
package/src/diagnostics.js
CHANGED
|
@@ -8,6 +8,14 @@ import { DiagnosticSeverity, DiagnosticTag } from 'vscode-languageserver/node.js
|
|
|
8
8
|
* @import { Issue, Rules } from 'knip/session';
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
+
const dimmedIssueTypes = {
|
|
12
|
+
exports: 'dimExports',
|
|
13
|
+
types: 'dimTypes',
|
|
14
|
+
enumMembers: 'dimEnumMembers',
|
|
15
|
+
classMembers: 'dimClassMembers',
|
|
16
|
+
duplicates: 'dimDuplicates',
|
|
17
|
+
};
|
|
18
|
+
|
|
11
19
|
const SEVERITY = {
|
|
12
20
|
error: DiagnosticSeverity.Error,
|
|
13
21
|
warn: DiagnosticSeverity.Warning,
|
|
@@ -42,12 +50,7 @@ export const issueToDiagnostic = (issue, rules, config, document) => {
|
|
|
42
50
|
/** @type {DiagnosticTag[]} */
|
|
43
51
|
const tags = [];
|
|
44
52
|
|
|
45
|
-
if (issue.type
|
|
46
|
-
severity = DiagnosticSeverity.Hint;
|
|
47
|
-
tags.push(DiagnosticTag.Unnecessary);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
if (issue.type === 'types' && config.editor.exports.highlight.dimTypes) {
|
|
53
|
+
if (dimmedIssueTypes[issue.type] && config.editor.exports.highlight[dimmedIssueTypes[issue.type]]) {
|
|
51
54
|
severity = DiagnosticSeverity.Hint;
|
|
52
55
|
tags.push(DiagnosticTag.Unnecessary);
|
|
53
56
|
}
|
package/src/server.js
CHANGED
|
@@ -34,7 +34,13 @@ const DEFAULT_CONFIG = {
|
|
|
34
34
|
codelens: { enabled: true },
|
|
35
35
|
hover: { enabled: true, includeImportLocationSnippet: false, maxSnippets: 10, timeout: 300 },
|
|
36
36
|
quickfix: { enabled: true },
|
|
37
|
-
highlight: {
|
|
37
|
+
highlight: {
|
|
38
|
+
dimExports: false,
|
|
39
|
+
dimTypes: false,
|
|
40
|
+
dimEnumMembers: false,
|
|
41
|
+
dimClassMembers: false,
|
|
42
|
+
dimDuplicates: false,
|
|
43
|
+
},
|
|
38
44
|
},
|
|
39
45
|
},
|
|
40
46
|
imports: { enabled: true },
|
|
@@ -278,16 +284,20 @@ export class LanguageServer {
|
|
|
278
284
|
|
|
279
285
|
if (changes.length === 0) return;
|
|
280
286
|
|
|
281
|
-
|
|
287
|
+
try {
|
|
288
|
+
const result = await this.session.handleFileChanges(changes);
|
|
282
289
|
|
|
283
|
-
|
|
290
|
+
if (!result) return;
|
|
284
291
|
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
292
|
+
this.connection.console.log(
|
|
293
|
+
`Module graph updated (${Math.floor(result.duration)}ms • ${(result.mem / 1024 / 1024).toFixed(2)}M)`
|
|
294
|
+
);
|
|
288
295
|
|
|
289
|
-
|
|
290
|
-
|
|
296
|
+
const config = await this.getConfig();
|
|
297
|
+
this.publishDiagnostics(this.buildDiagnostics(this.session.getIssues().issues, config, this.rules));
|
|
298
|
+
} catch (_error) {
|
|
299
|
+
this.connection.console.error(`Error handling file changes: ${_error}`);
|
|
300
|
+
}
|
|
291
301
|
}
|
|
292
302
|
|
|
293
303
|
/**
|