fix: nextjs eslint flat config compatibility

This commit is contained in:
2026-02-07 16:38:14 +01:00
parent e662415137
commit 5847bc5795
3 changed files with 43 additions and 34 deletions

View File

@@ -1,40 +1,41 @@
import { dirname } from "path"; import nextPlugin from "@next/eslint-plugin-next";
import { fileURLToPath } from "url"; import reactPlugin from "eslint-plugin-react";
import { FlatCompat } from "@eslint/eslintrc"; import hooksPlugin from "eslint-plugin-react-hooks";
import tseslint from "typescript-eslint";
import js from "@eslint/js";
const __filename = fileURLToPath(import.meta.url); /**
const __dirname = dirname(__filename); * Mintel Next.js ESLint Configuration (Flat Config)
*
const compat = new FlatCompat({ * This configuration replaces the legacy 'eslint-config-next' which
baseDirectory: __dirname, * relies on @rushstack/eslint-patch and causes issues in ESLint 9.
}); */
export const nextConfig = tseslint.config(
export const nextConfig = [
{
ignores: [
"**/dist/**",
"**/build/**",
"**/out/**",
"**/coverage/**",
"**/.next/**",
"**/node_modules/**",
"**/.gitea/**",
"**/.changeset/**",
"**/.vercel/**",
],
},
...compat.extends("next/core-web-vitals", "next/typescript"),
{ {
plugins: {
"react": reactPlugin,
"react-hooks": hooksPlugin,
"@next/next": nextPlugin,
},
languageOptions: {
globals: {
// Add common browser/node globals if needed,
// though usually handled by base configs
},
},
rules: { rules: {
"@typescript-eslint/no-explicit-any": "off", ...reactPlugin.configs.recommended.rules,
"@typescript-eslint/no-unused-vars": [ ...hooksPlugin.configs.recommended.rules,
"warn", ...nextPlugin.configs.recommended.rules,
{ argsIgnorePattern: "^_" }, ...nextPlugin.configs["core-web-vitals"].rules,
], "react/react-in-jsx-scope": "off",
"@typescript-eslint/no-require-imports": "off",
"prefer-const": "warn",
"react/no-unescaped-entities": "off", "react/no-unescaped-entities": "off",
"@next/next/no-img-element": "warn", "@next/next/no-img-element": "warn",
}, },
}, settings: {
]; react: {
version: "detect",
},
},
}
);

View File

@@ -22,6 +22,8 @@
"@eslint/js": "^9.39.2", "@eslint/js": "^9.39.2",
"@next/eslint-plugin-next": "15.1.6", "@next/eslint-plugin-next": "15.1.6",
"eslint-config-next": "15.1.6", "eslint-config-next": "15.1.6",
"eslint-plugin-react": "^7.37.5",
"eslint-plugin-react-hooks": "^7.0.1",
"typescript-eslint": "^8.54.0" "typescript-eslint": "^8.54.0"
} }
} }

6
pnpm-lock.yaml generated
View File

@@ -175,6 +175,12 @@ importers:
eslint-config-next: eslint-config-next:
specifier: 15.1.6 specifier: 15.1.6
version: 15.1.6(eslint@9.39.2(jiti@2.6.1))(typescript@5.9.3) version: 15.1.6(eslint@9.39.2(jiti@2.6.1))(typescript@5.9.3)
eslint-plugin-react:
specifier: ^7.37.5
version: 7.37.5(eslint@9.39.2(jiti@2.6.1))
eslint-plugin-react-hooks:
specifier: ^7.0.1
version: 7.0.1(eslint@9.39.2(jiti@2.6.1))
typescript-eslint: typescript-eslint:
specifier: ^8.54.0 specifier: ^8.54.0
version: 8.54.0(eslint@9.39.2(jiti@2.6.1))(typescript@5.9.3) version: 8.54.0(eslint@9.39.2(jiti@2.6.1))(typescript@5.9.3)