|
| 1 | +// @ts-check |
| 2 | +import tseslint from "typescript-eslint" |
| 3 | +import { FlatCompat } from "@eslint/eslintrc" |
| 4 | +import eslintPluginJsxA11y from "eslint-plugin-jsx-a11y" |
| 5 | +import eslintPluginReact from "eslint-plugin-react" |
| 6 | + |
| 7 | +const compat = new FlatCompat({ |
| 8 | + baseDirectory: import.meta.dirname, |
| 9 | +}) |
| 10 | + |
| 11 | +export default tseslint.config( |
| 12 | + tseslint.configs.recommendedTypeChecked, |
| 13 | + |
| 14 | + ...compat.config({ |
| 15 | + extends: ["next"], |
| 16 | + rules: { |
| 17 | + // react |
| 18 | + "react/prop-types": "off", |
| 19 | + "react/no-unescaped-entities": "off", |
| 20 | + "react/jsx-curly-brace-presence": "warn", |
| 21 | + |
| 22 | + // jsx-ally is already included in next-js so |
| 23 | + // we are adding only recommended rules directly here |
| 24 | + ...eslintPluginJsxA11y.flatConfigs.recommended.rules, |
| 25 | + "jsx-a11y/no-onchange": "warn", |
| 26 | + |
| 27 | + // import |
| 28 | + "import/no-anonymous-default-export": "off", |
| 29 | + |
| 30 | + // next |
| 31 | + "@next/next/no-img-element": "off", |
| 32 | + }, |
| 33 | + }), |
| 34 | + |
| 35 | + // @ts-expect-error eslintPluginReact.configs.flat, but runtime is always defined |
| 36 | + eslintPluginReact.configs.flat["jsx-runtime"], |
| 37 | + |
| 38 | + { |
| 39 | + linterOptions: { |
| 40 | + reportUnusedDisableDirectives: "error", |
| 41 | + }, |
| 42 | + languageOptions: { |
| 43 | + parserOptions: { |
| 44 | + projectService: true, |
| 45 | + tsconfigRootDir: import.meta.dirname, |
| 46 | + }, |
| 47 | + }, |
| 48 | + rules: { |
| 49 | + // typescript |
| 50 | + "@typescript-eslint/explicit-function-return-type": "off", |
| 51 | + "@typescript-eslint/explicit-module-boundary-types": "off", |
| 52 | + "@typescript-eslint/interface-name-prefix": "off", |
| 53 | + "@typescript-eslint/no-floating-promises": "off", |
| 54 | + "@typescript-eslint/restrict-template-expressions": [ |
| 55 | + "error", |
| 56 | + { |
| 57 | + allowAny: false, |
| 58 | + allowBoolean: false, |
| 59 | + allowNever: false, |
| 60 | + allowNullish: false, |
| 61 | + allowNumber: true, |
| 62 | + allowRegExp: false, |
| 63 | + }, |
| 64 | + ], |
| 65 | + }, |
| 66 | + } |
| 67 | +) |
0 commit comments