@tb-dev/eslint-config 9.0.2 → 9.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +806 -865
- package/package.json +7 -10
package/dist/index.js
CHANGED
|
@@ -1,884 +1,825 @@
|
|
|
1
|
-
import process from
|
|
2
|
-
import globals from
|
|
3
|
-
|
|
4
|
-
var Glob = /* @__PURE__ */ (
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}
|
|
12
|
-
var GlobIgnore = /* @__PURE__ */ (
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
|
|
1
|
+
import process from "node:process";
|
|
2
|
+
import globals from "globals";
|
|
3
|
+
//#region src/utils/enum.ts
|
|
4
|
+
var Glob = /* @__PURE__ */ function(Glob) {
|
|
5
|
+
Glob["All"] = "**/*.?([cm])[jt]s?(x)";
|
|
6
|
+
Glob["Html"] = "**/*.html";
|
|
7
|
+
Glob["Javascript"] = "**/*.?([cm])js?(x)";
|
|
8
|
+
Glob["Typescript"] = "**/*.?([cm])ts?(x)";
|
|
9
|
+
Glob["Vue"] = "**/*.vue";
|
|
10
|
+
return Glob;
|
|
11
|
+
}({});
|
|
12
|
+
var GlobIgnore = /* @__PURE__ */ function(GlobIgnore) {
|
|
13
|
+
GlobIgnore["Autogenerated"] = "**/autogenerated";
|
|
14
|
+
GlobIgnore["Cache"] = "**/cache";
|
|
15
|
+
GlobIgnore["Dist"] = "**/dist";
|
|
16
|
+
GlobIgnore["Log"] = "**/log?(s)";
|
|
17
|
+
GlobIgnore["NodeModules"] = "**/node_modules";
|
|
18
|
+
GlobIgnore["Out"] = "**/out";
|
|
19
|
+
GlobIgnore["Target"] = "**/target";
|
|
20
|
+
GlobIgnore["Temp"] = "**/?(.)temp";
|
|
21
|
+
return GlobIgnore;
|
|
22
|
+
}({});
|
|
23
|
+
//#endregion
|
|
24
|
+
//#region src/utils/index.ts
|
|
25
|
+
var OPTIONAL_FEATURES = [
|
|
26
|
+
"perfectionist",
|
|
27
|
+
"unicorn",
|
|
28
|
+
"vue"
|
|
29
|
+
];
|
|
25
30
|
async function interopDefault(promise) {
|
|
26
|
-
|
|
27
|
-
|
|
31
|
+
const result = await promise;
|
|
32
|
+
return result.default ?? result;
|
|
28
33
|
}
|
|
29
34
|
function isEnabled(config, feature) {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
case "unicorn":
|
|
39
|
-
return config?.unicorn ?? true;
|
|
40
|
-
case "vue":
|
|
41
|
-
return config?.vue ?? false;
|
|
42
|
-
default:
|
|
43
|
-
return false;
|
|
44
|
-
}
|
|
35
|
+
if (Array.isArray(config)) return OPTIONAL_FEATURES.includes(feature) ? config.includes(feature) : true;
|
|
36
|
+
else if (typeof config === "boolean") return config;
|
|
37
|
+
switch (feature) {
|
|
38
|
+
case "perfectionist": return config?.perfectionist ?? true;
|
|
39
|
+
case "unicorn": return config?.unicorn ?? true;
|
|
40
|
+
case "vue": return config?.vue ?? false;
|
|
41
|
+
default: return false;
|
|
42
|
+
}
|
|
45
43
|
}
|
|
46
44
|
function getIgnores() {
|
|
47
|
-
|
|
45
|
+
return Object.values(GlobIgnore);
|
|
48
46
|
}
|
|
49
|
-
|
|
47
|
+
//#endregion
|
|
48
|
+
//#region src/lib/vue.ts
|
|
49
|
+
/**
|
|
50
|
+
* @see https://eslint.vuejs.org/rules/
|
|
51
|
+
*/
|
|
50
52
|
async function vue(options) {
|
|
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
|
-
"vue/valid-v-pre": "error",
|
|
255
|
-
"vue/valid-v-show": "error",
|
|
256
|
-
"vue/valid-v-slot": "error",
|
|
257
|
-
"vue/valid-v-text": "error",
|
|
258
|
-
...options.overrides?.vue
|
|
259
|
-
};
|
|
260
|
-
return [
|
|
261
|
-
{ plugins: { vue: vuePlugin } },
|
|
262
|
-
{
|
|
263
|
-
files: [Glob.Vue],
|
|
264
|
-
languageOptions: {
|
|
265
|
-
parser: vueParser,
|
|
266
|
-
parserOptions: {
|
|
267
|
-
parser: tsParser,
|
|
268
|
-
project: options.project,
|
|
269
|
-
tsconfigRootDir: process.cwd(),
|
|
270
|
-
extraFileExtensions: [".vue"],
|
|
271
|
-
sourceType: "module",
|
|
272
|
-
ecmaVersion: "latest"
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
},
|
|
276
|
-
{
|
|
277
|
-
// @ts-expect-error no types
|
|
278
|
-
processor: vuePlugin.processors[".vue"],
|
|
279
|
-
rules
|
|
280
|
-
}
|
|
281
|
-
];
|
|
53
|
+
if (!isEnabled(options.features, "vue")) return [];
|
|
54
|
+
const [vuePlugin, vueParser, tsParser] = await Promise.all([
|
|
55
|
+
interopDefault(import("eslint-plugin-vue")),
|
|
56
|
+
interopDefault(import("vue-eslint-parser")),
|
|
57
|
+
interopDefault(import("@typescript-eslint/parser"))
|
|
58
|
+
]);
|
|
59
|
+
const rules = {
|
|
60
|
+
...vuePlugin.configs.base.rules,
|
|
61
|
+
"vue/attribute-hyphenation": ["error", "always"],
|
|
62
|
+
"vue/attributes-order": "error",
|
|
63
|
+
"vue/block-lang": ["error", {
|
|
64
|
+
script: { lang: "ts" },
|
|
65
|
+
style: {
|
|
66
|
+
lang: "scss",
|
|
67
|
+
allowNoLang: true
|
|
68
|
+
}
|
|
69
|
+
}],
|
|
70
|
+
"vue/block-order": ["error", { order: [
|
|
71
|
+
["script", "template"],
|
|
72
|
+
"style:not([scoped])",
|
|
73
|
+
"style[scoped]"
|
|
74
|
+
] }],
|
|
75
|
+
"vue/block-tag-newline": ["error", {
|
|
76
|
+
singleline: "always",
|
|
77
|
+
multiline: "always",
|
|
78
|
+
maxEmptyLines: 0
|
|
79
|
+
}],
|
|
80
|
+
"vue/component-api-style": ["error", ["script-setup"]],
|
|
81
|
+
"vue/component-definition-name-casing": ["error", "PascalCase"],
|
|
82
|
+
"vue/component-name-in-template-casing": [
|
|
83
|
+
"error",
|
|
84
|
+
"PascalCase",
|
|
85
|
+
{ registeredComponentsOnly: false }
|
|
86
|
+
],
|
|
87
|
+
"vue/custom-event-name-casing": ["error", "kebab-case"],
|
|
88
|
+
"vue/define-emits-declaration": ["error", "type-based"],
|
|
89
|
+
"vue/define-macros-order": ["error", {
|
|
90
|
+
order: [
|
|
91
|
+
"defineOptions",
|
|
92
|
+
"defineProps",
|
|
93
|
+
"defineModel",
|
|
94
|
+
"defineEmits",
|
|
95
|
+
"defineSlots"
|
|
96
|
+
],
|
|
97
|
+
defineExposeLast: true
|
|
98
|
+
}],
|
|
99
|
+
"vue/define-props-declaration": ["error", "type-based"],
|
|
100
|
+
"vue/enforce-style-attribute": ["error", { allow: ["scoped"] }],
|
|
101
|
+
"vue/html-button-has-type": ["error", {
|
|
102
|
+
button: true,
|
|
103
|
+
submit: true,
|
|
104
|
+
reset: true
|
|
105
|
+
}],
|
|
106
|
+
"vue/match-component-file-name": ["off", {
|
|
107
|
+
extensions: ["tsx", "vue"],
|
|
108
|
+
shouldMatchCase: false
|
|
109
|
+
}],
|
|
110
|
+
"vue/match-component-import-name": "error",
|
|
111
|
+
"vue/multi-word-component-names": "off",
|
|
112
|
+
"vue/no-arrow-functions-in-watch": "off",
|
|
113
|
+
"vue/no-async-in-computed-properties": "error",
|
|
114
|
+
"vue/no-boolean-default": ["error", "no-default"],
|
|
115
|
+
"vue/no-computed-properties-in-data": "error",
|
|
116
|
+
"vue/no-deprecated-delete-set": "error",
|
|
117
|
+
"vue/no-dupe-keys": "error",
|
|
118
|
+
"vue/no-dupe-v-else-if": "error",
|
|
119
|
+
"vue/no-duplicate-attributes": ["error", {
|
|
120
|
+
allowCoexistClass: true,
|
|
121
|
+
allowCoexistStyle: true
|
|
122
|
+
}],
|
|
123
|
+
"vue/no-duplicate-class-names": "error",
|
|
124
|
+
"vue/no-export-in-script-setup": "error",
|
|
125
|
+
"vue/no-expose-after-await": "error",
|
|
126
|
+
"vue/no-import-compiler-macros": "error",
|
|
127
|
+
"vue/no-lifecycle-after-await": "error",
|
|
128
|
+
"vue/no-lone-template": "error",
|
|
129
|
+
"vue/no-multiple-objects-in-class": "error",
|
|
130
|
+
"vue/no-mutating-props": "error",
|
|
131
|
+
"vue/no-parsing-error": "error",
|
|
132
|
+
"vue/no-ref-as-operand": "error",
|
|
133
|
+
"vue/no-ref-object-reactivity-loss": "error",
|
|
134
|
+
"vue/no-reserved-component-names": ["error", {
|
|
135
|
+
disallowVueBuiltInComponents: true,
|
|
136
|
+
disallowVue3BuiltInComponents: true,
|
|
137
|
+
htmlElementCaseSensitive: true
|
|
138
|
+
}],
|
|
139
|
+
"vue/no-reserved-keys": "error",
|
|
140
|
+
"vue/no-reserved-props": "error",
|
|
141
|
+
"vue/no-required-prop-with-default": ["error", { autofix: true }],
|
|
142
|
+
"vue/no-root-v-if": "error",
|
|
143
|
+
"vue/no-setup-props-reactivity-loss": "error",
|
|
144
|
+
"vue/no-shared-component-data": "error",
|
|
145
|
+
"vue/no-side-effects-in-computed-properties": "error",
|
|
146
|
+
"vue/no-static-inline-styles": ["error", { allowBinding: false }],
|
|
147
|
+
"vue/no-template-key": "error",
|
|
148
|
+
"vue/no-template-shadow": "error",
|
|
149
|
+
"vue/no-template-target-blank": "error",
|
|
150
|
+
"vue/no-textarea-mustache": "error",
|
|
151
|
+
"vue/no-unused-components": "error",
|
|
152
|
+
"vue/no-unused-emit-declarations": "error",
|
|
153
|
+
"vue/no-unused-properties": "error",
|
|
154
|
+
"vue/no-unused-refs": "error",
|
|
155
|
+
"vue/no-unused-vars": ["error", { ignorePattern: "^_" }],
|
|
156
|
+
"vue/no-use-computed-property-like-method": "error",
|
|
157
|
+
"vue/no-use-v-else-with-v-for": "error",
|
|
158
|
+
"vue/no-use-v-if-with-v-for": "error",
|
|
159
|
+
"vue/no-useless-mustaches": ["error", {
|
|
160
|
+
ignoreIncludesComment: false,
|
|
161
|
+
ignoreStringEscape: false
|
|
162
|
+
}],
|
|
163
|
+
"vue/no-useless-template-attributes": "error",
|
|
164
|
+
"vue/no-useless-v-bind": "error",
|
|
165
|
+
"vue/no-v-for-template-key-on-child": "error",
|
|
166
|
+
"vue/no-v-text-v-html-on-component": "error",
|
|
167
|
+
"vue/no-v-html": "off",
|
|
168
|
+
"vue/no-watch-after-await": "error",
|
|
169
|
+
"vue/order-in-components": "error",
|
|
170
|
+
"vue/padding-line-between-blocks": ["error", "always"],
|
|
171
|
+
"vue/prefer-define-options": "error",
|
|
172
|
+
"vue/prefer-import-from-vue": "error",
|
|
173
|
+
"vue/prefer-separate-static-class": "error",
|
|
174
|
+
"vue/prefer-true-attribute-shorthand": "error",
|
|
175
|
+
"vue/prop-name-casing": ["error", "camelCase"],
|
|
176
|
+
"vue/require-component-is": "error",
|
|
177
|
+
"vue/require-default-prop": "off",
|
|
178
|
+
"vue/require-explicit-emits": ["error", { allowProps: false }],
|
|
179
|
+
"vue/require-explicit-slots": "error",
|
|
180
|
+
"vue/require-macro-variable-name": ["error", {
|
|
181
|
+
defineProps: "props",
|
|
182
|
+
defineEmits: "emit",
|
|
183
|
+
defineSlots: "slots",
|
|
184
|
+
useSlots: "slots",
|
|
185
|
+
useAttrs: "attrs"
|
|
186
|
+
}],
|
|
187
|
+
"vue/require-prop-types": "error",
|
|
188
|
+
"vue/require-render-return": "error",
|
|
189
|
+
"vue/require-slots-as-functions": "error",
|
|
190
|
+
"vue/require-toggle-inside-transition": "error",
|
|
191
|
+
"vue/require-typed-ref": "error",
|
|
192
|
+
"vue/require-v-for-key": "error",
|
|
193
|
+
"vue/require-valid-default-prop": "error",
|
|
194
|
+
"vue/return-in-computed-property": "error",
|
|
195
|
+
"vue/return-in-emits-validator": "error",
|
|
196
|
+
"vue/this-in-template": ["error", "never"],
|
|
197
|
+
"vue/use-v-on-exact": "error",
|
|
198
|
+
"vue/v-bind-style": [
|
|
199
|
+
"error",
|
|
200
|
+
"shorthand",
|
|
201
|
+
{ sameNameShorthand: "always" }
|
|
202
|
+
],
|
|
203
|
+
"vue/v-for-delimiter-style": ["error", "of"],
|
|
204
|
+
"vue/v-on-handler-style": "off",
|
|
205
|
+
"vue/v-on-style": ["error", "shorthand"],
|
|
206
|
+
"vue/v-slot-style": ["error", {
|
|
207
|
+
atComponent: "shorthand",
|
|
208
|
+
default: "shorthand",
|
|
209
|
+
named: "shorthand"
|
|
210
|
+
}],
|
|
211
|
+
"vue/v-on-event-hyphenation": ["error", "always"],
|
|
212
|
+
"vue/valid-attribute-name": "error",
|
|
213
|
+
"vue/valid-define-emits": "error",
|
|
214
|
+
"vue/valid-define-options": "error",
|
|
215
|
+
"vue/valid-define-props": "error",
|
|
216
|
+
"vue/valid-next-tick": "error",
|
|
217
|
+
"vue/valid-template-root": "error",
|
|
218
|
+
"vue/valid-v-bind": "error",
|
|
219
|
+
"vue/valid-v-cloak": "error",
|
|
220
|
+
"vue/valid-v-else-if": "error",
|
|
221
|
+
"vue/valid-v-else": "error",
|
|
222
|
+
"vue/valid-v-for": "error",
|
|
223
|
+
"vue/valid-v-html": "error",
|
|
224
|
+
"vue/valid-v-if": "error",
|
|
225
|
+
"vue/valid-v-memo": "error",
|
|
226
|
+
"vue/valid-v-model": "error",
|
|
227
|
+
"vue/valid-v-on": "error",
|
|
228
|
+
"vue/valid-v-once": "error",
|
|
229
|
+
"vue/valid-v-pre": "error",
|
|
230
|
+
"vue/valid-v-show": "error",
|
|
231
|
+
"vue/valid-v-slot": "error",
|
|
232
|
+
"vue/valid-v-text": "error",
|
|
233
|
+
...options.overrides?.vue
|
|
234
|
+
};
|
|
235
|
+
return [
|
|
236
|
+
{ plugins: { vue: vuePlugin } },
|
|
237
|
+
{
|
|
238
|
+
files: [Glob.Vue],
|
|
239
|
+
languageOptions: {
|
|
240
|
+
parser: vueParser,
|
|
241
|
+
parserOptions: {
|
|
242
|
+
parser: tsParser,
|
|
243
|
+
project: options.project,
|
|
244
|
+
tsconfigRootDir: process.cwd(),
|
|
245
|
+
extraFileExtensions: [".vue"],
|
|
246
|
+
sourceType: "module",
|
|
247
|
+
ecmaVersion: "latest"
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
},
|
|
251
|
+
{
|
|
252
|
+
processor: vuePlugin.processors[".vue"],
|
|
253
|
+
rules
|
|
254
|
+
}
|
|
255
|
+
];
|
|
282
256
|
}
|
|
283
|
-
|
|
257
|
+
//#endregion
|
|
258
|
+
//#region src/lib/unicorn.ts
|
|
259
|
+
/**
|
|
260
|
+
* @see https://github.com/sindresorhus/eslint-plugin-unicorn#rules
|
|
261
|
+
*/
|
|
284
262
|
async function unicorn(options) {
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
};
|
|
263
|
+
if (!isEnabled(options.features, "unicorn")) return {};
|
|
264
|
+
return {
|
|
265
|
+
plugins: { unicorn: await interopDefault(import("eslint-plugin-unicorn")) },
|
|
266
|
+
rules: {
|
|
267
|
+
"unicorn/catch-error-name": ["error", { name: "err" }],
|
|
268
|
+
"unicorn/consistent-date-clone": "error",
|
|
269
|
+
"unicorn/consistent-empty-array-spread": "error",
|
|
270
|
+
"unicorn/consistent-existence-index-check": "error",
|
|
271
|
+
"unicorn/consistent-function-scoping": ["error", { checkArrowFunctions: false }],
|
|
272
|
+
"unicorn/custom-error-definition": "error",
|
|
273
|
+
"unicorn/error-message": "error",
|
|
274
|
+
"unicorn/no-array-for-each": "off",
|
|
275
|
+
"unicorn/no-array-method-this-argument": "error",
|
|
276
|
+
"unicorn/no-await-expression-member": "error",
|
|
277
|
+
"unicorn/no-await-in-promise-methods": "error",
|
|
278
|
+
"unicorn/no-immediate-mutation": "error",
|
|
279
|
+
"unicorn/no-invalid-fetch-options": "error",
|
|
280
|
+
"unicorn/no-invalid-remove-event-listener": "error",
|
|
281
|
+
"unicorn/no-magic-array-flat-depth": "error",
|
|
282
|
+
"unicorn/no-negation-in-equality-check": "error",
|
|
283
|
+
"unicorn/no-single-promise-in-promise-methods": "error",
|
|
284
|
+
"unicorn/no-thenable": "error",
|
|
285
|
+
"unicorn/no-typeof-undefined": "off",
|
|
286
|
+
"unicorn/no-unnecessary-array-flat-depth": "error",
|
|
287
|
+
"unicorn/no-unnecessary-array-splice-count": "error",
|
|
288
|
+
"unicorn/no-unnecessary-slice-end": "error",
|
|
289
|
+
"unicorn/no-useless-collection-argument": "error",
|
|
290
|
+
"unicorn/no-useless-fallback-in-spread": "error",
|
|
291
|
+
"unicorn/no-useless-length-check": "error",
|
|
292
|
+
"unicorn/no-useless-promise-resolve-reject": "error",
|
|
293
|
+
"unicorn/prefer-at": "error",
|
|
294
|
+
"unicorn/prefer-bigint-literals": "error",
|
|
295
|
+
"unicorn/prefer-classlist-toggle": "error",
|
|
296
|
+
"unicorn/prefer-date-now": "error",
|
|
297
|
+
"unicorn/prefer-dom-node-append": "error",
|
|
298
|
+
"unicorn/prefer-dom-node-dataset": "error",
|
|
299
|
+
"unicorn/prefer-dom-node-remove": "error",
|
|
300
|
+
"unicorn/prefer-dom-node-text-content": "error",
|
|
301
|
+
"unicorn/prefer-import-meta-properties": "error",
|
|
302
|
+
"unicorn/prefer-global-this": "off",
|
|
303
|
+
"unicorn/prefer-math-min-max": "error",
|
|
304
|
+
"unicorn/prefer-modern-dom-apis": "error",
|
|
305
|
+
"unicorn/prefer-node-protocol": "error",
|
|
306
|
+
"unicorn/prefer-number-properties": "error",
|
|
307
|
+
"unicorn/prefer-object-from-entries": "error",
|
|
308
|
+
"unicorn/prefer-prototype-methods": "error",
|
|
309
|
+
"unicorn/prefer-query-selector": "error",
|
|
310
|
+
"unicorn/prefer-reflect-apply": "error",
|
|
311
|
+
"unicorn/prefer-regexp-test": "error",
|
|
312
|
+
"unicorn/prefer-response-static-json": "error",
|
|
313
|
+
"unicorn/prefer-single-call": "error",
|
|
314
|
+
"unicorn/prefer-string-raw": "error",
|
|
315
|
+
"unicorn/prefer-string-slice": "error",
|
|
316
|
+
"unicorn/prefer-structured-clone": "error",
|
|
317
|
+
"unicorn/prefer-type-error": "error",
|
|
318
|
+
"unicorn/relative-url-style": ["error", "never"],
|
|
319
|
+
...options.overrides?.unicorn
|
|
320
|
+
}
|
|
321
|
+
};
|
|
345
322
|
}
|
|
346
|
-
|
|
323
|
+
//#endregion
|
|
324
|
+
//#region src/lib/javascript.ts
|
|
325
|
+
/**
|
|
326
|
+
* @see https://eslint.org/docs/latest/rules/
|
|
327
|
+
*/
|
|
347
328
|
function javascript(options) {
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
329
|
+
const files = [Glob.All];
|
|
330
|
+
if (isEnabled(options.features, "vue")) files.push(Glob.Vue);
|
|
331
|
+
return {
|
|
332
|
+
files,
|
|
333
|
+
languageOptions: {
|
|
334
|
+
ecmaVersion: "latest",
|
|
335
|
+
sourceType: "module",
|
|
336
|
+
globals: {
|
|
337
|
+
...globals.browser,
|
|
338
|
+
...globals.es2021,
|
|
339
|
+
...globals.node,
|
|
340
|
+
document: "readonly",
|
|
341
|
+
window: "readonly"
|
|
342
|
+
}
|
|
343
|
+
},
|
|
344
|
+
rules: {
|
|
345
|
+
"accessor-pairs": ["error", {
|
|
346
|
+
enforceForClassMembers: true,
|
|
347
|
+
setWithoutGet: true
|
|
348
|
+
}],
|
|
349
|
+
"array-callback-return": ["error", {
|
|
350
|
+
checkForEach: false,
|
|
351
|
+
allowVoid: true
|
|
352
|
+
}],
|
|
353
|
+
"block-scoped-var": "error",
|
|
354
|
+
"consistent-this": ["error", "self"],
|
|
355
|
+
"default-case-last": "error",
|
|
356
|
+
eqeqeq: ["error", "always"],
|
|
357
|
+
"for-direction": "error",
|
|
358
|
+
"func-style": [
|
|
359
|
+
"error",
|
|
360
|
+
"declaration",
|
|
361
|
+
{ allowArrowFunctions: true }
|
|
362
|
+
],
|
|
363
|
+
"grouped-accessor-pairs": ["error", "getBeforeSet"],
|
|
364
|
+
"guard-for-in": "error",
|
|
365
|
+
"init-declarations": "off",
|
|
366
|
+
"logical-assignment-operators": [
|
|
367
|
+
"error",
|
|
368
|
+
"always",
|
|
369
|
+
{ enforceForIfStatements: true }
|
|
370
|
+
],
|
|
371
|
+
"max-params": "off",
|
|
372
|
+
"new-cap": ["error", {
|
|
373
|
+
newIsCap: true,
|
|
374
|
+
capIsNew: false,
|
|
375
|
+
properties: true
|
|
376
|
+
}],
|
|
377
|
+
"no-alert": "error",
|
|
378
|
+
"no-async-promise-executor": "error",
|
|
379
|
+
"no-caller": "error",
|
|
380
|
+
"no-case-declarations": "error",
|
|
381
|
+
"no-class-assign": "error",
|
|
382
|
+
"no-compare-neg-zero": "error",
|
|
383
|
+
"no-cond-assign": ["error", "always"],
|
|
384
|
+
"no-constant-binary-expression": "error",
|
|
385
|
+
"no-constant-condition": "error",
|
|
386
|
+
"no-constructor-return": "error",
|
|
387
|
+
"no-control-regex": "error",
|
|
388
|
+
"no-debugger": "error",
|
|
389
|
+
"no-delete-var": "error",
|
|
390
|
+
"no-dupe-else-if": "error",
|
|
391
|
+
"no-duplicate-case": "error",
|
|
392
|
+
"no-duplicate-imports": ["error", { includeExports: false }],
|
|
393
|
+
"no-else-return": "off",
|
|
394
|
+
"no-empty": ["error", { allowEmptyCatch: true }],
|
|
395
|
+
"no-empty-character-class": "error",
|
|
396
|
+
"no-empty-pattern": "error",
|
|
397
|
+
"no-empty-static-block": "error",
|
|
398
|
+
"no-eval": "error",
|
|
399
|
+
"no-ex-assign": "error",
|
|
400
|
+
"no-extend-native": "error",
|
|
401
|
+
"no-extra-bind": "error",
|
|
402
|
+
"no-extra-boolean-cast": "error",
|
|
403
|
+
"no-fallthrough": ["error", { allowEmptyCase: true }],
|
|
404
|
+
"no-global-assign": "error",
|
|
405
|
+
"no-implicit-coercion": ["error", { disallowTemplateShorthand: true }],
|
|
406
|
+
"no-import-assign": "error",
|
|
407
|
+
"no-inner-declarations": ["error", "both"],
|
|
408
|
+
"no-invalid-regexp": "error",
|
|
409
|
+
"no-irregular-whitespace": "error",
|
|
410
|
+
"no-iterator": "error",
|
|
411
|
+
"no-labels": ["error", {
|
|
412
|
+
allowLoop: false,
|
|
413
|
+
allowSwitch: false
|
|
414
|
+
}],
|
|
415
|
+
"no-lone-blocks": "error",
|
|
416
|
+
"no-lonely-if": "error",
|
|
417
|
+
"no-loss-of-precision": "error",
|
|
418
|
+
"no-misleading-character-class": "error",
|
|
419
|
+
"no-multi-assign": "error",
|
|
420
|
+
"no-multi-str": "error",
|
|
421
|
+
"no-new": "error",
|
|
422
|
+
"no-new-func": "error",
|
|
423
|
+
"no-new-native-nonconstructor": "error",
|
|
424
|
+
"no-new-wrappers": "error",
|
|
425
|
+
"no-nonoctal-decimal-escape": "error",
|
|
426
|
+
"no-object-constructor": "error",
|
|
427
|
+
"no-octal": "error",
|
|
428
|
+
"no-octal-escape": "error",
|
|
429
|
+
"no-promise-executor-return": ["error", { allowVoid: true }],
|
|
430
|
+
"no-proto": "error",
|
|
431
|
+
"no-prototype-builtins": "error",
|
|
432
|
+
"no-regex-spaces": "error",
|
|
433
|
+
"no-script-url": "error",
|
|
434
|
+
"no-self-assign": "error",
|
|
435
|
+
"no-self-compare": "error",
|
|
436
|
+
"no-sequences": "error",
|
|
437
|
+
"no-shadow-restricted-names": "error",
|
|
438
|
+
"no-sparse-arrays": "error",
|
|
439
|
+
"no-template-curly-in-string": "error",
|
|
440
|
+
"no-undef-init": "error",
|
|
441
|
+
"no-undefined": "off",
|
|
442
|
+
"no-unexpected-multiline": "error",
|
|
443
|
+
"no-unmodified-loop-condition": "error",
|
|
444
|
+
"no-unneeded-ternary": ["error", { defaultAssignment: false }],
|
|
445
|
+
"no-unreachable-loop": "error",
|
|
446
|
+
"no-unsafe-finally": "error",
|
|
447
|
+
"no-unsafe-optional-chaining": ["error", { disallowArithmeticOperators: true }],
|
|
448
|
+
"no-unused-vars": "off",
|
|
449
|
+
"no-useless-backreference": "error",
|
|
450
|
+
"no-useless-call": "error",
|
|
451
|
+
"no-useless-catch": "error",
|
|
452
|
+
"no-useless-computed-key": "error",
|
|
453
|
+
"no-useless-concat": "error",
|
|
454
|
+
"no-useless-rename": "error",
|
|
455
|
+
"no-useless-return": "error",
|
|
456
|
+
"no-var": "error",
|
|
457
|
+
"no-with": "error",
|
|
458
|
+
"object-shorthand": ["error", "always"],
|
|
459
|
+
"operator-assignment": ["error", "always"],
|
|
460
|
+
"prefer-arrow-callback": "error",
|
|
461
|
+
"prefer-const": ["error", {
|
|
462
|
+
destructuring: "all",
|
|
463
|
+
ignoreReadBeforeAssign: true
|
|
464
|
+
}],
|
|
465
|
+
"prefer-destructuring": "off",
|
|
466
|
+
"prefer-exponentiation-operator": "error",
|
|
467
|
+
"prefer-object-has-own": "error",
|
|
468
|
+
"prefer-object-spread": "error",
|
|
469
|
+
"prefer-regex-literals": ["error", { disallowRedundantWrapping: true }],
|
|
470
|
+
"prefer-rest-params": "error",
|
|
471
|
+
"prefer-spread": "error",
|
|
472
|
+
"prefer-template": "error",
|
|
473
|
+
"require-atomic-updates": ["error", { allowProperties: true }],
|
|
474
|
+
"sort-imports": ["error", {
|
|
475
|
+
allowSeparatedGroups: false,
|
|
476
|
+
ignoreCase: false,
|
|
477
|
+
ignoreDeclarationSort: true,
|
|
478
|
+
ignoreMemberSort: false,
|
|
479
|
+
memberSyntaxSortOrder: [
|
|
480
|
+
"none",
|
|
481
|
+
"all",
|
|
482
|
+
"multiple",
|
|
483
|
+
"single"
|
|
484
|
+
]
|
|
485
|
+
}],
|
|
486
|
+
"symbol-description": "off",
|
|
487
|
+
"use-isnan": "error",
|
|
488
|
+
"valid-typeof": "error",
|
|
489
|
+
yoda: ["error", "never"],
|
|
490
|
+
...options.overrides?.javascript
|
|
491
|
+
}
|
|
492
|
+
};
|
|
500
493
|
}
|
|
501
|
-
|
|
494
|
+
//#endregion
|
|
495
|
+
//#region src/lib/typescript.ts
|
|
496
|
+
/**
|
|
497
|
+
* @see https://typescript-eslint.io/rules/
|
|
498
|
+
*/
|
|
502
499
|
async function typescript(options) {
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
"@typescript-eslint/promise-function-async": "off",
|
|
749
|
-
"@typescript-eslint/require-array-sort-compare": "error",
|
|
750
|
-
"require-await": "off",
|
|
751
|
-
"@typescript-eslint/require-await": "error",
|
|
752
|
-
"@typescript-eslint/restrict-plus-operands": "error",
|
|
753
|
-
"@typescript-eslint/restrict-template-expressions": "error",
|
|
754
|
-
"no-return-await": "off",
|
|
755
|
-
"@typescript-eslint/return-await": ["error", "in-try-catch"],
|
|
756
|
-
"@typescript-eslint/sort-type-constituents": "off",
|
|
757
|
-
"@typescript-eslint/strict-boolean-expressions": "off",
|
|
758
|
-
"@typescript-eslint/switch-exhaustiveness-check": [
|
|
759
|
-
"error",
|
|
760
|
-
{
|
|
761
|
-
considerDefaultExhaustiveForUnions: true,
|
|
762
|
-
requireDefaultForNonUnion: true
|
|
763
|
-
}
|
|
764
|
-
],
|
|
765
|
-
"@typescript-eslint/unbound-method": "error",
|
|
766
|
-
"@typescript-eslint/unified-signatures": ["error", { ignoreDifferentlyNamedParameters: true }],
|
|
767
|
-
"@typescript-eslint/use-unknown-in-catch-callback-variable": "error",
|
|
768
|
-
...options.overrides?.typescript
|
|
769
|
-
};
|
|
770
|
-
return [
|
|
771
|
-
{
|
|
772
|
-
files,
|
|
773
|
-
languageOptions: {
|
|
774
|
-
ecmaVersion: "latest",
|
|
775
|
-
sourceType: "module",
|
|
776
|
-
parser: tsParser,
|
|
777
|
-
parserOptions: {
|
|
778
|
-
project: options.project,
|
|
779
|
-
tsconfigRootDir: process.cwd(),
|
|
780
|
-
extraFileExtensions
|
|
781
|
-
}
|
|
782
|
-
},
|
|
783
|
-
plugins: { "@typescript-eslint": tsPlugin },
|
|
784
|
-
rules
|
|
785
|
-
},
|
|
786
|
-
{
|
|
787
|
-
files: options.moduleBoundaryTypesFiles ?? ["*.ts"],
|
|
788
|
-
rules: {
|
|
789
|
-
"@typescript-eslint/explicit-module-boundary-types": "error"
|
|
790
|
-
}
|
|
791
|
-
}
|
|
792
|
-
];
|
|
500
|
+
const [tsParser, tsPlugin] = await Promise.all([interopDefault(import("@typescript-eslint/parser")), interopDefault(import("@typescript-eslint/eslint-plugin"))]);
|
|
501
|
+
const files = [Glob.Typescript];
|
|
502
|
+
if (isEnabled(options.features, "vue")) files.push(Glob.Vue);
|
|
503
|
+
const extraFileExtensions = [];
|
|
504
|
+
if (isEnabled(options.features, "vue")) extraFileExtensions.push(".vue");
|
|
505
|
+
const rules = {
|
|
506
|
+
"@typescript-eslint/adjacent-overload-signatures": "error",
|
|
507
|
+
"no-array-constructor": "off",
|
|
508
|
+
"@typescript-eslint/no-array-constructor": "error",
|
|
509
|
+
"@typescript-eslint/array-type": ["error", { default: "array" }],
|
|
510
|
+
"@typescript-eslint/ban-ts-comment": ["error", {
|
|
511
|
+
"ts-expect-error": "allow-with-description",
|
|
512
|
+
"ts-ignore": true,
|
|
513
|
+
"ts-nocheck": true,
|
|
514
|
+
"ts-check": false,
|
|
515
|
+
minimumDescriptionLength: 3
|
|
516
|
+
}],
|
|
517
|
+
"@typescript-eslint/class-literal-property-style": ["error", "fields"],
|
|
518
|
+
"class-methods-use-this": "off",
|
|
519
|
+
"@typescript-eslint/class-methods-use-this": ["error", {
|
|
520
|
+
ignoreOverrideMethods: true,
|
|
521
|
+
ignoreClassesThatImplementAnInterface: "public-fields"
|
|
522
|
+
}],
|
|
523
|
+
"@typescript-eslint/consistent-generic-constructors": ["error", "constructor"],
|
|
524
|
+
"@typescript-eslint/consistent-indexed-object-style": ["error", "record"],
|
|
525
|
+
"@typescript-eslint/consistent-type-assertions": ["error", {
|
|
526
|
+
assertionStyle: "as",
|
|
527
|
+
objectLiteralTypeAssertions: "allow-as-parameter"
|
|
528
|
+
}],
|
|
529
|
+
"@typescript-eslint/consistent-type-definitions": ["error", "interface"],
|
|
530
|
+
"dot-notation": "off",
|
|
531
|
+
"@typescript-eslint/dot-notation": ["error", { allowKeywords: true }],
|
|
532
|
+
"@typescript-eslint/explicit-function-return-type": "off",
|
|
533
|
+
"@typescript-eslint/explicit-member-accessibility": ["error", {
|
|
534
|
+
accessibility: "explicit",
|
|
535
|
+
overrides: {
|
|
536
|
+
accessors: "no-public",
|
|
537
|
+
constructors: "no-public",
|
|
538
|
+
methods: "explicit",
|
|
539
|
+
properties: "explicit",
|
|
540
|
+
parameterProperties: "explicit"
|
|
541
|
+
}
|
|
542
|
+
}],
|
|
543
|
+
"@typescript-eslint/explicit-module-boundary-types": "off",
|
|
544
|
+
"@typescript-eslint/method-signature-style": ["error", "property"],
|
|
545
|
+
camelcase: "off",
|
|
546
|
+
"@typescript-eslint/naming-convention": [
|
|
547
|
+
"error",
|
|
548
|
+
{
|
|
549
|
+
selector: ["classProperty", "variable"],
|
|
550
|
+
format: ["strictCamelCase", "UPPER_CASE"],
|
|
551
|
+
leadingUnderscore: "allow"
|
|
552
|
+
},
|
|
553
|
+
{
|
|
554
|
+
selector: [
|
|
555
|
+
"classicAccessor",
|
|
556
|
+
"classMethod",
|
|
557
|
+
"parameter",
|
|
558
|
+
"parameterProperty"
|
|
559
|
+
],
|
|
560
|
+
format: ["strictCamelCase"],
|
|
561
|
+
leadingUnderscore: "allow"
|
|
562
|
+
},
|
|
563
|
+
{
|
|
564
|
+
selector: ["function"],
|
|
565
|
+
format: ["strictCamelCase", "StrictPascalCase"]
|
|
566
|
+
},
|
|
567
|
+
{
|
|
568
|
+
selector: [
|
|
569
|
+
"class",
|
|
570
|
+
"enum",
|
|
571
|
+
"enumMember",
|
|
572
|
+
"interface",
|
|
573
|
+
"typeAlias",
|
|
574
|
+
"typeParameter"
|
|
575
|
+
],
|
|
576
|
+
format: ["StrictPascalCase"]
|
|
577
|
+
}
|
|
578
|
+
],
|
|
579
|
+
"@typescript-eslint/no-array-delete": "error",
|
|
580
|
+
"@typescript-eslint/no-base-to-string": "error",
|
|
581
|
+
"@typescript-eslint/no-confusing-non-null-assertion": "error",
|
|
582
|
+
"@typescript-eslint/no-confusing-void-expression": ["error", {
|
|
583
|
+
ignoreArrowShorthand: true,
|
|
584
|
+
ignoreVoidOperator: true
|
|
585
|
+
}],
|
|
586
|
+
"@typescript-eslint/no-duplicate-enum-values": "error",
|
|
587
|
+
"@typescript-eslint/no-duplicate-type-constituents": "error",
|
|
588
|
+
"@typescript-eslint/no-dynamic-delete": "error",
|
|
589
|
+
"@typescript-eslint/no-empty-object-type": ["error", {
|
|
590
|
+
allowInterfaces: "never",
|
|
591
|
+
allowObjectTypes: "never"
|
|
592
|
+
}],
|
|
593
|
+
"@typescript-eslint/no-explicit-any": ["error", { fixToUnknown: true }],
|
|
594
|
+
"@typescript-eslint/no-extra-non-null-assertion": "error",
|
|
595
|
+
"@typescript-eslint/no-extraneous-class": "error",
|
|
596
|
+
"@typescript-eslint/no-floating-promises": ["error", {
|
|
597
|
+
allowForKnownSafeCalls: options.knownSafeCalls ?? [],
|
|
598
|
+
allowForKnownSafePromises: options.knownSafePromises ?? [],
|
|
599
|
+
checkThenables: false,
|
|
600
|
+
ignoreIIFE: true,
|
|
601
|
+
ignoreVoid: true
|
|
602
|
+
}],
|
|
603
|
+
"@typescript-eslint/no-for-in-array": "error",
|
|
604
|
+
"no-implied-eval": "off",
|
|
605
|
+
"@typescript-eslint/no-implied-eval": "error",
|
|
606
|
+
"@typescript-eslint/no-import-type-side-effects": "error",
|
|
607
|
+
"@typescript-eslint/no-inferrable-types": "error",
|
|
608
|
+
"@typescript-eslint/no-invalid-void-type": ["error", {
|
|
609
|
+
allowInGenericTypeArguments: true,
|
|
610
|
+
allowAsThisParameter: true
|
|
611
|
+
}],
|
|
612
|
+
"no-loop-func": "off",
|
|
613
|
+
"@typescript-eslint/no-loop-func": "error",
|
|
614
|
+
"@typescript-eslint/no-meaningless-void-operator": "error",
|
|
615
|
+
"@typescript-eslint/no-misused-new": "error",
|
|
616
|
+
"@typescript-eslint/no-misused-promises": ["error", {
|
|
617
|
+
checksConditionals: true,
|
|
618
|
+
checksSpreads: true,
|
|
619
|
+
checksVoidReturn: {
|
|
620
|
+
arguments: true,
|
|
621
|
+
attributes: true,
|
|
622
|
+
properties: true,
|
|
623
|
+
returns: true,
|
|
624
|
+
variables: true
|
|
625
|
+
}
|
|
626
|
+
}],
|
|
627
|
+
"@typescript-eslint/no-misused-spread": "error",
|
|
628
|
+
"@typescript-eslint/no-mixed-enums": "error",
|
|
629
|
+
"@typescript-eslint/no-namespace": "error",
|
|
630
|
+
"@typescript-eslint/no-non-null-asserted-nullish-coalescing": "error",
|
|
631
|
+
"@typescript-eslint/no-non-null-asserted-optional-chain": "error",
|
|
632
|
+
"@typescript-eslint/no-non-null-assertion": "error",
|
|
633
|
+
"@typescript-eslint/no-redundant-type-constituents": "off",
|
|
634
|
+
"@typescript-eslint/no-require-imports": "error",
|
|
635
|
+
"no-shadow": "off",
|
|
636
|
+
"@typescript-eslint/no-shadow": "error",
|
|
637
|
+
"@typescript-eslint/no-this-alias": "error",
|
|
638
|
+
"@typescript-eslint/no-unnecessary-boolean-literal-compare": ["error", {
|
|
639
|
+
allowComparingNullableBooleansToTrue: false,
|
|
640
|
+
allowComparingNullableBooleansToFalse: true
|
|
641
|
+
}],
|
|
642
|
+
"@typescript-eslint/no-unnecessary-condition": "error",
|
|
643
|
+
"@typescript-eslint/no-unnecessary-parameter-property-assignment": "error",
|
|
644
|
+
"@typescript-eslint/no-unnecessary-qualifier": "error",
|
|
645
|
+
"@typescript-eslint/no-unnecessary-type-arguments": "error",
|
|
646
|
+
"@typescript-eslint/no-unnecessary-type-assertion": "error",
|
|
647
|
+
"@typescript-eslint/no-unnecessary-type-constraint": "error",
|
|
648
|
+
"@typescript-eslint/no-unnecessary-type-parameters": "error",
|
|
649
|
+
"@typescript-eslint/no-unsafe-argument": "off",
|
|
650
|
+
"@typescript-eslint/no-unsafe-assignment": "off",
|
|
651
|
+
"@typescript-eslint/no-unsafe-call": "error",
|
|
652
|
+
"@typescript-eslint/no-unsafe-declaration-merging": "error",
|
|
653
|
+
"@typescript-eslint/no-unsafe-function-type": "error",
|
|
654
|
+
"@typescript-eslint/no-unsafe-enum-comparison": "off",
|
|
655
|
+
"@typescript-eslint/no-unsafe-member-access": "error",
|
|
656
|
+
"@typescript-eslint/no-unsafe-return": "off",
|
|
657
|
+
"@typescript-eslint/no-unsafe-unary-minus": "error",
|
|
658
|
+
"no-unused-expressions": "off",
|
|
659
|
+
"@typescript-eslint/no-unused-expressions": ["error", { allowTaggedTemplates: true }],
|
|
660
|
+
"no-unused-private-class-members": "off",
|
|
661
|
+
"@typescript-eslint/no-unused-private-class-members": "error",
|
|
662
|
+
"no-use-before-define": "off",
|
|
663
|
+
"@typescript-eslint/no-use-before-define": ["error", {
|
|
664
|
+
functions: false,
|
|
665
|
+
enums: true,
|
|
666
|
+
typedefs: false
|
|
667
|
+
}],
|
|
668
|
+
"no-useless-constructor": "off",
|
|
669
|
+
"@typescript-eslint/no-useless-constructor": "error",
|
|
670
|
+
"@typescript-eslint/no-useless-empty-export": "error",
|
|
671
|
+
"@typescript-eslint/no-wrapper-object-types": "error",
|
|
672
|
+
"@typescript-eslint/non-nullable-type-assertion-style": "error",
|
|
673
|
+
"no-throw-literal": "off",
|
|
674
|
+
"@typescript-eslint/only-throw-error": ["error", {
|
|
675
|
+
allowThrowingAny: false,
|
|
676
|
+
allowThrowingUnknown: false
|
|
677
|
+
}],
|
|
678
|
+
"@typescript-eslint/prefer-as-const": "error",
|
|
679
|
+
"@typescript-eslint/prefer-enum-initializers": "error",
|
|
680
|
+
"@typescript-eslint/prefer-find": "error",
|
|
681
|
+
"@typescript-eslint/prefer-for-of": "error",
|
|
682
|
+
"@typescript-eslint/prefer-function-type": "off",
|
|
683
|
+
"@typescript-eslint/prefer-includes": "error",
|
|
684
|
+
"@typescript-eslint/prefer-literal-enum-member": ["error", { allowBitwiseExpressions: true }],
|
|
685
|
+
"@typescript-eslint/prefer-nullish-coalescing": ["error", {
|
|
686
|
+
ignoreTernaryTests: false,
|
|
687
|
+
ignoreConditionalTests: false,
|
|
688
|
+
ignoreMixedLogicalExpressions: false,
|
|
689
|
+
ignorePrimitives: {
|
|
690
|
+
bigint: false,
|
|
691
|
+
boolean: false,
|
|
692
|
+
number: false,
|
|
693
|
+
string: false
|
|
694
|
+
}
|
|
695
|
+
}],
|
|
696
|
+
"@typescript-eslint/prefer-optional-chain": "error",
|
|
697
|
+
"prefer-promise-reject-errors": "off",
|
|
698
|
+
"@typescript-eslint/prefer-promise-reject-errors": ["error", {
|
|
699
|
+
allowThrowingAny: false,
|
|
700
|
+
allowThrowingUnknown: false
|
|
701
|
+
}],
|
|
702
|
+
"@typescript-eslint/prefer-readonly": "error",
|
|
703
|
+
"@typescript-eslint/prefer-readonly-parameter-types": "off",
|
|
704
|
+
"@typescript-eslint/prefer-reduce-type-parameter": "error",
|
|
705
|
+
"@typescript-eslint/prefer-regexp-exec": "error",
|
|
706
|
+
"@typescript-eslint/prefer-return-this-type": "error",
|
|
707
|
+
"@typescript-eslint/prefer-string-starts-ends-with": "error",
|
|
708
|
+
"@typescript-eslint/promise-function-async": "off",
|
|
709
|
+
"@typescript-eslint/require-array-sort-compare": "error",
|
|
710
|
+
"require-await": "off",
|
|
711
|
+
"@typescript-eslint/require-await": "error",
|
|
712
|
+
"@typescript-eslint/restrict-plus-operands": "error",
|
|
713
|
+
"@typescript-eslint/restrict-template-expressions": "error",
|
|
714
|
+
"no-return-await": "off",
|
|
715
|
+
"@typescript-eslint/return-await": ["error", "in-try-catch"],
|
|
716
|
+
"@typescript-eslint/sort-type-constituents": "off",
|
|
717
|
+
"@typescript-eslint/strict-boolean-expressions": "off",
|
|
718
|
+
"@typescript-eslint/switch-exhaustiveness-check": ["error", {
|
|
719
|
+
considerDefaultExhaustiveForUnions: true,
|
|
720
|
+
requireDefaultForNonUnion: true
|
|
721
|
+
}],
|
|
722
|
+
"@typescript-eslint/unbound-method": "error",
|
|
723
|
+
"@typescript-eslint/unified-signatures": ["error", { ignoreDifferentlyNamedParameters: true }],
|
|
724
|
+
"@typescript-eslint/use-unknown-in-catch-callback-variable": "error",
|
|
725
|
+
...options.overrides?.typescript
|
|
726
|
+
};
|
|
727
|
+
return [{
|
|
728
|
+
files,
|
|
729
|
+
languageOptions: {
|
|
730
|
+
ecmaVersion: "latest",
|
|
731
|
+
sourceType: "module",
|
|
732
|
+
parser: tsParser,
|
|
733
|
+
parserOptions: {
|
|
734
|
+
project: options.project,
|
|
735
|
+
tsconfigRootDir: process.cwd(),
|
|
736
|
+
extraFileExtensions
|
|
737
|
+
}
|
|
738
|
+
},
|
|
739
|
+
plugins: { "@typescript-eslint": tsPlugin },
|
|
740
|
+
rules
|
|
741
|
+
}, {
|
|
742
|
+
files: options.moduleBoundaryTypesFiles ?? ["*.ts"],
|
|
743
|
+
rules: { "@typescript-eslint/explicit-module-boundary-types": "error" }
|
|
744
|
+
}];
|
|
793
745
|
}
|
|
794
|
-
|
|
746
|
+
//#endregion
|
|
747
|
+
//#region src/lib/perfectionist.ts
|
|
748
|
+
/**
|
|
749
|
+
* @see https://eslint-plugin-perfectionist.azat.io/rules/
|
|
750
|
+
*/
|
|
795
751
|
async function perfectionist(options) {
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
"perfectionist/sort-named-imports": [
|
|
855
|
-
"error",
|
|
856
|
-
{
|
|
857
|
-
type: "natural",
|
|
858
|
-
order: "asc"
|
|
859
|
-
}
|
|
860
|
-
],
|
|
861
|
-
"perfectionist/sort-object-types": "off",
|
|
862
|
-
"perfectionist/sort-union-types": "off",
|
|
863
|
-
"perfectionist/sort-switch-case": "off",
|
|
864
|
-
...options.overrides?.perfectionist
|
|
865
|
-
}
|
|
866
|
-
};
|
|
752
|
+
if (!isEnabled(options.features, "perfectionist")) return {};
|
|
753
|
+
return {
|
|
754
|
+
plugins: { perfectionist: await interopDefault(import("eslint-plugin-perfectionist")) },
|
|
755
|
+
rules: {
|
|
756
|
+
"perfectionist/sort-array-includes": ["error", {
|
|
757
|
+
type: "natural",
|
|
758
|
+
order: "asc",
|
|
759
|
+
ignoreCase: true,
|
|
760
|
+
fallbackSort: {
|
|
761
|
+
type: "alphabetical",
|
|
762
|
+
order: "asc"
|
|
763
|
+
}
|
|
764
|
+
}],
|
|
765
|
+
"perfectionist/sort-enums": "off",
|
|
766
|
+
"perfectionist/sort-exports": ["error", {
|
|
767
|
+
type: "line-length",
|
|
768
|
+
order: "asc",
|
|
769
|
+
ignoreCase: true,
|
|
770
|
+
fallbackSort: {
|
|
771
|
+
type: "alphabetical",
|
|
772
|
+
order: "asc"
|
|
773
|
+
}
|
|
774
|
+
}],
|
|
775
|
+
"perfectionist/sort-imports": ["error", {
|
|
776
|
+
type: "line-length",
|
|
777
|
+
order: "asc",
|
|
778
|
+
ignoreCase: true,
|
|
779
|
+
newlinesBetween: 0,
|
|
780
|
+
fallbackSort: {
|
|
781
|
+
type: "alphabetical",
|
|
782
|
+
order: "asc"
|
|
783
|
+
},
|
|
784
|
+
groups: [["side-effect-style", "side-effect"], "unknown"]
|
|
785
|
+
}],
|
|
786
|
+
"perfectionist/sort-interfaces": "off",
|
|
787
|
+
"perfectionist/sort-intersection-types": ["error", {
|
|
788
|
+
type: "natural",
|
|
789
|
+
order: "asc"
|
|
790
|
+
}],
|
|
791
|
+
"perfectionist/sort-maps": ["error", {
|
|
792
|
+
type: "natural",
|
|
793
|
+
order: "asc"
|
|
794
|
+
}],
|
|
795
|
+
"perfectionist/sort-named-exports": ["error", {
|
|
796
|
+
type: "natural",
|
|
797
|
+
order: "asc"
|
|
798
|
+
}],
|
|
799
|
+
"sort-imports": "off",
|
|
800
|
+
"perfectionist/sort-named-imports": ["error", {
|
|
801
|
+
type: "natural",
|
|
802
|
+
order: "asc"
|
|
803
|
+
}],
|
|
804
|
+
"perfectionist/sort-object-types": "off",
|
|
805
|
+
"perfectionist/sort-union-types": "off",
|
|
806
|
+
"perfectionist/sort-switch-case": "off",
|
|
807
|
+
...options.overrides?.perfectionist
|
|
808
|
+
}
|
|
809
|
+
};
|
|
867
810
|
}
|
|
868
|
-
|
|
811
|
+
//#endregion
|
|
812
|
+
//#region src/index.ts
|
|
869
813
|
async function defineConfig(options) {
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
ignores
|
|
880
|
-
]);
|
|
881
|
-
return objects;
|
|
814
|
+
const ignores = { ignores: [...getIgnores(), ...options.ignores ?? []] };
|
|
815
|
+
return await Promise.all([
|
|
816
|
+
javascript(options),
|
|
817
|
+
...await typescript(options),
|
|
818
|
+
...await vue(options),
|
|
819
|
+
perfectionist(options),
|
|
820
|
+
unicorn(options),
|
|
821
|
+
ignores
|
|
822
|
+
]);
|
|
882
823
|
}
|
|
883
|
-
|
|
824
|
+
//#endregion
|
|
884
825
|
export { defineConfig };
|