@astrojs/language-server 2.3.0 → 2.3.2

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/dist/check.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as kit from '@volar/kit';
2
2
  import { Diagnostic, DiagnosticSeverity } from '@volar/language-server';
3
- export { DiagnosticSeverity, Diagnostic };
3
+ export { Diagnostic, DiagnosticSeverity };
4
4
  export interface CheckResult {
5
5
  status: 'completed' | 'cancelled' | undefined;
6
6
  fileChecked: number;
@@ -11,6 +11,7 @@ export interface CheckResult {
11
11
  errors: kit.Diagnostic[];
12
12
  fileUrl: URL;
13
13
  fileContent: string;
14
+ text: string;
14
15
  }[];
15
16
  }
16
17
  export declare class AstroCheck {
package/dist/check.js CHANGED
@@ -26,12 +26,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
26
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.AstroCheck = exports.Diagnostic = exports.DiagnosticSeverity = void 0;
29
+ exports.AstroCheck = exports.DiagnosticSeverity = exports.Diagnostic = void 0;
30
30
  const kit = __importStar(require("@volar/kit"));
31
31
  const language_server_1 = require("@volar/language-server");
32
32
  Object.defineProperty(exports, "Diagnostic", { enumerable: true, get: function () { return language_server_1.Diagnostic; } });
33
33
  Object.defineProperty(exports, "DiagnosticSeverity", { enumerable: true, get: function () { return language_server_1.DiagnosticSeverity; } });
34
34
  const fast_glob_1 = __importDefault(require("fast-glob"));
35
+ const node_fs_1 = require("node:fs");
35
36
  const node_url_1 = require("node:url");
36
37
  const index_js_1 = require("./core/index.js");
37
38
  const svelte_js_1 = require("./core/svelte.js");
@@ -67,7 +68,9 @@ class AstroCheck {
67
68
  result.status = 'cancelled';
68
69
  return result;
69
70
  }
70
- const fileDiagnostics = (await this.linter.check(file)).filter((diag) => {
71
+ const fileDiagnostics = await this.linter.check(file);
72
+ // Filter diagnostics based on the logErrors level
73
+ const fileDiagnosticsToPrint = fileDiagnostics.filter((diag) => {
71
74
  const severity = diag.severity ?? language_server_1.DiagnosticSeverity.Error;
72
75
  switch (logErrors?.level ?? 'error') {
73
76
  case 'error':
@@ -78,16 +81,18 @@ class AstroCheck {
78
81
  return severity <= language_server_1.DiagnosticSeverity.Hint;
79
82
  }
80
83
  });
81
- if (logErrors) {
82
- this.linter.logErrors(file, fileDiagnostics);
83
- }
84
84
  if (fileDiagnostics.length > 0) {
85
+ const errorText = this.linter.printErrors(file, fileDiagnosticsToPrint);
86
+ if (logErrors !== undefined && errorText) {
87
+ console.info(errorText);
88
+ }
85
89
  const fileSnapshot = this.project.languageHost.getScriptSnapshot(file);
86
90
  const fileContent = fileSnapshot?.getText(0, fileSnapshot.getLength());
87
91
  result.fileResult.push({
88
92
  errors: fileDiagnostics,
89
93
  fileContent: fileContent ?? '',
90
94
  fileUrl: (0, node_url_1.pathToFileURL)(file),
95
+ text: errorText,
91
96
  });
92
97
  result.errors += fileDiagnostics.filter((diag) => diag.severity === language_server_1.DiagnosticSeverity.Error).length;
93
98
  result.warnings += fileDiagnostics.filter((diag) => diag.severity === language_server_1.DiagnosticSeverity.Warning).length;
@@ -131,7 +136,13 @@ class AstroCheck {
131
136
  this.linter = kit.createLinter(config, this.project.languageHost);
132
137
  }
133
138
  getTsconfig() {
134
- const searchPath = this.tsconfigPath ?? this.workspacePath;
139
+ if (this.tsconfigPath) {
140
+ if (!(0, node_fs_1.existsSync)(this.tsconfigPath)) {
141
+ throw new Error(`Specified tsconfig file \`${this.tsconfigPath}\` does not exist.`);
142
+ }
143
+ return this.tsconfigPath;
144
+ }
145
+ const searchPath = this.workspacePath;
135
146
  const tsconfig = this.ts.findConfigFile(searchPath, this.ts.sys.fileExists) ||
136
147
  this.ts.findConfigFile(searchPath, this.ts.sys.fileExists, 'jsconfig.json');
137
148
  return tsconfig;
@@ -69,6 +69,7 @@ const plugin = (initOptions, modules) => ({
69
69
  prettier: prettier,
70
70
  languages: ['astro'],
71
71
  ignoreIdeOptions: true,
72
+ useIdeOptionsFallback: true,
72
73
  resolveConfigOptions: {
73
74
  // This seems to be broken since Prettier 3, and it'll always use its cumbersome cache. Hopefully it works one day.
74
75
  useCache: false,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astrojs/language-server",
3
- "version": "2.3.0",
3
+ "version": "2.3.2",
4
4
  "author": "withastro",
5
5
  "license": "MIT",
6
6
  "repository": {