forked from juspay/neurolink
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheslint.config.js
More file actions
295 lines (274 loc) · 8.75 KB
/
Copy patheslint.config.js
File metadata and controls
295 lines (274 loc) · 8.75 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
// ESLint v9 configuration for NeuroLink
import js from "@eslint/js";
import tseslint from "@typescript-eslint/eslint-plugin";
import tsparser from "@typescript-eslint/parser";
import { createRequire } from "node:module";
const require = createRequire(import.meta.url);
const neurolink = require("./eslint-rules/index.cjs");
export default [
js.configs.recommended,
{
files: ["**/*.js", "**/*.mjs"],
languageOptions: {
ecmaVersion: "latest",
sourceType: "module",
globals: {
// Node.js globals
process: "readonly",
Buffer: "readonly",
__dirname: "readonly",
__filename: "readonly",
global: "readonly",
console: "readonly",
setTimeout: "readonly",
clearTimeout: "readonly",
setInterval: "readonly",
clearInterval: "readonly",
URL: "readonly",
URLSearchParams: "readonly",
fetch: "readonly",
Headers: "readonly",
Request: "readonly",
Response: "readonly",
// Browser globals
window: "readonly",
document: "readonly",
navigator: "readonly",
// Test globals
describe: "readonly",
it: "readonly",
test: "readonly",
expect: "readonly",
beforeEach: "readonly",
afterEach: "readonly",
beforeAll: "readonly",
afterAll: "readonly",
vi: "readonly",
vitest: "readonly",
},
},
rules: {
// Basic rules
"no-unused-vars": "off", // Too many legacy unused vars in JS files
"no-console": "off",
"no-undef": "error",
// Modern JavaScript
"prefer-const": "warn",
"no-var": "error",
// Code quality
eqeqeq: ["error", "always"],
curly: ["error", "all"],
// Style (handled by Prettier)
indent: "off",
quotes: "off",
semi: "off",
},
},
{
// TypeScript files in src/ directory (use project-based linting)
files: ["src/**/*.ts"],
languageOptions: {
parser: tsparser,
parserOptions: {
ecmaVersion: "latest",
sourceType: "module",
project: "./tsconfig.json",
},
},
plugins: {
"@typescript-eslint": tseslint,
neurolink,
},
rules: {
// ======================================================================
// NeuroLink custom type-engineering rules (CLAUDE.md Critical Rules)
// All rules (7-13) enforced via ESLint — zero shell scripts.
// ======================================================================
"neurolink/no-interface": "error", // Rule 7
"neurolink/no-types-suffix-filename": "error", // Rule 8
"neurolink/unique-type-names": "error", // Rule 9
"neurolink/types-barrel-exports-only": "error", // Rule 10
"neurolink/no-local-types-folder": "error", // Rules 11 & 11b
"neurolink/no-type-export-outside-types": "error", // Rule 12
"neurolink/barrel-type-imports": "error", // Rule 13
"neurolink/no-local-type-alias": "error", // Rule 2 (strict)
// Disable base rules that are covered by TypeScript
"no-unused-vars": "off",
"no-undef": "off",
// TypeScript-specific rules (BALANCED ENFORCEMENT)
"@typescript-eslint/no-unused-vars": [
"error",
{
argsIgnorePattern: "^_",
varsIgnorePattern: "^_",
ignoreRestSiblings: true,
args: "after-used",
vars: "local",
},
], // Error for unused vars (unused imports should be caught)
"@typescript-eslint/no-explicit-any": "error", // Error on any types - enforce strict typing
"@typescript-eslint/prefer-as-const": "error",
"@typescript-eslint/no-non-null-assertion": "warn", // Warn about non-null assertions but don't block builds
// Enhanced type safety (basic rules only)
// Code quality gates (balanced enforcement - warnings for legacy code)
"max-depth": ["error", 6], // Error for deeply nested code
"max-lines-per-function": ["warn", 300], // Warn for very large functions (legacy methods)
"max-params": ["error", 6], // Error for too many parameters
// Security rules
"no-eval": "error",
"no-implied-eval": "error",
"no-console": ["error", { allow: ["warn", "error", "info"] }], // Allow console.warn, console.error, and console.info for legitimate logging
// Modern JavaScript
"prefer-const": "warn",
"no-var": "error",
// Code quality
eqeqeq: ["error", "always"],
curly: ["error", "all"],
// Style (handled by Prettier)
indent: "off",
quotes: "off",
semi: "off",
},
},
{
// TypeScript files in test/ directory (no project-based linting due to path mismatch)
files: ["test/**/*.ts"],
languageOptions: {
parser: tsparser,
parserOptions: {
ecmaVersion: "latest",
sourceType: "module",
// No project for test files since they're not in the main tsconfig
},
globals: {
// Node.js globals
process: "readonly",
Buffer: "readonly",
__dirname: "readonly",
__filename: "readonly",
global: "readonly",
console: "readonly",
setTimeout: "readonly",
clearTimeout: "readonly",
setInterval: "readonly",
clearInterval: "readonly",
// Browser globals
window: "readonly",
document: "readonly",
navigator: "readonly",
// Test globals
describe: "readonly",
it: "readonly",
test: "readonly",
expect: "readonly",
beforeEach: "readonly",
afterEach: "readonly",
beforeAll: "readonly",
afterAll: "readonly",
vi: "readonly",
vitest: "readonly",
},
},
plugins: {
"@typescript-eslint": tseslint,
},
rules: {
// Disable base rules that are covered by TypeScript
"no-unused-vars": "off",
"no-undef": "off",
// TypeScript-specific rules (less strict for test files)
"@typescript-eslint/no-unused-vars": "warn", // Test files often have unused vars - warn only
"@typescript-eslint/no-explicit-any": "warn", // Less strict for test files - warn only
"@typescript-eslint/prefer-as-const": "error",
"no-console": "off", // Allow all console statements in tests
// Modern JavaScript
"prefer-const": "warn",
"no-var": "error",
// Code quality
eqeqeq: ["error", "always"],
curly: ["error", "all"],
// Style (handled by Prettier)
indent: "off",
quotes: "off",
semi: "off",
},
},
{
// Logger file override - allow console statements in logger implementation
files: ["src/lib/utils/logger.ts"],
rules: {
"no-console": "off", // Logger implementation needs console access
},
},
{
// Test files override - allow console statements and relaxed rules
files: ["test/**/*.ts"],
rules: {
"no-console": "off", // Allow all console statements in test files
"@typescript-eslint/no-explicit-any": "warn", // Consistent with test directory rules above
"@typescript-eslint/no-unused-vars": "off", // Allow unused vars in tests
},
},
{
// CommonJS files (e.g., Docusaurus config) - allow module.exports and require
files: ["docs-site/**/*.js"],
languageOptions: {
sourceType: "commonjs",
globals: {
module: "writable",
require: "readonly",
exports: "writable",
__dirname: "readonly",
__filename: "readonly",
},
},
},
{
// Ignore patterns
ignores: [
"node_modules/**",
"dist/**",
"action-dist/**",
"build/**",
".svelte-kit/**",
"package/**",
".git/**",
".git_disabled/**",
"docs/cli-recordings/**",
"docs/visual-content/**",
"neurolink-demo/**",
"scripts/**",
"memory-bank/**",
"archive/**",
"examples/**",
"*.config.js",
"*.config.ts",
".changeset/**",
"*.log",
"test-output.json",
"test-output.txt",
"debug-output.txt",
"demo-results.json",
"batch-results.json",
// Scratch artifacts produced by the voice fix campaign — not source.
"test-results/**",
"package-lock.json",
"pnpm-lock.yaml",
"*.tgz",
"*.d.ts",
"src/cli/**/*.d.ts",
// Exclude built documentation site and generated files
"site/**",
"_site/**",
// Exclude landing build outputs and Svelte files (handled by landing workspace)
"landing/.vercel/**",
"landing/.svelte-kit/**",
"landing/**/*.svelte",
// Exclude Docusaurus build output
"docs-site/.docusaurus/**",
"docs-site/build/**",
// Exclude compiled MCP server output files
"docs-site/mcp-server/**/*.js",
],
},
];