Skip to content

Commit e7dc2a6

Browse files
author
Andy
authored
Enable "object-literal-shorthand" lint rule (microsoft#16987)
1 parent dc81b45 commit e7dc2a6

32 files changed

+94
-174
lines changed

Gulpfile.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -669,7 +669,7 @@ function runConsoleTests(defaultReporter: string, runInParallel: boolean, done:
669669
}
670670
args.push(run);
671671
setNodeEnvToDevelopment();
672-
runTestsInParallel(taskConfigsFolder, run, { testTimeout: testTimeout, noColors: colors === " --no-colors " }, function(err) {
672+
runTestsInParallel(taskConfigsFolder, run, { testTimeout, noColors: colors === " --no-colors " }, function(err) {
673673
// last worker clean everything and runs linter in case if there were no errors
674674
del(taskConfigsFolder).then(() => {
675675
if (!err) {

src/compiler/checker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21180,7 +21180,7 @@ namespace ts {
2118021180
for (const prop of properties) {
2118121181
const existing = seen.get(prop.name);
2118221182
if (!existing) {
21183-
seen.set(prop.name, { prop: prop, containingType: base });
21183+
seen.set(prop.name, { prop, containingType: base });
2118421184
}
2118521185
else {
2118621186
const isInheritedProperty = existing.containingType !== type;

src/compiler/moduleNameResolver.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -151,11 +151,7 @@ namespace ts {
151151
*/
152152
export function resolveTypeReferenceDirective(typeReferenceDirectiveName: string, containingFile: string | undefined, options: CompilerOptions, host: ModuleResolutionHost): ResolvedTypeReferenceDirectiveWithFailedLookupLocations {
153153
const traceEnabled = isTraceEnabled(options, host);
154-
const moduleResolutionState: ModuleResolutionState = {
155-
compilerOptions: options,
156-
host: host,
157-
traceEnabled
158-
};
154+
const moduleResolutionState: ModuleResolutionState = { compilerOptions: options, host, traceEnabled };
159155

160156
const typeRoots = getEffectiveTypeRoots(options, host);
161157
if (traceEnabled) {

src/compiler/sourcemap.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ namespace ts {
145145

146146
// Initialize source map data
147147
sourceMapData = {
148-
sourceMapFilePath: sourceMapFilePath,
148+
sourceMapFilePath,
149149
jsSourceMappingURL: !compilerOptions.inlineSourceMap ? getBaseFileName(normalizeSlashes(sourceMapFilePath)) : undefined,
150150
sourceMapFile: getBaseFileName(normalizeSlashes(filePath)),
151151
sourceMapSourceRoot: compilerOptions.sourceRoot || "",
@@ -292,8 +292,8 @@ namespace ts {
292292

293293
// New span
294294
lastRecordedSourceMapSpan = {
295-
emittedLine: emittedLine,
296-
emittedColumn: emittedColumn,
295+
emittedLine,
296+
emittedColumn,
297297
sourceLine: sourceLinePos.line,
298298
sourceColumn: sourceLinePos.character,
299299
sourceIndex: sourceMapSourceIndex

src/compiler/sys.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ namespace ts {
325325
const nodeSystem: System = {
326326
args: process.argv.slice(2),
327327
newLine: _os.EOL,
328-
useCaseSensitiveFileNames: useCaseSensitiveFileNames,
328+
useCaseSensitiveFileNames,
329329
write(s: string): void {
330330
process.stdout.write(s);
331331
},
@@ -394,9 +394,7 @@ namespace ts {
394394
}
395395
);
396396
},
397-
resolvePath: function(path: string): string {
398-
return _path.resolve(path);
399-
},
397+
resolvePath: path => _path.resolve(path),
400398
fileExists,
401399
directoryExists,
402400
createDirectory(directoryName: string) {

src/compiler/transformers/generators.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2220,8 +2220,8 @@ namespace ts {
22202220
beginBlock(<LoopBlock>{
22212221
kind: CodeBlockKind.Loop,
22222222
isScript: false,
2223-
breakLabel: breakLabel,
2224-
continueLabel: continueLabel
2223+
breakLabel,
2224+
continueLabel,
22252225
});
22262226
return breakLabel;
22272227
}
@@ -2262,7 +2262,7 @@ namespace ts {
22622262
beginBlock(<SwitchBlock>{
22632263
kind: CodeBlockKind.Switch,
22642264
isScript: false,
2265-
breakLabel: breakLabel
2265+
breakLabel,
22662266
});
22672267
return breakLabel;
22682268
}

src/harness/fourslash.ts

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2544,7 +2544,7 @@ namespace FourSlash {
25442544

25452545
// if there was an explicit match kind specified, then it should be validated.
25462546
if (matchKind !== undefined) {
2547-
const missingItem = { name: name, kind: kind, searchValue: searchValue, matchKind: matchKind, fileName: fileName, parentName: parentName };
2547+
const missingItem = { name, kind, searchValue, matchKind, fileName, parentName };
25482548
this.raiseError(`verifyNavigationItemsListContains failed - could not find the item: ${stringify(missingItem)} in the returned list: (${stringify(items)})`);
25492549
}
25502550
}
@@ -2618,7 +2618,7 @@ namespace FourSlash {
26182618
}
26192619
}
26202620

2621-
const missingItem = { fileName: fileName, start: start, end: end, isWriteAccess: isWriteAccess };
2621+
const missingItem = { fileName, start, end, isWriteAccess };
26222622
this.raiseError(`verifyOccurrencesAtPositionListContains failed - could not find the item: ${stringify(missingItem)} in the returned list: (${stringify(occurrences)})`);
26232623
}
26242624

@@ -3239,7 +3239,7 @@ ${code}
32393239
}
32403240

32413241
const range: Range = {
3242-
fileName: fileName,
3242+
fileName,
32433243
start: rangeStart.position,
32443244
end: (i - 1) - difference,
32453245
marker: rangeStart.marker
@@ -3367,7 +3367,7 @@ ${code}
33673367
content: output,
33683368
fileOptions: {},
33693369
version: 0,
3370-
fileName: fileName
3370+
fileName,
33713371
};
33723372
}
33733373

@@ -4198,11 +4198,8 @@ namespace FourSlashInterface {
41984198
}
41994199

42004200
function getClassification(classificationType: ts.ClassificationTypeNames, text: string, position?: number): Classification {
4201-
return {
4202-
classificationType,
4203-
text: text,
4204-
textSpan: position === undefined ? undefined : { start: position, end: position + text.length }
4205-
};
4201+
const textSpan = position === undefined ? undefined : { start: position, end: position + text.length };
4202+
return { classificationType, text, textSpan };
42064203
}
42074204
}
42084205
}

src/harness/projectsRunner.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ class ProjectRunner extends RunnerBase {
354354
ensureDirectoryStructure(ts.getDirectoryPath(ts.normalizePath(outputFilePath)));
355355
Harness.IO.writeFile(outputFilePath, data);
356356

357-
outputFiles.push({ emittedFileName: fileName, code: data, fileName: diskRelativeName, writeByteOrderMark: writeByteOrderMark });
357+
outputFiles.push({ emittedFileName: fileName, code: data, fileName: diskRelativeName, writeByteOrderMark });
358358
}
359359
}
360360

src/harness/sourceMapRecorder.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ namespace Harness.SourceMapRecorder {
259259
export function recordSourceMapSpan(sourceMapSpan: ts.SourceMapSpan) {
260260
// verify the decoded span is same as the new span
261261
const decodeResult = SourceMapDecoder.decodeNextEncodedSourceMapSpan();
262-
let decodedErrors: string[];
262+
let decodeErrors: string[];
263263
if (decodeResult.error
264264
|| decodeResult.sourceMapSpan.emittedLine !== sourceMapSpan.emittedLine
265265
|| decodeResult.sourceMapSpan.emittedColumn !== sourceMapSpan.emittedColumn
@@ -268,22 +268,20 @@ namespace Harness.SourceMapRecorder {
268268
|| decodeResult.sourceMapSpan.sourceIndex !== sourceMapSpan.sourceIndex
269269
|| decodeResult.sourceMapSpan.nameIndex !== sourceMapSpan.nameIndex) {
270270
if (decodeResult.error) {
271-
decodedErrors = ["!!^^ !!^^ There was decoding error in the sourcemap at this location: " + decodeResult.error];
271+
decodeErrors = ["!!^^ !!^^ There was decoding error in the sourcemap at this location: " + decodeResult.error];
272272
}
273273
else {
274-
decodedErrors = ["!!^^ !!^^ The decoded span from sourcemap's mapping entry does not match what was encoded for this span:"];
274+
decodeErrors = ["!!^^ !!^^ The decoded span from sourcemap's mapping entry does not match what was encoded for this span:"];
275275
}
276-
decodedErrors.push("!!^^ !!^^ Decoded span from sourcemap's mappings entry: " + getSourceMapSpanString(decodeResult.sourceMapSpan, /*getAbsentNameIndex*/ true) + " Span encoded by the emitter:" + getSourceMapSpanString(sourceMapSpan, /*getAbsentNameIndex*/ true));
276+
decodeErrors.push("!!^^ !!^^ Decoded span from sourcemap's mappings entry: " + getSourceMapSpanString(decodeResult.sourceMapSpan, /*getAbsentNameIndex*/ true) + " Span encoded by the emitter:" + getSourceMapSpanString(sourceMapSpan, /*getAbsentNameIndex*/ true));
277277
}
278278

279279
if (spansOnSingleLine.length && spansOnSingleLine[0].sourceMapSpan.emittedLine !== sourceMapSpan.emittedLine) {
280280
// On different line from the one that we have been recording till now,
281281
writeRecordedSpans();
282-
spansOnSingleLine = [{ sourceMapSpan: sourceMapSpan, decodeErrors: decodedErrors }];
283-
}
284-
else {
285-
spansOnSingleLine.push({ sourceMapSpan: sourceMapSpan, decodeErrors: decodedErrors });
282+
spansOnSingleLine = [];
286283
}
284+
spansOnSingleLine.push({ sourceMapSpan, decodeErrors });
287285
}
288286

289287
export function recordNewSourceFileSpan(sourceMapSpan: ts.SourceMapSpan, newSourceFileCode: string) {

src/harness/test262Runner.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class Test262BaselineRunner extends RunnerBase {
4848
// Emit the results
4949
testState = {
5050
filename: testFilename,
51-
inputFiles: inputFiles,
51+
inputFiles,
5252
compilerResult: undefined,
5353
};
5454

0 commit comments

Comments
 (0)