Repository navigation
Expand file tree
/
Copy patheslint.config.js
More file actions
226 lines (216 loc) · 6.61 KB
/
Copy patheslint.config.js
File metadata and controls
226 lines (216 loc) · 6.61 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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
import js from "@eslint/js";
import { defineConfig, globalIgnores } from "eslint/config";
import typescript from "@typescript-eslint/eslint-plugin";
import typescriptParser from "@typescript-eslint/parser";
import reactHooks from "eslint-plugin-react-hooks";
import reactRefresh from "eslint-plugin-react-refresh";
import react from "eslint-plugin-react";
import jsxA11y from "eslint-plugin-jsx-a11y";
import importX from "eslint-plugin-import-x";
import vitest from "@vitest/eslint-plugin";
import testingLibrary from "eslint-plugin-testing-library";
import prettier from "eslint-config-prettier";
import globals from "globals";
export default defineConfig(
// Global ignores
globalIgnores([
"dist/**",
"dist-core/**",
"node_modules/**",
"coverage/**",
"android/**",
"ios/**",
".claude/worktrees/**",
"*.config.{js,ts}",
"vite.config.ts",
"vitest.config.ts",
"postcss.config.js",
"src/routeTree.gen.ts", // Generated by TanStack Router
]),
// Base configs
js.configs.recommended,
// Main source files
{
files: ["src/**/*.{ts,tsx}"],
ignores: [
"src/__tests__/**",
"src/__mocks__/**",
"src/test-setup.ts",
"src/test-utils/**",
],
languageOptions: {
parser: typescriptParser,
ecmaVersion: 2022,
sourceType: "module",
globals: {
...globals.browser,
...globals.es2022,
// Build-time constant from vite.config.ts
__APP_BASE_PATH__: "readonly",
},
parserOptions: {
ecmaFeatures: {
jsx: true,
},
},
},
plugins: {
"@typescript-eslint": typescript,
react: react,
"react-hooks": reactHooks,
"react-refresh": reactRefresh,
"jsx-a11y": jsxA11y,
"import-x": importX,
},
rules: {
// TypeScript rules
...typescript.configs.recommended.rules,
"@typescript-eslint/no-unused-vars": "error",
"@typescript-eslint/no-explicit-any": "warn",
"prefer-const": "error",
// React rules
...react.configs.recommended.rules,
"react/react-in-jsx-scope": "off",
"react/jsx-uses-react": "off",
// React Hooks
...reactHooks.configs.recommended.rules,
// React Refresh
"react-refresh/only-export-components": [
"warn",
{
allowConstantExport: true,
// TanStack Router file-based routes export `Route = createFileRoute(...)`
// alongside their component; that pairing is the framework's canonical pattern.
// The component must also be exported (not just declared locally) so the
// rule still sees a React export — otherwise the local component would
// trigger a "move to separate file" warning.
allowExportNames: ["Route"],
},
],
// Accessibility rules
...jsxA11y.configs.recommended.rules,
// Import rules
"import-x/no-unresolved": "error",
"no-restricted-imports": [
"error",
{
patterns: [
{
group: ["../**/lib/*", "../**/hooks/*", "../**/components/*"],
message: "Use @/ alias instead of relative parent imports.",
},
],
},
],
"import-x/order": [
"warn",
{
groups: [
"builtin",
"external",
"internal",
"parent",
"sibling",
"index",
],
"newlines-between": "never",
},
],
},
settings: {
react: { version: "detect" },
"import-x/resolver": {
typescript: {
alwaysTryTypes: true,
project: "./tsconfig.json",
},
},
},
},
// Test files - with vitest and testing-library plugins, relaxed rules
{
files: [
"src/__tests__/**/*.{ts,tsx}",
"src/test-utils/**/*.{ts,tsx}",
"src/test-setup.ts",
],
languageOptions: {
parser: typescriptParser,
ecmaVersion: 2022,
sourceType: "module",
globals: {
...globals.browser,
...globals.es2022,
...globals.node,
// Vitest globals
describe: "readonly",
it: "readonly",
expect: "readonly",
vi: "readonly",
beforeEach: "readonly",
afterEach: "readonly",
beforeAll: "readonly",
afterAll: "readonly",
test: "readonly",
// React and DOM types for test files
React: "readonly",
EventListener: "readonly",
},
parserOptions: {
ecmaFeatures: {
jsx: true,
},
},
},
plugins: {
"@typescript-eslint": typescript,
react: react,
vitest: vitest,
"testing-library": testingLibrary,
},
settings: {
react: { version: "detect" },
},
rules: {
...typescript.configs.recommended.rules,
...react.configs.recommended.rules,
"react/react-in-jsx-scope": "off",
"react/jsx-uses-react": "off",
// Preserve the established test lint baseline when the maintained plugin adds rules.
"vitest/expect-expect": "error",
"vitest/no-identical-title": "error",
"vitest/no-commented-out-tests": "error",
"vitest/valid-title": "error",
"vitest/valid-expect": "error",
"vitest/valid-describe-callback": "error",
"vitest/require-local-test-context-for-concurrent-snapshots": "error",
"vitest/no-import-node-test": "error",
...testingLibrary.configs.react.rules,
// Relaxed rules for tests
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/no-require-imports": "off",
"@typescript-eslint/no-unused-vars": [
"error",
{ argsIgnorePattern: "^_" },
],
// Allow manual cleanup in test setup
"testing-library/no-manual-cleanup": "off",
// Container access is sometimes necessary for testing
"testing-library/no-node-access": "off",
"testing-library/no-container": "off",
// Allow act wrapping when needed for complex async operations
"testing-library/no-unnecessary-act": "warn",
// Allow destructuring queries when convenient
"testing-library/prefer-screen-queries": "warn",
// Allow await on sync events (often more readable)
"testing-library/no-await-sync-events": "off",
// Allow multiple assertions in waitFor when testing related state
"testing-library/no-wait-for-multiple-assertions": "warn",
// Escape rules are too strict for test strings
"react/no-unescaped-entities": "off",
},
},
// Prettier must be last to disable conflicting rules
prettier,
);