-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
eslint.config.mjs
158 lines (156 loc) · 4.88 KB
/
eslint.config.mjs
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
import importPlugin from "eslint-plugin-import";
import jsonc from "eslint-plugin-jsonc";
import noUnsanitized from "eslint-plugin-no-unsanitized";
import sonarjs from "eslint-plugin-sonarjs";
import simpleImportSort from "eslint-plugin-simple-import-sort";
import sortKeysFix from "eslint-plugin-sort-keys-fix";
import unicorn from "eslint-plugin-unicorn";
import prettier from "eslint-plugin-prettier";
import { fixupPluginRules } from "@eslint/compat";
import globals from "globals";
import tsParser from "@typescript-eslint/parser";
import path from "node:path";
import { fileURLToPath } from "node:url";
import js from "@eslint/js";
import { FlatCompat } from "@eslint/eslintrc";
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all,
});
export default [
sonarjs.configs.recommended,
{
plugins: {
import: fixupPluginRules(importPlugin),
jsonc,
"no-unsanitized": noUnsanitized,
"simple-import-sort": simpleImportSort,
"sort-keys-fix": sortKeysFix,
unicorn,
prettier,
},
languageOptions: {
globals: { ...globals.node },
},
},
...compat
.extends(
"plugin:@typescript-eslint/recommended",
"plugin:jsonc/recommended-with-jsonc",
"plugin:unicorn/recommended",
"plugin:prettier/recommended",
"plugin:@cspell/recommended",
)
.map(config => ({ ...config, files: ["src/**/*.mts"] })),
{
files: ["src/**/*.mts"],
languageOptions: {
parser: tsParser,
ecmaVersion: 5,
sourceType: "script",
parserOptions: {
project: ["tsconfig.json"],
},
},
rules: {
"prettier/prettier": "error",
"unicorn/switch-case-braces": "off",
"unicorn/prefer-module": "off",
"@typescript-eslint/no-magic-numbers": "warn",
"unicorn/no-object-as-default-parameter": "off",
"unicorn/no-null": "off",
"sonarjs/no-empty-function": "off",
"sonarjs/no-unused-expressions": "off",
"@typescript-eslint/no-unused-expressions": "off",
"unicorn/no-empty-file": "off",
"unicorn/expiring-todo-comments": "off",
"sonarjs/no-skipped-test": "off",
"sonarjs/prefer-single-boolean-return": "off",
"unicorn/no-array-callback-reference": "off",
"sonarjs/prefer-nullish-coalescing": "off",
"sonarjs/hashing": "off",
"unicorn/no-process-exit": "off",
"unicorn/consistent-function-scoping": "off",
"sonarjs/function-return-type": "off",
"unicorn/no-await-expression-member": "off",
"sonarjs/no-invalid-await": "off",
"sonarjs/no-nested-functions": "off",
"unicorn/no-useless-undefined": "off",
"@typescript-eslint/unbound-method": "error",
"sonarjs/sonar-no-fallthrough": "off",
"import/no-extraneous-dependencies": [
"error",
{
"packageDir": "./"
}
],
"sonarjs/prefer-immediate-return": "off",
"unicorn/prevent-abbreviations": "off",
"no-case-declarations": "off",
"no-async-promise-executor": "off",
"unicorn/prefer-node-protocol": "off",
"unicorn/no-array-for-each": "off",
"sonarjs/no-clear-text-protocols": "off",
"unicorn/import-style": "off",
"sonarjs/fixme-tag": "off",
"sort-keys-fix/sort-keys-fix": "warn",
"unicorn/prefer-event-target": "off",
"simple-import-sort/imports": "warn",
"sonarjs/no-misused-promises": "off",
"sonarjs/no-commented-code": "off",
"@typescript-eslint/no-empty-object-type": "off",
"sonarjs/todo-tag": "off",
"simple-import-sort/exports": "warn",
"no-console": [
"error"
],
"@typescript-eslint/no-unnecessary-type-constraint": "off",
"@typescript-eslint/no-unused-vars": [
"warn",
{
"varsIgnorePattern": "_|logger"
}
],
"@typescript-eslint/no-explicit-any": "error"
}
},
// module definitions
{
files: ["src/**/*.module.mts"],
languageOptions: {
parser: tsParser,
ecmaVersion: 5,
sourceType: "script",
parserOptions: {
project: ["tsconfig.json"],
},
},
rules: {
"@typescript-eslint/no-magic-numbers": "off",
},
},
{
files: ["src/**/*.spec.mts"],
languageOptions: {
globals: { ...globals.jest },
parser: tsParser,
ecmaVersion: 5,
sourceType: "script",
parserOptions: {
project: ["tsconfig.json"],
},
},
rules: {
"@cspell/spellchecker": "off",
"@typescript-eslint/no-magic-numbers": "off",
"@typescript-eslint/unbound-method": "off",
"sonarjs/no-duplicate-string": "off",
"sonarjs/no-unused-collection": "warn",
"sonarjs/prefer-promise-shorthand": "off",
"unicorn/consistent-function-scoping": "off",
},
},
];