Fixed tsfmt and eslint errors.

This commit is contained in:
vsrs 2020-04-30 18:41:48 +03:00
parent eb6f9c23e1
commit 10836543d6
2 changed files with 19 additions and 19 deletions

View file

@ -21,24 +21,24 @@ export class Cargo {
} }
public async artifactsFromArgs(cargoArgs: string[]): Promise<CompilationArtifact[]> { public async artifactsFromArgs(cargoArgs: string[]): Promise<CompilationArtifact[]> {
let artifacts: CompilationArtifact[] = []; const artifacts: CompilationArtifact[] = [];
try { try {
await this.runCargo(cargoArgs, await this.runCargo(cargoArgs,
message => { message => {
if (message.reason == 'compiler-artifact' && message.executable) { if (message.reason === 'compiler-artifact' && message.executable) {
let isBinary = message.target.crate_types.includes('bin'); const isBinary = message.target.crate_types.includes('bin');
let isBuildScript = message.target.kind.includes('custom-build'); const isBuildScript = message.target.kind.includes('custom-build');
if ((isBinary && !isBuildScript) || message.profile.test) { if ((isBinary && !isBuildScript) || message.profile.test) {
artifacts.push({ artifacts.push({
fileName: message.executable, fileName: message.executable,
name: message.target.name, name: message.target.name,
kind: message.target.kind[0], kind: message.target.kind[0],
isTest: message.profile.test isTest: message.profile.test
}) });
} }
} }
else if( message.reason == 'compiler-message') { else if (message.reason === 'compiler-message') {
this.output.append(message.message.rendered); this.output.append(message.message.rendered);
} }
}, },
@ -62,9 +62,9 @@ export class Cargo {
cargoArgs.push(...extraArgs); cargoArgs.push(...extraArgs);
} }
let artifacts = await this.artifactsFromArgs(cargoArgs); const artifacts = await this.artifactsFromArgs(cargoArgs);
if (artifacts.length == 0 ) { if (artifacts.length === 0) {
throw new Error('No compilation artifacts'); throw new Error('No compilation artifacts');
} else if (artifacts.length > 1) { } else if (artifacts.length > 1) {
throw new Error('Multiple compilation artifacts are not supported.'); throw new Error('Multiple compilation artifacts are not supported.');
@ -79,7 +79,7 @@ export class Cargo {
onStderrString: (data: string) => void onStderrString: (data: string) => void
): Promise<number> { ): Promise<number> {
return new Promise<number>((resolve, reject) => { return new Promise<number>((resolve, reject) => {
let cargo = cp.spawn('cargo', cargoArgs, { const cargo = cp.spawn('cargo', cargoArgs, {
stdio: ['ignore', 'pipe', 'pipe'], stdio: ['ignore', 'pipe', 'pipe'],
cwd: this.rootFolder, cwd: this.rootFolder,
env: this.env, env: this.env,
@ -92,14 +92,14 @@ export class Cargo {
onStderrString(chunk.toString()); onStderrString(chunk.toString());
}); });
let rl = readline.createInterface({ input: cargo.stdout }); const rl = readline.createInterface({ input: cargo.stdout });
rl.on('line', line => { rl.on('line', line => {
let message = JSON.parse(line); const message = JSON.parse(line);
onStdoutJson(message); onStdoutJson(message);
}); });
cargo.on('exit', (exitCode, _) => { cargo.on('exit', (exitCode, _) => {
if (exitCode == 0) if (exitCode === 0)
resolve(exitCode); resolve(exitCode);
else else
reject(new Error(`exit code: ${exitCode}.`)); reject(new Error(`exit code: ${exitCode}.`));

View file

@ -83,8 +83,8 @@ const debugOutput = vscode.window.createOutputChannel("Debug");
async function getCppvsDebugConfig(config: ra.Runnable, sourceFileMap: Record<string, string>): Promise<vscode.DebugConfiguration> { async function getCppvsDebugConfig(config: ra.Runnable, sourceFileMap: Record<string, string>): Promise<vscode.DebugConfiguration> {
debugOutput.clear(); debugOutput.clear();
let cargo = new Cargo(config.cwd || '.', debugOutput); const cargo = new Cargo(config.cwd || '.', debugOutput);
let executable = await cargo.executableFromArgs(config.args, config.extraArgs); const executable = await cargo.executableFromArgs(config.args, config.extraArgs);
// if we are here, there were no compilation errors. // if we are here, there were no compilation errors.
return { return {
@ -106,7 +106,7 @@ export function debugSingle(ctx: Ctx): Cmd {
const lldbId = "vadimcn.vscode-lldb"; const lldbId = "vadimcn.vscode-lldb";
const cpptoolsId = "ms-vscode.cpptools"; const cpptoolsId = "ms-vscode.cpptools";
let debugEngineId = ctx.config.debug.engine; const debugEngineId = ctx.config.debug.engine;
let debugEngine = null; let debugEngine = null;
if (debugEngineId === "auto") { if (debugEngineId === "auto") {
debugEngine = vscode.extensions.getExtension(lldbId); debugEngine = vscode.extensions.getExtension(lldbId);
@ -124,7 +124,7 @@ export function debugSingle(ctx: Ctx): Cmd {
return; return;
} }
const debugConfig = lldbId == debugEngine.id const debugConfig = lldbId === debugEngine.id
? getLldbDebugConfig(config, ctx.config.debug.sourceFileMap) ? getLldbDebugConfig(config, ctx.config.debug.sourceFileMap)
: await getCppvsDebugConfig(config, ctx.config.debug.sourceFileMap); : await getCppvsDebugConfig(config, ctx.config.debug.sourceFileMap);