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