From 17e658e297996db3f432f171095136e61ab995cc Mon Sep 17 00:00:00 2001 From: Sebastian Good <2230835+scagood@users.noreply.github.com> Date: Mon, 29 Jan 2024 02:04:23 +0000 Subject: [PATCH] chore: `npm run format` (#175) chore: npm run format --- lib/rules/no-deprecated-api.js | 4 +- tests/fixtures/configs/cjs/package.json | 3 +- .../ts-allow-extension/tsconfig.json | 4 +- .../indirect-thirdparty/package.json | 3 +- .../ts-allow-extension/tsconfig.json | 4 +- .../no-missing/ts-extends/tsconfig.json | 2 +- .../no-missing/ts-paths/tsconfig.json | 6 +- .../no-missing/ts-preserve/tsconfig.json | 4 +- .../no-missing/ts-react/tsconfig.json | 4 +- .../no-unpublished-bin/multi-ok/package.json | 2 +- tests/lib/rules/no-exports-assign.js | 2 +- tests/lib/rules/no-unpublished-bin.js | 544 +++++++++--------- 12 files changed, 288 insertions(+), 294 deletions(-) diff --git a/lib/rules/no-deprecated-api.js b/lib/rules/no-deprecated-api.js index 54367a71..957c51cc 100644 --- a/lib/rules/no-deprecated-api.js +++ b/lib/rules/no-deprecated-api.js @@ -668,8 +668,8 @@ function toName(type, path) { return type === ReferenceTracker.CALL ? `${baseName}()` : type === ReferenceTracker.CONSTRUCT - ? `new ${baseName}()` - : baseName + ? `new ${baseName}()` + : baseName } /** diff --git a/tests/fixtures/configs/cjs/package.json b/tests/fixtures/configs/cjs/package.json index 2c63c085..0967ef42 100644 --- a/tests/fixtures/configs/cjs/package.json +++ b/tests/fixtures/configs/cjs/package.json @@ -1,2 +1 @@ -{ -} +{} diff --git a/tests/fixtures/file-extension-in-import/ts-allow-extension/tsconfig.json b/tests/fixtures/file-extension-in-import/ts-allow-extension/tsconfig.json index 32d0a2a9..2035ba8b 100644 --- a/tests/fixtures/file-extension-in-import/ts-allow-extension/tsconfig.json +++ b/tests/fixtures/file-extension-in-import/ts-allow-extension/tsconfig.json @@ -1,6 +1,6 @@ { "compilerOptions": { "noEmit": true, - "allowImportingTsExtensions": true - } + "allowImportingTsExtensions": true, + }, } diff --git a/tests/fixtures/no-hide-core-modules/indirect-thirdparty/package.json b/tests/fixtures/no-hide-core-modules/indirect-thirdparty/package.json index 52fdc3bb..92a42507 100644 --- a/tests/fixtures/no-hide-core-modules/indirect-thirdparty/package.json +++ b/tests/fixtures/no-hide-core-modules/indirect-thirdparty/package.json @@ -1,4 +1,3 @@ { - "dependencies": { - } + "dependencies": {} } diff --git a/tests/fixtures/no-missing/ts-allow-extension/tsconfig.json b/tests/fixtures/no-missing/ts-allow-extension/tsconfig.json index 32d0a2a9..2035ba8b 100644 --- a/tests/fixtures/no-missing/ts-allow-extension/tsconfig.json +++ b/tests/fixtures/no-missing/ts-allow-extension/tsconfig.json @@ -1,6 +1,6 @@ { "compilerOptions": { "noEmit": true, - "allowImportingTsExtensions": true - } + "allowImportingTsExtensions": true, + }, } diff --git a/tests/fixtures/no-missing/ts-extends/tsconfig.json b/tests/fixtures/no-missing/ts-extends/tsconfig.json index 383418e6..ad3a83db 100644 --- a/tests/fixtures/no-missing/ts-extends/tsconfig.json +++ b/tests/fixtures/no-missing/ts-extends/tsconfig.json @@ -1,3 +1,3 @@ { - "extends": ["./base.tsconfig.json"] + "extends": ["./base.tsconfig.json"], } diff --git a/tests/fixtures/no-missing/ts-paths/tsconfig.json b/tests/fixtures/no-missing/ts-paths/tsconfig.json index f832947b..b933e44c 100644 --- a/tests/fixtures/no-missing/ts-paths/tsconfig.json +++ b/tests/fixtures/no-missing/ts-paths/tsconfig.json @@ -2,7 +2,7 @@ "compilerOptions": { "paths": { "@direct": ["./some/where.ts"], - "@wild/*": ["./some/*"] - } - } + "@wild/*": ["./some/*"], + }, + }, } diff --git a/tests/fixtures/no-missing/ts-preserve/tsconfig.json b/tests/fixtures/no-missing/ts-preserve/tsconfig.json index 94e40481..35e2dff9 100644 --- a/tests/fixtures/no-missing/ts-preserve/tsconfig.json +++ b/tests/fixtures/no-missing/ts-preserve/tsconfig.json @@ -1,5 +1,5 @@ { "compilerOptions": { - "jsx": "preserve" - } + "jsx": "preserve", + }, } diff --git a/tests/fixtures/no-missing/ts-react/tsconfig.json b/tests/fixtures/no-missing/ts-react/tsconfig.json index b5fbd521..d35c99c2 100644 --- a/tests/fixtures/no-missing/ts-react/tsconfig.json +++ b/tests/fixtures/no-missing/ts-react/tsconfig.json @@ -1,5 +1,5 @@ { "compilerOptions": { - "jsx": "react" - } + "jsx": "react", + }, } diff --git a/tests/fixtures/no-unpublished-bin/multi-ok/package.json b/tests/fixtures/no-unpublished-bin/multi-ok/package.json index 2ae8a190..87513ade 100644 --- a/tests/fixtures/no-unpublished-bin/multi-ok/package.json +++ b/tests/fixtures/no-unpublished-bin/multi-ok/package.json @@ -6,4 +6,4 @@ "a": "a.js", "b": "b.js" } -} \ No newline at end of file +} diff --git a/tests/lib/rules/no-exports-assign.js b/tests/lib/rules/no-exports-assign.js index b565d8a0..5f8b2699 100644 --- a/tests/lib/rules/no-exports-assign.js +++ b/tests/lib/rules/no-exports-assign.js @@ -12,7 +12,7 @@ new RuleTester({ globals: { exports: "writable", module: "readonly", - } + }, }, }).run("no-exports-assign", rule, { valid: [ diff --git a/tests/lib/rules/no-unpublished-bin.js b/tests/lib/rules/no-unpublished-bin.js index 35c1cb96..02293b52 100644 --- a/tests/lib/rules/no-unpublished-bin.js +++ b/tests/lib/rules/no-unpublished-bin.js @@ -17,286 +17,282 @@ function fixture(name) { return path.resolve(__dirname, "../../fixtures/no-unpublished-bin", name) } -new RuleTester().run( - "no-unpublished-bin", - rule, - { - valid: [ - { - filename: fixture("simple-ok/a.js"), - code: "'simple-ok/a.js'", - }, - { - filename: fixture("multi-ok/a.js"), - code: "'multi-ok/a.js'", - }, - { - filename: fixture("multi-ok/b.js"), - code: "'multi-ok/b.js'", - }, - { - filename: fixture("simple-files/x.js"), - code: "'simple-files/x.js'", - }, - { - filename: fixture("multi-files/x.js"), - code: "'multi-files/x.js'", - }, - { - filename: fixture("simple-files/lib/a.js"), - code: "'simple-files/lib/a.js'", - }, - { - filename: fixture("multi-files/lib/a.js"), - code: "'multi-files/lib/a.js'", - }, - { - filename: fixture("simple-npmignore/x.js"), - code: "'simple-npmignore/x.js'", - }, - { - filename: fixture("multi-npmignore/x.js"), - code: "'multi-npmignore/x.js'", - }, - { - filename: fixture("simple-npmignore/lib/a.js"), - code: "'simple-npmignore/lib/a.js'", - }, - { - filename: fixture("multi-npmignore/lib/a.js"), - code: "'multi-npmignore/lib/a.js'", - }, - { - filename: fixture("issue115/lib/a.js"), - code: "'issue115/lib/a.js'", - }, +new RuleTester().run("no-unpublished-bin", rule, { + valid: [ + { + filename: fixture("simple-ok/a.js"), + code: "'simple-ok/a.js'", + }, + { + filename: fixture("multi-ok/a.js"), + code: "'multi-ok/a.js'", + }, + { + filename: fixture("multi-ok/b.js"), + code: "'multi-ok/b.js'", + }, + { + filename: fixture("simple-files/x.js"), + code: "'simple-files/x.js'", + }, + { + filename: fixture("multi-files/x.js"), + code: "'multi-files/x.js'", + }, + { + filename: fixture("simple-files/lib/a.js"), + code: "'simple-files/lib/a.js'", + }, + { + filename: fixture("multi-files/lib/a.js"), + code: "'multi-files/lib/a.js'", + }, + { + filename: fixture("simple-npmignore/x.js"), + code: "'simple-npmignore/x.js'", + }, + { + filename: fixture("multi-npmignore/x.js"), + code: "'multi-npmignore/x.js'", + }, + { + filename: fixture("simple-npmignore/lib/a.js"), + code: "'simple-npmignore/lib/a.js'", + }, + { + filename: fixture("multi-npmignore/lib/a.js"), + code: "'multi-npmignore/lib/a.js'", + }, + { + filename: fixture("issue115/lib/a.js"), + code: "'issue115/lib/a.js'", + }, - // empty name - "'stdin'", + // empty name + "'stdin'", - // convertPath option - { - filename: fixture("simple-files/a.js"), - code: "'simple-files/a.js'", - options: [{ convertPath: { "a.js": ["a.js", "lib/a.js"] } }], - }, - { - filename: fixture("multi-files/a.js"), - code: "'multi-files/a.js'", - options: [{ convertPath: { "a.js": ["a.js", "lib/a.js"] } }], - }, - { - filename: fixture("simple-npmignore/a.js"), - code: "'simple-npmignore/a.js'", - options: [{ convertPath: { "a.js": ["a.js", "lib/a.js"] } }], - }, - { - filename: fixture("multi-npmignore/a.js"), - code: "'multi-npmignore/a.js'", - options: [{ convertPath: { "a.js": ["a.js", "lib/a.js"] } }], - }, - - // convertPath shared setting - { - filename: fixture("simple-files/a.js"), - code: "'simple-files/a.js'", - settings: { - node: { convertPath: { "a.js": ["a.js", "lib/a.js"] } }, - }, - }, - { - filename: fixture("multi-files/a.js"), - code: "'multi-files/a.js'", - settings: { - node: { convertPath: { "a.js": ["a.js", "lib/a.js"] } }, - }, - }, - { - filename: fixture("simple-npmignore/a.js"), - code: "'simple-npmignore/a.js'", - settings: { - node: { convertPath: { "a.js": ["a.js", "lib/a.js"] } }, - }, - }, - { - filename: fixture("multi-npmignore/a.js"), - code: "'multi-npmignore/a.js'", - settings: { - node: { convertPath: { "a.js": ["a.js", "lib/a.js"] } }, - }, - }, - ], - invalid: [ - // files field of `package.json` - { - filename: fixture("simple-files/a.js"), - code: "'simple-files/a.js'", - errors: [ - "npm ignores 'a.js'. Check 'files' field of 'package.json' or '.npmignore'.", - ], - }, - { - filename: fixture("multi-files/a.js"), - code: "'multi-files/a.js'", - errors: [ - "npm ignores 'a.js'. Check 'files' field of 'package.json' or '.npmignore'.", - ], - }, - { - filename: fixture("multi-files/b.js"), - code: "'multi-files/b.js'", - errors: [ - "npm ignores 'b.js'. Check 'files' field of 'package.json' or '.npmignore'.", - ], - }, + // convertPath option + { + filename: fixture("simple-files/a.js"), + code: "'simple-files/a.js'", + options: [{ convertPath: { "a.js": ["a.js", "lib/a.js"] } }], + }, + { + filename: fixture("multi-files/a.js"), + code: "'multi-files/a.js'", + options: [{ convertPath: { "a.js": ["a.js", "lib/a.js"] } }], + }, + { + filename: fixture("simple-npmignore/a.js"), + code: "'simple-npmignore/a.js'", + options: [{ convertPath: { "a.js": ["a.js", "lib/a.js"] } }], + }, + { + filename: fixture("multi-npmignore/a.js"), + code: "'multi-npmignore/a.js'", + options: [{ convertPath: { "a.js": ["a.js", "lib/a.js"] } }], + }, - // `.npmignore` - { - filename: fixture("simple-npmignore/a.js"), - code: "'simple-npmignore/a.js'", - errors: [ - "npm ignores 'a.js'. Check 'files' field of 'package.json' or '.npmignore'.", - ], - }, - { - filename: fixture("multi-npmignore/a.js"), - code: "'multi-npmignore/a.js'", - errors: [ - "npm ignores 'a.js'. Check 'files' field of 'package.json' or '.npmignore'.", - ], - }, + // convertPath shared setting + { + filename: fixture("simple-files/a.js"), + code: "'simple-files/a.js'", + settings: { + node: { convertPath: { "a.js": ["a.js", "lib/a.js"] } }, + }, + }, + { + filename: fixture("multi-files/a.js"), + code: "'multi-files/a.js'", + settings: { + node: { convertPath: { "a.js": ["a.js", "lib/a.js"] } }, + }, + }, + { + filename: fixture("simple-npmignore/a.js"), + code: "'simple-npmignore/a.js'", + settings: { + node: { convertPath: { "a.js": ["a.js", "lib/a.js"] } }, + }, + }, + { + filename: fixture("multi-npmignore/a.js"), + code: "'multi-npmignore/a.js'", + settings: { + node: { convertPath: { "a.js": ["a.js", "lib/a.js"] } }, + }, + }, + ], + invalid: [ + // files field of `package.json` + { + filename: fixture("simple-files/a.js"), + code: "'simple-files/a.js'", + errors: [ + "npm ignores 'a.js'. Check 'files' field of 'package.json' or '.npmignore'.", + ], + }, + { + filename: fixture("multi-files/a.js"), + code: "'multi-files/a.js'", + errors: [ + "npm ignores 'a.js'. Check 'files' field of 'package.json' or '.npmignore'.", + ], + }, + { + filename: fixture("multi-files/b.js"), + code: "'multi-files/b.js'", + errors: [ + "npm ignores 'b.js'. Check 'files' field of 'package.json' or '.npmignore'.", + ], + }, - // files field of `package.json` with convertPath - { - filename: fixture("simple-files/x.js"), - code: "'simple-files/x.js'", - options: [{ convertPath: { "x.js": ["x.js", "a.js"] } }], - errors: [ - "npm ignores 'a.js'. Check 'files' field of 'package.json' or '.npmignore'.", - ], - }, - { - filename: fixture("multi-files/x.js"), - code: "'multi-files/x.js'", - options: [{ convertPath: { "x.js": ["x.js", "a.js"] } }], - errors: [ - "npm ignores 'a.js'. Check 'files' field of 'package.json' or '.npmignore'.", - ], - }, - { - filename: fixture("multi-files/x.js"), - code: "'multi-files/x.js'", - options: [{ convertPath: { "x.js": ["x.js", "b.js"] } }], - errors: [ - "npm ignores 'b.js'. Check 'files' field of 'package.json' or '.npmignore'.", - ], - }, + // `.npmignore` + { + filename: fixture("simple-npmignore/a.js"), + code: "'simple-npmignore/a.js'", + errors: [ + "npm ignores 'a.js'. Check 'files' field of 'package.json' or '.npmignore'.", + ], + }, + { + filename: fixture("multi-npmignore/a.js"), + code: "'multi-npmignore/a.js'", + errors: [ + "npm ignores 'a.js'. Check 'files' field of 'package.json' or '.npmignore'.", + ], + }, - // `.npmignore` with convertPath - { - filename: fixture("simple-npmignore/x.js"), - code: "'simple-npmignore/x.js'", - options: [{ convertPath: { "x.js": ["x.js", "a.js"] } }], - errors: [ - "npm ignores 'a.js'. Check 'files' field of 'package.json' or '.npmignore'.", - ], - }, - { - filename: fixture("multi-npmignore/x.js"), - code: "'multi-npmignore/x.js'", - options: [{ convertPath: { "x.js": ["x.js", "a.js"] } }], - errors: [ - "npm ignores 'a.js'. Check 'files' field of 'package.json' or '.npmignore'.", - ], - }, - { - filename: fixture("simple-npmignore/x.js"), - code: "'simple-npmignore/x.js'", - options: [ - { - convertPath: [ - { - include: ["x.js"], - replace: ["x.js", "a.js"], - }, - ], - }, - ], - errors: [ - "npm ignores 'a.js'. Check 'files' field of 'package.json' or '.npmignore'.", - ], - }, - { - filename: fixture("multi-npmignore/x.js"), - code: "'multi-npmignore/x.js'", - options: [ - { - convertPath: [ - { - include: ["x.js"], - replace: ["x.js", "a.js"], - }, - ], - }, - ], - errors: [ - "npm ignores 'a.js'. Check 'files' field of 'package.json' or '.npmignore'.", - ], - }, + // files field of `package.json` with convertPath + { + filename: fixture("simple-files/x.js"), + code: "'simple-files/x.js'", + options: [{ convertPath: { "x.js": ["x.js", "a.js"] } }], + errors: [ + "npm ignores 'a.js'. Check 'files' field of 'package.json' or '.npmignore'.", + ], + }, + { + filename: fixture("multi-files/x.js"), + code: "'multi-files/x.js'", + options: [{ convertPath: { "x.js": ["x.js", "a.js"] } }], + errors: [ + "npm ignores 'a.js'. Check 'files' field of 'package.json' or '.npmignore'.", + ], + }, + { + filename: fixture("multi-files/x.js"), + code: "'multi-files/x.js'", + options: [{ convertPath: { "x.js": ["x.js", "b.js"] } }], + errors: [ + "npm ignores 'b.js'. Check 'files' field of 'package.json' or '.npmignore'.", + ], + }, - // files field of `package.json` with convertPath (shared setting) - { - filename: fixture("simple-files/x.js"), - code: "'simple-files/x.js'", - errors: [ - "npm ignores 'a.js'. Check 'files' field of 'package.json' or '.npmignore'.", - ], - settings: { - node: { convertPath: { "x.js": ["x.js", "a.js"] } }, - }, - }, - { - filename: fixture("multi-files/x.js"), - code: "'multi-files/x.js'", - errors: [ - "npm ignores 'a.js'. Check 'files' field of 'package.json' or '.npmignore'.", - ], - settings: { - node: { convertPath: { "x.js": ["x.js", "a.js"] } }, + // `.npmignore` with convertPath + { + filename: fixture("simple-npmignore/x.js"), + code: "'simple-npmignore/x.js'", + options: [{ convertPath: { "x.js": ["x.js", "a.js"] } }], + errors: [ + "npm ignores 'a.js'. Check 'files' field of 'package.json' or '.npmignore'.", + ], + }, + { + filename: fixture("multi-npmignore/x.js"), + code: "'multi-npmignore/x.js'", + options: [{ convertPath: { "x.js": ["x.js", "a.js"] } }], + errors: [ + "npm ignores 'a.js'. Check 'files' field of 'package.json' or '.npmignore'.", + ], + }, + { + filename: fixture("simple-npmignore/x.js"), + code: "'simple-npmignore/x.js'", + options: [ + { + convertPath: [ + { + include: ["x.js"], + replace: ["x.js", "a.js"], + }, + ], }, - }, - { - filename: fixture("multi-files/x.js"), - code: "'multi-files/x.js'", - errors: [ - "npm ignores 'b.js'. Check 'files' field of 'package.json' or '.npmignore'.", - ], - settings: { - node: { convertPath: { "x.js": ["x.js", "b.js"] } }, + ], + errors: [ + "npm ignores 'a.js'. Check 'files' field of 'package.json' or '.npmignore'.", + ], + }, + { + filename: fixture("multi-npmignore/x.js"), + code: "'multi-npmignore/x.js'", + options: [ + { + convertPath: [ + { + include: ["x.js"], + replace: ["x.js", "a.js"], + }, + ], }, - }, + ], + errors: [ + "npm ignores 'a.js'. Check 'files' field of 'package.json' or '.npmignore'.", + ], + }, - // `.npmignore` with convertPath (shared setting) - { - filename: fixture("simple-npmignore/x.js"), - code: "'simple-npmignore/x.js'", - errors: [ - "npm ignores 'a.js'. Check 'files' field of 'package.json' or '.npmignore'.", - ], - settings: { - node: { convertPath: { "x.js": ["x.js", "a.js"] } }, - }, - }, - { - filename: fixture("multi-npmignore/x.js"), - code: "'multi-npmignore/x.js'", - errors: [ - "npm ignores 'a.js'. Check 'files' field of 'package.json' or '.npmignore'.", - ], - settings: { - node: { convertPath: { "x.js": ["x.js", "a.js"] } }, - }, - }, - ], - } -) + // files field of `package.json` with convertPath (shared setting) + { + filename: fixture("simple-files/x.js"), + code: "'simple-files/x.js'", + errors: [ + "npm ignores 'a.js'. Check 'files' field of 'package.json' or '.npmignore'.", + ], + settings: { + node: { convertPath: { "x.js": ["x.js", "a.js"] } }, + }, + }, + { + filename: fixture("multi-files/x.js"), + code: "'multi-files/x.js'", + errors: [ + "npm ignores 'a.js'. Check 'files' field of 'package.json' or '.npmignore'.", + ], + settings: { + node: { convertPath: { "x.js": ["x.js", "a.js"] } }, + }, + }, + { + filename: fixture("multi-files/x.js"), + code: "'multi-files/x.js'", + errors: [ + "npm ignores 'b.js'. Check 'files' field of 'package.json' or '.npmignore'.", + ], + settings: { + node: { convertPath: { "x.js": ["x.js", "b.js"] } }, + }, + }, + + // `.npmignore` with convertPath (shared setting) + { + filename: fixture("simple-npmignore/x.js"), + code: "'simple-npmignore/x.js'", + errors: [ + "npm ignores 'a.js'. Check 'files' field of 'package.json' or '.npmignore'.", + ], + settings: { + node: { convertPath: { "x.js": ["x.js", "a.js"] } }, + }, + }, + { + filename: fixture("multi-npmignore/x.js"), + code: "'multi-npmignore/x.js'", + errors: [ + "npm ignores 'a.js'. Check 'files' field of 'package.json' or '.npmignore'.", + ], + settings: { + node: { convertPath: { "x.js": ["x.js", "a.js"] } }, + }, + }, + ], +})