diff --git a/eslint.config.js b/eslint.config.js index b6f6e04ab..c5fd5bb06 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -1,34 +1,52 @@ import globals from "globals"; -import path from "node:path"; -import { fileURLToPath } from "node:url"; -import js from "@eslint/js"; -import { FlatCompat } from "@eslint/eslintrc"; +import pluginJs from "@eslint/js"; +import stylisticJs from "@stylistic/eslint-plugin-js"; +import prettier from "eslint-config-prettier"; -const __filename = fileURLToPath(import.meta.url); -const __dirname = path.dirname(__filename); -const compat = new FlatCompat({ - baseDirectory: __dirname, - recommendedConfig: js.configs.recommended, - allConfig: js.configs.all, -}); +export const GLOB_SRC_EXT = '?([cm])[jt]s?(x)' -export default [ - ...compat.extends("eslint:recommended", "prettier"), - { - languageOptions: { - globals: { - ...globals.node, - }, - - ecmaVersion: "latest", - sourceType: "module", - }, +export const GLOB_TESTS = [ + `**/test/**/*.${GLOB_SRC_EXT}`, + `**/__tests__/**/*.${GLOB_SRC_EXT}`, + `**/*.spec.${GLOB_SRC_EXT}`, + `**/*.test.${GLOB_SRC_EXT}`, + `**/*.bench.${GLOB_SRC_EXT}`, + `**/*.benchmark.${GLOB_SRC_EXT}`, +] - rules: { - "no-async-promise-executor": "warn", - "no-prototype-builtins": "warn", - "no-unused-vars": "warn", - "space-unary-ops": "error", - }, - }, +export default [ + { + name: "11ty/setup/js", + ...pluginJs.configs.recommended, + }, + { + name: "11ty/rules/project-specific", + plugins: { + "@stylistic/js": stylisticJs, + }, + languageOptions: { + globals: { + ...globals.node, + }, + ecmaVersion: "latest", + sourceType: "module", + }, + rules: { + "no-async-promise-executor": "warn", + "no-prototype-builtins": "warn", + "no-unused-vars": "warn", + "@stylistic/js/space-unary-ops": "error", + }, + }, + { + name: "11ty/ignores", + files: GLOB_TESTS, + rules: { + "no-unused-vars": "off", + }, + }, + { + name: "11ty/setup/prettier", + ...prettier, + }, ]; diff --git a/package-lock.json b/package-lock.json index 847a23d1d..d6e426f9a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -51,16 +51,15 @@ "@11ty/eleventy-img": "^6.0.2", "@11ty/eleventy-plugin-rss": "^2.0.3", "@11ty/eleventy-plugin-syntaxhighlight": "^5.0.0", - "@eslint/eslintrc": "^3.3.1", "@eslint/js": "^9.24.0", "@iarna/toml": "^2.2.5", "@mdx-js/node-loader": "^3.1.0", + "@stylistic/eslint-plugin-js": "^4.2.0", "@types/node": "^22.14.1", "@vue/server-renderer": "^3.5.13", "@zachleat/noop": "^1.0.4", "ava": "^6.2.0", "c8": "^10.1.3", - "cross-env": "^7.0.3", "eslint": "^9.24.0", "eslint-config-prettier": "^10.1.2", "globals": "^16.0.0", @@ -2051,6 +2050,23 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/@stylistic/eslint-plugin-js": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/@stylistic/eslint-plugin-js/-/eslint-plugin-js-4.2.0.tgz", + "integrity": "sha512-MiJr6wvyzMYl/wElmj8Jns8zH7Q1w8XoVtm+WM6yDaTrfxryMyb8n0CMxt82fo42RoLIfxAEtM6tmQVxqhk0/A==", + "dev": true, + "license": "MIT", + "dependencies": { + "eslint-visitor-keys": "^4.2.0", + "espree": "^10.3.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "peerDependencies": { + "eslint": ">=9.0.0" + } + }, "node_modules/@types/acorn": { "version": "4.0.6", "resolved": "https://registry.npmjs.org/@types/acorn/-/acorn-4.0.6.tgz", @@ -3306,25 +3322,6 @@ "node": "^12.20.0 || ^14.13.1 || >=16.0.0" } }, - "node_modules/cross-env": { - "version": "7.0.3", - "resolved": "https://registry.npmjs.org/cross-env/-/cross-env-7.0.3.tgz", - "integrity": "sha512-+/HKd6EgcQCJGh2PSjZuUitQBQynKor4wrFbRg4DtAgS1aWO+gU52xpH7M9ScGgXSYmAVS9bIJ8EzuaGw0oNAw==", - "dev": true, - "license": "MIT", - "dependencies": { - "cross-spawn": "^7.0.1" - }, - "bin": { - "cross-env": "src/bin/cross-env.js", - "cross-env-shell": "src/bin/cross-env-shell.js" - }, - "engines": { - "node": ">=10.14", - "npm": ">=6", - "yarn": ">=1" - } - }, "node_modules/cross-spawn": { "version": "7.0.6", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz", diff --git a/package.json b/package.json index 52e7502f9..44e01712c 100644 --- a/package.json +++ b/package.json @@ -92,16 +92,15 @@ "@11ty/eleventy-img": "^6.0.2", "@11ty/eleventy-plugin-rss": "^2.0.3", "@11ty/eleventy-plugin-syntaxhighlight": "^5.0.0", - "@eslint/eslintrc": "^3.3.1", "@eslint/js": "^9.24.0", "@iarna/toml": "^2.2.5", "@mdx-js/node-loader": "^3.1.0", + "@stylistic/eslint-plugin-js": "^4.2.0", "@types/node": "^22.14.1", "@vue/server-renderer": "^3.5.13", "@zachleat/noop": "^1.0.4", "ava": "^6.2.0", "c8": "^10.1.3", - "cross-env": "^7.0.3", "eslint": "^9.24.0", "eslint-config-prettier": "^10.1.2", "globals": "^16.0.0",