From 1172836634269d4763385c2e0a8622a614a29bea Mon Sep 17 00:00:00 2001 From: Princesseuh <3019731+Princesseuh@users.noreply.github.com> Date: Thu, 8 Aug 2024 12:17:19 +0200 Subject: [PATCH] chore: update formatting config to match main repo --- biome.json | 2 +- packages/astro-check/src/index.ts | 6 ++--- packages/language-server/src/check.ts | 8 +++---- .../language-server/src/core/astro2tsx.ts | 6 ++--- packages/language-server/src/core/index.ts | 20 ++++++++-------- .../language-server/src/core/parseAstro.ts | 4 ++-- .../language-server/src/core/parseHTML.ts | 4 ++-- packages/language-server/src/core/parseJS.ts | 2 +- packages/language-server/src/core/svelte.ts | 4 ++-- packages/language-server/src/core/utils.ts | 4 ++-- packages/language-server/src/core/vue.ts | 4 ++-- packages/language-server/src/importPackage.ts | 6 ++--- .../src/languageServerPlugin.ts | 8 +++---- packages/language-server/src/nodeServer.ts | 4 ++-- packages/language-server/src/plugins/astro.ts | 8 +++---- packages/language-server/src/plugins/html.ts | 4 ++-- .../src/plugins/typescript/codeActions.ts | 2 +- .../src/plugins/typescript/completions.ts | 6 ++--- .../src/plugins/typescript/diagnostics.ts | 8 +++---- .../src/plugins/typescript/index.ts | 10 ++++---- packages/language-server/src/plugins/utils.ts | 16 ++++++------- packages/language-server/src/utils.ts | 6 ++--- .../language-server/test/check/check.test.ts | 4 ++-- .../test/css/completions.test.ts | 20 ++++++++-------- .../language-server/test/css/hover.test.ts | 2 +- .../test/html/completions.test.ts | 4 ++-- .../test/html/custom-data.test.ts | 2 +- .../language-server/test/html/hover.test.ts | 2 +- .../test/misc/prettier-format.test.ts | 4 ++-- packages/language-server/test/server.ts | 8 +++---- .../typescript-addons/completions.test.ts | 2 +- .../test/typescript/caching.test.ts | 22 ++++++++--------- .../test/typescript/completions.test.ts | 24 +++++++++---------- .../test/typescript/diagnostics.test.ts | 12 +++++----- .../test/typescript/organize-imports.test.ts | 4 ++-- .../test/typescript/scripts.test.ts | 20 ++++++++-------- .../test/units/parseAstro.test.ts | 6 ++--- .../language-server/test/units/utils.test.ts | 10 ++++---- packages/ts-plugin/src/astro2tsx.ts | 2 +- packages/ts-plugin/src/language.ts | 2 +- packages/ts-plugin/test/runTest.js | 2 +- .../ts-plugin/test/suite/extension.test.js | 16 ++++++------- packages/vscode/scripts/build.mjs | 2 +- packages/vscode/scripts/shared.mjs | 2 +- packages/vscode/src/client.ts | 2 +- prettier.config.mjs | 2 +- 46 files changed, 159 insertions(+), 159 deletions(-) diff --git a/biome.json b/biome.json index d857dd25..0e0654f8 100644 --- a/biome.json +++ b/biome.json @@ -20,7 +20,7 @@ "javascript": { "formatter": { "quoteStyle": "single", - "trailingComma": "es5" + "trailingComma": "all" } }, "json": { diff --git a/packages/astro-check/src/index.ts b/packages/astro-check/src/index.ts index 7070aff8..5f17d7d8 100644 --- a/packages/astro-check/src/index.ts +++ b/packages/astro-check/src/index.ts @@ -40,8 +40,8 @@ export async function check(flags: Partial): Promise { // Dynamically get the list of extensions to watch from the files already included in the project const checkedExtensions = Array.from( new Set( - checker.linter.projectHost.getScriptFileNames().map((fileName) => path.extname(fileName)) - ) + checker.linter.projectHost.getScriptFileNames().map((fileName) => path.extname(fileName)), + ), ); createWatcher(workspaceRoot, checkedExtensions) .on('add', (fileName) => { @@ -90,7 +90,7 @@ export async function check(flags: Partial): Promise { : undefined, ] .filter(Boolean) - .join(`\n${dim('-')} `) + .join(`\n${dim('-')} `), ); if (flags.watch) { diff --git a/packages/language-server/src/check.ts b/packages/language-server/src/check.ts index fe158c6c..3209bb9d 100644 --- a/packages/language-server/src/check.ts +++ b/packages/language-server/src/check.ts @@ -37,7 +37,7 @@ export class AstroCheck { constructor( private readonly workspacePath: string, private readonly typescriptPath: string | undefined, - private readonly tsconfigPath: string | undefined + private readonly tsconfigPath: string | undefined, ) { this.initialize(); } @@ -115,13 +115,13 @@ export class AstroCheck { }); result.errors += fileDiagnostics.filter( - (diag) => diag.severity === DiagnosticSeverity.Error + (diag) => diag.severity === DiagnosticSeverity.Error, ).length; result.warnings += fileDiagnostics.filter( - (diag) => diag.severity === DiagnosticSeverity.Warning + (diag) => diag.severity === DiagnosticSeverity.Warning, ).length; result.hints += fileDiagnostics.filter( - (diag) => diag.severity === DiagnosticSeverity.Hint + (diag) => diag.severity === DiagnosticSeverity.Hint, ).length; } diff --git a/packages/language-server/src/core/astro2tsx.ts b/packages/language-server/src/core/astro2tsx.ts index b3fc2902..30904eb5 100644 --- a/packages/language-server/src/core/astro2tsx.ts +++ b/packages/language-server/src/core/astro2tsx.ts @@ -28,7 +28,7 @@ export function safeConvertToTSX(content: string, options: ConvertToTSXOptions) return tsx; } catch (e) { console.error( - `There was an error transforming ${options.filename} to TSX. An empty file will be returned instead. Please create an issue: https://github.com/withastro/language-tools/issues\nError: ${e}.` + `There was an error transforming ${options.filename} to TSX. An empty file will be returned instead. Please create an issue: https://github.com/withastro/language-tools/issues\nError: ${e}.`, ); return { @@ -71,11 +71,11 @@ export function getTSXRangesAsLSPRanges(tsx: TSXResult): LSPTSXRanges { return { frontmatter: Range.create( textDocument.positionAt(tsx.metaRanges.frontmatter.start), - textDocument.positionAt(tsx.metaRanges.frontmatter.end) + textDocument.positionAt(tsx.metaRanges.frontmatter.end), ), body: Range.create( textDocument.positionAt(tsx.metaRanges.body.start), - textDocument.positionAt(tsx.metaRanges.body.end) + textDocument.positionAt(tsx.metaRanges.body.end), ), scripts: tsx.metaRanges.scripts ?? [], styles: tsx.metaRanges.styles ?? [], diff --git a/packages/language-server/src/core/index.ts b/packages/language-server/src/core/index.ts index ea3b283f..60ef604e 100644 --- a/packages/language-server/src/core/index.ts +++ b/packages/language-server/src/core/index.ts @@ -19,7 +19,7 @@ import { extractScriptTags } from './parseJS.js'; export function getAstroLanguagePlugin( astroInstall: AstroInstall | undefined, - ts: typeof import('typescript') + ts: typeof import('typescript'), ): LanguagePlugin { return { getLanguageId(uri) { @@ -76,8 +76,8 @@ export function getAstroLanguagePlugin( if (astroInstall) { addedFileNames.push( ...['./env.d.ts', './astro-jsx.d.ts'].map((filePath) => - ts.sys.resolvePath(path.resolve(astroInstall.path, filePath)) - ) + ts.sys.resolvePath(path.resolve(astroInstall.path, filePath)), + ), ); // If Astro version is < 4.0.8, add jsx-runtime-augment.d.ts to the files to fake `JSX` being available from "astro/jsx-runtime". @@ -90,8 +90,8 @@ export function getAstroLanguagePlugin( ) { addedFileNames.push( ...['./jsx-runtime-augment.d.ts'].map((filePath) => - ts.sys.resolvePath(path.resolve(languageServerTypesDirectory, filePath)) - ) + ts.sys.resolvePath(path.resolve(languageServerTypesDirectory, filePath)), + ), ); } } else { @@ -99,8 +99,8 @@ export function getAstroLanguagePlugin( // See the README in packages/language-server/types for more information. addedFileNames.push( ...['./env.d.ts', './astro-jsx.d.ts', './jsx-runtime-fallback.d.ts'].map((f) => - ts.sys.resolvePath(path.resolve(languageServerTypesDirectory, f)) - ) + ts.sys.resolvePath(path.resolve(languageServerTypesDirectory, f)), + ), ); } @@ -141,7 +141,7 @@ export class AstroVirtualCode implements VirtualCode { constructor( public fileName: string, - public snapshot: ts.IScriptSnapshot + public snapshot: ts.IScriptSnapshot, ) { this.mappings = [ { @@ -162,14 +162,14 @@ export class AstroVirtualCode implements VirtualCode { const tsx = astro2tsx(this.snapshot.getText(0, this.snapshot.getLength()), this.fileName); const astroMetadata = getAstroMetadata( this.fileName, - this.snapshot.getText(0, this.snapshot.getLength()) + this.snapshot.getText(0, this.snapshot.getLength()), ); const { htmlDocument, virtualCode: htmlVirtualCode } = parseHTML( this.snapshot, astroMetadata.frontmatter.status === 'closed' ? astroMetadata.frontmatter.position.end.offset - : 0 + : 0, ); this.htmlDocument = htmlDocument; diff --git a/packages/language-server/src/core/parseAstro.ts b/packages/language-server/src/core/parseAstro.ts index 04a2b4cf..f9f8f418 100644 --- a/packages/language-server/src/core/parseAstro.ts +++ b/packages/language-server/src/core/parseAstro.ts @@ -10,7 +10,7 @@ export type AstroMetadata = ParseResult & { export function getAstroMetadata( fileName: string, input: string, - options: ParseOptions = { position: true } + options: ParseOptions = { position: true }, ): Omit { const parseResult = safeParseAst(fileName, input, options); @@ -26,7 +26,7 @@ function safeParseAst(fileName: string, input: string, parseOptions: ParseOption return parseResult; } catch (e) { console.error( - `There was an error parsing ${fileName}'s AST. An empty AST will be returned instead to avoid breaking the server. Please create an issue: https://github.com/withastro/language-tools/issues\nError: ${e}.` + `There was an error parsing ${fileName}'s AST. An empty AST will be returned instead to avoid breaking the server. Please create an issue: https://github.com/withastro/language-tools/issues\nError: ${e}.`, ); return { diff --git a/packages/language-server/src/core/parseHTML.ts b/packages/language-server/src/core/parseHTML.ts index 3dd458ce..d92bbe63 100644 --- a/packages/language-server/src/core/parseHTML.ts +++ b/packages/language-server/src/core/parseHTML.ts @@ -7,7 +7,7 @@ const htmlLs = html.getLanguageService(); export function parseHTML( snapshot: ts.IScriptSnapshot, - frontmatterEnd: number + frontmatterEnd: number, ): { virtualCode: VirtualCode; htmlDocument: html.HTMLDocument } { const htmlContent = preprocessHTML(snapshot.getText(0, snapshot.getLength()), frontmatterEnd); @@ -20,7 +20,7 @@ export function parseHTML( const createScanner = htmlLs.createScanner as ( input: string, initialOffset?: number, - initialState?: html.ScannerState + initialState?: html.ScannerState, ) => html.Scanner; /** diff --git a/packages/language-server/src/core/parseJS.ts b/packages/language-server/src/core/parseJS.ts index 61383ba0..d52140f0 100644 --- a/packages/language-server/src/core/parseJS.ts +++ b/packages/language-server/src/core/parseJS.ts @@ -16,7 +16,7 @@ export function extractScriptTags(scripts: TSXExtractedScript[]): VirtualCode[] // TODO: Change this at some point so that unknown scripts are not included // We can't guarantee that they are JavaScript, so we shouldn't treat them as such, even if it might work in some cases // Perhaps we should make it so that the user has to specify the language of the script if it's not a known type (ex: lang="js"), not sure. - script.type === 'event-attribute' || script.type === 'inline' || script.type === 'unknown' + script.type === 'event-attribute' || script.type === 'inline' || script.type === 'unknown', ) .sort((a, b) => a.position.start - b.position.start); diff --git a/packages/language-server/src/core/svelte.ts b/packages/language-server/src/core/svelte.ts index 2243a3c8..3dffa373 100644 --- a/packages/language-server/src/core/svelte.ts +++ b/packages/language-server/src/core/svelte.ts @@ -48,13 +48,13 @@ class SvelteVirtualCode implements VirtualCode { constructor( public fileName: string, - public snapshot: ts.IScriptSnapshot + public snapshot: ts.IScriptSnapshot, ) { this.mappings = []; this.embeddedCodes = []; this.embeddedCodes.push( - framework2tsx(this.fileName, this.snapshot.getText(0, this.snapshot.getLength()), 'svelte') + framework2tsx(this.fileName, this.snapshot.getText(0, this.snapshot.getLength()), 'svelte'), ); } } diff --git a/packages/language-server/src/core/utils.ts b/packages/language-server/src/core/utils.ts index fba21dc3..5547376d 100644 --- a/packages/language-server/src/core/utils.ts +++ b/packages/language-server/src/core/utils.ts @@ -5,7 +5,7 @@ import { importSvelteIntegration, importVueIntegration } from '../importPackage' export function framework2tsx( filePath: string, sourceCode: string, - framework: 'vue' | 'svelte' + framework: 'vue' | 'svelte', ): VirtualCode { const integrationEditorEntrypoint = framework === 'vue' ? importVueIntegration(filePath) : importSvelteIntegration(filePath); @@ -44,7 +44,7 @@ function toPascalCase(string: string) { .replace(new RegExp(/[^\w\s]/, 'g'), '') .replace( new RegExp(/\s+(.)(\w*)/, 'g'), - ($1, $2, $3) => `${$2.toUpperCase() + $3.toLowerCase()}` + ($1, $2, $3) => `${$2.toUpperCase() + $3.toLowerCase()}`, ) .replace(new RegExp(/\w/), (s) => s.toUpperCase()); } diff --git a/packages/language-server/src/core/vue.ts b/packages/language-server/src/core/vue.ts index 8c026adf..57601bfc 100644 --- a/packages/language-server/src/core/vue.ts +++ b/packages/language-server/src/core/vue.ts @@ -48,13 +48,13 @@ class VueVirtualCode implements VirtualCode { constructor( public fileName: string, - public snapshot: ts.IScriptSnapshot + public snapshot: ts.IScriptSnapshot, ) { this.mappings = []; this.embeddedCodes = []; this.embeddedCodes.push( - framework2tsx(this.fileName, this.snapshot.getText(0, this.snapshot.getLength()), 'vue') + framework2tsx(this.fileName, this.snapshot.getText(0, this.snapshot.getLength()), 'vue'), ); } } diff --git a/packages/language-server/src/importPackage.ts b/packages/language-server/src/importPackage.ts index b555673a..fe6362eb 100644 --- a/packages/language-server/src/importPackage.ts +++ b/packages/language-server/src/importPackage.ts @@ -17,7 +17,7 @@ export function setIsTrusted(_isTrusted: boolean) { export function getPackagePath( packageName: string, fromPath: string[], - root = true + root = true, ): string | undefined { const paths = []; if (isTrusted) { @@ -43,14 +43,14 @@ function importEditorIntegration(packageName: string, fromPath: string): T | return require(main) as T; } catch (e) { console.error( - `Couldn't load editor module from ${pkgPath}. Make sure you're using at least version v0.2.1 of the corresponding integration. Reason: ${e}` + `Couldn't load editor module from ${pkgPath}. Make sure you're using at least version v0.2.1 of the corresponding integration. Reason: ${e}`, ); return undefined; } } else { console.info( - `Couldn't find package ${packageName} (searching from ${fromPath}). Make sure it's installed. If you believe this to be an error, please open an issue.` + `Couldn't find package ${packageName} (searching from ${fromPath}). Make sure it's installed. If you believe this to be an error, please open an issue.`, ); } diff --git a/packages/language-server/src/languageServerPlugin.ts b/packages/language-server/src/languageServerPlugin.ts index 993d8f59..48f18715 100644 --- a/packages/language-server/src/languageServerPlugin.ts +++ b/packages/language-server/src/languageServerPlugin.ts @@ -27,7 +27,7 @@ export function getLanguagePlugins( connection: Connection, ts: typeof import('typescript'), serviceEnv: LanguageServiceEnvironment, - tsconfig: string | undefined + tsconfig: string | undefined, ) { const languagePlugins: LanguagePlugin[] = [ getVueLanguagePlugin(), @@ -52,7 +52,7 @@ export function getLanguagePlugins( } languagePlugins.unshift( - getAstroLanguagePlugin(typeof astroInstall === 'string' ? undefined : astroInstall, ts) + getAstroLanguagePlugin(typeof astroInstall === 'string' ? undefined : astroInstall, ts), ); return languagePlugins; @@ -120,7 +120,7 @@ export function getLanguageServicePlugins(connection: Connection, ts: typeof imp const editorOptions = await context.env.getConfiguration?.( 'prettier', - document.uri + document.uri, ); // Return a config with the following cascade: @@ -153,7 +153,7 @@ export function getLanguageServicePlugins(connection: Connection, ts: typeof imp return hasPluginLoadedAlready ? [] : [prettierPluginPath]; } }, - } + }, ); } } diff --git a/packages/language-server/src/nodeServer.ts b/packages/language-server/src/nodeServer.ts index a62421d1..930bc7d6 100644 --- a/packages/language-server/src/nodeServer.ts +++ b/packages/language-server/src/nodeServer.ts @@ -16,7 +16,7 @@ connection.onInitialize((params) => { if (!tsdk) { throw new Error( - 'The `typescript.tsdk` init option is required. It should point to a directory containing a `typescript.js` or `tsserverlibrary.js` file, such as `node_modules/typescript/lib`.' + 'The `typescript.tsdk` init option is required. It should point to a directory containing a `typescript.js` or `tsserverlibrary.js` file, such as `node_modules/typescript/lib`.', ); } @@ -31,7 +31,7 @@ connection.onInitialize((params) => { }; }), getLanguageServicePlugins(connection, typescript), - { pullModelDiagnostics: params.initializationOptions?.pullModelDiagnostics } + { pullModelDiagnostics: params.initializationOptions?.pullModelDiagnostics }, ); }); diff --git a/packages/language-server/src/plugins/astro.ts b/packages/language-server/src/plugins/astro.ts index 9da786d1..a34d8526 100644 --- a/packages/language-server/src/plugins/astro.ts +++ b/packages/language-server/src/plugins/astro.ts @@ -79,7 +79,7 @@ export const create = (ts: typeof import('typescript')): LanguageServicePlugin = const { uriConverter } = context.project.typescript; const languageService = context.inject( - 'typescript/languageService' + 'typescript/languageService', ); if (!languageService) return; @@ -102,8 +102,8 @@ export const create = (ts: typeof import('typescript')): LanguageServicePlugin = getGlobResultAsCodeLens( globArgument.getText().slice(1, -1), dirname(uriConverter.asFileName(decoded[0])), - document.positionAt(node.arguments.pos) - ) + document.positionAt(node.arguments.pos), + ), ); } } @@ -135,7 +135,7 @@ function getGlobResultAsCodeLens(globText: string, dir: string, position: Positi function getFrontmatterCompletion( file: AstroVirtualCode, document: TextDocument, - position: Position + position: Position, ) { const base: CompletionItem = { kind: CompletionItemKind.Snippet, diff --git a/packages/language-server/src/plugins/html.ts b/packages/language-server/src/plugins/html.ts index c51ba534..3607cd33 100644 --- a/packages/language-server/src/plugins/html.ts +++ b/packages/language-server/src/plugins/html.ts @@ -57,7 +57,7 @@ export const create = (): LanguageServicePlugin => { document, position, completionContext, - token + token, ); if (!completions) { @@ -66,7 +66,7 @@ export const create = (): LanguageServicePlugin => { // We don't want completions for file references, as they're mostly invalid for Astro completions.items = completions.items.filter( - (completion) => completion.kind !== CompletionItemKind.File + (completion) => completion.kind !== CompletionItemKind.File, ); return completions; diff --git a/packages/language-server/src/plugins/typescript/codeActions.ts b/packages/language-server/src/plugins/typescript/codeActions.ts index ec269993..7cbbdd08 100644 --- a/packages/language-server/src/plugins/typescript/codeActions.ts +++ b/packages/language-server/src/plugins/typescript/codeActions.ts @@ -6,7 +6,7 @@ import { mapEdit } from './utils.js'; export function enhancedProvideCodeActions( codeActions: CodeAction[], - context: LanguageServiceContext + context: LanguageServiceContext, ) { return codeActions.map((codeAction) => mapCodeAction(codeAction, context)); } diff --git a/packages/language-server/src/plugins/typescript/completions.ts b/packages/language-server/src/plugins/typescript/completions.ts index 331ba98f..6f0098bd 100644 --- a/packages/language-server/src/plugins/typescript/completions.ts +++ b/packages/language-server/src/plugins/typescript/completions.ts @@ -34,13 +34,13 @@ export function enhancedProvideCompletionItems(completions: CompletionList): Com export function enhancedResolveCompletionItem( resolvedCompletion: CompletionItem, - context: LanguageServiceContext + context: LanguageServiceContext, ): CompletionItem { // Make sure we keep our icons even when the completion is resolved if (resolvedCompletion.data.isComponent) { resolvedCompletion.detail = getDetailForFileCompletion( resolvedCompletion.detail ?? '', - resolvedCompletion.data.originalItem.source + resolvedCompletion.data.originalItem.source, ); } @@ -52,7 +52,7 @@ export function enhancedResolveCompletionItem( if (!virtualCode || !(root instanceof AstroVirtualCode)) return resolvedCompletion; resolvedCompletion.additionalTextEdits = resolvedCompletion.additionalTextEdits.map((edit) => - mapEdit(edit, root, virtualCode.languageId) + mapEdit(edit, root, virtualCode.languageId), ); } diff --git a/packages/language-server/src/plugins/typescript/diagnostics.ts b/packages/language-server/src/plugins/typescript/diagnostics.ts index 64d5eea9..708610b5 100644 --- a/packages/language-server/src/plugins/typescript/diagnostics.ts +++ b/packages/language-server/src/plugins/typescript/diagnostics.ts @@ -15,7 +15,7 @@ export enum DiagnosticCodes { export function enhancedProvideSemanticDiagnostics( originalDiagnostics: Diagnostic[], - tsxLineCount?: number | undefined + tsxLineCount?: number | undefined, ) { const diagnostics = originalDiagnostics .filter( @@ -23,10 +23,10 @@ export function enhancedProvideSemanticDiagnostics( (tsxLineCount ? diagnostic.range.start.line <= tsxLineCount : true) && isNoCantReturnOutsideFunction(diagnostic) && isNoIsolatedModuleError(diagnostic) && - isNoJsxCannotHaveMultipleAttrsError(diagnostic) + isNoJsxCannotHaveMultipleAttrsError(diagnostic), ) .map((diag) => - tsxLineCount ? generalEnhancements(astroEnhancements(diag)) : generalEnhancements(diag) + tsxLineCount ? generalEnhancements(astroEnhancements(diag)) : generalEnhancements(diag), ); return diagnostics; @@ -84,7 +84,7 @@ function astroEnhancements(diagnostic: Diagnostic): Diagnostic { .replace('JSX element type', 'Component') .replace( 'does not have any construct or call signatures.', - 'is not a valid component.\n\nIf this is a Svelte or Vue component, it might have a syntax error that makes it impossible to parse.' + 'is not a valid component.\n\nIf this is a Svelte or Vue component, it might have a syntax error that makes it impossible to parse.', ), }; } diff --git a/packages/language-server/src/plugins/typescript/index.ts b/packages/language-server/src/plugins/typescript/index.ts index 3b1cbb59..4fc1fa97 100644 --- a/packages/language-server/src/plugins/typescript/index.ts +++ b/packages/language-server/src/plugins/typescript/index.ts @@ -21,7 +21,7 @@ export const create = (ts: typeof import('typescript')): LanguageServicePlugin[] document, position, completionContext, - token + token, ); if (!originalCompletions) return null; @@ -30,7 +30,7 @@ export const create = (ts: typeof import('typescript')): LanguageServicePlugin[] async resolveCompletionItem(item, token) { const resolvedCompletionItem = await typeScriptPlugin.resolveCompletionItem!( item, - token + token, ); if (!resolvedCompletionItem) return item; @@ -41,7 +41,7 @@ export const create = (ts: typeof import('typescript')): LanguageServicePlugin[] document, range, codeActionContext, - token + token, ); if (!originalCodeActions) return null; @@ -50,7 +50,7 @@ export const create = (ts: typeof import('typescript')): LanguageServicePlugin[] async resolveCodeAction(codeAction, token) { const resolvedCodeAction = await typeScriptPlugin.resolveCodeAction!( codeAction, - token + token, ); if (!resolvedCodeAction) return codeAction; @@ -72,7 +72,7 @@ export const create = (ts: typeof import('typescript')): LanguageServicePlugin[] const diagnostics = await typeScriptPlugin.provideSemanticDiagnostics!( document, - token + token, ); if (!diagnostics) return null; diff --git a/packages/language-server/src/plugins/utils.ts b/packages/language-server/src/plugins/utils.ts index a9ee5ebd..1515ce98 100644 --- a/packages/language-server/src/plugins/utils.ts +++ b/packages/language-server/src/plugins/utils.ts @@ -54,7 +54,7 @@ export function ensureProperEditForFrontmatter( edit: TextEdit, metadata: AstroMetadata, newLine: string, - position: FrontmatterEditPosition = 'top' + position: FrontmatterEditPosition = 'top', ): TextEdit { switch (metadata.frontmatter.status) { case 'open': @@ -80,7 +80,7 @@ export function ensureProperEditForFrontmatter( export function ensureRangeIsInFrontmatter( range: Range, metadata: AstroMetadata, - position: FrontmatterEditPosition = 'top' + position: FrontmatterEditPosition = 'top', ): Range { if (metadata.frontmatter.status === 'open' || metadata.frontmatter.status === 'closed') { const frontmatterEndPosition = metadata.frontmatter.position.end @@ -98,7 +98,7 @@ export function ensureRangeIsInFrontmatter( return Range.create( metadata.tsxRanges.frontmatter.start, - metadata.tsxRanges.frontmatter.start + metadata.tsxRanges.frontmatter.start, ); } @@ -111,14 +111,14 @@ export function ensureRangeIsInFrontmatter( export function getNewFrontmatterEdit( edit: TextEdit, astroMetadata: AstroMetadata, - newLine: string + newLine: string, ) { edit.newText = `---${edit.newText.startsWith(newLine) ? '' : newLine}${ edit.newText }---${newLine}${newLine}`; edit.range = Range.create( astroMetadata.tsxRanges.frontmatter.start, - astroMetadata.tsxRanges.frontmatter.start + astroMetadata.tsxRanges.frontmatter.start, ); return edit; @@ -127,14 +127,14 @@ export function getNewFrontmatterEdit( export function getOpenFrontmatterEdit( edit: TextEdit, astroMetadata: AstroMetadata, - newLine: string + newLine: string, ) { edit.newText = edit.newText.startsWith(newLine) ? `${edit.newText}---` : `${newLine}${edit.newText}---`; edit.range = Range.create( astroMetadata.tsxRanges.frontmatter.start, - astroMetadata.tsxRanges.frontmatter.start + astroMetadata.tsxRanges.frontmatter.start, ); return edit; } @@ -146,7 +146,7 @@ type FrontmatterEditValidity = // Most edits that are at the beginning of the TSX, or outside the document are intended for the frontmatter export function editShouldBeInFrontmatter( range: Range, - astroMetadata: AstroMetadata + astroMetadata: AstroMetadata, ): FrontmatterEditValidity { const isAtTSXStart = range.start.line < astroMetadata.tsxRanges.frontmatter.start.line; diff --git a/packages/language-server/src/utils.ts b/packages/language-server/src/utils.ts index 106f201d..ae38bd6f 100644 --- a/packages/language-server/src/utils.ts +++ b/packages/language-server/src/utils.ts @@ -20,7 +20,7 @@ export function getAstroInstall( checkForAstro?: { nearestPackageJson: string | undefined; readDirectory: typeof import('typescript').sys.readDirectory; - } + }, ): AstroInstall | 'not-an-astro-project' | 'not-found' { let astroPath; let version; @@ -44,7 +44,7 @@ export function getAstroInstall( ['.js', '.mjs', '.cjs', '.ts', '.mts', '.cts'], undefined, undefined, - 1 + 1, ); if (!directoryContent.some((file) => path.basename(file).startsWith('astro.config'))) { @@ -74,7 +74,7 @@ export function getAstroInstall( } catch (e) { // If we still couldn't find it, it probably just doesn't exist console.error( - `${basePaths[0]} seems to be an Astro project, but we couldn't find Astro or Astro is not installed` + `${basePaths[0]} seems to be an Astro project, but we couldn't find Astro or Astro is not installed`, ); return 'not-found'; diff --git a/packages/language-server/test/check/check.test.ts b/packages/language-server/test/check/check.test.ts index a3f27fdb..bfe29c75 100644 --- a/packages/language-server/test/check/check.test.ts +++ b/packages/language-server/test/check/check.test.ts @@ -14,7 +14,7 @@ describe('AstroCheck', async () => { checker = new AstroCheck( path.resolve(__dirname, 'fixture'), require.resolve('typescript/lib/typescript.js'), - undefined + undefined, ); result = await checker.lint({}); }); @@ -32,7 +32,7 @@ describe('AstroCheck', async () => { it("Returns the file's content", async () => { expect(result.fileResult[0].fileContent).to.not.be.undefined; expect(result.fileResult[0].fileContent).to.deep.equal( - `---${os.EOL}console.log(doesntExist);${os.EOL}---${os.EOL}` + `---${os.EOL}console.log(doesntExist);${os.EOL}---${os.EOL}`, ); }); diff --git a/packages/language-server/test/css/completions.test.ts b/packages/language-server/test/css/completions.test.ts index 20e7abd8..d6e6c5b5 100644 --- a/packages/language-server/test/css/completions.test.ts +++ b/packages/language-server/test/css/completions.test.ts @@ -12,7 +12,7 @@ describe('CSS - Completions', () => { const document = await languageServer.openFakeDocument(``, 'astro'); const completions = await languageServer.handle.sendCompletionRequest( document.uri, - Position.create(0, 18) + Position.create(0, 18), ); expect(completions!.items).to.not.be.empty; @@ -21,11 +21,11 @@ describe('CSS - Completions', () => { it('Can provide completions for CSS values', async () => { const document = await languageServer.openFakeDocument( ``, - 'astro' + 'astro', ); const completions = await languageServer.handle.sendCompletionRequest( document.uri, - Position.create(0, 21) + Position.create(0, 21), ); expect(completions!.items).to.not.be.empty; @@ -35,7 +35,7 @@ describe('CSS - Completions', () => { const document = await languageServer.openFakeDocument(`
`, 'astro'); const completions = await languageServer.handle.sendCompletionRequest( document.uri, - Position.create(0, 18) + Position.create(0, 18), ); expect(completions!.items).to.not.be.empty; @@ -45,11 +45,11 @@ describe('CSS - Completions', () => { it('Can provide completions inside inline styles with multi-bytes characters in the file', async () => { const document = await languageServer.openFakeDocument( `
`, - 'astro' + 'astro', ); const completions = await languageServer.handle.sendCompletionRequest( document.uri, - Position.create(0, 30) + Position.create(0, 30), ); expect(completions!.items).to.not.be.empty; @@ -65,11 +65,11 @@ describe('CSS - Completions', () => { } `, - 'astro' + 'astro', ); const completions = await languageServer.handle.sendCompletionRequest( document.uri, - Position.create(3, 10) + Position.create(3, 10), ); const allLabels = completions?.items.map((i) => i.label); @@ -87,11 +87,11 @@ describe('CSS - Completions', () => { } `, - 'astro' + 'astro', ); const completions = await languageServer.handle.sendCompletionRequest( document.uri, - Position.create(3, 10) + Position.create(3, 10), ); const allLabels = completions?.items.map((i) => i.label); diff --git a/packages/language-server/test/css/hover.test.ts b/packages/language-server/test/css/hover.test.ts index b8d6a3dd..7f318e20 100644 --- a/packages/language-server/test/css/hover.test.ts +++ b/packages/language-server/test/css/hover.test.ts @@ -13,7 +13,7 @@ describe('CSS - Hover', () => { it('Can get hover in style tags', async () => { const document = await languageServer.openFakeDocument( '', - 'astro' + 'astro', ); const hover = await languageServer.handle.sendHoverRequest(document.uri, Position.create(2, 7)); diff --git a/packages/language-server/test/html/completions.test.ts b/packages/language-server/test/html/completions.test.ts index 67409195..b3426db9 100644 --- a/packages/language-server/test/html/completions.test.ts +++ b/packages/language-server/test/html/completions.test.ts @@ -12,7 +12,7 @@ describe('HTML - Completions', () => { const document = await languageServer.openFakeDocument(` i.label); @@ -24,7 +24,7 @@ describe('HTML - Completions', () => { const document = await languageServer.openFakeDocument(`
{ const document = await languageServer.openFakeDocument(`
`, 'astro'); const completions = await languageServer.handle.sendCompletionRequest( document.uri, - Position.create(0, 10) + Position.create(0, 10), ); const labels = completions!.items.map((i) => i.label); diff --git a/packages/language-server/test/html/hover.test.ts b/packages/language-server/test/html/hover.test.ts index 7a502ba7..73ce746d 100644 --- a/packages/language-server/test/html/hover.test.ts +++ b/packages/language-server/test/html/hover.test.ts @@ -19,7 +19,7 @@ describe('HTML - Hover', () => { const document = await languageServer.openFakeDocument(`
{ it('Can ignore documents correctly', async () => { const document = await languageServer.handle.openTextDocument( path.resolve(__dirname, '..', 'fixture', 'dontFormat.astro'), - 'astro' + 'astro', ); const formatEdits = await languageServer.handle.sendDocumentFormattingRequest(document.uri, { tabSize: 2, @@ -40,7 +40,7 @@ describe('Formatting - Prettier', () => { it('Respect .editorconfig', async () => { const document = await languageServer.handle.openTextDocument( path.resolve(__dirname, '..', 'fixture', 'editorConfig.astro'), - 'astro' + 'astro', ); const formatEdits = await languageServer.handle.sendDocumentFormattingRequest(document.uri, { tabSize: 2, diff --git a/packages/language-server/test/server.ts b/packages/language-server/test/server.ts index 94e50fa3..9632cd7e 100644 --- a/packages/language-server/test/server.ts +++ b/packages/language-server/test/server.ts @@ -20,7 +20,7 @@ export async function getLanguageServer(): Promise { if (!serverHandle) { serverHandle = startLanguageServer( path.resolve('./bin/nodeServer.js'), - fileURLToPath(new URL('./fixture', import.meta.url)) + fileURLToPath(new URL('./fixture', import.meta.url)), ); initializeResult = await serverHandle.initialize( @@ -32,7 +32,7 @@ export async function getLanguageServer(): Promise { '../', 'node_modules', 'typescript', - 'lib' + 'lib', ), }, pullModelDiagnostics: true, @@ -42,12 +42,12 @@ export async function getLanguageServer(): Promise { // Needed for tests that use didChangeWatchedFiles didChangeWatchedFiles: {}, }, - } + }, ); // Ensure that our first test does not suffer from a TypeScript overhead await serverHandle.sendCompletionRequest( 'file://doesnt-exists', - protocol.Position.create(0, 0) + protocol.Position.create(0, 0), ); } diff --git a/packages/language-server/test/typescript-addons/completions.test.ts b/packages/language-server/test/typescript-addons/completions.test.ts index 0298c141..d0d09a6a 100644 --- a/packages/language-server/test/typescript-addons/completions.test.ts +++ b/packages/language-server/test/typescript-addons/completions.test.ts @@ -12,7 +12,7 @@ describe('TypeScript Addons - Completions', async () => { const document = await languageServer.openFakeDocument('---\nprerender\n---', 'astro'); const completions = await languageServer.handle.sendCompletionRequest( document.uri, - Position.create(1, 10) + Position.create(1, 10), ); const prerenderCompletions = completions?.items.filter((item) => item.label === 'prerender'); diff --git a/packages/language-server/test/typescript/caching.test.ts b/packages/language-server/test/typescript/caching.test.ts index e3a2025c..bfdaef58 100644 --- a/packages/language-server/test/typescript/caching.test.ts +++ b/packages/language-server/test/typescript/caching.test.ts @@ -65,7 +65,7 @@ describe('TypeScript - Cache invalidation', async () => { const document = await languageServer.handle.openTextDocument( path.join(fixtureDir, 'cachingTest.astro'), - 'astro' + 'astro', ); // Try two different files, to make sure the cache capture everything @@ -85,7 +85,7 @@ describe('TypeScript - Cache invalidation', async () => { it('Does not get path completions for removed files', async () => { const document = await languageServer.handle.openTextDocument( path.join(fixtureDir, 'cachingTest.astro'), - 'astro' + 'astro', ); await removeFile('toBeDeleted.astro'); @@ -101,7 +101,7 @@ describe('TypeScript - Cache invalidation', async () => { const labels = completions?.items.map((i) => i.label); expect(labels).to.not.include( 'toBeDeleted.astro', - `Expected toBeDeleted.astro to not be in the completions, since the file was deleted` + `Expected toBeDeleted.astro to not be in the completions, since the file was deleted`, ); }); @@ -111,7 +111,7 @@ describe('TypeScript - Cache invalidation', async () => { const document = await languageServer.handle.openTextDocument( path.join(fixtureDir, 'cachingTest.astro'), - 'astro' + 'astro', ); // Try two different files in a row, to make sure the cache updates properly for each file individually @@ -132,30 +132,30 @@ describe('TypeScript - Cache invalidation', async () => { it('New files have access to context of the project', async () => { const existingDocument = await languageServer.handle.openTextDocument( path.join(fixtureDir, 'importFromSuperModule.astro'), - 'astro' + 'astro', ); const existingDiagnostics = (await languageServer.handle.sendDocumentDiagnosticRequest( - existingDocument.uri + existingDocument.uri, )) as FullDocumentDiagnosticReport; expect(existingDiagnostics.items).to.have.length( 0, - 'Expected no diagnostics, as the file is part of the project' + 'Expected no diagnostics, as the file is part of the project', ); const document = await createFile( 'WillImportFromSuperModule.astro', - '---\n\nimport { hello } from "im-a-super-module";\n\nhello;\n\n---\n' + '---\n\nimport { hello } from "im-a-super-module";\n\nhello;\n\n---\n', ); const diagnostics = (await languageServer.handle.sendDocumentDiagnosticRequest( - document.uri + document.uri, )) as FullDocumentDiagnosticReport; expect(diagnostics.items).to.have.length( 0, - 'Expected no diagnostics, as new files should have access to the module declaration in the project like already existing files.' + 'Expected no diagnostics, as new files should have access to the module declaration in the project like already existing files.', ); const hoverSuperModule = await languageServer.handle.sendHoverRequest(document.uri, { @@ -164,7 +164,7 @@ describe('TypeScript - Cache invalidation', async () => { }); expect((hoverSuperModule?.contents as MarkupContent).value).to.include( - 'module "im-a-super-module"' + 'module "im-a-super-module"', ); }); diff --git a/packages/language-server/test/typescript/completions.test.ts b/packages/language-server/test/typescript/completions.test.ts index 64e336fb..112cfa9a 100644 --- a/packages/language-server/test/typescript/completions.test.ts +++ b/packages/language-server/test/typescript/completions.test.ts @@ -16,7 +16,7 @@ describe('TypeScript - Completions', async () => { const document = await languageServer.openFakeDocument('---\nc\n---', 'astro'); const completions = await languageServer.handle.sendCompletionRequest( document.uri, - Position.create(1, 1) + Position.create(1, 1), ); expect(completions?.items).to.not.be.empty; @@ -26,7 +26,7 @@ describe('TypeScript - Completions', async () => { const document = await languageServer.openFakeDocument('{c}', 'astro'); const completions = await languageServer.handle.sendCompletionRequest( document.uri, - Position.create(0, 1) + Position.create(0, 1), ); expect(completions?.items).to.not.be.empty; @@ -36,11 +36,11 @@ describe('TypeScript - Completions', async () => { const document = await languageServer.openFakeDocument(' item.labelDetails?.description === 'astro:assets' + (item) => item.labelDetails?.description === 'astro:assets', ); expect(imageCompletion?.sortText).to.equal('\x00￿16'); @@ -57,7 +57,7 @@ describe('TypeScript - Completions', async () => { const document = await languageServer.openFakeDocument(doc, 'astro'); const completions = await languageServer.handle.sendCompletionRequest( document.uri, - Position.create(1, 8) + Position.create(1, 8), ); const allLabels = completions?.items.map((item) => item.label); @@ -69,15 +69,15 @@ describe('TypeScript - Completions', async () => { it('properly maps edits for completions in script tags', async () => { const document = await languageServer.handle.openTextDocument( path.join(fixtureDir, 'scriptImport.astro'), - 'astro' + 'astro', ); const completions = await languageServer.handle.sendCompletionRequest( document.uri, - Position.create(1, 0) + Position.create(1, 0), ); const imageConfigCompletion = completions?.items.find( - (item) => item.label === 'Image' && item.labelDetails?.description === 'astro:assets' + (item) => item.label === 'Image' && item.labelDetails?.description === 'astro:assets', ); expect(imageConfigCompletion).to.not.be.undefined; @@ -87,7 +87,7 @@ describe('TypeScript - Completions', async () => { // Why `import type`? I... don't know. TypeScript return this in some contexts and somehow in the editor it's not a problem. // This issue affects all imports, even outside of Astro. expect(edits?.additionalTextEdits?.[0].newText).to.equal( - `\nimport type { Image } from "astro:assets";\n` + `\nimport type { Image } from "astro:assets";\n`, ); expect(edits?.additionalTextEdits?.[0].range.start.line).to.equal(0); }); @@ -96,7 +96,7 @@ describe('TypeScript - Completions', async () => { const document = await languageServer.openFakeDocument('
', 'astro'); const completions = await languageServer.handle.sendCompletionRequest( document.uri, - Position.create(0, 13) + Position.create(0, 13), ); expect(completions?.items).to.not.be.empty; @@ -109,11 +109,11 @@ describe('TypeScript - Completions', async () => { it('Can get completions inside HTML events with multi-bytes characters in the file', async () => { const document = await languageServer.openFakeDocument( '
', - 'astro' + 'astro', ); const completions = await languageServer.handle.sendCompletionRequest( document.uri, - Position.create(0, 24) + Position.create(0, 24), ); expect(completions?.items).to.not.be.empty; diff --git a/packages/language-server/test/typescript/diagnostics.test.ts b/packages/language-server/test/typescript/diagnostics.test.ts index d4356c88..ec4a1862 100644 --- a/packages/language-server/test/typescript/diagnostics.test.ts +++ b/packages/language-server/test/typescript/diagnostics.test.ts @@ -17,7 +17,7 @@ describe('TypeScript - Diagnostics', async () => { it('Can get diagnostics in the frontmatter', async () => { const document = await languageServer.openFakeDocument('---\nNotAThing\n---', 'astro'); const diagnostics = (await languageServer.handle.sendDocumentDiagnosticRequest( - document.uri + document.uri, )) as FullDocumentDiagnosticReport; // We should only have one error here. @@ -39,7 +39,7 @@ describe('TypeScript - Diagnostics', async () => { it('Can get diagnostics in the template', async () => { const document = await languageServer.openFakeDocument('---\n\n---\n{nope}', 'astro'); const diagnostics = (await languageServer.handle.sendDocumentDiagnosticRequest( - document.uri + document.uri, )) as FullDocumentDiagnosticReport; expect(diagnostics.items).length(1); @@ -57,10 +57,10 @@ describe('TypeScript - Diagnostics', async () => { it('shows enhanced diagnostics', async () => { const document = await languageServer.handle.openTextDocument( path.resolve(__dirname, '..', 'fixture', 'enhancedDiagnostics.astro'), - 'astro' + 'astro', ); const diagnostics = (await languageServer.handle.sendDocumentDiagnosticRequest( - document.uri + document.uri, )) as FullDocumentDiagnosticReport; expect(diagnostics.items).length(2); @@ -90,10 +90,10 @@ describe('TypeScript - Diagnostics', async () => { it('can get diagnostics in script tags', async () => { const document = await languageServer.openFakeDocument( `
`, - 'astro' + 'astro', ); const diagnostics = (await languageServer.handle.sendDocumentDiagnosticRequest( - document.uri + document.uri, )) as FullDocumentDiagnosticReport; expect(diagnostics.items).length(1); }); diff --git a/packages/language-server/test/typescript/organize-imports.test.ts b/packages/language-server/test/typescript/organize-imports.test.ts index 91fdc967..67622c63 100644 --- a/packages/language-server/test/typescript/organize-imports.test.ts +++ b/packages/language-server/test/typescript/organize-imports.test.ts @@ -12,7 +12,7 @@ describe('TypeScript - Organize & Sort Imports', () => { it('Can organize imports', async () => { const document = await languageServer.openFakeDocument( `---\n\nimport os from "node:os";\n\nimport fs from "node:fs";\n\n---\n\n`, - 'astro' + 'astro', ); const organizeEdits = await languageServer.handle.sendCodeActionsRequest( document.uri, @@ -21,7 +21,7 @@ describe('TypeScript - Organize & Sort Imports', () => { diagnostics: [], only: ['source.organizeImports'], triggerKind: 1, - } + }, ); expect(organizeEdits).to.deep.equal([ diff --git a/packages/language-server/test/typescript/scripts.test.ts b/packages/language-server/test/typescript/scripts.test.ts index 94300517..d9572188 100644 --- a/packages/language-server/test/typescript/scripts.test.ts +++ b/packages/language-server/test/typescript/scripts.test.ts @@ -10,10 +10,10 @@ describe('TypeScript - Diagnostics', async () => { it('treats script tags as modules', async () => { const document = await languageServer.openFakeDocument( '', - 'astro' + 'astro', ); const diagnostics = (await languageServer.handle.sendDocumentDiagnosticRequest( - document.uri + document.uri, )) as FullDocumentDiagnosticReport; expect(diagnostics.items).length(2); @@ -22,11 +22,11 @@ describe('TypeScript - Diagnostics', async () => { it('treats inline script tags as not isolated modules', async () => { const document = await languageServer.openFakeDocument( '', - 'astro' + 'astro', ); const diagnostics = (await languageServer.handle.sendDocumentDiagnosticRequest( - document.uri + document.uri, )) as FullDocumentDiagnosticReport; expect(diagnostics.items).length(0); @@ -35,12 +35,12 @@ describe('TypeScript - Diagnostics', async () => { it('still supports script tags with unknown types', async () => { const document = await languageServer.openFakeDocument( '', - 'astro' + 'astro', ); const hoverInfo = await languageServer.handle.sendHoverRequest( document.uri, - Position.create(0, 38) + Position.create(0, 38), ); expect(hoverInfo).to.not.be.undefined; @@ -49,12 +49,12 @@ describe('TypeScript - Diagnostics', async () => { it('ignores is:raw script tags', async () => { const document = await languageServer.openFakeDocument( '', - 'astro' + 'astro', ); const hoverInfo = await languageServer.handle.sendHoverRequest( document.uri, - Position.create(0, 38) + Position.create(0, 38), ); expect(hoverInfo).to.be.null; @@ -64,11 +64,11 @@ describe('TypeScript - Diagnostics', async () => { const document = await languageServer.openFakeDocument( `🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀 `, - 'astro' + 'astro', ); const diagnostics = (await languageServer.handle.sendDocumentDiagnosticRequest( - document.uri + document.uri, )) as FullDocumentDiagnosticReport; expect(diagnostics.items).length(1); diff --git a/packages/language-server/test/units/parseAstro.test.ts b/packages/language-server/test/units/parseAstro.test.ts index a9c45b8a..3710a514 100644 --- a/packages/language-server/test/units/parseAstro.test.ts +++ b/packages/language-server/test/units/parseAstro.test.ts @@ -13,7 +13,7 @@ describe('parseAstro - Can parse astro files', () => { { position: createCompilerPosition( createCompilerPoint(1, 1, 0), - createCompilerPoint(2, 4, 7) + createCompilerPoint(2, 4, 7), ), type: 'frontmatter', value: '\n', @@ -24,7 +24,7 @@ describe('parseAstro - Can parse astro files', () => { { position: createCompilerPosition( createCompilerPoint(2, 10, 13), - createCompilerPoint(2, 16, 19) + createCompilerPoint(2, 16, 19), ), type: 'text', value: 'Astro!', @@ -33,7 +33,7 @@ describe('parseAstro - Can parse astro files', () => { name: 'div', position: createCompilerPosition( createCompilerPoint(2, 5, 8), - createCompilerPoint(2, 22, 25) + createCompilerPoint(2, 22, 25), ), type: 'element', }, diff --git a/packages/language-server/test/units/utils.test.ts b/packages/language-server/test/units/utils.test.ts index 175a7a2b..a53a0467 100644 --- a/packages/language-server/test/units/utils.test.ts +++ b/packages/language-server/test/units/utils.test.ts @@ -84,17 +84,17 @@ describe('Utilities', async () => { const astroMetadata = { tsxRanges, ...getAstroMetadata('file.astro', input) }; expect(utils.ensureRangeIsInFrontmatter(beforeFrontmatterRange, astroMetadata)).to.deep.equal( - Range.create(2, 0, 2, 0) + Range.create(2, 0, 2, 0), ); const insideFrontmatterRange = html.Range.create(1, 0, 1, 0); expect(utils.ensureRangeIsInFrontmatter(insideFrontmatterRange, astroMetadata)).to.deep.equal( - Range.create(2, 0, 2, 0) + Range.create(2, 0, 2, 0), ); const outsideFrontmatterRange = html.Range.create(6, 0, 6, 0); expect(utils.ensureRangeIsInFrontmatter(outsideFrontmatterRange, astroMetadata)).to.deep.equal( - Range.create(2, 0, 2, 0) + Range.create(2, 0, 2, 0), ); }); @@ -106,7 +106,7 @@ describe('Utilities', async () => { const edit = utils.getNewFrontmatterEdit( { range: Range.create(43, 0, 44, 0), newText: 'foo' }, astroMetadata, - '\n' + '\n', ); expect(edit).to.deep.equal({ range: Range.create(2, 0, 2, 0), @@ -122,7 +122,7 @@ describe('Utilities', async () => { const edit = utils.getOpenFrontmatterEdit( { range: Range.create(2, 0, 2, 0), newText: 'foo' }, astroMetadata, - '\n' + '\n', ); expect(edit).to.deep.equal({ diff --git a/packages/ts-plugin/src/astro2tsx.ts b/packages/ts-plugin/src/astro2tsx.ts index 3e64bd48..501830ce 100644 --- a/packages/ts-plugin/src/astro2tsx.ts +++ b/packages/ts-plugin/src/astro2tsx.ts @@ -11,7 +11,7 @@ function safeConvertToTSX(content: string, options: ConvertToTSXOptions) { return tsx; } catch (e) { console.error( - `There was an error transforming ${options.filename} to TSX. An empty file will be returned instead. Please create an issue: https://github.com/withastro/language-tools/issues\nError: ${e}.` + `There was an error transforming ${options.filename} to TSX. An empty file will be returned instead. Please create an issue: https://github.com/withastro/language-tools/issues\nError: ${e}.`, ); return { diff --git a/packages/ts-plugin/src/language.ts b/packages/ts-plugin/src/language.ts index 265e8b96..a2a492ff 100644 --- a/packages/ts-plugin/src/language.ts +++ b/packages/ts-plugin/src/language.ts @@ -47,7 +47,7 @@ export class AstroVirtualCode implements VirtualCode { constructor( public fileName: string, - public snapshot: ts.IScriptSnapshot + public snapshot: ts.IScriptSnapshot, ) { this.mappings = [ { diff --git a/packages/ts-plugin/test/runTest.js b/packages/ts-plugin/test/runTest.js index 66ca8a5c..b5588d9d 100644 --- a/packages/ts-plugin/test/runTest.js +++ b/packages/ts-plugin/test/runTest.js @@ -26,7 +26,7 @@ async function main() { files.forEach((file) => { if (file.startsWith('vscode-')) { vsPath = downloadDirToExecutablePath( - path.resolve(__dirname, '../../vscode/.vscode-test/', file) + path.resolve(__dirname, '../../vscode/.vscode-test/', file), ); return; } diff --git a/packages/ts-plugin/test/suite/extension.test.js b/packages/ts-plugin/test/suite/extension.test.js index a7225a4d..2ecaf4b4 100644 --- a/packages/ts-plugin/test/suite/extension.test.js +++ b/packages/ts-plugin/test/suite/extension.test.js @@ -16,19 +16,19 @@ suite('Extension Test Suite', () => { await new Promise((resolve) => setTimeout(resolve, 100)); } throw new Error( - `TypeScript plugin never started or condition never resolved for command ${command}` + `TypeScript plugin never started or condition never resolved for command ${command}`, ); } test('can find references inside Astro files', async () => { const doc = await vscode.workspace.openTextDocument( - vscode.Uri.file(path.join(__dirname, '../fixtures/script.ts')) + vscode.Uri.file(path.join(__dirname, '../fixtures/script.ts')), ); const references = await waitForTS( 'vscode.executeReferenceProvider', [doc.uri, new vscode.Position(0, 18)], - (result) => result.length > 1 + (result) => result.length > 1, ); const hasAstroRef = references.some((ref) => ref.uri.path.includes('MyAstroComponent.astro')); @@ -37,13 +37,13 @@ suite('Extension Test Suite', () => { test('can get completions for Astro components', async () => { const doc = await vscode.workspace.openTextDocument( - vscode.Uri.file(path.join(__dirname, '../fixtures/script.ts')) + vscode.Uri.file(path.join(__dirname, '../fixtures/script.ts')), ); const completions = await waitForTS( 'vscode.executeCompletionItemProvider', [doc.uri, new vscode.Position(4, 12)], - (result) => result.items.length > 0 + (result) => result.items.length > 0, ); const hasAstroCompletion = completions.items.some((item) => { @@ -54,17 +54,17 @@ suite('Extension Test Suite', () => { test('can get implementations inside Astro files', async () => { const doc = await vscode.workspace.openTextDocument( - vscode.Uri.file(path.join(__dirname, '../fixtures/script.ts')) + vscode.Uri.file(path.join(__dirname, '../fixtures/script.ts')), ); const implementations = await waitForTS( 'vscode.executeImplementationProvider', [doc.uri, new vscode.Position(6, 15)], - (result) => result.length > 1 + (result) => result.length > 1, ); const hasAstroImplementation = implementations.some((impl) => - impl.uri.path.includes('MyAstroComponent') + impl.uri.path.includes('MyAstroComponent'), ); expect(hasAstroImplementation).to.be.true; }).timeout(12000); diff --git a/packages/vscode/scripts/build.mjs b/packages/vscode/scripts/build.mjs index 7d29e619..75136512 100644 --- a/packages/vscode/scripts/build.mjs +++ b/packages/vscode/scripts/build.mjs @@ -51,7 +51,7 @@ export default async function build() { // Call twice the replace is to solve the problem of the path in Windows const pathEsm = pathUmdMay.replace('/umd/', '/esm/').replace('\\umd\\', '\\esm\\'); return { path: pathEsm }; - } + }, ); }, }, diff --git a/packages/vscode/scripts/shared.mjs b/packages/vscode/scripts/shared.mjs index a83c4106..7443ab78 100644 --- a/packages/vscode/scripts/shared.mjs +++ b/packages/vscode/scripts/shared.mjs @@ -19,7 +19,7 @@ export const rebuildPlugin = { } else { if (result.warnings.length) { console.log( - dim(`[${date}] `) + yellow('⚠ updated with warnings:\n' + result.warnings.join('\n')) + dim(`[${date}] `) + yellow('⚠ updated with warnings:\n' + result.warnings.join('\n')), ); } console.log(dim(`[${date}] `) + green('✔ updated')); diff --git a/packages/vscode/src/client.ts b/packages/vscode/src/client.ts index 297a3046..3914e585 100644 --- a/packages/vscode/src/client.ts +++ b/packages/vscode/src/client.ts @@ -121,7 +121,7 @@ async function getConfiguredServerPath(workspaceState: vscode.Memento) { msg, allowPrompt, dismissPrompt, - neverPrompt + neverPrompt, ); if (result === allowPrompt) { diff --git a/prettier.config.mjs b/prettier.config.mjs index 1621013f..c1b4b572 100644 --- a/prettier.config.mjs +++ b/prettier.config.mjs @@ -4,7 +4,7 @@ export default { semi: true, singleQuote: true, tabWidth: 2, - trailingComma: 'es5', + trailingComma: 'all', useTabs: true, overrides: [ {