- Override react-hooks rules within the same config object that defines the plugin - Avoids 'Cannot redefine plugin' error in ESLint 9 flat config
39 lines
998 B
JavaScript
39 lines
998 B
JavaScript
import { defineConfig, globalIgnores } from "eslint/config";
|
|
import nextVitals from "eslint-config-next/core-web-vitals";
|
|
import nextTs from "eslint-config-next/typescript";
|
|
|
|
const eslintConfig = defineConfig([
|
|
...nextVitals.map((cfg) => {
|
|
// Downgrade React 19 strict rules to warnings (fix incrementally)
|
|
if (cfg?.rules?.["react-hooks/rules-of-hooks"]) {
|
|
return {
|
|
...cfg,
|
|
rules: {
|
|
...cfg.rules,
|
|
"react-hooks/rules-of-hooks": "warn",
|
|
"react-hooks/set-state-in-effect": "off",
|
|
"react-hooks/purity": "warn",
|
|
},
|
|
};
|
|
}
|
|
return cfg;
|
|
}),
|
|
...nextTs,
|
|
// Override default ignores of eslint-config-next.
|
|
globalIgnores([
|
|
// Default ignores of eslint-config-next:
|
|
".next/**",
|
|
"out/**",
|
|
"build/**",
|
|
"next-env.d.ts",
|
|
]),
|
|
{
|
|
rules: {
|
|
"@typescript-eslint/no-this-alias": "warn",
|
|
"@typescript-eslint/no-require-imports": "warn",
|
|
},
|
|
},
|
|
]);
|
|
|
|
export default eslintConfig;
|