From 91421c8dbc0dfa5c50e7219dab22abbd82c77d4f Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Fri, 10 Feb 2017 12:24:10 -0800 Subject: [PATCH] Fix "semicolon" lint rule options (was not enabled) --- src/compiler/checker.ts | 2 +- src/compiler/core.ts | 4 ++-- src/compiler/moduleNameResolver.ts | 2 +- src/compiler/transformers/es2015.ts | 2 +- src/harness/fourslash.ts | 4 ++-- src/harness/harness.ts | 2 +- src/harness/unittests/compileOnSave.ts | 2 +- src/harness/unittests/printer.ts | 2 +- src/harness/unittests/textStorage.ts | 2 +- src/harness/unittests/tsserverProjectSystem.ts | 10 +++++----- src/harness/unittests/typingsInstaller.ts | 4 ++-- src/server/editorServices.ts | 4 ++-- src/server/project.ts | 4 ++-- src/server/scriptInfo.ts | 2 +- src/server/server.ts | 4 ++-- src/server/typingsInstaller/nodeTypingsInstaller.ts | 4 +--- src/services/codefixes/importFixes.ts | 6 +++--- src/services/findAllReferences.ts | 4 ++-- tslint.json | 2 +- 19 files changed, 32 insertions(+), 34 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index ac1135788c..cd06c3b577 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -19760,7 +19760,7 @@ namespace ts { } if (potentialNewTargetCollisions.length) { - forEach(potentialNewTargetCollisions, checkIfNewTargetIsCapturedInEnclosingScope) + forEach(potentialNewTargetCollisions, checkIfNewTargetIsCapturedInEnclosingScope); potentialNewTargetCollisions.length = 0; } diff --git a/src/compiler/core.ts b/src/compiler/core.ts index 94e32dfdbb..e75cd09170 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -84,7 +84,7 @@ namespace ts { this.index++; return { value: this.selector(this.data, this.keys[index]), done: false }; } - return { value: undefined as never, done: true } + return { value: undefined as never, done: true }; } } @@ -140,7 +140,7 @@ namespace ts { action(this.data[key], key); } } - } + }; } export function createFileMap(keyMapper?: (key: string) => string): FileMap { diff --git a/src/compiler/moduleNameResolver.ts b/src/compiler/moduleNameResolver.ts index 0300ff71ec..651c8b3897 100644 --- a/src/compiler/moduleNameResolver.ts +++ b/src/compiler/moduleNameResolver.ts @@ -958,7 +958,7 @@ namespace ts { const result = cache && cache.get(containingDirectory); if (result) { if (traceEnabled) { - trace(host, Diagnostics.Resolution_for_module_0_was_found_in_cache, moduleName) + trace(host, Diagnostics.Resolution_for_module_0_was_found_in_cache, moduleName); } return { value: result.resolvedModule && { path: result.resolvedModule.resolvedFileName, extension: result.resolvedModule.extension } }; } diff --git a/src/compiler/transformers/es2015.ts b/src/compiler/transformers/es2015.ts index e0fd435a90..9c11364ed3 100644 --- a/src/compiler/transformers/es2015.ts +++ b/src/compiler/transformers/es2015.ts @@ -2581,7 +2581,7 @@ namespace ts { if (loopOutParameters.length) { copyOutParameters(loopOutParameters, CopyDirection.ToOutParameter, statements); } - addRange(statements, lexicalEnvironment) + addRange(statements, lexicalEnvironment); loopBody = createBlock(statements, /*multiline*/ true); } diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index fc85fb7276..5d63298b94 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -571,7 +571,7 @@ namespace FourSlash { } private getGoToDefinition(): ts.DefinitionInfo[] { - return this.languageService.getDefinitionAtPosition(this.activeFile.fileName, this.currentCaretPosition) + return this.languageService.getDefinitionAtPosition(this.activeFile.fileName, this.currentCaretPosition); } public verifyGoToType(arg0: any, endMarkerNames?: string | string[]) { @@ -912,7 +912,7 @@ namespace FourSlash { function rangeToReferenceEntry(r: Range) { let { isWriteAccess, isDefinition } = (r.marker && r.marker.data) || { isWriteAccess: false, isDefinition: false }; isWriteAccess = !!isWriteAccess; isDefinition = !!isDefinition; - return { fileName: r.fileName, textSpan: { start: r.start, length: r.end - r.start }, isWriteAccess, isDefinition } + return { fileName: r.fileName, textSpan: { start: r.start, length: r.end - r.start }, isWriteAccess, isDefinition }; } } diff --git a/src/harness/harness.ts b/src/harness/harness.ts index 1dd41f9d81..f999c6a008 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -44,7 +44,7 @@ declare namespace NodeJS { declare var window: {}; declare var XMLHttpRequest: { new(): XMLHttpRequest; -} +}; interface XMLHttpRequest { readonly readyState: number; readonly responseText: string; diff --git a/src/harness/unittests/compileOnSave.ts b/src/harness/unittests/compileOnSave.ts index c8deb9e755..0c9390924a 100644 --- a/src/harness/unittests/compileOnSave.ts +++ b/src/harness/unittests/compileOnSave.ts @@ -495,7 +495,7 @@ namespace ts.projectSystem { const emitOutput = host.readFile(path + ".js"); assert.equal(emitOutput, f.content + newLine, "content of emit output should be identical with the input + newline"); } - }) + }); it("should emit specified file", () => { const file1 = { diff --git a/src/harness/unittests/printer.ts b/src/harness/unittests/printer.ts index 2496a880bc..1a5a5a12f9 100644 --- a/src/harness/unittests/printer.ts +++ b/src/harness/unittests/printer.ts @@ -9,7 +9,7 @@ namespace ts { Harness.Baseline.runBaseline(`printerApi/${prefix}.${name}.js`, () => printCallback(createPrinter({ newLine: NewLineKind.CarriageReturnLineFeed, ...options }))); }); - } + }; } describe("printFile", () => { diff --git a/src/harness/unittests/textStorage.ts b/src/harness/unittests/textStorage.ts index b4287f2610..545d090df9 100644 --- a/src/harness/unittests/textStorage.ts +++ b/src/harness/unittests/textStorage.ts @@ -65,6 +65,6 @@ namespace ts.textStorage { ts1.getLineInfo(0); assert.isTrue(ts1.hasScriptVersionCache(), "have script version cache - 2"); - }) + }); }); } \ No newline at end of file diff --git a/src/harness/unittests/tsserverProjectSystem.ts b/src/harness/unittests/tsserverProjectSystem.ts index e6f4abde38..228d6aa8f6 100644 --- a/src/harness/unittests/tsserverProjectSystem.ts +++ b/src/harness/unittests/tsserverProjectSystem.ts @@ -600,7 +600,7 @@ namespace ts.projectSystem { checkProjectActualFiles(service.configuredProjects[0], []); checkProjectActualFiles(service.inferredProjects[0], [f1.path]); - }) + }); it("create configured project without file list", () => { const configFile: FileOrFolder = { @@ -1153,7 +1153,7 @@ namespace ts.projectSystem { const host = createServerHost([f1, f2, libFile]); const service = createProjectService(host); - service.openExternalProject({ projectFileName: "/a/b/project", rootFiles: toExternalFiles([f1.path, f2.path]), options: {} }) + service.openExternalProject({ projectFileName: "/a/b/project", rootFiles: toExternalFiles([f1.path, f2.path]), options: {} }); service.openClientFile(f1.path); service.openClientFile(f2.path, "let x: string"); @@ -1185,7 +1185,7 @@ namespace ts.projectSystem { const host = createServerHost([f1, f2, libFile]); const service = createProjectService(host); - service.openExternalProject({ projectFileName: "/a/b/project", rootFiles: [{ fileName: f1.path }, { fileName: f2.path, hasMixedContent: true }], options: {} }) + service.openExternalProject({ projectFileName: "/a/b/project", rootFiles: [{ fileName: f1.path }, { fileName: f2.path, hasMixedContent: true }], options: {} }); service.openClientFile(f1.path); service.openClientFile(f2.path, "let somelongname: string"); @@ -1868,7 +1868,7 @@ namespace ts.projectSystem { for (const f of [f2, f3]) { const scriptInfo = projectService.getScriptInfoForNormalizedPath(server.toNormalizedPath(f.path)); - assert.equal(scriptInfo.containingProjects.length, 0, `expect 0 containing projects for '${f.path}'`) + assert.equal(scriptInfo.containingProjects.length, 0, `expect 0 containing projects for '${f.path}'`); } }); @@ -1984,7 +1984,7 @@ namespace ts.projectSystem { projectFileName, rootFiles: [toExternalFile(f1.path)], options: {} - }) + }); projectService.openClientFile(f1.path, "let x = 1;\nlet y = 2;"); projectService.checkNumberOfProjects({ externalProjects: 1 }); diff --git a/src/harness/unittests/typingsInstaller.ts b/src/harness/unittests/typingsInstaller.ts index 29076df80f..2eae01c352 100644 --- a/src/harness/unittests/typingsInstaller.ts +++ b/src/harness/unittests/typingsInstaller.ts @@ -56,7 +56,7 @@ namespace ts.projectSystem { path: "/a/config.js", content: "export let x = 1" }; - const typesCache = "/cache" + const typesCache = "/cache"; const typesConfig = { path: typesCache + "/node_modules/@types/config/index.d.ts", content: "export let y: number;" @@ -74,7 +74,7 @@ namespace ts.projectSystem { super(host, { typesRegistry: createTypesRegistry("config"), globalTypingsCacheLocation: typesCache }); } installWorker(_requestId: number, _args: string[], _cwd: string, _cb: server.typingsInstaller.RequestCompletedAction) { - assert(false, "should not be called") + assert(false, "should not be called"); } })(); const service = createProjectService(host, { typingsInstaller: installer }); diff --git a/src/server/editorServices.ts b/src/server/editorServices.ts index edc4fab9a1..f0aaba3d5b 100644 --- a/src/server/editorServices.ts +++ b/src/server/editorServices.ts @@ -140,7 +140,7 @@ namespace ts.server { getScriptKind: _ => undefined, hasMixedContent: (fileName, extraFileExtensions) => { const mixedContentExtensions = ts.map(ts.filter(extraFileExtensions, item => item.isMixedContent), item => item.extension); - return forEach(mixedContentExtensions, extension => fileExtensionIs(fileName, extension)) + return forEach(mixedContentExtensions, extension => fileExtensionIs(fileName, extension)); } }; @@ -1377,7 +1377,7 @@ namespace ts.server { // close projects that were missing in the input list forEachKey(projectsToClose, externalProjectName => { - this.closeExternalProject(externalProjectName, /*suppressRefresh*/ true) + this.closeExternalProject(externalProjectName, /*suppressRefresh*/ true); }); this.refreshInferredProjects(); diff --git a/src/server/project.ts b/src/server/project.ts index 6042fd9a62..4f218d3900 100644 --- a/src/server/project.ts +++ b/src/server/project.ts @@ -689,7 +689,7 @@ namespace ts.server { const fileName = resolvedTypeReferenceDirective.resolvedFileName; const typeFilePath = toPath(fileName, currentDirectory, getCanonicalFileName); referencedFiles.set(typeFilePath, true); - }) + }); } const allFileNames = arrayFrom(referencedFiles.keys()) as Path[]; @@ -711,7 +711,7 @@ namespace ts.server { const id = nextId; nextId++; return makeInferredProjectName(id); - } + }; })(); private _isJsInferredProject = false; diff --git a/src/server/scriptInfo.ts b/src/server/scriptInfo.ts index be3ef34ce3..e5df91fd93 100644 --- a/src/server/scriptInfo.ts +++ b/src/server/scriptInfo.ts @@ -48,7 +48,7 @@ namespace ts.server { public reloadFromFile(tempFileName?: string) { if (this.svc || (tempFileName !== this.fileName)) { - this.reload(this.getFileText(tempFileName)) + this.reload(this.getFileText(tempFileName)); } else { this.setText(undefined); diff --git a/src/server/server.ts b/src/server/server.ts index e689a2fc78..989c355884 100644 --- a/src/server/server.ts +++ b/src/server/server.ts @@ -46,14 +46,14 @@ namespace ts.server { if (process.env.XDG_CACHE_HOME) { return process.env.XDG_CACHE_HOME; } - const usersDir = platformIsDarwin ? "Users" : "home" + const usersDir = platformIsDarwin ? "Users" : "home"; const homePath = (os.homedir && os.homedir()) || process.env.HOME || ((process.env.LOGNAME || process.env.USER) && `/${usersDir}/${process.env.LOGNAME || process.env.USER}`) || os.tmpdir(); const cacheFolder = platformIsDarwin ? "Library/Caches" - : ".cache" + : ".cache"; return combinePaths(normalizeSlashes(homePath), cacheFolder); } diff --git a/src/server/typingsInstaller/nodeTypingsInstaller.ts b/src/server/typingsInstaller/nodeTypingsInstaller.ts index ff20e89e2d..447a2c0542 100644 --- a/src/server/typingsInstaller/nodeTypingsInstaller.ts +++ b/src/server/typingsInstaller/nodeTypingsInstaller.ts @@ -61,9 +61,7 @@ namespace ts.server.typingsInstaller { return combinePaths(normalizeSlashes(globalTypingsCacheLocation), `node_modules/${TypesRegistryPackageName}/index.json`); } - type ExecSync = { - (command: string, options: { cwd: string, stdio?: "ignore" }): any - } + type ExecSync = (command: string, options: { cwd: string, stdio?: "ignore" }) => any; export class NodeTypingsInstaller extends TypingsInstaller { private readonly execSync: ExecSync; diff --git a/src/services/codefixes/importFixes.ts b/src/services/codefixes/importFixes.ts index 1f1b499d03..1c15725705 100644 --- a/src/services/codefixes/importFixes.ts +++ b/src/services/codefixes/importFixes.ts @@ -3,8 +3,8 @@ namespace ts.codefix { type ImportCodeActionKind = "CodeChange" | "InsertingIntoExistingImport" | "NewImport"; interface ImportCodeAction extends CodeAction { - kind: ImportCodeActionKind, - moduleSpecifier?: string + kind: ImportCodeActionKind; + moduleSpecifier?: string; } enum ModuleSpecifierComparison { @@ -75,7 +75,7 @@ namespace ts.codefix { getAllActions() { let result: ImportCodeAction[] = []; for (const key in this.symbolIdToActionMap) { - result = concatenate(result, this.symbolIdToActionMap[key]) + result = concatenate(result, this.symbolIdToActionMap[key]); } return result; } diff --git a/src/services/findAllReferences.ts b/src/services/findAllReferences.ts index cd1477c444..610fa25d7b 100644 --- a/src/services/findAllReferences.ts +++ b/src/services/findAllReferences.ts @@ -414,7 +414,7 @@ namespace ts.FindAllReferences { name, textSpan: createTextSpan(0, 1), displayParts: [{ text: name, kind: ScriptElementKind.keyword }] - } + }; const references: ReferenceEntry[] = []; for (const sourceFile of sourceFiles) { cancellationToken.throwIfCancellationRequested(); @@ -610,7 +610,7 @@ namespace ts.FindAllReferences { const result: Node[] = []; for (const decl of classSymbol.members.get("__constructor").declarations) { - const ctrKeyword = ts.findChildOfKind(decl, ts.SyntaxKind.ConstructorKeyword, sourceFile)! + const ctrKeyword = ts.findChildOfKind(decl, ts.SyntaxKind.ConstructorKeyword, sourceFile)!; Debug.assert(decl.kind === SyntaxKind.Constructor && !!ctrKeyword); result.push(ctrKeyword); } diff --git a/tslint.json b/tslint.json index 13de7acec6..3952d4fac2 100644 --- a/tslint.json +++ b/tslint.json @@ -17,7 +17,7 @@ "double", "avoid-escape" ], - "semicolon": [true, "ignore-bound-class-methods"], + "semicolon": [true, "always", "ignore-bound-class-methods"], "whitespace": [true, "check-branch", "check-decl",