Skip to content

Commit 2b8ef5e

Browse files
Merge pull request microsoft#4008 from weswigham/fix-many-linter-errors
Fix as many linter errors as possible
2 parents 8a64262 + 5324f8b commit 2b8ef5e

22 files changed

Lines changed: 637 additions & 631 deletions

src/compiler/binder.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ namespace ts {
139139
function getDeclarationName(node: Declaration): string {
140140
if (node.name) {
141141
if (node.kind === SyntaxKind.ModuleDeclaration && node.name.kind === SyntaxKind.StringLiteral) {
142-
return '"' + (<LiteralExpression>node.name).text + '"';
142+
return `"${(<LiteralExpression>node.name).text}"`;
143143
}
144144
if (node.name.kind === SyntaxKind.ComputedPropertyName) {
145145
let nameExpression = (<ComputedPropertyName>node.name).expression;
@@ -830,7 +830,7 @@ namespace ts {
830830

831831
// Note: the node text must be exactly "use strict" or 'use strict'. It is not ok for the
832832
// string to contain unicode escapes (as per ES5).
833-
return nodeText === '"use strict"' || nodeText === "'use strict'";
833+
return nodeText === "\"use strict\"" || nodeText === "'use strict'";
834834
}
835835

836836
function bindWorker(node: Node) {
@@ -930,7 +930,7 @@ namespace ts {
930930
function bindSourceFileIfExternalModule() {
931931
setExportContextFlag(file);
932932
if (isExternalModule(file)) {
933-
bindAnonymousDeclaration(file, SymbolFlags.ValueModule, '"' + removeFileExtension(file.fileName) + '"');
933+
bindAnonymousDeclaration(file, SymbolFlags.ValueModule, `"${removeFileExtension(file.fileName)}"`);
934934
}
935935
}
936936

src/compiler/checker.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,9 @@ namespace ts {
211211
let assignableRelation: Map<RelationComparisonResult> = {};
212212
let identityRelation: Map<RelationComparisonResult> = {};
213213

214+
// This is for caching the result of getSymbolDisplayBuilder. Do not access directly.
215+
let _displayBuilder: SymbolDisplayBuilder;
216+
214217
type TypeSystemEntity = Symbol | Type | Signature;
215218

216219
const enum TypeSystemPropertyName {
@@ -965,7 +968,7 @@ namespace ts {
965968
if (!moduleName) return;
966969
let isRelative = isExternalModuleNameRelative(moduleName);
967970
if (!isRelative) {
968-
let symbol = getSymbol(globals, '"' + moduleName + '"', SymbolFlags.ValueModule);
971+
let symbol = getSymbol(globals, "\"" + moduleName + "\"", SymbolFlags.ValueModule);
969972
if (symbol) {
970973
return symbol;
971974
}
@@ -1490,8 +1493,6 @@ namespace ts {
14901493
return undefined;
14911494
}
14921495

1493-
// This is for caching the result of getSymbolDisplayBuilder. Do not access directly.
1494-
let _displayBuilder: SymbolDisplayBuilder;
14951496
function getSymbolDisplayBuilder(): SymbolDisplayBuilder {
14961497

14971498
function getNameOfSymbol(symbol: Symbol): string {
@@ -3448,7 +3449,7 @@ namespace ts {
34483449
// type, a property is considered known if it is known in any constituent type.
34493450
function isKnownProperty(type: Type, name: string): boolean {
34503451
if (type.flags & TypeFlags.ObjectType && type !== globalObjectType) {
3451-
var resolved = resolveStructuredTypeMembers(type);
3452+
const resolved = resolveStructuredTypeMembers(type);
34523453
return !!(resolved.properties.length === 0 ||
34533454
resolved.stringIndexType ||
34543455
resolved.numberIndexType ||
@@ -7355,7 +7356,7 @@ namespace ts {
73557356
}
73567357

73577358
// Wasn't found
7358-
error(node, Diagnostics.Property_0_does_not_exist_on_type_1, (<Identifier>node.tagName).text, 'JSX.' + JsxNames.IntrinsicElements);
7359+
error(node, Diagnostics.Property_0_does_not_exist_on_type_1, (<Identifier>node.tagName).text, "JSX." + JsxNames.IntrinsicElements);
73597360
return unknownSymbol;
73607361
}
73617362
else {
@@ -7395,7 +7396,7 @@ namespace ts {
73957396
function getJsxElementInstanceType(node: JsxOpeningLikeElement) {
73967397
// There is no such thing as an instance type for a non-class element. This
73977398
// line shouldn't be hit.
7398-
Debug.assert(!!(getNodeLinks(node).jsxFlags & JsxFlags.ClassElement), 'Should not call getJsxElementInstanceType on non-class Element');
7399+
Debug.assert(!!(getNodeLinks(node).jsxFlags & JsxFlags.ClassElement), "Should not call getJsxElementInstanceType on non-class Element");
73997400

74007401
let classSymbol = getJsxElementTagSymbol(node);
74017402
if (classSymbol === unknownSymbol) {
@@ -7575,7 +7576,7 @@ namespace ts {
75757576
// be marked as 'used' so we don't incorrectly elide its import. And if there
75767577
// is no 'React' symbol in scope, we should issue an error.
75777578
if (compilerOptions.jsx === JsxEmit.React) {
7578-
let reactSym = resolveName(node.tagName, 'React', SymbolFlags.Value, Diagnostics.Cannot_find_name_0, 'React');
7579+
let reactSym = resolveName(node.tagName, "React", SymbolFlags.Value, Diagnostics.Cannot_find_name_0, "React");
75797580
if (reactSym) {
75807581
getSymbolLinks(reactSym).referenced = true;
75817582
}

src/compiler/commandLineParser.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ namespace ts {
335335
* @param fileName The path to the config file
336336
*/
337337
export function readConfigFile(fileName: string): { config?: any; error?: Diagnostic } {
338-
let text = '';
338+
let text = "";
339339
try {
340340
text = sys.readFile(fileName);
341341
}
@@ -423,7 +423,7 @@ namespace ts {
423423
fileNames = map(<string[]>json["files"], s => combinePaths(basePath, s));
424424
}
425425
else {
426-
errors.push(createCompilerDiagnostic(Diagnostics.Compiler_option_0_requires_a_value_of_type_1, 'files', 'Array'));
426+
errors.push(createCompilerDiagnostic(Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "files", "Array"));
427427
}
428428
}
429429
else {

src/compiler/core.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -219,10 +219,10 @@ namespace ts {
219219
export function reduceLeft<T, U>(array: T[], f: (a: U, x: T) => U, initial: U): U;
220220
export function reduceLeft<T, U>(array: T[], f: (a: U, x: T) => U, initial?: U): U {
221221
if (array) {
222-
var count = array.length;
222+
const count = array.length;
223223
if (count > 0) {
224-
var pos = 0;
225-
var result = arguments.length <= 2 ? array[pos++] : initial;
224+
let pos = 0;
225+
let result = arguments.length <= 2 ? array[pos++] : initial;
226226
while (pos < count) {
227227
result = f(<U>result, array[pos++]);
228228
}
@@ -236,9 +236,9 @@ namespace ts {
236236
export function reduceRight<T, U>(array: T[], f: (a: U, x: T) => U, initial: U): U;
237237
export function reduceRight<T, U>(array: T[], f: (a: U, x: T) => U, initial?: U): U {
238238
if (array) {
239-
var pos = array.length - 1;
239+
let pos = array.length - 1;
240240
if (pos >= 0) {
241-
var result = arguments.length <= 2 ? array[pos--] : initial;
241+
let result = arguments.length <= 2 ? array[pos--] : initial;
242242
while (pos >= 0) {
243243
result = f(<U>result, array[pos--]);
244244
}
@@ -523,7 +523,7 @@ namespace ts {
523523
if (path.lastIndexOf("file:///", 0) === 0) {
524524
return "file:///".length;
525525
}
526-
let idx = path.indexOf('://');
526+
let idx = path.indexOf("://");
527527
if (idx !== -1) {
528528
return idx + "://".length;
529529
}
@@ -805,4 +805,4 @@ namespace ts {
805805
Debug.assert(false, message);
806806
}
807807
}
808-
}
808+
}

src/compiler/emitter.ts

Lines changed: 31 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
380380
function base64VLQFormatEncode(inValue: number) {
381381
function base64FormatEncode(inValue: number) {
382382
if (inValue < 64) {
383-
return 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'.charAt(inValue);
383+
return "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(inValue);
384384
}
385385
throw TypeError(inValue + ": not a 64 based value");
386386
}
@@ -895,7 +895,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
895895
// Any template literal or string literal with an extended escape
896896
// (e.g. "\u{0067}") will need to be downleveled as a escaped string literal.
897897
if (languageVersion < ScriptTarget.ES6 && (isTemplateLiteralKind(node.kind) || node.hasExtendedUnicodeEscape)) {
898-
return getQuotedEscapedLiteralText('"', node.text, '"');
898+
return getQuotedEscapedLiteralText("\"", node.text, "\"");
899899
}
900900

901901
// If we don't need to downlevel and we can reach the original source text using
@@ -908,15 +908,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
908908
// or an escaped quoted form of the original text if it's string-like.
909909
switch (node.kind) {
910910
case SyntaxKind.StringLiteral:
911-
return getQuotedEscapedLiteralText('"', node.text, '"');
911+
return getQuotedEscapedLiteralText("\"", node.text, "\"");
912912
case SyntaxKind.NoSubstitutionTemplateLiteral:
913-
return getQuotedEscapedLiteralText('`', node.text, '`');
913+
return getQuotedEscapedLiteralText("`", node.text, "`");
914914
case SyntaxKind.TemplateHead:
915-
return getQuotedEscapedLiteralText('`', node.text, '${');
915+
return getQuotedEscapedLiteralText("`", node.text, "${");
916916
case SyntaxKind.TemplateMiddle:
917-
return getQuotedEscapedLiteralText('}', node.text, '${');
917+
return getQuotedEscapedLiteralText("}", node.text, "${");
918918
case SyntaxKind.TemplateTail:
919-
return getQuotedEscapedLiteralText('}', node.text, '`');
919+
return getQuotedEscapedLiteralText("}", node.text, "`");
920920
case SyntaxKind.NumericLiteral:
921921
return node.text;
922922
}
@@ -947,7 +947,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
947947
text = text.replace(/\r\n?/g, "\n");
948948
text = escapeString(text);
949949

950-
write('"' + text + '"');
950+
write(`"${text}"`);
951951
}
952952

953953
function emitDownlevelTaggedTemplateArray(node: TaggedTemplateExpression, literalEmitter: (literal: LiteralExpression) => void) {
@@ -1134,9 +1134,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
11341134
/// 'Div' for upper-cased or dotted names
11351135
function emitTagName(name: Identifier|QualifiedName) {
11361136
if (name.kind === SyntaxKind.Identifier && isIntrinsicJsxName((<Identifier>name).text)) {
1137-
write('"');
1137+
write("\"");
11381138
emit(name);
1139-
write('"');
1139+
write("\"");
11401140
}
11411141
else {
11421142
emit(name);
@@ -1148,9 +1148,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
11481148
/// about keywords, just non-identifier characters
11491149
function emitAttributeName(name: Identifier) {
11501150
if (/[A-Za-z_]+[\w*]/.test(name.text)) {
1151-
write('"');
1151+
write("\"");
11521152
emit(name);
1153-
write('"');
1153+
write("\"");
11541154
}
11551155
else {
11561156
emit(name);
@@ -1248,10 +1248,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
12481248
// Don't emit empty strings
12491249
if (children[i].kind === SyntaxKind.JsxText) {
12501250
let text = getTextToEmit(<JsxText>children[i]);
1251-
if(text !== undefined) {
1252-
write(', "');
1251+
if (text !== undefined) {
1252+
write(", \"");
12531253
write(text);
1254-
write('"');
1254+
write("\"");
12551255
}
12561256
}
12571257
else {
@@ -1491,7 +1491,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
14911491
if (declaration.kind === SyntaxKind.ImportClause) {
14921492
// Identifier references default import
14931493
write(getGeneratedNameForNode(<ImportDeclaration>declaration.parent));
1494-
write(languageVersion === ScriptTarget.ES3 ? '["default"]' : ".default");
1494+
write(languageVersion === ScriptTarget.ES3 ? "[\"default\"]" : ".default");
14951495
return;
14961496
}
14971497
else if (declaration.kind === SyntaxKind.ImportSpecifier) {
@@ -4270,11 +4270,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
42704270
emitDetachedComments(ctor.body.statements);
42714271
}
42724272
emitCaptureThisForNodeIfNecessary(node);
4273+
let superCall: ExpressionStatement;
42734274
if (ctor) {
42744275
emitDefaultValueAssignments(ctor);
42754276
emitRestParameter(ctor);
42764277
if (baseTypeElement) {
4277-
var superCall = findInitialSuperCall(ctor);
4278+
superCall = findInitialSuperCall(ctor);
42784279
if (superCall) {
42794280
writeLine();
42804281
emit(superCall);
@@ -4951,7 +4952,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
49514952
let temp = createAndRecordTempVariable(TempFlags.Auto);
49524953
write("(typeof (");
49534954
emitNodeWithoutSourceMap(temp);
4954-
write(" = ")
4955+
write(" = ");
49554956
emitEntityNameAsExpression(typeName, /*useFallback*/ true);
49564957
write(") === 'function' && ");
49574958
emitNodeWithoutSourceMap(temp);
@@ -5010,7 +5011,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
50105011
//
50115012
// For the rules on serializing the type of each parameter declaration, see `serializeTypeOfDeclaration`.
50125013
if (node) {
5013-
var valueDeclaration: FunctionLikeDeclaration;
5014+
let valueDeclaration: FunctionLikeDeclaration;
50145015
if (node.kind === SyntaxKind.ClassDeclaration) {
50155016
valueDeclaration = getFirstConstructorWithBody(<ClassDeclaration>node);
50165017
}
@@ -5019,16 +5020,16 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
50195020
}
50205021

50215022
if (valueDeclaration) {
5022-
var parameters = valueDeclaration.parameters;
5023-
var parameterCount = parameters.length;
5023+
const parameters = valueDeclaration.parameters;
5024+
const parameterCount = parameters.length;
50245025
if (parameterCount > 0) {
50255026
for (var i = 0; i < parameterCount; i++) {
50265027
if (i > 0) {
50275028
write(", ");
50285029
}
50295030

50305031
if (parameters[i].dotDotDotToken) {
5031-
var parameterType = parameters[i].type;
5032+
let parameterType = parameters[i].type;
50325033
if (parameterType.kind === SyntaxKind.ArrayType) {
50335034
parameterType = (<ArrayTypeNode>parameterType).elementType;
50345035
}
@@ -5840,7 +5841,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
58405841
writeLine();
58415842
write("}");
58425843
writeLine();
5843-
write(`${exportFunctionForFile}(exports);`)
5844+
write(`${exportFunctionForFile}(exports);`);
58445845
decreaseIndent();
58455846
writeLine();
58465847
write("}");
@@ -6188,7 +6189,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
61886189
// exports_(reexports);
61896190
let reexportsVariableName = makeUniqueName("reexports");
61906191
writeLine();
6191-
write(`var ${reexportsVariableName} = {};`)
6192+
write(`var ${reexportsVariableName} = {};`);
61926193
writeLine();
61936194
for (let e of (<ExportDeclaration>importNode).exportClause.elements) {
61946195
write(`${reexportsVariableName}["`);
@@ -6454,7 +6455,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
64546455
if (isLineBreak(c)) {
64556456
if (firstNonWhitespace !== -1 && (lastNonWhitespace - firstNonWhitespace + 1 > 0)) {
64566457
let part = text.substr(firstNonWhitespace, lastNonWhitespace - firstNonWhitespace + 1);
6457-
result = (result ? result + '" + \' \' + "' : '') + part;
6458+
result = (result ? result + "\" + ' ' + \"" : "") + part;
64586459
}
64596460
firstNonWhitespace = -1;
64606461
}
@@ -6467,7 +6468,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
64676468
}
64686469
if (firstNonWhitespace !== -1) {
64696470
let part = text.substr(firstNonWhitespace);
6470-
result = (result ? result + '" + \' \' + "' : '') + part;
6471+
result = (result ? result + "\" + ' ' + \"" : "") + part;
64716472
}
64726473

64736474
return result;
@@ -6492,9 +6493,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
64926493
function emitJsxText(node: JsxText) {
64936494
switch (compilerOptions.jsx) {
64946495
case JsxEmit.React:
6495-
write('"');
6496+
write("\"");
64966497
write(trimReactWhitespace(node));
6497-
write('"');
6498+
write("\"");
64986499
break;
64996500

65006501
case JsxEmit.Preserve:
@@ -6509,9 +6510,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
65096510
switch (compilerOptions.jsx) {
65106511
case JsxEmit.Preserve:
65116512
default:
6512-
write('{');
6513+
write("{");
65136514
emit(node.expression);
6514-
write('}');
6515+
write("}");
65156516
break;
65166517
case JsxEmit.React:
65176518
emit(node.expression);

0 commit comments

Comments
 (0)