@astrojs/language-server 2.13.1 → 2.13.4

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/bin/nodeServer.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  if (process.argv.includes('--version')) {
3
3
  const pkgJSON = require('../package.json');
4
- console.log(`${pkgJSON['version']}`);
4
+ console.info(`${pkgJSON['version']}`);
5
5
  } else {
6
6
  require('../dist/nodeServer.js');
7
7
  }
@@ -4,7 +4,7 @@ import type ts from 'typescript';
4
4
  import type { HTMLDocument } from 'vscode-html-languageservice';
5
5
  import type { URI } from 'vscode-uri';
6
6
  import { type AstroInstall } from '../utils.js';
7
- import { AstroMetadata } from './parseAstro';
7
+ import type { AstroMetadata } from './parseAstro';
8
8
  export declare function getAstroLanguagePlugin(astroInstall: AstroInstall | undefined, ts: typeof import('typescript')): LanguagePlugin<URI, AstroVirtualCode>;
9
9
  export declare class AstroVirtualCode implements VirtualCode {
10
10
  fileName: string;
@@ -160,7 +160,10 @@ class AstroVirtualCode {
160
160
  this.embeddedCodes = [htmlVirtualCode, tsx.virtualCode];
161
161
  }
162
162
  get hasCompilationErrors() {
163
- return this.compilerDiagnostics.filter((diag) => diag.severity === 1).length > 0;
163
+ return (
164
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison
165
+ this.compilerDiagnostics.filter((diag) => diag.severity === (1))
166
+ .length > 0);
164
167
  }
165
168
  }
166
169
  exports.AstroVirtualCode = AstroVirtualCode;
@@ -43,7 +43,7 @@ function classNameFromFilename(filename) {
43
43
  const withoutInvalidCharacters = withoutExtensions
44
44
  .split('')
45
45
  // Although "-" is invalid, we leave it in, pascal-case-handling will throw it out later
46
- .filter((char) => /[A-Za-z$_\d-]/.test(char))
46
+ .filter((char) => /[\w$-]/.test(char))
47
47
  .join('');
48
48
  const firstValidCharIdx = withoutInvalidCharacters
49
49
  .split('')
@@ -60,7 +60,7 @@ exports.classNameFromFilename = classNameFromFilename;
60
60
  function patchTSX(code, filePath) {
61
61
  const basename = filePath.split('/').pop();
62
62
  const isDynamic = basename.startsWith('[') && basename.endsWith(']');
63
- return code.replace(/\b(\S*)__AstroComponent_/gm, (fullMatch, m1) => {
63
+ return code.replace(/\b(\S*)__AstroComponent_/g, (fullMatch, m1) => {
64
64
  // If we don't have a match here, it usually means the file has a weird name that couldn't be expressed with valid identifier characters
65
65
  if (!m1) {
66
66
  if (basename === '404')
@@ -20,7 +20,7 @@ function getPackagePath(packageName, fromPath, root = true) {
20
20
  ? (0, node_path_1.dirname)(require.resolve(packageName + '/package.json', { paths }))
21
21
  : require.resolve(packageName, { paths });
22
22
  }
23
- catch (e) {
23
+ catch {
24
24
  return undefined;
25
25
  }
26
26
  }
@@ -1,4 +1,4 @@
1
- import { Connection, LanguagePlugin, LanguageServiceEnvironment } from '@volar/language-server/node';
1
+ import type { Connection, LanguagePlugin, LanguageServiceEnvironment } from '@volar/language-server/node';
2
2
  import { URI } from 'vscode-uri';
3
3
  export declare function getLanguagePlugins(connection: Connection, ts: typeof import('typescript'), serviceEnv: LanguageServiceEnvironment, tsconfig: string | undefined): LanguagePlugin<URI, import("@volar/language-server/node").VirtualCode>[];
4
4
  export declare function getLanguageServicePlugins(connection: Connection, ts: typeof import('typescript')): import("@volar/language-server/node").LanguageServicePlugin<any>[];
@@ -1,2 +1,2 @@
1
- import { LanguageServicePlugin } from '@volar/language-server';
1
+ import type { LanguageServicePlugin } from '@volar/language-server';
2
2
  export declare const create: (ts: typeof import('typescript')) => LanguageServicePlugin;
@@ -126,7 +126,7 @@ function getFrontmatterCompletion(file, document, position) {
126
126
  return {
127
127
  ...base,
128
128
  insertText: '---\n$0\n---',
129
- textEdit: prefix.match(/^\s*\-+/)
129
+ textEdit: /^\s*-+/.test(prefix)
130
130
  ? language_server_1.TextEdit.replace({ start: { ...position, character: 0 }, end: position }, '---\n$0\n---')
131
131
  : undefined,
132
132
  };
@@ -142,7 +142,7 @@ function getFrontmatterCompletion(file, document, position) {
142
142
  ...base,
143
143
  insertText,
144
144
  detail: insertText === '---' ? 'Close component script block' : 'Create component script block',
145
- textEdit: prefix.match(/^\s*\-+/)
145
+ textEdit: /^\s*-+/.test(prefix)
146
146
  ? language_server_1.TextEdit.replace({ start: { ...position, character: 0 }, end: position }, insertText)
147
147
  : undefined,
148
148
  };
@@ -1,2 +1,2 @@
1
- import { LanguageServicePlugin } from '@volar/language-server';
1
+ import type { LanguageServicePlugin } from '@volar/language-server';
2
2
  export declare const create: () => LanguageServicePlugin;
@@ -1,3 +1,3 @@
1
- import { CompletionItem, CompletionList, LanguageServiceContext } from '@volar/language-server';
1
+ import type { CompletionItem, CompletionList, LanguageServiceContext } from '@volar/language-server';
2
2
  export declare function enhancedProvideCompletionItems(completions: CompletionList): CompletionList;
3
3
  export declare function enhancedResolveCompletionItem(resolvedCompletion: CompletionItem, context: LanguageServiceContext): CompletionItem;
@@ -1,4 +1,5 @@
1
- import { HTMLDocument, Node, Range, TextEdit } from 'vscode-html-languageservice';
1
+ import type { HTMLDocument, Node, TextEdit } from 'vscode-html-languageservice';
2
+ import { Range } from 'vscode-html-languageservice';
2
3
  import type { AstroMetadata, FrontmatterStatus } from '../core/parseAstro.js';
3
4
  export declare function isJSDocument(languageId: string): boolean;
4
5
  /**
@@ -14,7 +14,9 @@ exports.isJSDocument = isJSDocument;
14
14
  * This is not a 100% sure test as it'll return false for any component that does not match the standard format for a component
15
15
  */
16
16
  function isPossibleComponent(node) {
17
- return !!node.tag?.[0].match(/[A-Z]/) || !!node.tag?.match(/.+[.][A-Z]?/);
17
+ if (!node.tag)
18
+ return false;
19
+ return !!/[A-Z]/.test(node.tag?.[0]) || !!/.+\.[A-Z]?/.test(node.tag);
18
20
  }
19
21
  exports.isPossibleComponent = isPossibleComponent;
20
22
  /**
package/dist/utils.js CHANGED
@@ -68,7 +68,7 @@ function getAstroInstall(basePaths, checkForAstro) {
68
68
  }
69
69
  version = require(path.resolve(astroPath, 'package.json')).version;
70
70
  }
71
- catch (e) {
71
+ catch {
72
72
  // If we still couldn't find it, it probably just doesn't exist
73
73
  console.error(`${basePaths[0]} seems to be an Astro project, but we couldn't find Astro or Astro is not installed`);
74
74
  return 'not-found';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astrojs/language-server",
3
- "version": "2.13.1",
3
+ "version": "2.13.4",
4
4
  "author": "withastro",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -20,7 +20,7 @@
20
20
  "astro-ls": "./bin/nodeServer.js"
21
21
  },
22
22
  "dependencies": {
23
- "@astrojs/compiler": "^2.10.1",
23
+ "@astrojs/compiler": "^2.10.3",
24
24
  "@jridgewell/sourcemap-codec": "^1.4.15",
25
25
  "@volar/kit": "~2.4.0-alpha.15",
26
26
  "@volar/language-core": "~2.4.0-alpha.15",
@@ -14,7 +14,7 @@ declare namespace astroHTML.JSX {
14
14
  export type Children = Child | Child[];
15
15
 
16
16
  interface ElementChildrenAttribute {
17
- // eslint-disable-next-line @typescript-eslint/ban-types
17
+ // eslint-disable-next-line @typescript-eslint/no-empty-object-type
18
18
  children: {};
19
19
  }
20
20
 
@@ -591,7 +591,7 @@ declare namespace astroHTML.JSX {
591
591
  referrerpolicy?: HTMLAttributeReferrerPolicy | undefined | null;
592
592
  }
593
593
 
594
- // eslint-disable-next-line @typescript-eslint/no-empty-interface
594
+ // eslint-disable-next-line @typescript-eslint/no-empty-object-type
595
595
  interface AudioHTMLAttributes extends MediaHTMLAttributes {}
596
596
 
597
597
  interface AreaHTMLAttributes extends HTMLAttributes {