-
Notifications
You must be signed in to change notification settings - Fork 51
Expand file tree
/
Copy patheslint.config.mjs
More file actions
419 lines (375 loc) · 13.8 KB
/
Copy patheslint.config.mjs
File metadata and controls
419 lines (375 loc) · 13.8 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
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
// @ts-check
/**
* ESLint Flat Config for Shep AI CLI
*
* This configuration uses ESLint 9+ flat config format with TypeScript support.
* It's designed to be scalable and maintainable for a large open source project.
*
* @see https://eslint.org/docs/latest/use/configure/configuration-files
* @see https://typescript-eslint.io/getting-started/
*/
import { dirname } from 'node:path';
import { fileURLToPath } from 'node:url';
import eslint from '@eslint/js';
import tseslint from 'typescript-eslint';
import prettierConfig from 'eslint-config-prettier';
import reactPlugin from 'eslint-plugin-react';
import reactHooksPlugin from 'eslint-plugin-react-hooks';
import nextPlugin from '@next/eslint-plugin-next';
import tailwindPlugin from 'eslint-plugin-tailwindcss';
import storybookPlugin from 'eslint-plugin-storybook';
const __dirname = dirname(fileURLToPath(import.meta.url));
export default tseslint.config(
// =============================================================================
// Global ignores (replaces .eslintignore)
// =============================================================================
{
ignores: [
// Build outputs
'dist/**',
'packages/*/dist/**',
'packages/*/release/**',
'packages/*/release-apps-only/**',
'packages/*/staged-*/**',
'build/**',
'web/**',
'**/.next/**',
'out/**',
'**/storybook-static/**',
// Dependencies
'node_modules/**',
// Git worktrees (parallel development checkouts)
'.worktrees/**',
// Generated files
'apis/**',
'*.generated.*',
'coverage/**',
'next-env.d.ts',
'src/domain/generated/**', // TypeSpec-generated domain models
'packages/core/src/domain/generated/**', // TypeSpec-generated domain models (core)
// Fat-template payload — raw assets shipped into user projects at
// scaffold time. These files import from the user's own
// `react` / `lucide-react` / `@/lib/utils` scope (not core's),
// so they're intentionally excluded from the core tsconfig and
// must also be skipped by eslint's project service.
'packages/core/src/infrastructure/templates/**',
// Spec artifacts (auto-generated YAML/MD, evidence PNGs)
'specs/**',
// Claude Code skills (third-party)
'.claude/skills/**',
// TypeSpec (handled by tsp linter)
'tsp/**',
// Test outputs
'test-results/**',
'playwright-report/**',
// POC TypeScript files (not part of main tsconfig)
'docs/poc/**/*.ts',
// Config files that don't need linting
'*.config.js',
'*.config.mjs',
'*.config.cjs',
'*.config.ts',
],
},
// =============================================================================
// Base ESLint recommended rules
// =============================================================================
eslint.configs.recommended,
// =============================================================================
// TypeScript recommended rules
// =============================================================================
...tseslint.configs.recommended,
...tseslint.configs.stylistic,
// =============================================================================
// Project-specific TypeScript rules
// =============================================================================
{
files: ['**/*.ts', '**/*.tsx', '**/*.mts', '**/*.cts'],
languageOptions: {
parserOptions: {
projectService: true,
tsconfigRootDir: import.meta.dirname,
},
},
rules: {
// -------------------------------------------------------------------------
// TypeScript-specific rules
// -------------------------------------------------------------------------
// Prefer type-only imports for types (tree-shaking friendly)
'@typescript-eslint/consistent-type-imports': [
'warn',
{
prefer: 'type-imports',
fixStyle: 'inline-type-imports',
},
],
// Require explicit return types on public methods
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
// Allow unused vars with underscore prefix
'@typescript-eslint/no-unused-vars': [
'warn',
{
argsIgnorePattern: '^_',
varsIgnorePattern: '^_',
caughtErrorsIgnorePattern: '^_',
},
],
// Prefer nullish coalescing
'@typescript-eslint/prefer-nullish-coalescing': 'warn',
// Prefer optional chaining
'@typescript-eslint/prefer-optional-chain': 'warn',
// No floating promises (must handle or void)
'@typescript-eslint/no-floating-promises': 'off', // Enable when typed linting is set up
// No misused promises
'@typescript-eslint/no-misused-promises': 'off', // Enable when typed linting is set up
// -------------------------------------------------------------------------
// General code quality rules
// -------------------------------------------------------------------------
// Enforce consistent brace style
curly: ['warn', 'all'],
// Require === and !==
eqeqeq: ['error', 'always', { null: 'ignore' }],
// No console in production code (warn for now)
'no-console': 'warn',
// No debugger statements
'no-debugger': 'error',
// Prefer const over let when variable is not reassigned
'prefer-const': 'warn',
// Prefer template literals over string concatenation
'prefer-template': 'warn',
// No var, use let or const
'no-var': 'error',
},
},
// =============================================================================
// JavaScript files (no TypeScript rules)
// =============================================================================
{
files: ['**/*.js', '**/*.mjs', '**/*.cjs'],
...tseslint.configs.disableTypeChecked,
},
// =============================================================================
// CLI presentation layer - allow console statements (intentional user output)
// =============================================================================
{
files: ['src/presentation/cli/**/*.ts'],
rules: {
'no-console': 'off',
},
},
// =============================================================================
// POC/Demo files - browser environment, relaxed rules
// =============================================================================
{
files: ['docs/poc/**/*.js'],
languageOptions: {
globals: {
// Browser globals
window: 'readonly',
document: 'readonly',
console: 'readonly',
localStorage: 'readonly',
navigator: 'readonly',
setInterval: 'readonly',
clearInterval: 'readonly',
setTimeout: 'readonly',
clearTimeout: 'readonly',
},
},
rules: {
'no-console': 'off',
'@typescript-eslint/no-unused-vars': 'off',
'no-undef': 'off',
},
},
// =============================================================================
// Test files - relaxed rules
// =============================================================================
{
files: ['**/*.test.ts', '**/*.spec.ts', '**/tests/**/*.ts'],
rules: {
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'no-console': 'off',
},
},
// =============================================================================
// Dev tooling scripts - console output is their user interface
// =============================================================================
{
files: ['scripts/**/*.ts'],
rules: {
'no-console': 'off',
},
},
// =============================================================================
// React/Next.js configuration for web presentation layer
// =============================================================================
{
files: ['src/presentation/web/**/*.tsx', 'src/presentation/web/**/*.ts'],
plugins: {
react: reactPlugin,
'react-hooks': reactHooksPlugin,
'@next/next': nextPlugin,
tailwindcss: tailwindPlugin,
},
languageOptions: {
parserOptions: {
ecmaFeatures: {
jsx: true,
},
},
},
settings: {
react: {
version: 'detect',
},
tailwindcss: {
config: `${__dirname}/src/presentation/web/app/globals.css`,
},
},
rules: {
// React rules
'react/jsx-uses-react': 'off', // Not needed with React 19 JSX transform
'react/react-in-jsx-scope': 'off', // Not needed with React 19 JSX transform
'react/prop-types': 'off', // Using TypeScript for prop types
'react/jsx-no-target-blank': 'error',
'react/jsx-key': 'error',
'react/no-array-index-key': 'warn',
'react/self-closing-comp': 'warn',
'react/jsx-no-useless-fragment': 'warn',
'react/jsx-curly-brace-presence': ['warn', { props: 'never', children: 'never' }],
'react/hook-use-state': 'warn',
'react/jsx-no-leaked-render': 'warn',
'react/no-unstable-nested-components': 'error',
// React Hooks rules
'react-hooks/rules-of-hooks': 'error',
'react-hooks/exhaustive-deps': 'warn',
// Next.js rules
'@next/next/no-html-link-for-pages': ['error', 'src/presentation/web/app'],
'@next/next/no-img-element': 'warn',
'@next/next/no-sync-scripts': 'error',
// Tailwind CSS rules
// Class sorting is handled by prettier-plugin-tailwindcss
'tailwindcss/classnames-order': 'off',
'tailwindcss/no-contradicting-classname': 'error',
'tailwindcss/no-unnecessary-arbitrary-value': 'warn',
'tailwindcss/enforces-shorthand': 'warn',
},
},
// =============================================================================
// Storybook story files
// =============================================================================
{
files: ['**/*.stories.@(ts|tsx)'],
plugins: {
storybook: storybookPlugin,
},
rules: {
'storybook/default-exports': 'error',
'storybook/hierarchy-separator': 'error',
'storybook/no-uninstalled-addons': 'error',
'storybook/prefer-pascal-case': 'warn',
},
},
// =============================================================================
// Clean Architecture — application layer must not import infrastructure
// =============================================================================
{
files: ['packages/core/src/application/**/*.ts'],
rules: {
'no-restricted-imports': [
'error',
{
patterns: [
{
group: ['**/infrastructure/**', '**/infrastructure/*'],
message:
'Application layer must not import from infrastructure. Use a port interface in application/ports/ and inject via DI.',
},
],
},
],
},
},
// =============================================================================
// Interactive service subfolder layering
//
// Dependency direction: core/ ← lifecycle/ ← runtime/ ← api/ ← facade
// Inner layers must NOT import from outer layers.
// =============================================================================
{
files: ['packages/core/src/infrastructure/services/interactive/core/**/*.ts'],
rules: {
'no-restricted-imports': [
'error',
{
patterns: [
{
group: [
'**/services/interactive/lifecycle/**',
'**/services/interactive/lifecycle/*',
],
message:
'core/ must not import from lifecycle/. Dependency direction: core ← lifecycle ← runtime ← api.',
},
{
group: ['**/services/interactive/runtime/**', '**/services/interactive/runtime/*'],
message:
'core/ must not import from runtime/. Dependency direction: core ← lifecycle ← runtime ← api.',
},
{
group: ['**/services/interactive/api/**', '**/services/interactive/api/*'],
message:
'core/ must not import from api/. Dependency direction: core ← lifecycle ← runtime ← api.',
},
],
},
],
},
},
{
files: ['packages/core/src/infrastructure/services/interactive/lifecycle/**/*.ts'],
rules: {
'no-restricted-imports': [
'error',
{
patterns: [
{
group: ['**/services/interactive/runtime/**', '**/services/interactive/runtime/*'],
message:
'lifecycle/ must not import from runtime/. Dependency direction: core ← lifecycle ← runtime ← api.',
},
{
group: ['**/services/interactive/api/**', '**/services/interactive/api/*'],
message:
'lifecycle/ must not import from api/. Dependency direction: core ← lifecycle ← runtime ← api.',
},
],
},
],
},
},
{
files: ['packages/core/src/infrastructure/services/interactive/runtime/**/*.ts'],
rules: {
'no-restricted-imports': [
'error',
{
patterns: [
{
group: ['**/services/interactive/api/**', '**/services/interactive/api/*'],
message:
'runtime/ must not import from api/. Dependency direction: core ← lifecycle ← runtime ← api.',
},
],
},
],
},
},
// =============================================================================
// Prettier compatibility (must be last)
// =============================================================================
prettierConfig
);