[ci] yarn format

This commit is contained in:
matthewp 2021-08-09 16:04:44 +00:00 committed by GitHub Actions
parent 5293519470
commit bef7247812
2 changed files with 31 additions and 27 deletions

View file

@ -74,9 +74,11 @@ class AstroDocumentSnapshot implements DocumentSnapshot {
/** @internal */
private transformContent(content: string) {
return content.replace(/---/g, '///') +
// TypeScript needs this to know there's a default export.
FILLER_DEFAULT_EXPORT;
return (
content.replace(/---/g, '///') +
// TypeScript needs this to know there's a default export.
FILLER_DEFAULT_EXPORT
);
}
get filePath() {
@ -138,9 +140,11 @@ export class DocumentFragmentSnapshot implements Omit<DocumentSnapshot, 'getFrag
/** @internal */
private transformContent(content: string) {
return content.replace(/---/g, '///') +
// TypeScript needs this to know there's a default export.
FILLER_DEFAULT_EXPORT;
return (
content.replace(/---/g, '///') +
// TypeScript needs this to know there's a default export.
FILLER_DEFAULT_EXPORT
);
}
getText(start: number, end: number) {

View file

@ -62,9 +62,9 @@ export class TypeScriptPlugin implements CompletionsProvider {
}
// Resolve all imports if we can
if(this.goToDefinitionFoundOnlyAlias(tsFilePath, defs.definitions!)) {
if (this.goToDefinitionFoundOnlyAlias(tsFilePath, defs.definitions!)) {
let importDef = this.getGoToDefinitionRefsForImportSpecifier(tsFilePath, fragmentOffset, lang);
if(importDef) {
if (importDef) {
defs = importDef;
}
}
@ -130,9 +130,7 @@ export class TypeScriptPlugin implements CompletionsProvider {
}
private goToDefinitionFoundOnlyAlias(tsFileName: string, defs: readonly ts.DefinitionInfo[]) {
return !!(defs.length === 1 &&
defs[0].kind === 'alias' &&
defs[0].fileName === tsFileName);
return !!(defs.length === 1 && defs[0].kind === 'alias' && defs[0].fileName === tsFileName);
}
private getGoToDefinitionRefsForImportSpecifier(tsFilePath: string, offset: number, lang: ts.LanguageService): ts.DefinitionInfoAndBoundSpan | undefined {
@ -140,29 +138,31 @@ export class TypeScriptPlugin implements CompletionsProvider {
const sourceFile = program?.getSourceFile(tsFilePath);
if (sourceFile) {
let node = (ts as BetterTS).getTouchingPropertyName(sourceFile, offset);
if(node && node.kind === SyntaxKind.Identifier) {
if(node.parent.kind === SyntaxKind.ImportClause) {
if (node && node.kind === SyntaxKind.Identifier) {
if (node.parent.kind === SyntaxKind.ImportClause) {
let decl = node.parent.parent as ImportDeclaration;
let spec = ts.isStringLiteral(decl.moduleSpecifier) && decl.moduleSpecifier.text;
if(spec) {
if (spec) {
let fileName = pathJoin(pathDirname(tsFilePath), spec);
let start = node.pos + 1;
let def: ts.DefinitionInfoAndBoundSpan = {
definitions: [{
kind: 'alias',
fileName,
name: '',
containerKind: '',
containerName: '',
textSpan: {
start: 0,
length: 0
}
} as ts.DefinitionInfo],
definitions: [
{
kind: 'alias',
fileName,
name: '',
containerKind: '',
containerName: '',
textSpan: {
start: 0,
length: 0,
},
} as ts.DefinitionInfo,
],
textSpan: {
start,
length: node.end - start
}
length: node.end - start,
},
};
return def;
}