From 5847bc5795b9baf121f508f47c652cf97abfde03 Mon Sep 17 00:00:00 2001 From: Marc Mintel Date: Sat, 7 Feb 2026 16:38:14 +0100 Subject: [PATCH] fix: nextjs eslint flat config compatibility --- packages/eslint-config/next.js | 69 +++++++++++++++-------------- packages/eslint-config/package.json | 2 + pnpm-lock.yaml | 6 +++ 3 files changed, 43 insertions(+), 34 deletions(-) diff --git a/packages/eslint-config/next.js b/packages/eslint-config/next.js index 2ebc9d5..99d6d03 100644 --- a/packages/eslint-config/next.js +++ b/packages/eslint-config/next.js @@ -1,40 +1,41 @@ -import { dirname } from "path"; -import { fileURLToPath } from "url"; -import { FlatCompat } from "@eslint/eslintrc"; +import nextPlugin from "@next/eslint-plugin-next"; +import reactPlugin from "eslint-plugin-react"; +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); - -const compat = new FlatCompat({ - baseDirectory: __dirname, -}); - -export const nextConfig = [ - { - ignores: [ - "**/dist/**", - "**/build/**", - "**/out/**", - "**/coverage/**", - "**/.next/**", - "**/node_modules/**", - "**/.gitea/**", - "**/.changeset/**", - "**/.vercel/**", - ], - }, - ...compat.extends("next/core-web-vitals", "next/typescript"), +/** + * Mintel Next.js ESLint Configuration (Flat Config) + * + * This configuration replaces the legacy 'eslint-config-next' which + * relies on @rushstack/eslint-patch and causes issues in ESLint 9. + */ +export const nextConfig = tseslint.config( { + 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: { - "@typescript-eslint/no-explicit-any": "off", - "@typescript-eslint/no-unused-vars": [ - "warn", - { argsIgnorePattern: "^_" }, - ], - "@typescript-eslint/no-require-imports": "off", - "prefer-const": "warn", + ...reactPlugin.configs.recommended.rules, + ...hooksPlugin.configs.recommended.rules, + ...nextPlugin.configs.recommended.rules, + ...nextPlugin.configs["core-web-vitals"].rules, + "react/react-in-jsx-scope": "off", "react/no-unescaped-entities": "off", "@next/next/no-img-element": "warn", }, - }, -]; + settings: { + react: { + version: "detect", + }, + }, + } +); diff --git a/packages/eslint-config/package.json b/packages/eslint-config/package.json index afc6d41..3e6d02d 100644 --- a/packages/eslint-config/package.json +++ b/packages/eslint-config/package.json @@ -22,6 +22,8 @@ "@eslint/js": "^9.39.2", "@next/eslint-plugin-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" } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index a893cb7..d0e9953 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -175,6 +175,12 @@ importers: eslint-config-next: specifier: 15.1.6 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: specifier: ^8.54.0 version: 8.54.0(eslint@9.39.2(jiti@2.6.1))(typescript@5.9.3)