mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-23 07:07:09 -05:00
Enable "object-literal-shorthand" lint rule (#16987)
This commit is contained in:
@@ -58,11 +58,7 @@ namespace ts.codefix {
|
||||
}
|
||||
|
||||
function pushAction(result: CodeAction[], newNodes: Node[], description: string): void {
|
||||
const newAction: CodeAction = {
|
||||
description: description,
|
||||
changes: newNodesToChanges(newNodes, openBrace, context)
|
||||
};
|
||||
result.push(newAction);
|
||||
result.push({ description, changes: newNodesToChanges(newNodes, openBrace, context) });
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -76,7 +76,7 @@ namespace ts.Completions {
|
||||
addRange(entries, getKeywordCompletions(keywordFilters));
|
||||
}
|
||||
|
||||
return { isGlobalCompletion, isMemberCompletion, isNewIdentifierLocation: isNewIdentifierLocation, entries };
|
||||
return { isGlobalCompletion, isMemberCompletion, isNewIdentifierLocation, entries };
|
||||
}
|
||||
|
||||
function getJavaScriptCompletionEntries(sourceFile: SourceFile, position: number, uniqueNames: Map<string>, target: ScriptTarget): CompletionEntry[] {
|
||||
|
||||
@@ -179,7 +179,7 @@ namespace ts {
|
||||
const sourceFile = createLanguageServiceSourceFile(fileName, scriptSnapshot, compilationSettings.target, version, /*setNodeParents*/ false, scriptKind);
|
||||
|
||||
entry = {
|
||||
sourceFile: sourceFile,
|
||||
sourceFile,
|
||||
languageServiceRefCount: 0,
|
||||
owners: []
|
||||
};
|
||||
|
||||
@@ -146,7 +146,7 @@ namespace ts.formatting {
|
||||
// format from the beginning of the line
|
||||
const span = {
|
||||
pos: getLineStartPositionForPosition(start, sourceFile),
|
||||
end: end
|
||||
end,
|
||||
};
|
||||
return formatSpan(span, sourceFile, options, rulesProvider, FormattingRequestKind.FormatSelection);
|
||||
}
|
||||
|
||||
@@ -96,7 +96,7 @@ namespace ts.formatting {
|
||||
// consume leading trivia
|
||||
scanner.scan();
|
||||
const item = {
|
||||
pos: pos,
|
||||
pos,
|
||||
end: scanner.getStartPos(),
|
||||
kind: t
|
||||
};
|
||||
@@ -264,11 +264,7 @@ namespace ts.formatting {
|
||||
}
|
||||
}
|
||||
|
||||
lastTokenInfo = {
|
||||
leadingTrivia: leadingTrivia,
|
||||
trailingTrivia: trailingTrivia,
|
||||
token: token
|
||||
};
|
||||
lastTokenInfo = { leadingTrivia, trailingTrivia, token };
|
||||
|
||||
return fixTokenKind(lastTokenInfo, n);
|
||||
}
|
||||
|
||||
@@ -271,7 +271,7 @@ namespace ts.GoToDefinition {
|
||||
fileName: targetFileName,
|
||||
textSpan: createTextSpanFromBounds(0, 0),
|
||||
kind: ScriptElementKind.scriptElement,
|
||||
name: name,
|
||||
name,
|
||||
containerName: undefined,
|
||||
containerKind: undefined
|
||||
};
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace ts.OutliningElementsCollector {
|
||||
textSpan: createTextSpanFromBounds(startElement.pos, endElement.end),
|
||||
hintSpan: createTextSpanFromNode(hintSpanNode, sourceFile),
|
||||
bannerText: collapseText,
|
||||
autoCollapse: autoCollapse
|
||||
autoCollapse,
|
||||
};
|
||||
elements.push(span);
|
||||
}
|
||||
@@ -22,7 +22,7 @@ namespace ts.OutliningElementsCollector {
|
||||
textSpan: createTextSpanFromBounds(commentSpan.pos, commentSpan.end),
|
||||
hintSpan: createTextSpanFromBounds(commentSpan.pos, commentSpan.end),
|
||||
bannerText: collapseText,
|
||||
autoCollapse: autoCollapse
|
||||
autoCollapse,
|
||||
};
|
||||
elements.push(span);
|
||||
}
|
||||
@@ -71,7 +71,7 @@ namespace ts.OutliningElementsCollector {
|
||||
const multipleSingleLineComments: CommentRange = {
|
||||
kind: SyntaxKind.SingleLineCommentTrivia,
|
||||
pos: start,
|
||||
end: end,
|
||||
end,
|
||||
};
|
||||
|
||||
addOutliningSpanComments(multipleSingleLineComments, /*autoCollapse*/ false);
|
||||
|
||||
@@ -41,13 +41,9 @@ namespace ts {
|
||||
}
|
||||
|
||||
function getFileReference() {
|
||||
const file = scanner.getTokenValue();
|
||||
const fileName = scanner.getTokenValue();
|
||||
const pos = scanner.getTokenPos();
|
||||
return {
|
||||
fileName: file,
|
||||
pos: pos,
|
||||
end: pos + file.length
|
||||
};
|
||||
return { fileName, pos, end: pos + fileName.length };
|
||||
}
|
||||
|
||||
function recordAmbientExternalModule(): void {
|
||||
|
||||
@@ -838,7 +838,7 @@ namespace ts {
|
||||
entry = {
|
||||
hostFileName: fileName,
|
||||
version: this.host.getScriptVersion(fileName),
|
||||
scriptSnapshot: scriptSnapshot,
|
||||
scriptSnapshot,
|
||||
scriptKind: getScriptKind(fileName, this.host)
|
||||
};
|
||||
}
|
||||
@@ -1524,12 +1524,8 @@ namespace ts {
|
||||
const sourceFile = getValidSourceFile(fileName);
|
||||
const outputFiles: OutputFile[] = [];
|
||||
|
||||
function writeFile(fileName: string, data: string, writeByteOrderMark: boolean) {
|
||||
outputFiles.push({
|
||||
name: fileName,
|
||||
writeByteOrderMark: writeByteOrderMark,
|
||||
text: data
|
||||
});
|
||||
function writeFile(fileName: string, text: string, writeByteOrderMark: boolean) {
|
||||
outputFiles.push({ name: fileName, writeByteOrderMark, text });
|
||||
}
|
||||
|
||||
const customTransformers = host.getCustomTransformers && host.getCustomTransformers();
|
||||
@@ -1773,25 +1769,14 @@ namespace ts {
|
||||
synchronizeHostData();
|
||||
const sourceFile = getValidSourceFile(fileName);
|
||||
const span = { start, length: end - start };
|
||||
const newLineChar = getNewLineOrDefaultFromHost(host);
|
||||
const newLineCharacter = getNewLineOrDefaultFromHost(host);
|
||||
|
||||
let allFixes: CodeAction[] = [];
|
||||
|
||||
forEach(deduplicate(errorCodes), error => {
|
||||
forEach(deduplicate(errorCodes), errorCode => {
|
||||
cancellationToken.throwIfCancellationRequested();
|
||||
|
||||
const context = {
|
||||
errorCode: error,
|
||||
sourceFile: sourceFile,
|
||||
span: span,
|
||||
program: program,
|
||||
newLineCharacter: newLineChar,
|
||||
host: host,
|
||||
cancellationToken: cancellationToken,
|
||||
rulesProvider: getRuleProvider(formatOptions)
|
||||
};
|
||||
|
||||
const fixes = codefix.getFixes(context);
|
||||
const rulesProvider = getRuleProvider(formatOptions);
|
||||
const fixes = codefix.getFixes({ errorCode, sourceFile, span, program, newLineCharacter, host, cancellationToken, rulesProvider });
|
||||
if (fixes) {
|
||||
allFixes = allFixes.concat(fixes);
|
||||
}
|
||||
@@ -1907,11 +1892,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
const message = matchArray[2];
|
||||
result.push({
|
||||
descriptor: descriptor,
|
||||
message: message,
|
||||
position: matchPosition
|
||||
});
|
||||
result.push({ descriptor, message, position: matchPosition });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -242,7 +242,7 @@ namespace ts.textChanges {
|
||||
}
|
||||
|
||||
public insertNodeAt(sourceFile: SourceFile, pos: number, newNode: Node, options: InsertNodeOptions = {}) {
|
||||
this.changes.push({ sourceFile, options, node: newNode, range: { pos: pos, end: pos } });
|
||||
this.changes.push({ sourceFile, options, node: newNode, range: { pos, end: pos } });
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@@ -1198,10 +1198,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
export function displayPart(text: string, kind: SymbolDisplayPartKind): SymbolDisplayPart {
|
||||
return <SymbolDisplayPart>{
|
||||
text: text,
|
||||
kind: SymbolDisplayPartKind[kind]
|
||||
};
|
||||
return { text, kind: SymbolDisplayPartKind[kind] };
|
||||
}
|
||||
|
||||
export function spacePart() {
|
||||
|
||||
Reference in New Issue
Block a user