|
1 | 1 | import { defineConfig, globalIgnores } from "eslint/config"; |
2 | 2 | import nextVitals from "eslint-config-next/core-web-vitals"; |
3 | 3 | import nextTs from "eslint-config-next/typescript"; |
| 4 | +import importPlugin from "eslint-plugin-import"; |
4 | 5 |
|
5 | 6 | const eslintConfig = defineConfig([ |
6 | 7 | ...nextVitals, |
7 | 8 | ...nextTs, |
8 | | - // Override default ignores of eslint-config-next. |
| 9 | + { |
| 10 | + linterOptions: { |
| 11 | + reportUnusedDisableDirectives: "error", |
| 12 | + }, |
| 13 | + }, |
| 14 | + { |
| 15 | + files: ["src/**/*.{ts,tsx,mts}", "supabase/functions/**/*.ts"], |
| 16 | + plugins: { |
| 17 | + import: importPlugin, |
| 18 | + }, |
| 19 | + rules: { |
| 20 | + "@typescript-eslint/consistent-type-imports": [ |
| 21 | + "error", |
| 22 | + { |
| 23 | + prefer: "type-imports", |
| 24 | + fixStyle: "separate-type-imports", |
| 25 | + disallowTypeAnnotations: false, |
| 26 | + }, |
| 27 | + ], |
| 28 | + "@typescript-eslint/no-unused-vars": [ |
| 29 | + "error", |
| 30 | + { |
| 31 | + argsIgnorePattern: "^_", |
| 32 | + varsIgnorePattern: "^_", |
| 33 | + caughtErrorsIgnorePattern: "^_", |
| 34 | + }, |
| 35 | + ], |
| 36 | + curly: ["error", "all"], |
| 37 | + eqeqeq: ["error", "always"], |
| 38 | + "import/first": "error", |
| 39 | + "import/no-duplicates": "error", |
| 40 | + "no-console": ["error", { allow: ["warn", "error"] }], |
| 41 | + "no-else-return": "error", |
| 42 | + "no-nested-ternary": "error", |
| 43 | + "no-unneeded-ternary": "error", |
| 44 | + "prefer-template": "error", |
| 45 | + }, |
| 46 | + }, |
| 47 | + { |
| 48 | + files: ["src/**/*.{ts,tsx,mts}"], |
| 49 | + ignores: ["src/**/*.test.ts", "src/content/**"], |
| 50 | + rules: { |
| 51 | + "no-restricted-imports": [ |
| 52 | + "error", |
| 53 | + { |
| 54 | + patterns: [ |
| 55 | + { |
| 56 | + group: ["../../../*", "../../../../*", "../../../../../*"], |
| 57 | + message: |
| 58 | + "Prefer @/ aliases or feature-local imports over deep parent-relative paths.", |
| 59 | + }, |
| 60 | + ], |
| 61 | + }, |
| 62 | + ], |
| 63 | + }, |
| 64 | + }, |
| 65 | + { |
| 66 | + files: ["src/**/*.{ts,tsx,mts}", "supabase/functions/**/*.ts"], |
| 67 | + rules: { |
| 68 | + "import/order": [ |
| 69 | + "error", |
| 70 | + { |
| 71 | + groups: [ |
| 72 | + "builtin", |
| 73 | + "external", |
| 74 | + "internal", |
| 75 | + ["parent", "sibling", "index"], |
| 76 | + "type", |
| 77 | + ], |
| 78 | + "newlines-between": "always", |
| 79 | + alphabetize: { |
| 80 | + order: "asc", |
| 81 | + caseInsensitive: true, |
| 82 | + }, |
| 83 | + pathGroups: [ |
| 84 | + { |
| 85 | + pattern: "@/**", |
| 86 | + group: "internal", |
| 87 | + position: "before", |
| 88 | + }, |
| 89 | + ], |
| 90 | + pathGroupsExcludedImportTypes: ["builtin"], |
| 91 | + }, |
| 92 | + ], |
| 93 | + }, |
| 94 | + }, |
| 95 | + { |
| 96 | + files: ["src/actions/**/*.{ts,tsx,mts}"], |
| 97 | + ignores: ["src/**/*.test.ts", "src/**/*.test-helpers.ts"], |
| 98 | + rules: { |
| 99 | + "@typescript-eslint/explicit-module-boundary-types": [ |
| 100 | + "warn", |
| 101 | + { |
| 102 | + allowArgumentsExplicitlyTypedAsAny: true, |
| 103 | + }, |
| 104 | + ], |
| 105 | + }, |
| 106 | + }, |
| 107 | + { |
| 108 | + files: [ |
| 109 | + "src/actions/**/*.{ts,tsx,mts}", |
| 110 | + "src/lib/**/*.{ts,tsx,mts}", |
| 111 | + "supabase/functions/**/*.ts", |
| 112 | + ], |
| 113 | + ignores: ["src/**/*.test.ts", "src/**/*.test-helpers.ts"], |
| 114 | + rules: { |
| 115 | + complexity: ["warn", 10], |
| 116 | + "max-depth": ["warn", 3], |
| 117 | + "max-lines-per-function": [ |
| 118 | + "warn", |
| 119 | + { |
| 120 | + max: 80, |
| 121 | + skipBlankLines: true, |
| 122 | + skipComments: true, |
| 123 | + }, |
| 124 | + ], |
| 125 | + "max-nested-callbacks": ["warn", 2], |
| 126 | + }, |
| 127 | + }, |
| 128 | + /** |
| 129 | + * Preserve Next's default generated-file ignores and extend them with the |
| 130 | + * artifacts created by test and coverage tooling. |
| 131 | + */ |
9 | 132 | globalIgnores([ |
10 | | - // Default ignores of eslint-config-next: |
11 | 133 | ".next/**", |
12 | 134 | "out/**", |
13 | 135 | "build/**", |
14 | 136 | "next-env.d.ts", |
15 | | - // Generated test artifacts: |
16 | 137 | "playwright-report/**", |
17 | 138 | "test-results/**", |
18 | 139 | "coverage/**", |
|
0 commit comments