-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheslint.config.mjs
More file actions
118 lines (110 loc) · 3.56 KB
/
Copy patheslint.config.mjs
File metadata and controls
118 lines (110 loc) · 3.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
import next from "eslint-config-next";
import prettier from "eslint-config-prettier";
import simpleImportSort from "eslint-plugin-simple-import-sort";
import unusedImports from "eslint-plugin-unused-imports";
export default [
// Project-wide ignores (extend Next's defaults).
{
ignores: [
".next/**",
"out/**",
"build/**",
"node_modules/**",
"drizzle/**",
"data/**",
"next-env.d.ts",
"*.config.{js,mjs,cjs}",
],
},
// Next.js base + TypeScript rules + React + a11y + import resolver settings.
...next,
{
files: ["**/*.{ts,tsx,js,jsx,mjs,cjs}"],
plugins: {
"simple-import-sort": simpleImportSort,
"unused-imports": unusedImports,
},
rules: {
// --- Code quality ---
"no-nested-ternary": "error",
complexity: ["warn", 8],
"max-depth": ["warn", 3],
"no-var": "error",
"prefer-const": "error",
"no-console": ["warn", { allow: ["warn", "error"] }],
eqeqeq: "error",
curly: "error",
"object-shorthand": "error",
"prefer-template": "error",
"no-useless-return": "warn",
"no-unneeded-ternary": "error",
"no-else-return": "warn",
// --- TypeScript ---
"@typescript-eslint/no-explicit-any": "warn",
"@typescript-eslint/consistent-type-imports": "error",
// The unused-imports plugin owns this so its --fix can drop them.
"@typescript-eslint/no-unused-vars": "off",
"no-unused-vars": "off",
"unused-imports/no-unused-imports": "error",
"unused-imports/no-unused-vars": [
"warn",
{
args: "after-used",
argsIgnorePattern: "^_",
vars: "all",
varsIgnorePattern: "^_",
caughtErrorsIgnorePattern: "^_",
},
],
// --- React ---
"react/jsx-no-useless-fragment": "warn",
// --- Imports ---
"import/first": "error",
"import/newline-after-import": "error",
// Smarter than `no-duplicate-imports`: understands `import type`.
"import/no-duplicates": "error",
"simple-import-sort/exports": "error",
"simple-import-sort/imports": [
"error",
{
// Group regexes use `(/|\u0000|$)` instead of `$` so they match both
// value imports (`import x from "react"`) and type-only imports
// (which simple-import-sort tags with a trailing `\u0000`).
groups: [
// 1. Side-effect imports (e.g. `import "server-only"`).
["^\\u0000"],
// 2. React.
["^react(/|\\u0000|$)"],
// 3. Next.js.
["^next(/|\\u0000|$)"],
// 4. Other external libraries.
["^@?\\w"],
// 5. Internal lib / utils / services / hooks / configs / constants / types.
["^@/(lib|utils|services|hooks|configs?|constants|types)(/|\\u0000|$)"],
// 6. Feature/domain imports.
["^@/features(/|\\u0000|$)"],
// 7. UI components.
["^@/components(/|\\u0000|$)"],
// 8. Other internal `@/` imports.
["^@/"],
// 9. Parent imports.
["^\\.\\."],
// 10. Sibling/index imports.
["^\\."],
// 11. Style imports.
["^.+\\.s?css(\\u0000|$)"],
],
},
],
},
},
// Test files: relax line-length / complexity caps.
{
files: ["**/*.{test,spec}.{ts,tsx}", "**/__tests__/**/*"],
rules: {
complexity: "off",
},
},
// Must come last: turn off any rule that conflicts with Prettier's formatting.
prettier,
];