-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Expand file tree
/
Copy patheslint.config.mjs
More file actions
155 lines (145 loc) · 5.77 KB
/
Copy patheslint.config.mjs
File metadata and controls
155 lines (145 loc) · 5.77 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
import eslint from '@eslint/js';
import tseslint from 'typescript-eslint';
import prettierConfig from 'eslint-config-prettier';
export default tseslint.config(
// Global ignores (applied to all configs)
{
ignores: [
'node_modules/**',
'packages/*/node_modules/**',
'packages/*/dist/**',
'dist/**',
'coverage/**',
'.agents/examples/**',
'packages/docs-web/**',
'workspace/**',
'worktrees/**',
'.claude/worktrees/**',
'.claude/skills/**',
'.archon/**', // User workflow/script/command content — not in any tsconfig project
'**/*.generated.ts', // Auto-generated source files (content inlined via JSON.stringify)
'**/*.js',
'*.mjs',
'**/*.test.ts',
'**/src/test/**', // Test helper files (mock factories, fixtures)
'*.d.ts', // Root-level declaration files (not in tsconfig project scope)
'**/*.generated.d.ts', // Auto-generated declaration files (e.g. openapi-typescript output)
'packages/web/vite.config.ts', // Vite config doesn't need type-checked linting
'packages/web/components.json',
'packages/web/src/components/ui/**', // shadcn/ui auto-generated components
'packages/web/src/lib/utils.ts', // shadcn/ui utility file
],
},
// Base configs
eslint.configs.recommended,
...tseslint.configs.recommendedTypeChecked,
...tseslint.configs.strictTypeChecked,
...tseslint.configs.stylisticTypeChecked,
// Prettier integration
prettierConfig,
// Project-specific settings
{
files: ['packages/*/src/**/*.{ts,tsx}', 'scripts/**/*.ts'],
languageOptions: {
parserOptions: {
projectService: true,
tsconfigRootDir: import.meta.dirname,
},
},
rules: {
// === ENFORCED RULES (errors) ===
'@typescript-eslint/explicit-function-return-type': 'error',
'@typescript-eslint/no-explicit-any': 'error',
'@typescript-eslint/no-unused-vars': [
'error',
{
argsIgnorePattern: '^_',
varsIgnorePattern: '^_',
caughtErrorsIgnorePattern: '^_',
},
],
quotes: ['error', 'single', { avoidEscape: true }],
semi: ['error', 'always'],
'@typescript-eslint/naming-convention': [
'error',
{
selector: 'interface',
format: ['PascalCase'],
custom: { regex: '^I?[A-Z]', match: true },
},
{ selector: 'typeAlias', format: ['PascalCase'] },
{ selector: 'function', format: ['camelCase', 'PascalCase'] },
{ selector: 'variable', format: ['camelCase', 'UPPER_CASE'] },
],
'@typescript-eslint/no-non-null-assertion': 'error',
// === DISABLED RULES ===
// --- Template/expression rules ---
// Numbers/booleans in template literals are valid JS (auto-converted to string)
'@typescript-eslint/restrict-template-expressions': 'off',
// Mixed operands in + are often intentional (string concatenation)
'@typescript-eslint/restrict-plus-operands': 'off',
// --- Defensive coding patterns ---
// Switch defaults, null checks, and defensive guards are valuable
'@typescript-eslint/no-unnecessary-condition': 'off',
// Env var checks need || for truthy evaluation (empty string = missing)
'@typescript-eslint/prefer-nullish-coalescing': 'off',
// --- External SDK interop (types are often `any` or incomplete) ---
'@typescript-eslint/no-unsafe-assignment': 'off',
'@typescript-eslint/no-unsafe-member-access': 'off',
'@typescript-eslint/no-unsafe-argument': 'off',
// Event handler patterns in SDKs often have promise mismatches
'@typescript-eslint/no-misused-promises': 'off',
'@typescript-eslint/no-floating-promises': 'off',
// --- Style preferences (not critical for type safety) ---
// Catch variable typing preference
'@typescript-eslint/use-unknown-in-catch-callback-variable': 'off',
// Allow using deprecated APIs during migration periods
'@typescript-eslint/no-deprecated': 'off',
// Empty async functions valid for interface compliance
'@typescript-eslint/require-await': 'off',
// Constructor style preference
'@typescript-eslint/consistent-generic-constructors': 'off',
},
},
// Console spike (packages/web/src/experiments/console/**) — isolation guard.
// This experiment must not couple to the production web UI's state/components
// so that it can be extracted or discarded cleanly.
{
files: ['packages/web/src/experiments/console/**/*.{ts,tsx}'],
rules: {
'no-restricted-imports': [
'error',
{
patterns: [
{
// `**` matches nested paths too; the single `*` form let
// experiments couple to `@/components/layout/...` etc.
group: [
'@/components/**',
'@/contexts/**',
'@/hooks/**',
'@/routes/**',
'@/stores/**',
],
message:
'The console spike must not import from production web UI modules. See packages/web/src/experiments/console/README.md.',
},
{
// Block every named import from `@/lib/api` — only generated
// types from `@/lib/api.generated` are allowed (different
// module path, not matched by this glob).
group: ['@/lib/api'],
message:
'Import only types from @/lib/api.generated. Skill calls go through packages/web/src/experiments/console/skills/.',
},
{
group: ['@tanstack/react-query'],
message:
'The console spike uses its own reactive store (store/cache.ts). No React Query.',
},
],
},
],
},
}
);