@antfu/eslint-config 2.4.6 → 2.6.0
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 +39 -11
- package/bin/index.js +1 -1
- package/dist/cli.cjs +7 -5
- package/dist/cli.js +7 -5
- package/dist/index.cjs +154 -20
- package/dist/index.d.cts +45 -11
- package/dist/index.d.ts +45 -11
- package/dist/index.js +150 -20
- package/package.json +25 -15
package/README.md
CHANGED
|
@@ -4,14 +4,15 @@
|
|
|
4
4
|
|
|
5
5
|
- Single quotes, no semi
|
|
6
6
|
- Auto fix for formatting (aimed to be used standalone **without** Prettier)
|
|
7
|
+
- Sorted imports, dangling commas
|
|
8
|
+
- Reasonable defaults, best practices, only one line of config
|
|
7
9
|
- Designed to work with TypeScript, JSX, Vue out-of-box
|
|
8
10
|
- Lints also for json, yaml, toml, markdown
|
|
9
|
-
- Sorted imports, dangling commas
|
|
10
|
-
- Reasonable defaults, best practices, only one-line of config
|
|
11
11
|
- Opinionated, but [very customizable](#customization)
|
|
12
12
|
- [ESLint Flat config](https://eslint.org/docs/latest/use/configure/configuration-files-new), compose easily!
|
|
13
13
|
- Using [ESLint Stylistic](https://github.com/eslint-stylistic/eslint-stylistic)
|
|
14
14
|
- Respects `.gitignore` by default
|
|
15
|
+
- Optional [React](#react), [Svelte](#svelte), [UnoCSS](#unocss) support
|
|
15
16
|
- Optional [formatters](#formatters) support for CSS, HTML, etc.
|
|
16
17
|
- **Style principle**: Minimal for reading, stable for diff, consistent
|
|
17
18
|
|
|
@@ -304,7 +305,10 @@ Certain rules would only be enabled in specific files, for example, `ts/*` rules
|
|
|
304
305
|
import antfu from '@antfu/eslint-config'
|
|
305
306
|
|
|
306
307
|
export default antfu(
|
|
307
|
-
{
|
|
308
|
+
{
|
|
309
|
+
vue: true,
|
|
310
|
+
typescript: true
|
|
311
|
+
},
|
|
308
312
|
{
|
|
309
313
|
// Remember to specify the file glob here, otherwise it might cause the vue plugin to handle non-vue files
|
|
310
314
|
files: ['**/*.vue'],
|
|
@@ -321,23 +325,28 @@ export default antfu(
|
|
|
321
325
|
)
|
|
322
326
|
```
|
|
323
327
|
|
|
324
|
-
We also provided
|
|
328
|
+
We also provided a `overrides` options in each integration to make it easier:
|
|
325
329
|
|
|
326
330
|
```js
|
|
327
331
|
// eslint.config.js
|
|
328
332
|
import antfu from '@antfu/eslint-config'
|
|
329
333
|
|
|
330
334
|
export default antfu({
|
|
331
|
-
|
|
332
|
-
|
|
335
|
+
vue: {
|
|
336
|
+
overrides: {
|
|
333
337
|
'vue/operator-linebreak': ['error', 'before'],
|
|
334
338
|
},
|
|
335
|
-
|
|
339
|
+
},
|
|
340
|
+
typescript: {
|
|
341
|
+
overrides: {
|
|
336
342
|
'ts/consistent-type-definitions': ['error', 'interface'],
|
|
337
343
|
},
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
344
|
+
},
|
|
345
|
+
yaml: {
|
|
346
|
+
overrides: {
|
|
347
|
+
// ...
|
|
348
|
+
},
|
|
349
|
+
},
|
|
341
350
|
})
|
|
342
351
|
```
|
|
343
352
|
|
|
@@ -403,6 +412,25 @@ Running `npx eslint` should prompt you to install the required dependencies, oth
|
|
|
403
412
|
npm i -D eslint-plugin-react eslint-plugin-react-hooks eslint-plugin-react-refresh
|
|
404
413
|
```
|
|
405
414
|
|
|
415
|
+
#### Svelte
|
|
416
|
+
|
|
417
|
+
To enable svelte support, you need to explicitly turn it on:
|
|
418
|
+
|
|
419
|
+
```js
|
|
420
|
+
// eslint.config.js
|
|
421
|
+
import antfu from '@antfu/eslint-config'
|
|
422
|
+
|
|
423
|
+
export default antfu({
|
|
424
|
+
svelte: true,
|
|
425
|
+
})
|
|
426
|
+
```
|
|
427
|
+
|
|
428
|
+
Running `npx eslint` should prompt you to install the required dependencies, otherwise, you can install them manually:
|
|
429
|
+
|
|
430
|
+
```bash
|
|
431
|
+
npm i -D eslint-plugin-svelte
|
|
432
|
+
```
|
|
433
|
+
|
|
406
434
|
#### UnoCSS
|
|
407
435
|
|
|
408
436
|
To enable UnoCSS support, you need to explicitly turn it on:
|
|
@@ -424,7 +452,7 @@ npm i -D @unocss/eslint-plugin
|
|
|
424
452
|
|
|
425
453
|
### Optional Rules
|
|
426
454
|
|
|
427
|
-
This config also provides some optional plugins/rules for extended
|
|
455
|
+
This config also provides some optional plugins/rules for extended usage.
|
|
428
456
|
|
|
429
457
|
#### `perfectionist` (sorting)
|
|
430
458
|
|
package/bin/index.js
CHANGED
package/dist/cli.cjs
CHANGED
|
@@ -46,15 +46,15 @@ var import_parse_gitignore = __toESM(require("parse-gitignore"), 1);
|
|
|
46
46
|
var import_picocolors = __toESM(require("picocolors"), 1);
|
|
47
47
|
|
|
48
48
|
// package.json
|
|
49
|
-
var version = "2.
|
|
49
|
+
var version = "2.6.0";
|
|
50
50
|
var devDependencies = {
|
|
51
51
|
"@antfu/eslint-config": "workspace:*",
|
|
52
52
|
"@antfu/eslint-plugin-prettier": "^5.0.1-1",
|
|
53
53
|
"@antfu/ni": "^0.21.12",
|
|
54
54
|
"@stylistic/eslint-plugin-migrate": "^1.5.1",
|
|
55
|
-
"@types/eslint": "^8.
|
|
55
|
+
"@types/eslint": "^8.56.0",
|
|
56
56
|
"@types/fs-extra": "^11.0.4",
|
|
57
|
-
"@types/node": "^20.10.
|
|
57
|
+
"@types/node": "^20.10.5",
|
|
58
58
|
"@types/prompts": "^2.4.9",
|
|
59
59
|
"@types/yargs": "^17.0.32",
|
|
60
60
|
"@unocss/eslint-plugin": "^0.58.0",
|
|
@@ -65,6 +65,7 @@ var devDependencies = {
|
|
|
65
65
|
"eslint-plugin-react": "^7.33.2",
|
|
66
66
|
"eslint-plugin-react-hooks": "^4.6.0",
|
|
67
67
|
"eslint-plugin-react-refresh": "^0.4.5",
|
|
68
|
+
"eslint-plugin-svelte": "^2.35.1",
|
|
68
69
|
"eslint-ts-patch": "^8.55.0-1",
|
|
69
70
|
esno: "^4.0.0",
|
|
70
71
|
execa: "^8.0.1",
|
|
@@ -73,10 +74,11 @@ var devDependencies = {
|
|
|
73
74
|
"lint-staged": "^15.2.0",
|
|
74
75
|
rimraf: "^5.0.5",
|
|
75
76
|
"simple-git-hooks": "^2.9.0",
|
|
77
|
+
"svelte-eslint-parser": "^0.33.1",
|
|
76
78
|
tsup: "^8.0.1",
|
|
77
79
|
typescript: "^5.3.3",
|
|
78
|
-
vitest: "^1.0
|
|
79
|
-
vue: "^3.3.
|
|
80
|
+
vitest: "^1.1.0",
|
|
81
|
+
vue: "^3.3.13"
|
|
80
82
|
};
|
|
81
83
|
|
|
82
84
|
// src/cli/constants.ts
|
package/dist/cli.js
CHANGED
|
@@ -17,15 +17,15 @@ import parse from "parse-gitignore";
|
|
|
17
17
|
import c from "picocolors";
|
|
18
18
|
|
|
19
19
|
// package.json
|
|
20
|
-
var version = "2.
|
|
20
|
+
var version = "2.6.0";
|
|
21
21
|
var devDependencies = {
|
|
22
22
|
"@antfu/eslint-config": "workspace:*",
|
|
23
23
|
"@antfu/eslint-plugin-prettier": "^5.0.1-1",
|
|
24
24
|
"@antfu/ni": "^0.21.12",
|
|
25
25
|
"@stylistic/eslint-plugin-migrate": "^1.5.1",
|
|
26
|
-
"@types/eslint": "^8.
|
|
26
|
+
"@types/eslint": "^8.56.0",
|
|
27
27
|
"@types/fs-extra": "^11.0.4",
|
|
28
|
-
"@types/node": "^20.10.
|
|
28
|
+
"@types/node": "^20.10.5",
|
|
29
29
|
"@types/prompts": "^2.4.9",
|
|
30
30
|
"@types/yargs": "^17.0.32",
|
|
31
31
|
"@unocss/eslint-plugin": "^0.58.0",
|
|
@@ -36,6 +36,7 @@ var devDependencies = {
|
|
|
36
36
|
"eslint-plugin-react": "^7.33.2",
|
|
37
37
|
"eslint-plugin-react-hooks": "^4.6.0",
|
|
38
38
|
"eslint-plugin-react-refresh": "^0.4.5",
|
|
39
|
+
"eslint-plugin-svelte": "^2.35.1",
|
|
39
40
|
"eslint-ts-patch": "^8.55.0-1",
|
|
40
41
|
esno: "^4.0.0",
|
|
41
42
|
execa: "^8.0.1",
|
|
@@ -44,10 +45,11 @@ var devDependencies = {
|
|
|
44
45
|
"lint-staged": "^15.2.0",
|
|
45
46
|
rimraf: "^5.0.5",
|
|
46
47
|
"simple-git-hooks": "^2.9.0",
|
|
48
|
+
"svelte-eslint-parser": "^0.33.1",
|
|
47
49
|
tsup: "^8.0.1",
|
|
48
50
|
typescript: "^5.3.3",
|
|
49
|
-
vitest: "^1.0
|
|
50
|
-
vue: "^3.3.
|
|
51
|
+
vitest: "^1.1.0",
|
|
52
|
+
vue: "^3.3.13"
|
|
51
53
|
};
|
|
52
54
|
|
|
53
55
|
// src/cli/constants.ts
|
package/dist/index.cjs
CHANGED
|
@@ -48,6 +48,7 @@ __export(src_exports, {
|
|
|
48
48
|
GLOB_SRC: () => GLOB_SRC,
|
|
49
49
|
GLOB_SRC_EXT: () => GLOB_SRC_EXT,
|
|
50
50
|
GLOB_STYLE: () => GLOB_STYLE,
|
|
51
|
+
GLOB_SVELTE: () => GLOB_SVELTE,
|
|
51
52
|
GLOB_TESTS: () => GLOB_TESTS,
|
|
52
53
|
GLOB_TOML: () => GLOB_TOML,
|
|
53
54
|
GLOB_TS: () => GLOB_TS,
|
|
@@ -61,6 +62,7 @@ __export(src_exports, {
|
|
|
61
62
|
default: () => src_default,
|
|
62
63
|
ensurePackages: () => ensurePackages,
|
|
63
64
|
formatters: () => formatters,
|
|
65
|
+
getOverrides: () => getOverrides,
|
|
64
66
|
ignores: () => ignores,
|
|
65
67
|
imports: () => imports,
|
|
66
68
|
interopDefault: () => interopDefault,
|
|
@@ -73,9 +75,11 @@ __export(src_exports, {
|
|
|
73
75
|
perfectionist: () => perfectionist,
|
|
74
76
|
react: () => react,
|
|
75
77
|
renameRules: () => renameRules,
|
|
78
|
+
resolveSubOptions: () => resolveSubOptions,
|
|
76
79
|
sortPackageJson: () => sortPackageJson,
|
|
77
80
|
sortTsconfig: () => sortTsconfig,
|
|
78
81
|
stylistic: () => stylistic,
|
|
82
|
+
svelte: () => svelte,
|
|
79
83
|
test: () => test,
|
|
80
84
|
toArray: () => toArray,
|
|
81
85
|
toml: () => toml,
|
|
@@ -136,6 +140,7 @@ var GLOB_JSON5 = "**/*.json5";
|
|
|
136
140
|
var GLOB_JSONC = "**/*.jsonc";
|
|
137
141
|
var GLOB_MARKDOWN = "**/*.md";
|
|
138
142
|
var GLOB_MARKDOWN_IN_MARKDOWN = "**/*.md/*.md";
|
|
143
|
+
var GLOB_SVELTE = "**/*.svelte";
|
|
139
144
|
var GLOB_VUE = "**/*.vue";
|
|
140
145
|
var GLOB_YAML = "**/*.y?(a)ml";
|
|
141
146
|
var GLOB_TOML = "**/*.toml";
|
|
@@ -154,6 +159,7 @@ var GLOB_ALL_SRC = [
|
|
|
154
159
|
GLOB_JSON,
|
|
155
160
|
GLOB_JSON5,
|
|
156
161
|
GLOB_MARKDOWN,
|
|
162
|
+
GLOB_SVELTE,
|
|
157
163
|
GLOB_VUE,
|
|
158
164
|
GLOB_YAML,
|
|
159
165
|
GLOB_HTML
|
|
@@ -212,6 +218,7 @@ async function imports(options = {}) {
|
|
|
212
218
|
},
|
|
213
219
|
rules: {
|
|
214
220
|
"antfu/import-dedupe": "error",
|
|
221
|
+
"antfu/no-import-dist": "error",
|
|
215
222
|
"antfu/no-import-node-modules-by-path": "error",
|
|
216
223
|
"import/first": "error",
|
|
217
224
|
"import/no-duplicates": "error",
|
|
@@ -760,6 +767,7 @@ async function stylistic(options = {}) {
|
|
|
760
767
|
const {
|
|
761
768
|
indent,
|
|
762
769
|
jsx,
|
|
770
|
+
overrides = {},
|
|
763
771
|
quotes,
|
|
764
772
|
semi
|
|
765
773
|
} = {
|
|
@@ -787,7 +795,8 @@ async function stylistic(options = {}) {
|
|
|
787
795
|
"antfu/consistent-list-newline": "error",
|
|
788
796
|
"antfu/if-newline": "error",
|
|
789
797
|
"antfu/top-level-function": "error",
|
|
790
|
-
"curly": ["error", "multi-or-nest", "consistent"]
|
|
798
|
+
"curly": ["error", "multi-or-nest", "consistent"],
|
|
799
|
+
...overrides
|
|
791
800
|
}
|
|
792
801
|
}
|
|
793
802
|
];
|
|
@@ -924,6 +933,7 @@ async function formatters(options = {}, stylistic2 = {}) {
|
|
|
924
933
|
[`format/${formater}`]: [
|
|
925
934
|
"error",
|
|
926
935
|
formater === "prettier" ? {
|
|
936
|
+
printWidth: 120,
|
|
927
937
|
...prettierOptions,
|
|
928
938
|
embeddedLanguageFormatting: "off",
|
|
929
939
|
parser: "markdown"
|
|
@@ -1263,6 +1273,98 @@ function sortTsconfig() {
|
|
|
1263
1273
|
];
|
|
1264
1274
|
}
|
|
1265
1275
|
|
|
1276
|
+
// src/configs/svelte.ts
|
|
1277
|
+
async function svelte(options = {}) {
|
|
1278
|
+
const {
|
|
1279
|
+
files = [GLOB_SVELTE],
|
|
1280
|
+
overrides = {},
|
|
1281
|
+
stylistic: stylistic2 = true
|
|
1282
|
+
} = options;
|
|
1283
|
+
const {
|
|
1284
|
+
indent = 2,
|
|
1285
|
+
quotes = "single"
|
|
1286
|
+
} = typeof stylistic2 === "boolean" ? {} : stylistic2;
|
|
1287
|
+
await ensurePackages([
|
|
1288
|
+
"eslint-plugin-svelte"
|
|
1289
|
+
]);
|
|
1290
|
+
const [
|
|
1291
|
+
pluginSvelte,
|
|
1292
|
+
parserSvelte
|
|
1293
|
+
] = await Promise.all([
|
|
1294
|
+
interopDefault(import("eslint-plugin-svelte")),
|
|
1295
|
+
interopDefault(import("svelte-eslint-parser"))
|
|
1296
|
+
]);
|
|
1297
|
+
return [
|
|
1298
|
+
{
|
|
1299
|
+
name: "antfu:svelte:setup",
|
|
1300
|
+
plugins: {
|
|
1301
|
+
svelte: pluginSvelte
|
|
1302
|
+
}
|
|
1303
|
+
},
|
|
1304
|
+
{
|
|
1305
|
+
files,
|
|
1306
|
+
languageOptions: {
|
|
1307
|
+
parser: parserSvelte,
|
|
1308
|
+
parserOptions: {
|
|
1309
|
+
extraFileExtensions: [".svelte"],
|
|
1310
|
+
parser: options.typescript ? await interopDefault(import("@typescript-eslint/parser")) : null
|
|
1311
|
+
}
|
|
1312
|
+
},
|
|
1313
|
+
name: "antfu:svelte:rules",
|
|
1314
|
+
rules: {
|
|
1315
|
+
"import/no-mutable-exports": "off",
|
|
1316
|
+
"no-undef": "off",
|
|
1317
|
+
// incompatible with most recent (attribute-form) generic types RFC
|
|
1318
|
+
"no-unused-vars": ["error", {
|
|
1319
|
+
args: "none",
|
|
1320
|
+
caughtErrors: "none",
|
|
1321
|
+
ignoreRestSiblings: true,
|
|
1322
|
+
vars: "all",
|
|
1323
|
+
varsIgnorePattern: "^\\$\\$Props$"
|
|
1324
|
+
}],
|
|
1325
|
+
"svelte/comment-directive": "error",
|
|
1326
|
+
"svelte/no-at-debug-tags": "warn",
|
|
1327
|
+
"svelte/no-at-html-tags": "error",
|
|
1328
|
+
"svelte/no-dupe-else-if-blocks": "error",
|
|
1329
|
+
"svelte/no-dupe-style-properties": "error",
|
|
1330
|
+
"svelte/no-dupe-use-directives": "error",
|
|
1331
|
+
"svelte/no-dynamic-slot-name": "error",
|
|
1332
|
+
"svelte/no-export-load-in-svelte-module-in-kit-pages": "error",
|
|
1333
|
+
"svelte/no-inner-declarations": "error",
|
|
1334
|
+
"svelte/no-not-function-handler": "error",
|
|
1335
|
+
"svelte/no-object-in-text-mustaches": "error",
|
|
1336
|
+
"svelte/no-reactive-functions": "error",
|
|
1337
|
+
"svelte/no-reactive-literals": "error",
|
|
1338
|
+
"svelte/no-shorthand-style-property-overrides": "error",
|
|
1339
|
+
"svelte/no-unknown-style-directive-property": "error",
|
|
1340
|
+
"svelte/no-unused-svelte-ignore": "error",
|
|
1341
|
+
"svelte/no-useless-mustaches": "error",
|
|
1342
|
+
"svelte/require-store-callbacks-use-set-param": "error",
|
|
1343
|
+
"svelte/system": "error",
|
|
1344
|
+
"svelte/valid-compile": "error",
|
|
1345
|
+
"svelte/valid-each-key": "error",
|
|
1346
|
+
"unused-imports/no-unused-vars": [
|
|
1347
|
+
"error",
|
|
1348
|
+
{ args: "after-used", argsIgnorePattern: "^_", vars: "all", varsIgnorePattern: "^(_|\\$\\$Props$)" }
|
|
1349
|
+
],
|
|
1350
|
+
...stylistic2 ? {
|
|
1351
|
+
"style/no-trailing-spaces": "off",
|
|
1352
|
+
// superseded by svelte/no-trailing-spaces
|
|
1353
|
+
"svelte/derived-has-same-inputs-outputs": "error",
|
|
1354
|
+
"svelte/html-closing-bracket-spacing": "error",
|
|
1355
|
+
"svelte/html-quotes": ["error", { prefer: quotes }],
|
|
1356
|
+
"svelte/indent": ["error", { alignAttributesVertically: true, indent }],
|
|
1357
|
+
"svelte/mustache-spacing": "error",
|
|
1358
|
+
"svelte/no-spaces-around-equal-signs-in-attribute": "error",
|
|
1359
|
+
"svelte/no-trailing-spaces": "error",
|
|
1360
|
+
"svelte/spaced-html-comment": "error"
|
|
1361
|
+
} : {},
|
|
1362
|
+
...overrides
|
|
1363
|
+
}
|
|
1364
|
+
}
|
|
1365
|
+
];
|
|
1366
|
+
}
|
|
1367
|
+
|
|
1266
1368
|
// src/configs/test.ts
|
|
1267
1369
|
async function test(options = {}) {
|
|
1268
1370
|
const {
|
|
@@ -1321,6 +1423,7 @@ async function typescript(options = {}) {
|
|
|
1321
1423
|
GLOB_SRC,
|
|
1322
1424
|
...componentExts.map((ext) => `**/*.${ext}`)
|
|
1323
1425
|
];
|
|
1426
|
+
const filesTypeAware = options.filesTypeAware ?? [GLOB_TS, GLOB_TSX];
|
|
1324
1427
|
const typeAwareRules = {
|
|
1325
1428
|
"dot-notation": "off",
|
|
1326
1429
|
"no-implied-eval": "off",
|
|
@@ -1410,6 +1513,13 @@ async function typescript(options = {}) {
|
|
|
1410
1513
|
"ts/prefer-ts-expect-error": "error",
|
|
1411
1514
|
"ts/triple-slash-reference": "off",
|
|
1412
1515
|
"ts/unified-signatures": "off",
|
|
1516
|
+
...overrides
|
|
1517
|
+
}
|
|
1518
|
+
},
|
|
1519
|
+
{
|
|
1520
|
+
files: filesTypeAware,
|
|
1521
|
+
name: "antfu:typescript:rules-type-aware",
|
|
1522
|
+
rules: {
|
|
1413
1523
|
...tsconfigPath ? typeAwareRules : {},
|
|
1414
1524
|
...overrides
|
|
1415
1525
|
}
|
|
@@ -1800,9 +1910,9 @@ async function antfu(options = {}, ...userConfigs) {
|
|
|
1800
1910
|
const {
|
|
1801
1911
|
componentExts = [],
|
|
1802
1912
|
gitignore: enableGitignore = true,
|
|
1803
|
-
isInEditor = !!((import_node_process3.default.env.VSCODE_PID || import_node_process3.default.env.JETBRAINS_IDE) && !import_node_process3.default.env.CI),
|
|
1804
|
-
overrides = {},
|
|
1913
|
+
isInEditor = !!((import_node_process3.default.env.VSCODE_PID || import_node_process3.default.env.JETBRAINS_IDE || import_node_process3.default.env.VIM) && !import_node_process3.default.env.CI),
|
|
1805
1914
|
react: enableReact = false,
|
|
1915
|
+
svelte: enableSvelte = false,
|
|
1806
1916
|
typescript: enableTypeScript = (0, import_local_pkg3.isPackageExists)("typescript"),
|
|
1807
1917
|
unocss: enableUnoCSS = false,
|
|
1808
1918
|
vue: enableVue = VuePackages.some((i) => (0, import_local_pkg3.isPackageExists)(i))
|
|
@@ -1823,7 +1933,7 @@ async function antfu(options = {}, ...userConfigs) {
|
|
|
1823
1933
|
ignores(),
|
|
1824
1934
|
javascript({
|
|
1825
1935
|
isInEditor,
|
|
1826
|
-
overrides:
|
|
1936
|
+
overrides: getOverrides(options, "javascript")
|
|
1827
1937
|
}),
|
|
1828
1938
|
comments(),
|
|
1829
1939
|
node(),
|
|
@@ -1841,42 +1951,52 @@ async function antfu(options = {}, ...userConfigs) {
|
|
|
1841
1951
|
componentExts.push("vue");
|
|
1842
1952
|
if (enableTypeScript) {
|
|
1843
1953
|
configs.push(typescript({
|
|
1844
|
-
...
|
|
1845
|
-
componentExts
|
|
1846
|
-
|
|
1954
|
+
...resolveSubOptions(options, "typescript"),
|
|
1955
|
+
componentExts
|
|
1956
|
+
}));
|
|
1957
|
+
}
|
|
1958
|
+
if (stylisticOptions) {
|
|
1959
|
+
configs.push(stylistic({
|
|
1960
|
+
...stylisticOptions,
|
|
1961
|
+
overrides: getOverrides(options, "stylistic")
|
|
1847
1962
|
}));
|
|
1848
1963
|
}
|
|
1849
|
-
if (stylisticOptions)
|
|
1850
|
-
configs.push(stylistic(stylisticOptions));
|
|
1851
1964
|
if (options.test ?? true) {
|
|
1852
1965
|
configs.push(test({
|
|
1853
1966
|
isInEditor,
|
|
1854
|
-
overrides:
|
|
1967
|
+
overrides: getOverrides(options, "test")
|
|
1855
1968
|
}));
|
|
1856
1969
|
}
|
|
1857
1970
|
if (enableVue) {
|
|
1858
1971
|
configs.push(vue({
|
|
1859
|
-
...
|
|
1860
|
-
overrides: overrides.vue,
|
|
1972
|
+
...resolveSubOptions(options, "vue"),
|
|
1861
1973
|
stylistic: stylisticOptions,
|
|
1862
1974
|
typescript: !!enableTypeScript
|
|
1863
1975
|
}));
|
|
1864
1976
|
}
|
|
1865
1977
|
if (enableReact) {
|
|
1866
1978
|
configs.push(react({
|
|
1867
|
-
overrides:
|
|
1979
|
+
overrides: getOverrides(options, "react"),
|
|
1980
|
+
typescript: !!enableTypeScript
|
|
1981
|
+
}));
|
|
1982
|
+
}
|
|
1983
|
+
if (enableSvelte) {
|
|
1984
|
+
configs.push(svelte({
|
|
1985
|
+
overrides: getOverrides(options, "svelte"),
|
|
1986
|
+
stylistic: stylisticOptions,
|
|
1868
1987
|
typescript: !!enableTypeScript
|
|
1869
1988
|
}));
|
|
1870
1989
|
}
|
|
1871
1990
|
if (enableUnoCSS) {
|
|
1872
|
-
configs.push(unocss(
|
|
1873
|
-
|
|
1874
|
-
|
|
1991
|
+
configs.push(unocss({
|
|
1992
|
+
...resolveSubOptions(options, "unocss"),
|
|
1993
|
+
overrides: getOverrides(options, "unocss")
|
|
1994
|
+
}));
|
|
1875
1995
|
}
|
|
1876
1996
|
if (options.jsonc ?? true) {
|
|
1877
1997
|
configs.push(
|
|
1878
1998
|
jsonc({
|
|
1879
|
-
overrides:
|
|
1999
|
+
overrides: getOverrides(options, "jsonc"),
|
|
1880
2000
|
stylistic: stylisticOptions
|
|
1881
2001
|
}),
|
|
1882
2002
|
sortPackageJson(),
|
|
@@ -1885,13 +2005,13 @@ async function antfu(options = {}, ...userConfigs) {
|
|
|
1885
2005
|
}
|
|
1886
2006
|
if (options.yaml ?? true) {
|
|
1887
2007
|
configs.push(yaml({
|
|
1888
|
-
overrides:
|
|
2008
|
+
overrides: getOverrides(options, "yaml"),
|
|
1889
2009
|
stylistic: stylisticOptions
|
|
1890
2010
|
}));
|
|
1891
2011
|
}
|
|
1892
2012
|
if (options.toml ?? true) {
|
|
1893
2013
|
configs.push(toml({
|
|
1894
|
-
overrides:
|
|
2014
|
+
overrides: getOverrides(options, "toml"),
|
|
1895
2015
|
stylistic: stylisticOptions
|
|
1896
2016
|
}));
|
|
1897
2017
|
}
|
|
@@ -1900,7 +2020,7 @@ async function antfu(options = {}, ...userConfigs) {
|
|
|
1900
2020
|
markdown(
|
|
1901
2021
|
{
|
|
1902
2022
|
componentExts,
|
|
1903
|
-
overrides:
|
|
2023
|
+
overrides: getOverrides(options, "markdown")
|
|
1904
2024
|
}
|
|
1905
2025
|
)
|
|
1906
2026
|
);
|
|
@@ -1924,6 +2044,16 @@ async function antfu(options = {}, ...userConfigs) {
|
|
|
1924
2044
|
);
|
|
1925
2045
|
return merged;
|
|
1926
2046
|
}
|
|
2047
|
+
function resolveSubOptions(options, key) {
|
|
2048
|
+
return typeof options[key] === "boolean" ? {} : options[key] || {};
|
|
2049
|
+
}
|
|
2050
|
+
function getOverrides(options, key) {
|
|
2051
|
+
const sub = resolveSubOptions(options, key);
|
|
2052
|
+
return {
|
|
2053
|
+
...options.overrides?.[key],
|
|
2054
|
+
..."overrides" in sub ? sub.overrides : {}
|
|
2055
|
+
};
|
|
2056
|
+
}
|
|
1927
2057
|
|
|
1928
2058
|
// src/index.ts
|
|
1929
2059
|
var src_default = antfu;
|
|
@@ -1947,6 +2077,7 @@ var src_default = antfu;
|
|
|
1947
2077
|
GLOB_SRC,
|
|
1948
2078
|
GLOB_SRC_EXT,
|
|
1949
2079
|
GLOB_STYLE,
|
|
2080
|
+
GLOB_SVELTE,
|
|
1950
2081
|
GLOB_TESTS,
|
|
1951
2082
|
GLOB_TOML,
|
|
1952
2083
|
GLOB_TS,
|
|
@@ -1959,6 +2090,7 @@ var src_default = antfu;
|
|
|
1959
2090
|
comments,
|
|
1960
2091
|
ensurePackages,
|
|
1961
2092
|
formatters,
|
|
2093
|
+
getOverrides,
|
|
1962
2094
|
ignores,
|
|
1963
2095
|
imports,
|
|
1964
2096
|
interopDefault,
|
|
@@ -1971,9 +2103,11 @@ var src_default = antfu;
|
|
|
1971
2103
|
perfectionist,
|
|
1972
2104
|
react,
|
|
1973
2105
|
renameRules,
|
|
2106
|
+
resolveSubOptions,
|
|
1974
2107
|
sortPackageJson,
|
|
1975
2108
|
sortTsconfig,
|
|
1976
2109
|
stylistic,
|
|
2110
|
+
svelte,
|
|
1977
2111
|
test,
|
|
1978
2112
|
toArray,
|
|
1979
2113
|
toml,
|
package/dist/index.d.cts
CHANGED
|
@@ -14,6 +14,11 @@ import { UnprefixedRuleOptions, StylisticCustomizeOptions } from '@stylistic/esl
|
|
|
14
14
|
*/
|
|
15
15
|
type VendoredPrettierOptions = Partial<VendoredPrettierOptionsRequired>;
|
|
16
16
|
interface VendoredPrettierOptionsRequired {
|
|
17
|
+
/**
|
|
18
|
+
* Specify the line length that the printer will wrap on.
|
|
19
|
+
* @default 120
|
|
20
|
+
*/
|
|
21
|
+
printWidth: number;
|
|
17
22
|
/**
|
|
18
23
|
* Specify the number of spaces per indentation-level.
|
|
19
24
|
*/
|
|
@@ -131,7 +136,7 @@ interface OptionsFiles {
|
|
|
131
136
|
*/
|
|
132
137
|
files?: string[];
|
|
133
138
|
}
|
|
134
|
-
interface OptionsVue {
|
|
139
|
+
interface OptionsVue extends OptionsOverrides {
|
|
135
140
|
/**
|
|
136
141
|
* Create virtual files for Vue SFC blocks to enable linting.
|
|
137
142
|
*
|
|
@@ -146,6 +151,7 @@ interface OptionsVue {
|
|
|
146
151
|
*/
|
|
147
152
|
vueVersion?: 2 | 3;
|
|
148
153
|
}
|
|
154
|
+
type OptionsTypescript = (OptionsTypeScriptWithTypes & OptionsOverrides) | (OptionsTypeScriptParserOptions & OptionsOverrides);
|
|
149
155
|
interface OptionsFormatters {
|
|
150
156
|
/**
|
|
151
157
|
* Enable formatting support for CSS, Less, Sass, and SCSS.
|
|
@@ -198,6 +204,11 @@ interface OptionsTypeScriptParserOptions {
|
|
|
198
204
|
* Additional parser options for TypeScript.
|
|
199
205
|
*/
|
|
200
206
|
parserOptions?: Partial<ParserOptions>;
|
|
207
|
+
/**
|
|
208
|
+
* Glob patterns for files that should be type aware.
|
|
209
|
+
* @default ['**\/*.{ts,tsx}']
|
|
210
|
+
*/
|
|
211
|
+
filesTypeAware?: string[];
|
|
201
212
|
}
|
|
202
213
|
interface OptionsTypeScriptWithTypes {
|
|
203
214
|
/**
|
|
@@ -220,7 +231,7 @@ interface OptionsOverrides {
|
|
|
220
231
|
interface OptionsIsInEditor {
|
|
221
232
|
isInEditor?: boolean;
|
|
222
233
|
}
|
|
223
|
-
interface OptionsUnoCSS {
|
|
234
|
+
interface OptionsUnoCSS extends OptionsOverrides {
|
|
224
235
|
/**
|
|
225
236
|
* Enable attributify support.
|
|
226
237
|
* @default true
|
|
@@ -242,6 +253,10 @@ interface OptionsConfig extends OptionsComponentExts {
|
|
|
242
253
|
* @default true
|
|
243
254
|
*/
|
|
244
255
|
gitignore?: boolean | FlatGitignoreOptions;
|
|
256
|
+
/**
|
|
257
|
+
* Core rules. Can't be disabled.
|
|
258
|
+
*/
|
|
259
|
+
javascript?: OptionsOverrides;
|
|
245
260
|
/**
|
|
246
261
|
* Enable TypeScript support.
|
|
247
262
|
*
|
|
@@ -249,7 +264,7 @@ interface OptionsConfig extends OptionsComponentExts {
|
|
|
249
264
|
*
|
|
250
265
|
* @default auto-detect based on the dependencies
|
|
251
266
|
*/
|
|
252
|
-
typescript?: boolean |
|
|
267
|
+
typescript?: boolean | OptionsTypescript;
|
|
253
268
|
/**
|
|
254
269
|
* Enable JSX related rules.
|
|
255
270
|
*
|
|
@@ -263,7 +278,7 @@ interface OptionsConfig extends OptionsComponentExts {
|
|
|
263
278
|
*
|
|
264
279
|
* @default true
|
|
265
280
|
*/
|
|
266
|
-
test?: boolean;
|
|
281
|
+
test?: boolean | OptionsOverrides;
|
|
267
282
|
/**
|
|
268
283
|
* Enable Vue support.
|
|
269
284
|
*
|
|
@@ -275,19 +290,19 @@ interface OptionsConfig extends OptionsComponentExts {
|
|
|
275
290
|
*
|
|
276
291
|
* @default true
|
|
277
292
|
*/
|
|
278
|
-
jsonc?: boolean;
|
|
293
|
+
jsonc?: boolean | OptionsOverrides;
|
|
279
294
|
/**
|
|
280
295
|
* Enable YAML support.
|
|
281
296
|
*
|
|
282
297
|
* @default true
|
|
283
298
|
*/
|
|
284
|
-
yaml?: boolean;
|
|
299
|
+
yaml?: boolean | OptionsOverrides;
|
|
285
300
|
/**
|
|
286
301
|
* Enable TOML support.
|
|
287
302
|
*
|
|
288
303
|
* @default true
|
|
289
304
|
*/
|
|
290
|
-
toml?: boolean;
|
|
305
|
+
toml?: boolean | OptionsOverrides;
|
|
291
306
|
/**
|
|
292
307
|
* Enable linting for **code snippets** in Markdown.
|
|
293
308
|
*
|
|
@@ -295,7 +310,7 @@ interface OptionsConfig extends OptionsComponentExts {
|
|
|
295
310
|
*
|
|
296
311
|
* @default true
|
|
297
312
|
*/
|
|
298
|
-
markdown?: boolean;
|
|
313
|
+
markdown?: boolean | OptionsOverrides;
|
|
299
314
|
/**
|
|
300
315
|
* Enable stylistic rules.
|
|
301
316
|
*
|
|
@@ -312,7 +327,16 @@ interface OptionsConfig extends OptionsComponentExts {
|
|
|
312
327
|
*
|
|
313
328
|
* @default false
|
|
314
329
|
*/
|
|
315
|
-
react?: boolean;
|
|
330
|
+
react?: boolean | OptionsOverrides;
|
|
331
|
+
/**
|
|
332
|
+
* Enable svelte rules.
|
|
333
|
+
*
|
|
334
|
+
* Requires installing:
|
|
335
|
+
* - `eslint-plugin-svelte`
|
|
336
|
+
*
|
|
337
|
+
* @default false
|
|
338
|
+
*/
|
|
339
|
+
svelte?: boolean;
|
|
316
340
|
/**
|
|
317
341
|
* Enable unocss rules.
|
|
318
342
|
*
|
|
@@ -340,8 +364,11 @@ interface OptionsConfig extends OptionsComponentExts {
|
|
|
340
364
|
isInEditor?: boolean;
|
|
341
365
|
/**
|
|
342
366
|
* Provide overrides for rules for each integration.
|
|
367
|
+
*
|
|
368
|
+
* @deprecated use `overrides` option in each integration key instead
|
|
343
369
|
*/
|
|
344
370
|
overrides?: {
|
|
371
|
+
stylistic?: FlatConfigItem['rules'];
|
|
345
372
|
javascript?: FlatConfigItem['rules'];
|
|
346
373
|
typescript?: FlatConfigItem['rules'];
|
|
347
374
|
test?: FlatConfigItem['rules'];
|
|
@@ -351,6 +378,7 @@ interface OptionsConfig extends OptionsComponentExts {
|
|
|
351
378
|
yaml?: FlatConfigItem['rules'];
|
|
352
379
|
toml?: FlatConfigItem['rules'];
|
|
353
380
|
react?: FlatConfigItem['rules'];
|
|
381
|
+
svelte?: FlatConfigItem['rules'];
|
|
354
382
|
};
|
|
355
383
|
}
|
|
356
384
|
|
|
@@ -358,6 +386,9 @@ interface OptionsConfig extends OptionsComponentExts {
|
|
|
358
386
|
* Construct an array of ESLint flat config items.
|
|
359
387
|
*/
|
|
360
388
|
declare function antfu(options?: OptionsConfig & FlatConfigItem, ...userConfigs: Awaitable<UserConfigItem | UserConfigItem[]>[]): Promise<UserConfigItem[]>;
|
|
389
|
+
type ResolvedOptions<T> = T extends boolean ? never : NonNullable<T>;
|
|
390
|
+
declare function resolveSubOptions<K extends keyof OptionsConfig>(options: OptionsConfig, key: K): ResolvedOptions<OptionsConfig[K]>;
|
|
391
|
+
declare function getOverrides<K extends keyof OptionsConfig>(options: OptionsConfig, key: K): any;
|
|
361
392
|
|
|
362
393
|
declare function comments(): Promise<FlatConfigItem[]>;
|
|
363
394
|
|
|
@@ -400,7 +431,9 @@ declare function sortPackageJson(): Promise<FlatConfigItem[]>;
|
|
|
400
431
|
declare function sortTsconfig(): FlatConfigItem[];
|
|
401
432
|
|
|
402
433
|
declare const StylisticConfigDefaults: StylisticConfig;
|
|
403
|
-
declare function stylistic(options?: StylisticConfig): Promise<FlatConfigItem[]>;
|
|
434
|
+
declare function stylistic(options?: StylisticConfig & OptionsOverrides): Promise<FlatConfigItem[]>;
|
|
435
|
+
|
|
436
|
+
declare function svelte(options?: OptionsHasTypeScript & OptionsOverrides & OptionsStylistic & OptionsFiles): Promise<FlatConfigItem[]>;
|
|
404
437
|
|
|
405
438
|
declare function test(options?: OptionsFiles & OptionsIsInEditor & OptionsOverrides): Promise<FlatConfigItem[]>;
|
|
406
439
|
|
|
@@ -432,6 +465,7 @@ declare const GLOB_JSON5 = "**/*.json5";
|
|
|
432
465
|
declare const GLOB_JSONC = "**/*.jsonc";
|
|
433
466
|
declare const GLOB_MARKDOWN = "**/*.md";
|
|
434
467
|
declare const GLOB_MARKDOWN_IN_MARKDOWN = "**/*.md/*.md";
|
|
468
|
+
declare const GLOB_SVELTE = "**/*.svelte";
|
|
435
469
|
declare const GLOB_VUE = "**/*.vue";
|
|
436
470
|
declare const GLOB_YAML = "**/*.y?(a)ml";
|
|
437
471
|
declare const GLOB_TOML = "**/*.toml";
|
|
@@ -479,4 +513,4 @@ declare function interopDefault<T>(m: Awaitable<T>): Promise<T extends {
|
|
|
479
513
|
} ? U : T>;
|
|
480
514
|
declare function ensurePackages(packages: string[]): Promise<void>;
|
|
481
515
|
|
|
482
|
-
export { type Awaitable, type FlatConfigItem, GLOB_ALL_SRC, GLOB_CSS, GLOB_EXCLUDE, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_LESS, GLOB_MARKDOWN, GLOB_MARKDOWN_CODE, GLOB_MARKDOWN_IN_MARKDOWN, GLOB_POSTCSS, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLE, GLOB_TESTS, GLOB_TOML, GLOB_TS, GLOB_TSX, GLOB_VUE, GLOB_YAML, type OptionsComponentExts, type OptionsConfig, type OptionsFiles, type OptionsFormatters, type OptionsHasTypeScript, type OptionsIsInEditor, type OptionsOverrides, type OptionsStylistic, type OptionsTypeScriptParserOptions, type OptionsTypeScriptWithTypes, type OptionsUnoCSS, type OptionsVue, type Rules, type StylisticConfig, StylisticConfigDefaults, type UserConfigItem, type WrapRuleConfig, antfu, combine, comments, antfu as default, ensurePackages, formatters, ignores, imports, interopDefault, javascript, jsdoc, jsonc, markdown, node, parserPlain, perfectionist, react, renameRules, sortPackageJson, sortTsconfig, stylistic, test, toArray, toml, typescript, unicorn, unocss, vue, yaml };
|
|
516
|
+
export { type Awaitable, type FlatConfigItem, GLOB_ALL_SRC, GLOB_CSS, GLOB_EXCLUDE, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_LESS, GLOB_MARKDOWN, GLOB_MARKDOWN_CODE, GLOB_MARKDOWN_IN_MARKDOWN, GLOB_POSTCSS, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLE, GLOB_SVELTE, GLOB_TESTS, GLOB_TOML, GLOB_TS, GLOB_TSX, GLOB_VUE, GLOB_YAML, type OptionsComponentExts, type OptionsConfig, type OptionsFiles, type OptionsFormatters, type OptionsHasTypeScript, type OptionsIsInEditor, type OptionsOverrides, type OptionsStylistic, type OptionsTypeScriptParserOptions, type OptionsTypeScriptWithTypes, type OptionsTypescript, type OptionsUnoCSS, type OptionsVue, type ResolvedOptions, type Rules, type StylisticConfig, StylisticConfigDefaults, type UserConfigItem, type WrapRuleConfig, antfu, combine, comments, antfu as default, ensurePackages, formatters, getOverrides, ignores, imports, interopDefault, javascript, jsdoc, jsonc, markdown, node, parserPlain, perfectionist, react, renameRules, resolveSubOptions, sortPackageJson, sortTsconfig, stylistic, svelte, test, toArray, toml, typescript, unicorn, unocss, vue, yaml };
|
package/dist/index.d.ts
CHANGED
|
@@ -14,6 +14,11 @@ import { UnprefixedRuleOptions, StylisticCustomizeOptions } from '@stylistic/esl
|
|
|
14
14
|
*/
|
|
15
15
|
type VendoredPrettierOptions = Partial<VendoredPrettierOptionsRequired>;
|
|
16
16
|
interface VendoredPrettierOptionsRequired {
|
|
17
|
+
/**
|
|
18
|
+
* Specify the line length that the printer will wrap on.
|
|
19
|
+
* @default 120
|
|
20
|
+
*/
|
|
21
|
+
printWidth: number;
|
|
17
22
|
/**
|
|
18
23
|
* Specify the number of spaces per indentation-level.
|
|
19
24
|
*/
|
|
@@ -131,7 +136,7 @@ interface OptionsFiles {
|
|
|
131
136
|
*/
|
|
132
137
|
files?: string[];
|
|
133
138
|
}
|
|
134
|
-
interface OptionsVue {
|
|
139
|
+
interface OptionsVue extends OptionsOverrides {
|
|
135
140
|
/**
|
|
136
141
|
* Create virtual files for Vue SFC blocks to enable linting.
|
|
137
142
|
*
|
|
@@ -146,6 +151,7 @@ interface OptionsVue {
|
|
|
146
151
|
*/
|
|
147
152
|
vueVersion?: 2 | 3;
|
|
148
153
|
}
|
|
154
|
+
type OptionsTypescript = (OptionsTypeScriptWithTypes & OptionsOverrides) | (OptionsTypeScriptParserOptions & OptionsOverrides);
|
|
149
155
|
interface OptionsFormatters {
|
|
150
156
|
/**
|
|
151
157
|
* Enable formatting support for CSS, Less, Sass, and SCSS.
|
|
@@ -198,6 +204,11 @@ interface OptionsTypeScriptParserOptions {
|
|
|
198
204
|
* Additional parser options for TypeScript.
|
|
199
205
|
*/
|
|
200
206
|
parserOptions?: Partial<ParserOptions>;
|
|
207
|
+
/**
|
|
208
|
+
* Glob patterns for files that should be type aware.
|
|
209
|
+
* @default ['**\/*.{ts,tsx}']
|
|
210
|
+
*/
|
|
211
|
+
filesTypeAware?: string[];
|
|
201
212
|
}
|
|
202
213
|
interface OptionsTypeScriptWithTypes {
|
|
203
214
|
/**
|
|
@@ -220,7 +231,7 @@ interface OptionsOverrides {
|
|
|
220
231
|
interface OptionsIsInEditor {
|
|
221
232
|
isInEditor?: boolean;
|
|
222
233
|
}
|
|
223
|
-
interface OptionsUnoCSS {
|
|
234
|
+
interface OptionsUnoCSS extends OptionsOverrides {
|
|
224
235
|
/**
|
|
225
236
|
* Enable attributify support.
|
|
226
237
|
* @default true
|
|
@@ -242,6 +253,10 @@ interface OptionsConfig extends OptionsComponentExts {
|
|
|
242
253
|
* @default true
|
|
243
254
|
*/
|
|
244
255
|
gitignore?: boolean | FlatGitignoreOptions;
|
|
256
|
+
/**
|
|
257
|
+
* Core rules. Can't be disabled.
|
|
258
|
+
*/
|
|
259
|
+
javascript?: OptionsOverrides;
|
|
245
260
|
/**
|
|
246
261
|
* Enable TypeScript support.
|
|
247
262
|
*
|
|
@@ -249,7 +264,7 @@ interface OptionsConfig extends OptionsComponentExts {
|
|
|
249
264
|
*
|
|
250
265
|
* @default auto-detect based on the dependencies
|
|
251
266
|
*/
|
|
252
|
-
typescript?: boolean |
|
|
267
|
+
typescript?: boolean | OptionsTypescript;
|
|
253
268
|
/**
|
|
254
269
|
* Enable JSX related rules.
|
|
255
270
|
*
|
|
@@ -263,7 +278,7 @@ interface OptionsConfig extends OptionsComponentExts {
|
|
|
263
278
|
*
|
|
264
279
|
* @default true
|
|
265
280
|
*/
|
|
266
|
-
test?: boolean;
|
|
281
|
+
test?: boolean | OptionsOverrides;
|
|
267
282
|
/**
|
|
268
283
|
* Enable Vue support.
|
|
269
284
|
*
|
|
@@ -275,19 +290,19 @@ interface OptionsConfig extends OptionsComponentExts {
|
|
|
275
290
|
*
|
|
276
291
|
* @default true
|
|
277
292
|
*/
|
|
278
|
-
jsonc?: boolean;
|
|
293
|
+
jsonc?: boolean | OptionsOverrides;
|
|
279
294
|
/**
|
|
280
295
|
* Enable YAML support.
|
|
281
296
|
*
|
|
282
297
|
* @default true
|
|
283
298
|
*/
|
|
284
|
-
yaml?: boolean;
|
|
299
|
+
yaml?: boolean | OptionsOverrides;
|
|
285
300
|
/**
|
|
286
301
|
* Enable TOML support.
|
|
287
302
|
*
|
|
288
303
|
* @default true
|
|
289
304
|
*/
|
|
290
|
-
toml?: boolean;
|
|
305
|
+
toml?: boolean | OptionsOverrides;
|
|
291
306
|
/**
|
|
292
307
|
* Enable linting for **code snippets** in Markdown.
|
|
293
308
|
*
|
|
@@ -295,7 +310,7 @@ interface OptionsConfig extends OptionsComponentExts {
|
|
|
295
310
|
*
|
|
296
311
|
* @default true
|
|
297
312
|
*/
|
|
298
|
-
markdown?: boolean;
|
|
313
|
+
markdown?: boolean | OptionsOverrides;
|
|
299
314
|
/**
|
|
300
315
|
* Enable stylistic rules.
|
|
301
316
|
*
|
|
@@ -312,7 +327,16 @@ interface OptionsConfig extends OptionsComponentExts {
|
|
|
312
327
|
*
|
|
313
328
|
* @default false
|
|
314
329
|
*/
|
|
315
|
-
react?: boolean;
|
|
330
|
+
react?: boolean | OptionsOverrides;
|
|
331
|
+
/**
|
|
332
|
+
* Enable svelte rules.
|
|
333
|
+
*
|
|
334
|
+
* Requires installing:
|
|
335
|
+
* - `eslint-plugin-svelte`
|
|
336
|
+
*
|
|
337
|
+
* @default false
|
|
338
|
+
*/
|
|
339
|
+
svelte?: boolean;
|
|
316
340
|
/**
|
|
317
341
|
* Enable unocss rules.
|
|
318
342
|
*
|
|
@@ -340,8 +364,11 @@ interface OptionsConfig extends OptionsComponentExts {
|
|
|
340
364
|
isInEditor?: boolean;
|
|
341
365
|
/**
|
|
342
366
|
* Provide overrides for rules for each integration.
|
|
367
|
+
*
|
|
368
|
+
* @deprecated use `overrides` option in each integration key instead
|
|
343
369
|
*/
|
|
344
370
|
overrides?: {
|
|
371
|
+
stylistic?: FlatConfigItem['rules'];
|
|
345
372
|
javascript?: FlatConfigItem['rules'];
|
|
346
373
|
typescript?: FlatConfigItem['rules'];
|
|
347
374
|
test?: FlatConfigItem['rules'];
|
|
@@ -351,6 +378,7 @@ interface OptionsConfig extends OptionsComponentExts {
|
|
|
351
378
|
yaml?: FlatConfigItem['rules'];
|
|
352
379
|
toml?: FlatConfigItem['rules'];
|
|
353
380
|
react?: FlatConfigItem['rules'];
|
|
381
|
+
svelte?: FlatConfigItem['rules'];
|
|
354
382
|
};
|
|
355
383
|
}
|
|
356
384
|
|
|
@@ -358,6 +386,9 @@ interface OptionsConfig extends OptionsComponentExts {
|
|
|
358
386
|
* Construct an array of ESLint flat config items.
|
|
359
387
|
*/
|
|
360
388
|
declare function antfu(options?: OptionsConfig & FlatConfigItem, ...userConfigs: Awaitable<UserConfigItem | UserConfigItem[]>[]): Promise<UserConfigItem[]>;
|
|
389
|
+
type ResolvedOptions<T> = T extends boolean ? never : NonNullable<T>;
|
|
390
|
+
declare function resolveSubOptions<K extends keyof OptionsConfig>(options: OptionsConfig, key: K): ResolvedOptions<OptionsConfig[K]>;
|
|
391
|
+
declare function getOverrides<K extends keyof OptionsConfig>(options: OptionsConfig, key: K): any;
|
|
361
392
|
|
|
362
393
|
declare function comments(): Promise<FlatConfigItem[]>;
|
|
363
394
|
|
|
@@ -400,7 +431,9 @@ declare function sortPackageJson(): Promise<FlatConfigItem[]>;
|
|
|
400
431
|
declare function sortTsconfig(): FlatConfigItem[];
|
|
401
432
|
|
|
402
433
|
declare const StylisticConfigDefaults: StylisticConfig;
|
|
403
|
-
declare function stylistic(options?: StylisticConfig): Promise<FlatConfigItem[]>;
|
|
434
|
+
declare function stylistic(options?: StylisticConfig & OptionsOverrides): Promise<FlatConfigItem[]>;
|
|
435
|
+
|
|
436
|
+
declare function svelte(options?: OptionsHasTypeScript & OptionsOverrides & OptionsStylistic & OptionsFiles): Promise<FlatConfigItem[]>;
|
|
404
437
|
|
|
405
438
|
declare function test(options?: OptionsFiles & OptionsIsInEditor & OptionsOverrides): Promise<FlatConfigItem[]>;
|
|
406
439
|
|
|
@@ -432,6 +465,7 @@ declare const GLOB_JSON5 = "**/*.json5";
|
|
|
432
465
|
declare const GLOB_JSONC = "**/*.jsonc";
|
|
433
466
|
declare const GLOB_MARKDOWN = "**/*.md";
|
|
434
467
|
declare const GLOB_MARKDOWN_IN_MARKDOWN = "**/*.md/*.md";
|
|
468
|
+
declare const GLOB_SVELTE = "**/*.svelte";
|
|
435
469
|
declare const GLOB_VUE = "**/*.vue";
|
|
436
470
|
declare const GLOB_YAML = "**/*.y?(a)ml";
|
|
437
471
|
declare const GLOB_TOML = "**/*.toml";
|
|
@@ -479,4 +513,4 @@ declare function interopDefault<T>(m: Awaitable<T>): Promise<T extends {
|
|
|
479
513
|
} ? U : T>;
|
|
480
514
|
declare function ensurePackages(packages: string[]): Promise<void>;
|
|
481
515
|
|
|
482
|
-
export { type Awaitable, type FlatConfigItem, GLOB_ALL_SRC, GLOB_CSS, GLOB_EXCLUDE, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_LESS, GLOB_MARKDOWN, GLOB_MARKDOWN_CODE, GLOB_MARKDOWN_IN_MARKDOWN, GLOB_POSTCSS, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLE, GLOB_TESTS, GLOB_TOML, GLOB_TS, GLOB_TSX, GLOB_VUE, GLOB_YAML, type OptionsComponentExts, type OptionsConfig, type OptionsFiles, type OptionsFormatters, type OptionsHasTypeScript, type OptionsIsInEditor, type OptionsOverrides, type OptionsStylistic, type OptionsTypeScriptParserOptions, type OptionsTypeScriptWithTypes, type OptionsUnoCSS, type OptionsVue, type Rules, type StylisticConfig, StylisticConfigDefaults, type UserConfigItem, type WrapRuleConfig, antfu, combine, comments, antfu as default, ensurePackages, formatters, ignores, imports, interopDefault, javascript, jsdoc, jsonc, markdown, node, parserPlain, perfectionist, react, renameRules, sortPackageJson, sortTsconfig, stylistic, test, toArray, toml, typescript, unicorn, unocss, vue, yaml };
|
|
516
|
+
export { type Awaitable, type FlatConfigItem, GLOB_ALL_SRC, GLOB_CSS, GLOB_EXCLUDE, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_LESS, GLOB_MARKDOWN, GLOB_MARKDOWN_CODE, GLOB_MARKDOWN_IN_MARKDOWN, GLOB_POSTCSS, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLE, GLOB_SVELTE, GLOB_TESTS, GLOB_TOML, GLOB_TS, GLOB_TSX, GLOB_VUE, GLOB_YAML, type OptionsComponentExts, type OptionsConfig, type OptionsFiles, type OptionsFormatters, type OptionsHasTypeScript, type OptionsIsInEditor, type OptionsOverrides, type OptionsStylistic, type OptionsTypeScriptParserOptions, type OptionsTypeScriptWithTypes, type OptionsTypescript, type OptionsUnoCSS, type OptionsVue, type ResolvedOptions, type Rules, type StylisticConfig, StylisticConfigDefaults, type UserConfigItem, type WrapRuleConfig, antfu, combine, comments, antfu as default, ensurePackages, formatters, getOverrides, ignores, imports, interopDefault, javascript, jsdoc, jsonc, markdown, node, parserPlain, perfectionist, react, renameRules, resolveSubOptions, sortPackageJson, sortTsconfig, stylistic, svelte, test, toArray, toml, typescript, unicorn, unocss, vue, yaml };
|
package/dist/index.js
CHANGED
|
@@ -47,6 +47,7 @@ var GLOB_JSON5 = "**/*.json5";
|
|
|
47
47
|
var GLOB_JSONC = "**/*.jsonc";
|
|
48
48
|
var GLOB_MARKDOWN = "**/*.md";
|
|
49
49
|
var GLOB_MARKDOWN_IN_MARKDOWN = "**/*.md/*.md";
|
|
50
|
+
var GLOB_SVELTE = "**/*.svelte";
|
|
50
51
|
var GLOB_VUE = "**/*.vue";
|
|
51
52
|
var GLOB_YAML = "**/*.y?(a)ml";
|
|
52
53
|
var GLOB_TOML = "**/*.toml";
|
|
@@ -65,6 +66,7 @@ var GLOB_ALL_SRC = [
|
|
|
65
66
|
GLOB_JSON,
|
|
66
67
|
GLOB_JSON5,
|
|
67
68
|
GLOB_MARKDOWN,
|
|
69
|
+
GLOB_SVELTE,
|
|
68
70
|
GLOB_VUE,
|
|
69
71
|
GLOB_YAML,
|
|
70
72
|
GLOB_HTML
|
|
@@ -123,6 +125,7 @@ async function imports(options = {}) {
|
|
|
123
125
|
},
|
|
124
126
|
rules: {
|
|
125
127
|
"antfu/import-dedupe": "error",
|
|
128
|
+
"antfu/no-import-dist": "error",
|
|
126
129
|
"antfu/no-import-node-modules-by-path": "error",
|
|
127
130
|
"import/first": "error",
|
|
128
131
|
"import/no-duplicates": "error",
|
|
@@ -671,6 +674,7 @@ async function stylistic(options = {}) {
|
|
|
671
674
|
const {
|
|
672
675
|
indent,
|
|
673
676
|
jsx,
|
|
677
|
+
overrides = {},
|
|
674
678
|
quotes,
|
|
675
679
|
semi
|
|
676
680
|
} = {
|
|
@@ -698,7 +702,8 @@ async function stylistic(options = {}) {
|
|
|
698
702
|
"antfu/consistent-list-newline": "error",
|
|
699
703
|
"antfu/if-newline": "error",
|
|
700
704
|
"antfu/top-level-function": "error",
|
|
701
|
-
"curly": ["error", "multi-or-nest", "consistent"]
|
|
705
|
+
"curly": ["error", "multi-or-nest", "consistent"],
|
|
706
|
+
...overrides
|
|
702
707
|
}
|
|
703
708
|
}
|
|
704
709
|
];
|
|
@@ -835,6 +840,7 @@ async function formatters(options = {}, stylistic2 = {}) {
|
|
|
835
840
|
[`format/${formater}`]: [
|
|
836
841
|
"error",
|
|
837
842
|
formater === "prettier" ? {
|
|
843
|
+
printWidth: 120,
|
|
838
844
|
...prettierOptions,
|
|
839
845
|
embeddedLanguageFormatting: "off",
|
|
840
846
|
parser: "markdown"
|
|
@@ -1174,6 +1180,98 @@ function sortTsconfig() {
|
|
|
1174
1180
|
];
|
|
1175
1181
|
}
|
|
1176
1182
|
|
|
1183
|
+
// src/configs/svelte.ts
|
|
1184
|
+
async function svelte(options = {}) {
|
|
1185
|
+
const {
|
|
1186
|
+
files = [GLOB_SVELTE],
|
|
1187
|
+
overrides = {},
|
|
1188
|
+
stylistic: stylistic2 = true
|
|
1189
|
+
} = options;
|
|
1190
|
+
const {
|
|
1191
|
+
indent = 2,
|
|
1192
|
+
quotes = "single"
|
|
1193
|
+
} = typeof stylistic2 === "boolean" ? {} : stylistic2;
|
|
1194
|
+
await ensurePackages([
|
|
1195
|
+
"eslint-plugin-svelte"
|
|
1196
|
+
]);
|
|
1197
|
+
const [
|
|
1198
|
+
pluginSvelte,
|
|
1199
|
+
parserSvelte
|
|
1200
|
+
] = await Promise.all([
|
|
1201
|
+
interopDefault(import("eslint-plugin-svelte")),
|
|
1202
|
+
interopDefault(import("svelte-eslint-parser"))
|
|
1203
|
+
]);
|
|
1204
|
+
return [
|
|
1205
|
+
{
|
|
1206
|
+
name: "antfu:svelte:setup",
|
|
1207
|
+
plugins: {
|
|
1208
|
+
svelte: pluginSvelte
|
|
1209
|
+
}
|
|
1210
|
+
},
|
|
1211
|
+
{
|
|
1212
|
+
files,
|
|
1213
|
+
languageOptions: {
|
|
1214
|
+
parser: parserSvelte,
|
|
1215
|
+
parserOptions: {
|
|
1216
|
+
extraFileExtensions: [".svelte"],
|
|
1217
|
+
parser: options.typescript ? await interopDefault(import("@typescript-eslint/parser")) : null
|
|
1218
|
+
}
|
|
1219
|
+
},
|
|
1220
|
+
name: "antfu:svelte:rules",
|
|
1221
|
+
rules: {
|
|
1222
|
+
"import/no-mutable-exports": "off",
|
|
1223
|
+
"no-undef": "off",
|
|
1224
|
+
// incompatible with most recent (attribute-form) generic types RFC
|
|
1225
|
+
"no-unused-vars": ["error", {
|
|
1226
|
+
args: "none",
|
|
1227
|
+
caughtErrors: "none",
|
|
1228
|
+
ignoreRestSiblings: true,
|
|
1229
|
+
vars: "all",
|
|
1230
|
+
varsIgnorePattern: "^\\$\\$Props$"
|
|
1231
|
+
}],
|
|
1232
|
+
"svelte/comment-directive": "error",
|
|
1233
|
+
"svelte/no-at-debug-tags": "warn",
|
|
1234
|
+
"svelte/no-at-html-tags": "error",
|
|
1235
|
+
"svelte/no-dupe-else-if-blocks": "error",
|
|
1236
|
+
"svelte/no-dupe-style-properties": "error",
|
|
1237
|
+
"svelte/no-dupe-use-directives": "error",
|
|
1238
|
+
"svelte/no-dynamic-slot-name": "error",
|
|
1239
|
+
"svelte/no-export-load-in-svelte-module-in-kit-pages": "error",
|
|
1240
|
+
"svelte/no-inner-declarations": "error",
|
|
1241
|
+
"svelte/no-not-function-handler": "error",
|
|
1242
|
+
"svelte/no-object-in-text-mustaches": "error",
|
|
1243
|
+
"svelte/no-reactive-functions": "error",
|
|
1244
|
+
"svelte/no-reactive-literals": "error",
|
|
1245
|
+
"svelte/no-shorthand-style-property-overrides": "error",
|
|
1246
|
+
"svelte/no-unknown-style-directive-property": "error",
|
|
1247
|
+
"svelte/no-unused-svelte-ignore": "error",
|
|
1248
|
+
"svelte/no-useless-mustaches": "error",
|
|
1249
|
+
"svelte/require-store-callbacks-use-set-param": "error",
|
|
1250
|
+
"svelte/system": "error",
|
|
1251
|
+
"svelte/valid-compile": "error",
|
|
1252
|
+
"svelte/valid-each-key": "error",
|
|
1253
|
+
"unused-imports/no-unused-vars": [
|
|
1254
|
+
"error",
|
|
1255
|
+
{ args: "after-used", argsIgnorePattern: "^_", vars: "all", varsIgnorePattern: "^(_|\\$\\$Props$)" }
|
|
1256
|
+
],
|
|
1257
|
+
...stylistic2 ? {
|
|
1258
|
+
"style/no-trailing-spaces": "off",
|
|
1259
|
+
// superseded by svelte/no-trailing-spaces
|
|
1260
|
+
"svelte/derived-has-same-inputs-outputs": "error",
|
|
1261
|
+
"svelte/html-closing-bracket-spacing": "error",
|
|
1262
|
+
"svelte/html-quotes": ["error", { prefer: quotes }],
|
|
1263
|
+
"svelte/indent": ["error", { alignAttributesVertically: true, indent }],
|
|
1264
|
+
"svelte/mustache-spacing": "error",
|
|
1265
|
+
"svelte/no-spaces-around-equal-signs-in-attribute": "error",
|
|
1266
|
+
"svelte/no-trailing-spaces": "error",
|
|
1267
|
+
"svelte/spaced-html-comment": "error"
|
|
1268
|
+
} : {},
|
|
1269
|
+
...overrides
|
|
1270
|
+
}
|
|
1271
|
+
}
|
|
1272
|
+
];
|
|
1273
|
+
}
|
|
1274
|
+
|
|
1177
1275
|
// src/configs/test.ts
|
|
1178
1276
|
async function test(options = {}) {
|
|
1179
1277
|
const {
|
|
@@ -1232,6 +1330,7 @@ async function typescript(options = {}) {
|
|
|
1232
1330
|
GLOB_SRC,
|
|
1233
1331
|
...componentExts.map((ext) => `**/*.${ext}`)
|
|
1234
1332
|
];
|
|
1333
|
+
const filesTypeAware = options.filesTypeAware ?? [GLOB_TS, GLOB_TSX];
|
|
1235
1334
|
const typeAwareRules = {
|
|
1236
1335
|
"dot-notation": "off",
|
|
1237
1336
|
"no-implied-eval": "off",
|
|
@@ -1321,6 +1420,13 @@ async function typescript(options = {}) {
|
|
|
1321
1420
|
"ts/prefer-ts-expect-error": "error",
|
|
1322
1421
|
"ts/triple-slash-reference": "off",
|
|
1323
1422
|
"ts/unified-signatures": "off",
|
|
1423
|
+
...overrides
|
|
1424
|
+
}
|
|
1425
|
+
},
|
|
1426
|
+
{
|
|
1427
|
+
files: filesTypeAware,
|
|
1428
|
+
name: "antfu:typescript:rules-type-aware",
|
|
1429
|
+
rules: {
|
|
1324
1430
|
...tsconfigPath ? typeAwareRules : {},
|
|
1325
1431
|
...overrides
|
|
1326
1432
|
}
|
|
@@ -1711,9 +1817,9 @@ async function antfu(options = {}, ...userConfigs) {
|
|
|
1711
1817
|
const {
|
|
1712
1818
|
componentExts = [],
|
|
1713
1819
|
gitignore: enableGitignore = true,
|
|
1714
|
-
isInEditor = !!((process3.env.VSCODE_PID || process3.env.JETBRAINS_IDE) && !process3.env.CI),
|
|
1715
|
-
overrides = {},
|
|
1820
|
+
isInEditor = !!((process3.env.VSCODE_PID || process3.env.JETBRAINS_IDE || process3.env.VIM) && !process3.env.CI),
|
|
1716
1821
|
react: enableReact = false,
|
|
1822
|
+
svelte: enableSvelte = false,
|
|
1717
1823
|
typescript: enableTypeScript = isPackageExists3("typescript"),
|
|
1718
1824
|
unocss: enableUnoCSS = false,
|
|
1719
1825
|
vue: enableVue = VuePackages.some((i) => isPackageExists3(i))
|
|
@@ -1734,7 +1840,7 @@ async function antfu(options = {}, ...userConfigs) {
|
|
|
1734
1840
|
ignores(),
|
|
1735
1841
|
javascript({
|
|
1736
1842
|
isInEditor,
|
|
1737
|
-
overrides:
|
|
1843
|
+
overrides: getOverrides(options, "javascript")
|
|
1738
1844
|
}),
|
|
1739
1845
|
comments(),
|
|
1740
1846
|
node(),
|
|
@@ -1752,42 +1858,52 @@ async function antfu(options = {}, ...userConfigs) {
|
|
|
1752
1858
|
componentExts.push("vue");
|
|
1753
1859
|
if (enableTypeScript) {
|
|
1754
1860
|
configs.push(typescript({
|
|
1755
|
-
...
|
|
1756
|
-
componentExts
|
|
1757
|
-
|
|
1861
|
+
...resolveSubOptions(options, "typescript"),
|
|
1862
|
+
componentExts
|
|
1863
|
+
}));
|
|
1864
|
+
}
|
|
1865
|
+
if (stylisticOptions) {
|
|
1866
|
+
configs.push(stylistic({
|
|
1867
|
+
...stylisticOptions,
|
|
1868
|
+
overrides: getOverrides(options, "stylistic")
|
|
1758
1869
|
}));
|
|
1759
1870
|
}
|
|
1760
|
-
if (stylisticOptions)
|
|
1761
|
-
configs.push(stylistic(stylisticOptions));
|
|
1762
1871
|
if (options.test ?? true) {
|
|
1763
1872
|
configs.push(test({
|
|
1764
1873
|
isInEditor,
|
|
1765
|
-
overrides:
|
|
1874
|
+
overrides: getOverrides(options, "test")
|
|
1766
1875
|
}));
|
|
1767
1876
|
}
|
|
1768
1877
|
if (enableVue) {
|
|
1769
1878
|
configs.push(vue({
|
|
1770
|
-
...
|
|
1771
|
-
overrides: overrides.vue,
|
|
1879
|
+
...resolveSubOptions(options, "vue"),
|
|
1772
1880
|
stylistic: stylisticOptions,
|
|
1773
1881
|
typescript: !!enableTypeScript
|
|
1774
1882
|
}));
|
|
1775
1883
|
}
|
|
1776
1884
|
if (enableReact) {
|
|
1777
1885
|
configs.push(react({
|
|
1778
|
-
overrides:
|
|
1886
|
+
overrides: getOverrides(options, "react"),
|
|
1887
|
+
typescript: !!enableTypeScript
|
|
1888
|
+
}));
|
|
1889
|
+
}
|
|
1890
|
+
if (enableSvelte) {
|
|
1891
|
+
configs.push(svelte({
|
|
1892
|
+
overrides: getOverrides(options, "svelte"),
|
|
1893
|
+
stylistic: stylisticOptions,
|
|
1779
1894
|
typescript: !!enableTypeScript
|
|
1780
1895
|
}));
|
|
1781
1896
|
}
|
|
1782
1897
|
if (enableUnoCSS) {
|
|
1783
|
-
configs.push(unocss(
|
|
1784
|
-
|
|
1785
|
-
|
|
1898
|
+
configs.push(unocss({
|
|
1899
|
+
...resolveSubOptions(options, "unocss"),
|
|
1900
|
+
overrides: getOverrides(options, "unocss")
|
|
1901
|
+
}));
|
|
1786
1902
|
}
|
|
1787
1903
|
if (options.jsonc ?? true) {
|
|
1788
1904
|
configs.push(
|
|
1789
1905
|
jsonc({
|
|
1790
|
-
overrides:
|
|
1906
|
+
overrides: getOverrides(options, "jsonc"),
|
|
1791
1907
|
stylistic: stylisticOptions
|
|
1792
1908
|
}),
|
|
1793
1909
|
sortPackageJson(),
|
|
@@ -1796,13 +1912,13 @@ async function antfu(options = {}, ...userConfigs) {
|
|
|
1796
1912
|
}
|
|
1797
1913
|
if (options.yaml ?? true) {
|
|
1798
1914
|
configs.push(yaml({
|
|
1799
|
-
overrides:
|
|
1915
|
+
overrides: getOverrides(options, "yaml"),
|
|
1800
1916
|
stylistic: stylisticOptions
|
|
1801
1917
|
}));
|
|
1802
1918
|
}
|
|
1803
1919
|
if (options.toml ?? true) {
|
|
1804
1920
|
configs.push(toml({
|
|
1805
|
-
overrides:
|
|
1921
|
+
overrides: getOverrides(options, "toml"),
|
|
1806
1922
|
stylistic: stylisticOptions
|
|
1807
1923
|
}));
|
|
1808
1924
|
}
|
|
@@ -1811,7 +1927,7 @@ async function antfu(options = {}, ...userConfigs) {
|
|
|
1811
1927
|
markdown(
|
|
1812
1928
|
{
|
|
1813
1929
|
componentExts,
|
|
1814
|
-
overrides:
|
|
1930
|
+
overrides: getOverrides(options, "markdown")
|
|
1815
1931
|
}
|
|
1816
1932
|
)
|
|
1817
1933
|
);
|
|
@@ -1835,6 +1951,16 @@ async function antfu(options = {}, ...userConfigs) {
|
|
|
1835
1951
|
);
|
|
1836
1952
|
return merged;
|
|
1837
1953
|
}
|
|
1954
|
+
function resolveSubOptions(options, key) {
|
|
1955
|
+
return typeof options[key] === "boolean" ? {} : options[key] || {};
|
|
1956
|
+
}
|
|
1957
|
+
function getOverrides(options, key) {
|
|
1958
|
+
const sub = resolveSubOptions(options, key);
|
|
1959
|
+
return {
|
|
1960
|
+
...options.overrides?.[key],
|
|
1961
|
+
..."overrides" in sub ? sub.overrides : {}
|
|
1962
|
+
};
|
|
1963
|
+
}
|
|
1838
1964
|
|
|
1839
1965
|
// src/index.ts
|
|
1840
1966
|
var src_default = antfu;
|
|
@@ -1857,6 +1983,7 @@ export {
|
|
|
1857
1983
|
GLOB_SRC,
|
|
1858
1984
|
GLOB_SRC_EXT,
|
|
1859
1985
|
GLOB_STYLE,
|
|
1986
|
+
GLOB_SVELTE,
|
|
1860
1987
|
GLOB_TESTS,
|
|
1861
1988
|
GLOB_TOML,
|
|
1862
1989
|
GLOB_TS,
|
|
@@ -1870,6 +1997,7 @@ export {
|
|
|
1870
1997
|
src_default as default,
|
|
1871
1998
|
ensurePackages,
|
|
1872
1999
|
formatters,
|
|
2000
|
+
getOverrides,
|
|
1873
2001
|
ignores,
|
|
1874
2002
|
imports,
|
|
1875
2003
|
interopDefault,
|
|
@@ -1882,9 +2010,11 @@ export {
|
|
|
1882
2010
|
perfectionist,
|
|
1883
2011
|
react,
|
|
1884
2012
|
renameRules,
|
|
2013
|
+
resolveSubOptions,
|
|
1885
2014
|
sortPackageJson,
|
|
1886
2015
|
sortTsconfig,
|
|
1887
2016
|
stylistic,
|
|
2017
|
+
svelte,
|
|
1888
2018
|
test,
|
|
1889
2019
|
toArray,
|
|
1890
2020
|
toml,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antfu/eslint-config",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.6.0",
|
|
5
5
|
"packageManager": "pnpm@8.12.1",
|
|
6
6
|
"description": "Anthony's ESLint config",
|
|
7
7
|
"author": "Anthony Fu <anthonyfu117@hotmail.com> (https://github.com/antfu/)",
|
|
@@ -30,7 +30,9 @@
|
|
|
30
30
|
"eslint-plugin-format": ">=0.1.0",
|
|
31
31
|
"eslint-plugin-react": "^7.33.2",
|
|
32
32
|
"eslint-plugin-react-hooks": "^4.6.0",
|
|
33
|
-
"eslint-plugin-react-refresh": "^0.4.4"
|
|
33
|
+
"eslint-plugin-react-refresh": "^0.4.4",
|
|
34
|
+
"eslint-plugin-svelte": "^2.34.1",
|
|
35
|
+
"svelte-eslint-parser": "^0.33.1"
|
|
34
36
|
},
|
|
35
37
|
"peerDependenciesMeta": {
|
|
36
38
|
"@unocss/eslint-plugin": {
|
|
@@ -47,6 +49,12 @@
|
|
|
47
49
|
},
|
|
48
50
|
"eslint-plugin-react-refresh": {
|
|
49
51
|
"optional": true
|
|
52
|
+
},
|
|
53
|
+
"eslint-plugin-svelte": {
|
|
54
|
+
"optional": true
|
|
55
|
+
},
|
|
56
|
+
"svelte-eslint-parser": {
|
|
57
|
+
"optional": true
|
|
50
58
|
}
|
|
51
59
|
},
|
|
52
60
|
"dependencies": {
|
|
@@ -56,23 +64,23 @@
|
|
|
56
64
|
"@eslint-types/typescript-eslint": "^6.12.0",
|
|
57
65
|
"@eslint-types/unicorn": "^49.0.0",
|
|
58
66
|
"@stylistic/eslint-plugin": "^1.5.1",
|
|
59
|
-
"@typescript-eslint/eslint-plugin": "^6.
|
|
60
|
-
"@typescript-eslint/parser": "^6.
|
|
67
|
+
"@typescript-eslint/eslint-plugin": "^6.15.0",
|
|
68
|
+
"@typescript-eslint/parser": "^6.15.0",
|
|
61
69
|
"eslint-config-flat-gitignore": "^0.1.2",
|
|
62
70
|
"eslint-merge-processors": "^0.1.0",
|
|
63
|
-
"eslint-plugin-antfu": "^2.
|
|
71
|
+
"eslint-plugin-antfu": "^2.1.0",
|
|
64
72
|
"eslint-plugin-eslint-comments": "^3.2.0",
|
|
65
|
-
"eslint-plugin-i": "^2.29.
|
|
73
|
+
"eslint-plugin-i": "^2.29.1",
|
|
66
74
|
"eslint-plugin-jsdoc": "^46.9.1",
|
|
67
|
-
"eslint-plugin-jsonc": "^2.11.
|
|
75
|
+
"eslint-plugin-jsonc": "^2.11.2",
|
|
68
76
|
"eslint-plugin-markdown": "^3.0.1",
|
|
69
|
-
"eslint-plugin-n": "^16.
|
|
77
|
+
"eslint-plugin-n": "^16.5.0",
|
|
70
78
|
"eslint-plugin-no-only-tests": "^3.1.0",
|
|
71
79
|
"eslint-plugin-perfectionist": "^2.5.0",
|
|
72
80
|
"eslint-plugin-toml": "^0.8.0",
|
|
73
|
-
"eslint-plugin-unicorn": "^
|
|
81
|
+
"eslint-plugin-unicorn": "^50.0.1",
|
|
74
82
|
"eslint-plugin-unused-imports": "^3.0.0",
|
|
75
|
-
"eslint-plugin-vitest": "^0.3.
|
|
83
|
+
"eslint-plugin-vitest": "^0.3.20",
|
|
76
84
|
"eslint-plugin-vue": "^9.19.2",
|
|
77
85
|
"eslint-plugin-yml": "^1.11.0",
|
|
78
86
|
"eslint-processor-vue-blocks": "^0.1.1",
|
|
@@ -91,9 +99,9 @@
|
|
|
91
99
|
"@antfu/eslint-plugin-prettier": "^5.0.1-1",
|
|
92
100
|
"@antfu/ni": "^0.21.12",
|
|
93
101
|
"@stylistic/eslint-plugin-migrate": "^1.5.1",
|
|
94
|
-
"@types/eslint": "^8.
|
|
102
|
+
"@types/eslint": "^8.56.0",
|
|
95
103
|
"@types/fs-extra": "^11.0.4",
|
|
96
|
-
"@types/node": "^20.10.
|
|
104
|
+
"@types/node": "^20.10.5",
|
|
97
105
|
"@types/prompts": "^2.4.9",
|
|
98
106
|
"@types/yargs": "^17.0.32",
|
|
99
107
|
"@unocss/eslint-plugin": "^0.58.0",
|
|
@@ -104,6 +112,7 @@
|
|
|
104
112
|
"eslint-plugin-react": "^7.33.2",
|
|
105
113
|
"eslint-plugin-react-hooks": "^4.6.0",
|
|
106
114
|
"eslint-plugin-react-refresh": "^0.4.5",
|
|
115
|
+
"eslint-plugin-svelte": "^2.35.1",
|
|
107
116
|
"eslint-ts-patch": "^8.55.0-1",
|
|
108
117
|
"esno": "^4.0.0",
|
|
109
118
|
"execa": "^8.0.1",
|
|
@@ -112,11 +121,12 @@
|
|
|
112
121
|
"lint-staged": "^15.2.0",
|
|
113
122
|
"rimraf": "^5.0.5",
|
|
114
123
|
"simple-git-hooks": "^2.9.0",
|
|
124
|
+
"svelte-eslint-parser": "^0.33.1",
|
|
115
125
|
"tsup": "^8.0.1",
|
|
116
126
|
"typescript": "^5.3.3",
|
|
117
|
-
"vitest": "^1.0
|
|
118
|
-
"vue": "^3.3.
|
|
119
|
-
"@antfu/eslint-config": "2.
|
|
127
|
+
"vitest": "^1.1.0",
|
|
128
|
+
"vue": "^3.3.13",
|
|
129
|
+
"@antfu/eslint-config": "2.6.0"
|
|
120
130
|
},
|
|
121
131
|
"simple-git-hooks": {
|
|
122
132
|
"pre-commit": "pnpm lint-staged"
|