From a3a07a0f9f45b4ff9359a3c4c5b652f3d7ae9bde Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Wed, 17 Aug 2016 14:47:54 -0700 Subject: [PATCH] lint more files --- Jakefile.js | 3 +++ src/server/cancellationToken.ts | 6 ++--- .../typingsInstaller/nodeTypingsInstaller.ts | 25 +++++++++---------- .../typingsInstaller/typingsInstaller.ts | 14 +++++------ 4 files changed, 24 insertions(+), 24 deletions(-) diff --git a/Jakefile.js b/Jakefile.js index ee7122af114..cfc3ca7929c 100644 --- a/Jakefile.js +++ b/Jakefile.js @@ -128,6 +128,7 @@ var serverCoreSources = [ "types.d.ts", "utilities.ts", "scriptVersionCache.ts", + "typingsCache.ts", "scriptInfo.ts", "lsHost.ts", "project.ts", @@ -1101,6 +1102,8 @@ var lintTargets = compilerSources .concat(serverCoreSources) .concat(tslintRulesFiles) .concat(servicesSources) + .concat(typingsInstallerSources) + .concat(cancellationTokenSources) .concat(["Gulpfile.ts"]) .concat([nodeServerInFile, perftscPath, "tests/perfsys.ts", webhostPath]); diff --git a/src/server/cancellationToken.ts b/src/server/cancellationToken.ts index 39b74b8bc1a..dbc07716128 100644 --- a/src/server/cancellationToken.ts +++ b/src/server/cancellationToken.ts @@ -17,7 +17,7 @@ function createCancellationToken(args: string[]): HostCancellationToken { } } if (!cancellationPipeName) { - return { isCancellationRequested: () => false }; + return { isCancellationRequested: () => false }; } return { isCancellationRequested() { @@ -25,10 +25,10 @@ function createCancellationToken(args: string[]): HostCancellationToken { fs.statSync(cancellationPipeName); return true; } - catch(e) { + catch (e) { return false; } } }; } -export = createCancellationToken \ No newline at end of file +export = createCancellationToken; \ No newline at end of file diff --git a/src/server/typingsInstaller/nodeTypingsInstaller.ts b/src/server/typingsInstaller/nodeTypingsInstaller.ts index 99a2513cd9f..55b67621f33 100644 --- a/src/server/typingsInstaller/nodeTypingsInstaller.ts +++ b/src/server/typingsInstaller/nodeTypingsInstaller.ts @@ -21,7 +21,7 @@ namespace ts.server.typingsInstaller { basePath = os.homedir(); break; case "darwin": - basePath = combinePaths(os.homedir(), "Library/Application Support/") + basePath = combinePaths(os.homedir(), "Library/Application Support/"); break; } @@ -32,7 +32,7 @@ namespace ts.server.typingsInstaller { class FileLog implements Log { constructor(private readonly logFile?: string) { } - + isEnabled() { return this.logFile !== undefined; } @@ -44,9 +44,8 @@ namespace ts.server.typingsInstaller { export class NodeTypingsInstaller extends TypingsInstaller { private execSync: { (command: string, options: { stdio: "ignore" | "pipe" }): Buffer | string }; private exec: { (command: string, options: { cwd: string }, callback?: (error: Error, stdout: string, stderr: string) => void): any }; - private npmBinPath: string; - + private tsdRunCount = 1; readonly installTypingHost: InstallTypingHost = sys; @@ -55,7 +54,7 @@ namespace ts.server.typingsInstaller { if (this.log.isEnabled()) { this.log.writeLine(`Process id: ${process.pid}`); } - const { exec, execSync } = require("child_process"); + const { exec, execSync } = require("child_process"); this.execSync = execSync; this.exec = exec; } @@ -68,7 +67,7 @@ namespace ts.server.typingsInstaller { this.log.writeLine(`Global npm bin path '${this.npmBinPath}'`); } } - catch(e) { + catch (e) { this.npmBinPath = ""; if (this.log.isEnabled()) { this.log.writeLine(`Error when getting npm bin path: ${e}. Set bin path to ""`); @@ -82,7 +81,7 @@ namespace ts.server.typingsInstaller { case "closeProject": this.closeProject(req); } - }) + }); } protected isPackageInstalled(packageName: string) { @@ -121,11 +120,11 @@ namespace ts.server.typingsInstaller { protected sendResponse(response: SetTypings | InvalidateCachedTypings) { if (this.log.isEnabled()) { - this.log.writeLine(`Sending response: ${JSON.stringify(response)}`) + this.log.writeLine(`Sending response: ${JSON.stringify(response)}`); } process.send(response); if (this.log.isEnabled()) { - this.log.writeLine(`Response has been sent.`) + this.log.writeLine(`Response has been sent.`); } } @@ -134,12 +133,12 @@ namespace ts.server.typingsInstaller { this.tsdRunCount++; const tsdPath = combinePaths(this.npmBinPath, "tsd"); if (this.log.isEnabled()) { - this.log.writeLine(`Running tsd ${id}, tsd path '${tsdPath}, typings to install: ${JSON.stringify(typingsToInstall)}. cache path '${cachePath}'`) + this.log.writeLine(`Running tsd ${id}, tsd path '${tsdPath}, typings to install: ${JSON.stringify(typingsToInstall)}. cache path '${cachePath}'`); } - this.exec(`${tsdPath} install ${typingsToInstall.join(" ")} -ros`, { cwd: cachePath }, (err, stdout, stderr) => { + this.exec(`${tsdPath} install ${typingsToInstall.join(" ")} -ros`, { cwd: cachePath }, (err, stdout, stderr) => { if (this.log.isEnabled()) { this.log.writeLine(`TSD ${id} stdout: ${stdout}`); - this.log.writeLine(`TSD ${id} stderr: ${stderr}`) + this.log.writeLine(`TSD ${id} stderr: ${stderr}`); } const i = stdout.indexOf("running install"); if (i < 0) { @@ -154,7 +153,7 @@ namespace ts.server.typingsInstaller { installedTypings.push(match[1]); } postInstallAction(installedTypings); - }) + }); } } diff --git a/src/server/typingsInstaller/typingsInstaller.ts b/src/server/typingsInstaller/typingsInstaller.ts index e1f026d37f9..f4a899068f7 100644 --- a/src/server/typingsInstaller/typingsInstaller.ts +++ b/src/server/typingsInstaller/typingsInstaller.ts @@ -17,11 +17,11 @@ namespace ts.server.typingsInstaller { isEnabled(): boolean; writeLine(text: string): void; } - + const nullLog: Log = { isEnabled: () => false, writeLine: () => {} - } + }; function tsdTypingToFileName(cachePath: string, tsdTypingFile: string) { return combinePaths(cachePath, `typings/${tsdTypingFile}`); @@ -33,7 +33,6 @@ namespace ts.server.typingsInstaller { } export abstract class TypingsInstaller { - private isTsdInstalled: boolean; private packageNameToTypingLocation: Map = createMap(); @@ -81,14 +80,13 @@ namespace ts.server.typingsInstaller { if (this.log.isEnabled()) { this.log.writeLine(`No watchers are registered for project '${projectName}'`); } - return; } for (const w of watchers) { w.close(); } - delete this.projectWatchers[projectName] + delete this.projectWatchers[projectName]; if (this.log.isEnabled()) { this.log.writeLine(`Closing file watchers for project '${projectName}' - done.`); @@ -102,7 +100,7 @@ namespace ts.server.typingsInstaller { } return; } - + if (this.log.isEnabled()) { this.log.writeLine(`Got install request ${JSON.stringify(req)}`); } @@ -123,7 +121,7 @@ namespace ts.server.typingsInstaller { this.packageNameToTypingLocation, req.typingOptions, req.compilerOptions); - + if (this.log.isEnabled()) { this.log.writeLine(`Finished typings discovery: ${JSON.stringify(discoverTypingsResult)}`); } @@ -151,7 +149,7 @@ namespace ts.server.typingsInstaller { } if (this.knownCachesSet[cacheLocation]) { if (this.log.isEnabled()) { - this.log.writeLine(`Cache location was already processed...`) + this.log.writeLine(`Cache location was already processed...`); } return; }