import path from "node:path"; import { fileURLToPath } from "node:url"; import { fixupConfigRules, fixupPluginRules } from "@eslint/compat"; import typescriptEslint from "@typescript-eslint/eslint-plugin"; import tsParser from "@typescript-eslint/parser"; import _import from "eslint-plugin-import"; import jsxA11Y from "eslint-plugin-jsx-a11y"; import prettier from "eslint-plugin-prettier"; import react from "eslint-plugin-react"; import unusedImports from "eslint-plugin-unused-imports"; import { defineConfig, globalIgnores } from "eslint/config"; import globals from "globals"; const __filename = fileURLToPath(import.meta.url); const __dirname = path.dirname(__filename); const compat = new FlatCompat({ baseDirectory: __dirname, recommendedConfig: js.configs.recommended, allConfig: js.configs.all, }); export default defineConfig([ globalIgnores([ ".next/**", "node_modules/**", "out/**", "dist/**", "**/index.ts", "**/index.d.ts", ]), { extends: fixupConfigRules( compat.extends( "plugin:react/recommended", "plugin:prettier/recommended", "plugin:react-hooks/recommended", "plugin:jsx-a11y/recommended", "plugin:@next/next/recommended" ) ), plugins: { react: fixupPluginRules(react), "unused-imports": unusedImports, import: fixupPluginRules(_import), "@typescript-eslint": typescriptEslint, "jsx-a11y": fixupPluginRules(jsxA11Y), prettier: fixupPluginRules(prettier), }, languageOptions: { globals: { ...Object.fromEntries( Object.entries(globals.browser).map(([key]) => [key, "off"]) ), ...globals.node, }, parser: tsParser, ecmaVersion: 12, sourceType: "module", parserOptions: { ecmaFeatures: { jsx: true, }, }, }, settings: { react: { version: "detect", }, }, rules: { "no-console": "warn", "react/prop-types": "off", "react/jsx-uses-react": "off", "react/react-in-jsx-scope": "off", "react-hooks/exhaustive-deps": "off", "@next/next/no-assign-module-variable": "off", "jsx-a11y/click-events-have-key-events": "warn", "jsx-a11y/interactive-supports-focus": "warn", "prettier/prettier": "warn", // Disable the built‑in unused vars rules: "no-unused-vars": "off", "@typescript-eslint/no-unused-vars": "off", // Enable unused imports rule: "unused-imports/no-unused-imports": "error", // (Optional) If you want to also flag unused variables (excluding imports) // you can use the plugin’s no-unused-vars rule: // "unused-imports/no-unused-vars": [ // "warn", // { vars: "all", varsIgnorePattern: "^_", args: "after-used", argsIgnorePattern: "^_" } // ], "import/order": [ "warn", { groups: [ "type", "builtin", "object", "external", "internal", "parent", "sibling", "index", ], pathGroups: [ { pattern: "~/**", group: "external", position: "after", }, ], "newlines-between": "always", }, ], "react/self-closing-comp": "warn", "react/jsx-sort-props": [ "warn", { callbacksLast: true, shorthandFirst: true, noSortAlphabetically: false, reservedFirst: true, }, ], "padding-line-between-statements": [ "warn", { blankLine: "always", prev: "*", next: "return", }, { blankLine: "always", prev: ["const", "let", "var"], next: "*", }, { blankLine: "any", prev: ["const", "let", "var"], next: ["const", "let", "var"], }, ], "react/no-unknown-property": "warn", }, }, ]);