@knip/language-server 1.2.0 → 1.2.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.
Files changed (2) hide show
  1. package/package.json +3 -3
  2. package/src/server.js +4 -6
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@knip/language-server",
3
- "version": "1.2.0",
3
+ "version": "1.2.1",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -12,10 +12,10 @@
12
12
  "dependencies": {
13
13
  "vscode-languageserver": "^9.0.1",
14
14
  "vscode-languageserver-textdocument": "^1.0.12",
15
- "knip": "^5.83.0"
15
+ "knip": "^5.83.1"
16
16
  },
17
17
  "engines": {
18
- "node": ">=18.18.0"
18
+ "node": ">=18.20.0"
19
19
  },
20
20
  "scripts": {
21
21
  "release": "release-it -c ../../.release-it.json"
package/src/server.js CHANGED
@@ -1,10 +1,10 @@
1
- import fs from 'node:fs';
2
1
  import path from 'node:path';
3
2
  import { fileURLToPath, pathToFileURL } from 'node:url';
4
3
  import { createOptions, createSession, KNIP_CONFIG_LOCATIONS } from 'knip/session';
5
4
  import { FileChangeType, ProposedFeatures, TextDocuments } from 'vscode-languageserver';
6
5
  import { CodeActionKind, createConnection } from 'vscode-languageserver/node.js';
7
6
  import { TextDocument } from 'vscode-languageserver-textdocument';
7
+ import pkg from '../package.json' with { type: 'json' };
8
8
  import {
9
9
  createAddJSDocTagEdit,
10
10
  createDeleteFileEdit,
@@ -24,9 +24,6 @@ import {
24
24
  } from './constants.js';
25
25
  import { issueToDiagnostic } from './diagnostics.js';
26
26
 
27
- const __dirname = path.dirname(fileURLToPath(import.meta.url));
28
- const pkg = JSON.parse(fs.readFileSync(path.join(__dirname, '..', 'package.json'), 'utf8'));
29
-
30
27
  const RESTART_FOR = new Set(['package.json', ...KNIP_CONFIG_LOCATIONS]);
31
28
 
32
29
  /** @param {string} value */
@@ -370,6 +367,7 @@ export class LanguageServer {
370
367
  }
371
368
 
372
369
  if (issueType === 'unlisted') {
370
+ const workspacePath = path.resolve(this.cwd ?? process.cwd(), issue.workspace);
373
371
  codeActions.push({
374
372
  title: `Install '${issue.symbol}' as dependency`,
375
373
  kind: CodeActionKind.QuickFix,
@@ -377,7 +375,7 @@ export class LanguageServer {
377
375
  command: {
378
376
  title: `Install '${issue.symbol}' as dependency`,
379
377
  command: 'knip.installDependency',
380
- arguments: [issue.symbol, 'dependencies', issue.workspace],
378
+ arguments: [issue.symbol, 'dependencies', workspacePath],
381
379
  },
382
380
  });
383
381
 
@@ -388,7 +386,7 @@ export class LanguageServer {
388
386
  command: {
389
387
  title: `Install '${issue.symbol}' as devDependency`,
390
388
  command: 'knip.installDependency',
391
- arguments: [issue.symbol, 'devDependencies', issue.workspace],
389
+ arguments: [issue.symbol, 'devDependencies', workspacePath],
392
390
  },
393
391
  });
394
392
  }