diff --git a/global.d.ts b/global.d.ts index 03b4db0..e642dd0 100644 --- a/global.d.ts +++ b/global.d.ts @@ -7,3 +7,8 @@ declare module "eslint-plugin-import" { const value: unknown; export default value; } + +declare module "@next/eslint-plugin-next" { + const value: any; + export default value; +} diff --git a/package-lock.json b/package-lock.json index b98129d..5efec64 100644 --- a/package-lock.json +++ b/package-lock.json @@ -16,6 +16,7 @@ "typescript-eslint": "^8.15.0" }, "devDependencies": { + "@next/eslint-plugin-next": "^15.0.3", "@types/eslint__js": "^8.42.3", "@types/eslint-plugin-jsx-a11y": "^6.9.0", "eslint": "^9.15.0", @@ -247,6 +248,46 @@ "url": "https://github.com/sponsors/nzakas" } }, + "node_modules/@next/eslint-plugin-next": { + "version": "15.0.3", + "resolved": "https://registry.npmjs.org/@next/eslint-plugin-next/-/eslint-plugin-next-15.0.3.tgz", + "integrity": "sha512-3Ln/nHq2V+v8uIaxCR6YfYo7ceRgZNXfTd3yW1ukTaFbO+/I8jNakrjYWODvG9BuR2v5kgVtH/C8r0i11quOgw==", + "dev": true, + "license": "MIT", + "dependencies": { + "fast-glob": "3.3.1" + } + }, + "node_modules/@next/eslint-plugin-next/node_modules/fast-glob": { + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.1.tgz", + "integrity": "sha512-kNFPyjhh5cKjrUltxs+wFx+ZkbRaxxmZ+X0ZU31SOsxCEtP9VPgtq2teZw1DebupL5GmDaNQ6yKMMVcM41iqDg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@nodelib/fs.stat": "^2.0.2", + "@nodelib/fs.walk": "^1.2.3", + "glob-parent": "^5.1.2", + "merge2": "^1.3.0", + "micromatch": "^4.0.4" + }, + "engines": { + "node": ">=8.6.0" + } + }, + "node_modules/@next/eslint-plugin-next/node_modules/glob-parent": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", + "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", + "dev": true, + "license": "ISC", + "dependencies": { + "is-glob": "^4.0.1" + }, + "engines": { + "node": ">= 6" + } + }, "node_modules/@nodelib/fs.scandir": { "version": "2.1.5", "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", diff --git a/package.json b/package.json index c7b1a73..e83afdc 100644 --- a/package.json +++ b/package.json @@ -78,6 +78,7 @@ "typescript-eslint": "^8.15.0" }, "devDependencies": { + "@next/eslint-plugin-next": "^15.0.3", "@types/eslint__js": "^8.42.3", "@types/eslint-plugin-jsx-a11y": "^6.9.0", "eslint": "^9.15.0", diff --git a/src/index.ts b/src/index.ts index 8175fe3..43352dc 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,6 +1,7 @@ import base from "./base.js"; import importPlugin from "./import.js"; import { loadJsxAccessibilityConfig } from "./jsx-a11y.js"; +import { loadNextConfig } from "./next.js"; import { loadReactConfig } from "./react.js"; import stylistic from "./stylistic.js"; import typescript from "./typescript.js"; @@ -13,6 +14,7 @@ export default [ ...typescript, ...(await loadReactConfig()), ...(await loadJsxAccessibilityConfig()), + ...(await loadNextConfig()), ...importPlugin, ...unusedImports, ] as Linter.Config[]; diff --git a/src/next.ts b/src/next.ts new file mode 100644 index 0000000..20e61ed --- /dev/null +++ b/src/next.ts @@ -0,0 +1,20 @@ +import type { Linter } from "eslint"; + +export async function loadNextConfig() { + try { + const { default: nextPlugin } = await import("@next/eslint-plugin-next"); + return [ + { + plugins: { + "@next/next": nextPlugin, + }, + rules: { + ...nextPlugin.configs.recommended.rules, + ...nextPlugin.configs["core-web-vitals"].rules, + }, + }, + ] as Linter.Config[]; + } catch { + return []; + } +}