@unshared/eslint-config 0.0.1 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/index.cjs +674 -672
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +1378 -0
- package/dist/index.js.map +1 -0
- package/package.json +7 -8
package/dist/index.cjs
CHANGED
@@ -1,12 +1,370 @@
|
|
1
1
|
"use strict";
|
2
|
-
var vueParser = require("vue-eslint-parser"), tslint = require("typescript-eslint"), vuePlugin = require("eslint-plugin-vue"),
|
3
|
-
|
4
|
-
|
2
|
+
var vueParser = require("vue-eslint-parser"), tslint = require("typescript-eslint"), vueProcessorBlocks = require("eslint-processor-vue-blocks"), vuePlugin = require("eslint-plugin-vue"), eslintMergeProcessors = require("eslint-merge-processors"), node_process = require("node:process"), perfectionist = require("eslint-plugin-perfectionist"), toArray = require("@unshared/collection/toArray"), stylistic = require("@stylistic/eslint-plugin"), javascript = require("@eslint/js"), vitestPlugin = require("eslint-plugin-vitest"), unicornPlugin = require("eslint-plugin-unicorn"), eslintrc = require("@eslint/eslintrc"), nodePlugin = require("eslint-plugin-n"), jsonc = require("eslint-plugin-jsonc"), pluginJsdoc = require("eslint-plugin-jsdoc"), eslintCommentsPlugin = require("eslint-plugin-eslint-comments"), pluginAntfu = require("eslint-plugin-antfu");
|
3
|
+
function getConfigRules(config) {
|
4
|
+
const rules = toArray.toArray(config).flat().map((x) => x.rules);
|
5
|
+
return Object.assign({}, ...rules);
|
6
|
+
}
|
7
|
+
function typescript(options) {
|
5
8
|
return [
|
9
|
+
javascript.configs.recommended,
|
6
10
|
{
|
11
|
+
languageOptions: {
|
12
|
+
// @ts-expect-error: ignore
|
13
|
+
parser: tslint.parser,
|
14
|
+
parserOptions: {
|
15
|
+
ecmaVersion: "latest",
|
16
|
+
sourceType: "module",
|
17
|
+
project: toArray.toArray(options.tsConfigPath ?? "./tsconfig.json"),
|
18
|
+
tsconfigRootDir: node_process.cwd()
|
19
|
+
}
|
20
|
+
},
|
21
|
+
plugins: {
|
22
|
+
"@typescript-eslint": tslint.plugin,
|
23
|
+
"@stylistic": stylistic,
|
24
|
+
perfectionist
|
25
|
+
},
|
7
26
|
files: [
|
8
|
-
"**/*.
|
27
|
+
"**/*.{ts,tsx,cts,mts}",
|
28
|
+
"**/*.{js,jsx,cjs,mjs}"
|
9
29
|
],
|
30
|
+
rules: {
|
31
|
+
/**
|
32
|
+
* Inherit all recommended rules from the `@eslint/js` plugin. This is the base
|
33
|
+
* configuration for JavaScript files.
|
34
|
+
*/
|
35
|
+
...getConfigRules(tslint.configs.recommendedTypeChecked),
|
36
|
+
...getConfigRules(tslint.configs.stylisticTypeChecked),
|
37
|
+
/**
|
38
|
+
* Age-old debate over how to style braces. This rule aims to reduce the
|
39
|
+
* cognitive load of reasoning about code by enforcing a consistent style.
|
40
|
+
*
|
41
|
+
* @see https://eslint.style/rules/default/brace-style
|
42
|
+
*/
|
43
|
+
"brace-style": "off",
|
44
|
+
"@typescript-eslint/brace-style": "off",
|
45
|
+
"@stylistic/brace-style": ["error", "stroustrup", {
|
46
|
+
allowSingleLine: !0
|
47
|
+
}],
|
48
|
+
/**
|
49
|
+
* Enforce an indent of 2 spaces. Aims to reduce visual noise and maintain
|
50
|
+
* readability of code when viewed on GitHub or GitLab.
|
51
|
+
*
|
52
|
+
* @see https://eslint.style/rules/default/no-tabs
|
53
|
+
* @see https://eslint.style/rules/default/indent
|
54
|
+
* @see https://eslint.style/rules/default/indent-binary-ops
|
55
|
+
*/
|
56
|
+
"no-tabs": "off",
|
57
|
+
indent: "off",
|
58
|
+
"indent-binary-ops": "off",
|
59
|
+
"@typescript-eslint/no-tabs": "off",
|
60
|
+
"@typescript-eslint/indent": "off",
|
61
|
+
"@typescript-eslint/indent-binary-ops": "off",
|
62
|
+
"@stylistic/no-tabs": "error",
|
63
|
+
"@stylistic/indent": ["error", 2],
|
64
|
+
"@stylistic/indent-binary-ops": ["error", 2],
|
65
|
+
/**
|
66
|
+
* Enforce no semi-colons. This rule aims to maintain consistency around the
|
67
|
+
* use or omission of trailing semicolons. Helps reduce the visual noise in
|
68
|
+
* the codebase. Also helps to prevent errors when refactoring and adding
|
69
|
+
* new lines.
|
70
|
+
*
|
71
|
+
* @see https://eslint.style/rules/default/semi
|
72
|
+
*/
|
73
|
+
semi: "off",
|
74
|
+
"@typescript-eslint/semi": "off",
|
75
|
+
"@stylistic/semi": ["error", "never"],
|
76
|
+
/**
|
77
|
+
* Enforce a consistent linebreak style and ensure no leading line breaks
|
78
|
+
* and a single trailing line break. This rule aims to maintain consistency
|
79
|
+
* around the use of line breaks in the codebase and reduce the amount of
|
80
|
+
* diff churn when making changes.
|
81
|
+
*
|
82
|
+
* @see https://eslint.style/rules/default/linebreak-style
|
83
|
+
*/
|
84
|
+
"eol-last": "off",
|
85
|
+
"no-multiple-empty-lines": "off",
|
86
|
+
"@stylistic/eol-last": ["error", "always"],
|
87
|
+
"@stylistic/no-multiple-empty-lines": ["error", {
|
88
|
+
max: 1,
|
89
|
+
maxBOF: 0,
|
90
|
+
maxEOF: 0
|
91
|
+
}],
|
92
|
+
/**
|
93
|
+
* Enforce a trailing comma after the last element or property in a multiline
|
94
|
+
* list of properties or elements. This rule improves the clarity of diffs
|
95
|
+
* when an item is added or removed from an object or array.
|
96
|
+
*
|
97
|
+
* @see https://eslint.style/rules/default/comma-dangle
|
98
|
+
* @see https://eslint.style/rules/default/comma-spacing
|
99
|
+
*/
|
100
|
+
"comma-dangle": "off",
|
101
|
+
"@typescript-eslint/comma-dangle": "off",
|
102
|
+
"@stylistic/comma-dangle": ["error", "always-multiline"],
|
103
|
+
/**
|
104
|
+
* This rule requires empty lines before and/or after comments. It is disabled
|
105
|
+
* however when in an object literal, array, or type literal.
|
106
|
+
*
|
107
|
+
* @see https://eslint.style/rules/default/lines-around-comment
|
108
|
+
*/
|
109
|
+
/**
|
110
|
+
* Normalize type declaration and definition. This reduces the cognitive load
|
111
|
+
* of reasoning about code by enforcing a consistent style.
|
112
|
+
*
|
113
|
+
* @see https://typescript-eslint.io/rules/consistent-indexed-object-style
|
114
|
+
*/
|
115
|
+
"@typescript-eslint/consistent-indexed-object-style": ["error", "record"],
|
116
|
+
"@typescript-eslint/consistent-type-definitions": ["error", "interface"],
|
117
|
+
"@typescript-eslint/member-delimiter-style": ["error", { multiline: { delimiter: "none" } }],
|
118
|
+
"@typescript-eslint/array-type": ["error", { default: "array-simple", readonly: "array-simple" }],
|
119
|
+
/**
|
120
|
+
* Enforce sequential declarations in the same block. This rule aims to
|
121
|
+
* enforce a top to bottom ordering of variable and type declarations.
|
122
|
+
* This reduces the likelihood of a developer skipping over a declaration
|
123
|
+
* when modifying code.
|
124
|
+
*
|
125
|
+
* @see https://typescript-eslint.io/rules/no-use-before-define
|
126
|
+
*/
|
127
|
+
"no-use-before-define": "off",
|
128
|
+
"@typescript-eslint/no-use-before-define": ["error", {
|
129
|
+
enums: !0,
|
130
|
+
classes: !1,
|
131
|
+
typedefs: !0,
|
132
|
+
variables: !0,
|
133
|
+
functions: !1,
|
134
|
+
ignoreTypeReferences: !0
|
135
|
+
}],
|
136
|
+
/**
|
137
|
+
* Enforce a consistent spacing around various places where spaces are optional.
|
138
|
+
* This rule aims to maintain consistency around the use of spaces in the codebase
|
139
|
+
* and reduce the amount of diff churn when making changes.
|
140
|
+
*
|
141
|
+
* @see https://eslint.style/rules/default/key-spacing
|
142
|
+
* @see https://eslint.style/rules/default/comma-spacing
|
143
|
+
* @see https://eslint.style/rules/default/block-spacing
|
144
|
+
* @see https://eslint.style/rules/default/arrow-spacing
|
145
|
+
* @see https://eslint.style/rules/default/object-curly-spacing
|
146
|
+
*/
|
147
|
+
"key-spacing": "off",
|
148
|
+
"comma-spacing": "off",
|
149
|
+
"block-spacing": "off",
|
150
|
+
"arrow-spacing": "off",
|
151
|
+
"spaced-comment": "off",
|
152
|
+
"no-multi-spaces": "off",
|
153
|
+
"space-before-blocks": "off",
|
154
|
+
"lines-around-comment": "off",
|
155
|
+
"object-curly-spacing": "off",
|
156
|
+
"array-bracket-spacing": "off",
|
157
|
+
"array-bracket-newline": "off",
|
158
|
+
"function-call-spacing": "off",
|
159
|
+
"generator-star-spacing": "off",
|
160
|
+
"template-curly-spacing": "off",
|
161
|
+
"object-property-newline ": "off",
|
162
|
+
"newline-per-chained-call": "off",
|
163
|
+
"computed-property-spacing": "off",
|
164
|
+
"lines-between-class-members": "off",
|
165
|
+
"@typescript-eslint/comma-spacing": "off",
|
166
|
+
"@typescript-eslint/object-curly-spacing": "off",
|
167
|
+
"@typescript-eslint/type-annotation-spacing": "off",
|
168
|
+
"@typescript-eslint/lines-around-comment": "off",
|
169
|
+
"@stylistic/key-spacing": ["error", { afterColon: !0, beforeColon: !1 }],
|
170
|
+
"@stylistic/comma-spacing": ["error", { after: !0, before: !1 }],
|
171
|
+
"@stylistic/arrow-spacing": ["error", { before: !0, after: !0 }],
|
172
|
+
"@stylistic/type-generic-spacing": "error",
|
173
|
+
"@stylistic/type-named-tuple-spacing": "error",
|
174
|
+
"@stylistic/block-spacing": ["error", "always"],
|
175
|
+
"@stylistic/no-multi-spaces": "error",
|
176
|
+
"@stylistic/keyword-spacing": ["error", { before: !0, after: !0 }],
|
177
|
+
"@stylistic/space-before-blocks": ["error", "always"],
|
178
|
+
"@stylistic/object-curly-spacing": ["error", "always"],
|
179
|
+
"@stylistic/array-bracket-spacing": ["error", "never"],
|
180
|
+
"@stylistic/array-bracket-newline": ["error", "consistent"],
|
181
|
+
"@stylistic/function-call-spacing": ["error", "never"],
|
182
|
+
"@stylistic/template-curly-spacing": ["error", "never"],
|
183
|
+
"@stylistic/object-property-newline": ["error", { allowAllPropertiesOnSameLine: !0 }],
|
184
|
+
"@stylistic/generator-star-spacing": ["error", { before: !0, after: !0 }],
|
185
|
+
"@stylistic/computed-property-spacing": ["error", "never"],
|
186
|
+
"@stylistic/multiline-ternary": ["error", "always-multiline"],
|
187
|
+
"@stylistic/lines-around-comment": ["error", {
|
188
|
+
beforeBlockComment: !0,
|
189
|
+
beforeLineComment: !0,
|
190
|
+
ignorePattern: "^(?! ?---|\\*)",
|
191
|
+
applyDefaultIgnorePatterns: !0,
|
192
|
+
afterHashbangComment: !0
|
193
|
+
}],
|
194
|
+
"@stylistic/spaced-comment": ["error", "always", {
|
195
|
+
block: { markers: ["!"], exceptions: ["*"], balanced: !0 },
|
196
|
+
line: { markers: ["/"], exceptions: ["/", "#"] }
|
197
|
+
}],
|
198
|
+
"@stylistic/lines-between-class-members": ["error", {
|
199
|
+
enforce: [{ blankLine: "always", prev: "method", next: "*" }]
|
200
|
+
}, {
|
201
|
+
exceptAfterSingleLine: !0
|
202
|
+
}],
|
203
|
+
"@stylistic/type-annotation-spacing": ["error", {
|
204
|
+
before: !1,
|
205
|
+
after: !0,
|
206
|
+
overrides: {
|
207
|
+
arrow: { before: !0, after: !0 },
|
208
|
+
colon: { before: !1, after: !0 },
|
209
|
+
variable: { before: !1, after: !0 },
|
210
|
+
property: { before: !1, after: !0 },
|
211
|
+
parameter: { before: !1, after: !0 },
|
212
|
+
returnType: { before: !1, after: !0 }
|
213
|
+
}
|
214
|
+
}],
|
215
|
+
/**
|
216
|
+
* Enforce the use of `@ts-expect-error` over `@ts-ignore` to silence TypeScript
|
217
|
+
* errors. This rule aims to ensure that TypeScript errors are never silenced
|
218
|
+
* without explanation or justification. When an error is fixed, the
|
219
|
+
* `@ts-expect-error` forces the developer to remove the comment.
|
220
|
+
*
|
221
|
+
* @see https://typescript-eslint.io/rules/prefer-ts-expect-error
|
222
|
+
* @see https://typescript-eslint.io/rules/ban-ts-comment
|
223
|
+
*/
|
224
|
+
"@typescript-eslint/prefer-ts-expect-error": "error",
|
225
|
+
"@typescript-eslint/ban-ts-comment": ["error", {
|
226
|
+
"ts-check": !1,
|
227
|
+
"ts-expect-error": "allow-with-description",
|
228
|
+
"ts-ignore": !1,
|
229
|
+
"ts-nocheck": !1
|
230
|
+
}],
|
231
|
+
/**
|
232
|
+
* Disallow dangling expressions and promises. This rule aims to prevent
|
233
|
+
* dangling promises and expressions that are not assigned to a variable.
|
234
|
+
* This can lead to bugs and unexpected behavior in the codebase.
|
235
|
+
*
|
236
|
+
* @see https://eslint.org/docs/rules/no-void
|
237
|
+
* @see https://typescript-eslint.io/rules/no-floating-promises
|
238
|
+
*/
|
239
|
+
"no-void": "off",
|
240
|
+
"no-unused-expressions": "off",
|
241
|
+
"@typescript-eslint/no-unused-expressions": "error",
|
242
|
+
"@typescript-eslint/no-floating-promises": ["error", {
|
243
|
+
ignoreVoid: !0,
|
244
|
+
ignoreIIFE: !0
|
245
|
+
}],
|
246
|
+
/**
|
247
|
+
* Sort imports alphabetically and group them without newlines. This rule
|
248
|
+
* aims to maintain consistency around the order of imports in JavaScript
|
249
|
+
* files. Helps reduce the visual noise in the codebase.
|
250
|
+
*
|
251
|
+
* @see https://eslint-plugin-perfectionist.azat.io/rules/sort-imports
|
252
|
+
*/
|
253
|
+
"sort-imports": "off",
|
254
|
+
"@typescript-eslint/sort-type-constituents": "off",
|
255
|
+
"@typescript-eslint/consistent-type-imports": ["error", {
|
256
|
+
disallowTypeAnnotations: !1,
|
257
|
+
prefer: "no-type-imports"
|
258
|
+
}],
|
259
|
+
"perfectionist/sort-named-imports": ["error", { type: "natural" }],
|
260
|
+
"perfectionist/sort-imports": ["error", {
|
261
|
+
"newlines-between": "never",
|
262
|
+
order: "desc"
|
263
|
+
}],
|
264
|
+
/**
|
265
|
+
* Enforce no unused variables. Helps keep the codebase clean and reduces
|
266
|
+
* the chance of bugs from side-effects.
|
267
|
+
*
|
268
|
+
* @see https://typescript-eslint.io/rules/@typescript-eslint/no-unused-vars
|
269
|
+
*/
|
270
|
+
"no-redeclare": "off",
|
271
|
+
"no-unused-vars": "off",
|
272
|
+
"@typescript-eslint/no-redeclare": "error",
|
273
|
+
"@typescript-eslint/no-unused-vars": ["error", { argsIgnorePattern: "^_" }],
|
274
|
+
//////////////////////////////////////////////////////////////////////////////////////////
|
275
|
+
"perfectionist/sort-intersection-types": ["error", { type: "natural" }],
|
276
|
+
"perfectionist/sort-union-types": ["error", {
|
277
|
+
type: "natural",
|
278
|
+
"nullable-last": !0
|
279
|
+
}],
|
280
|
+
"no-useless-constructor": "off",
|
281
|
+
"@typescript-eslint/ban-types": "off",
|
282
|
+
"@typescript-eslint/camelcase": "off",
|
283
|
+
"@typescript-eslint/explicit-function-return-type": "off",
|
284
|
+
"@typescript-eslint/explicit-member-accessibility": "off",
|
285
|
+
"@typescript-eslint/explicit-module-boundary-types": "off",
|
286
|
+
"@typescript-eslint/no-empty-function": "off",
|
287
|
+
"@typescript-eslint/no-empty-interface": "off",
|
288
|
+
"@typescript-eslint/no-explicit-any": "off",
|
289
|
+
"@typescript-eslint/no-namespace": "off",
|
290
|
+
"@typescript-eslint/no-non-null-assertion": "off",
|
291
|
+
"@typescript-eslint/no-parameter-properties": "off",
|
292
|
+
"array-callback-return": "error",
|
293
|
+
"arrow-body-style": ["error", "as-needed"],
|
294
|
+
"arrow-parens": ["error", "as-needed", { requireForBlockBody: !0 }],
|
295
|
+
"block-scoped-var": "error",
|
296
|
+
camelcase: "off",
|
297
|
+
"comma-style": ["error", "last"],
|
298
|
+
complexity: ["off", 11],
|
299
|
+
"consistent-return": "off",
|
300
|
+
curly: ["error", "multi-or-nest", "consistent"],
|
301
|
+
eqeqeq: ["error", "smart"],
|
302
|
+
"no-alert": "error",
|
303
|
+
"no-case-declarations": "error",
|
304
|
+
"no-cond-assign": ["error", "always"],
|
305
|
+
"no-confusing-arrow": "error",
|
306
|
+
"no-console": ["warn", { allow: ["warn", "error"] }],
|
307
|
+
"no-constant-condition": "error",
|
308
|
+
"no-debugger": "error",
|
309
|
+
"no-eval": "error",
|
310
|
+
"no-implied-eval": "error",
|
311
|
+
"no-multi-str": "error",
|
312
|
+
"no-param-reassign": "off",
|
313
|
+
"no-restricted-syntax": ["error", "DebuggerStatement", "LabeledStatement", "WithStatement"],
|
314
|
+
"no-return-assign": "off",
|
315
|
+
"no-return-await": "off",
|
316
|
+
"no-trailing-spaces": "error",
|
317
|
+
"no-useless-escape": "off",
|
318
|
+
"no-var": "error",
|
319
|
+
"no-with": "error",
|
320
|
+
"object-shorthand": ["error", "always", { avoidQuotes: !0, ignoreConstructors: !1 }],
|
321
|
+
"one-var-declaration-per-line": "error",
|
322
|
+
"operator-linebreak": ["error", "before"],
|
323
|
+
"prefer-arrow-callback": ["error", { allowNamedFunctions: !1, allowUnboundThis: !0 }],
|
324
|
+
"prefer-const": ["error", { destructuring: "any", ignoreReadBeforeAssign: !0 }],
|
325
|
+
"prefer-rest-params": "error",
|
326
|
+
"prefer-spread": "error",
|
327
|
+
"prefer-template": "error",
|
328
|
+
"quote-props": ["error", "consistent-as-needed"],
|
329
|
+
quotes: ["error", "single"],
|
330
|
+
"require-await": "off",
|
331
|
+
"space-before-function-paren": ["error", "never"],
|
332
|
+
"vars-on-top": "error"
|
333
|
+
}
|
334
|
+
},
|
335
|
+
/**
|
336
|
+
* Ignore duplicate imports in declaration files as they are often used to re-export
|
337
|
+
* types from other packages into multiple namespaces. This is a common pattern
|
338
|
+
* in TypeScript declaration files.
|
339
|
+
*/
|
340
|
+
{
|
341
|
+
files: ["*.d.ts"],
|
342
|
+
rules: {
|
343
|
+
"@typescript-eslint/no-use-before-define": "off",
|
344
|
+
"import/no-duplicates": "off"
|
345
|
+
}
|
346
|
+
},
|
347
|
+
/**
|
348
|
+
* Allow console statements in scripts and CLI files since they are not part of the
|
349
|
+
* library / production code and are useful for debugging, logging, and testing.
|
350
|
+
*/
|
351
|
+
{
|
352
|
+
files: ["**/scripts/**/*", "cli.*"],
|
353
|
+
rules: {
|
354
|
+
"no-console": "off"
|
355
|
+
}
|
356
|
+
}
|
357
|
+
];
|
358
|
+
}
|
359
|
+
function vue(options) {
|
360
|
+
const TYPESCRIPT_CONFIG = typescript(options).at(1);
|
361
|
+
return [
|
362
|
+
...vuePlugin.configs?.["flat/base"],
|
363
|
+
{
|
364
|
+
plugins: {
|
365
|
+
vue: vuePlugin,
|
366
|
+
...TYPESCRIPT_CONFIG.plugins
|
367
|
+
},
|
10
368
|
languageOptions: {
|
11
369
|
globals: {
|
12
370
|
computed: "readonly",
|
@@ -26,18 +384,35 @@ function vue() {
|
|
26
384
|
},
|
27
385
|
parser: vueParser,
|
28
386
|
parserOptions: {
|
29
|
-
ecmaFeatures: { jsx: !1 },
|
30
|
-
ecmaVersion: "latest",
|
31
387
|
parser: tslint.parser,
|
32
|
-
|
388
|
+
extraFileExtensions: [".vue"],
|
389
|
+
...TYPESCRIPT_CONFIG.languageOptions.parserOptions
|
33
390
|
}
|
34
391
|
},
|
35
|
-
|
36
|
-
|
37
|
-
vue
|
38
|
-
|
392
|
+
processor: eslintMergeProcessors.mergeProcessors([
|
393
|
+
// @ts-expect-error: ignore
|
394
|
+
vuePlugin.processors[".vue"],
|
395
|
+
vueProcessorBlocks()
|
396
|
+
]),
|
397
|
+
files: [
|
398
|
+
"**/*.vue"
|
399
|
+
],
|
39
400
|
rules: {
|
40
|
-
...
|
401
|
+
...TYPESCRIPT_CONFIG.rules,
|
402
|
+
// @ts-expect-error: ignore
|
403
|
+
...vuePlugin.configs["flat/recommended"].rules,
|
404
|
+
// @ts-expect-error: ignore
|
405
|
+
...vuePlugin.configs["flat/strongly-recommended"].rules,
|
406
|
+
// @ts-expect-error: ignore
|
407
|
+
...vuePlugin.configs["flat/essential"].rules,
|
408
|
+
/**
|
409
|
+
* Disable some TypeScript rules that may conflict with the Vue SFC parser.
|
410
|
+
*/
|
411
|
+
"@typescript-eslint/no-unsafe-call": "off",
|
412
|
+
"@typescript-eslint/no-unsafe-return": "off",
|
413
|
+
"@typescript-eslint/no-misused-promises": "off",
|
414
|
+
"@typescript-eslint/no-unsafe-assignment": "off",
|
415
|
+
"@typescript-eslint/no-unsafe-member-access": "off",
|
41
416
|
/**
|
42
417
|
* Enforces consistent usage of type imports. This rule will enforce the use
|
43
418
|
* of `type` imports to make it easier for the Vue SFC compiler to analyze
|
@@ -46,28 +421,11 @@ function vue() {
|
|
46
421
|
* @see https://typescript-eslint.io/rules/consistent-type-imports
|
47
422
|
* @see https://vuejs.github.io/vetur/guide/FAQ.html#why-does-vetur-show-cannot-find-module-xxx
|
48
423
|
*/
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
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" } }],
|
424
|
+
// '@typescript-eslint/consistent-type-imports': ['error', {
|
425
|
+
// disallowTypeAnnotations: false,
|
426
|
+
// fixStyle: 'inline-type-imports',
|
427
|
+
// prefer: 'type-imports',
|
428
|
+
// }],
|
71
429
|
/**
|
72
430
|
* Enforce the order of the top-level properties in the component. This rule
|
73
431
|
* helps to maintain consistency and readability by enforcing a predictable
|
@@ -83,23 +441,15 @@ function vue() {
|
|
83
441
|
"style"
|
84
442
|
]
|
85
443
|
}],
|
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
444
|
/**
|
97
445
|
* Enforce use of the Composition API and TypeScript. This rule forbids the
|
98
446
|
* use of the Options API and JavaScript in Vue components for better
|
99
447
|
* consistency and maintainability.
|
100
448
|
*
|
101
449
|
* @see https://eslint.vuejs.org/rules/vue/prefer-define-options.html
|
450
|
+
* @see https://eslint.vuejs.org/rules/vue/component-api-style.html
|
102
451
|
*/
|
452
|
+
"vue/prefer-define-options": "error",
|
103
453
|
"vue/component-api-style": ["error", ["script-setup"]],
|
104
454
|
/**
|
105
455
|
* Enforce the component name casing to be PascalCase. This rules helps identify
|
@@ -112,30 +462,6 @@ function vue() {
|
|
112
462
|
ignores: ["/\\./"],
|
113
463
|
registeredComponentsOnly: !1
|
114
464
|
}],
|
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
465
|
/**
|
140
466
|
* Enforce consistent spacing between HTML comments and their content.
|
141
467
|
*
|
@@ -143,6 +469,10 @@ function vue() {
|
|
143
469
|
* @see https://eslint.vuejs.org/rules/html-comment-content-newline.html
|
144
470
|
*/
|
145
471
|
"vue/html-comment-content-spacing": ["error", "always"],
|
472
|
+
"vue/html-comment-content-newline": ["error", {
|
473
|
+
multiline: "always",
|
474
|
+
singleline: "never"
|
475
|
+
}],
|
146
476
|
/**
|
147
477
|
* Enforce consistent spacing between HTML / Component tags. This makes it
|
148
478
|
* easier to read and understand the structure of the component.
|
@@ -150,7 +480,17 @@ function vue() {
|
|
150
480
|
* @see https://eslint.vuejs.org/rules/padding-line-between-blocks.html
|
151
481
|
* @see https://eslint.vuejs.org/rules/padding-line-between-tags.html
|
152
482
|
*/
|
483
|
+
"vue/padding-line-between-blocks": ["error", "always"],
|
484
|
+
"vue/padding-line-between-tags": ["error", [
|
485
|
+
{ blankLine: "consistent", next: "*", prev: "*" },
|
486
|
+
{ blankLine: "always", next: "*", prev: "comment" }
|
487
|
+
]],
|
153
488
|
"vue/html-comment-indent": ["error", 2],
|
489
|
+
"vue/multiline-html-element-content-newline": ["error", {
|
490
|
+
allowEmptyLines: !0,
|
491
|
+
ignores: [],
|
492
|
+
ignoreWhenEmpty: !0
|
493
|
+
}],
|
154
494
|
/**
|
155
495
|
* Enforce consistent spacing and newlines in the template. This rule helps
|
156
496
|
* to maintain consistency and readability by enforcing a predictable
|
@@ -180,23 +520,7 @@ function vue() {
|
|
180
520
|
* @see https://eslint.vuejs.org/rules/multi-word-component-names.html
|
181
521
|
*/
|
182
522
|
"vue/multi-word-component-names": "off",
|
183
|
-
"vue/
|
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-/"],
|
523
|
+
"vue/no-reserved-component-names": "off",
|
200
524
|
/**
|
201
525
|
* Reports the destructuring or member expression of props passed to setup
|
202
526
|
* causing the value to lose reactivity. This rule helps to avoid common
|
@@ -205,9 +529,6 @@ function vue() {
|
|
205
529
|
* @see https://eslint.vuejs.org/rules/no-setup-props-reactivity-loss.html
|
206
530
|
*/
|
207
531
|
"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
532
|
/**
|
212
533
|
* Disallow v-if in v-for. This rule helps to avoid common pitfalls when
|
213
534
|
* using v-if and v-for together in the same element.
|
@@ -215,6 +536,27 @@ function vue() {
|
|
215
536
|
* @see https://eslint.vuejs.org/rules/no-use-v-if-with-v-for.html
|
216
537
|
*/
|
217
538
|
"vue/no-use-v-if-with-v-for": "error",
|
539
|
+
/**
|
540
|
+
* Enforce the declaration of emits in the setup function and warn on unused
|
541
|
+
* emits declarations. This rule helps reduce the risk stale code.
|
542
|
+
*
|
543
|
+
* @see https://eslint.vuejs.org/rules/require-explicit-emits.html
|
544
|
+
* @see https://eslint.vuejs.org/rules/no-unused-emit-declarations.html
|
545
|
+
*/
|
546
|
+
"vue/require-explicit-emits": "error",
|
547
|
+
/**
|
548
|
+
* Enforce the `@` shorthand over `v-on:` and only allow inline callbacks.
|
549
|
+
* This rule helps to maintain consistency and readability by enforcing a
|
550
|
+
* predictable order of the event handlers in the component.
|
551
|
+
*
|
552
|
+
* @see https://eslint.vuejs.org/rules/v-on-style.html
|
553
|
+
* @see https://eslint.vuejs.org/rules/v-on-handler-style.html
|
554
|
+
*/
|
555
|
+
"vue/v-on-style": ["error", "shorthand"],
|
556
|
+
"vue/return-in-computed-property": "off",
|
557
|
+
"vue/no-sparse-arrays": "error",
|
558
|
+
"vue/no-unused-emit-declarations": "error",
|
559
|
+
"vue/no-use-v-else-with-v-for": "error",
|
218
560
|
"vue/no-useless-v-bind": "error",
|
219
561
|
"vue/no-v-html": "off",
|
220
562
|
"vue/no-v-text-v-html-on-component": "error",
|
@@ -229,52 +571,89 @@ function vue() {
|
|
229
571
|
}
|
230
572
|
],
|
231
573
|
"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
574
|
"vue/prefer-import-from-vue": "off",
|
238
575
|
"vue/prefer-separate-static-class": "error",
|
239
576
|
"vue/prefer-template": "error",
|
240
577
|
"vue/quote-props": ["error", "consistent-as-needed"],
|
241
578
|
"vue/require-default-prop": "off",
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
"vue/
|
579
|
+
// reactivity transform
|
580
|
+
"vue/block-tag-newline": ["error", {
|
581
|
+
multiline: "always",
|
582
|
+
singleline: "always"
|
583
|
+
}],
|
584
|
+
// extensions
|
585
|
+
"vue/array-bracket-spacing": ["error", "never"],
|
586
|
+
"vue/arrow-spacing": ["error", { after: !0, before: !0 }],
|
587
|
+
"vue/block-lang": ["error", { script: { lang: "ts" } }],
|
588
|
+
"vue/block-spacing": ["error", "always"],
|
589
|
+
"vue/brace-style": ["error", "stroustrup", { allowSingleLine: !0 }],
|
590
|
+
"vue/comma-dangle": ["error", "always-multiline"],
|
591
|
+
"vue/comma-spacing": ["error", { after: !0, before: !1 }],
|
592
|
+
"vue/comma-style": ["error", "last"],
|
593
|
+
"vue/component-options-name-casing": ["error", "PascalCase"],
|
594
|
+
"vue/custom-event-name-casing": ["error", "camelCase"],
|
595
|
+
"vue/define-macros-order": ["error", {
|
596
|
+
order: ["defineProps", "defineEmits"]
|
597
|
+
}],
|
598
|
+
"vue/dot-location": ["error", "property"],
|
599
|
+
"vue/dot-notation": ["error", { allowKeywords: !0 }],
|
600
|
+
"vue/eqeqeq": ["error", "smart"],
|
601
|
+
"vue/first-attribute-linebreak": ["error", {
|
602
|
+
multiline: "below",
|
603
|
+
singleline: "beside"
|
604
|
+
}],
|
605
|
+
"vue/html-closing-bracket-newline": ["error", {
|
606
|
+
multiline: "never",
|
607
|
+
selfClosingTag: {
|
608
|
+
multiline: "always",
|
609
|
+
singleline: "never"
|
610
|
+
},
|
611
|
+
singleline: "never"
|
612
|
+
}],
|
613
|
+
"vue/no-constant-condition": "warn",
|
614
|
+
"vue/no-empty-pattern": "error",
|
615
|
+
"vue/no-extra-parens": ["error", "functions"],
|
616
|
+
"vue/no-irregular-whitespace": "error",
|
617
|
+
"vue/no-loss-of-precision": "error",
|
618
|
+
"vue/no-restricted-syntax": [
|
619
|
+
"error",
|
620
|
+
"DebuggerStatement",
|
621
|
+
"LabeledStatement",
|
622
|
+
"WithStatement"
|
623
|
+
],
|
624
|
+
"vue/no-restricted-v-bind": ["error", "/^v-/"],
|
250
625
|
"vue/require-prop-types": "off",
|
251
626
|
"vue/space-in-parens": ["error", "never"],
|
252
627
|
"vue/space-infix-ops": "error",
|
253
628
|
"vue/space-unary-ops": ["error", { nonwords: !1, words: !0 }],
|
254
629
|
"vue/template-curly-spacing": "error",
|
255
630
|
"vue/v-on-handler-style": ["error", "inline"],
|
256
|
-
/**
|
257
|
-
|
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"]
|
631
|
+
/** User-defined rules */
|
632
|
+
...options.rules
|
265
633
|
}
|
266
634
|
}
|
267
635
|
];
|
268
636
|
}
|
269
|
-
function vitest() {
|
637
|
+
function vitest(options) {
|
270
638
|
return [
|
271
639
|
{
|
640
|
+
plugins: {
|
641
|
+
vitest: vitestPlugin
|
642
|
+
},
|
272
643
|
files: [
|
273
644
|
"**/*.{ts,mts,cts,tsx,d.ts}",
|
274
645
|
"**/*.{js,mjs,cjs,jsx}"
|
275
646
|
],
|
276
|
-
|
277
|
-
vitest:
|
647
|
+
settings: {
|
648
|
+
vitest: {
|
649
|
+
typecheck: !0
|
650
|
+
}
|
651
|
+
},
|
652
|
+
languageOptions: {
|
653
|
+
globals: {
|
654
|
+
...vitestPlugin.environments.env.globals,
|
655
|
+
expectTypeOf: !0
|
656
|
+
}
|
278
657
|
},
|
279
658
|
rules: {
|
280
659
|
/**
|
@@ -306,418 +685,158 @@ function vitest() {
|
|
306
685
|
"vitest/no-conditional-in-test": "off",
|
307
686
|
"vitest/no-conditional-tests": "off",
|
308
687
|
/**
|
309
|
-
*
|
688
|
+
* Since we use in-source testing, we need to disable the rule as it may prevent
|
689
|
+
* us from using top level evaluation that are not part of the test suite.
|
310
690
|
*
|
311
691
|
* @see https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-hooks.md
|
312
692
|
*/
|
693
|
+
"vitest/require-hook": "off",
|
313
694
|
"vitest/no-hooks": "off",
|
314
695
|
/**
|
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.
|
696
|
+
* Disable the rule that enforces the use of `expect.assertions` in tests.
|
697
|
+
* As much as this rule enforces a best-practice, it is not always necessary.
|
643
698
|
*
|
644
|
-
* @see https://
|
699
|
+
* @see https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/prefer-expect-assertions.md
|
645
700
|
*/
|
646
|
-
"
|
701
|
+
"vitest/prefer-expect-assertions": "off",
|
647
702
|
/**
|
648
|
-
*
|
649
|
-
*
|
650
|
-
* This reduces the likelihood of a developer skipping over a declaration
|
651
|
-
* when modifying code.
|
703
|
+
* Some functions may have a single test case, and it is not necessary
|
704
|
+
* to wrap them in a describe block.
|
652
705
|
*
|
653
|
-
* @see https://
|
706
|
+
* @see https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/require-top-level-describe.md
|
654
707
|
*/
|
655
|
-
"
|
656
|
-
"no-useless-constructor": "off",
|
657
|
-
"object-curly-spacing": "off",
|
708
|
+
"vitest/require-top-level-describe": "off",
|
658
709
|
/**
|
659
|
-
* Enforce
|
660
|
-
*
|
661
|
-
*
|
662
|
-
* new lines.
|
710
|
+
* Enforce rule titles starts with 'should'. This is a convention
|
711
|
+
* to force the developer to write the test in a way that it reads
|
712
|
+
* like a sentence.
|
663
713
|
*
|
664
|
-
* @see https://
|
714
|
+
* @see https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/valid-title.md
|
665
715
|
*/
|
666
|
-
|
667
|
-
|
668
|
-
|
669
|
-
|
670
|
-
|
671
|
-
|
672
|
-
|
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"
|
716
|
+
"vitest/valid-title": ["error", {
|
717
|
+
ignoreTypeOfDescribeName: !0,
|
718
|
+
mustMatch: {
|
719
|
+
test: ["^should"]
|
720
|
+
}
|
721
|
+
}],
|
722
|
+
/** User-defined rules */
|
723
|
+
...options.rules
|
689
724
|
}
|
690
725
|
}
|
691
726
|
];
|
692
727
|
}
|
693
|
-
|
728
|
+
const UNICORN_RECOMMENDED_RULES = unicornPlugin.configs.recommended.rules;
|
729
|
+
function unicorn(options) {
|
694
730
|
return [
|
695
731
|
{
|
696
732
|
plugins: {
|
697
|
-
|
733
|
+
unicorn: unicornPlugin
|
698
734
|
},
|
699
735
|
rules: {
|
736
|
+
...UNICORN_RECOMMENDED_RULES,
|
700
737
|
/**
|
701
|
-
*
|
702
|
-
*
|
738
|
+
* Improve regexes by making them shorter, consistent, and safer. This rule
|
739
|
+
* aims to improve readability and consistency of regexes while also
|
740
|
+
* mitigating regex denial of service attacks by disallowing potentially
|
741
|
+
* catastrophic backtracking.
|
703
742
|
*
|
704
|
-
* @see https://
|
743
|
+
* @see https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/better-regex.md
|
705
744
|
*/
|
706
|
-
"
|
707
|
-
|
708
|
-
|
709
|
-
|
710
|
-
|
711
|
-
|
712
|
-
|
713
|
-
|
714
|
-
|
715
|
-
|
716
|
-
|
745
|
+
"unicorn/better-regex": "error",
|
746
|
+
/**
|
747
|
+
* Enforce the catch clause parameter name to be named `error`. This rule
|
748
|
+
* aims to enforce a consistent parameter name in catch clauses. The name
|
749
|
+
* `error` is the most commonly used name for the parameter that is passed
|
750
|
+
* to the catch clause.
|
751
|
+
*
|
752
|
+
* @see https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/catch-error-name.md
|
753
|
+
*/
|
754
|
+
"unicorn/catch-error-name": ["error", {
|
755
|
+
name: "error"
|
756
|
+
}],
|
757
|
+
/**
|
758
|
+
* Enforce the use of camelCase or PascalCase when naming folders, files and
|
759
|
+
* variables. This rule aims to enforce a consistent naming convention for
|
760
|
+
* filenames, directory names, and variable names.
|
761
|
+
*
|
762
|
+
* @see https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/filename-case.md
|
763
|
+
*/
|
764
|
+
"unicorn/filename-case": ["error", {
|
765
|
+
cases: {
|
766
|
+
camelCase: !0,
|
767
|
+
pascalCase: !0
|
768
|
+
},
|
769
|
+
ignore: [
|
770
|
+
"^[A-Z]+(.md)?$"
|
771
|
+
]
|
772
|
+
}],
|
773
|
+
/**
|
774
|
+
* Disable the recommended import style rules. We want to be able to use both
|
775
|
+
* named and default imports in our codebase.
|
776
|
+
*
|
777
|
+
* @see https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/import-style.md
|
778
|
+
*/
|
779
|
+
"unicorn/import-style": "off",
|
780
|
+
/**
|
781
|
+
* Disallow unsafe regular expressions. Regular expressions can be unsafe
|
782
|
+
* when they are too complex and can cause catastrophic backtracking. This
|
783
|
+
* rule disallows regular expressions that can lead to catastrophic
|
784
|
+
*
|
785
|
+
* @see https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-unsafe-regex.md
|
786
|
+
*/
|
787
|
+
"unicorn/no-unsafe-regex": "error",
|
788
|
+
/**
|
789
|
+
* Enforces a convention of grouping digits using numeric separators.
|
790
|
+
* Long numbers can become really hard to read, so cutting it into groups
|
791
|
+
* of digits, separated with a _, is important to keep your code clear.
|
792
|
+
*
|
793
|
+
* @see https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/numeric-separators-style.md
|
794
|
+
*/
|
795
|
+
"unicorn/numeric-separators-style": ["error", {
|
796
|
+
onlyIfContainsSeparator: !0
|
797
|
+
}],
|
798
|
+
"unicorn/number-literal-case": "error",
|
799
|
+
"unicorn/consistent-function-scoping": "off",
|
800
|
+
"unicorn/error-message": "error",
|
801
|
+
"unicorn/escape-case": "error",
|
802
|
+
"unicorn/no-array-callback-reference": "off",
|
803
|
+
"unicorn/no-array-for-each": "off",
|
804
|
+
"unicorn/no-array-instanceof": "error",
|
805
|
+
"unicorn/no-new-buffer": "error",
|
806
|
+
"unicorn/no-static-only-class": "off",
|
807
|
+
"unicorn/prefer-code-point": "off",
|
808
|
+
"unicorn/prefer-exponentiation-operator": "error",
|
809
|
+
"unicorn/prefer-includes": "error",
|
810
|
+
"unicorn/prefer-module": "off",
|
811
|
+
"unicorn/prefer-starts-ends-with": "error",
|
812
|
+
"unicorn/prefer-switch": "off",
|
813
|
+
"unicorn/prefer-text-content": "error",
|
814
|
+
"unicorn/prefer-type-error": "error",
|
815
|
+
"unicorn/prevent-abbreviations": ["error", {
|
816
|
+
allowList: {
|
817
|
+
args: !0,
|
818
|
+
dir: !0,
|
819
|
+
fn: !0,
|
820
|
+
i: !0,
|
821
|
+
j: !0,
|
822
|
+
k: !0,
|
823
|
+
props: !0,
|
824
|
+
Props: !0,
|
825
|
+
ref: !0,
|
826
|
+
v: !0,
|
827
|
+
x: !0,
|
828
|
+
y: !0,
|
829
|
+
z: !0
|
830
|
+
}
|
831
|
+
}],
|
832
|
+
"unicorn/throw-new-error": "error"
|
833
|
+
},
|
834
|
+
/** User-defined rules */
|
835
|
+
...options.rules
|
717
836
|
}
|
718
837
|
];
|
719
838
|
}
|
720
|
-
function sonarjs() {
|
839
|
+
function sonarjs(options) {
|
721
840
|
return new eslintrc.FlatCompat().config({
|
722
841
|
extends: [
|
723
842
|
"plugin:sonarjs/recommended"
|
@@ -745,53 +864,22 @@ function sonarjs() {
|
|
745
864
|
"sonarjs/no-duplicate-string": ["error", {
|
746
865
|
threshold: 10
|
747
866
|
}],
|
748
|
-
"sonarjs/no-empty-collection": "off",
|
749
|
-
"sonarjs/no-extra-arguments": "off",
|
750
|
-
"sonarjs/no-gratuitous-expressions": "off",
|
751
867
|
/**
|
752
868
|
* Those rules are crashing ESLint at startup, so they are disabled for now.
|
753
869
|
*/
|
870
|
+
"sonarjs/no-empty-collection": "off",
|
871
|
+
"sonarjs/no-extra-arguments": "off",
|
872
|
+
"sonarjs/no-gratuitous-expressions": "off",
|
754
873
|
"sonarjs/no-one-iteration-loop": "off",
|
755
874
|
"sonarjs/no-redundant-jump": "off",
|
756
875
|
"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
|
-
}]
|
876
|
+
"sonarjs/no-use-of-empty-return-value": "off",
|
877
|
+
/** User-defined rules */
|
878
|
+
...options.rules
|
791
879
|
}
|
792
880
|
});
|
793
881
|
}
|
794
|
-
function node() {
|
882
|
+
function node(options) {
|
795
883
|
return [
|
796
884
|
{
|
797
885
|
plugins: {
|
@@ -815,7 +903,16 @@ function node() {
|
|
815
903
|
*/
|
816
904
|
"n/no-missing-import": "off",
|
817
905
|
"n/no-missing-require": "off",
|
818
|
-
|
906
|
+
/**
|
907
|
+
* Enfore the use of the asyncrounous version of the `fs` and `dns` APIs.
|
908
|
+
*
|
909
|
+
* @see https://github.com/eslint-community/eslint-plugin-n/blob/HEAD/docs/rules/no-sync.md
|
910
|
+
* @see https://github.com/eslint-community/eslint-plugin-n/blob/HEAD/docs/rules/prefer-promises/fs.md
|
911
|
+
* @see https://github.com/eslint-community/eslint-plugin-n/blob/HEAD/docs/rules/prefer-promises/dns.md
|
912
|
+
*/
|
913
|
+
"n/no-sync": "off",
|
914
|
+
"n/prefer-promises/fs": "error",
|
915
|
+
"n/prefer-promises/dns": "error",
|
819
916
|
/**
|
820
917
|
* Allow the use of features up to Node.js version 20. This will allow
|
821
918
|
* the use of newer ECMAScript features and Node.js APIs.
|
@@ -823,6 +920,7 @@ function node() {
|
|
823
920
|
* @see https://github.com/eslint-community/eslint-plugin-n/tree/master/docs/rules
|
824
921
|
*/
|
825
922
|
"n/no-unsupported-features/es-syntax": "error",
|
923
|
+
"n/no-unsupported-features/es-builtins": "error",
|
826
924
|
"n/no-unsupported-features/node-builtins": "error",
|
827
925
|
/**
|
828
926
|
* Prepend the `node:` prefix to all Node.js core modules. This helps
|
@@ -831,7 +929,9 @@ function node() {
|
|
831
929
|
*
|
832
930
|
* @see https://github.com/eslint-community/eslint-plugin-n/blob/HEAD/docs/rules/prefer-node-protocol.md
|
833
931
|
*/
|
834
|
-
"n/prefer-node-protocol": "error"
|
932
|
+
"n/prefer-node-protocol": "error",
|
933
|
+
/** User-defined rules */
|
934
|
+
...options.rules
|
835
935
|
},
|
836
936
|
settings: {
|
837
937
|
node: {
|
@@ -1043,7 +1143,7 @@ function jsonPackage() {
|
|
1043
1143
|
}
|
1044
1144
|
];
|
1045
1145
|
}
|
1046
|
-
function configJson() {
|
1146
|
+
function configJson(options) {
|
1047
1147
|
return [
|
1048
1148
|
...jsonc.configs["flat/recommended-with-json"],
|
1049
1149
|
{
|
@@ -1057,19 +1157,21 @@ function configJson() {
|
|
1057
1157
|
*
|
1058
1158
|
* @see https://ota-meshi.github.io/eslint-plugin-jsonc/rules/auto.html
|
1059
1159
|
*/
|
1060
|
-
"jsonc/auto": "error"
|
1160
|
+
"jsonc/auto": "error",
|
1161
|
+
/** User-defined rules */
|
1162
|
+
...options.rules
|
1061
1163
|
}
|
1062
1164
|
}
|
1063
1165
|
];
|
1064
1166
|
}
|
1065
|
-
function jsdoc() {
|
1167
|
+
function jsdoc(options) {
|
1066
1168
|
return [
|
1067
1169
|
pluginJsdoc.configs["flat/recommended-typescript-flavor-error"],
|
1068
1170
|
{
|
1069
1171
|
files: [
|
1070
|
-
"**/*.
|
1071
|
-
"**/*.
|
1072
|
-
"**/*.
|
1172
|
+
"**/*.{ts,mts,cts,tsx,d.ts}",
|
1173
|
+
"**/*.{js,mjs,cjs,jsx}",
|
1174
|
+
"**/*.vue"
|
1073
1175
|
],
|
1074
1176
|
rules: {
|
1075
1177
|
/**
|
@@ -1090,6 +1192,8 @@ function jsdoc() {
|
|
1090
1192
|
*
|
1091
1193
|
* @see https://github.com/gajus/eslint-plugin-jsdoc/blob/main/.README/rules/check-tag-names.md
|
1092
1194
|
*/
|
1195
|
+
"jsdoc/require-jsdoc": "off",
|
1196
|
+
"jsdoc/require-param-type": "off",
|
1093
1197
|
"jsdoc/check-tag-names": ["error", {
|
1094
1198
|
definedTags: [
|
1095
1199
|
"category"
|
@@ -1099,7 +1203,7 @@ function jsdoc() {
|
|
1099
1203
|
* Checks for multi-line-style comments which fail to meet the criteria of a jsdoc block,
|
1100
1204
|
* namely that it should begin with two and only two asterisks.
|
1101
1205
|
*
|
1102
|
-
* @see https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/no-bad-blocks.md
|
1206
|
+
* @see https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/no-bad-blocks.md
|
1103
1207
|
*/
|
1104
1208
|
"jsdoc/no-bad-blocks": "error",
|
1105
1209
|
/**
|
@@ -1107,129 +1211,29 @@ function jsdoc() {
|
|
1107
1211
|
* is sometimes forgotten and has no real purpose. This rule aims to enforce
|
1108
1212
|
* that no hyphen is used.
|
1109
1213
|
*
|
1110
|
-
* @see https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-hyphen-before-param-description
|
1214
|
+
* @see https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-hyphen-before-param-description
|
1111
1215
|
*/
|
1112
1216
|
"jsdoc/require-hyphen-before-param-description": ["error", "never"],
|
1113
|
-
"jsdoc/require-jsdoc": "off",
|
1114
|
-
"jsdoc/require-param-type": "off",
|
1115
1217
|
/**
|
1116
1218
|
* Since we are using TypeScript, we don't need to enforce types in JSDoc.
|
1117
1219
|
*
|
1118
|
-
* @see https://github.com/gajus/eslint-plugin-jsdoc/blob/main
|
1220
|
+
* @see https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-param-type.md
|
1119
1221
|
*/
|
1120
1222
|
"jsdoc/require-returns-type": "off",
|
1121
1223
|
/**
|
1122
1224
|
* Enforce a new-line between the JSDoc summary and tags. Aims to improve
|
1123
1225
|
* readability by separating the summary and tags.
|
1124
1226
|
*
|
1125
|
-
* @see https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/tag-lines.md
|
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
|
1227
|
+
* @see https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/tag-lines.md
|
1178
1228
|
*/
|
1179
|
-
"
|
1180
|
-
|
1181
|
-
|
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"
|
1229
|
+
"jsdoc/tag-lines": ["error", "any", { startLines: 1 }],
|
1230
|
+
/** User-defined rules */
|
1231
|
+
...options.rules
|
1228
1232
|
}
|
1229
1233
|
}
|
1230
1234
|
];
|
1231
1235
|
}
|
1232
|
-
function eslintComments() {
|
1236
|
+
function eslintComments(options) {
|
1233
1237
|
return [
|
1234
1238
|
{
|
1235
1239
|
plugins: {
|
@@ -1272,12 +1276,14 @@ function eslintComments() {
|
|
1272
1276
|
*
|
1273
1277
|
* @see https://mysticatea.github.io/eslint-plugin-eslint-comments/rules/no-unused-disable
|
1274
1278
|
*/
|
1275
|
-
"eslint-comments/no-unused-disable": "error"
|
1279
|
+
"eslint-comments/no-unused-disable": "error",
|
1280
|
+
/** User-defined rules */
|
1281
|
+
...options.rules
|
1276
1282
|
}
|
1277
1283
|
}
|
1278
1284
|
];
|
1279
1285
|
}
|
1280
|
-
function antfu() {
|
1286
|
+
function antfu(options) {
|
1281
1287
|
return [
|
1282
1288
|
{
|
1283
1289
|
plugins: {
|
@@ -1309,30 +1315,27 @@ function antfu() {
|
|
1309
1315
|
*
|
1310
1316
|
* @see https://github.com/antfu/eslint-plugin-antfu/blob/main/src/rules/consistent-list-newline.md
|
1311
1317
|
*/
|
1312
|
-
"object-curly-newline": "off"
|
1318
|
+
"object-curly-newline": "off",
|
1319
|
+
/** User-defined rules */
|
1320
|
+
...options.rules
|
1313
1321
|
}
|
1314
1322
|
}
|
1315
1323
|
];
|
1316
1324
|
}
|
1317
|
-
function all() {
|
1325
|
+
function all(options = {}) {
|
1318
1326
|
return [
|
1319
|
-
...antfu(),
|
1320
|
-
...eslintComments(),
|
1321
|
-
...
|
1322
|
-
...
|
1323
|
-
...configJson(),
|
1327
|
+
...antfu(options),
|
1328
|
+
...eslintComments(options),
|
1329
|
+
...jsdoc(options),
|
1330
|
+
...configJson(options),
|
1324
1331
|
...jsonPackage(),
|
1325
1332
|
...jsonTsconfig(),
|
1326
|
-
...node(),
|
1327
|
-
...
|
1328
|
-
...
|
1329
|
-
...
|
1330
|
-
...
|
1331
|
-
...
|
1332
|
-
...vitest(),
|
1333
|
-
...vue(),
|
1334
|
-
// ...promise(),
|
1335
|
-
// ...markdown(),
|
1333
|
+
...node(options),
|
1334
|
+
...sonarjs(options),
|
1335
|
+
...typescript(options),
|
1336
|
+
...unicorn(options),
|
1337
|
+
...vitest(options),
|
1338
|
+
...vue(options),
|
1336
1339
|
{
|
1337
1340
|
ignores: [
|
1338
1341
|
"**/dist",
|
@@ -1353,6 +1356,5 @@ function all() {
|
|
1353
1356
|
}
|
1354
1357
|
];
|
1355
1358
|
}
|
1356
|
-
|
1357
|
-
module.exports = index;
|
1359
|
+
module.exports = all;
|
1358
1360
|
//# sourceMappingURL=index.cjs.map
|