-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheslint.config.mjs
More file actions
84 lines (75 loc) · 2.67 KB
/
eslint.config.mjs
File metadata and controls
84 lines (75 loc) · 2.67 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
// @ts-check
import eslint from "@eslint/js";
import sonarjs from "eslint-plugin-sonarjs";
import unicorn from "eslint-plugin-unicorn";
import tseslint from "typescript-eslint";
export default [
eslint.configs.recommended,
...tseslint.configs.recommended,
/** @type {any} */ (sonarjs.configs?.recommended ?? {}),
unicorn.configs["recommended"],
{
languageOptions: {
parserOptions: {
projectService: true,
tsconfigRootDir: import.meta.dirname,
},
},
rules: {
// === Security ===
"no-eval": "error",
"no-implied-eval": "error",
"no-new-func": "error",
// === Basic quality ===
"no-var": "error",
"prefer-const": "error",
eqeqeq: "error",
"no-console": ["warn", { allow: ["warn", "error"] }],
// === Guardrail #7: Cognitive Complexity ===
"sonarjs/cognitive-complexity": ["error", 15],
// === Guardrail #9: Bit ops / legacy API ===
"no-bitwise": "error",
"unicorn/prefer-number-properties": "error",
// === Guardrail #12: Modern API ===
"@typescript-eslint/prefer-optional-chain": "error",
"unicorn/prefer-string-starts-ends-with": "error",
// === Guardrail #14: Promise quality ===
"prefer-promise-reject-errors": "error",
"@typescript-eslint/no-floating-promises": "error",
// === Guardrail #16: SonarQube patterns ===
"no-duplicate-imports": "error",
"unicorn/prefer-string-replace-all": "error",
"unicorn/prefer-set-has": "error",
"unicorn/numeric-separators-style": "error",
"@typescript-eslint/no-unnecessary-type-assertion": "error",
// === TypeScript quality ===
"@typescript-eslint/no-explicit-any": "error",
"@typescript-eslint/explicit-function-return-type": "warn",
"@typescript-eslint/no-unused-vars": [
"error",
{
argsIgnorePattern: "^_",
varsIgnorePattern: "^_",
caughtErrorsIgnorePattern: "^_|^error$",
},
],
// === Unicorn overrides (disable overly opinionated rules) ===
"unicorn/no-null": "off",
"unicorn/prevent-abbreviations": "off",
"unicorn/filename-case": "off",
"unicorn/no-process-exit": "off",
"unicorn/prefer-module": "off",
"unicorn/prefer-top-level-await": "off",
"unicorn/no-abusive-eslint-disable": "off",
"unicorn/import-style": "off",
"unicorn/no-useless-undefined": "off",
"unicorn/prefer-node-protocol": "off", // Cloudflare Workers — no Node.js modules
},
linterOptions: {
reportUnusedDisableDirectives: "warn",
},
},
{
ignores: ["node_modules/**", "dist/**", ".wrangler/**", "*.js", "*.mjs"],
},
];