@unshared/eslint-config 0.0.1
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/LICENSE.md +21 -0
- package/dist/index.cjs +1358 -0
- package/package.json +69 -0
package/dist/index.cjs
ADDED
@@ -0,0 +1,1358 @@
|
|
1
|
+
"use strict";
|
2
|
+
var vueParser = require("vue-eslint-parser"), tslint = require("typescript-eslint"), vuePlugin = require("eslint-plugin-vue"), vitestPlugin = require("eslint-plugin-vitest"), unicornPlugin = require("eslint-plugin-unicorn"), stylisticPlugin = require("@stylistic/eslint-plugin"), eslintrc = require("@eslint/eslintrc"), nodePlugin = require("eslint-plugin-n"), jsonc = require("eslint-plugin-jsonc"), pluginJsdoc = require("eslint-plugin-jsdoc"), javascriptPlugin = require("@eslint/js"), eslintCommentsPlugin = require("eslint-plugin-eslint-comments"), pluginAntfu = require("eslint-plugin-antfu");
|
3
|
+
const VUE_RECOMMENDED_RULES = vuePlugin.configs?.["flat/recommended"].rules;
|
4
|
+
function vue() {
|
5
|
+
return [
|
6
|
+
{
|
7
|
+
files: [
|
8
|
+
"**/*.vue"
|
9
|
+
],
|
10
|
+
languageOptions: {
|
11
|
+
globals: {
|
12
|
+
computed: "readonly",
|
13
|
+
defineEmits: "readonly",
|
14
|
+
defineExpose: "readonly",
|
15
|
+
defineProps: "readonly",
|
16
|
+
onMounted: "readonly",
|
17
|
+
onUnmounted: "readonly",
|
18
|
+
reactive: "readonly",
|
19
|
+
ref: "readonly",
|
20
|
+
shallowReactive: "readonly",
|
21
|
+
shallowRef: "readonly",
|
22
|
+
toRef: "readonly",
|
23
|
+
toRefs: "readonly",
|
24
|
+
watch: "readonly",
|
25
|
+
watchEffect: "readonly"
|
26
|
+
},
|
27
|
+
parser: vueParser,
|
28
|
+
parserOptions: {
|
29
|
+
ecmaFeatures: { jsx: !1 },
|
30
|
+
ecmaVersion: "latest",
|
31
|
+
parser: tslint.parser,
|
32
|
+
sourceType: "module"
|
33
|
+
}
|
34
|
+
},
|
35
|
+
plugins: {
|
36
|
+
"@typescript-eslint": tslint.plugin,
|
37
|
+
vue: vuePlugin
|
38
|
+
},
|
39
|
+
rules: {
|
40
|
+
...VUE_RECOMMENDED_RULES,
|
41
|
+
/**
|
42
|
+
* Enforces consistent usage of type imports. This rule will enforce the use
|
43
|
+
* of `type` imports to make it easier for the Vue SFC compiler to analyze
|
44
|
+
* the code and infer the dependency graph correctly.
|
45
|
+
*
|
46
|
+
* @see https://typescript-eslint.io/rules/consistent-type-imports
|
47
|
+
* @see https://vuejs.github.io/vetur/guide/FAQ.html#why-does-vetur-show-cannot-find-module-xxx
|
48
|
+
*/
|
49
|
+
"@typescript-eslint/consistent-type-imports": ["error", {
|
50
|
+
disallowTypeAnnotations: !1,
|
51
|
+
fixStyle: "inline-type-imports",
|
52
|
+
prefer: "type-imports"
|
53
|
+
}],
|
54
|
+
"no-undef": "off",
|
55
|
+
/**
|
56
|
+
* Disable the `no-unused-vars` rule because as it may trigger false positives
|
57
|
+
* when using the Composition API.
|
58
|
+
*/
|
59
|
+
"no-unused-vars": "off",
|
60
|
+
/**
|
61
|
+
* Since we may use the auto-import feature of Nuxt / unplugin-autoimport,
|
62
|
+
* we may have access to global variables that are not known to ESLint.
|
63
|
+
*
|
64
|
+
* @see https://eslint.org/docs/latest/rules/no-undef
|
65
|
+
*/
|
66
|
+
semi: "off",
|
67
|
+
// extensions
|
68
|
+
"vue/array-bracket-spacing": ["error", "never"],
|
69
|
+
"vue/arrow-spacing": ["error", { after: !0, before: !0 }],
|
70
|
+
"vue/block-lang": ["error", { script: { lang: "ts" } }],
|
71
|
+
/**
|
72
|
+
* Enforce the order of the top-level properties in the component. This rule
|
73
|
+
* helps to maintain consistency and readability by enforcing a predictable
|
74
|
+
* order of the top-level properties in the component.
|
75
|
+
*
|
76
|
+
* @see https://eslint.vuejs.org/rules/ordered-component-elements.html
|
77
|
+
*/
|
78
|
+
"vue/block-order": ["error", {
|
79
|
+
order: [
|
80
|
+
"docs",
|
81
|
+
"script",
|
82
|
+
"template",
|
83
|
+
"style"
|
84
|
+
]
|
85
|
+
}],
|
86
|
+
"vue/block-spacing": ["error", "always"],
|
87
|
+
// reactivity transform
|
88
|
+
"vue/block-tag-newline": ["error", {
|
89
|
+
multiline: "always",
|
90
|
+
singleline: "always"
|
91
|
+
}],
|
92
|
+
"vue/brace-style": ["error", "stroustrup", { allowSingleLine: !0 }],
|
93
|
+
"vue/comma-dangle": ["error", "always-multiline"],
|
94
|
+
"vue/comma-spacing": ["error", { after: !0, before: !1 }],
|
95
|
+
"vue/comma-style": ["error", "last"],
|
96
|
+
/**
|
97
|
+
* Enforce use of the Composition API and TypeScript. This rule forbids the
|
98
|
+
* use of the Options API and JavaScript in Vue components for better
|
99
|
+
* consistency and maintainability.
|
100
|
+
*
|
101
|
+
* @see https://eslint.vuejs.org/rules/vue/prefer-define-options.html
|
102
|
+
*/
|
103
|
+
"vue/component-api-style": ["error", ["script-setup"]],
|
104
|
+
/**
|
105
|
+
* Enforce the component name casing to be PascalCase. This rules helps identify
|
106
|
+
* and distinguish between components and HTML elements. It also helps to avoid
|
107
|
+
* conflicts with existing and future HTML elements.
|
108
|
+
*
|
109
|
+
* @see https://eslint.vuejs.org/rules/component-name-in-template-casing.html
|
110
|
+
*/
|
111
|
+
"vue/component-name-in-template-casing": ["error", "PascalCase", {
|
112
|
+
ignores: ["/\\./"],
|
113
|
+
registeredComponentsOnly: !1
|
114
|
+
}],
|
115
|
+
"vue/component-options-name-casing": ["error", "PascalCase"],
|
116
|
+
"vue/custom-event-name-casing": ["error", "camelCase"],
|
117
|
+
"vue/define-macros-order": ["error", {
|
118
|
+
order: ["defineProps", "defineEmits"]
|
119
|
+
}],
|
120
|
+
"vue/dot-location": ["error", "property"],
|
121
|
+
"vue/dot-notation": ["error", { allowKeywords: !0 }],
|
122
|
+
"vue/eqeqeq": ["error", "smart"],
|
123
|
+
"vue/first-attribute-linebreak": ["error", {
|
124
|
+
multiline: "below",
|
125
|
+
singleline: "beside"
|
126
|
+
}],
|
127
|
+
"vue/html-closing-bracket-newline": ["error", {
|
128
|
+
multiline: "never",
|
129
|
+
selfClosingTag: {
|
130
|
+
multiline: "always",
|
131
|
+
singleline: "never"
|
132
|
+
},
|
133
|
+
singleline: "never"
|
134
|
+
}],
|
135
|
+
"vue/html-comment-content-newline": ["error", {
|
136
|
+
multiline: "always",
|
137
|
+
singleline: "never"
|
138
|
+
}],
|
139
|
+
/**
|
140
|
+
* Enforce consistent spacing between HTML comments and their content.
|
141
|
+
*
|
142
|
+
* @see https://eslint.vuejs.org/rules/html-comment-content-spacing.html
|
143
|
+
* @see https://eslint.vuejs.org/rules/html-comment-content-newline.html
|
144
|
+
*/
|
145
|
+
"vue/html-comment-content-spacing": ["error", "always"],
|
146
|
+
/**
|
147
|
+
* Enforce consistent spacing between HTML / Component tags. This makes it
|
148
|
+
* easier to read and understand the structure of the component.
|
149
|
+
*
|
150
|
+
* @see https://eslint.vuejs.org/rules/padding-line-between-blocks.html
|
151
|
+
* @see https://eslint.vuejs.org/rules/padding-line-between-tags.html
|
152
|
+
*/
|
153
|
+
"vue/html-comment-indent": ["error", 2],
|
154
|
+
/**
|
155
|
+
* Enforce consistent spacing and newlines in the template. This rule helps
|
156
|
+
* to maintain consistency and readability by enforcing a predictable
|
157
|
+
*
|
158
|
+
* @see https://eslint.vuejs.org/rules/html-indent.html
|
159
|
+
* @see https://eslint.vuejs.org/rules/max-attributes-per-line.html
|
160
|
+
* @see https://eslint.vuejs.org/rules/html-closing-bracket-newline.html
|
161
|
+
*/
|
162
|
+
"vue/html-indent": ["error", 2, {
|
163
|
+
alignAttributesVertically: !0,
|
164
|
+
attribute: 1,
|
165
|
+
baseIndent: 1,
|
166
|
+
closeBracket: 0,
|
167
|
+
ignores: []
|
168
|
+
}],
|
169
|
+
// 'vue/func-call-spacing': ['off', 'never'],
|
170
|
+
"vue/key-spacing": ["error", { afterColon: !0, beforeColon: !1 }],
|
171
|
+
"vue/keyword-spacing": ["error", { after: !0, before: !0 }],
|
172
|
+
"vue/max-attributes-per-line": ["error", {
|
173
|
+
multiline: { max: 1 },
|
174
|
+
singleline: { max: 5 }
|
175
|
+
}],
|
176
|
+
/**
|
177
|
+
* Allow single-word component names. This rule is disabled because we use
|
178
|
+
* pascal-casing to distinguish between components and HTML elements.
|
179
|
+
*
|
180
|
+
* @see https://eslint.vuejs.org/rules/multi-word-component-names.html
|
181
|
+
*/
|
182
|
+
"vue/multi-word-component-names": "off",
|
183
|
+
"vue/multiline-html-element-content-newline": ["error", {
|
184
|
+
allowEmptyLines: !0,
|
185
|
+
ignores: [],
|
186
|
+
ignoreWhenEmpty: !0
|
187
|
+
}],
|
188
|
+
"vue/no-constant-condition": "warn",
|
189
|
+
"vue/no-empty-pattern": "error",
|
190
|
+
"vue/no-extra-parens": ["error", "functions"],
|
191
|
+
"vue/no-irregular-whitespace": "error",
|
192
|
+
"vue/no-loss-of-precision": "error",
|
193
|
+
"vue/no-restricted-syntax": [
|
194
|
+
"error",
|
195
|
+
"DebuggerStatement",
|
196
|
+
"LabeledStatement",
|
197
|
+
"WithStatement"
|
198
|
+
],
|
199
|
+
"vue/no-restricted-v-bind": ["error", "/^v-/"],
|
200
|
+
/**
|
201
|
+
* Reports the destructuring or member expression of props passed to setup
|
202
|
+
* causing the value to lose reactivity. This rule helps to avoid common
|
203
|
+
* pitfalls when using the Composition API.
|
204
|
+
*
|
205
|
+
* @see https://eslint.vuejs.org/rules/no-setup-props-reactivity-loss.html
|
206
|
+
*/
|
207
|
+
"vue/no-setup-props-reactivity-loss": "error",
|
208
|
+
"vue/no-sparse-arrays": "error",
|
209
|
+
"vue/no-unused-emit-declarations": "error",
|
210
|
+
"vue/no-use-v-else-with-v-for": "error",
|
211
|
+
/**
|
212
|
+
* Disallow v-if in v-for. This rule helps to avoid common pitfalls when
|
213
|
+
* using v-if and v-for together in the same element.
|
214
|
+
*
|
215
|
+
* @see https://eslint.vuejs.org/rules/no-use-v-if-with-v-for.html
|
216
|
+
*/
|
217
|
+
"vue/no-use-v-if-with-v-for": "error",
|
218
|
+
"vue/no-useless-v-bind": "error",
|
219
|
+
"vue/no-v-html": "off",
|
220
|
+
"vue/no-v-text-v-html-on-component": "error",
|
221
|
+
"vue/object-curly-newline": ["error", { consistent: !0, multiline: !0 }],
|
222
|
+
"vue/object-curly-spacing": ["error", "always"],
|
223
|
+
"vue/object-shorthand": [
|
224
|
+
"error",
|
225
|
+
"always",
|
226
|
+
{
|
227
|
+
avoidQuotes: !0,
|
228
|
+
ignoreConstructors: !1
|
229
|
+
}
|
230
|
+
],
|
231
|
+
"vue/operator-linebreak": ["error", "before"],
|
232
|
+
"vue/padding-line-between-blocks": ["error", "always"],
|
233
|
+
"vue/padding-line-between-tags": ["error", [
|
234
|
+
{ blankLine: "consistent", next: "*", prev: "*" }
|
235
|
+
]],
|
236
|
+
"vue/prefer-define-options": "error",
|
237
|
+
"vue/prefer-import-from-vue": "off",
|
238
|
+
"vue/prefer-separate-static-class": "error",
|
239
|
+
"vue/prefer-template": "error",
|
240
|
+
"vue/quote-props": ["error", "consistent-as-needed"],
|
241
|
+
"vue/require-default-prop": "off",
|
242
|
+
/**
|
243
|
+
* Enforce the declaration of emits in the setup function and warn on unused
|
244
|
+
* emits declarations. This rule helps reduce the risk stale code.
|
245
|
+
*
|
246
|
+
* @see https://eslint.vuejs.org/rules/require-explicit-emits.html
|
247
|
+
* @see https://eslint.vuejs.org/rules/no-unused-emit-declarations.html
|
248
|
+
*/
|
249
|
+
"vue/require-explicit-emits": "error",
|
250
|
+
"vue/require-prop-types": "off",
|
251
|
+
"vue/space-in-parens": ["error", "never"],
|
252
|
+
"vue/space-infix-ops": "error",
|
253
|
+
"vue/space-unary-ops": ["error", { nonwords: !1, words: !0 }],
|
254
|
+
"vue/template-curly-spacing": "error",
|
255
|
+
"vue/v-on-handler-style": ["error", "inline"],
|
256
|
+
/**
|
257
|
+
* Enforce the `@` shorthand over `v-on:` and only allow inline callbacks.
|
258
|
+
* This rule helps to maintain consistency and readability by enforcing a
|
259
|
+
* predictable order of the event handlers in the component.
|
260
|
+
*
|
261
|
+
* @see https://eslint.vuejs.org/rules/v-on-style.html
|
262
|
+
* @see https://eslint.vuejs.org/rules/v-on-handler-style.html
|
263
|
+
*/
|
264
|
+
"vue/v-on-style": ["error", "shorthand"]
|
265
|
+
}
|
266
|
+
}
|
267
|
+
];
|
268
|
+
}
|
269
|
+
function vitest() {
|
270
|
+
return [
|
271
|
+
{
|
272
|
+
files: [
|
273
|
+
"**/*.{ts,mts,cts,tsx,d.ts}",
|
274
|
+
"**/*.{js,mjs,cjs,jsx}"
|
275
|
+
],
|
276
|
+
plugins: {
|
277
|
+
vitest: vitestPlugin
|
278
|
+
},
|
279
|
+
rules: {
|
280
|
+
/**
|
281
|
+
* Inject all configuration from eslint-plugin-vitest.
|
282
|
+
*
|
283
|
+
* @see https://github.com/veritem/eslint-plugin-vitest/tree/main?tab=readme-ov-file#rules
|
284
|
+
*/
|
285
|
+
...vitestPlugin.configs.all.rules,
|
286
|
+
/**
|
287
|
+
* This rule aims to enforce having at least one expectation
|
288
|
+
* in test body to ensure that the test is actually testing something.
|
289
|
+
*
|
290
|
+
* @see https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/expect-expect.md
|
291
|
+
*/
|
292
|
+
"vitest/expect-expect": ["error", {
|
293
|
+
assertFunctionNames: [
|
294
|
+
"expect",
|
295
|
+
"expectTypeOf"
|
296
|
+
]
|
297
|
+
}],
|
298
|
+
/**
|
299
|
+
* Disable the conditional test rule as it is prevent's us to use in-source
|
300
|
+
* testing when using the `if (import.meta.vitest)` condition. Also disable
|
301
|
+
* the rule that prevents the use of if-else statements in tests as we want
|
302
|
+
* to use it to test type predicates.
|
303
|
+
*
|
304
|
+
* @see https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-conditional-in-test.md
|
305
|
+
*/
|
306
|
+
"vitest/no-conditional-in-test": "off",
|
307
|
+
"vitest/no-conditional-tests": "off",
|
308
|
+
/**
|
309
|
+
* Allow hooks to be defined at the top-level of the test file.
|
310
|
+
*
|
311
|
+
* @see https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-hooks.md
|
312
|
+
*/
|
313
|
+
"vitest/no-hooks": "off",
|
314
|
+
/**
|
315
|
+
* Disable the rule that enforces the use of `expect.assertions` in tests.
|
316
|
+
* As much as this rule enforces a best-practice, it is not always necessary.
|
317
|
+
*
|
318
|
+
* @see https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/prefer-expect-assertions.md
|
319
|
+
*/
|
320
|
+
"vitest/prefer-expect-assertions": "off",
|
321
|
+
/**
|
322
|
+
* Some functions may have a single test case, and it is not necessary
|
323
|
+
* to wrap them in a describe block.
|
324
|
+
*
|
325
|
+
* @see https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/require-top-level-describe.md
|
326
|
+
*/
|
327
|
+
"vitest/require-top-level-describe": "off",
|
328
|
+
/**
|
329
|
+
* Enforce rule titles starts with 'should'. This is a convention
|
330
|
+
* to force the developer to write the test in a way that it reads
|
331
|
+
* like a sentence.
|
332
|
+
*
|
333
|
+
* @see https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/valid-title.md
|
334
|
+
*/
|
335
|
+
"vitest/valid-title": ["error", {
|
336
|
+
ignoreTypeOfDescribeName: !0,
|
337
|
+
mustMatch: {
|
338
|
+
test: ["^should"]
|
339
|
+
}
|
340
|
+
}]
|
341
|
+
// /**
|
342
|
+
// * Allow runt
|
343
|
+
// */
|
344
|
+
// 'vitest/require-hook': 'off',
|
345
|
+
}
|
346
|
+
}
|
347
|
+
];
|
348
|
+
}
|
349
|
+
const UNICORN_RECOMMENDED_RULES = unicornPlugin.configs.recommended.rules;
|
350
|
+
function unicorn() {
|
351
|
+
return [
|
352
|
+
{
|
353
|
+
plugins: {
|
354
|
+
unicorn: unicornPlugin
|
355
|
+
},
|
356
|
+
rules: {
|
357
|
+
...UNICORN_RECOMMENDED_RULES,
|
358
|
+
/**
|
359
|
+
* Improve regexes by making them shorter, consistent, and safer. This rule
|
360
|
+
* aims to improve readability and consistency of regexes while also
|
361
|
+
* mitigating regex denial of service attacks by disallowing potentially
|
362
|
+
* catastrophic backtracking.
|
363
|
+
*
|
364
|
+
* @see https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/better-regex.md
|
365
|
+
*/
|
366
|
+
"unicorn/better-regex": "error",
|
367
|
+
/**
|
368
|
+
* Enforce the catch clause parameter name to be named `error`. This rule
|
369
|
+
* aims to enforce a consistent parameter name in catch clauses. The name
|
370
|
+
* `error` is the most commonly used name for the parameter that is passed
|
371
|
+
* to the catch clause.
|
372
|
+
*
|
373
|
+
* @see https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/catch-error-name.md
|
374
|
+
*/
|
375
|
+
"unicorn/catch-error-name": ["error", {
|
376
|
+
name: "error"
|
377
|
+
}],
|
378
|
+
"unicorn/consistent-function-scoping": "off",
|
379
|
+
"unicorn/error-message": "error",
|
380
|
+
"unicorn/escape-case": "error",
|
381
|
+
/**
|
382
|
+
* Enforce the use of camelCase or PascalCase when naming folders, files and
|
383
|
+
* variables. This rule aims to enforce a consistent naming convention for
|
384
|
+
* filenames, directory names, and variable names.
|
385
|
+
*
|
386
|
+
* @see https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/filename-case.md
|
387
|
+
*/
|
388
|
+
"unicorn/filename-case": ["error", {
|
389
|
+
cases: {
|
390
|
+
camelCase: !0,
|
391
|
+
pascalCase: !0
|
392
|
+
},
|
393
|
+
ignore: [
|
394
|
+
"^[A-Z]+(.md)?$"
|
395
|
+
]
|
396
|
+
}],
|
397
|
+
/**
|
398
|
+
* Disable the recommended import style rules. We want to be able to use both
|
399
|
+
* named and default imports in our codebase.
|
400
|
+
*
|
401
|
+
* @see https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/import-style.md
|
402
|
+
*/
|
403
|
+
"unicorn/import-style": "off",
|
404
|
+
"unicorn/no-array-callback-reference": "off",
|
405
|
+
"unicorn/no-array-for-each": "off",
|
406
|
+
"unicorn/no-array-instanceof": "error",
|
407
|
+
"unicorn/no-new-buffer": "error",
|
408
|
+
"unicorn/no-static-only-class": "off",
|
409
|
+
/**
|
410
|
+
* Disallow unsafe regular expressions. Regular expressions can be unsafe
|
411
|
+
* when they are too complex and can cause catastrophic backtracking. This
|
412
|
+
* rule disallows regular expressions that can lead to catastrophic
|
413
|
+
*
|
414
|
+
* @see https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-unsafe-regex.md
|
415
|
+
*/
|
416
|
+
"unicorn/no-unsafe-regex": "error",
|
417
|
+
"unicorn/number-literal-case": "error",
|
418
|
+
/**
|
419
|
+
* Enforces a convention of grouping digits using numeric separators.
|
420
|
+
* Long numbers can become really hard to read, so cutting it into groups
|
421
|
+
* of digits, separated with a _, is important to keep your code clear.
|
422
|
+
*
|
423
|
+
* @see https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/numeric-separators-style.md
|
424
|
+
*/
|
425
|
+
"unicorn/numeric-separators-style": ["error", {
|
426
|
+
onlyIfContainsSeparator: !0
|
427
|
+
}],
|
428
|
+
"unicorn/prefer-code-point": "off",
|
429
|
+
"unicorn/prefer-exponentiation-operator": "error",
|
430
|
+
"unicorn/prefer-includes": "error",
|
431
|
+
"unicorn/prefer-module": "off",
|
432
|
+
"unicorn/prefer-starts-ends-with": "error",
|
433
|
+
"unicorn/prefer-switch": "off",
|
434
|
+
"unicorn/prefer-text-content": "error",
|
435
|
+
"unicorn/prefer-type-error": "error",
|
436
|
+
"unicorn/prevent-abbreviations": ["error", {
|
437
|
+
allowList: {
|
438
|
+
args: !0,
|
439
|
+
dir: !0,
|
440
|
+
fn: !0,
|
441
|
+
i: !0,
|
442
|
+
j: !0,
|
443
|
+
k: !0,
|
444
|
+
props: !0,
|
445
|
+
Props: !0,
|
446
|
+
ref: !0,
|
447
|
+
v: !0,
|
448
|
+
x: !0,
|
449
|
+
y: !0,
|
450
|
+
z: !0
|
451
|
+
}
|
452
|
+
}],
|
453
|
+
"unicorn/throw-new-error": "error"
|
454
|
+
}
|
455
|
+
}
|
456
|
+
];
|
457
|
+
}
|
458
|
+
const { recommendedTypeChecked, stylisticTypeChecked } = tslint.configs, TSLING_DEFAULT_RULES = [recommendedTypeChecked, stylisticTypeChecked].flat().map((x) => x.rules).reduce((accumulator, x) => ({ ...accumulator, ...x }), {});
|
459
|
+
function typescript() {
|
460
|
+
return [
|
461
|
+
{
|
462
|
+
files: [
|
463
|
+
"**/*.ts",
|
464
|
+
"**/*.tsx"
|
465
|
+
],
|
466
|
+
languageOptions: {
|
467
|
+
// @ts-expect-error: ignore
|
468
|
+
parser: tslint.parser,
|
469
|
+
parserOptions: {
|
470
|
+
project: [
|
471
|
+
"./tsconfig.json",
|
472
|
+
"./packages/*/tsconfig.json"
|
473
|
+
]
|
474
|
+
}
|
475
|
+
},
|
476
|
+
plugins: {
|
477
|
+
"@typescript-eslint": tslint.plugin
|
478
|
+
},
|
479
|
+
rules: {
|
480
|
+
...TSLING_DEFAULT_RULES,
|
481
|
+
/**
|
482
|
+
* Enforce consistent Array types. This rule aims to standardize the usage of
|
483
|
+
* `Array<T>` over `T[]`, and `ReadonlyArray<T>` over `readonly T[]`. Allows
|
484
|
+
* for reduced cognitive load when reading code that uses arrays. Exceptions
|
485
|
+
* are allowed for primitive or simple types.
|
486
|
+
*
|
487
|
+
* @see https://typescript-eslint.io/rules/array-type
|
488
|
+
*/
|
489
|
+
"@typescript-eslint/array-type": ["error", {
|
490
|
+
default: "array-simple",
|
491
|
+
readonly: "array-simple"
|
492
|
+
}],
|
493
|
+
"@typescript-eslint/ban-ts-comment": ["error", {
|
494
|
+
"ts-check": !1,
|
495
|
+
"ts-expect-error": "allow-with-description",
|
496
|
+
"ts-ignore": !1,
|
497
|
+
"ts-nocheck": !1
|
498
|
+
}],
|
499
|
+
"@typescript-eslint/ban-ts-ignore": "off",
|
500
|
+
"@typescript-eslint/ban-types": "off",
|
501
|
+
"@typescript-eslint/brace-style": ["error", "stroustrup", {
|
502
|
+
allowSingleLine: !0
|
503
|
+
}],
|
504
|
+
"@typescript-eslint/camelcase": "off",
|
505
|
+
/**
|
506
|
+
* Enforce a trailing comma after the last element or property in a multiline
|
507
|
+
* list of properties or elements. This rule improves the clarity of diffs
|
508
|
+
* when an item is added or removed from an object or array.
|
509
|
+
*
|
510
|
+
* @see https://typescript-eslint.io/rules/comma-dangle
|
511
|
+
*/
|
512
|
+
"@typescript-eslint/comma-dangle": ["error", "always-multiline"],
|
513
|
+
"@typescript-eslint/comma-spacing": ["error"],
|
514
|
+
/**
|
515
|
+
* Enforce `Record<K, T>` instead of `{ [K]: T }`. This rule aims to standardize
|
516
|
+
* the declaration of Record types and helps prevent bugs caused by typos.
|
517
|
+
*
|
518
|
+
* @see https://typescript-eslint.io/rules/consistent-indexed-object-style
|
519
|
+
*/
|
520
|
+
"@typescript-eslint/consistent-indexed-object-style": ["error", "record"],
|
521
|
+
/**
|
522
|
+
* Enforces `interface` usage over `type` usage. This allows for better consistency
|
523
|
+
* and identification of objects that can be augmented while favoring separation
|
524
|
+
* between interfaces describing objects and types describing primitives and/or unions.
|
525
|
+
*
|
526
|
+
* @see https://typescript-eslint.io/rules/consistent-type-definitions
|
527
|
+
*/
|
528
|
+
"@typescript-eslint/consistent-type-definitions": ["error", "interface"],
|
529
|
+
/**
|
530
|
+
* Enforces consistent usage of type imports. This rule will disallow the use of
|
531
|
+
* `import type` or `import { type }` to reduce the cognitive load of reasoning
|
532
|
+
* about imports. Typically, the bundler will know which imports are types and
|
533
|
+
* strip them out.
|
534
|
+
*
|
535
|
+
* @see https://typescript-eslint.io/rules/consistent-type-imports
|
536
|
+
*/
|
537
|
+
"@typescript-eslint/consistent-type-imports": ["error", {
|
538
|
+
disallowTypeAnnotations: !1,
|
539
|
+
prefer: "no-type-imports"
|
540
|
+
}],
|
541
|
+
"@typescript-eslint/explicit-function-return-type": "off",
|
542
|
+
"@typescript-eslint/explicit-member-accessibility": "off",
|
543
|
+
"@typescript-eslint/explicit-module-boundary-types": "off",
|
544
|
+
/**
|
545
|
+
* Enforce an indent of 2 spaces. Aims to reduce visual noise and maintain
|
546
|
+
* readability of code when viewed on GitHub or GitLab.
|
547
|
+
*
|
548
|
+
* @see https://typescript-eslint.io/rules/indent
|
549
|
+
*/
|
550
|
+
"@typescript-eslint/indent": ["error", 2],
|
551
|
+
/**
|
552
|
+
* Enforce no comma/semi-columns in interfaces. This rule aims to maintain
|
553
|
+
* consistency around the use or omission of trailing semicolons. Helps
|
554
|
+
* reduce the visual noise in the codebase. Also helps to prevent errors
|
555
|
+
* when refactoring and adding new lines.
|
556
|
+
*
|
557
|
+
* @see https://typescript-eslint.io/rules/member-delimiter-style
|
558
|
+
*/
|
559
|
+
"@typescript-eslint/member-delimiter-style": ["error", {
|
560
|
+
multiline: { delimiter: "none" }
|
561
|
+
}],
|
562
|
+
"@typescript-eslint/no-empty-function": "off",
|
563
|
+
"@typescript-eslint/no-empty-interface": "off",
|
564
|
+
"@typescript-eslint/no-explicit-any": "off",
|
565
|
+
"@typescript-eslint/no-namespace": "off",
|
566
|
+
"@typescript-eslint/no-non-null-assertion": "off",
|
567
|
+
"@typescript-eslint/no-parameter-properties": "off",
|
568
|
+
"@typescript-eslint/no-redeclare": "error",
|
569
|
+
"@typescript-eslint/no-unused-expressions": "error",
|
570
|
+
"@typescript-eslint/no-unused-vars": ["error", {
|
571
|
+
argsIgnorePattern: "^_"
|
572
|
+
}],
|
573
|
+
"@typescript-eslint/no-use-before-define": ["error", {
|
574
|
+
classes: !1,
|
575
|
+
functions: !1,
|
576
|
+
variables: !0
|
577
|
+
}],
|
578
|
+
/**
|
579
|
+
* Enforce consistent spacing inside braces. This rule aims to reduce the
|
580
|
+
* cognitive load of reasoning about code by enforcing a consistent style.
|
581
|
+
*
|
582
|
+
* @see https://typescript-eslint.io/rules/object-curly-spacing
|
583
|
+
*/
|
584
|
+
"@typescript-eslint/object-curly-spacing": ["error", "always"],
|
585
|
+
/**
|
586
|
+
* Enforce the use of `@ts-expect-error` over `@ts-ignore` to silence TypeScript
|
587
|
+
* errors. This rule aims to ensure that TypeScript errors are never silenced
|
588
|
+
* without explanation or justification. When an error is fixed, the
|
589
|
+
* `@ts-expect-error` forces the developer to remove the comment.
|
590
|
+
*
|
591
|
+
* @see https://typescript-eslint.io/rules/prefer-ts-expect-error
|
592
|
+
* @see https://typescript-eslint.io/rules/ban-ts-comment
|
593
|
+
*/
|
594
|
+
"@typescript-eslint/prefer-ts-expect-error": "error",
|
595
|
+
"@typescript-eslint/semi": ["error", "never"],
|
596
|
+
/**
|
597
|
+
* Disable this rule as it may conflict with the `perfectionist/sort-imports` rule.
|
598
|
+
*
|
599
|
+
* @see https://typescript-eslint.io/rules/sort-type-constituents
|
600
|
+
*/
|
601
|
+
"@typescript-eslint/sort-type-constituents": "off",
|
602
|
+
/**
|
603
|
+
* Enforce spacing around the `:` in type annotations. This rule aims to
|
604
|
+
* maintain consistency and reduce visual noise in the codebase.
|
605
|
+
*
|
606
|
+
* @see https://typescript-eslint.io/rules/type-annotation-spacing
|
607
|
+
*/
|
608
|
+
"@typescript-eslint/type-annotation-spacing": ["error", {}],
|
609
|
+
/**
|
610
|
+
* Age-old debate over how to style braces. This rule aims to reduce the
|
611
|
+
* cognitive load of reasoning about code by enforcing a consistent style.
|
612
|
+
*
|
613
|
+
* @see https://typescript-eslint.io/rules/brace-style
|
614
|
+
*/
|
615
|
+
"brace-style": "off",
|
616
|
+
"comma-dangle": "off",
|
617
|
+
/**
|
618
|
+
* Enforce standard comma-spacing. Normalizes the codebase and reduces
|
619
|
+
* cognitive load when reasoning about code.
|
620
|
+
*
|
621
|
+
* @see https://typescript-eslint.io/rules/comma-spacing
|
622
|
+
*/
|
623
|
+
"comma-spacing": "off",
|
624
|
+
"import/named": "off",
|
625
|
+
indent: "off",
|
626
|
+
/**
|
627
|
+
* In JavaScript, it’s possible to redeclare the same variable name using var.
|
628
|
+
* This can lead to confusion as to where the variable is actually declared and initialized.
|
629
|
+
*
|
630
|
+
* @see https://typescript-eslint.io/rules/no-redeclare
|
631
|
+
*/
|
632
|
+
"no-redeclare": "off",
|
633
|
+
/**
|
634
|
+
* Enforce no unused expressions. This rule aims to prevent dead code and
|
635
|
+
* reduce the likelihood of bugs.
|
636
|
+
*
|
637
|
+
* @see https://typescript-eslint.io/rules/no-unused-expressions
|
638
|
+
*/
|
639
|
+
"no-unused-expressions": "off",
|
640
|
+
/**
|
641
|
+
* Enforce no unused variables. Helps keep the codebase clean and reduces
|
642
|
+
* the chance of bugs from side-effects.
|
643
|
+
*
|
644
|
+
* @see https://typescript-eslint.io/rules/@typescript-eslint/no-unused-vars
|
645
|
+
*/
|
646
|
+
"no-unused-vars": "off",
|
647
|
+
/**
|
648
|
+
* Enforce sequential declarations in the same block. This rule aims to
|
649
|
+
* enforce a top to bottom ordering of variable and type declarations.
|
650
|
+
* This reduces the likelihood of a developer skipping over a declaration
|
651
|
+
* when modifying code.
|
652
|
+
*
|
653
|
+
* @see https://typescript-eslint.io/rules/no-use-before-define
|
654
|
+
*/
|
655
|
+
"no-use-before-define": "off",
|
656
|
+
"no-useless-constructor": "off",
|
657
|
+
"object-curly-spacing": "off",
|
658
|
+
/**
|
659
|
+
* Enforce no semi-colons. This rule aims to maintain consistency around the
|
660
|
+
* use or omission of trailing semicolons. Helps reduce the visual noise in
|
661
|
+
* the codebase. Also helps to prevent errors when refactoring and adding
|
662
|
+
* new lines.
|
663
|
+
*
|
664
|
+
* @see https://typescript-eslint.io/rules/semi
|
665
|
+
*/
|
666
|
+
semi: "off"
|
667
|
+
}
|
668
|
+
},
|
669
|
+
/**
|
670
|
+
* Ignore duplicate imports in declaration files as they are often used to re-export
|
671
|
+
* types from other packages into multiple namespaces. This is a common pattern
|
672
|
+
* in TypeScript declaration files.
|
673
|
+
*/
|
674
|
+
{
|
675
|
+
files: ["*.d.ts"],
|
676
|
+
rules: {
|
677
|
+
"@typescript-eslint/no-use-before-define": "off",
|
678
|
+
"import/no-duplicates": "off"
|
679
|
+
}
|
680
|
+
},
|
681
|
+
/**
|
682
|
+
* Allow console statements in scripts and CLI files since they are not part of the
|
683
|
+
* library / production code and are useful for debugging, logging, and testing.
|
684
|
+
*/
|
685
|
+
{
|
686
|
+
files: ["**/scripts/**/*", "cli.*"],
|
687
|
+
rules: {
|
688
|
+
"no-console": "off"
|
689
|
+
}
|
690
|
+
}
|
691
|
+
];
|
692
|
+
}
|
693
|
+
function stylistic() {
|
694
|
+
return [
|
695
|
+
{
|
696
|
+
plugins: {
|
697
|
+
"@stylistic": stylisticPlugin
|
698
|
+
},
|
699
|
+
rules: {
|
700
|
+
/**
|
701
|
+
* Enforce a line before any comment. This makes the code more readable and
|
702
|
+
* separates the comments from the code.
|
703
|
+
*
|
704
|
+
* @see https://eslint.style/rules/default/lines-around-comment
|
705
|
+
*/
|
706
|
+
"@stylistic/lines-around-comment": ["error", {
|
707
|
+
allowArrayEnd: !0,
|
708
|
+
allowBlockEnd: !0,
|
709
|
+
allowBlockStart: !0,
|
710
|
+
allowObjectEnd: !0,
|
711
|
+
allowTypeStart: !0,
|
712
|
+
beforeBlockComment: !0,
|
713
|
+
beforeLineComment: !0,
|
714
|
+
ignorePattern: "^\\*"
|
715
|
+
}]
|
716
|
+
}
|
717
|
+
}
|
718
|
+
];
|
719
|
+
}
|
720
|
+
function sonarjs() {
|
721
|
+
return new eslintrc.FlatCompat().config({
|
722
|
+
extends: [
|
723
|
+
"plugin:sonarjs/recommended"
|
724
|
+
],
|
725
|
+
plugins: [
|
726
|
+
"sonarjs"
|
727
|
+
],
|
728
|
+
rules: {
|
729
|
+
/**
|
730
|
+
* Cognitive Complexity is a measure of how hard the control flow of a function
|
731
|
+
* is to understand. Functions with high Cognitive Complexity will be difficult
|
732
|
+
* to maintain.
|
733
|
+
*
|
734
|
+
* @see https://github.com/SonarSource/eslint-plugin-sonarjs/blob/master/docs/rules/cognitive-complexity.md
|
735
|
+
*/
|
736
|
+
"sonarjs/cognitive-complexity": ["error", 30],
|
737
|
+
/**
|
738
|
+
* Duplicated string literals make the process of refactoring error-prone,
|
739
|
+
* since you must be sure to update all occurrences. On the other hand,
|
740
|
+
* constants can be referenced from many places, but only need to be
|
741
|
+
* updated in a single place.
|
742
|
+
*
|
743
|
+
* @see https://github.com/SonarSource/eslint-plugin-sonarjs/blob/master/docs/rules/no-duplicate-string.md
|
744
|
+
*/
|
745
|
+
"sonarjs/no-duplicate-string": ["error", {
|
746
|
+
threshold: 10
|
747
|
+
}],
|
748
|
+
"sonarjs/no-empty-collection": "off",
|
749
|
+
"sonarjs/no-extra-arguments": "off",
|
750
|
+
"sonarjs/no-gratuitous-expressions": "off",
|
751
|
+
/**
|
752
|
+
* Those rules are crashing ESLint at startup, so they are disabled for now.
|
753
|
+
*/
|
754
|
+
"sonarjs/no-one-iteration-loop": "off",
|
755
|
+
"sonarjs/no-redundant-jump": "off",
|
756
|
+
"sonarjs/no-unused-collection": "off",
|
757
|
+
"sonarjs/no-use-of-empty-return-value": "off"
|
758
|
+
}
|
759
|
+
});
|
760
|
+
}
|
761
|
+
function perfectionist() {
|
762
|
+
return new eslintrc.FlatCompat().config({
|
763
|
+
extends: [
|
764
|
+
"plugin:perfectionist/recommended-natural"
|
765
|
+
],
|
766
|
+
plugins: [
|
767
|
+
"perfectionist"
|
768
|
+
],
|
769
|
+
rules: {
|
770
|
+
/**
|
771
|
+
* Sort imports alphabetically and group them without newlines. This rule
|
772
|
+
* aims to maintain consistency around the order of imports in JavaScript
|
773
|
+
* files. Helps reduce the visual noise in the codebase.
|
774
|
+
*
|
775
|
+
* @see https://eslint-plugin-perfectionist.azat.io/rules/sort-imports
|
776
|
+
*/
|
777
|
+
"perfectionist/sort-imports": ["error", {
|
778
|
+
"newlines-between": "never",
|
779
|
+
order: "desc"
|
780
|
+
}],
|
781
|
+
/**
|
782
|
+
* Sort objects alphabetically. This rule aims to maintain consistency around
|
783
|
+
* the order of object properties in JavaScript files. Helps reduce the visual
|
784
|
+
* noise in the codebase.
|
785
|
+
*
|
786
|
+
* @see https://eslint-plugin-perfectionist.azat.io/rules/sort-objects
|
787
|
+
*/
|
788
|
+
"perfectionist/sort-objects": ["error", {
|
789
|
+
"partition-by-comment": "--- **"
|
790
|
+
}]
|
791
|
+
}
|
792
|
+
});
|
793
|
+
}
|
794
|
+
function node() {
|
795
|
+
return [
|
796
|
+
{
|
797
|
+
plugins: {
|
798
|
+
n: nodePlugin
|
799
|
+
},
|
800
|
+
rules: {
|
801
|
+
...nodePlugin.configs.recommended.rules,
|
802
|
+
/**
|
803
|
+
* Disallow the use of extraneous imports. This rule helps prevent the
|
804
|
+
* use of third-party modules that are not listed in the project's
|
805
|
+
* dependencies.
|
806
|
+
*
|
807
|
+
* @see https://github.com/eslint-community/eslint-plugin-n/blob/HEAD/docs/rules/no-extraneous-import.md
|
808
|
+
*/
|
809
|
+
"n/no-extraneous-import": "error",
|
810
|
+
/**
|
811
|
+
* Disable the no-missing-import as module resolution is already checked
|
812
|
+
* by other tools and IDEs extensively. This rule is redundant.
|
813
|
+
*
|
814
|
+
* @see https://github.com/eslint-community/eslint-plugin-n/blob/HEAD/docs/rules/no-missing-import.md
|
815
|
+
*/
|
816
|
+
"n/no-missing-import": "off",
|
817
|
+
"n/no-missing-require": "off",
|
818
|
+
"n/no-unsupported-features/es-builtins": "error",
|
819
|
+
/**
|
820
|
+
* Allow the use of features up to Node.js version 20. This will allow
|
821
|
+
* the use of newer ECMAScript features and Node.js APIs.
|
822
|
+
*
|
823
|
+
* @see https://github.com/eslint-community/eslint-plugin-n/tree/master/docs/rules
|
824
|
+
*/
|
825
|
+
"n/no-unsupported-features/es-syntax": "error",
|
826
|
+
"n/no-unsupported-features/node-builtins": "error",
|
827
|
+
/**
|
828
|
+
* Prepend the `node:` prefix to all Node.js core modules. This helps
|
829
|
+
* identify the module as a Node.js core module and not a third-party
|
830
|
+
* module.
|
831
|
+
*
|
832
|
+
* @see https://github.com/eslint-community/eslint-plugin-n/blob/HEAD/docs/rules/prefer-node-protocol.md
|
833
|
+
*/
|
834
|
+
"n/prefer-node-protocol": "error"
|
835
|
+
},
|
836
|
+
settings: {
|
837
|
+
node: {
|
838
|
+
version: ">=20.0.0"
|
839
|
+
}
|
840
|
+
}
|
841
|
+
}
|
842
|
+
];
|
843
|
+
}
|
844
|
+
function jsonTsconfig() {
|
845
|
+
return [
|
846
|
+
{
|
847
|
+
files: [
|
848
|
+
"**/tsconfig.json",
|
849
|
+
"**/tsconfig.*.json"
|
850
|
+
],
|
851
|
+
rules: {
|
852
|
+
"jsonc/sort-array-values": [
|
853
|
+
"error",
|
854
|
+
{
|
855
|
+
order: { type: "asc" },
|
856
|
+
pathPattern: "^(includes|excludes)$"
|
857
|
+
}
|
858
|
+
],
|
859
|
+
"jsonc/sort-keys": [
|
860
|
+
"error",
|
861
|
+
{
|
862
|
+
order: [
|
863
|
+
"extends",
|
864
|
+
"compilerOptions",
|
865
|
+
"references",
|
866
|
+
"files",
|
867
|
+
"include",
|
868
|
+
"exclude"
|
869
|
+
],
|
870
|
+
pathPattern: "^$"
|
871
|
+
},
|
872
|
+
{
|
873
|
+
order: [
|
874
|
+
// --- Project Structure
|
875
|
+
"incremental",
|
876
|
+
"composite",
|
877
|
+
"tsBuildInfoFile",
|
878
|
+
"disableSourceOfProjectReferenceRedirect",
|
879
|
+
"disableSolutionSearching",
|
880
|
+
"disableReferencedProjectLoad",
|
881
|
+
// --- Language and Environment
|
882
|
+
"target",
|
883
|
+
"jsx",
|
884
|
+
"jsxFactory",
|
885
|
+
"jsxFragmentFactory",
|
886
|
+
"jsxImportSource",
|
887
|
+
"lib",
|
888
|
+
"moduleDetection",
|
889
|
+
"noLib",
|
890
|
+
"reactNamespace",
|
891
|
+
"useDefineForClassFields",
|
892
|
+
"emitDecoratorMetadata",
|
893
|
+
"experimentalDecorators",
|
894
|
+
// --- Module Resolution
|
895
|
+
"baseUrl",
|
896
|
+
"rootDir",
|
897
|
+
"rootDirs",
|
898
|
+
"customConditions",
|
899
|
+
"module",
|
900
|
+
"moduleResolution",
|
901
|
+
"moduleSuffixes",
|
902
|
+
"noResolve",
|
903
|
+
"paths",
|
904
|
+
"resolveJsonModule",
|
905
|
+
"resolvePackageJsonExports",
|
906
|
+
"resolvePackageJsonImports",
|
907
|
+
"typeRoots",
|
908
|
+
"types",
|
909
|
+
"allowArbitraryExtensions",
|
910
|
+
"allowImportingTsExtensions",
|
911
|
+
"allowUmdGlobalAccess",
|
912
|
+
// --- JavaScript Support
|
913
|
+
"allowJs",
|
914
|
+
"checkJs",
|
915
|
+
"maxNodeModuleJsDepth",
|
916
|
+
// --- Type Checking
|
917
|
+
"strict",
|
918
|
+
"strictBindCallApply",
|
919
|
+
"strictFunctionTypes",
|
920
|
+
"strictNullChecks",
|
921
|
+
"strictPropertyInitialization",
|
922
|
+
"allowUnreachableCode",
|
923
|
+
"allowUnusedLabels",
|
924
|
+
"alwaysStrict",
|
925
|
+
"exactOptionalPropertyTypes",
|
926
|
+
"noFallthroughCasesInSwitch",
|
927
|
+
"noImplicitAny",
|
928
|
+
"noImplicitOverride",
|
929
|
+
"noImplicitReturns",
|
930
|
+
"noImplicitThis",
|
931
|
+
"noPropertyAccessFromIndexSignature",
|
932
|
+
"noUncheckedIndexedAccess",
|
933
|
+
"noUnusedLocals",
|
934
|
+
"noUnusedParameters",
|
935
|
+
"useUnknownInCatchVariables",
|
936
|
+
// --- Emitting
|
937
|
+
"declaration",
|
938
|
+
"declarationDir",
|
939
|
+
"declarationMap",
|
940
|
+
"downlevelIteration",
|
941
|
+
"emitBOM",
|
942
|
+
"emitDeclarationOnly",
|
943
|
+
"importHelpers",
|
944
|
+
"importsNotUsedAsValues",
|
945
|
+
"inlineSourceMap",
|
946
|
+
"inlineSources",
|
947
|
+
"mapRoot",
|
948
|
+
"newLine",
|
949
|
+
"noEmit",
|
950
|
+
"noEmitHelpers",
|
951
|
+
"noEmitOnError",
|
952
|
+
"outDir",
|
953
|
+
"outFile",
|
954
|
+
"preserveConstEnums",
|
955
|
+
"preserveValueImports",
|
956
|
+
"removeComments",
|
957
|
+
"sourceMap",
|
958
|
+
"sourceRoot",
|
959
|
+
"stripInternal",
|
960
|
+
// --- Interop Constraints
|
961
|
+
"allowSyntheticDefaultImports",
|
962
|
+
"esModuleInterop",
|
963
|
+
"forceConsistentCasingInFileNames",
|
964
|
+
"isolatedModules",
|
965
|
+
"preserveSymlinks",
|
966
|
+
"verbatimModuleSyntax",
|
967
|
+
// --- Completeness
|
968
|
+
"skipDefaultLibCheck",
|
969
|
+
"skipLibCheck"
|
970
|
+
],
|
971
|
+
pathPattern: "^compilerOptions$"
|
972
|
+
},
|
973
|
+
{
|
974
|
+
order: { type: "asc" },
|
975
|
+
pathPattern: "^compilerOptions\\.paths$"
|
976
|
+
}
|
977
|
+
]
|
978
|
+
}
|
979
|
+
}
|
980
|
+
];
|
981
|
+
}
|
982
|
+
function jsonPackage() {
|
983
|
+
return [
|
984
|
+
{
|
985
|
+
files: [
|
986
|
+
"**/package.json"
|
987
|
+
],
|
988
|
+
rules: {
|
989
|
+
"jsonc/sort-keys": [
|
990
|
+
"error",
|
991
|
+
{
|
992
|
+
order: [
|
993
|
+
"name",
|
994
|
+
"type",
|
995
|
+
"version",
|
996
|
+
"license",
|
997
|
+
"private",
|
998
|
+
"sideEffects",
|
999
|
+
// --- Publishing
|
1000
|
+
"description",
|
1001
|
+
"author",
|
1002
|
+
"keywords",
|
1003
|
+
"bugs",
|
1004
|
+
"funding",
|
1005
|
+
"homepage",
|
1006
|
+
"repository",
|
1007
|
+
// --- Distribution
|
1008
|
+
"bin",
|
1009
|
+
"main",
|
1010
|
+
"module",
|
1011
|
+
"types",
|
1012
|
+
"typings",
|
1013
|
+
"browser",
|
1014
|
+
"exports",
|
1015
|
+
"files",
|
1016
|
+
// --- Package Manager
|
1017
|
+
"packageManager",
|
1018
|
+
"pnpm",
|
1019
|
+
// --- Scripts
|
1020
|
+
"scripts",
|
1021
|
+
// --- Dependencies
|
1022
|
+
"peerDependencies",
|
1023
|
+
"peerDependenciesMeta",
|
1024
|
+
"optionalDependencies",
|
1025
|
+
"dependencies",
|
1026
|
+
"devDependencies",
|
1027
|
+
"bundledDependencies",
|
1028
|
+
"bundleDependencies",
|
1029
|
+
// --- Config
|
1030
|
+
"tsup",
|
1031
|
+
"husky",
|
1032
|
+
"lint-staged",
|
1033
|
+
"eslintConfig"
|
1034
|
+
],
|
1035
|
+
pathPattern: "^$"
|
1036
|
+
},
|
1037
|
+
{
|
1038
|
+
order: { type: "asc" },
|
1039
|
+
pathPattern: "^(?:dev|peer|optional|bundled)?[Dd]ependencies$"
|
1040
|
+
}
|
1041
|
+
]
|
1042
|
+
}
|
1043
|
+
}
|
1044
|
+
];
|
1045
|
+
}
|
1046
|
+
function configJson() {
|
1047
|
+
return [
|
1048
|
+
...jsonc.configs["flat/recommended-with-json"],
|
1049
|
+
{
|
1050
|
+
files: [
|
1051
|
+
"**/*.json",
|
1052
|
+
"**/*.json5"
|
1053
|
+
],
|
1054
|
+
rules: {
|
1055
|
+
/**
|
1056
|
+
* Automatically apply jsonc rules similar to your configured ESLint core rules to JSON.
|
1057
|
+
*
|
1058
|
+
* @see https://ota-meshi.github.io/eslint-plugin-jsonc/rules/auto.html
|
1059
|
+
*/
|
1060
|
+
"jsonc/auto": "error"
|
1061
|
+
}
|
1062
|
+
}
|
1063
|
+
];
|
1064
|
+
}
|
1065
|
+
function jsdoc() {
|
1066
|
+
return [
|
1067
|
+
pluginJsdoc.configs["flat/recommended-typescript-flavor-error"],
|
1068
|
+
{
|
1069
|
+
files: [
|
1070
|
+
"**/*.js",
|
1071
|
+
"**/*.ts",
|
1072
|
+
"**/*.tsx"
|
1073
|
+
],
|
1074
|
+
rules: {
|
1075
|
+
/**
|
1076
|
+
* Enforce a consistent padding of the block description.
|
1077
|
+
*
|
1078
|
+
* @see https://github.com/gajus/eslint-plugin-jsdoc/blob/HEAD/docs/rules/check-alignment.md#readme
|
1079
|
+
*/
|
1080
|
+
"jsdoc/check-alignment": "error",
|
1081
|
+
/**
|
1082
|
+
* Normalize the indentation in the JSdoc comment to improve readability.
|
1083
|
+
*
|
1084
|
+
* @see https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/check-indentation.md#readme
|
1085
|
+
*/
|
1086
|
+
"jsdoc/check-indentation": "error",
|
1087
|
+
/**
|
1088
|
+
* Enforce a strict set of tags for the JSDoc comment. This rule also includes
|
1089
|
+
* some custom tags that are used in our projects.
|
1090
|
+
*
|
1091
|
+
* @see https://github.com/gajus/eslint-plugin-jsdoc/blob/main/.README/rules/check-tag-names.md
|
1092
|
+
*/
|
1093
|
+
"jsdoc/check-tag-names": ["error", {
|
1094
|
+
definedTags: [
|
1095
|
+
"category"
|
1096
|
+
]
|
1097
|
+
}],
|
1098
|
+
/**
|
1099
|
+
* Checks for multi-line-style comments which fail to meet the criteria of a jsdoc block,
|
1100
|
+
* namely that it should begin with two and only two asterisks.
|
1101
|
+
*
|
1102
|
+
* @see https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/no-bad-blocks.md#readme
|
1103
|
+
*/
|
1104
|
+
"jsdoc/no-bad-blocks": "error",
|
1105
|
+
/**
|
1106
|
+
* It is common practice to prefix a hyphen to parameters in JSDoc. But this
|
1107
|
+
* is sometimes forgotten and has no real purpose. This rule aims to enforce
|
1108
|
+
* that no hyphen is used.
|
1109
|
+
*
|
1110
|
+
* @see https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-hyphen-before-param-description#readme
|
1111
|
+
*/
|
1112
|
+
"jsdoc/require-hyphen-before-param-description": ["error", "never"],
|
1113
|
+
"jsdoc/require-jsdoc": "off",
|
1114
|
+
"jsdoc/require-param-type": "off",
|
1115
|
+
/**
|
1116
|
+
* Since we are using TypeScript, we don't need to enforce types in JSDoc.
|
1117
|
+
*
|
1118
|
+
* @see https://github.com/gajus/eslint-plugin-jsdoc/blob/main/.README/rules/require-return-type.md
|
1119
|
+
*/
|
1120
|
+
"jsdoc/require-returns-type": "off",
|
1121
|
+
/**
|
1122
|
+
* Enforce a new-line between the JSDoc summary and tags. Aims to improve
|
1123
|
+
* readability by separating the summary and tags.
|
1124
|
+
*
|
1125
|
+
* @see https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/tag-lines.md#readme
|
1126
|
+
*/
|
1127
|
+
"jsdoc/tag-lines": ["error", "any", { startLines: 1 }]
|
1128
|
+
}
|
1129
|
+
}
|
1130
|
+
];
|
1131
|
+
}
|
1132
|
+
function javascript() {
|
1133
|
+
return [
|
1134
|
+
{
|
1135
|
+
rules: {
|
1136
|
+
/**
|
1137
|
+
* Inherit all recommended rules from the `@eslint/js` plugin. This is the base
|
1138
|
+
* configuration for JavaScript files.
|
1139
|
+
*/
|
1140
|
+
...javascriptPlugin.configs.recommended.rules,
|
1141
|
+
"array-bracket-spacing": ["error", "never"],
|
1142
|
+
"array-callback-return": "error",
|
1143
|
+
"arrow-body-style": ["error", "as-needed"],
|
1144
|
+
"arrow-parens": ["error", "as-needed", { requireForBlockBody: !0 }],
|
1145
|
+
"block-scoped-var": "error",
|
1146
|
+
"block-spacing": ["error", "always"],
|
1147
|
+
"brace-style": ["error", "stroustrup", { allowSingleLine: !0 }],
|
1148
|
+
camelcase: "off",
|
1149
|
+
"comma-dangle": ["error", "always-multiline"],
|
1150
|
+
"comma-spacing": ["error", { after: !0, before: !1 }],
|
1151
|
+
"comma-style": ["error", "last"],
|
1152
|
+
complexity: ["off", 11],
|
1153
|
+
"consistent-return": "off",
|
1154
|
+
curly: ["error", "multi-or-nest", "consistent"],
|
1155
|
+
"eol-last": "error",
|
1156
|
+
eqeqeq: ["error", "smart"],
|
1157
|
+
"func-call-spacing": ["off", "never"],
|
1158
|
+
"generator-star-spacing": "off",
|
1159
|
+
indent: ["error", 2, { outerIIFEBody: 1, SwitchCase: 1, VariableDeclarator: 1 }],
|
1160
|
+
"key-spacing": ["error", { afterColon: !0, beforeColon: !1 }],
|
1161
|
+
"n/no-callback-literal": "off",
|
1162
|
+
"no-alert": "error",
|
1163
|
+
"no-case-declarations": "error",
|
1164
|
+
"no-cond-assign": ["error", "always"],
|
1165
|
+
"no-confusing-arrow": "error",
|
1166
|
+
"no-console": ["warn", { allow: ["warn", "error"] }],
|
1167
|
+
"no-constant-condition": "error",
|
1168
|
+
"no-debugger": "error",
|
1169
|
+
"no-eval": "error",
|
1170
|
+
"no-implied-eval": "error",
|
1171
|
+
"no-multi-spaces": "error",
|
1172
|
+
"no-multi-str": "error",
|
1173
|
+
/**
|
1174
|
+
* Enforce a consistent linebreak style. Reduces merge conflicts and makes the code
|
1175
|
+
* more consistent between different iterations of the same file.
|
1176
|
+
*
|
1177
|
+
* @see https://eslint.org/docs/rules/linebreak-style
|
1178
|
+
*/
|
1179
|
+
"no-multiple-empty-lines": ["error", {
|
1180
|
+
max: 1,
|
1181
|
+
maxBOF: 0,
|
1182
|
+
maxEOF: 1
|
1183
|
+
}],
|
1184
|
+
"no-param-reassign": "off",
|
1185
|
+
"no-restricted-syntax": ["error", "DebuggerStatement", "LabeledStatement", "WithStatement"],
|
1186
|
+
"no-return-assign": "off",
|
1187
|
+
"no-return-await": "off",
|
1188
|
+
"no-trailing-spaces": "error",
|
1189
|
+
"no-unused-vars": "warn",
|
1190
|
+
"no-use-before-define": ["error", { classes: !1, functions: !1, variables: !0 }],
|
1191
|
+
"no-useless-escape": "off",
|
1192
|
+
"no-var": "error",
|
1193
|
+
/**
|
1194
|
+
* Allow `void` operator. It's useful to discard the result of an expression, especially
|
1195
|
+
* when calling asynchronous functions that return a promise.
|
1196
|
+
*
|
1197
|
+
* @see https://eslint.org/docs/rules/no-void
|
1198
|
+
*/
|
1199
|
+
"no-void": "off",
|
1200
|
+
"no-with": "error",
|
1201
|
+
"object-curly-spacing": ["error", "always"],
|
1202
|
+
"object-shorthand": ["error", "always", { avoidQuotes: !0, ignoreConstructors: !1 }],
|
1203
|
+
"one-var-declaration-per-line": "error",
|
1204
|
+
"operator-linebreak": ["error", "before"],
|
1205
|
+
"prefer-arrow-callback": ["error", { allowNamedFunctions: !1, allowUnboundThis: !0 }],
|
1206
|
+
"prefer-const": ["error", { destructuring: "any", ignoreReadBeforeAssign: !0 }],
|
1207
|
+
"prefer-rest-params": "error",
|
1208
|
+
"prefer-spread": "error",
|
1209
|
+
"prefer-template": "error",
|
1210
|
+
"quote-props": ["error", "consistent-as-needed"],
|
1211
|
+
quotes: ["error", "single"],
|
1212
|
+
"require-await": "off",
|
1213
|
+
semi: ["error", "never"],
|
1214
|
+
"space-before-function-paren": ["error", "never"],
|
1215
|
+
"spaced-comment": ["error", "always", {
|
1216
|
+
block: {
|
1217
|
+
balanced: !0,
|
1218
|
+
exceptions: ["*"],
|
1219
|
+
markers: ["!"]
|
1220
|
+
},
|
1221
|
+
line: {
|
1222
|
+
exceptions: ["/", "#"],
|
1223
|
+
markers: ["/"]
|
1224
|
+
}
|
1225
|
+
}],
|
1226
|
+
"template-curly-spacing": "error",
|
1227
|
+
"vars-on-top": "error"
|
1228
|
+
}
|
1229
|
+
}
|
1230
|
+
];
|
1231
|
+
}
|
1232
|
+
function eslintComments() {
|
1233
|
+
return [
|
1234
|
+
{
|
1235
|
+
plugins: {
|
1236
|
+
"eslint-comments": eslintCommentsPlugin
|
1237
|
+
},
|
1238
|
+
rules: {
|
1239
|
+
/**
|
1240
|
+
* Allow multiple rules directive in a single comment. This
|
1241
|
+
* reduces the number of comments in the code.
|
1242
|
+
*
|
1243
|
+
* @see https://mysticatea.github.io/eslint-plugin-eslint-comments/rules/disable-enable-pair
|
1244
|
+
*/
|
1245
|
+
"eslint-comments/disable-enable-pair": "off",
|
1246
|
+
/**
|
1247
|
+
* `eslint-enable` directive-comments can enable rules which are disabled by different
|
1248
|
+
* eslint-disable directive-comments. It can enable a rule unintentionally. This rule
|
1249
|
+
* will report such cases.
|
1250
|
+
*
|
1251
|
+
* @see https://mysticatea.github.io/eslint-plugin-eslint-comments/rules/no-aggregating-enable
|
1252
|
+
*/
|
1253
|
+
"eslint-comments/no-aggregating-enable": "error",
|
1254
|
+
/**
|
1255
|
+
* Disallow duplicate eslint-disable comments. This rule will report when there are
|
1256
|
+
* multiple eslint-disable comments for the same rule, either in the same line or enabled
|
1257
|
+
* by different eslint-disable comments.
|
1258
|
+
*
|
1259
|
+
* @see https://mysticatea.github.io/eslint-plugin-eslint-comments/rules/no-duplicate-disable
|
1260
|
+
*/
|
1261
|
+
"eslint-comments/no-duplicate-disable": "error",
|
1262
|
+
/**
|
1263
|
+
* Disallow eslint-disable comments without rule names. This ensures that we cannot
|
1264
|
+
* disable all rules in a file using eslint-disable comment.
|
1265
|
+
*
|
1266
|
+
* @see https://mysticatea.github.io/eslint-plugin-eslint-comments/rules/no-unlimited-disable
|
1267
|
+
*/
|
1268
|
+
"eslint-comments/no-unlimited-disable": "error",
|
1269
|
+
/**
|
1270
|
+
* Errors when an eslint-disable comment has no effect. This is useful
|
1271
|
+
* to prevent unnecessary comments in the code.
|
1272
|
+
*
|
1273
|
+
* @see https://mysticatea.github.io/eslint-plugin-eslint-comments/rules/no-unused-disable
|
1274
|
+
*/
|
1275
|
+
"eslint-comments/no-unused-disable": "error"
|
1276
|
+
}
|
1277
|
+
}
|
1278
|
+
];
|
1279
|
+
}
|
1280
|
+
function antfu() {
|
1281
|
+
return [
|
1282
|
+
{
|
1283
|
+
plugins: {
|
1284
|
+
antfu: pluginAntfu
|
1285
|
+
},
|
1286
|
+
rules: {
|
1287
|
+
"antfu/consistent-list-newline": "error",
|
1288
|
+
/**
|
1289
|
+
* Auto-fix import duplication. The TypeScript compiler already detects and removes
|
1290
|
+
* duplicate imports, but this rule can be used to fix the issue automatically in the editor.
|
1291
|
+
*
|
1292
|
+
* @see https://github.com/antfu/eslint-plugin-antfu/blob/main/src/rules/import-dedupe.md
|
1293
|
+
*/
|
1294
|
+
"antfu/import-dedupe": "error",
|
1295
|
+
/**
|
1296
|
+
* Enforce top-level function to be declared using function instead of arrow function. This
|
1297
|
+
* rule helps when you want to add additional overload signatures to a function without
|
1298
|
+
* having to transform the arrow function into a function declaration manually.
|
1299
|
+
*
|
1300
|
+
* On top of that, it mitigates the risk of accidentally using the `this` instance from
|
1301
|
+
* an outer scope.
|
1302
|
+
*
|
1303
|
+
* @see https://github.com/antfu/eslint-plugin-antfu/blob/main/src/rules/top-level-function.md
|
1304
|
+
*/
|
1305
|
+
"antfu/top-level-function": "error",
|
1306
|
+
/**
|
1307
|
+
* Enforce consistent line breaks inside braces of object/array/named imports/exports and
|
1308
|
+
* function parameters. Reduces the cognitive load of reasoning about code style.
|
1309
|
+
*
|
1310
|
+
* @see https://github.com/antfu/eslint-plugin-antfu/blob/main/src/rules/consistent-list-newline.md
|
1311
|
+
*/
|
1312
|
+
"object-curly-newline": "off"
|
1313
|
+
}
|
1314
|
+
}
|
1315
|
+
];
|
1316
|
+
}
|
1317
|
+
function all() {
|
1318
|
+
return [
|
1319
|
+
...antfu(),
|
1320
|
+
...eslintComments(),
|
1321
|
+
...javascript(),
|
1322
|
+
...jsdoc(),
|
1323
|
+
...configJson(),
|
1324
|
+
...jsonPackage(),
|
1325
|
+
...jsonTsconfig(),
|
1326
|
+
...node(),
|
1327
|
+
...perfectionist(),
|
1328
|
+
...sonarjs(),
|
1329
|
+
...stylistic(),
|
1330
|
+
...typescript(),
|
1331
|
+
...unicorn(),
|
1332
|
+
...vitest(),
|
1333
|
+
...vue(),
|
1334
|
+
// ...promise(),
|
1335
|
+
// ...markdown(),
|
1336
|
+
{
|
1337
|
+
ignores: [
|
1338
|
+
"**/dist",
|
1339
|
+
"**/bin",
|
1340
|
+
"**/node_modules",
|
1341
|
+
"**/.nuxt",
|
1342
|
+
"**/output",
|
1343
|
+
"**/coverage",
|
1344
|
+
"**/public",
|
1345
|
+
"**/__wip__",
|
1346
|
+
"**/__snapshots__",
|
1347
|
+
"**/LICENSE*",
|
1348
|
+
"**/CHANGELOG*",
|
1349
|
+
"packages-lock.json",
|
1350
|
+
"pnpm-lock.yaml",
|
1351
|
+
"yarn.lock"
|
1352
|
+
]
|
1353
|
+
}
|
1354
|
+
];
|
1355
|
+
}
|
1356
|
+
var index = all();
|
1357
|
+
module.exports = index;
|
1358
|
+
//# sourceMappingURL=index.cjs.map
|