-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy patheslint.config.js
More file actions
166 lines (133 loc) · 7.31 KB
/
eslint.config.js
File metadata and controls
166 lines (133 loc) · 7.31 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
// @ts-check
import eslint from '@eslint/js';
import tseslint from 'typescript-eslint';
import eslintConfigPrettier from 'eslint-config-prettier';
export default tseslint.config(
// Base configurations
eslint.configs.recommended,
...tseslint.configs.strictTypeChecked,
...tseslint.configs.stylisticTypeChecked,
eslintConfigPrettier,
// TypeScript parser options
{
languageOptions: {
parserOptions: {
projectService: true,
tsconfigRootDir: import.meta.dirname,
},
},
},
// Strict code quality rules
{
rules: {
// ═══════════════════════════════════════════════════════════════════════
// COMPLEXITY RULES - Keep code readable for humans and LLMs
// ⚠️ DO NOT MODIFY THESE LIMITS - Refactor code instead of changing rules
// ═══════════════════════════════════════════════════════════════════════
// Max 200 lines per file - keeps files small and LLM-friendly
'max-lines': ['error', { max: 200, skipBlankLines: true, skipComments: true }],
// Max 60 lines per function - allows for async/try-catch blocks
'max-lines-per-function': ['error', { max: 60, skipBlankLines: true, skipComments: true }],
// Max 4 levels of nesting - allows for necessary try-catch in loops
'max-depth': ['error', 4],
// Max 5 parameters per function - for merge functions that need context
'max-params': ['error', 5],
// Max 20 statements per function
'max-statements': ['error', 20],
// Cyclomatic complexity limit (relaxed for sync logic)
'complexity': ['error', 15],
// ═══════════════════════════════════════════════════════════════════════
// CODE STYLE - Consistency and clarity
// ═══════════════════════════════════════════════════════════════════════
// Require explicit return types on functions
'@typescript-eslint/explicit-function-return-type': ['error', {
allowExpressions: true,
allowTypedFunctionExpressions: true,
allowHigherOrderFunctions: true,
}],
// Require explicit accessibility modifiers
'@typescript-eslint/explicit-member-accessibility': ['error', {
accessibility: 'explicit',
overrides: { constructors: 'no-public' },
}],
// Naming conventions (relaxed for external API types and plugin exports)
'@typescript-eslint/naming-convention': [
'error',
{ selector: 'default', format: ['camelCase'] },
// Allow PascalCase for exported variables (like plugin exports that act as classes)
{ selector: 'variable', format: ['camelCase', 'UPPER_CASE', 'PascalCase'] },
{ selector: 'parameter', format: ['camelCase'], leadingUnderscore: 'allow' },
{ selector: 'typeLike', format: ['PascalCase'] },
{ selector: 'enumMember', format: ['UPPER_CASE', 'PascalCase'] },
// Allow snake_case for properties to match external APIs (GitHub, etc.)
{ selector: 'property', format: ['camelCase', 'UPPER_CASE', 'snake_case'], leadingUnderscore: 'allow' },
{ selector: 'typeProperty', format: ['camelCase', 'UPPER_CASE', 'snake_case'], leadingUnderscore: 'allow' },
// Allow HTTP headers and plugin hook names (like 'tool.execute.after')
{ selector: 'objectLiteralProperty', format: null },
// Allow method names with dots for plugin hooks
{ selector: 'objectLiteralMethod', format: null },
],
// Prefer const over let when possible
'prefer-const': 'error',
// No var, only const and let
'no-var': 'error',
// Use strict equality
'eqeqeq': ['error', 'always'],
// ═══════════════════════════════════════════════════════════════════════
// ERROR PREVENTION - Catch bugs early
// ═══════════════════════════════════════════════════════════════════════
// No unused variables
'@typescript-eslint/no-unused-vars': ['error', {
argsIgnorePattern: '^_',
varsIgnorePattern: '^_',
}],
// No floating promises (must await or handle)
'@typescript-eslint/no-floating-promises': 'error',
// No misused promises
'@typescript-eslint/no-misused-promises': 'error',
// Require await in async functions
'@typescript-eslint/require-await': 'error',
// No unsafe any usage
'@typescript-eslint/no-unsafe-assignment': 'error',
'@typescript-eslint/no-unsafe-call': 'error',
'@typescript-eslint/no-unsafe-member-access': 'error',
'@typescript-eslint/no-unsafe-return': 'error',
// No explicit any
'@typescript-eslint/no-explicit-any': 'error',
// ═══════════════════════════════════════════════════════════════════════
// BEST PRACTICES
// ═══════════════════════════════════════════════════════════════════════
// Prefer nullish coalescing
'@typescript-eslint/prefer-nullish-coalescing': 'error',
// Prefer optional chaining
'@typescript-eslint/prefer-optional-chain': 'error',
// No non-null assertions
'@typescript-eslint/no-non-null-assertion': 'error',
// Consistent type imports
'@typescript-eslint/consistent-type-imports': ['error', {
prefer: 'type-imports',
fixStyle: 'separate-type-imports',
}],
// Consistent type exports
'@typescript-eslint/consistent-type-exports': 'error',
// No console in production code (use proper logging)
'no-console': ['warn', { allow: ['warn', 'error'] }],
// ═══════════════════════════════════════════════════════════════════════
// DOCUMENTATION
// ═══════════════════════════════════════════════════════════════════════
// Require JSDoc for exported functions
// Commented out - can be too strict for rapid development
// 'jsdoc/require-jsdoc': ['warn', { publicOnly: true }],
},
},
// Ignore patterns
{
ignores: [
'dist/**',
'node_modules/**',
'*.js',
'*.mjs',
'eslint.config.js',
],
}
);