From d387c9c230dc0489abc612c3f68cb423f840ba56 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Mon, 5 Oct 2020 10:12:49 +0200 Subject: [PATCH] =?UTF-8?q?fix(lint):=20=F0=9F=90=9B=20updated=20packages?= =?UTF-8?q?=20and=20fixed=20linting=20errors?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .eslintrc.js | 1 + __tests__/filter.ts | 4 ++++ __tests__/options.ts | 2 +- __tests__/package.ts | 2 +- __tests__/parser.ts | 24 ++++++++++++------------ __tests__/runner.ts | 2 +- __tests__/spawn.ts | 14 +++++++------- __tests__/workspace.ts | 7 ++++++- bin/ultra.js | 4 +++- src/package.ts | 1 + src/workspace.providers.ts | 2 +- src/yargs.ts | 2 +- 12 files changed, 39 insertions(+), 26 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 4a3a3258..8819f3d6 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -46,6 +46,7 @@ module.exports = { "prettier/prettier": "warn", "unicorn/prevent-abbreviations": "off", "unicorn/explicit-length-check": "off", + "unicorn/import-style": "off", "unicorn/no-reduce": "off", "unicorn/consistent-function-scoping": "off", "lines-between-class-members": [ diff --git a/__tests__/filter.ts b/__tests__/filter.ts index e1c8ad8c..c6c4e684 100644 --- a/__tests__/filter.ts +++ b/__tests__/filter.ts @@ -13,6 +13,7 @@ test("filter dir", async () => { path.relative("__tests__/workspace", p.root).replace(/\\/gu, "/") ) dirs.sort() + // eslint-disable-next-line jest/no-conditional-expect expect(dirs).toStrictEqual(["apps/app1", "apps/app2"]) } }) @@ -29,6 +30,7 @@ test("filter pkg", async () => { path.relative("__tests__/workspace", p.root).replace(/\\/gu, "/") ) dirs.sort() + // eslint-disable-next-line jest/no-conditional-expect expect(dirs).toStrictEqual(["libs/lib3"]) } }) @@ -45,6 +47,7 @@ test("filter pkg no deps", async () => { path.relative("__tests__/workspace", p.root).replace(/\\/gu, "/") ) dirs.sort() + // eslint-disable-next-line jest/no-conditional-expect expect(dirs).toStrictEqual(["apps/app1"]) } }) @@ -61,6 +64,7 @@ test("filter pkg with deps", async () => { path.relative("__tests__/workspace", p.root).replace(/\\/gu, "/") ) dirs.sort() + // eslint-disable-next-line jest/no-conditional-expect expect(dirs).toStrictEqual(["apps/app1", "libs/lib1", "libs/lib2"]) } }) diff --git a/__tests__/options.ts b/__tests__/options.ts index 51ccf999..73bca77d 100644 --- a/__tests__/options.ts +++ b/__tests__/options.ts @@ -1,5 +1,5 @@ import { defaults } from "../src/options" -test("should ", () => { +test("should", () => { expect(defaults).toBeDefined() }) diff --git a/__tests__/package.ts b/__tests__/package.ts index 94c91c00..c1a70a44 100644 --- a/__tests__/package.ts +++ b/__tests__/package.ts @@ -5,7 +5,7 @@ function fa(files: string[]) { return files.map((f) => f.replace(/\\/gu, "/")) } -test("findPackages without options ", async () => { +test("findPackages without options", async () => { const root = path.resolve("__tests__/workspace") const packages = ( await findPackages(["**"], { diff --git a/__tests__/parser.ts b/__tests__/parser.ts index e365c74e..7f056c96 100644 --- a/__tests__/parser.ts +++ b/__tests__/parser.ts @@ -1,6 +1,6 @@ import { CommandParser } from "../src/parser" -test("should ", () => { +test("should", () => { const parser = new CommandParser({ name: "test", scripts: { test: "foo" } }) const cmd = parser.parse("sleep 10") expect(cmd.debug()).toStrictEqual("system:sleep 10") @@ -14,7 +14,7 @@ test("no scripts", () => { expect(cmd.children[0].args).toStrictEqual(["sleep", "10"]) }) -test("test pre ", () => { +test("pre", () => { const parser = new CommandParser({ name: "test", scripts: { pretest: "bar", test: "foo" }, @@ -25,7 +25,7 @@ test("test pre ", () => { }) }) -test("test post ", () => { +test("post", () => { const parser = new CommandParser({ name: "test", scripts: { posttest: "bar", test: "foo" }, @@ -36,7 +36,7 @@ test("test post ", () => { }) }) -test("test bin ", () => { +test("bin", () => { const parser = new CommandParser({ name: "test", scripts: {} }) const cmd = parser.parse("jest") expect(cmd.children).toHaveLength(1) @@ -61,13 +61,13 @@ test("yarn script", () => { }) }) -test("test npx bin ", () => { +test("npx bin", () => { const parser = new CommandParser({ name: "test", scripts: {} }) const cmd = parser.parse("npx jest") expect(cmd.debug()).toStrictEqual("bin:jest") }) -test("AA=123 test npx bin ", () => { +test("AA=123 test npx bin", () => { const parser = new CommandParser({ name: "test", scripts: {} }) const cmd = parser.parse("AA=123 npx jest") expect(cmd.children[0].env).toStrictEqual({ AA: "123" }) @@ -81,37 +81,37 @@ test("AA=123 foobar", () => { expect(cmd.debug()).toStrictEqual("system:foobar") }) -test("test op", () => { +test("op", () => { const parser = new CommandParser({ name: "test", scripts: {} }) const cmd = parser.parse("npx jest && npx foo") expect(cmd.debug()).toStrictEqual(["bin:jest", "op:&&", "system:npx foo"]) }) -test("test op ;", () => { +test("op ;", () => { const parser = new CommandParser({ name: "test", scripts: {} }) const cmd = parser.parse("test ; test") expect(cmd.debug()).toStrictEqual(["system:test", "op:;", "system:test"]) }) -test("test op &&", () => { +test("op &&", () => { const parser = new CommandParser({ name: "test", scripts: {} }) const cmd = parser.parse("jest && test") expect(cmd.debug()).toStrictEqual(["bin:jest", "op:&&", "system:test"]) }) -test("test op ; 2", () => { +test("op ; 2", () => { const parser = new CommandParser({ name: "test", scripts: {} }) const cmd = parser.parse("test; test") expect(cmd.debug()).toStrictEqual(["system:test", "op:;", "system:test"]) }) -test("test op only", () => { +test("op only", () => { const parser = new CommandParser({ name: "test", scripts: {} }) const cmd = parser.parse("&&") expect(cmd.debug()).toStrictEqual("op:&&") }) -test("test non top level script", () => { +test("non top level script", () => { const parser = new CommandParser({ name: "test", scripts: { test: "foo" } }) const cmd = parser.parse("test") expect(cmd.debug()).toStrictEqual({ "script:test": "system:foo" }) diff --git a/__tests__/runner.ts b/__tests__/runner.ts index 6365aec2..2e235b38 100644 --- a/__tests__/runner.ts +++ b/__tests__/runner.ts @@ -190,7 +190,7 @@ test("advanced build --raw", async () => { ) }) -test("concurrent ", async () => { +test("concurrent", async () => { const runner = new Runner({}) await runner.run("test", { name: "test", diff --git a/__tests__/spawn.ts b/__tests__/spawn.ts index c705a633..ccaca1b2 100644 --- a/__tests__/spawn.ts +++ b/__tests__/spawn.ts @@ -7,43 +7,43 @@ chai.use(sinonChai) beforeEach(() => sinon.restore()) -test("true ", async () => { +test("true", async () => { const spawner = new Spawner("true") await spawner.spawn() expect(spawner.output).toBe("") }) -test("echo foo ", async () => { +test("echo foo", async () => { const spawner = new Spawner("echo", ["foo"]) await spawner.spawn() expect(spawner.output.trim()).toBe("foo") }) -test("command does not exist ", () => { +test("command does not exist", () => { const spawner = new Spawner("foofoobarbar") return expect(spawner.spawn()).rejects.toThrow() }) -test("test exit code 0", async () => { +test("exit code 0", async () => { const spawner = new Spawner("true") await spawner.spawn() expect(spawner.exitCode).toBe(0) }) -test("test exit code 1", async () => { +test("exit code 1", async () => { const spawner = new Spawner("false") await expect(spawner.spawn()).rejects.toThrow() expect(spawner.exitCode).toBe(1) }) -test("raw echo foo ", async () => { +test("raw echo foo", async () => { const spawner = new Spawner("true", []) await spawner.spawn(true) expect(spawner.output).toBe("") expect(spawner.exitCode).toBe(0) }) -test("lines ", async () => { +test("lines", async () => { const spawner = new Spawner("echo", ["-n", "foo\nbar"]) spawner.onLine = sinon.fake() await spawner.spawn() diff --git a/__tests__/workspace.ts b/__tests__/workspace.ts index d2dfe538..aaf22887 100644 --- a/__tests__/workspace.ts +++ b/__tests__/workspace.ts @@ -3,7 +3,7 @@ import path from "path" import { findUp } from "../src/package" import { WorkspaceProviderType } from "../src/workspace.providers" -test("findUp ", () => { +test("findUp", () => { const tests = [ ["./foo/fa/boo", ".git", path.resolve(__dirname, "../")], [".", ".git", path.resolve(__dirname, "../")], @@ -29,6 +29,7 @@ test("lerna", async () => { path.relative(".", p.root).replace(/\\/gu, "/") ) dirs.sort() + // eslint-disable-next-line jest/no-conditional-expect expect(dirs).toStrictEqual([ "__tests__/workspace/apps/app1", "__tests__/workspace/apps/app2", @@ -52,6 +53,7 @@ test("yarn", async () => { path.relative(".", p.root).replace(/\\/gu, "/") ) dirs.sort() + // eslint-disable-next-line jest/no-conditional-expect expect(dirs).toStrictEqual([ "__tests__/workspace/apps/app1", "__tests__/workspace/apps/app2", @@ -75,6 +77,7 @@ test("pnpm", async () => { path.relative(".", p.root).replace(/\\/gu, "/") ) dirs.sort() + // eslint-disable-next-line jest/no-conditional-expect expect(dirs).toStrictEqual([ "__tests__/workspace/apps/app1", "__tests__/workspace/apps/app2", @@ -98,6 +101,7 @@ test("recursive", async () => { path.relative(".", p.root).replace(/\\/gu, "/") ) dirs.sort() + // eslint-disable-next-line jest/no-conditional-expect expect(dirs).toStrictEqual([ "__tests__/workspace/apps/app1", "__tests__/workspace/apps/app2", @@ -118,6 +122,7 @@ test("workspace", async () => { path.relative(".", p.root).replace(/\\/gu, "/") ) dirs.sort() + // eslint-disable-next-line jest/no-conditional-expect expect(dirs).toStrictEqual([ "__tests__/workspace/apps/app1", "__tests__/workspace/apps/app2", diff --git a/bin/ultra.js b/bin/ultra.js index c909f7c5..edd7f9b3 100755 --- a/bin/ultra.js +++ b/bin/ultra.js @@ -1,3 +1,5 @@ #!/usr/bin/env node -// eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access +// eslint-disable-next-line @typescript-eslint/ban-ts-comment +// @ts-nocheck +// eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-var-requires void require("../lib/cli").run() diff --git a/src/package.ts b/src/package.ts index 9ed3d70d..b0c73374 100644 --- a/src/package.ts +++ b/src/package.ts @@ -61,6 +61,7 @@ export function findUp(name: string, cwd = process.cwd()): string | undefined { export function getPackage(root: string): PackageJsonWithRoot | undefined { const pkgPath = path.resolve(root, "package.json") if (fs.existsSync(pkgPath)) { + // eslint-disable-next-line @typescript-eslint/no-var-requires const pkg = require(pkgPath) as PackageJsonWithRoot if (!pkg.name) pkg.name = root pkg.root = root diff --git a/src/workspace.providers.ts b/src/workspace.providers.ts index 4608be2b..79934675 100644 --- a/src/workspace.providers.ts +++ b/src/workspace.providers.ts @@ -51,7 +51,7 @@ export const providers: Record = { if (root) return { root, - // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access + // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-var-requires patterns: require(path.resolve(root, "lerna.json")) .packages as string[], } diff --git a/src/yargs.ts b/src/yargs.ts index d50c1617..30d3014b 100644 --- a/src/yargs.ts +++ b/src/yargs.ts @@ -33,7 +33,7 @@ const program = yargs ) .alias("h", "help") .help(false) - // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access + // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-var-requires .version(require(path.resolve(__dirname, "../package.json")).version) .group( ["recursive", "filter", "root", "concurrency", "serial", "topology"],