@knip/language-server 1.0.0 → 1.1.1

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@knip/language-server",
3
- "version": "1.0.0",
3
+ "version": "1.1.1",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -12,7 +12,7 @@
12
12
  "dependencies": {
13
13
  "vscode-languageserver": "^9.0.1",
14
14
  "vscode-languageserver-textdocument": "^1.0.12",
15
- "knip": "^5.80.1"
15
+ "knip": "^5.82.0"
16
16
  },
17
17
  "engines": {
18
18
  "node": ">=18.18.0"
package/src/constants.js CHANGED
@@ -12,4 +12,6 @@ export const REQUEST_PACKAGE_JSON = 'knip.getPackageJson';
12
12
 
13
13
  export const REQUEST_RESULTS = 'knip.getResults';
14
14
 
15
+ export const NOTIFICATION_MODULE_GRAPH_BUILT = 'knip.moduleGraphBuilt';
16
+
15
17
  export const SESSION_LOADING = 'session-loading';
package/src/server.js CHANGED
@@ -12,6 +12,7 @@ import {
12
12
  } from './code-actions.js';
13
13
  import {
14
14
  DEFAULT_JSDOC_TAGS,
15
+ NOTIFICATION_MODULE_GRAPH_BUILT,
15
16
  REQUEST_FILE_NODE,
16
17
  REQUEST_PACKAGE_JSON,
17
18
  REQUEST_RESTART,
@@ -195,6 +196,7 @@ export class LanguageServer {
195
196
 
196
197
  this.session = session;
197
198
  this.publishDiagnostics(this.buildDiagnostics(session.getIssues().issues, config, this.rules));
199
+ this.connection.sendNotification(NOTIFICATION_MODULE_GRAPH_BUILT, { duration: Date.now() - start });
198
200
  } catch (_error) {
199
201
  this.connection.console.error(`Error: ${_error}`);
200
202
  }
@@ -359,21 +361,25 @@ export class LanguageServer {
359
361
 
360
362
  if (issueType === 'unlisted') {
361
363
  codeActions.push({
362
- title: `Add '${issue.symbol}' to dependencies in package.json`,
364
+ title: `Install '${issue.symbol}' as dependency`,
363
365
  kind: CodeActionKind.QuickFix,
364
366
  diagnostics: [diagnostic],
367
+ command: {
368
+ title: `Install '${issue.symbol}' as dependency`,
369
+ command: 'knip.installDependency',
370
+ arguments: [issue.symbol, 'dependencies', issue.workspace],
371
+ },
365
372
  });
366
373
 
367
374
  codeActions.push({
368
- title: `Add '${issue.symbol}' to devDependencies in package.json`,
369
- kind: CodeActionKind.QuickFix,
370
- diagnostics: [diagnostic],
371
- });
372
-
373
- codeActions.push({
374
- title: `Add '@types/${issue.symbol}' to devDependencies in package.json`,
375
+ title: `Install '${issue.symbol}' as devDependency`,
375
376
  kind: CodeActionKind.QuickFix,
376
377
  diagnostics: [diagnostic],
378
+ command: {
379
+ title: `Install '${issue.symbol}' as devDependency`,
380
+ command: 'knip.installDependency',
381
+ arguments: [issue.symbol, 'devDependencies', issue.workspace],
382
+ },
377
383
  });
378
384
  }
379
385