Skip to content

Commit

Permalink
fix(lint): πŸ› updated packages and fixed linting errors
Browse files Browse the repository at this point in the history
  • Loading branch information
folke committed Oct 5, 2020
1 parent b700edd commit d387c9c
Show file tree
Hide file tree
Showing 12 changed files with 39 additions and 26 deletions.
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down
4 changes: 4 additions & 0 deletions __tests__/filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"])
}
})
Expand All @@ -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"])
}
})
Expand All @@ -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"])
}
})
Expand All @@ -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"])
}
})
2 changes: 1 addition & 1 deletion __tests__/options.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { defaults } from "../src/options"

test("should ", () => {
test("should", () => {
expect(defaults).toBeDefined()
})
2 changes: 1 addition & 1 deletion __tests__/package.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(["**"], {
Expand Down
24 changes: 12 additions & 12 deletions __tests__/parser.ts
Original file line number Diff line number Diff line change
@@ -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")
Expand All @@ -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" },
Expand All @@ -25,7 +25,7 @@ test("test pre ", () => {
})
})

test("test post ", () => {
test("post", () => {
const parser = new CommandParser({
name: "test",
scripts: { posttest: "bar", test: "foo" },
Expand All @@ -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)
Expand All @@ -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" })
Expand All @@ -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" })
Expand Down
2 changes: 1 addition & 1 deletion __tests__/runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
14 changes: 7 additions & 7 deletions __tests__/spawn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
7 changes: 6 additions & 1 deletion __tests__/workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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, "../")],
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand Down
4 changes: 3 additions & 1 deletion bin/ultra.js
Original file line number Diff line number Diff line change
@@ -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()
1 change: 1 addition & 0 deletions src/package.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/workspace.providers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export const providers: Record<WorkspaceProviderType, WorkspaceProvider> = {
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[],
}
Expand Down
2 changes: 1 addition & 1 deletion src/yargs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
Expand Down

0 comments on commit d387c9c

Please sign in to comment.