@antfu/eslint-config 1.0.0-beta.2 → 1.0.0-beta.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +115 -44
- package/dist/index.cjs +1602 -0
- package/dist/index.d.cts +236 -0
- package/dist/index.d.ts +123 -36
- package/dist/index.js +972 -725
- package/package.json +42 -32
package/dist/index.js
CHANGED
|
@@ -1,60 +1,83 @@
|
|
|
1
1
|
// src/factory.ts
|
|
2
2
|
import process2 from "process";
|
|
3
|
+
import fs from "fs";
|
|
3
4
|
import { isPackageExists } from "local-pkg";
|
|
4
|
-
|
|
5
|
-
// src/flags.ts
|
|
6
|
-
var OFF = 0;
|
|
5
|
+
import gitignore from "eslint-config-flat-gitignore";
|
|
7
6
|
|
|
8
7
|
// src/plugins.ts
|
|
9
8
|
import { default as default2 } from "eslint-plugin-antfu";
|
|
10
9
|
import { default as default3 } from "eslint-plugin-eslint-comments";
|
|
11
|
-
import
|
|
12
|
-
import { default as
|
|
13
|
-
import
|
|
14
|
-
import { default as
|
|
15
|
-
import { default as
|
|
16
|
-
import { default as
|
|
17
|
-
import { default as
|
|
18
|
-
import { default as
|
|
19
|
-
import { default as
|
|
20
|
-
import { default as
|
|
21
|
-
import
|
|
22
|
-
import { default as
|
|
23
|
-
import { default as
|
|
24
|
-
import
|
|
25
|
-
import { default as
|
|
26
|
-
import { default as
|
|
27
|
-
import { default as
|
|
10
|
+
import * as pluginImport from "eslint-plugin-i";
|
|
11
|
+
import { default as default4 } from "eslint-plugin-jsdoc";
|
|
12
|
+
import * as pluginJsonc from "eslint-plugin-jsonc";
|
|
13
|
+
import { default as default5 } from "eslint-plugin-markdown";
|
|
14
|
+
import { default as default6 } from "eslint-plugin-n";
|
|
15
|
+
import { default as default7 } from "@stylistic/eslint-plugin";
|
|
16
|
+
import { default as default8 } from "@typescript-eslint/eslint-plugin";
|
|
17
|
+
import { default as default9 } from "eslint-plugin-unicorn";
|
|
18
|
+
import { default as default10 } from "eslint-plugin-unused-imports";
|
|
19
|
+
import { default as default11 } from "eslint-plugin-vue";
|
|
20
|
+
import * as pluginYaml from "eslint-plugin-yml";
|
|
21
|
+
import { default as default12 } from "eslint-plugin-no-only-tests";
|
|
22
|
+
import { default as default13 } from "eslint-plugin-vitest";
|
|
23
|
+
import * as parserTs from "@typescript-eslint/parser";
|
|
24
|
+
import { default as default14 } from "vue-eslint-parser";
|
|
25
|
+
import { default as default15 } from "yaml-eslint-parser";
|
|
26
|
+
import { default as default16 } from "jsonc-eslint-parser";
|
|
28
27
|
|
|
29
28
|
// src/configs/comments.ts
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
"eslint-comments"
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
29
|
+
function comments() {
|
|
30
|
+
return [
|
|
31
|
+
{
|
|
32
|
+
name: "antfu:eslint-comments",
|
|
33
|
+
plugins: {
|
|
34
|
+
"eslint-comments": default3
|
|
35
|
+
},
|
|
36
|
+
rules: {
|
|
37
|
+
"eslint-comments/no-aggregating-enable": "error",
|
|
38
|
+
"eslint-comments/no-duplicate-disable": "error",
|
|
39
|
+
"eslint-comments/no-unlimited-disable": "error",
|
|
40
|
+
"eslint-comments/no-unused-enable": "error"
|
|
41
|
+
}
|
|
38
42
|
}
|
|
39
|
-
|
|
40
|
-
|
|
43
|
+
];
|
|
44
|
+
}
|
|
41
45
|
|
|
42
46
|
// src/globs.ts
|
|
43
47
|
var GLOB_SRC_EXT = "?([cm])[jt]s?(x)";
|
|
44
48
|
var GLOB_SRC = "**/*.?([cm])[jt]s?(x)";
|
|
49
|
+
var GLOB_JS = "**/*.?([cm])js";
|
|
50
|
+
var GLOB_JSX = "**/*.?([cm])jsx";
|
|
45
51
|
var GLOB_TS = "**/*.?([cm])ts";
|
|
46
52
|
var GLOB_TSX = "**/*.?([cm])tsx";
|
|
53
|
+
var GLOB_STYLE = "**/*.{c,le,sc}ss";
|
|
54
|
+
var GLOB_CSS = "**/*.css";
|
|
55
|
+
var GLOB_LESS = "**/*.less";
|
|
56
|
+
var GLOB_SCSS = "**/*.scss";
|
|
47
57
|
var GLOB_JSON = "**/*.json";
|
|
48
58
|
var GLOB_JSON5 = "**/*.json5";
|
|
49
59
|
var GLOB_JSONC = "**/*.jsonc";
|
|
50
60
|
var GLOB_MARKDOWN = "**/*.md";
|
|
51
61
|
var GLOB_VUE = "**/*.vue";
|
|
52
62
|
var GLOB_YAML = "**/*.y?(a)ml";
|
|
63
|
+
var GLOB_HTML = "**/*.htm?(l)";
|
|
53
64
|
var GLOB_MARKDOWN_CODE = `${GLOB_MARKDOWN}/${GLOB_SRC}`;
|
|
54
65
|
var GLOB_TESTS = [
|
|
55
66
|
`**/__tests__/**/*.${GLOB_SRC_EXT}`,
|
|
56
67
|
`**/*.spec.${GLOB_SRC_EXT}`,
|
|
57
|
-
`**/*.test.${GLOB_SRC_EXT}
|
|
68
|
+
`**/*.test.${GLOB_SRC_EXT}`,
|
|
69
|
+
`**/*.bench.${GLOB_SRC_EXT}`,
|
|
70
|
+
`**/*.benchmark.${GLOB_SRC_EXT}`
|
|
71
|
+
];
|
|
72
|
+
var GLOB_ALL_SRC = [
|
|
73
|
+
GLOB_SRC,
|
|
74
|
+
GLOB_STYLE,
|
|
75
|
+
GLOB_JSON,
|
|
76
|
+
GLOB_JSON5,
|
|
77
|
+
GLOB_MARKDOWN,
|
|
78
|
+
GLOB_VUE,
|
|
79
|
+
GLOB_YAML,
|
|
80
|
+
GLOB_HTML
|
|
58
81
|
];
|
|
59
82
|
var GLOB_EXCLUDE = [
|
|
60
83
|
"**/node_modules",
|
|
@@ -62,6 +85,7 @@ var GLOB_EXCLUDE = [
|
|
|
62
85
|
"**/package-lock.json",
|
|
63
86
|
"**/yarn.lock",
|
|
64
87
|
"**/pnpm-lock.yaml",
|
|
88
|
+
"**/bun.lockb",
|
|
65
89
|
"**/output",
|
|
66
90
|
"**/coverage",
|
|
67
91
|
"**/temp",
|
|
@@ -70,6 +94,7 @@ var GLOB_EXCLUDE = [
|
|
|
70
94
|
"**/.vercel",
|
|
71
95
|
"**/.changeset",
|
|
72
96
|
"**/.idea",
|
|
97
|
+
"**/.cache",
|
|
73
98
|
"**/.output",
|
|
74
99
|
"**/.vite-inspect",
|
|
75
100
|
"**/CHANGELOG*.md",
|
|
@@ -81,33 +106,56 @@ var GLOB_EXCLUDE = [
|
|
|
81
106
|
];
|
|
82
107
|
|
|
83
108
|
// src/configs/ignores.ts
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
109
|
+
function ignores() {
|
|
110
|
+
return [
|
|
111
|
+
{
|
|
112
|
+
ignores: GLOB_EXCLUDE
|
|
113
|
+
}
|
|
114
|
+
];
|
|
115
|
+
}
|
|
87
116
|
|
|
88
117
|
// src/configs/imports.ts
|
|
89
|
-
|
|
90
|
-
{
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
118
|
+
function imports(options = {}) {
|
|
119
|
+
const {
|
|
120
|
+
stylistic: stylistic2 = true
|
|
121
|
+
} = options;
|
|
122
|
+
return [
|
|
123
|
+
{
|
|
124
|
+
name: "antfu:imports",
|
|
125
|
+
plugins: {
|
|
126
|
+
antfu: default2,
|
|
127
|
+
import: pluginImport
|
|
128
|
+
},
|
|
129
|
+
rules: {
|
|
130
|
+
"antfu/import-dedupe": "error",
|
|
131
|
+
"antfu/no-import-node-modules-by-path": "error",
|
|
132
|
+
"import/first": "error",
|
|
133
|
+
"import/no-duplicates": "error",
|
|
134
|
+
"import/no-mutable-exports": "error",
|
|
135
|
+
"import/no-named-default": "error",
|
|
136
|
+
"import/no-self-import": "error",
|
|
137
|
+
"import/no-webpack-loader-syntax": "error",
|
|
138
|
+
"import/order": "error",
|
|
139
|
+
...stylistic2 ? {
|
|
140
|
+
"import/newline-after-import": ["error", { considerComments: true, count: 1 }]
|
|
141
|
+
} : {}
|
|
142
|
+
}
|
|
104
143
|
}
|
|
105
|
-
|
|
106
|
-
|
|
144
|
+
];
|
|
145
|
+
}
|
|
107
146
|
|
|
108
147
|
// src/configs/javascript.ts
|
|
109
148
|
import globals from "globals";
|
|
149
|
+
|
|
150
|
+
// src/flags.ts
|
|
151
|
+
var OFF = 0;
|
|
152
|
+
|
|
153
|
+
// src/configs/javascript.ts
|
|
110
154
|
function javascript(options = {}) {
|
|
155
|
+
const {
|
|
156
|
+
isInEditor = false,
|
|
157
|
+
overrides = {}
|
|
158
|
+
} = options;
|
|
111
159
|
return [
|
|
112
160
|
{
|
|
113
161
|
languageOptions: {
|
|
@@ -129,30 +177,22 @@ function javascript(options = {}) {
|
|
|
129
177
|
},
|
|
130
178
|
sourceType: "module"
|
|
131
179
|
},
|
|
180
|
+
name: "antfu:javascript",
|
|
132
181
|
plugins: {
|
|
133
182
|
"antfu": default2,
|
|
134
|
-
"unused-imports":
|
|
183
|
+
"unused-imports": default10
|
|
135
184
|
},
|
|
136
185
|
rules: {
|
|
137
186
|
"accessor-pairs": ["error", { enforceForClassMembers: true, setWithoutGet: true }],
|
|
138
|
-
"antfu/import-dedupe": "error",
|
|
139
|
-
"antfu/no-import-node-modules-by-path": "error",
|
|
140
|
-
"antfu/top-level-function": "error",
|
|
141
187
|
"array-callback-return": "error",
|
|
142
188
|
"arrow-parens": ["error", "as-needed", { requireForBlockBody: true }],
|
|
143
189
|
"block-scoped-var": "error",
|
|
144
|
-
"camelcase": OFF,
|
|
145
|
-
"complexity": OFF,
|
|
146
|
-
"consistent-return": OFF,
|
|
147
190
|
"constructor-super": "error",
|
|
148
191
|
"default-case-last": "error",
|
|
149
192
|
"dot-notation": ["error", { allowKeywords: true }],
|
|
150
|
-
"eol-last": "error",
|
|
151
193
|
"eqeqeq": ["error", "smart"],
|
|
152
|
-
"max-statements-per-line": ["error", { max: 1 }],
|
|
153
194
|
"new-cap": ["error", { capIsNew: false, newIsCap: true, properties: true }],
|
|
154
|
-
"
|
|
155
|
-
"no-alert": "warn",
|
|
195
|
+
"no-alert": "error",
|
|
156
196
|
"no-array-constructor": "error",
|
|
157
197
|
"no-async-promise-executor": "error",
|
|
158
198
|
"no-caller": "error",
|
|
@@ -162,7 +202,6 @@ function javascript(options = {}) {
|
|
|
162
202
|
"no-cond-assign": ["error", "always"],
|
|
163
203
|
"no-console": ["error", { allow: ["warn", "error"] }],
|
|
164
204
|
"no-const-assign": "error",
|
|
165
|
-
"no-constant-condition": "warn",
|
|
166
205
|
"no-control-regex": "error",
|
|
167
206
|
"no-debugger": "error",
|
|
168
207
|
"no-delete-var": "error",
|
|
@@ -178,9 +217,7 @@ function javascript(options = {}) {
|
|
|
178
217
|
"no-extend-native": "error",
|
|
179
218
|
"no-extra-bind": "error",
|
|
180
219
|
"no-extra-boolean-cast": "error",
|
|
181
|
-
"no-extra-parens": ["error", "functions"],
|
|
182
220
|
"no-fallthrough": "error",
|
|
183
|
-
"no-floating-decimal": "error",
|
|
184
221
|
"no-func-assign": "error",
|
|
185
222
|
"no-global-assign": "error",
|
|
186
223
|
"no-implied-eval": "error",
|
|
@@ -193,14 +230,6 @@ function javascript(options = {}) {
|
|
|
193
230
|
"no-lone-blocks": "error",
|
|
194
231
|
"no-loss-of-precision": "error",
|
|
195
232
|
"no-misleading-character-class": "error",
|
|
196
|
-
"no-mixed-operators": ["error", {
|
|
197
|
-
allowSamePrecedence: true,
|
|
198
|
-
groups: [
|
|
199
|
-
["==", "!=", "===", "!==", ">", ">=", "<", "<="],
|
|
200
|
-
["&&", "||"],
|
|
201
|
-
["in", "instanceof"]
|
|
202
|
-
]
|
|
203
|
-
}],
|
|
204
233
|
"no-multi-str": "error",
|
|
205
234
|
"no-new": "error",
|
|
206
235
|
"no-new-func": "error",
|
|
@@ -210,7 +239,6 @@ function javascript(options = {}) {
|
|
|
210
239
|
"no-obj-calls": "error",
|
|
211
240
|
"no-octal": "error",
|
|
212
241
|
"no-octal-escape": "error",
|
|
213
|
-
"no-param-reassign": OFF,
|
|
214
242
|
"no-proto": "error",
|
|
215
243
|
"no-prototype-builtins": "error",
|
|
216
244
|
"no-redeclare": ["error", { builtinGlobals: false }],
|
|
@@ -232,10 +260,10 @@ function javascript(options = {}) {
|
|
|
232
260
|
"error",
|
|
233
261
|
"DebuggerStatement",
|
|
234
262
|
"LabeledStatement",
|
|
235
|
-
"WithStatement"
|
|
263
|
+
"WithStatement",
|
|
264
|
+
"TSEnumDeclaration[const=true]",
|
|
265
|
+
"TSExportAssignment"
|
|
236
266
|
],
|
|
237
|
-
"no-return-assign": OFF,
|
|
238
|
-
"no-return-await": OFF,
|
|
239
267
|
"no-self-assign": ["error", { props: true }],
|
|
240
268
|
"no-self-compare": "error",
|
|
241
269
|
"no-sequences": "error",
|
|
@@ -270,7 +298,6 @@ function javascript(options = {}) {
|
|
|
270
298
|
"no-useless-catch": "error",
|
|
271
299
|
"no-useless-computed-key": "error",
|
|
272
300
|
"no-useless-constructor": "error",
|
|
273
|
-
"no-useless-escape": OFF,
|
|
274
301
|
"no-useless-rename": "error",
|
|
275
302
|
"no-useless-return": "error",
|
|
276
303
|
"no-var": "error",
|
|
@@ -305,8 +332,6 @@ function javascript(options = {}) {
|
|
|
305
332
|
"prefer-rest-params": "error",
|
|
306
333
|
"prefer-spread": "error",
|
|
307
334
|
"prefer-template": "error",
|
|
308
|
-
"quote-props": ["error", "consistent-as-needed"],
|
|
309
|
-
"require-await": OFF,
|
|
310
335
|
"sort-imports": [
|
|
311
336
|
"error",
|
|
312
337
|
{
|
|
@@ -319,20 +344,21 @@ function javascript(options = {}) {
|
|
|
319
344
|
],
|
|
320
345
|
"symbol-description": "error",
|
|
321
346
|
"unicode-bom": ["error", "never"],
|
|
322
|
-
"unused-imports/no-unused-imports":
|
|
347
|
+
"unused-imports/no-unused-imports": isInEditor ? OFF : "error",
|
|
323
348
|
"unused-imports/no-unused-vars": [
|
|
324
|
-
"
|
|
349
|
+
"error",
|
|
325
350
|
{ args: "after-used", argsIgnorePattern: "^_", vars: "all", varsIgnorePattern: "^_" }
|
|
326
351
|
],
|
|
327
352
|
"use-isnan": ["error", { enforceForIndexOf: true, enforceForSwitchCase: true }],
|
|
328
353
|
"valid-typeof": ["error", { requireStringLiterals: true }],
|
|
329
354
|
"vars-on-top": "error",
|
|
330
|
-
"
|
|
331
|
-
|
|
355
|
+
"yoda": ["error", "never"],
|
|
356
|
+
...overrides
|
|
332
357
|
}
|
|
333
358
|
},
|
|
334
359
|
{
|
|
335
|
-
files: [
|
|
360
|
+
files: [`scripts/${GLOB_SRC}`, `cli.${GLOB_SRC_EXT}`],
|
|
361
|
+
name: "antfu:scripts-overrides",
|
|
336
362
|
rules: {
|
|
337
363
|
"no-console": OFF
|
|
338
364
|
}
|
|
@@ -341,65 +367,124 @@ function javascript(options = {}) {
|
|
|
341
367
|
}
|
|
342
368
|
|
|
343
369
|
// src/configs/jsdoc.ts
|
|
344
|
-
|
|
345
|
-
{
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
370
|
+
function jsdoc(options = {}) {
|
|
371
|
+
const {
|
|
372
|
+
stylistic: stylistic2 = true
|
|
373
|
+
} = options;
|
|
374
|
+
return [
|
|
375
|
+
{
|
|
376
|
+
name: "antfu:jsdoc",
|
|
377
|
+
plugins: {
|
|
378
|
+
jsdoc: default4
|
|
379
|
+
},
|
|
380
|
+
rules: {
|
|
381
|
+
"jsdoc/check-access": "warn",
|
|
382
|
+
"jsdoc/check-param-names": "warn",
|
|
383
|
+
"jsdoc/check-property-names": "warn",
|
|
384
|
+
"jsdoc/check-types": "warn",
|
|
385
|
+
"jsdoc/empty-tags": "warn",
|
|
386
|
+
"jsdoc/implements-on-classes": "warn",
|
|
387
|
+
"jsdoc/no-defaults": "warn",
|
|
388
|
+
"jsdoc/no-multi-asterisks": "warn",
|
|
389
|
+
"jsdoc/require-param-name": "warn",
|
|
390
|
+
"jsdoc/require-property": "warn",
|
|
391
|
+
"jsdoc/require-property-description": "warn",
|
|
392
|
+
"jsdoc/require-property-name": "warn",
|
|
393
|
+
"jsdoc/require-returns-check": "warn",
|
|
394
|
+
"jsdoc/require-returns-description": "warn",
|
|
395
|
+
"jsdoc/require-yields-check": "warn",
|
|
396
|
+
...stylistic2 ? {
|
|
397
|
+
"jsdoc/check-alignment": "warn",
|
|
398
|
+
"jsdoc/multiline-blocks": "warn"
|
|
399
|
+
} : {}
|
|
400
|
+
}
|
|
363
401
|
}
|
|
364
|
-
|
|
365
|
-
|
|
402
|
+
];
|
|
403
|
+
}
|
|
366
404
|
|
|
367
405
|
// src/configs/jsonc.ts
|
|
368
|
-
|
|
369
|
-
{
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
406
|
+
function jsonc(options = {}) {
|
|
407
|
+
const {
|
|
408
|
+
stylistic: stylistic2 = true,
|
|
409
|
+
overrides = {}
|
|
410
|
+
} = options;
|
|
411
|
+
const {
|
|
412
|
+
indent = 2
|
|
413
|
+
} = typeof stylistic2 === "boolean" ? {} : stylistic2;
|
|
414
|
+
return [
|
|
415
|
+
{
|
|
416
|
+
name: "antfu:jsonc:setup",
|
|
417
|
+
plugins: {
|
|
418
|
+
jsonc: pluginJsonc
|
|
419
|
+
}
|
|
376
420
|
},
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
"jsonc
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
421
|
+
{
|
|
422
|
+
files: [GLOB_JSON, GLOB_JSON5, GLOB_JSONC],
|
|
423
|
+
languageOptions: {
|
|
424
|
+
parser: default16
|
|
425
|
+
},
|
|
426
|
+
name: "antfu:jsonc:rules",
|
|
427
|
+
rules: {
|
|
428
|
+
"jsonc/no-bigint-literals": "error",
|
|
429
|
+
"jsonc/no-binary-expression": "error",
|
|
430
|
+
"jsonc/no-binary-numeric-literals": "error",
|
|
431
|
+
"jsonc/no-dupe-keys": "error",
|
|
432
|
+
"jsonc/no-escape-sequence-in-identifier": "error",
|
|
433
|
+
"jsonc/no-floating-decimal": "error",
|
|
434
|
+
"jsonc/no-hexadecimal-numeric-literals": "error",
|
|
435
|
+
"jsonc/no-infinity": "error",
|
|
436
|
+
"jsonc/no-multi-str": "error",
|
|
437
|
+
"jsonc/no-nan": "error",
|
|
438
|
+
"jsonc/no-number-props": "error",
|
|
439
|
+
"jsonc/no-numeric-separators": "error",
|
|
440
|
+
"jsonc/no-octal": "error",
|
|
441
|
+
"jsonc/no-octal-escape": "error",
|
|
442
|
+
"jsonc/no-octal-numeric-literals": "error",
|
|
443
|
+
"jsonc/no-parenthesized": "error",
|
|
444
|
+
"jsonc/no-plus-sign": "error",
|
|
445
|
+
"jsonc/no-regexp-literals": "error",
|
|
446
|
+
"jsonc/no-sparse-arrays": "error",
|
|
447
|
+
"jsonc/no-template-literals": "error",
|
|
448
|
+
"jsonc/no-undefined-value": "error",
|
|
449
|
+
"jsonc/no-unicode-codepoint-escapes": "error",
|
|
450
|
+
"jsonc/no-useless-escape": "error",
|
|
451
|
+
"jsonc/space-unary-ops": "error",
|
|
452
|
+
"jsonc/valid-json-number": "error",
|
|
453
|
+
"jsonc/vue-custom-block/no-parsing-error": "error",
|
|
454
|
+
...stylistic2 ? {
|
|
455
|
+
"jsonc/array-bracket-spacing": ["error", "never"],
|
|
456
|
+
"jsonc/comma-dangle": ["error", "never"],
|
|
457
|
+
"jsonc/comma-style": ["error", "last"],
|
|
458
|
+
"jsonc/indent": ["error", indent],
|
|
459
|
+
"jsonc/key-spacing": ["error", { afterColon: true, beforeColon: false }],
|
|
460
|
+
"jsonc/object-curly-newline": ["error", { consistent: true, multiline: true }],
|
|
461
|
+
"jsonc/object-curly-spacing": ["error", "always"],
|
|
462
|
+
"jsonc/object-property-newline": ["error", { allowMultiplePropertiesPerLine: true }],
|
|
463
|
+
"jsonc/quote-props": "error",
|
|
464
|
+
"jsonc/quotes": "error"
|
|
465
|
+
} : {},
|
|
466
|
+
...overrides
|
|
467
|
+
}
|
|
388
468
|
}
|
|
389
|
-
|
|
390
|
-
|
|
469
|
+
];
|
|
470
|
+
}
|
|
391
471
|
|
|
392
472
|
// src/configs/markdown.ts
|
|
393
473
|
function markdown(options = {}) {
|
|
394
474
|
const {
|
|
395
|
-
componentExts = []
|
|
475
|
+
componentExts = [],
|
|
476
|
+
overrides = {}
|
|
396
477
|
} = options;
|
|
397
478
|
return [
|
|
398
479
|
{
|
|
399
|
-
|
|
480
|
+
name: "antfu:markdown:setup",
|
|
400
481
|
plugins: {
|
|
401
|
-
markdown:
|
|
402
|
-
}
|
|
482
|
+
markdown: default5
|
|
483
|
+
}
|
|
484
|
+
},
|
|
485
|
+
{
|
|
486
|
+
files: [GLOB_MARKDOWN],
|
|
487
|
+
name: "antfu:markdown:processor",
|
|
403
488
|
processor: "markdown/markdown"
|
|
404
489
|
},
|
|
405
490
|
{
|
|
@@ -414,22 +499,18 @@ function markdown(options = {}) {
|
|
|
414
499
|
}
|
|
415
500
|
}
|
|
416
501
|
},
|
|
417
|
-
|
|
418
|
-
ts: default11
|
|
419
|
-
},
|
|
502
|
+
name: "antfu:markdown:rules",
|
|
420
503
|
rules: {
|
|
421
|
-
...default7.configs.recommended.overrides[1].rules,
|
|
422
504
|
"antfu/no-cjs-exports": OFF,
|
|
423
505
|
"antfu/no-ts-export-equal": OFF,
|
|
424
|
-
"import/no-unresolved": OFF,
|
|
425
506
|
"no-alert": OFF,
|
|
426
507
|
"no-console": OFF,
|
|
427
|
-
"no-restricted-imports": OFF,
|
|
428
508
|
"no-undef": OFF,
|
|
429
509
|
"no-unused-expressions": OFF,
|
|
430
510
|
"no-unused-vars": OFF,
|
|
431
511
|
"node/prefer-global/process": OFF,
|
|
432
|
-
"
|
|
512
|
+
"style/comma-dangle": OFF,
|
|
513
|
+
"style/eol-last": OFF,
|
|
433
514
|
"ts/consistent-type-imports": OFF,
|
|
434
515
|
"ts/no-namespace": OFF,
|
|
435
516
|
"ts/no-redeclare": OFF,
|
|
@@ -437,385 +518,395 @@ function markdown(options = {}) {
|
|
|
437
518
|
"ts/no-unused-vars": OFF,
|
|
438
519
|
"ts/no-use-before-define": OFF,
|
|
439
520
|
"ts/no-var-requires": OFF,
|
|
521
|
+
"unicode-bom": "off",
|
|
440
522
|
"unused-imports/no-unused-imports": OFF,
|
|
441
|
-
"unused-imports/no-unused-vars": OFF
|
|
523
|
+
"unused-imports/no-unused-vars": OFF,
|
|
524
|
+
// Type aware rules
|
|
525
|
+
...{
|
|
526
|
+
"ts/await-thenable": OFF,
|
|
527
|
+
"ts/dot-notation": OFF,
|
|
528
|
+
"ts/no-floating-promises": OFF,
|
|
529
|
+
"ts/no-for-in-array": OFF,
|
|
530
|
+
"ts/no-implied-eval": OFF,
|
|
531
|
+
"ts/no-misused-promises": OFF,
|
|
532
|
+
"ts/no-throw-literal": OFF,
|
|
533
|
+
"ts/no-unnecessary-type-assertion": OFF,
|
|
534
|
+
"ts/no-unsafe-argument": OFF,
|
|
535
|
+
"ts/no-unsafe-assignment": OFF,
|
|
536
|
+
"ts/no-unsafe-call": OFF,
|
|
537
|
+
"ts/no-unsafe-member-access": OFF,
|
|
538
|
+
"ts/no-unsafe-return": OFF,
|
|
539
|
+
"ts/restrict-plus-operands": OFF,
|
|
540
|
+
"ts/restrict-template-expressions": OFF,
|
|
541
|
+
"ts/unbound-method": OFF
|
|
542
|
+
},
|
|
543
|
+
...overrides
|
|
442
544
|
}
|
|
443
545
|
}
|
|
444
546
|
];
|
|
445
547
|
}
|
|
446
548
|
|
|
447
549
|
// src/configs/node.ts
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
550
|
+
function node() {
|
|
551
|
+
return [
|
|
552
|
+
{
|
|
553
|
+
name: "antfu:node",
|
|
554
|
+
plugins: {
|
|
555
|
+
node: default6
|
|
556
|
+
},
|
|
557
|
+
rules: {
|
|
558
|
+
"node/handle-callback-err": ["error", "^(err|error)$"],
|
|
559
|
+
"node/no-deprecated-api": "error",
|
|
560
|
+
"node/no-exports-assign": "error",
|
|
561
|
+
"node/no-new-require": "error",
|
|
562
|
+
"node/no-path-concat": "error",
|
|
563
|
+
"node/prefer-global/buffer": ["error", "never"],
|
|
564
|
+
"node/prefer-global/process": ["error", "never"],
|
|
565
|
+
"node/process-exit-as-throw": "error"
|
|
566
|
+
}
|
|
462
567
|
}
|
|
463
|
-
|
|
464
|
-
|
|
568
|
+
];
|
|
569
|
+
}
|
|
465
570
|
|
|
466
571
|
// src/configs/sort.ts
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
"
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
572
|
+
function sortPackageJson() {
|
|
573
|
+
return [
|
|
574
|
+
{
|
|
575
|
+
files: ["**/package.json"],
|
|
576
|
+
name: "antfu:sort-package-json",
|
|
577
|
+
rules: {
|
|
578
|
+
"jsonc/sort-array-values": [
|
|
579
|
+
"error",
|
|
580
|
+
{
|
|
581
|
+
order: { type: "asc" },
|
|
582
|
+
pathPattern: "^files$"
|
|
583
|
+
}
|
|
584
|
+
],
|
|
585
|
+
"jsonc/sort-keys": [
|
|
586
|
+
"error",
|
|
587
|
+
{
|
|
588
|
+
order: [
|
|
589
|
+
"publisher",
|
|
590
|
+
"name",
|
|
591
|
+
"displayName",
|
|
592
|
+
"type",
|
|
593
|
+
"version",
|
|
594
|
+
"private",
|
|
595
|
+
"packageManager",
|
|
596
|
+
"description",
|
|
597
|
+
"author",
|
|
598
|
+
"license",
|
|
599
|
+
"funding",
|
|
600
|
+
"homepage",
|
|
601
|
+
"repository",
|
|
602
|
+
"bugs",
|
|
603
|
+
"keywords",
|
|
604
|
+
"categories",
|
|
605
|
+
"sideEffects",
|
|
606
|
+
"exports",
|
|
607
|
+
"main",
|
|
608
|
+
"module",
|
|
609
|
+
"unpkg",
|
|
610
|
+
"jsdelivr",
|
|
611
|
+
"types",
|
|
612
|
+
"typesVersions",
|
|
613
|
+
"bin",
|
|
614
|
+
"icon",
|
|
615
|
+
"files",
|
|
616
|
+
"engines",
|
|
617
|
+
"activationEvents",
|
|
618
|
+
"contributes",
|
|
619
|
+
"scripts",
|
|
620
|
+
"peerDependencies",
|
|
621
|
+
"peerDependenciesMeta",
|
|
622
|
+
"dependencies",
|
|
623
|
+
"optionalDependencies",
|
|
624
|
+
"devDependencies",
|
|
625
|
+
"pnpm",
|
|
626
|
+
"overrides",
|
|
627
|
+
"resolutions",
|
|
628
|
+
"husky",
|
|
629
|
+
"simple-git-hooks",
|
|
630
|
+
"lint-staged",
|
|
631
|
+
"eslintConfig"
|
|
632
|
+
],
|
|
633
|
+
pathPattern: "^$"
|
|
634
|
+
},
|
|
635
|
+
{
|
|
636
|
+
order: { type: "asc" },
|
|
637
|
+
pathPattern: "^(?:dev|peer|optional|bundled)?[Dd]ependencies$"
|
|
638
|
+
},
|
|
639
|
+
{
|
|
640
|
+
order: { type: "asc" },
|
|
641
|
+
pathPattern: "^resolutions$"
|
|
642
|
+
},
|
|
643
|
+
{
|
|
644
|
+
order: { type: "asc" },
|
|
645
|
+
pathPattern: "^pnpm.overrides$"
|
|
646
|
+
},
|
|
647
|
+
{
|
|
648
|
+
order: [
|
|
649
|
+
"types",
|
|
650
|
+
"import",
|
|
651
|
+
"require",
|
|
652
|
+
"default"
|
|
653
|
+
],
|
|
654
|
+
pathPattern: "^exports.*$"
|
|
655
|
+
}
|
|
656
|
+
]
|
|
657
|
+
}
|
|
550
658
|
}
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
"
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
659
|
+
];
|
|
660
|
+
}
|
|
661
|
+
function sortTsconfig() {
|
|
662
|
+
return [
|
|
663
|
+
{
|
|
664
|
+
files: ["**/tsconfig.json", "**/tsconfig.*.json"],
|
|
665
|
+
name: "antfu:sort-tsconfig",
|
|
666
|
+
rules: {
|
|
667
|
+
"jsonc/sort-keys": [
|
|
668
|
+
"error",
|
|
669
|
+
{
|
|
670
|
+
order: [
|
|
671
|
+
"extends",
|
|
672
|
+
"compilerOptions",
|
|
673
|
+
"references",
|
|
674
|
+
"files",
|
|
675
|
+
"include",
|
|
676
|
+
"exclude"
|
|
677
|
+
],
|
|
678
|
+
pathPattern: "^$"
|
|
679
|
+
},
|
|
680
|
+
{
|
|
681
|
+
order: [
|
|
682
|
+
/* Projects */
|
|
683
|
+
"incremental",
|
|
684
|
+
"composite",
|
|
685
|
+
"tsBuildInfoFile",
|
|
686
|
+
"disableSourceOfProjectReferenceRedirect",
|
|
687
|
+
"disableSolutionSearching",
|
|
688
|
+
"disableReferencedProjectLoad",
|
|
689
|
+
/* Language and Environment */
|
|
690
|
+
"target",
|
|
691
|
+
"jsx",
|
|
692
|
+
"jsxFactory",
|
|
693
|
+
"jsxFragmentFactory",
|
|
694
|
+
"jsxImportSource",
|
|
695
|
+
"lib",
|
|
696
|
+
"moduleDetection",
|
|
697
|
+
"noLib",
|
|
698
|
+
"reactNamespace",
|
|
699
|
+
"useDefineForClassFields",
|
|
700
|
+
"emitDecoratorMetadata",
|
|
701
|
+
"experimentalDecorators",
|
|
702
|
+
/* Modules */
|
|
703
|
+
"baseUrl",
|
|
704
|
+
"rootDir",
|
|
705
|
+
"rootDirs",
|
|
706
|
+
"customConditions",
|
|
707
|
+
"module",
|
|
708
|
+
"moduleResolution",
|
|
709
|
+
"moduleSuffixes",
|
|
710
|
+
"noResolve",
|
|
711
|
+
"paths",
|
|
712
|
+
"resolveJsonModule",
|
|
713
|
+
"resolvePackageJsonExports",
|
|
714
|
+
"resolvePackageJsonImports",
|
|
715
|
+
"typeRoots",
|
|
716
|
+
"types",
|
|
717
|
+
"allowArbitraryExtensions",
|
|
718
|
+
"allowImportingTsExtensions",
|
|
719
|
+
"allowUmdGlobalAccess",
|
|
720
|
+
/* JavaScript Support */
|
|
721
|
+
"allowJs",
|
|
722
|
+
"checkJs",
|
|
723
|
+
"maxNodeModuleJsDepth",
|
|
724
|
+
/* Type Checking */
|
|
725
|
+
"strict",
|
|
726
|
+
"strictBindCallApply",
|
|
727
|
+
"strictFunctionTypes",
|
|
728
|
+
"strictNullChecks",
|
|
729
|
+
"strictPropertyInitialization",
|
|
730
|
+
"allowUnreachableCode",
|
|
731
|
+
"allowUnusedLabels",
|
|
732
|
+
"alwaysStrict",
|
|
733
|
+
"exactOptionalPropertyTypes",
|
|
734
|
+
"noFallthroughCasesInSwitch",
|
|
735
|
+
"noImplicitAny",
|
|
736
|
+
"noImplicitOverride",
|
|
737
|
+
"noImplicitReturns",
|
|
738
|
+
"noImplicitThis",
|
|
739
|
+
"noPropertyAccessFromIndexSignature",
|
|
740
|
+
"noUncheckedIndexedAccess",
|
|
741
|
+
"noUnusedLocals",
|
|
742
|
+
"noUnusedParameters",
|
|
743
|
+
"useUnknownInCatchVariables",
|
|
744
|
+
/* Emit */
|
|
745
|
+
"declaration",
|
|
746
|
+
"declarationDir",
|
|
747
|
+
"declarationMap",
|
|
748
|
+
"downlevelIteration",
|
|
749
|
+
"emitBOM",
|
|
750
|
+
"emitDeclarationOnly",
|
|
751
|
+
"importHelpers",
|
|
752
|
+
"importsNotUsedAsValues",
|
|
753
|
+
"inlineSourceMap",
|
|
754
|
+
"inlineSources",
|
|
755
|
+
"mapRoot",
|
|
756
|
+
"newLine",
|
|
757
|
+
"noEmit",
|
|
758
|
+
"noEmitHelpers",
|
|
759
|
+
"noEmitOnError",
|
|
760
|
+
"outDir",
|
|
761
|
+
"outFile",
|
|
762
|
+
"preserveConstEnums",
|
|
763
|
+
"preserveValueImports",
|
|
764
|
+
"removeComments",
|
|
765
|
+
"sourceMap",
|
|
766
|
+
"sourceRoot",
|
|
767
|
+
"stripInternal",
|
|
768
|
+
/* Interop Constraints */
|
|
769
|
+
"allowSyntheticDefaultImports",
|
|
770
|
+
"esModuleInterop",
|
|
771
|
+
"forceConsistentCasingInFileNames",
|
|
772
|
+
"isolatedModules",
|
|
773
|
+
"preserveSymlinks",
|
|
774
|
+
"verbatimModuleSyntax",
|
|
775
|
+
/* Completeness */
|
|
776
|
+
"skipDefaultLibCheck",
|
|
777
|
+
"skipLibCheck"
|
|
778
|
+
],
|
|
779
|
+
pathPattern: "^compilerOptions$"
|
|
780
|
+
}
|
|
781
|
+
]
|
|
782
|
+
}
|
|
672
783
|
}
|
|
673
|
-
|
|
674
|
-
|
|
784
|
+
];
|
|
785
|
+
}
|
|
675
786
|
|
|
676
787
|
// src/configs/stylistic.ts
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
}
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
]
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
788
|
+
function stylistic(options = {}) {
|
|
789
|
+
const {
|
|
790
|
+
indent = 2,
|
|
791
|
+
quotes = "single"
|
|
792
|
+
} = options;
|
|
793
|
+
return [
|
|
794
|
+
{
|
|
795
|
+
name: "antfu:stylistic",
|
|
796
|
+
plugins: {
|
|
797
|
+
antfu: default2,
|
|
798
|
+
style: default7
|
|
799
|
+
},
|
|
800
|
+
rules: {
|
|
801
|
+
"antfu/consistent-list-newline": "error",
|
|
802
|
+
"antfu/if-newline": "error",
|
|
803
|
+
"antfu/top-level-function": "error",
|
|
804
|
+
"curly": ["error", "multi-or-nest", "consistent"],
|
|
805
|
+
"style/array-bracket-spacing": ["error", "never"],
|
|
806
|
+
"style/arrow-spacing": ["error", { after: true, before: true }],
|
|
807
|
+
"style/block-spacing": ["error", "always"],
|
|
808
|
+
"style/brace-style": ["error", "stroustrup", { allowSingleLine: true }],
|
|
809
|
+
"style/comma-dangle": ["error", "always-multiline"],
|
|
810
|
+
"style/comma-spacing": ["error", { after: true, before: false }],
|
|
811
|
+
"style/comma-style": ["error", "last"],
|
|
812
|
+
"style/computed-property-spacing": ["error", "never", { enforceForClassMembers: true }],
|
|
813
|
+
"style/dot-location": ["error", "property"],
|
|
814
|
+
"style/eol-last": "error",
|
|
815
|
+
"style/indent": ["error", indent, {
|
|
816
|
+
ArrayExpression: 1,
|
|
817
|
+
CallExpression: { arguments: 1 },
|
|
818
|
+
FunctionDeclaration: { body: 1, parameters: 1 },
|
|
819
|
+
FunctionExpression: { body: 1, parameters: 1 },
|
|
820
|
+
ImportDeclaration: 1,
|
|
821
|
+
MemberExpression: 1,
|
|
822
|
+
ObjectExpression: 1,
|
|
823
|
+
SwitchCase: 1,
|
|
824
|
+
VariableDeclarator: 1,
|
|
825
|
+
flatTernaryExpressions: false,
|
|
826
|
+
ignoreComments: false,
|
|
827
|
+
ignoredNodes: [
|
|
828
|
+
"TemplateLiteral *",
|
|
829
|
+
"JSXElement",
|
|
830
|
+
"JSXElement > *",
|
|
831
|
+
"JSXAttribute",
|
|
832
|
+
"JSXIdentifier",
|
|
833
|
+
"JSXNamespacedName",
|
|
834
|
+
"JSXMemberExpression",
|
|
835
|
+
"JSXSpreadAttribute",
|
|
836
|
+
"JSXExpressionContainer",
|
|
837
|
+
"JSXOpeningElement",
|
|
838
|
+
"JSXClosingElement",
|
|
839
|
+
"JSXFragment",
|
|
840
|
+
"JSXOpeningFragment",
|
|
841
|
+
"JSXClosingFragment",
|
|
842
|
+
"JSXText",
|
|
843
|
+
"JSXEmptyExpression",
|
|
844
|
+
"JSXSpreadChild",
|
|
845
|
+
"TSTypeParameterInstantiation",
|
|
846
|
+
"FunctionExpression > .params[decorators.length > 0]",
|
|
847
|
+
"FunctionExpression > .params > :matches(Decorator, :not(:first-child))",
|
|
848
|
+
"ClassBody.body > PropertyDefinition[decorators.length > 0] > .key"
|
|
849
|
+
],
|
|
850
|
+
offsetTernaryExpressions: true,
|
|
851
|
+
outerIIFEBody: 1
|
|
852
|
+
}],
|
|
853
|
+
"style/jsx-quotes": "error",
|
|
854
|
+
"style/key-spacing": ["error", { afterColon: true, beforeColon: false }],
|
|
855
|
+
"style/keyword-spacing": ["error", { after: true, before: true }],
|
|
856
|
+
"style/lines-between-class-members": ["error", "always", { exceptAfterSingleLine: true }],
|
|
857
|
+
"style/max-statements-per-line": ["error", { max: 1 }],
|
|
858
|
+
"style/member-delimiter-style": ["error", { multiline: { delimiter: "none" } }],
|
|
859
|
+
"style/multiline-ternary": ["error", "always-multiline"],
|
|
860
|
+
"style/new-parens": "error",
|
|
861
|
+
"style/no-extra-parens": ["error", "functions"],
|
|
862
|
+
"style/no-floating-decimal": "error",
|
|
863
|
+
"style/no-mixed-operators": ["error", {
|
|
864
|
+
allowSamePrecedence: true,
|
|
865
|
+
groups: [
|
|
866
|
+
["==", "!=", "===", "!==", ">", ">=", "<", "<="],
|
|
867
|
+
["&&", "||"],
|
|
868
|
+
["in", "instanceof"]
|
|
869
|
+
]
|
|
870
|
+
}],
|
|
871
|
+
"style/no-mixed-spaces-and-tabs": "error",
|
|
872
|
+
"style/no-multi-spaces": "error",
|
|
873
|
+
"style/no-multiple-empty-lines": ["error", { max: 1, maxBOF: 0, maxEOF: 0 }],
|
|
874
|
+
"style/no-tabs": indent === "tab" ? "off" : "error",
|
|
875
|
+
"style/no-trailing-spaces": "error",
|
|
876
|
+
"style/no-whitespace-before-property": "error",
|
|
877
|
+
"style/object-curly-spacing": ["error", "always"],
|
|
878
|
+
"style/object-property-newline": ["error", { allowMultiplePropertiesPerLine: true }],
|
|
879
|
+
"style/operator-linebreak": ["error", "before"],
|
|
880
|
+
"style/padded-blocks": ["error", { blocks: "never", classes: "never", switches: "never" }],
|
|
881
|
+
"style/quote-props": ["error", "consistent-as-needed"],
|
|
882
|
+
"style/quotes": ["error", quotes, { allowTemplateLiterals: true, avoidEscape: false }],
|
|
883
|
+
"style/rest-spread-spacing": ["error", "never"],
|
|
884
|
+
"style/semi": ["error", "never"],
|
|
885
|
+
"style/semi-spacing": ["error", { after: true, before: false }],
|
|
886
|
+
"style/space-before-blocks": ["error", "always"],
|
|
887
|
+
"style/space-before-function-paren": ["error", { anonymous: "always", asyncArrow: "always", named: "never" }],
|
|
888
|
+
"style/space-in-parens": ["error", "never"],
|
|
889
|
+
"style/space-infix-ops": "error",
|
|
890
|
+
"style/space-unary-ops": ["error", { nonwords: false, words: true }],
|
|
891
|
+
"style/spaced-comment": ["error", "always", {
|
|
892
|
+
block: {
|
|
893
|
+
balanced: true,
|
|
894
|
+
exceptions: ["*"],
|
|
895
|
+
markers: ["!"]
|
|
896
|
+
},
|
|
897
|
+
line: {
|
|
898
|
+
exceptions: ["/", "#"],
|
|
899
|
+
markers: ["/"]
|
|
900
|
+
}
|
|
901
|
+
}],
|
|
902
|
+
"style/template-curly-spacing": "error",
|
|
903
|
+
"style/template-tag-spacing": ["error", "never"],
|
|
904
|
+
"style/type-annotation-spacing": ["error", {}],
|
|
905
|
+
"style/wrap-iife": ["error", "any", { functionPrototypeMethods: true }],
|
|
906
|
+
"style/yield-star-spacing": ["error", "both"]
|
|
907
|
+
}
|
|
793
908
|
}
|
|
794
|
-
|
|
795
|
-
];
|
|
796
|
-
function stylisticJsToTS(input) {
|
|
797
|
-
return {
|
|
798
|
-
// turn off all stylistic rules from style
|
|
799
|
-
...Object.fromEntries(
|
|
800
|
-
Object.entries(input).map(([key]) => {
|
|
801
|
-
if (!key.startsWith("style/"))
|
|
802
|
-
return null;
|
|
803
|
-
const basename = key.replace("style/", "");
|
|
804
|
-
if (tsPackage.rules.find((i) => i.name === basename))
|
|
805
|
-
return [key, OFF];
|
|
806
|
-
return null;
|
|
807
|
-
}).filter(Boolean)
|
|
808
|
-
),
|
|
809
|
-
// rename all stylistic rules from style to style/ts
|
|
810
|
-
...Object.fromEntries(
|
|
811
|
-
Object.entries(input).map(([key, value]) => {
|
|
812
|
-
if (!key.startsWith("style/"))
|
|
813
|
-
return null;
|
|
814
|
-
const basename = key.replace("style/", "");
|
|
815
|
-
return tsPackage.rules.find((i) => i.name === basename) ? [`style-ts/${basename}`, value] : null;
|
|
816
|
-
}).filter(Boolean)
|
|
817
|
-
)
|
|
818
|
-
};
|
|
909
|
+
];
|
|
819
910
|
}
|
|
820
911
|
|
|
821
912
|
// src/configs/typescript.ts
|
|
@@ -834,96 +925,151 @@ function renameRules(rules, from, to) {
|
|
|
834
925
|
})
|
|
835
926
|
);
|
|
836
927
|
}
|
|
928
|
+
var rulesOn = /* @__PURE__ */ new Set();
|
|
929
|
+
var rulesOff = /* @__PURE__ */ new Set();
|
|
930
|
+
function recordRulesStateConfigs(configs) {
|
|
931
|
+
for (const config of configs)
|
|
932
|
+
recordRulesState(config.rules ?? {});
|
|
933
|
+
return configs;
|
|
934
|
+
}
|
|
935
|
+
function recordRulesState(rules) {
|
|
936
|
+
for (const [key, value] of Object.entries(rules ?? {})) {
|
|
937
|
+
const firstValue = Array.isArray(value) ? value[0] : value;
|
|
938
|
+
if (firstValue == null)
|
|
939
|
+
continue;
|
|
940
|
+
if (firstValue === "off" || firstValue === 0)
|
|
941
|
+
rulesOff.add(key);
|
|
942
|
+
else
|
|
943
|
+
rulesOn.add(key);
|
|
944
|
+
}
|
|
945
|
+
return rules;
|
|
946
|
+
}
|
|
947
|
+
function warnUnnecessaryOffRules() {
|
|
948
|
+
const unnecessaryOffRules = [...rulesOff].filter((key) => !rulesOn.has(key));
|
|
949
|
+
for (const off of unnecessaryOffRules)
|
|
950
|
+
console.warn(`[eslint] rule \`${off}\` is never turned on, you can remove the rule from your config`);
|
|
951
|
+
}
|
|
837
952
|
|
|
838
953
|
// src/configs/typescript.ts
|
|
839
954
|
function typescript(options) {
|
|
840
955
|
const {
|
|
841
|
-
componentExts = []
|
|
956
|
+
componentExts = [],
|
|
957
|
+
overrides = {},
|
|
958
|
+
parserOptions = {},
|
|
959
|
+
tsconfigPath
|
|
842
960
|
} = options ?? {};
|
|
961
|
+
const typeAwareRules = {
|
|
962
|
+
"dot-notation": OFF,
|
|
963
|
+
"no-implied-eval": OFF,
|
|
964
|
+
"no-throw-literal": OFF,
|
|
965
|
+
"ts/await-thenable": "error",
|
|
966
|
+
"ts/dot-notation": ["error", { allowKeywords: true }],
|
|
967
|
+
"ts/no-floating-promises": "error",
|
|
968
|
+
"ts/no-for-in-array": "error",
|
|
969
|
+
"ts/no-implied-eval": "error",
|
|
970
|
+
"ts/no-misused-promises": "error",
|
|
971
|
+
"ts/no-throw-literal": "error",
|
|
972
|
+
"ts/no-unnecessary-type-assertion": "error",
|
|
973
|
+
"ts/no-unsafe-argument": "error",
|
|
974
|
+
"ts/no-unsafe-assignment": "error",
|
|
975
|
+
"ts/no-unsafe-call": "error",
|
|
976
|
+
"ts/no-unsafe-member-access": "error",
|
|
977
|
+
"ts/no-unsafe-return": "error",
|
|
978
|
+
"ts/restrict-plus-operands": "error",
|
|
979
|
+
"ts/restrict-template-expressions": "error",
|
|
980
|
+
"ts/unbound-method": "error"
|
|
981
|
+
};
|
|
843
982
|
return [
|
|
983
|
+
{
|
|
984
|
+
// Install the plugins without globs, so they can be configured separately.
|
|
985
|
+
name: "antfu:typescript:setup",
|
|
986
|
+
plugins: {
|
|
987
|
+
antfu: default2,
|
|
988
|
+
import: pluginImport,
|
|
989
|
+
ts: default8
|
|
990
|
+
}
|
|
991
|
+
},
|
|
844
992
|
{
|
|
845
993
|
files: [
|
|
846
|
-
|
|
847
|
-
GLOB_TSX,
|
|
994
|
+
GLOB_SRC,
|
|
848
995
|
...componentExts.map((ext) => `**/*.${ext}`)
|
|
849
996
|
],
|
|
850
997
|
languageOptions: {
|
|
851
|
-
parser:
|
|
998
|
+
parser: parserTs,
|
|
852
999
|
parserOptions: {
|
|
853
|
-
sourceType: "module"
|
|
1000
|
+
sourceType: "module",
|
|
1001
|
+
...tsconfigPath ? {
|
|
1002
|
+
project: [tsconfigPath],
|
|
1003
|
+
tsconfigRootDir: process.cwd()
|
|
1004
|
+
} : {},
|
|
1005
|
+
...parserOptions
|
|
854
1006
|
}
|
|
855
1007
|
},
|
|
856
|
-
|
|
857
|
-
antfu: default2,
|
|
858
|
-
import: default4,
|
|
859
|
-
ts: default11
|
|
860
|
-
},
|
|
1008
|
+
name: "antfu:typescript:rules",
|
|
861
1009
|
rules: {
|
|
862
1010
|
...renameRules(
|
|
863
|
-
|
|
1011
|
+
default8.configs["eslint-recommended"].overrides[0].rules,
|
|
864
1012
|
"@typescript-eslint/",
|
|
865
1013
|
"ts/"
|
|
866
1014
|
),
|
|
867
1015
|
...renameRules(
|
|
868
|
-
|
|
1016
|
+
default8.configs.strict.rules,
|
|
869
1017
|
"@typescript-eslint/",
|
|
870
1018
|
"ts/"
|
|
871
1019
|
),
|
|
872
1020
|
"antfu/generic-spacing": "error",
|
|
873
1021
|
"antfu/named-tuple-spacing": "error",
|
|
874
1022
|
"antfu/no-cjs-exports": "error",
|
|
875
|
-
"antfu/no-const-enum": "error",
|
|
876
|
-
"antfu/no-ts-export-equal": "error",
|
|
877
1023
|
"no-dupe-class-members": OFF,
|
|
878
|
-
"no-extra-parens": OFF,
|
|
879
1024
|
"no-invalid-this": OFF,
|
|
880
1025
|
"no-loss-of-precision": OFF,
|
|
881
1026
|
"no-redeclare": OFF,
|
|
882
1027
|
"no-use-before-define": OFF,
|
|
883
1028
|
"no-useless-constructor": OFF,
|
|
884
|
-
// TS
|
|
885
1029
|
"ts/ban-ts-comment": ["error", { "ts-ignore": "allow-with-description" }],
|
|
886
|
-
"ts/ban-
|
|
887
|
-
"ts/consistent-indexed-object-style": OFF,
|
|
1030
|
+
"ts/ban-types": ["error", { types: { Function: false } }],
|
|
888
1031
|
"ts/consistent-type-definitions": ["error", "interface"],
|
|
889
1032
|
"ts/consistent-type-imports": ["error", { disallowTypeAnnotations: false, prefer: "type-imports" }],
|
|
890
|
-
"ts/explicit-function-return-type": OFF,
|
|
891
|
-
"ts/explicit-member-accessibility": OFF,
|
|
892
|
-
"ts/explicit-module-boundary-types": OFF,
|
|
893
|
-
"ts/naming-convention": OFF,
|
|
894
1033
|
"ts/no-dupe-class-members": "error",
|
|
895
|
-
"ts/no-
|
|
896
|
-
"ts/no-empty-interface": OFF,
|
|
1034
|
+
"ts/no-dynamic-delete": OFF,
|
|
897
1035
|
"ts/no-explicit-any": OFF,
|
|
898
|
-
"ts/no-
|
|
1036
|
+
"ts/no-extraneous-class": OFF,
|
|
899
1037
|
"ts/no-invalid-this": "error",
|
|
1038
|
+
"ts/no-invalid-void-type": OFF,
|
|
900
1039
|
"ts/no-loss-of-precision": "error",
|
|
901
1040
|
"ts/no-non-null-assertion": OFF,
|
|
902
1041
|
"ts/no-redeclare": "error",
|
|
903
1042
|
"ts/no-require-imports": "error",
|
|
904
1043
|
"ts/no-unused-vars": OFF,
|
|
905
1044
|
"ts/no-use-before-define": ["error", { classes: false, functions: false, variables: true }],
|
|
906
|
-
"ts/
|
|
1045
|
+
"ts/no-useless-constructor": OFF,
|
|
907
1046
|
"ts/prefer-ts-expect-error": "error",
|
|
908
|
-
"ts/triple-slash-reference": OFF
|
|
1047
|
+
"ts/triple-slash-reference": OFF,
|
|
1048
|
+
"ts/unified-signatures": OFF,
|
|
1049
|
+
...tsconfigPath ? typeAwareRules : {},
|
|
1050
|
+
...overrides
|
|
909
1051
|
}
|
|
910
1052
|
},
|
|
911
1053
|
{
|
|
912
1054
|
files: ["**/*.d.ts"],
|
|
1055
|
+
name: "antfu:typescript:dts-overrides",
|
|
913
1056
|
rules: {
|
|
914
1057
|
"eslint-comments/no-unlimited-disable": OFF,
|
|
915
1058
|
"import/no-duplicates": OFF,
|
|
1059
|
+
"no-restricted-syntax": OFF,
|
|
916
1060
|
"unused-imports/no-unused-vars": OFF
|
|
917
1061
|
}
|
|
918
1062
|
},
|
|
919
1063
|
{
|
|
920
1064
|
files: ["**/*.{test,spec}.ts?(x)"],
|
|
1065
|
+
name: "antfu:typescript:tests-overrides",
|
|
921
1066
|
rules: {
|
|
922
1067
|
"no-unused-expressions": OFF
|
|
923
1068
|
}
|
|
924
1069
|
},
|
|
925
1070
|
{
|
|
926
1071
|
files: ["**/*.js", "**/*.cjs"],
|
|
1072
|
+
name: "antfu:typescript:javascript-overrides",
|
|
927
1073
|
rules: {
|
|
928
1074
|
"ts/no-require-imports": OFF,
|
|
929
1075
|
"ts/no-var-requires": OFF
|
|
@@ -931,135 +1077,87 @@ function typescript(options) {
|
|
|
931
1077
|
}
|
|
932
1078
|
];
|
|
933
1079
|
}
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
tsconfigPath,
|
|
938
|
-
tsconfigRootDir = process.cwd()
|
|
939
|
-
} = options;
|
|
1080
|
+
|
|
1081
|
+
// src/configs/unicorn.ts
|
|
1082
|
+
function unicorn() {
|
|
940
1083
|
return [
|
|
941
1084
|
{
|
|
942
|
-
|
|
943
|
-
GLOB_TS,
|
|
944
|
-
GLOB_TSX,
|
|
945
|
-
...componentExts.map((ext) => `**/*.${ext}`)
|
|
946
|
-
],
|
|
947
|
-
ignores: ["**/*.md/*.*"],
|
|
948
|
-
languageOptions: {
|
|
949
|
-
parser: default17,
|
|
950
|
-
parserOptions: {
|
|
951
|
-
project: [tsconfigPath],
|
|
952
|
-
tsconfigRootDir
|
|
953
|
-
}
|
|
954
|
-
},
|
|
1085
|
+
name: "antfu:unicorn",
|
|
955
1086
|
plugins: {
|
|
956
|
-
|
|
1087
|
+
unicorn: default9
|
|
957
1088
|
},
|
|
958
1089
|
rules: {
|
|
959
|
-
|
|
960
|
-
"
|
|
961
|
-
|
|
962
|
-
"
|
|
963
|
-
|
|
964
|
-
"
|
|
965
|
-
|
|
966
|
-
"
|
|
967
|
-
|
|
968
|
-
"
|
|
969
|
-
|
|
970
|
-
"
|
|
971
|
-
|
|
972
|
-
"
|
|
973
|
-
|
|
974
|
-
"
|
|
975
|
-
|
|
976
|
-
"
|
|
977
|
-
|
|
978
|
-
"
|
|
979
|
-
|
|
1090
|
+
// Pass error message when throwing errors
|
|
1091
|
+
"unicorn/error-message": "error",
|
|
1092
|
+
// Uppercase regex escapes
|
|
1093
|
+
"unicorn/escape-case": "error",
|
|
1094
|
+
// Array.isArray instead of instanceof
|
|
1095
|
+
"unicorn/no-instanceof-array": "error",
|
|
1096
|
+
// Ban `new Array` as `Array` constructor's params are ambiguous
|
|
1097
|
+
"unicorn/no-new-array": "error",
|
|
1098
|
+
// Prevent deprecated `new Buffer()`
|
|
1099
|
+
"unicorn/no-new-buffer": "error",
|
|
1100
|
+
// Lowercase number formatting for octal, hex, binary (0x1'error' instead of 0X1'error')
|
|
1101
|
+
"unicorn/number-literal-case": "error",
|
|
1102
|
+
// textContent instead of innerText
|
|
1103
|
+
"unicorn/prefer-dom-node-text-content": "error",
|
|
1104
|
+
// includes over indexOf when checking for existence
|
|
1105
|
+
"unicorn/prefer-includes": "error",
|
|
1106
|
+
// Prefer using the node: protocol
|
|
1107
|
+
"unicorn/prefer-node-protocol": "error",
|
|
1108
|
+
// Prefer using number properties like `Number.isNaN` rather than `isNaN`
|
|
1109
|
+
"unicorn/prefer-number-properties": "error",
|
|
1110
|
+
// String methods startsWith/endsWith instead of more complicated stuff
|
|
1111
|
+
"unicorn/prefer-string-starts-ends-with": "error",
|
|
1112
|
+
// Enforce throwing type error when throwing error while checking typeof
|
|
1113
|
+
"unicorn/prefer-type-error": "error",
|
|
1114
|
+
// Use new when throwing error
|
|
1115
|
+
"unicorn/throw-new-error": "error"
|
|
980
1116
|
}
|
|
981
1117
|
}
|
|
982
1118
|
];
|
|
983
1119
|
}
|
|
984
1120
|
|
|
985
|
-
// src/configs/unicorn.ts
|
|
986
|
-
var unicorn = [
|
|
987
|
-
{
|
|
988
|
-
plugins: {
|
|
989
|
-
unicorn: default12
|
|
990
|
-
},
|
|
991
|
-
rules: {
|
|
992
|
-
// Pass error message when throwing errors
|
|
993
|
-
"unicorn/error-message": "error",
|
|
994
|
-
// Uppercase regex escapes
|
|
995
|
-
"unicorn/escape-case": "error",
|
|
996
|
-
// Array.isArray instead of instanceof
|
|
997
|
-
"unicorn/no-instanceof-array": "error",
|
|
998
|
-
// Ban `new Array` as `Array` constructor's params are ambiguous
|
|
999
|
-
"unicorn/no-new-array": "error",
|
|
1000
|
-
// Prevent deprecated `new Buffer()`
|
|
1001
|
-
"unicorn/no-new-buffer": "error",
|
|
1002
|
-
// Keep regex literals safe!
|
|
1003
|
-
"unicorn/no-unsafe-regex": "error",
|
|
1004
|
-
// Lowercase number formatting for octal, hex, binary (0x1'error' instead of 0X1'error')
|
|
1005
|
-
"unicorn/number-literal-case": "error",
|
|
1006
|
-
// includes over indexOf when checking for existence
|
|
1007
|
-
"unicorn/prefer-includes": "error",
|
|
1008
|
-
// Prefer using the node: protocol
|
|
1009
|
-
"unicorn/prefer-node-protocol": "error",
|
|
1010
|
-
// Prefer using number properties like `Number.isNaN` rather than `isNaN`
|
|
1011
|
-
"unicorn/prefer-number-properties": "error",
|
|
1012
|
-
// String methods startsWith/endsWith instead of more complicated stuff
|
|
1013
|
-
"unicorn/prefer-string-starts-ends-with": "error",
|
|
1014
|
-
// textContent instead of innerText
|
|
1015
|
-
"unicorn/prefer-text-content": "error",
|
|
1016
|
-
// Enforce throwing type error when throwing error while checking typeof
|
|
1017
|
-
"unicorn/prefer-type-error": "error",
|
|
1018
|
-
// Use new when throwing error
|
|
1019
|
-
"unicorn/throw-new-error": "error"
|
|
1020
|
-
}
|
|
1021
|
-
}
|
|
1022
|
-
];
|
|
1023
|
-
|
|
1024
1121
|
// src/configs/vue.ts
|
|
1025
1122
|
function vue(options = {}) {
|
|
1123
|
+
const {
|
|
1124
|
+
overrides = {},
|
|
1125
|
+
stylistic: stylistic2 = true
|
|
1126
|
+
} = options;
|
|
1127
|
+
const {
|
|
1128
|
+
indent = 2
|
|
1129
|
+
} = typeof stylistic2 === "boolean" ? {} : stylistic2;
|
|
1026
1130
|
return [
|
|
1131
|
+
{
|
|
1132
|
+
name: "antfu:vue:setup",
|
|
1133
|
+
plugins: {
|
|
1134
|
+
vue: default11
|
|
1135
|
+
}
|
|
1136
|
+
},
|
|
1027
1137
|
{
|
|
1028
1138
|
files: [GLOB_VUE],
|
|
1029
1139
|
languageOptions: {
|
|
1030
|
-
parser:
|
|
1140
|
+
parser: default14,
|
|
1031
1141
|
parserOptions: {
|
|
1032
1142
|
ecmaFeatures: {
|
|
1033
1143
|
jsx: true
|
|
1034
1144
|
},
|
|
1035
1145
|
extraFileExtensions: [".vue"],
|
|
1036
|
-
parser: options.typescript ?
|
|
1146
|
+
parser: options.typescript ? parserTs : null,
|
|
1037
1147
|
sourceType: "module"
|
|
1038
1148
|
}
|
|
1039
1149
|
},
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
},
|
|
1043
|
-
processor: default14.processors[".vue"],
|
|
1150
|
+
name: "antfu:vue:rules",
|
|
1151
|
+
processor: default11.processors[".vue"],
|
|
1044
1152
|
rules: {
|
|
1045
|
-
...
|
|
1046
|
-
...
|
|
1047
|
-
...
|
|
1048
|
-
...
|
|
1049
|
-
"
|
|
1050
|
-
"vue/arrow-spacing": ["error", { after: true, before: true }],
|
|
1153
|
+
...default11.configs.base.rules,
|
|
1154
|
+
...default11.configs["vue3-essential"].rules,
|
|
1155
|
+
...default11.configs["vue3-strongly-recommended"].rules,
|
|
1156
|
+
...default11.configs["vue3-recommended"].rules,
|
|
1157
|
+
"node/prefer-global/process": OFF,
|
|
1051
1158
|
"vue/block-order": ["error", {
|
|
1052
1159
|
order: ["script", "template", "style"]
|
|
1053
1160
|
}],
|
|
1054
|
-
"vue/block-spacing": ["error", "always"],
|
|
1055
|
-
"vue/block-tag-newline": ["error", {
|
|
1056
|
-
multiline: "always",
|
|
1057
|
-
singleline: "always"
|
|
1058
|
-
}],
|
|
1059
|
-
"vue/brace-style": ["error", "stroustrup", { allowSingleLine: true }],
|
|
1060
|
-
"vue/comma-dangle": ["error", "always-multiline"],
|
|
1061
|
-
"vue/comma-spacing": ["error", { after: true, before: false }],
|
|
1062
|
-
"vue/comma-style": ["error", "last"],
|
|
1063
1161
|
"vue/component-name-in-template-casing": ["error", "PascalCase"],
|
|
1064
1162
|
"vue/component-options-name-casing": ["error", "PascalCase"],
|
|
1065
1163
|
"vue/custom-event-name-casing": ["error", "camelCase"],
|
|
@@ -1069,14 +1167,10 @@ function vue(options = {}) {
|
|
|
1069
1167
|
"vue/dot-location": ["error", "property"],
|
|
1070
1168
|
"vue/dot-notation": ["error", { allowKeywords: true }],
|
|
1071
1169
|
"vue/eqeqeq": ["error", "smart"],
|
|
1072
|
-
"vue/html-
|
|
1073
|
-
|
|
1074
|
-
}],
|
|
1075
|
-
"vue/key-spacing": ["error", { afterColon: true, beforeColon: false }],
|
|
1076
|
-
"vue/keyword-spacing": ["error", { after: true, before: true }],
|
|
1170
|
+
"vue/html-indent": ["error", indent],
|
|
1171
|
+
"vue/html-quotes": ["error", "double"],
|
|
1077
1172
|
"vue/max-attributes-per-line": OFF,
|
|
1078
1173
|
"vue/multi-word-component-names": OFF,
|
|
1079
|
-
"vue/no-constant-condition": "warn",
|
|
1080
1174
|
"vue/no-dupe-keys": OFF,
|
|
1081
1175
|
"vue/no-empty-pattern": "error",
|
|
1082
1176
|
"vue/no-extra-parens": ["error", "functions"],
|
|
@@ -1089,16 +1183,11 @@ function vue(options = {}) {
|
|
|
1089
1183
|
"WithStatement"
|
|
1090
1184
|
],
|
|
1091
1185
|
"vue/no-restricted-v-bind": ["error", "/^v-/"],
|
|
1092
|
-
// reactivity transform
|
|
1093
1186
|
"vue/no-setup-props-reactivity-loss": OFF,
|
|
1094
1187
|
"vue/no-sparse-arrays": "error",
|
|
1095
1188
|
"vue/no-unused-refs": "error",
|
|
1096
1189
|
"vue/no-useless-v-bind": "error",
|
|
1097
1190
|
"vue/no-v-html": OFF,
|
|
1098
|
-
"vue/no-v-text-v-html-on-component": OFF,
|
|
1099
|
-
"vue/object-curly-newline": ["error", { consistent: true, multiline: true }],
|
|
1100
|
-
"vue/object-curly-spacing": ["error", "always"],
|
|
1101
|
-
"vue/object-property-newline": ["error", { allowMultiplePropertiesPerLine: true }],
|
|
1102
1191
|
"vue/object-shorthand": [
|
|
1103
1192
|
"error",
|
|
1104
1193
|
"always",
|
|
@@ -1107,112 +1196,269 @@ function vue(options = {}) {
|
|
|
1107
1196
|
ignoreConstructors: false
|
|
1108
1197
|
}
|
|
1109
1198
|
],
|
|
1110
|
-
"vue/operator-linebreak": ["error", "before"],
|
|
1111
|
-
"vue/padding-line-between-blocks": ["error", "always"],
|
|
1112
1199
|
"vue/prefer-separate-static-class": "error",
|
|
1113
1200
|
"vue/prefer-template": "error",
|
|
1114
|
-
"vue/quote-props": ["error", "consistent-as-needed"],
|
|
1115
1201
|
"vue/require-default-prop": OFF,
|
|
1116
1202
|
"vue/require-prop-types": OFF,
|
|
1117
|
-
"vue/space-in-parens": ["error", "never"],
|
|
1118
1203
|
"vue/space-infix-ops": "error",
|
|
1119
1204
|
"vue/space-unary-ops": ["error", { nonwords: false, words: true }],
|
|
1120
|
-
|
|
1205
|
+
...stylistic2 ? {
|
|
1206
|
+
"vue/array-bracket-spacing": ["error", "never"],
|
|
1207
|
+
"vue/arrow-spacing": ["error", { after: true, before: true }],
|
|
1208
|
+
"vue/block-spacing": ["error", "always"],
|
|
1209
|
+
"vue/block-tag-newline": ["error", {
|
|
1210
|
+
multiline: "always",
|
|
1211
|
+
singleline: "always"
|
|
1212
|
+
}],
|
|
1213
|
+
"vue/brace-style": ["error", "stroustrup", { allowSingleLine: true }],
|
|
1214
|
+
"vue/comma-dangle": ["error", "always-multiline"],
|
|
1215
|
+
"vue/comma-spacing": ["error", { after: true, before: false }],
|
|
1216
|
+
"vue/comma-style": ["error", "last"],
|
|
1217
|
+
"vue/html-comment-content-spacing": ["error", "always", {
|
|
1218
|
+
exceptions: ["-"]
|
|
1219
|
+
}],
|
|
1220
|
+
"vue/key-spacing": ["error", { afterColon: true, beforeColon: false }],
|
|
1221
|
+
"vue/keyword-spacing": ["error", { after: true, before: true }],
|
|
1222
|
+
"vue/object-curly-newline": OFF,
|
|
1223
|
+
"vue/object-curly-spacing": ["error", "always"],
|
|
1224
|
+
"vue/object-property-newline": ["error", { allowMultiplePropertiesPerLine: true }],
|
|
1225
|
+
"vue/operator-linebreak": ["error", "before"],
|
|
1226
|
+
"vue/padding-line-between-blocks": ["error", "always"],
|
|
1227
|
+
"vue/quote-props": ["error", "consistent-as-needed"],
|
|
1228
|
+
"vue/space-in-parens": ["error", "never"],
|
|
1229
|
+
"vue/template-curly-spacing": "error"
|
|
1230
|
+
} : {},
|
|
1231
|
+
...overrides
|
|
1121
1232
|
}
|
|
1122
1233
|
}
|
|
1123
1234
|
];
|
|
1124
1235
|
}
|
|
1125
1236
|
|
|
1126
|
-
// src/configs/
|
|
1127
|
-
|
|
1128
|
-
{
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1237
|
+
// src/configs/yaml.ts
|
|
1238
|
+
function yaml(options = {}) {
|
|
1239
|
+
const {
|
|
1240
|
+
overrides = {},
|
|
1241
|
+
stylistic: stylistic2 = true
|
|
1242
|
+
} = options;
|
|
1243
|
+
const {
|
|
1244
|
+
indent = 2,
|
|
1245
|
+
quotes = "single"
|
|
1246
|
+
} = typeof stylistic2 === "boolean" ? {} : stylistic2;
|
|
1247
|
+
return [
|
|
1248
|
+
{
|
|
1249
|
+
name: "antfu:yaml:setup",
|
|
1250
|
+
plugins: {
|
|
1251
|
+
yaml: pluginYaml
|
|
1252
|
+
}
|
|
1135
1253
|
},
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1254
|
+
{
|
|
1255
|
+
files: [GLOB_YAML],
|
|
1256
|
+
languageOptions: {
|
|
1257
|
+
parser: default15
|
|
1258
|
+
},
|
|
1259
|
+
name: "antfu:yaml:rules",
|
|
1260
|
+
rules: {
|
|
1261
|
+
"style/spaced-comment": OFF,
|
|
1262
|
+
"yaml/block-mapping": "error",
|
|
1263
|
+
"yaml/block-sequence": "error",
|
|
1264
|
+
"yaml/no-empty-key": "error",
|
|
1265
|
+
"yaml/no-empty-sequence-entry": "error",
|
|
1266
|
+
"yaml/no-irregular-whitespace": "error",
|
|
1267
|
+
"yaml/plain-scalar": "error",
|
|
1268
|
+
"yaml/vue-custom-block/no-parsing-error": "error",
|
|
1269
|
+
...stylistic2 ? {
|
|
1270
|
+
"yaml/block-mapping-question-indicator-newline": "error",
|
|
1271
|
+
"yaml/block-sequence-hyphen-indicator-newline": "error",
|
|
1272
|
+
"yaml/flow-mapping-curly-newline": "error",
|
|
1273
|
+
"yaml/flow-mapping-curly-spacing": "error",
|
|
1274
|
+
"yaml/flow-sequence-bracket-newline": "error",
|
|
1275
|
+
"yaml/flow-sequence-bracket-spacing": "error",
|
|
1276
|
+
"yaml/indent": ["error", indent === "tab" ? 2 : indent],
|
|
1277
|
+
"yaml/key-spacing": "error",
|
|
1278
|
+
"yaml/no-tab-indent": "error",
|
|
1279
|
+
"yaml/quotes": ["error", { avoidEscape: false, prefer: quotes }],
|
|
1280
|
+
"yaml/spaced-comment": "error"
|
|
1281
|
+
} : {},
|
|
1282
|
+
...overrides
|
|
1283
|
+
}
|
|
1142
1284
|
}
|
|
1143
|
-
|
|
1144
|
-
|
|
1285
|
+
];
|
|
1286
|
+
}
|
|
1145
1287
|
|
|
1146
1288
|
// src/configs/test.ts
|
|
1147
1289
|
function test(options = {}) {
|
|
1290
|
+
const {
|
|
1291
|
+
isInEditor = false,
|
|
1292
|
+
overrides = {}
|
|
1293
|
+
} = options;
|
|
1148
1294
|
return [
|
|
1149
1295
|
{
|
|
1150
|
-
|
|
1296
|
+
name: "antfu:test:setup",
|
|
1151
1297
|
plugins: {
|
|
1152
|
-
|
|
1153
|
-
|
|
1298
|
+
test: {
|
|
1299
|
+
...default13,
|
|
1300
|
+
rules: {
|
|
1301
|
+
...default13.rules,
|
|
1302
|
+
// extend `test/no-only-tests` rule
|
|
1303
|
+
...default12.rules
|
|
1304
|
+
}
|
|
1305
|
+
}
|
|
1306
|
+
}
|
|
1307
|
+
},
|
|
1308
|
+
{
|
|
1309
|
+
files: GLOB_TESTS,
|
|
1310
|
+
name: "antfu:test:rules",
|
|
1154
1311
|
rules: {
|
|
1155
|
-
"
|
|
1312
|
+
"test/consistent-test-it": ["error", { fn: "it", withinDescribe: "it" }],
|
|
1313
|
+
"test/no-identical-title": "error",
|
|
1314
|
+
"test/no-only-tests": isInEditor ? OFF : "error",
|
|
1315
|
+
"test/prefer-hooks-in-order": "error",
|
|
1316
|
+
"test/prefer-lowercase-title": "error",
|
|
1317
|
+
...overrides
|
|
1156
1318
|
}
|
|
1157
1319
|
}
|
|
1158
1320
|
];
|
|
1159
1321
|
}
|
|
1160
1322
|
|
|
1161
1323
|
// src/factory.ts
|
|
1324
|
+
var flatConfigProps = [
|
|
1325
|
+
"files",
|
|
1326
|
+
"ignores",
|
|
1327
|
+
"languageOptions",
|
|
1328
|
+
"linterOptions",
|
|
1329
|
+
"processor",
|
|
1330
|
+
"plugins",
|
|
1331
|
+
"rules",
|
|
1332
|
+
"settings"
|
|
1333
|
+
];
|
|
1334
|
+
var VuePackages = [
|
|
1335
|
+
"vue",
|
|
1336
|
+
"nuxt",
|
|
1337
|
+
"vitepress",
|
|
1338
|
+
"@slidev/cli"
|
|
1339
|
+
];
|
|
1162
1340
|
function antfu(options = {}, ...userConfigs) {
|
|
1163
|
-
const
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1341
|
+
const {
|
|
1342
|
+
isInEditor = !!((process2.env.VSCODE_PID || process2.env.JETBRAINS_IDE) && !process2.env.CI),
|
|
1343
|
+
vue: enableVue = VuePackages.some((i) => isPackageExists(i)),
|
|
1344
|
+
typescript: enableTypeScript = isPackageExists("typescript"),
|
|
1345
|
+
stylistic: enableStylistic = true,
|
|
1346
|
+
gitignore: enableGitignore = true,
|
|
1347
|
+
overrides = {},
|
|
1348
|
+
componentExts = []
|
|
1349
|
+
} = options;
|
|
1350
|
+
const configs = [];
|
|
1351
|
+
if (enableGitignore) {
|
|
1352
|
+
if (typeof enableGitignore !== "boolean") {
|
|
1353
|
+
configs.push([gitignore(enableGitignore)]);
|
|
1354
|
+
} else {
|
|
1355
|
+
if (fs.existsSync(".gitignore"))
|
|
1356
|
+
configs.push([gitignore()]);
|
|
1357
|
+
}
|
|
1358
|
+
}
|
|
1359
|
+
configs.push(
|
|
1360
|
+
ignores(),
|
|
1361
|
+
javascript({
|
|
1362
|
+
isInEditor,
|
|
1363
|
+
overrides: overrides.javascript
|
|
1364
|
+
}),
|
|
1365
|
+
comments(),
|
|
1366
|
+
node(),
|
|
1367
|
+
jsdoc({
|
|
1368
|
+
stylistic: enableStylistic
|
|
1369
|
+
}),
|
|
1370
|
+
imports({
|
|
1371
|
+
stylistic: enableStylistic
|
|
1372
|
+
}),
|
|
1373
|
+
unicorn()
|
|
1374
|
+
);
|
|
1177
1375
|
if (enableVue)
|
|
1178
1376
|
componentExts.push("vue");
|
|
1179
|
-
if (enableStylistic)
|
|
1180
|
-
configs.push(javascriptStylistic);
|
|
1181
1377
|
if (enableTypeScript) {
|
|
1182
|
-
configs.push(typescript({
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1378
|
+
configs.push(typescript({
|
|
1379
|
+
...typeof enableTypeScript !== "boolean" ? enableTypeScript : {},
|
|
1380
|
+
componentExts,
|
|
1381
|
+
overrides: overrides.typescript
|
|
1382
|
+
}));
|
|
1383
|
+
}
|
|
1384
|
+
if (enableStylistic) {
|
|
1385
|
+
configs.push(stylistic(
|
|
1386
|
+
typeof enableStylistic === "boolean" ? {} : enableStylistic
|
|
1387
|
+
));
|
|
1388
|
+
}
|
|
1389
|
+
if (options.test ?? true) {
|
|
1390
|
+
configs.push(test({
|
|
1391
|
+
isInEditor,
|
|
1392
|
+
overrides: overrides.test
|
|
1393
|
+
}));
|
|
1394
|
+
}
|
|
1395
|
+
if (enableVue) {
|
|
1396
|
+
configs.push(vue({
|
|
1397
|
+
overrides: overrides.vue,
|
|
1398
|
+
stylistic: enableStylistic,
|
|
1399
|
+
typescript: !!enableTypeScript
|
|
1400
|
+
}));
|
|
1191
1401
|
}
|
|
1192
|
-
if (options.test ?? true)
|
|
1193
|
-
configs.push(test({ isInEditor }));
|
|
1194
|
-
if (enableVue)
|
|
1195
|
-
configs.push(vue({ typescript: !!enableTypeScript }));
|
|
1196
1402
|
if (options.jsonc ?? true) {
|
|
1197
1403
|
configs.push(
|
|
1198
|
-
jsonc
|
|
1199
|
-
|
|
1200
|
-
|
|
1404
|
+
jsonc({
|
|
1405
|
+
overrides: overrides.jsonc,
|
|
1406
|
+
stylistic: enableStylistic
|
|
1407
|
+
}),
|
|
1408
|
+
sortPackageJson(),
|
|
1409
|
+
sortTsconfig()
|
|
1201
1410
|
);
|
|
1202
1411
|
}
|
|
1203
|
-
if (options.yaml ?? true)
|
|
1204
|
-
configs.push(
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1412
|
+
if (options.yaml ?? true) {
|
|
1413
|
+
configs.push(yaml({
|
|
1414
|
+
overrides: overrides.yaml,
|
|
1415
|
+
stylistic: enableStylistic
|
|
1416
|
+
}));
|
|
1417
|
+
}
|
|
1418
|
+
if (options.markdown ?? true) {
|
|
1419
|
+
configs.push(markdown({
|
|
1420
|
+
componentExts,
|
|
1421
|
+
overrides: overrides.markdown
|
|
1422
|
+
}));
|
|
1423
|
+
}
|
|
1424
|
+
const fusedConfig = flatConfigProps.reduce((acc, key) => {
|
|
1425
|
+
if (key in options)
|
|
1426
|
+
acc[key] = options[key];
|
|
1427
|
+
return acc;
|
|
1428
|
+
}, {});
|
|
1429
|
+
if (Object.keys(fusedConfig).length)
|
|
1430
|
+
configs.push([fusedConfig]);
|
|
1431
|
+
const merged = combine(
|
|
1208
1432
|
...configs,
|
|
1209
1433
|
...userConfigs
|
|
1210
1434
|
);
|
|
1435
|
+
return merged;
|
|
1211
1436
|
}
|
|
1212
1437
|
|
|
1213
1438
|
// src/index.ts
|
|
1214
1439
|
var src_default = antfu;
|
|
1215
1440
|
export {
|
|
1441
|
+
GLOB_ALL_SRC,
|
|
1442
|
+
GLOB_CSS,
|
|
1443
|
+
GLOB_EXCLUDE,
|
|
1444
|
+
GLOB_HTML,
|
|
1445
|
+
GLOB_JS,
|
|
1446
|
+
GLOB_JSON,
|
|
1447
|
+
GLOB_JSON5,
|
|
1448
|
+
GLOB_JSONC,
|
|
1449
|
+
GLOB_JSX,
|
|
1450
|
+
GLOB_LESS,
|
|
1451
|
+
GLOB_MARKDOWN,
|
|
1452
|
+
GLOB_MARKDOWN_CODE,
|
|
1453
|
+
GLOB_SCSS,
|
|
1454
|
+
GLOB_SRC,
|
|
1455
|
+
GLOB_SRC_EXT,
|
|
1456
|
+
GLOB_STYLE,
|
|
1457
|
+
GLOB_TESTS,
|
|
1458
|
+
GLOB_TS,
|
|
1459
|
+
GLOB_TSX,
|
|
1460
|
+
GLOB_VUE,
|
|
1461
|
+
GLOB_YAML,
|
|
1216
1462
|
antfu,
|
|
1217
1463
|
combine,
|
|
1218
1464
|
comments,
|
|
@@ -1220,38 +1466,39 @@ export {
|
|
|
1220
1466
|
ignores,
|
|
1221
1467
|
imports,
|
|
1222
1468
|
javascript,
|
|
1223
|
-
javascriptStylistic,
|
|
1224
1469
|
jsdoc,
|
|
1225
1470
|
jsonc,
|
|
1226
1471
|
markdown,
|
|
1227
1472
|
node,
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1473
|
+
default16 as parserJsonc,
|
|
1474
|
+
parserTs,
|
|
1475
|
+
default14 as parserVue,
|
|
1476
|
+
default15 as parserYaml,
|
|
1232
1477
|
default2 as pluginAntfu,
|
|
1233
1478
|
default3 as pluginComments,
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
default13 as
|
|
1245
|
-
|
|
1246
|
-
|
|
1479
|
+
pluginImport,
|
|
1480
|
+
default4 as pluginJsdoc,
|
|
1481
|
+
pluginJsonc,
|
|
1482
|
+
default5 as pluginMarkdown,
|
|
1483
|
+
default12 as pluginNoOnlyTests,
|
|
1484
|
+
default6 as pluginNode,
|
|
1485
|
+
default7 as pluginStylistic,
|
|
1486
|
+
default8 as pluginTs,
|
|
1487
|
+
default9 as pluginUnicorn,
|
|
1488
|
+
default10 as pluginUnusedImports,
|
|
1489
|
+
default13 as pluginVitest,
|
|
1490
|
+
default11 as pluginVue,
|
|
1491
|
+
pluginYaml,
|
|
1492
|
+
recordRulesState,
|
|
1493
|
+
recordRulesStateConfigs,
|
|
1247
1494
|
renameRules,
|
|
1248
1495
|
sortPackageJson,
|
|
1249
1496
|
sortTsconfig,
|
|
1497
|
+
stylistic,
|
|
1250
1498
|
test,
|
|
1251
1499
|
typescript,
|
|
1252
|
-
typescriptStylistic,
|
|
1253
|
-
typescriptWithLanguageServer,
|
|
1254
1500
|
unicorn,
|
|
1255
1501
|
vue,
|
|
1256
|
-
|
|
1502
|
+
warnUnnecessaryOffRules,
|
|
1503
|
+
yaml
|
|
1257
1504
|
};
|