-
-
Notifications
You must be signed in to change notification settings - Fork 8.5k
Expand file tree
/
Copy patheslint.complexity-ratchets.config.mjs
More file actions
76 lines (71 loc) · 1.99 KB
/
Copy patheslint.complexity-ratchets.config.mjs
File metadata and controls
76 lines (71 loc) · 1.99 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
// eslint.complexity-ratchets.config.mjs
// STANDALONE flat config for BOTH complexity ratchets in ONE ESLint walk:
// - ESLint core: complexity + max-lines-per-function (src, open-sse, electron, bin)
// - sonarjs/cognitive-complexity (src, open-sse only)
//
// Existence reason: two independent baselines (complexity-baseline.json +
// quality-baseline metrics.cognitiveComplexity) must stay isolatable from the
// main lint warning budget — but they do NOT need two cold tree walks.
//
// Counts are taken by ruleId in the check scripts (never file.errorCount), so
// cognitive violations cannot inflate the cyclomatic/max-lines ratchet.
import tseslint from "typescript-eslint";
import sonarjs from "eslint-plugin-sonarjs";
const SHARED_LANGUAGE = {
parser: tseslint.parser,
parserOptions: {
ecmaVersion: 2022,
sourceType: "module",
ecmaFeatures: { jsx: true },
},
};
const SHARED_LINTER = {
noInlineConfig: true,
reportUnusedDisableDirectives: "off",
};
const SHARED_IGNORES = {
ignores: [
"**/*.test.ts",
"**/*.test.tsx",
"**/__tests__/**",
"**/*.d.ts",
"node_modules/**",
"electron/node_modules/**",
"electron/dist-electron/**",
".next/**",
".build/**",
"dist/**",
"coverage/**",
],
};
/** @type {import("eslint").Linter.Config[]} */
const config = [
{
files: [
"src/**/*.{ts,tsx}",
"open-sse/**/*.{ts,tsx}",
"electron/**/*.{ts,tsx}",
"bin/**/*.{ts,tsx}",
],
languageOptions: SHARED_LANGUAGE,
linterOptions: SHARED_LINTER,
rules: {
complexity: ["error", 15],
"max-lines-per-function": [
"error",
{ max: 80, skipBlankLines: true, skipComments: true },
],
},
},
{
files: ["src/**/*.{ts,tsx}", "open-sse/**/*.{ts,tsx}"],
languageOptions: SHARED_LANGUAGE,
plugins: { sonarjs },
linterOptions: SHARED_LINTER,
rules: {
"sonarjs/cognitive-complexity": ["error", 15],
},
},
SHARED_IGNORES,
];
export default config;