From a65c95d023e022a2a7a724f8c6439d002fc5a561 Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Fri, 17 Apr 2020 08:40:04 +0200 Subject: [PATCH] Add and lint-fix in cli package --- packages/cli/package.json | 1 + packages/cli/src/cli.ts | 4 ++-- packages/cli/src/helpers.spec.ts | 6 +++--- packages/cli/src/helpers.ts | 2 +- packages/cli/src/tsrepl.spec.ts | 4 ++-- packages/cli/src/tsrepl.ts | 2 +- 6 files changed, 10 insertions(+), 9 deletions(-) diff --git a/packages/cli/package.json b/packages/cli/package.json index 741599ff..7f85de75 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -18,6 +18,7 @@ "format": "prettier --write --loglevel warn \"./src/**/*.ts\"", "format-text": "prettier --write --prose-wrap always --print-width 80 \"./*.md\"", "lint": "eslint --max-warnings 0 \"**/*.{js,ts}\"", + "lint-fix": "eslint --max-warnings 0 \"**/*.{js,ts}\" --fix", "build": "tsc", "build-or-skip": "[ -n \"$SKIP_BUILD\" ] || yarn build", "start": "yarn build-or-skip && ./bin/cosmwasm-cli", diff --git a/packages/cli/src/cli.ts b/packages/cli/src/cli.ts index 6c1e9fc9..dd220fa2 100644 --- a/packages/cli/src/cli.ts +++ b/packages/cli/src/cli.ts @@ -163,7 +163,7 @@ export function main(originalArgs: readonly string[]): void { } if (args.init) { - for (const path of args.init.map(arg => arg.toString())) { + for (const path of args.init.map((arg) => arg.toString())) { if (args.debug) console.info(`Adding file: '${path}' ...`); init += fs.readFileSync(path, "utf8") + "\n"; } @@ -171,7 +171,7 @@ export function main(originalArgs: readonly string[]): void { const tsconfigPath = join(__dirname, "..", "tsconfig_repl.json"); const installationDir = join(__dirname, ".."); - new TsRepl(tsconfigPath, init, !!args.debug, installationDir).start().catch(error => { + new TsRepl(tsconfigPath, init, !!args.debug, installationDir).start().catch((error) => { console.error(error); process.exit(1); }); diff --git a/packages/cli/src/helpers.spec.ts b/packages/cli/src/helpers.spec.ts index 5667c9ba..6571d3cf 100644 --- a/packages/cli/src/helpers.spec.ts +++ b/packages/cli/src/helpers.spec.ts @@ -85,13 +85,13 @@ describe("Helpers", () => { const context = createContext({}); await executeJavaScriptAsync("var a", "myfile.js", context) .then(() => fail("must not resolve")) - .catch(e => expect(e).toMatch(/SyntaxError:/)); + .catch((e) => expect(e).toMatch(/SyntaxError:/)); await executeJavaScriptAsync("let b", "myfile.js", context) .then(() => fail("must not resolve")) - .catch(e => expect(e).toMatch(/SyntaxError:/)); + .catch((e) => expect(e).toMatch(/SyntaxError:/)); await executeJavaScriptAsync("const c", "myfile.js", context) .then(() => fail("must not resolve")) - .catch(e => expect(e).toMatch(/SyntaxError:/)); + .catch((e) => expect(e).toMatch(/SyntaxError:/)); }); it("can execute multiple commands in one context", async () => { diff --git a/packages/cli/src/helpers.ts b/packages/cli/src/helpers.ts index d0c59d4d..b6d3e9f7 100644 --- a/packages/cli/src/helpers.ts +++ b/packages/cli/src/helpers.ts @@ -29,5 +29,5 @@ export function isRecoverable(error: TSError): boolean { 2355, // "A function whose declared type is neither 'void' nor 'any' must return a value." ]); - return error.diagnosticCodes.every(code => recoveryCodes.has(code)); + return error.diagnosticCodes.every((code) => recoveryCodes.has(code)); } diff --git a/packages/cli/src/tsrepl.spec.ts b/packages/cli/src/tsrepl.spec.ts index 23540372..e6b488d1 100644 --- a/packages/cli/src/tsrepl.spec.ts +++ b/packages/cli/src/tsrepl.spec.ts @@ -35,12 +35,12 @@ describe("TsRepl", () => { await new TsRepl(tsConfigPath, "const a: string = 123;") .start() .then(() => fail("must not resolve")) - .catch(e => expect(e).toMatch(/is not assignable to type 'string'/)); + .catch((e) => expect(e).toMatch(/is not assignable to type 'string'/)); await new TsRepl(tsConfigPath, "const const const;") .start() .then(() => fail("must not resolve")) - .catch(e => expect(e).toMatch(/Variable declaration expected./)); + .catch((e) => expect(e).toMatch(/Variable declaration expected./)); }); it("can be started with top level await", async () => { diff --git a/packages/cli/src/tsrepl.ts b/packages/cli/src/tsrepl.ts index 4375eca8..274c0468 100644 --- a/packages/cli/src/tsrepl.ts +++ b/packages/cli/src/tsrepl.ts @@ -156,7 +156,7 @@ export class TsRepl { // statement in TypeScript is compiled to no JavaScript until the imported symbol is used // somewhere. This btw. leads to a different execution order of imports than in the TS source. let lastResult: any; - for (const added of changes.filter(change => change.added)) { + for (const added of changes.filter((change) => change.added)) { // eslint-disable-next-line @typescript-eslint/no-non-null-assertion lastResult = await executeJavaScriptAsync(added.value, this.evalFilename, this.context!); }