code linting

This commit is contained in:
vsrs 2020-07-02 22:08:33 +03:00
parent 271abb7bc4
commit 611fad275f
3 changed files with 32 additions and 32 deletions

View file

@ -5,7 +5,7 @@ export type UpdatesChannel = "stable" | "nightly";
export const NIGHTLY_TAG = "nightly"; export const NIGHTLY_TAG = "nightly";
export type RunnableEnvCfg = undefined | Record<string, string> | { mask?: string, env: Record<string, string>; }[]; export type RunnableEnvCfg = undefined | Record<string, string> | { mask?: string; env: Record<string, string> }[];
export class Config { export class Config {
readonly extensionId = "matklad.rust-analyzer"; readonly extensionId = "matklad.rust-analyzer";

View file

@ -111,7 +111,7 @@ export function prepareEnv(runnable: ra.Runnable, runnableEnvCfg: RunnableEnvCfg
} }
} }
} else { } else {
Object.assign(env, runnableEnvCfg as Record<string, string>); Object.assign(env, runnableEnvCfg);
} }
} }

View file

@ -3,7 +3,7 @@ import { prepareEnv } from '../../src/run';
import { RunnableEnvCfg } from '../../src/config'; import { RunnableEnvCfg } from '../../src/config';
import * as ra from '../../src/lsp_ext'; import * as ra from '../../src/lsp_ext';
function make_runnable(label: string): ra.Runnable { function makeRunnable(label: string): ra.Runnable {
return { return {
label, label,
kind: "cargo", kind: "cargo",
@ -11,21 +11,21 @@ function make_runnable(label: string): ra.Runnable {
cargoArgs: [], cargoArgs: [],
executableArgs: [] executableArgs: []
} }
} };
} }
function fakePrepareEnv(runnable_name: string, config: RunnableEnvCfg) : Record<string, string> { function fakePrepareEnv(runnableName: string, config: RunnableEnvCfg): Record<string, string> {
const runnable = make_runnable(runnable_name); const runnable = makeRunnable(runnableName);
return prepareEnv(runnable, config); return prepareEnv(runnable, config);
} }
suite('Runnable env', () => { suite('Runnable env', () => {
test('Global config works', () => { test('Global config works', () => {
const bin_env = fakePrepareEnv("run project_name", {"GLOBAL": "g"}); const binEnv = fakePrepareEnv("run project_name", { "GLOBAL": "g" });
assert.equal(bin_env["GLOBAL"], "g"); assert.equal(binEnv["GLOBAL"], "g");
const test_env = fakePrepareEnv("test some::mod::test_name", {"GLOBAL": "g"}); const testEnv = fakePrepareEnv("test some::mod::test_name", { "GLOBAL": "g" });
assert.equal(test_env["GLOBAL"], "g"); assert.equal(testEnv["GLOBAL"], "g");
}); });
test('null mask works', () => { test('null mask works', () => {
@ -34,11 +34,11 @@ suite('Runnable env', () => {
env: { DATA: "data" } env: { DATA: "data" }
} }
]; ];
const bin_env = fakePrepareEnv("run project_name", config); const binEnv = fakePrepareEnv("run project_name", config);
assert.equal(bin_env["DATA"], "data"); assert.equal(binEnv["DATA"], "data");
const test_env = fakePrepareEnv("test some::mod::test_name", config); const testEnv = fakePrepareEnv("test some::mod::test_name", config);
assert.equal(test_env["DATA"], "data"); assert.equal(testEnv["DATA"], "data");
}); });
test('order works', () => { test('order works', () => {
@ -50,11 +50,11 @@ suite('Runnable env', () => {
env: { DATA: "newdata" } env: { DATA: "newdata" }
} }
]; ];
const bin_env = fakePrepareEnv("run project_name", config); const binEnv = fakePrepareEnv("run project_name", config);
assert.equal(bin_env["DATA"], "newdata"); assert.equal(binEnv["DATA"], "newdata");
const test_env = fakePrepareEnv("test some::mod::test_name", config); const testEnv = fakePrepareEnv("test some::mod::test_name", config);
assert.equal(test_env["DATA"], "newdata"); assert.equal(testEnv["DATA"], "newdata");
}); });
test('mask works', () => { test('mask works', () => {
@ -71,14 +71,14 @@ suite('Runnable env', () => {
env: { DATA: "special_test" } env: { DATA: "special_test" }
} }
]; ];
const bin_env = fakePrepareEnv("run project_name", config); const binEnv = fakePrepareEnv("run project_name", config);
assert.equal(bin_env["DATA"], "rundata"); assert.equal(binEnv["DATA"], "rundata");
const test_env = fakePrepareEnv("test some::mod::test_name", config); const testEnv = fakePrepareEnv("test some::mod::test_name", config);
assert.equal(test_env["DATA"], "data"); assert.equal(testEnv["DATA"], "data");
const special_test_env = fakePrepareEnv("test some::mod::special_test", config); const specialTestEnv = fakePrepareEnv("test some::mod::special_test", config);
assert.equal(special_test_env["DATA"], "special_test"); assert.equal(specialTestEnv["DATA"], "special_test");
}); });
test('exact test name works', () => { test('exact test name works', () => {
@ -91,11 +91,11 @@ suite('Runnable env', () => {
env: { DATA: "test special" } env: { DATA: "test special" }
} }
]; ];
const test_env = fakePrepareEnv("test some::mod::test_name", config); const testEnv = fakePrepareEnv("test some::mod::test_name", config);
assert.equal(test_env["DATA"], "test special"); assert.equal(testEnv["DATA"], "test special");
const special_test_env = fakePrepareEnv("test some::mod::another_test", config); const specialTestEnv = fakePrepareEnv("test some::mod::another_test", config);
assert.equal(special_test_env["DATA"], "data"); assert.equal(specialTestEnv["DATA"], "data");
}); });
test('test mod name works', () => { test('test mod name works', () => {
@ -108,11 +108,11 @@ suite('Runnable env', () => {
env: { DATA: "mod special" } env: { DATA: "mod special" }
} }
]; ];
const test_env = fakePrepareEnv("test some::mod::test_name", config); const testEnv = fakePrepareEnv("test some::mod::test_name", config);
assert.equal(test_env["DATA"], "mod special"); assert.equal(testEnv["DATA"], "mod special");
const special_test_env = fakePrepareEnv("test some::mod::another_test", config); const specialTestEnv = fakePrepareEnv("test some::mod::another_test", config);
assert.equal(special_test_env["DATA"], "mod special"); assert.equal(specialTestEnv["DATA"], "mod special");
}); });
}); });