@antfu/eslint-config 2.4.6 → 2.5.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 +22 -2
- package/bin/index.js +1 -1
- package/dist/cli.cjs +7 -5
- package/dist/cli.js +7 -5
- package/dist/index.cjs +126 -4
- package/dist/index.d.cts +26 -2
- package/dist/index.d.ts +26 -2
- package/dist/index.js +124 -4
- 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
|
|
|
@@ -403,6 +404,25 @@ Running `npx eslint` should prompt you to install the required dependencies, oth
|
|
|
403
404
|
npm i -D eslint-plugin-react eslint-plugin-react-hooks eslint-plugin-react-refresh
|
|
404
405
|
```
|
|
405
406
|
|
|
407
|
+
#### Svelte
|
|
408
|
+
|
|
409
|
+
To enable svelte support, you need to explicitly turn it on:
|
|
410
|
+
|
|
411
|
+
```js
|
|
412
|
+
// eslint.config.js
|
|
413
|
+
import antfu from '@antfu/eslint-config'
|
|
414
|
+
|
|
415
|
+
export default antfu({
|
|
416
|
+
svelte: true,
|
|
417
|
+
})
|
|
418
|
+
```
|
|
419
|
+
|
|
420
|
+
Running `npx eslint` should prompt you to install the required dependencies, otherwise, you can install them manually:
|
|
421
|
+
|
|
422
|
+
```bash
|
|
423
|
+
npm i -D eslint-plugin-svelte
|
|
424
|
+
```
|
|
425
|
+
|
|
406
426
|
#### UnoCSS
|
|
407
427
|
|
|
408
428
|
To enable UnoCSS support, you need to explicitly turn it on:
|
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.5.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.5.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,
|
|
@@ -76,6 +77,7 @@ __export(src_exports, {
|
|
|
76
77
|
sortPackageJson: () => sortPackageJson,
|
|
77
78
|
sortTsconfig: () => sortTsconfig,
|
|
78
79
|
stylistic: () => stylistic,
|
|
80
|
+
svelte: () => svelte,
|
|
79
81
|
test: () => test,
|
|
80
82
|
toArray: () => toArray,
|
|
81
83
|
toml: () => toml,
|
|
@@ -136,6 +138,7 @@ var GLOB_JSON5 = "**/*.json5";
|
|
|
136
138
|
var GLOB_JSONC = "**/*.jsonc";
|
|
137
139
|
var GLOB_MARKDOWN = "**/*.md";
|
|
138
140
|
var GLOB_MARKDOWN_IN_MARKDOWN = "**/*.md/*.md";
|
|
141
|
+
var GLOB_SVELTE = "**/*.svelte";
|
|
139
142
|
var GLOB_VUE = "**/*.vue";
|
|
140
143
|
var GLOB_YAML = "**/*.y?(a)ml";
|
|
141
144
|
var GLOB_TOML = "**/*.toml";
|
|
@@ -154,6 +157,7 @@ var GLOB_ALL_SRC = [
|
|
|
154
157
|
GLOB_JSON,
|
|
155
158
|
GLOB_JSON5,
|
|
156
159
|
GLOB_MARKDOWN,
|
|
160
|
+
GLOB_SVELTE,
|
|
157
161
|
GLOB_VUE,
|
|
158
162
|
GLOB_YAML,
|
|
159
163
|
GLOB_HTML
|
|
@@ -212,6 +216,7 @@ async function imports(options = {}) {
|
|
|
212
216
|
},
|
|
213
217
|
rules: {
|
|
214
218
|
"antfu/import-dedupe": "error",
|
|
219
|
+
"antfu/no-import-dist": "error",
|
|
215
220
|
"antfu/no-import-node-modules-by-path": "error",
|
|
216
221
|
"import/first": "error",
|
|
217
222
|
"import/no-duplicates": "error",
|
|
@@ -760,6 +765,7 @@ async function stylistic(options = {}) {
|
|
|
760
765
|
const {
|
|
761
766
|
indent,
|
|
762
767
|
jsx,
|
|
768
|
+
overrides = {},
|
|
763
769
|
quotes,
|
|
764
770
|
semi
|
|
765
771
|
} = {
|
|
@@ -787,7 +793,8 @@ async function stylistic(options = {}) {
|
|
|
787
793
|
"antfu/consistent-list-newline": "error",
|
|
788
794
|
"antfu/if-newline": "error",
|
|
789
795
|
"antfu/top-level-function": "error",
|
|
790
|
-
"curly": ["error", "multi-or-nest", "consistent"]
|
|
796
|
+
"curly": ["error", "multi-or-nest", "consistent"],
|
|
797
|
+
...overrides
|
|
791
798
|
}
|
|
792
799
|
}
|
|
793
800
|
];
|
|
@@ -924,6 +931,7 @@ async function formatters(options = {}, stylistic2 = {}) {
|
|
|
924
931
|
[`format/${formater}`]: [
|
|
925
932
|
"error",
|
|
926
933
|
formater === "prettier" ? {
|
|
934
|
+
printWidth: 120,
|
|
927
935
|
...prettierOptions,
|
|
928
936
|
embeddedLanguageFormatting: "off",
|
|
929
937
|
parser: "markdown"
|
|
@@ -1263,6 +1271,98 @@ function sortTsconfig() {
|
|
|
1263
1271
|
];
|
|
1264
1272
|
}
|
|
1265
1273
|
|
|
1274
|
+
// src/configs/svelte.ts
|
|
1275
|
+
async function svelte(options = {}) {
|
|
1276
|
+
const {
|
|
1277
|
+
files = [GLOB_SVELTE],
|
|
1278
|
+
overrides = {},
|
|
1279
|
+
stylistic: stylistic2 = true
|
|
1280
|
+
} = options;
|
|
1281
|
+
const {
|
|
1282
|
+
indent = 2,
|
|
1283
|
+
quotes = "single"
|
|
1284
|
+
} = typeof stylistic2 === "boolean" ? {} : stylistic2;
|
|
1285
|
+
await ensurePackages([
|
|
1286
|
+
"eslint-plugin-svelte"
|
|
1287
|
+
]);
|
|
1288
|
+
const [
|
|
1289
|
+
pluginSvelte,
|
|
1290
|
+
parserSvelte
|
|
1291
|
+
] = await Promise.all([
|
|
1292
|
+
interopDefault(import("eslint-plugin-svelte")),
|
|
1293
|
+
interopDefault(import("svelte-eslint-parser"))
|
|
1294
|
+
]);
|
|
1295
|
+
return [
|
|
1296
|
+
{
|
|
1297
|
+
name: "antfu:svelte:setup",
|
|
1298
|
+
plugins: {
|
|
1299
|
+
svelte: pluginSvelte
|
|
1300
|
+
}
|
|
1301
|
+
},
|
|
1302
|
+
{
|
|
1303
|
+
files,
|
|
1304
|
+
languageOptions: {
|
|
1305
|
+
parser: parserSvelte,
|
|
1306
|
+
parserOptions: {
|
|
1307
|
+
extraFileExtensions: [".svelte"],
|
|
1308
|
+
parser: options.typescript ? await interopDefault(import("@typescript-eslint/parser")) : null
|
|
1309
|
+
}
|
|
1310
|
+
},
|
|
1311
|
+
name: "antfu:svelte:rules",
|
|
1312
|
+
rules: {
|
|
1313
|
+
"import/no-mutable-exports": "off",
|
|
1314
|
+
"no-undef": "off",
|
|
1315
|
+
// incompatible with most recent (attribute-form) generic types RFC
|
|
1316
|
+
"no-unused-vars": ["error", {
|
|
1317
|
+
args: "none",
|
|
1318
|
+
caughtErrors: "none",
|
|
1319
|
+
ignoreRestSiblings: true,
|
|
1320
|
+
vars: "all",
|
|
1321
|
+
varsIgnorePattern: "^\\$\\$Props$"
|
|
1322
|
+
}],
|
|
1323
|
+
"svelte/comment-directive": "error",
|
|
1324
|
+
"svelte/no-at-debug-tags": "warn",
|
|
1325
|
+
"svelte/no-at-html-tags": "error",
|
|
1326
|
+
"svelte/no-dupe-else-if-blocks": "error",
|
|
1327
|
+
"svelte/no-dupe-style-properties": "error",
|
|
1328
|
+
"svelte/no-dupe-use-directives": "error",
|
|
1329
|
+
"svelte/no-dynamic-slot-name": "error",
|
|
1330
|
+
"svelte/no-export-load-in-svelte-module-in-kit-pages": "error",
|
|
1331
|
+
"svelte/no-inner-declarations": "error",
|
|
1332
|
+
"svelte/no-not-function-handler": "error",
|
|
1333
|
+
"svelte/no-object-in-text-mustaches": "error",
|
|
1334
|
+
"svelte/no-reactive-functions": "error",
|
|
1335
|
+
"svelte/no-reactive-literals": "error",
|
|
1336
|
+
"svelte/no-shorthand-style-property-overrides": "error",
|
|
1337
|
+
"svelte/no-unknown-style-directive-property": "error",
|
|
1338
|
+
"svelte/no-unused-svelte-ignore": "error",
|
|
1339
|
+
"svelte/no-useless-mustaches": "error",
|
|
1340
|
+
"svelte/require-store-callbacks-use-set-param": "error",
|
|
1341
|
+
"svelte/system": "error",
|
|
1342
|
+
"svelte/valid-compile": "error",
|
|
1343
|
+
"svelte/valid-each-key": "error",
|
|
1344
|
+
"unused-imports/no-unused-vars": [
|
|
1345
|
+
"error",
|
|
1346
|
+
{ args: "after-used", argsIgnorePattern: "^_", vars: "all", varsIgnorePattern: "^(_|\\$\\$Props$)" }
|
|
1347
|
+
],
|
|
1348
|
+
...stylistic2 ? {
|
|
1349
|
+
"style/no-trailing-spaces": "off",
|
|
1350
|
+
// superseded by svelte/no-trailing-spaces
|
|
1351
|
+
"svelte/derived-has-same-inputs-outputs": "error",
|
|
1352
|
+
"svelte/html-closing-bracket-spacing": "error",
|
|
1353
|
+
"svelte/html-quotes": ["error", { prefer: quotes }],
|
|
1354
|
+
"svelte/indent": ["error", { alignAttributesVertically: true, indent }],
|
|
1355
|
+
"svelte/mustache-spacing": "error",
|
|
1356
|
+
"svelte/no-spaces-around-equal-signs-in-attribute": "error",
|
|
1357
|
+
"svelte/no-trailing-spaces": "error",
|
|
1358
|
+
"svelte/spaced-html-comment": "error"
|
|
1359
|
+
} : {},
|
|
1360
|
+
...overrides
|
|
1361
|
+
}
|
|
1362
|
+
}
|
|
1363
|
+
];
|
|
1364
|
+
}
|
|
1365
|
+
|
|
1266
1366
|
// src/configs/test.ts
|
|
1267
1367
|
async function test(options = {}) {
|
|
1268
1368
|
const {
|
|
@@ -1321,6 +1421,7 @@ async function typescript(options = {}) {
|
|
|
1321
1421
|
GLOB_SRC,
|
|
1322
1422
|
...componentExts.map((ext) => `**/*.${ext}`)
|
|
1323
1423
|
];
|
|
1424
|
+
const filesTypeAware = options.filesTypeAware ?? [GLOB_TS, GLOB_TSX];
|
|
1324
1425
|
const typeAwareRules = {
|
|
1325
1426
|
"dot-notation": "off",
|
|
1326
1427
|
"no-implied-eval": "off",
|
|
@@ -1410,6 +1511,13 @@ async function typescript(options = {}) {
|
|
|
1410
1511
|
"ts/prefer-ts-expect-error": "error",
|
|
1411
1512
|
"ts/triple-slash-reference": "off",
|
|
1412
1513
|
"ts/unified-signatures": "off",
|
|
1514
|
+
...overrides
|
|
1515
|
+
}
|
|
1516
|
+
},
|
|
1517
|
+
{
|
|
1518
|
+
files: filesTypeAware,
|
|
1519
|
+
name: "antfu:typescript:rules-type-aware",
|
|
1520
|
+
rules: {
|
|
1413
1521
|
...tsconfigPath ? typeAwareRules : {},
|
|
1414
1522
|
...overrides
|
|
1415
1523
|
}
|
|
@@ -1800,9 +1908,10 @@ async function antfu(options = {}, ...userConfigs) {
|
|
|
1800
1908
|
const {
|
|
1801
1909
|
componentExts = [],
|
|
1802
1910
|
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),
|
|
1911
|
+
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),
|
|
1804
1912
|
overrides = {},
|
|
1805
1913
|
react: enableReact = false,
|
|
1914
|
+
svelte: enableSvelte = false,
|
|
1806
1915
|
typescript: enableTypeScript = (0, import_local_pkg3.isPackageExists)("typescript"),
|
|
1807
1916
|
unocss: enableUnoCSS = false,
|
|
1808
1917
|
vue: enableVue = VuePackages.some((i) => (0, import_local_pkg3.isPackageExists)(i))
|
|
@@ -1846,8 +1955,12 @@ async function antfu(options = {}, ...userConfigs) {
|
|
|
1846
1955
|
overrides: overrides.typescript
|
|
1847
1956
|
}));
|
|
1848
1957
|
}
|
|
1849
|
-
if (stylisticOptions)
|
|
1850
|
-
configs.push(stylistic(
|
|
1958
|
+
if (stylisticOptions) {
|
|
1959
|
+
configs.push(stylistic({
|
|
1960
|
+
...stylisticOptions,
|
|
1961
|
+
overrides: overrides.stylistic
|
|
1962
|
+
}));
|
|
1963
|
+
}
|
|
1851
1964
|
if (options.test ?? true) {
|
|
1852
1965
|
configs.push(test({
|
|
1853
1966
|
isInEditor,
|
|
@@ -1868,6 +1981,13 @@ async function antfu(options = {}, ...userConfigs) {
|
|
|
1868
1981
|
typescript: !!enableTypeScript
|
|
1869
1982
|
}));
|
|
1870
1983
|
}
|
|
1984
|
+
if (enableSvelte) {
|
|
1985
|
+
configs.push(svelte({
|
|
1986
|
+
overrides: overrides.svelte,
|
|
1987
|
+
stylistic: stylisticOptions,
|
|
1988
|
+
typescript: !!enableTypeScript
|
|
1989
|
+
}));
|
|
1990
|
+
}
|
|
1871
1991
|
if (enableUnoCSS) {
|
|
1872
1992
|
configs.push(unocss(
|
|
1873
1993
|
typeof enableUnoCSS === "boolean" ? {} : enableUnoCSS
|
|
@@ -1947,6 +2067,7 @@ var src_default = antfu;
|
|
|
1947
2067
|
GLOB_SRC,
|
|
1948
2068
|
GLOB_SRC_EXT,
|
|
1949
2069
|
GLOB_STYLE,
|
|
2070
|
+
GLOB_SVELTE,
|
|
1950
2071
|
GLOB_TESTS,
|
|
1951
2072
|
GLOB_TOML,
|
|
1952
2073
|
GLOB_TS,
|
|
@@ -1974,6 +2095,7 @@ var src_default = antfu;
|
|
|
1974
2095
|
sortPackageJson,
|
|
1975
2096
|
sortTsconfig,
|
|
1976
2097
|
stylistic,
|
|
2098
|
+
svelte,
|
|
1977
2099
|
test,
|
|
1978
2100
|
toArray,
|
|
1979
2101
|
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
|
*/
|
|
@@ -198,6 +203,11 @@ interface OptionsTypeScriptParserOptions {
|
|
|
198
203
|
* Additional parser options for TypeScript.
|
|
199
204
|
*/
|
|
200
205
|
parserOptions?: Partial<ParserOptions>;
|
|
206
|
+
/**
|
|
207
|
+
* Glob patterns for files that should be type aware.
|
|
208
|
+
* @default ['**\/*.{ts,tsx}']
|
|
209
|
+
*/
|
|
210
|
+
filesTypeAware?: string[];
|
|
201
211
|
}
|
|
202
212
|
interface OptionsTypeScriptWithTypes {
|
|
203
213
|
/**
|
|
@@ -313,6 +323,15 @@ interface OptionsConfig extends OptionsComponentExts {
|
|
|
313
323
|
* @default false
|
|
314
324
|
*/
|
|
315
325
|
react?: boolean;
|
|
326
|
+
/**
|
|
327
|
+
* Enable svelte rules.
|
|
328
|
+
*
|
|
329
|
+
* Requires installing:
|
|
330
|
+
* - `eslint-plugin-svelte`
|
|
331
|
+
*
|
|
332
|
+
* @default false
|
|
333
|
+
*/
|
|
334
|
+
svelte?: boolean;
|
|
316
335
|
/**
|
|
317
336
|
* Enable unocss rules.
|
|
318
337
|
*
|
|
@@ -342,6 +361,7 @@ interface OptionsConfig extends OptionsComponentExts {
|
|
|
342
361
|
* Provide overrides for rules for each integration.
|
|
343
362
|
*/
|
|
344
363
|
overrides?: {
|
|
364
|
+
stylistic?: FlatConfigItem['rules'];
|
|
345
365
|
javascript?: FlatConfigItem['rules'];
|
|
346
366
|
typescript?: FlatConfigItem['rules'];
|
|
347
367
|
test?: FlatConfigItem['rules'];
|
|
@@ -351,6 +371,7 @@ interface OptionsConfig extends OptionsComponentExts {
|
|
|
351
371
|
yaml?: FlatConfigItem['rules'];
|
|
352
372
|
toml?: FlatConfigItem['rules'];
|
|
353
373
|
react?: FlatConfigItem['rules'];
|
|
374
|
+
svelte?: FlatConfigItem['rules'];
|
|
354
375
|
};
|
|
355
376
|
}
|
|
356
377
|
|
|
@@ -400,7 +421,9 @@ declare function sortPackageJson(): Promise<FlatConfigItem[]>;
|
|
|
400
421
|
declare function sortTsconfig(): FlatConfigItem[];
|
|
401
422
|
|
|
402
423
|
declare const StylisticConfigDefaults: StylisticConfig;
|
|
403
|
-
declare function stylistic(options?: StylisticConfig): Promise<FlatConfigItem[]>;
|
|
424
|
+
declare function stylistic(options?: StylisticConfig & OptionsOverrides): Promise<FlatConfigItem[]>;
|
|
425
|
+
|
|
426
|
+
declare function svelte(options?: OptionsHasTypeScript & OptionsOverrides & OptionsStylistic & OptionsFiles): Promise<FlatConfigItem[]>;
|
|
404
427
|
|
|
405
428
|
declare function test(options?: OptionsFiles & OptionsIsInEditor & OptionsOverrides): Promise<FlatConfigItem[]>;
|
|
406
429
|
|
|
@@ -432,6 +455,7 @@ declare const GLOB_JSON5 = "**/*.json5";
|
|
|
432
455
|
declare const GLOB_JSONC = "**/*.jsonc";
|
|
433
456
|
declare const GLOB_MARKDOWN = "**/*.md";
|
|
434
457
|
declare const GLOB_MARKDOWN_IN_MARKDOWN = "**/*.md/*.md";
|
|
458
|
+
declare const GLOB_SVELTE = "**/*.svelte";
|
|
435
459
|
declare const GLOB_VUE = "**/*.vue";
|
|
436
460
|
declare const GLOB_YAML = "**/*.y?(a)ml";
|
|
437
461
|
declare const GLOB_TOML = "**/*.toml";
|
|
@@ -479,4 +503,4 @@ declare function interopDefault<T>(m: Awaitable<T>): Promise<T extends {
|
|
|
479
503
|
} ? U : T>;
|
|
480
504
|
declare function ensurePackages(packages: string[]): Promise<void>;
|
|
481
505
|
|
|
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 };
|
|
506
|
+
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 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, 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
|
*/
|
|
@@ -198,6 +203,11 @@ interface OptionsTypeScriptParserOptions {
|
|
|
198
203
|
* Additional parser options for TypeScript.
|
|
199
204
|
*/
|
|
200
205
|
parserOptions?: Partial<ParserOptions>;
|
|
206
|
+
/**
|
|
207
|
+
* Glob patterns for files that should be type aware.
|
|
208
|
+
* @default ['**\/*.{ts,tsx}']
|
|
209
|
+
*/
|
|
210
|
+
filesTypeAware?: string[];
|
|
201
211
|
}
|
|
202
212
|
interface OptionsTypeScriptWithTypes {
|
|
203
213
|
/**
|
|
@@ -313,6 +323,15 @@ interface OptionsConfig extends OptionsComponentExts {
|
|
|
313
323
|
* @default false
|
|
314
324
|
*/
|
|
315
325
|
react?: boolean;
|
|
326
|
+
/**
|
|
327
|
+
* Enable svelte rules.
|
|
328
|
+
*
|
|
329
|
+
* Requires installing:
|
|
330
|
+
* - `eslint-plugin-svelte`
|
|
331
|
+
*
|
|
332
|
+
* @default false
|
|
333
|
+
*/
|
|
334
|
+
svelte?: boolean;
|
|
316
335
|
/**
|
|
317
336
|
* Enable unocss rules.
|
|
318
337
|
*
|
|
@@ -342,6 +361,7 @@ interface OptionsConfig extends OptionsComponentExts {
|
|
|
342
361
|
* Provide overrides for rules for each integration.
|
|
343
362
|
*/
|
|
344
363
|
overrides?: {
|
|
364
|
+
stylistic?: FlatConfigItem['rules'];
|
|
345
365
|
javascript?: FlatConfigItem['rules'];
|
|
346
366
|
typescript?: FlatConfigItem['rules'];
|
|
347
367
|
test?: FlatConfigItem['rules'];
|
|
@@ -351,6 +371,7 @@ interface OptionsConfig extends OptionsComponentExts {
|
|
|
351
371
|
yaml?: FlatConfigItem['rules'];
|
|
352
372
|
toml?: FlatConfigItem['rules'];
|
|
353
373
|
react?: FlatConfigItem['rules'];
|
|
374
|
+
svelte?: FlatConfigItem['rules'];
|
|
354
375
|
};
|
|
355
376
|
}
|
|
356
377
|
|
|
@@ -400,7 +421,9 @@ declare function sortPackageJson(): Promise<FlatConfigItem[]>;
|
|
|
400
421
|
declare function sortTsconfig(): FlatConfigItem[];
|
|
401
422
|
|
|
402
423
|
declare const StylisticConfigDefaults: StylisticConfig;
|
|
403
|
-
declare function stylistic(options?: StylisticConfig): Promise<FlatConfigItem[]>;
|
|
424
|
+
declare function stylistic(options?: StylisticConfig & OptionsOverrides): Promise<FlatConfigItem[]>;
|
|
425
|
+
|
|
426
|
+
declare function svelte(options?: OptionsHasTypeScript & OptionsOverrides & OptionsStylistic & OptionsFiles): Promise<FlatConfigItem[]>;
|
|
404
427
|
|
|
405
428
|
declare function test(options?: OptionsFiles & OptionsIsInEditor & OptionsOverrides): Promise<FlatConfigItem[]>;
|
|
406
429
|
|
|
@@ -432,6 +455,7 @@ declare const GLOB_JSON5 = "**/*.json5";
|
|
|
432
455
|
declare const GLOB_JSONC = "**/*.jsonc";
|
|
433
456
|
declare const GLOB_MARKDOWN = "**/*.md";
|
|
434
457
|
declare const GLOB_MARKDOWN_IN_MARKDOWN = "**/*.md/*.md";
|
|
458
|
+
declare const GLOB_SVELTE = "**/*.svelte";
|
|
435
459
|
declare const GLOB_VUE = "**/*.vue";
|
|
436
460
|
declare const GLOB_YAML = "**/*.y?(a)ml";
|
|
437
461
|
declare const GLOB_TOML = "**/*.toml";
|
|
@@ -479,4 +503,4 @@ declare function interopDefault<T>(m: Awaitable<T>): Promise<T extends {
|
|
|
479
503
|
} ? U : T>;
|
|
480
504
|
declare function ensurePackages(packages: string[]): Promise<void>;
|
|
481
505
|
|
|
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 };
|
|
506
|
+
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 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, 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,10 @@ 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),
|
|
1820
|
+
isInEditor = !!((process3.env.VSCODE_PID || process3.env.JETBRAINS_IDE || process3.env.VIM) && !process3.env.CI),
|
|
1715
1821
|
overrides = {},
|
|
1716
1822
|
react: enableReact = false,
|
|
1823
|
+
svelte: enableSvelte = false,
|
|
1717
1824
|
typescript: enableTypeScript = isPackageExists3("typescript"),
|
|
1718
1825
|
unocss: enableUnoCSS = false,
|
|
1719
1826
|
vue: enableVue = VuePackages.some((i) => isPackageExists3(i))
|
|
@@ -1757,8 +1864,12 @@ async function antfu(options = {}, ...userConfigs) {
|
|
|
1757
1864
|
overrides: overrides.typescript
|
|
1758
1865
|
}));
|
|
1759
1866
|
}
|
|
1760
|
-
if (stylisticOptions)
|
|
1761
|
-
configs.push(stylistic(
|
|
1867
|
+
if (stylisticOptions) {
|
|
1868
|
+
configs.push(stylistic({
|
|
1869
|
+
...stylisticOptions,
|
|
1870
|
+
overrides: overrides.stylistic
|
|
1871
|
+
}));
|
|
1872
|
+
}
|
|
1762
1873
|
if (options.test ?? true) {
|
|
1763
1874
|
configs.push(test({
|
|
1764
1875
|
isInEditor,
|
|
@@ -1779,6 +1890,13 @@ async function antfu(options = {}, ...userConfigs) {
|
|
|
1779
1890
|
typescript: !!enableTypeScript
|
|
1780
1891
|
}));
|
|
1781
1892
|
}
|
|
1893
|
+
if (enableSvelte) {
|
|
1894
|
+
configs.push(svelte({
|
|
1895
|
+
overrides: overrides.svelte,
|
|
1896
|
+
stylistic: stylisticOptions,
|
|
1897
|
+
typescript: !!enableTypeScript
|
|
1898
|
+
}));
|
|
1899
|
+
}
|
|
1782
1900
|
if (enableUnoCSS) {
|
|
1783
1901
|
configs.push(unocss(
|
|
1784
1902
|
typeof enableUnoCSS === "boolean" ? {} : enableUnoCSS
|
|
@@ -1857,6 +1975,7 @@ export {
|
|
|
1857
1975
|
GLOB_SRC,
|
|
1858
1976
|
GLOB_SRC_EXT,
|
|
1859
1977
|
GLOB_STYLE,
|
|
1978
|
+
GLOB_SVELTE,
|
|
1860
1979
|
GLOB_TESTS,
|
|
1861
1980
|
GLOB_TOML,
|
|
1862
1981
|
GLOB_TS,
|
|
@@ -1885,6 +2004,7 @@ export {
|
|
|
1885
2004
|
sortPackageJson,
|
|
1886
2005
|
sortTsconfig,
|
|
1887
2006
|
stylistic,
|
|
2007
|
+
svelte,
|
|
1888
2008
|
test,
|
|
1889
2009
|
toArray,
|
|
1890
2010
|
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.5.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.5.0"
|
|
120
130
|
},
|
|
121
131
|
"simple-git-hooks": {
|
|
122
132
|
"pre-commit": "pnpm lint-staged"
|