-
Notifications
You must be signed in to change notification settings - Fork 32
Expand file tree
/
Copy patheslint.config.js
More file actions
192 lines (186 loc) · 6.5 KB
/
Copy patheslint.config.js
File metadata and controls
192 lines (186 loc) · 6.5 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
import js from "@eslint/js";
import sonarjs from "eslint-plugin-sonarjs";
import unicorn from "eslint-plugin-unicorn";
import tseslint from "typescript-eslint";
export default [
{
ignores: [
"dist/**",
"coverage/**",
"node_modules/**",
"examples/**",
".worktrees/**",
".mindmodel/**",
".opencode/**",
"*.config.ts",
"*.config.js",
"thoughts/**",
"docs/**",
],
},
js.configs.recommended,
...tseslint.configs.recommendedTypeChecked,
{
languageOptions: {
parserOptions: {
project: "./tsconfig.eslint.json",
tsconfigRootDir: import.meta.dirname,
},
},
plugins: {
sonarjs,
unicorn,
},
rules: {
// --- Disable rules that overlap with Biome or conflict with codebase ---
indent: "off",
quotes: "off",
semi: "off",
"comma-dangle": "off",
"no-unused-vars": "off",
"sort-imports": "off",
"no-multiple-empty-lines": "off",
"eol-last": "off",
// PTY code intentionally uses control characters (e.g. \x03 for SIGINT)
"no-control-regex": "off",
// --- Empty blocks and class prohibition ---
"no-empty": ["error", { allowEmptyCatch: false }],
"no-restricted-syntax": [
"error",
{
selector: "ClassDeclaration:not([superClass.name='Error'])",
message: "No classes for business logic. Use factory functions with closed-over state.",
},
{
selector: "VariableDeclarator > Identifier.id[name=/^.+(Map|List|Dict|Fn|Func|Callback)$/]",
message:
"No Hungarian notation. Name by domain meaning, not data structure (e.g., providerMap -> providers).",
},
{
selector: "FunctionDeclaration > Identifier.id[name=/^.+(Map|List|Dict|Fn|Func|Callback)$/]",
message: "No Hungarian notation. Name by domain meaning, not data structure.",
},
],
// --- Structural limits ---
"max-depth": ["error", 2],
"max-lines-per-function": ["error", { max: 40, skipBlankLines: true, skipComments: true }],
// --- TypeScript-specific ---
"@typescript-eslint/consistent-type-imports": [
"error",
{ prefer: "type-imports", disallowTypeAnnotations: false },
],
"@typescript-eslint/consistent-type-definitions": ["error", "interface"],
"@typescript-eslint/prefer-readonly": "error",
"@typescript-eslint/use-unknown-in-catch-callback-variable": "error",
"@typescript-eslint/explicit-function-return-type": [
"error",
{
allowExpressions: true,
allowTypedFunctionExpressions: true,
allowHigherOrderFunctions: true,
},
],
// OFF: OpenCode plugin framework requires async signatures even for sync hooks
"@typescript-eslint/require-await": "off",
"@typescript-eslint/no-unused-vars": [
"error",
{
argsIgnorePattern: "^_",
varsIgnorePattern: "^_",
caughtErrorsIgnorePattern: "^_",
},
],
"@typescript-eslint/naming-convention": [
"error",
{ selector: "default", format: ["camelCase"], leadingUnderscore: "allow" },
{
selector: "variable",
format: ["camelCase", "UPPER_CASE", "snake_case", "PascalCase"],
leadingUnderscore: "allow",
},
{
selector: "function",
format: ["camelCase"],
},
{
selector: "parameter",
format: ["camelCase"],
leadingUnderscore: "allow",
},
{ selector: "typeLike", format: ["PascalCase"] },
{
selector: "objectLiteralProperty",
format: null,
},
{
selector: "objectLiteralMethod",
format: null,
},
{
selector: "typeProperty",
format: null,
},
{
selector: "typeMethod",
format: null,
},
],
"@typescript-eslint/no-magic-numbers": [
"error",
{
ignore: [0, 1, -1, 2],
ignoreEnums: true,
ignoreNumericLiteralTypes: true,
ignoreReadonlyClassProperties: true,
},
],
"@typescript-eslint/no-explicit-any": "error",
"@typescript-eslint/consistent-type-assertions": "off",
"@typescript-eslint/no-floating-promises": "error",
"@typescript-eslint/no-misused-promises": "error",
// WARN: violations from type assertions flowing through
"@typescript-eslint/no-unsafe-assignment": "error",
"@typescript-eslint/no-unsafe-member-access": "error",
"@typescript-eslint/no-unsafe-argument": "error",
"@typescript-eslint/no-unsafe-call": "error",
"@typescript-eslint/no-unsafe-return": "error",
"@typescript-eslint/restrict-template-expressions": "error",
// WARN: error cause chaining - good practice but not enforced yet
"sonarjs/sonar-prefer-optional-chain": "off",
// --- Sonarjs (complexity and duplication) ---
"sonarjs/cognitive-complexity": ["error", 10],
"sonarjs/no-duplicate-string": ["error", { threshold: 3 }],
"sonarjs/no-identical-functions": "error",
// --- Unicorn (patterns) ---
"unicorn/no-nested-ternary": "error",
},
},
{
// Relax rules for test files
files: ["tests/**/*.ts", "src/**/*.test.ts", "**/*.test.ts"],
rules: {
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-magic-numbers": "off",
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/no-floating-promises": "off",
"@typescript-eslint/no-unused-vars": "off",
"@typescript-eslint/no-unsafe-assignment": "off",
"@typescript-eslint/no-unsafe-argument": "off",
"@typescript-eslint/no-unsafe-call": "off",
"@typescript-eslint/no-unsafe-member-access": "off",
"@typescript-eslint/no-unsafe-return": "off",
"@typescript-eslint/await-thenable": "off",
"@typescript-eslint/no-require-imports": "off",
"@typescript-eslint/restrict-template-expressions": "off",
"@typescript-eslint/naming-convention": "off",
"@typescript-eslint/consistent-type-definitions": "off",
"@typescript-eslint/prefer-readonly": "off",
"@typescript-eslint/use-unknown-in-catch-callback-variable": "off",
"sonarjs/no-duplicate-string": "off",
"sonarjs/no-identical-functions": "off",
"sonarjs/cognitive-complexity": "off",
"max-depth": "off",
"max-lines-per-function": "off",
},
},
];