-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheslint.config.js
More file actions
249 lines (239 loc) · 7.35 KB
/
Copy patheslint.config.js
File metadata and controls
249 lines (239 loc) · 7.35 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
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
// @ts-check
const tseslint = require('@typescript-eslint/eslint-plugin');
const tsParser = require('@typescript-eslint/parser');
const importPlugin = require('eslint-plugin-import');
const reactHooksPlugin = require('eslint-plugin-react-hooks');
// ---------------------------------------------------------------------------
// Shared pattern groups for component-tier boundary rules
// Docs: docs/conventions/component-decomposition.md
// Import direction: screens → features → domain → UI (one-way only)
// ---------------------------------------------------------------------------
const STORE_QUERY_BOUNDARY = [
{
group: [
'@/domains/*/use-*-store',
'@/domains/*/use-*-store.*',
'**/domains/*/use-*-store',
'**/domains/*/use-*-store.*',
],
message: 'Store hooks belong in screens (or screen hooks). Pass resolved data as props.',
},
{
group: ['@tanstack/react-query', '@tanstack/react-query/*'],
message: 'React Query belongs in screens (or screen hooks). Pass resolved data as props.',
},
{
group: [
'@/lib/api',
'@/lib/api/*',
'@/lib/api/**',
'**/lib/api',
'**/lib/api/*',
'**/lib/api/**',
],
message: 'API calls belong in screens (or screen hooks). Pass resolved data as props.',
},
];
/** @type {import('eslint').Linter.Config[]} */
module.exports = [
// Global ignores
{
ignores: [
'node_modules/**',
'.expo/**',
'dist/**',
'build/**',
'coverage/**',
'src/lib/api/endpoints/**',
'src/lib/api/model/**',
'babel.config.js',
'eslint.config.js',
'metro.config.js',
],
},
// TypeScript files
{
files: ['**/*.ts', '**/*.tsx'],
languageOptions: {
parser: tsParser,
parserOptions: {
ecmaVersion: 2022,
sourceType: 'module',
ecmaFeatures: { jsx: true },
},
globals: {
process: 'readonly',
console: 'readonly',
require: 'readonly',
module: 'readonly',
__dirname: 'readonly',
},
},
plugins: {
'@typescript-eslint': tseslint,
import: importPlugin,
'react-hooks': reactHooksPlugin,
},
rules: {
// TypeScript rules
'@typescript-eslint/no-explicit-any': 'error',
'@typescript-eslint/no-non-null-assertion': 'error',
'@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
'@typescript-eslint/consistent-type-imports': ['error', { prefer: 'type-imports' }],
// Console
'no-console': ['warn', { allow: ['info', 'warn', 'error'] }],
// Import ordering: builtin → external → internal → type
'import/order': [
'error',
{
groups: ['builtin', 'external', 'internal', 'parent', 'sibling', 'index', 'type'],
pathGroups: [
{
pattern: '@/**',
group: 'internal',
position: 'before',
},
],
pathGroupsExcludedImportTypes: ['type'],
'newlines-between': 'always',
alphabetize: {
order: 'asc',
caseInsensitive: true,
},
},
],
// React Hooks
'react-hooks/rules-of-hooks': 'error',
'react-hooks/exhaustive-deps': 'warn',
},
},
// ---------------------------------------------------------------------------
// Component-tier boundary: store/query forbidden in ALL components
// ---------------------------------------------------------------------------
{
files: ['src/components/**/*.ts', 'src/components/**/*.tsx'],
rules: {
'no-restricted-imports': [
'error',
{ patterns: [...STORE_QUERY_BOUNDARY] },
],
},
},
// ---------------------------------------------------------------------------
// UI layer — cannot import domain, features, or screens
// (overrides the general components rule above for ui/ files)
// ---------------------------------------------------------------------------
{
files: ['src/components/ui/**/*.ts', 'src/components/ui/**/*.tsx'],
rules: {
'no-restricted-imports': [
'error',
{
patterns: [
{
group: [
'@/components/domain',
'@/components/domain/*',
'@/components/domain/**',
'**/components/domain',
'**/components/domain/*',
'**/components/domain/**',
],
message: 'UI layer cannot import from domain layer.',
},
{
group: [
'@/components/features',
'@/components/features/*',
'@/components/features/**',
'**/components/features',
'**/components/features/*',
'**/components/features/**',
],
message: 'UI layer cannot import from features layer.',
},
{
group: [
'@/screens',
'@/screens/*',
'@/screens/**',
'**/screens',
'**/screens/*',
'**/screens/**',
],
message: 'UI layer cannot import from screens.',
},
...STORE_QUERY_BOUNDARY,
],
},
],
},
},
// ---------------------------------------------------------------------------
// Domain layer — cannot import features or screens
// ---------------------------------------------------------------------------
{
files: ['src/components/domain/**/*.ts', 'src/components/domain/**/*.tsx'],
rules: {
'no-restricted-imports': [
'error',
{
patterns: [
{
group: [
'@/components/features',
'@/components/features/*',
'@/components/features/**',
'**/components/features',
'**/components/features/*',
'**/components/features/**',
],
message: 'Domain layer cannot import from features layer.',
},
{
group: [
'@/screens',
'@/screens/*',
'@/screens/**',
'**/screens',
'**/screens/*',
'**/screens/**',
],
message: 'Domain layer cannot import from screens.',
},
...STORE_QUERY_BOUNDARY,
],
},
],
},
},
// ---------------------------------------------------------------------------
// Features layer — cannot import screens
// Cross-feature imports (features/A → features/B) will be enforced
// per-feature as features are populated.
// ---------------------------------------------------------------------------
{
files: ['src/components/features/**/*.ts', 'src/components/features/**/*.tsx'],
rules: {
'no-restricted-imports': [
'error',
{
patterns: [
{
group: [
'@/screens',
'@/screens/*',
'@/screens/**',
'**/screens',
'**/screens/*',
'**/screens/**',
],
message: 'Features layer cannot import from screens.',
},
...STORE_QUERY_BOUNDARY,
],
},
],
},
},
];