-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy patheslint.config.js
More file actions
156 lines (148 loc) · 4.27 KB
/
eslint.config.js
File metadata and controls
156 lines (148 loc) · 4.27 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
import js from '@eslint/js';
import globals from 'globals';
import tsParser from '@typescript-eslint/parser';
import tsPlugin from '@typescript-eslint/eslint-plugin';
import sonarjs from 'eslint-plugin-sonarjs';
import jsdoc from 'eslint-plugin-jsdoc';
export default [
// Global ignores
{
ignores: [
'**/node_modules/**',
'**/dist/**',
'**/coverage/**',
'**/.cache/**',
'**/.stryker-tmp/**',
'.stryker-tmp/**',
'**/tmp/**',
'**/output/**',
'**/runs/**',
'**/report/**',
'**/reports/**',
'reports/**',
'**/test-e2e-output/**',
'**/vendor/**',
'**/docs/research/**',
'**/experiments/**',
'**/archive/**',
'assets/templates/**',
'templates/**',
'**/connectors/**',
'**/docs/api/**',
'**/*.d.ts',
'scripts/run-vitest.mjs',
],
},
// Base recommended rules
{
...js.configs.recommended,
languageOptions: {
...js.configs.recommended.languageOptions,
globals: {
...globals.node,
},
},
},
// Browser-only static assets (Lab UI)
{
files: ['assets/lab/**/*.js'],
languageOptions: {
globals: {
...globals.browser,
},
},
},
// TypeScript files
{
files: ['**/*.ts', '**/*.tsx'],
languageOptions: {
parser: tsParser,
parserOptions: {
sourceType: 'module',
ecmaVersion: 'latest',
// NOTE: No `project` — avoids type-aware linting issues
},
globals: {
...globals.node,
},
},
plugins: {
'@typescript-eslint': tsPlugin,
sonarjs,
jsdoc,
},
rules: {
// Disable base rules replaced by TS versions
'no-unused-vars': 'off',
'no-undef': 'off', // TypeScript handles this
// TypeScript rules
'@typescript-eslint/no-unused-vars': [
'error',
{ argsIgnorePattern: '^_', varsIgnorePattern: '^_' },
],
// JSDoc correctness for any docs that exist (keeps docs consistent without forcing them everywhere).
'jsdoc/check-alignment': 'error',
'jsdoc/check-param-names': 'error',
// Too strict for example blocks inside JSDoc (e.g., CLI usage snippets).
'jsdoc/check-indentation': 'off',
'jsdoc/check-tag-names': ['error', { definedTags: ['packageDocumentation', 'cmTerm'] }],
'jsdoc/check-types': 'error',
// === MAINTAINABILITY GATES ===
// Keep these as guidance (warn) so CI stays green while the project matures.
complexity: ['warn', 30],
'sonarjs/cognitive-complexity': ['warn', 30],
'max-depth': ['warn', 6],
'max-params': ['warn', 8],
'max-lines-per-function': [
'warn',
{ max: 200, skipBlankLines: true, skipComments: true, IIFEs: true },
],
'sonarjs/no-duplicate-string': ['warn', { threshold: 10 }],
'sonarjs/no-identical-functions': 'warn',
},
},
// Enforce centralized domain model imports.
// - Schemas/types/errors should be imported from `src/domain` rather than scattered `*/schema` modules.
// - Allow schema modules themselves to compose schemas directly without going through the domain barrel.
{
files: ['src/**/*.{ts,tsx}'],
ignores: ['src/domain/**', 'src/**/schema/**', '**/schema.ts', '**/schema.test.ts'],
rules: {
'no-restricted-imports': [
'error',
{
patterns: [
{
group: ['**/schema', '**/schema.ts', '**/*-schema', '**/*-schema.ts'],
message: 'Import schemas/types from `src/domain` instead of `*/schema`.',
},
],
},
],
},
},
{
files: [
'src/cli/commands/generate.ts',
'src/cli/commands/generate-output.ts',
'src/cli/commands/generate-preflight.ts',
'src/cli/commands/render.ts',
'src/validate/caption-sync.ts',
],
rules: {
complexity: 'off',
'sonarjs/cognitive-complexity': 'off',
'max-lines-per-function': 'off',
},
},
// Test files: relax complexity rules
{
files: ['**/*.test.ts', '**/*.spec.ts', 'tests/**/*.ts'],
rules: {
complexity: 'off',
'sonarjs/cognitive-complexity': 'off',
'max-lines-per-function': 'off',
'sonarjs/no-duplicate-string': 'off', // Test assertions often repeat strings
},
},
];