import { defineConfig, globalIgnores } from "eslint/config"; import nextVitals from "eslint-config-next/core-web-vitals"; import nextTs from "eslint-config-next/typescript"; import sonarjs from "eslint-plugin-sonarjs"; import unusedImports from "eslint-plugin-unused-imports"; const eslintConfig = defineConfig([ ...nextVitals, ...nextTs, // Override default ignores of eslint-config-next. globalIgnores([ // Default ignores of eslint-config-next: ".next/**", "out/**", "build/**", "next-env.d.ts", // Test artifacts (Playwright): "**/test-results/**", "**/playwright-report/**", ]), { plugins: { sonarjs, "unused-imports": unusedImports, }, rules: { "max-lines": ["warn", { max: 600, skipBlankLines: true, skipComments: true }], "max-lines-per-function": ["warn", { max: 100, skipBlankLines: true, skipComments: true }], complexity: ["warn", 15], "max-depth": ["warn", 4], "max-params": ["warn", 5], "no-nested-ternary": "warn", "sonarjs/cognitive-complexity": ["warn", 20], "sonarjs/no-duplicate-string": ["warn", { threshold: 4 }], "sonarjs/no-identical-functions": "warn", "unused-imports/no-unused-imports": "warn", "@typescript-eslint/no-unused-vars": [ "warn", { varsIgnorePattern: "^_", argsIgnorePattern: "^_", caughtErrorsIgnorePattern: "^_" }, ], }, }, // E2E tests (Playwright): disable React hooks rules since Playwright's `use()` and // `test.extend()` patterns are falsely flagged, and relax test-specific limits. { files: ["e2e/**/*.ts"], rules: { "react-hooks/rules-of-hooks": "off", "react-hooks/exhaustive-deps": "off", "max-lines-per-function": "off", "max-lines": "off", "sonarjs/no-duplicate-string": "off", }, }, ]); export default eslintConfig;