1
1
mirror of https://github.com/theoludwig/eslint-config-conventions.git synced 2025-02-23 01:01:31 +01:00

Compare commits

..

No commits in common. "develop" and "v18.0.0" have entirely different histories.

9 changed files with 743 additions and 597 deletions

View File

@ -13,7 +13,7 @@ jobs:
- uses: "actions/checkout@v4.2.2"
- name: "Setup Node.js"
uses: "actions/setup-node@v4.2.0"
uses: "actions/setup-node@v4.1.0"
with:
node-version: "lts/*"
cache: "npm"

View File

@ -19,7 +19,7 @@ jobs:
persist-credentials: false
- name: "Setup Node.js"
uses: "actions/setup-node@v4.2.0"
uses: "actions/setup-node@v4.1.0"
with:
node-version: "lts/*"
cache: "npm"

View File

@ -13,7 +13,7 @@ jobs:
- uses: "actions/checkout@v4.2.2"
- name: "Setup Node.js"
uses: "actions/setup-node@v4.2.0"
uses: "actions/setup-node@v4.1.0"
with:
node-version: "lts/*"
cache: "npm"

View File

@ -35,13 +35,13 @@ More information about **formatting rules** vs **code-quality rules** can be fou
```sh
npm install --save-dev \
eslint@^9.21.0 \
eslint-plugin-promise@^7.2.1 \
eslint-plugin-unicorn@^57.0.0 \
eslint-plugin-import-x@^4.6.1 \
globals@^16.0.0 \
typescript@^5.7.3 \
typescript-eslint@^8.24.1 \
eslint@^9.12.0 \
eslint-plugin-promise@^7.1.0 \
eslint-plugin-unicorn@^56.0.0 \
eslint-plugin-import-x@^4.3.1 \
globals@^15.10.0 \
typescript@~5.5.4 \
typescript-eslint@^8.8.0 \
eslint-config-conventions@latest
```

View File

@ -132,8 +132,6 @@ export default typescriptESLint.config(
"no-array-constructor": "error",
"no-caller": "error",
"no-delete-var": "error",
"no-implicit-coercion": "error",
"no-extra-boolean-cast": ["error", { enforceForInnerExpressions: true }],
"no-empty": [
"error",
{
@ -225,7 +223,6 @@ export default typescriptESLint.config(
"unicorn/better-regex": "error",
"unicorn/catch-error-name": "error",
"unicorn/custom-error-definition": "error",
"unicorn/consistent-date-clone": "error",
"unicorn/error-message": "error",
"unicorn/escape-case": "error",
"unicorn/explicit-length-check": "error",
@ -234,10 +231,9 @@ export default typescriptESLint.config(
"unicorn/no-array-for-each": "error",
"unicorn/no-array-method-this-argument": "error",
"unicorn/no-document-cookie": "error",
"unicorn/no-named-default": "error",
"unicorn/no-empty-file": "error",
"unicorn/no-hex-escape": "error",
"unicorn/no-instanceof-builtins": "error",
"unicorn/no-instanceof-array": "error",
"unicorn/no-new-array": "error",
"unicorn/no-new-buffer": "error",
"unicorn/no-this-assignment": "error",
@ -251,7 +247,6 @@ export default typescriptESLint.config(
"unicorn/prefer-modern-math-apis": "error",
"unicorn/prefer-structured-clone": "error",
"unicorn/template-indent": "error",
"unicorn/consistent-existence-index-check": "error",
"import-x/no-absolute-path": "error",
"import-x/no-webpack-loader-syntax": "error",
@ -368,6 +363,7 @@ export default typescriptESLint.config(
],
"@typescript-eslint/method-signature-style": "error",
"@typescript-eslint/unbound-method": "error",
"@typescript-eslint/naming-convention": [
"error",
@ -392,19 +388,7 @@ export default typescriptESLint.config(
},
],
"@typescript-eslint/no-floating-promises": [
"error",
{
allowForKnownSafeCalls: [
{
from: "package",
name: ["it", "describe"],
package: "node:test",
},
],
},
],
"@typescript-eslint/no-floating-promises": "error",
"@typescript-eslint/no-for-in-array": "error",
"@typescript-eslint/no-invalid-void-type": "error",
"@typescript-eslint/no-misused-new": "error",

1101
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -45,24 +45,25 @@
"release": "semantic-release"
},
"peerDependencies": {
"eslint": "^9.21.0",
"eslint-plugin-promise": "^7.2.1",
"eslint-plugin-unicorn": "^57.0.0",
"eslint-plugin-import-x": "^4.6.1",
"globals": "^16.0.0",
"typescript-eslint": "^8.24.1"
"eslint": "^9.12.0",
"eslint-plugin-promise": "^7.1.0",
"eslint-plugin-unicorn": "^56.0.0",
"eslint-plugin-import-x": "^4.3.1",
"globals": "^15.10.0",
"typescript-eslint": "^8.8.0"
},
"devDependencies": {
"@types/node": "22.13.5",
"globals": "16.0.0",
"editorconfig-checker": "6.0.1",
"eslint": "9.21.0",
"@types/eslint__js": "8.42.3",
"@types/node": "22.10.2",
"globals": "15.13.0",
"editorconfig-checker": "6.0.0",
"eslint": "9.17.0",
"eslint-plugin-promise": "7.2.1",
"eslint-plugin-unicorn": "57.0.0",
"eslint-plugin-import-x": "4.6.1",
"typescript-eslint": "8.24.1",
"prettier": "3.5.2",
"semantic-release": "24.2.3",
"typescript": "5.7.3"
"eslint-plugin-unicorn": "56.0.1",
"eslint-plugin-import-x": "4.5.0",
"typescript-eslint": "8.18.0",
"prettier": "3.4.2",
"semantic-release": "24.2.0",
"typescript": "5.7.2"
}
}

77
test/validate-config.js Normal file
View File

@ -0,0 +1,77 @@
import test from "node:test"
import assert from "node:assert/strict"
import { ESLint } from "eslint"
const eslint = new ESLint()
test("ensure we validate correctly JavaScript files", async () => {
const [noErrors] = await eslint.lintFiles(
"test/fixtures/javascript-no-errors.js",
)
const [withErrors] = await eslint.lintFiles(
"test/fixtures/javascript-with-errors.js",
)
assert.strictEqual(noErrors?.errorCount, 0, JSON.stringify(noErrors, null, 2))
assert.strictEqual(
withErrors?.errorCount,
3,
JSON.stringify(withErrors, null, 2),
)
})
test("ensure we do not use deprecated rules", async () => {
const [javascriptLintResult] = await eslint.lintFiles(
"test/fixtures/javascript-no-errors.js",
)
const [typescriptLintResult] = await eslint.lintFiles(
"test/fixtures/typescript-no-errors.ts",
)
assert.strictEqual(
javascriptLintResult.usedDeprecatedRules.length,
0,
JSON.stringify(javascriptLintResult, null, 2),
)
assert.strictEqual(
typescriptLintResult.usedDeprecatedRules.length,
0,
JSON.stringify(typescriptLintResult, null, 2),
)
})
test("ensure we validate correctly TypeScript files", async () => {
const [noErrors] = await eslint.lintFiles(
"test/fixtures/typescript-no-errors.ts",
)
const [withErrors] = await eslint.lintFiles(
"test/fixtures/javascript-with-errors.js",
)
assert.strictEqual(noErrors?.errorCount, 0, JSON.stringify(noErrors, null, 2))
assert.strictEqual(
withErrors?.errorCount,
3,
JSON.stringify(withErrors, null, 2),
)
})
test("ensure we allow top-level await", async () => {
const [lintResult] = await eslint.lintFiles(
"test/fixtures/top-level-await.mjs",
)
assert.strictEqual(
lintResult?.errorCount,
0,
JSON.stringify(lintResult, null, 2),
)
})
test("ensure we allow to ignore floating promise with void operator (@typescript-eslint/no-floating-promises)", async () => {
const [lintResult] = await eslint.lintFiles(
"test/fixtures/typescript-no-errors-ignore-promise.ts",
)
assert.strictEqual(
lintResult?.errorCount,
0,
JSON.stringify(lintResult, null, 2),
)
})

View File

@ -1,87 +0,0 @@
import assert from "node:assert/strict"
import { describe, it } from "node:test"
import { ESLint } from "eslint"
const eslint = new ESLint()
describe("ESLint configuration", () => {
it("should validate correctly JavaScript files", async () => {
const [noErrors] = await eslint.lintFiles(
"test/fixtures/javascript-no-errors.js",
)
const [withErrors] = await eslint.lintFiles(
"test/fixtures/javascript-with-errors.js",
)
assert.strictEqual(
noErrors?.errorCount,
0,
JSON.stringify(noErrors, null, 2),
)
assert.strictEqual(
withErrors?.errorCount,
3,
JSON.stringify(withErrors, null, 2),
)
})
it("should validate correctly TypeScript files", async () => {
const [noErrors] = await eslint.lintFiles(
"test/fixtures/typescript-no-errors.ts",
)
const [withErrors] = await eslint.lintFiles(
"test/fixtures/javascript-with-errors.js",
)
assert.strictEqual(
noErrors?.errorCount,
0,
JSON.stringify(noErrors, null, 2),
)
assert.strictEqual(
withErrors?.errorCount,
3,
JSON.stringify(withErrors, null, 2),
)
})
it("should not use deprecated rules", async () => {
const [javascriptLintResult] = await eslint.lintFiles(
"test/fixtures/javascript-no-errors.js",
)
const [typescriptLintResult] = await eslint.lintFiles(
"test/fixtures/typescript-no-errors.ts",
)
assert.strictEqual(
javascriptLintResult.usedDeprecatedRules.length,
0,
JSON.stringify(javascriptLintResult, null, 2),
)
assert.strictEqual(
typescriptLintResult.usedDeprecatedRules.length,
0,
JSON.stringify(typescriptLintResult, null, 2),
)
})
it("should allow top-level await", async () => {
const [lintResult] = await eslint.lintFiles(
"test/fixtures/top-level-await.mjs",
)
assert.strictEqual(
lintResult?.errorCount,
0,
JSON.stringify(lintResult, null, 2),
)
})
it("should allow to ignore floating promise with void operator (@typescript-eslint/no-floating-promises)", async () => {
const [lintResult] = await eslint.lintFiles(
"test/fixtures/typescript-no-errors-ignore-promise.ts",
)
assert.strictEqual(
lintResult?.errorCount,
0,
JSON.stringify(lintResult, null, 2),
)
})
})