-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheslint.config.js
More file actions
217 lines (209 loc) · 5.63 KB
/
eslint.config.js
File metadata and controls
217 lines (209 loc) · 5.63 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
import path from 'node:path'
import { fileURLToPath } from 'node:url'
import storybook from 'eslint-plugin-storybook'
import js from '@eslint/js'
import globals from 'globals'
import reactHooks from 'eslint-plugin-react-hooks'
import reactRefresh from 'eslint-plugin-react-refresh'
import tseslint from 'typescript-eslint'
import importPlugin from 'eslint-plugin-import'
import prettierConfig from 'eslint-config-prettier'
const __dirname = path.dirname(fileURLToPath(import.meta.url))
export default tseslint.config(
{
ignores: [
'dist',
'node_modules',
'.storybook',
'storybook-static',
'test-*',
'build',
'coverage',
'playwright-report',
'test-results',
'*.config.js',
'*.config.ts',
'public',
],
},
{
files: ['**/*.{ts,tsx}'],
extends: [
js.configs.recommended,
...tseslint.configs.recommended,
prettierConfig,
],
languageOptions: {
ecmaVersion: 2022,
globals: {
...globals.browser,
...globals.es2022,
},
parserOptions: {
tsconfigRootDir: __dirname,
},
},
plugins: {
'react-hooks': reactHooks,
'react-refresh': reactRefresh,
import: importPlugin,
},
settings: {
'import/resolver': {
typescript: {
project: './tsconfig.app.json',
},
node: true,
},
},
rules: {
// React rules
...reactHooks.configs.recommended.rules,
'react-refresh/only-export-components': [
'warn',
{ allowConstantExport: true },
],
// Import order
'import/order': [
'error',
{
groups: [
'builtin',
'external',
'internal',
['parent', 'sibling'],
'index',
'type',
],
pathGroups: [
{ pattern: 'react', group: 'builtin', position: 'before' },
{ pattern: '@/**', group: 'internal', position: 'before' },
],
pathGroupsExcludedImportTypes: ['react'],
'newlines-between': 'always',
alphabetize: { order: 'asc', caseInsensitive: true },
},
],
// Import boundaries - No cross-feature imports
'no-restricted-imports': [
'error',
{
patterns: [
{
group: ['@/features/*/*'],
message:
'Do not import directly from feature internals. Use the feature barrel export (index.ts) instead.',
},
],
},
],
// TypeScript rules
'@typescript-eslint/no-unused-vars': [
'error',
{ argsIgnorePattern: '^_', varsIgnorePattern: '^_' },
],
'@typescript-eslint/consistent-type-imports': [
'error',
{ prefer: 'type-imports' },
],
// General rules
'no-console': ['warn', { allow: ['warn', 'error'] }],
},
}, // Feature-specific rules to prevent cross-feature imports
{
files: ['src/features/**/*.{ts,tsx}'],
rules: {
'no-restricted-imports': [
'error',
{
patterns: [
{
group: ['@/features/*/*'],
message:
'Features cannot import from other feature internals. Use core or shared instead.',
},
{
group: ['@/app/*'],
message: 'Features cannot import from app layer.',
},
],
},
],
},
}, // Core layer rules - no feature or app imports
{
files: ['src/core/**/*.{ts,tsx}'],
rules: {
'no-restricted-imports': [
'error',
{
patterns: [
{
group: ['@/features/*', '@/features/**'],
message: 'Core cannot import from features.',
},
{
group: ['@/app/*'],
message: 'Core cannot import from app layer.',
},
],
},
],
},
}, // Shared layer rules - no other layer imports
{
files: ['src/shared/**/*.{ts,tsx}'],
rules: {
'no-restricted-imports': [
'error',
{
patterns: [
{
group: ['@/features/*', '@/features/**'],
message: 'Shared cannot import from features.',
},
{
group: ['@/core/*', '@/core/**'],
message: 'Shared cannot import from core.',
},
{
group: ['@/app/*'],
message: 'Shared cannot import from app layer.',
},
],
},
],
},
},
// Disable react-refresh/only-export-components for context files and files that export both components and utilities
{
files: [
'src/**/context.tsx',
'src/**/*Context.tsx',
'src/core/ui/components/Toast.tsx',
'src/core/ui/components/Breadcrumbs.tsx',
],
rules: {
'react-refresh/only-export-components': 'off',
},
},
// Allow console methods in monitoring and performance utilities
{
files: ['src/core/monitoring/**/*.ts', 'src/core/performance/**/*.ts'],
rules: {
'no-console': 'off',
},
},
// Test utilities can export both components and helpers
{
files: [
'**/*.test.{ts,tsx}',
'**/test/**/*.{ts,tsx}',
'**/__tests__/**/*.{ts,tsx}',
],
rules: {
'react-refresh/only-export-components': 'off',
},
},
storybook.configs['flat/recommended']
)