Enable "object-literal-shorthand" lint rule (#16987)

This commit is contained in:
Andy
2017-07-07 07:26:58 -07:00
committed by GitHub
parent dc81b456e2
commit e7dc2a67ca
32 changed files with 94 additions and 174 deletions

View File

@@ -184,10 +184,7 @@ namespace ts.server {
}
getProjectInfo(fileName: string, needFileNameList: boolean): protocol.ProjectInfo {
const args: protocol.ProjectInfoRequestArgs = {
file: fileName,
needFileNameList: needFileNameList
};
const args: protocol.ProjectInfoRequestArgs = { file: fileName, needFileNameList };
const request = this.processRequest<protocol.ProjectInfoRequest>(CommandNames.ProjectInfo, args);
const response = this.processResponse<protocol.ProjectInfoResponse>(request);
@@ -270,7 +267,7 @@ namespace ts.server {
kindModifiers: entry.kindModifiers,
matchKind: entry.matchKind,
isCaseSensitive: entry.isCaseSensitive,
fileName: fileName,
fileName,
textSpan: ts.createTextSpanFromBounds(start, end)
};
});
@@ -304,7 +301,7 @@ namespace ts.server {
file: fileName,
line: lineOffset.line,
offset: lineOffset.offset,
key: key
key,
};
// TODO: handle FormatCodeOptions
@@ -332,7 +329,7 @@ namespace ts.server {
return {
containerKind: ScriptElementKind.unknown,
containerName: "",
fileName: fileName,
fileName,
textSpan: ts.createTextSpanFromBounds(start, end),
kind: ScriptElementKind.unknown,
name: ""
@@ -358,7 +355,7 @@ namespace ts.server {
return {
containerKind: ScriptElementKind.unknown,
containerName: "",
fileName: fileName,
fileName,
textSpan: ts.createTextSpanFromBounds(start, end),
kind: ScriptElementKind.unknown,
name: ""
@@ -411,7 +408,7 @@ namespace ts.server {
const start = this.lineOffsetToPosition(fileName, entry.start);
const end = this.lineOffsetToPosition(fileName, entry.end);
return {
fileName: fileName,
fileName,
textSpan: ts.createTextSpanFromBounds(start, end),
isWriteAccess: entry.isWriteAccess,
isDefinition: entry.isDefinition,
@@ -456,7 +453,7 @@ namespace ts.server {
start: entry.start,
length: entry.length,
messageText: entry.message,
category: category,
category,
code: entry.code
};
}
@@ -483,10 +480,7 @@ namespace ts.server {
entry.locs.map((loc: protocol.TextSpan) => {
const start = this.lineOffsetToPosition(fileName, loc.start);
const end = this.lineOffsetToPosition(fileName, loc.end);
locations.push({
textSpan: ts.createTextSpanFromBounds(start, end),
fileName: fileName
});
locations.push({ textSpan: ts.createTextSpanFromBounds(start, end), fileName, });
});
});
return this.lastRenameEntry = {
@@ -497,11 +491,11 @@ namespace ts.server {
kindModifiers: response.body.info.kindModifiers,
localizedErrorMessage: response.body.info.localizedErrorMessage,
triggerSpan: ts.createTextSpanFromBounds(position, position),
fileName: fileName,
position: position,
findInStrings: findInStrings,
findInComments: findInComments,
locations: locations
fileName,
position,
findInStrings,
findInComments,
locations,
};
}
@@ -596,10 +590,7 @@ namespace ts.server {
const result: SignatureHelpItems = {
items: helpItems.items,
applicableSpan: {
start: start,
length: end - start
},
applicableSpan: { start, length: end - start },
selectedItemIndex: helpItems.selectedItemIndex,
argumentIndex: helpItems.argumentIndex,
argumentCount: helpItems.argumentCount,
@@ -686,7 +677,7 @@ namespace ts.server {
startOffset: startLineOffset.offset,
endLine: endLineOffset.line,
endOffset: endLineOffset.offset,
errorCodes: errorCodes,
errorCodes,
};
const request = this.processRequest<protocol.CodeFixRequest>(CommandNames.GetCodeFixes, args);
@@ -779,10 +770,7 @@ namespace ts.server {
const end = this.lineOffsetToPosition(fileName, change.end);
return {
span: {
start: start,
length: end - start
},
span: { start, length: end - start },
newText: change.newText ? change.newText : ""
};
}
@@ -801,10 +789,7 @@ namespace ts.server {
return response.body.map(entry => {
const start = this.lineOffsetToPosition(fileName, entry.start);
const end = this.lineOffsetToPosition(fileName, entry.end);
return {
start: start,
length: end - start,
};
return { start, length: end - start };
});
}

View File

@@ -508,7 +508,7 @@ namespace ts.server {
const walkFns = {
goSubtree: true,
done: false,
leaf: function (this: ILineIndexWalker, relativeStart: number, relativeLength: number, ll: LineLeaf) {
leaf(this: ILineIndexWalker, relativeStart: number, relativeLength: number, ll: LineLeaf) {
if (!f(ll, relativeStart, relativeLength)) {
this.done = true;
}
@@ -607,25 +607,25 @@ namespace ts.server {
}
static linesFromText(text: string) {
const lineStarts = ts.computeLineStarts(text);
const lineMap = ts.computeLineStarts(text);
if (lineStarts.length === 0) {
return { lines: <string[]>[], lineMap: lineStarts };
if (lineMap.length === 0) {
return { lines: <string[]>[], lineMap };
}
const lines = <string[]>new Array(lineStarts.length);
const lc = lineStarts.length - 1;
const lines = <string[]>new Array(lineMap.length);
const lc = lineMap.length - 1;
for (let lmi = 0; lmi < lc; lmi++) {
lines[lmi] = text.substring(lineStarts[lmi], lineStarts[lmi + 1]);
lines[lmi] = text.substring(lineMap[lmi], lineMap[lmi + 1]);
}
const endText = text.substring(lineStarts[lc]);
const endText = text.substring(lineMap[lc]);
if (endText.length > 0) {
lines[lc] = endText;
}
else {
lines.length--;
}
return { lines: lines, lineMap: lineStarts };
return { lines, lineMap };
}
}
@@ -791,12 +791,7 @@ namespace ts.server {
charOffset += child.charCount();
}
}
return {
child: child,
childIndex: i,
relativeLineNumber: relativeLineNumber,
charOffset: charOffset
};
return { child, childIndex: i, relativeLineNumber, charOffset };
}
childFromCharOffset(lineNumber: number, charOffset: number) {
@@ -813,12 +808,7 @@ namespace ts.server {
lineNumber += child.lineCount();
}
}
return {
child: child,
childIndex: i,
charOffset: charOffset,
lineNumber: lineNumber
};
return { child, childIndex: i, charOffset, lineNumber };
}
splitAfter(childIndex: number) {

View File

@@ -510,6 +510,7 @@ namespace ts.server {
const watchedFiles: WatchedFile[] = [];
let nextFileToCheck = 0;
let watchTimer: any;
return { getModifiedTime, poll, startWatchTimer, addFile, removeFile };
function getModifiedTime(fileName: string): Date {
return fs.statSync(fileName).mtime;
@@ -577,14 +578,6 @@ namespace ts.server {
function removeFile(file: WatchedFile) {
unorderedRemoveItem(watchedFiles, file);
}
return {
getModifiedTime: getModifiedTime,
poll: poll,
startWatchTimer: startWatchTimer,
addFile: addFile,
removeFile: removeFile
};
}
// REVIEW: for now this implementation uses polling.

View File

@@ -439,7 +439,7 @@ namespace ts.server {
}
const bakedDiags = diags.map((diag) => formatDiag(file, project, diag));
this.event<protocol.DiagnosticEventBody>({ file: file, diagnostics: bakedDiags }, "semanticDiag");
this.event<protocol.DiagnosticEventBody>({ file, diagnostics: bakedDiags }, "semanticDiag");
}
catch (err) {
this.logError(err, "semantic check");
@@ -451,7 +451,7 @@ namespace ts.server {
const diags = project.getLanguageService().getSyntacticDiagnostics(file);
if (diags) {
const bakedDiags = diags.map((diag) => formatDiag(file, project, diag));
this.event<protocol.DiagnosticEventBody>({ file: file, diagnostics: bakedDiags }, "syntaxDiag");
this.event<protocol.DiagnosticEventBody>({ file, diagnostics: bakedDiags }, "syntaxDiag");
}
}
catch (err) {
@@ -939,8 +939,8 @@ namespace ts.server {
const lineText = refScriptInfo.getSnapshot().getText(refLineSpan.start, ts.textSpanEnd(refLineSpan)).replace(/\r|\n/g, "");
return {
file: ref.fileName,
start: start,
lineText: lineText,
start,
lineText,
end: refScriptInfo.positionToLineOffset(ts.textSpanEnd(ref.textSpan)),
isWriteAccess: ref.isWriteAccess,
isDefinition: ref.isDefinition
@@ -1072,7 +1072,7 @@ namespace ts.server {
kindModifiers: quickInfo.kindModifiers,
start: scriptInfo.positionToLineOffset(quickInfo.textSpan.start),
end: scriptInfo.positionToLineOffset(ts.textSpanEnd(quickInfo.textSpan)),
displayString: displayString,
displayString,
documentation: docString,
tags: quickInfo.tags || []
};
@@ -1402,8 +1402,8 @@ namespace ts.server {
name: navItem.name,
kind: navItem.kind,
file: navItem.fileName,
start: start,
end: end,
start,
end,
};
if (navItem.kindModifiers && (navItem.kindModifiers !== "")) {
bakedItem.kindModifiers = navItem.kindModifiers;

View File

@@ -389,7 +389,7 @@ namespace ts.server.typingsInstaller {
this.log.writeLine(`Got FS notification for ${f}, handler is already invoked '${isInvoked}'`);
}
if (!isInvoked) {
this.sendResponse({ projectName: projectName, kind: server.ActionInvalidate });
this.sendResponse({ projectName, kind: server.ActionInvalidate });
isInvoked = true;
}
}, /*pollingInterval*/ 2000);