@antfu/eslint-config 2.6.4 → 2.8.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 +20 -1
- package/dist/cli.cjs +22 -17
- package/dist/cli.js +22 -17
- package/dist/index.cjs +129 -11
- package/dist/index.d.cts +25 -2
- package/dist/index.d.ts +25 -2
- package/dist/index.js +127 -11
- package/package.json +50 -30
package/README.md
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
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
|
+
- Optional [React](#react), [Svelte](#svelte), [UnoCSS](#unocss), [Astro](#astro) support
|
|
16
16
|
- Optional [formatters](#formatters) support for CSS, HTML, etc.
|
|
17
17
|
- **Style principle**: Minimal for reading, stable for diff, consistent
|
|
18
18
|
|
|
@@ -431,6 +431,25 @@ Running `npx eslint` should prompt you to install the required dependencies, oth
|
|
|
431
431
|
npm i -D eslint-plugin-svelte
|
|
432
432
|
```
|
|
433
433
|
|
|
434
|
+
#### Astro
|
|
435
|
+
|
|
436
|
+
To enable astro support, you need to explicitly turn it on:
|
|
437
|
+
|
|
438
|
+
```js
|
|
439
|
+
// eslint.config.js
|
|
440
|
+
import antfu from '@antfu/eslint-config'
|
|
441
|
+
|
|
442
|
+
export default antfu({
|
|
443
|
+
astro: true,
|
|
444
|
+
})
|
|
445
|
+
```
|
|
446
|
+
|
|
447
|
+
Running `npx eslint` should prompt you to install the required dependencies, otherwise, you can install them manually:
|
|
448
|
+
|
|
449
|
+
```bash
|
|
450
|
+
npm i -D eslint-plugin-astro
|
|
451
|
+
```
|
|
452
|
+
|
|
434
453
|
#### UnoCSS
|
|
435
454
|
|
|
436
455
|
To enable UnoCSS support, you need to explicitly turn it on:
|
package/dist/cli.cjs
CHANGED
|
@@ -46,40 +46,44 @@ 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.8.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
|
-
"@stylistic/eslint-plugin-migrate": "^1.
|
|
55
|
-
"@types/eslint": "^8.56.
|
|
54
|
+
"@stylistic/eslint-plugin-migrate": "^1.6.3",
|
|
55
|
+
"@types/eslint": "^8.56.5",
|
|
56
56
|
"@types/fs-extra": "^11.0.4",
|
|
57
|
-
"@types/node": "^20.11.
|
|
57
|
+
"@types/node": "^20.11.24",
|
|
58
58
|
"@types/prompts": "^2.4.9",
|
|
59
59
|
"@types/yargs": "^17.0.32",
|
|
60
|
-
"@unocss/eslint-plugin": "^0.58.
|
|
61
|
-
|
|
62
|
-
|
|
60
|
+
"@unocss/eslint-plugin": "^0.58.5",
|
|
61
|
+
"astro-eslint-parser": "^0.16.3",
|
|
62
|
+
bumpp: "^9.4.0",
|
|
63
|
+
eslint: "npm:eslint-ts-patch@^8.57.0-0",
|
|
63
64
|
"eslint-flat-config-viewer": "^0.1.11",
|
|
65
|
+
"eslint-plugin-astro": "^0.31.4",
|
|
64
66
|
"eslint-plugin-format": "^0.1.0",
|
|
65
|
-
"eslint-plugin-react": "^7.
|
|
67
|
+
"eslint-plugin-react": "^7.34.0",
|
|
66
68
|
"eslint-plugin-react-hooks": "^4.6.0",
|
|
67
69
|
"eslint-plugin-react-refresh": "^0.4.5",
|
|
68
70
|
"eslint-plugin-svelte": "^2.35.1",
|
|
69
|
-
"eslint-ts-patch": "^8.
|
|
70
|
-
esno: "^4.
|
|
71
|
+
"eslint-ts-patch": "^8.57.0-0",
|
|
72
|
+
esno: "^4.7.0",
|
|
71
73
|
execa: "^8.0.1",
|
|
72
74
|
"fast-glob": "^3.3.2",
|
|
73
75
|
"fs-extra": "^11.2.0",
|
|
74
|
-
"lint-staged": "^15.2.
|
|
76
|
+
"lint-staged": "^15.2.2",
|
|
77
|
+
"prettier-plugin-astro": "^0.13.0",
|
|
78
|
+
"prettier-plugin-slidev": "^1.0.5",
|
|
75
79
|
rimraf: "^5.0.5",
|
|
76
|
-
"simple-git-hooks": "^2.
|
|
77
|
-
svelte: "^4.2.
|
|
80
|
+
"simple-git-hooks": "^2.10.0",
|
|
81
|
+
svelte: "^4.2.12",
|
|
78
82
|
"svelte-eslint-parser": "^0.33.1",
|
|
79
|
-
tsup: "^8.0.
|
|
83
|
+
tsup: "^8.0.2",
|
|
80
84
|
typescript: "^5.3.3",
|
|
81
|
-
vitest: "^1.
|
|
82
|
-
vue: "^3.4.
|
|
85
|
+
vitest: "^1.3.1",
|
|
86
|
+
vue: "^3.4.21"
|
|
83
87
|
};
|
|
84
88
|
|
|
85
89
|
// src/cli/constants.ts
|
|
@@ -128,7 +132,8 @@ var vscodeSettingsString = `
|
|
|
128
132
|
"json",
|
|
129
133
|
"jsonc",
|
|
130
134
|
"yaml",
|
|
131
|
-
"toml"
|
|
135
|
+
"toml",
|
|
136
|
+
"astro",
|
|
132
137
|
]
|
|
133
138
|
`;
|
|
134
139
|
|
package/dist/cli.js
CHANGED
|
@@ -17,40 +17,44 @@ 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.8.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
|
-
"@stylistic/eslint-plugin-migrate": "^1.
|
|
26
|
-
"@types/eslint": "^8.56.
|
|
25
|
+
"@stylistic/eslint-plugin-migrate": "^1.6.3",
|
|
26
|
+
"@types/eslint": "^8.56.5",
|
|
27
27
|
"@types/fs-extra": "^11.0.4",
|
|
28
|
-
"@types/node": "^20.11.
|
|
28
|
+
"@types/node": "^20.11.24",
|
|
29
29
|
"@types/prompts": "^2.4.9",
|
|
30
30
|
"@types/yargs": "^17.0.32",
|
|
31
|
-
"@unocss/eslint-plugin": "^0.58.
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
"@unocss/eslint-plugin": "^0.58.5",
|
|
32
|
+
"astro-eslint-parser": "^0.16.3",
|
|
33
|
+
bumpp: "^9.4.0",
|
|
34
|
+
eslint: "npm:eslint-ts-patch@^8.57.0-0",
|
|
34
35
|
"eslint-flat-config-viewer": "^0.1.11",
|
|
36
|
+
"eslint-plugin-astro": "^0.31.4",
|
|
35
37
|
"eslint-plugin-format": "^0.1.0",
|
|
36
|
-
"eslint-plugin-react": "^7.
|
|
38
|
+
"eslint-plugin-react": "^7.34.0",
|
|
37
39
|
"eslint-plugin-react-hooks": "^4.6.0",
|
|
38
40
|
"eslint-plugin-react-refresh": "^0.4.5",
|
|
39
41
|
"eslint-plugin-svelte": "^2.35.1",
|
|
40
|
-
"eslint-ts-patch": "^8.
|
|
41
|
-
esno: "^4.
|
|
42
|
+
"eslint-ts-patch": "^8.57.0-0",
|
|
43
|
+
esno: "^4.7.0",
|
|
42
44
|
execa: "^8.0.1",
|
|
43
45
|
"fast-glob": "^3.3.2",
|
|
44
46
|
"fs-extra": "^11.2.0",
|
|
45
|
-
"lint-staged": "^15.2.
|
|
47
|
+
"lint-staged": "^15.2.2",
|
|
48
|
+
"prettier-plugin-astro": "^0.13.0",
|
|
49
|
+
"prettier-plugin-slidev": "^1.0.5",
|
|
46
50
|
rimraf: "^5.0.5",
|
|
47
|
-
"simple-git-hooks": "^2.
|
|
48
|
-
svelte: "^4.2.
|
|
51
|
+
"simple-git-hooks": "^2.10.0",
|
|
52
|
+
svelte: "^4.2.12",
|
|
49
53
|
"svelte-eslint-parser": "^0.33.1",
|
|
50
|
-
tsup: "^8.0.
|
|
54
|
+
tsup: "^8.0.2",
|
|
51
55
|
typescript: "^5.3.3",
|
|
52
|
-
vitest: "^1.
|
|
53
|
-
vue: "^3.4.
|
|
56
|
+
vitest: "^1.3.1",
|
|
57
|
+
vue: "^3.4.21"
|
|
54
58
|
};
|
|
55
59
|
|
|
56
60
|
// src/cli/constants.ts
|
|
@@ -99,7 +103,8 @@ var vscodeSettingsString = `
|
|
|
99
103
|
"json",
|
|
100
104
|
"jsonc",
|
|
101
105
|
"yaml",
|
|
102
|
-
"toml"
|
|
106
|
+
"toml",
|
|
107
|
+
"astro",
|
|
103
108
|
]
|
|
104
109
|
`;
|
|
105
110
|
|
package/dist/index.cjs
CHANGED
|
@@ -31,6 +31,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
31
31
|
var src_exports = {};
|
|
32
32
|
__export(src_exports, {
|
|
33
33
|
GLOB_ALL_SRC: () => GLOB_ALL_SRC,
|
|
34
|
+
GLOB_ASTRO: () => GLOB_ASTRO,
|
|
34
35
|
GLOB_CSS: () => GLOB_CSS,
|
|
35
36
|
GLOB_EXCLUDE: () => GLOB_EXCLUDE,
|
|
36
37
|
GLOB_HTML: () => GLOB_HTML,
|
|
@@ -57,6 +58,7 @@ __export(src_exports, {
|
|
|
57
58
|
GLOB_YAML: () => GLOB_YAML,
|
|
58
59
|
StylisticConfigDefaults: () => StylisticConfigDefaults,
|
|
59
60
|
antfu: () => antfu,
|
|
61
|
+
astro: () => astro,
|
|
60
62
|
combine: () => combine,
|
|
61
63
|
comments: () => comments,
|
|
62
64
|
default: () => src_default,
|
|
@@ -94,7 +96,7 @@ module.exports = __toCommonJS(src_exports);
|
|
|
94
96
|
// src/factory.ts
|
|
95
97
|
var import_node_process3 = __toESM(require("process"), 1);
|
|
96
98
|
var import_node_fs = __toESM(require("fs"), 1);
|
|
97
|
-
var
|
|
99
|
+
var import_local_pkg4 = require("local-pkg");
|
|
98
100
|
|
|
99
101
|
// src/plugins.ts
|
|
100
102
|
var import_eslint_plugin_antfu = __toESM(require("eslint-plugin-antfu"), 1);
|
|
@@ -145,6 +147,7 @@ var GLOB_VUE = "**/*.vue";
|
|
|
145
147
|
var GLOB_YAML = "**/*.y?(a)ml";
|
|
146
148
|
var GLOB_TOML = "**/*.toml";
|
|
147
149
|
var GLOB_HTML = "**/*.htm?(l)";
|
|
150
|
+
var GLOB_ASTRO = "**/*.astro";
|
|
148
151
|
var GLOB_MARKDOWN_CODE = `${GLOB_MARKDOWN}/${GLOB_SRC}`;
|
|
149
152
|
var GLOB_TESTS = [
|
|
150
153
|
`**/__tests__/**/*.${GLOB_SRC_EXT}`,
|
|
@@ -505,7 +508,7 @@ async function interopDefault(m) {
|
|
|
505
508
|
async function ensurePackages(packages) {
|
|
506
509
|
if (import_node_process.default.env.CI || import_node_process.default.stdout.isTTY === false)
|
|
507
510
|
return;
|
|
508
|
-
const nonExistingPackages = packages.filter((i) => !(0, import_local_pkg.isPackageExists)(i));
|
|
511
|
+
const nonExistingPackages = packages.filter((i) => i && !(0, import_local_pkg.isPackageExists)(i));
|
|
509
512
|
if (nonExistingPackages.length === 0)
|
|
510
513
|
return;
|
|
511
514
|
const { default: prompts } = await import("prompts");
|
|
@@ -762,6 +765,9 @@ async function perfectionist() {
|
|
|
762
765
|
];
|
|
763
766
|
}
|
|
764
767
|
|
|
768
|
+
// src/configs/formatters.ts
|
|
769
|
+
var import_local_pkg2 = require("local-pkg");
|
|
770
|
+
|
|
765
771
|
// src/configs/stylistic.ts
|
|
766
772
|
var StylisticConfigDefaults = {
|
|
767
773
|
indent: 2,
|
|
@@ -810,17 +816,23 @@ async function stylistic(options = {}) {
|
|
|
810
816
|
|
|
811
817
|
// src/configs/formatters.ts
|
|
812
818
|
async function formatters(options = {}, stylistic2 = {}) {
|
|
813
|
-
await ensurePackages([
|
|
814
|
-
"eslint-plugin-format"
|
|
815
|
-
]);
|
|
816
819
|
if (options === true) {
|
|
817
820
|
options = {
|
|
821
|
+
astro: (0, import_local_pkg2.isPackageExists)("astro"),
|
|
818
822
|
css: true,
|
|
819
823
|
graphql: true,
|
|
820
824
|
html: true,
|
|
821
|
-
markdown: true
|
|
825
|
+
markdown: true,
|
|
826
|
+
slidev: (0, import_local_pkg2.isPackageExists)("@slidev/cli")
|
|
822
827
|
};
|
|
823
828
|
}
|
|
829
|
+
await ensurePackages([
|
|
830
|
+
"eslint-plugin-format",
|
|
831
|
+
options.markdown && options.slidev ? "prettier-plugin-slidev" : void 0,
|
|
832
|
+
options.astro ? "prettier-plugin-astro" : void 0
|
|
833
|
+
]);
|
|
834
|
+
if (options.slidev && options.markdown !== true && options.markdown !== "prettier")
|
|
835
|
+
throw new Error("`slidev` option only works when `markdown` is enabled with `prettier`");
|
|
824
836
|
const {
|
|
825
837
|
indent,
|
|
826
838
|
quotes,
|
|
@@ -929,8 +941,10 @@ async function formatters(options = {}, stylistic2 = {}) {
|
|
|
929
941
|
}
|
|
930
942
|
if (options.markdown) {
|
|
931
943
|
const formater = options.markdown === true ? "prettier" : options.markdown;
|
|
944
|
+
const GLOB_SLIDEV = !options.slidev ? [] : options.slidev === true ? ["**/slides.md"] : options.slidev.files;
|
|
932
945
|
configs.push({
|
|
933
946
|
files: [GLOB_MARKDOWN],
|
|
947
|
+
ignores: GLOB_SLIDEV,
|
|
934
948
|
languageOptions: {
|
|
935
949
|
parser: parserPlain
|
|
936
950
|
},
|
|
@@ -950,6 +964,50 @@ async function formatters(options = {}, stylistic2 = {}) {
|
|
|
950
964
|
]
|
|
951
965
|
}
|
|
952
966
|
});
|
|
967
|
+
if (options.slidev) {
|
|
968
|
+
configs.push({
|
|
969
|
+
files: GLOB_SLIDEV,
|
|
970
|
+
languageOptions: {
|
|
971
|
+
parser: parserPlain
|
|
972
|
+
},
|
|
973
|
+
name: "antfu:formatter:slidev",
|
|
974
|
+
rules: {
|
|
975
|
+
"format/prettier": [
|
|
976
|
+
"error",
|
|
977
|
+
{
|
|
978
|
+
printWidth: 120,
|
|
979
|
+
...prettierOptions,
|
|
980
|
+
embeddedLanguageFormatting: "off",
|
|
981
|
+
parser: "slidev",
|
|
982
|
+
plugins: [
|
|
983
|
+
"prettier-plugin-slidev"
|
|
984
|
+
]
|
|
985
|
+
}
|
|
986
|
+
]
|
|
987
|
+
}
|
|
988
|
+
});
|
|
989
|
+
}
|
|
990
|
+
}
|
|
991
|
+
if (options.astro) {
|
|
992
|
+
configs.push({
|
|
993
|
+
files: [GLOB_ASTRO],
|
|
994
|
+
languageOptions: {
|
|
995
|
+
parser: parserPlain
|
|
996
|
+
},
|
|
997
|
+
name: "antfu:formatter:astro",
|
|
998
|
+
rules: {
|
|
999
|
+
"format/prettier": [
|
|
1000
|
+
"error",
|
|
1001
|
+
{
|
|
1002
|
+
...prettierOptions,
|
|
1003
|
+
parser: "astro",
|
|
1004
|
+
plugins: [
|
|
1005
|
+
"prettier-plugin-astro"
|
|
1006
|
+
]
|
|
1007
|
+
}
|
|
1008
|
+
]
|
|
1009
|
+
}
|
|
1010
|
+
});
|
|
953
1011
|
}
|
|
954
1012
|
if (options.graphql) {
|
|
955
1013
|
configs.push({
|
|
@@ -973,7 +1031,7 @@ async function formatters(options = {}, stylistic2 = {}) {
|
|
|
973
1031
|
}
|
|
974
1032
|
|
|
975
1033
|
// src/configs/react.ts
|
|
976
|
-
var
|
|
1034
|
+
var import_local_pkg3 = require("local-pkg");
|
|
977
1035
|
var ReactRefreshAllowConstantExportPackages = [
|
|
978
1036
|
"vite"
|
|
979
1037
|
];
|
|
@@ -998,7 +1056,7 @@ async function react(options = {}) {
|
|
|
998
1056
|
interopDefault(import("eslint-plugin-react-refresh"))
|
|
999
1057
|
]);
|
|
1000
1058
|
const isAllowConstantExport = ReactRefreshAllowConstantExportPackages.some(
|
|
1001
|
-
(i) => (0,
|
|
1059
|
+
(i) => (0, import_local_pkg3.isPackageExists)(i)
|
|
1002
1060
|
);
|
|
1003
1061
|
return [
|
|
1004
1062
|
{
|
|
@@ -1355,6 +1413,8 @@ async function svelte(options = {}) {
|
|
|
1355
1413
|
{ args: "after-used", argsIgnorePattern: "^_", vars: "all", varsIgnorePattern: "^(_|\\$\\$Props$)" }
|
|
1356
1414
|
],
|
|
1357
1415
|
...stylistic2 ? {
|
|
1416
|
+
"style/indent": "off",
|
|
1417
|
+
// superseded by svelte/indent
|
|
1358
1418
|
"style/no-trailing-spaces": "off",
|
|
1359
1419
|
// superseded by svelte/no-trailing-spaces
|
|
1360
1420
|
"svelte/derived-has-same-inputs-outputs": "error",
|
|
@@ -1912,6 +1972,55 @@ async function toml(options = {}) {
|
|
|
1912
1972
|
];
|
|
1913
1973
|
}
|
|
1914
1974
|
|
|
1975
|
+
// src/configs/astro.ts
|
|
1976
|
+
async function astro(options = {}) {
|
|
1977
|
+
const {
|
|
1978
|
+
files = [GLOB_ASTRO],
|
|
1979
|
+
overrides = {},
|
|
1980
|
+
stylistic: stylistic2 = true
|
|
1981
|
+
} = options;
|
|
1982
|
+
const [
|
|
1983
|
+
pluginAstro,
|
|
1984
|
+
parserAstro,
|
|
1985
|
+
parserTs
|
|
1986
|
+
] = await Promise.all([
|
|
1987
|
+
interopDefault(import("eslint-plugin-astro")),
|
|
1988
|
+
interopDefault(import("astro-eslint-parser")),
|
|
1989
|
+
interopDefault(import("@typescript-eslint/parser"))
|
|
1990
|
+
]);
|
|
1991
|
+
return [
|
|
1992
|
+
{
|
|
1993
|
+
name: "antfu:astro:setup",
|
|
1994
|
+
plugins: {
|
|
1995
|
+
astro: pluginAstro
|
|
1996
|
+
}
|
|
1997
|
+
},
|
|
1998
|
+
{
|
|
1999
|
+
files,
|
|
2000
|
+
languageOptions: {
|
|
2001
|
+
parser: parserAstro,
|
|
2002
|
+
parserOptions: {
|
|
2003
|
+
extraFileExtensions: [".astro"],
|
|
2004
|
+
parser: parserTs
|
|
2005
|
+
}
|
|
2006
|
+
},
|
|
2007
|
+
name: "antfu:astro:rules",
|
|
2008
|
+
rules: {
|
|
2009
|
+
"astro/no-set-html-directive": "off",
|
|
2010
|
+
"astro/semi": "off",
|
|
2011
|
+
...stylistic2 ? {
|
|
2012
|
+
"style/indent": "off",
|
|
2013
|
+
"style/jsx-closing-tag-location": "off",
|
|
2014
|
+
"style/jsx-indent": "off",
|
|
2015
|
+
"style/jsx-one-expression-per-line": "off",
|
|
2016
|
+
"style/no-multiple-empty-lines": "off"
|
|
2017
|
+
} : {},
|
|
2018
|
+
...overrides
|
|
2019
|
+
}
|
|
2020
|
+
}
|
|
2021
|
+
];
|
|
2022
|
+
}
|
|
2023
|
+
|
|
1915
2024
|
// src/factory.ts
|
|
1916
2025
|
var flatConfigProps = [
|
|
1917
2026
|
"name",
|
|
@@ -1932,14 +2041,15 @@ var VuePackages = [
|
|
|
1932
2041
|
];
|
|
1933
2042
|
async function antfu(options = {}, ...userConfigs) {
|
|
1934
2043
|
const {
|
|
2044
|
+
astro: enableAstro = false,
|
|
1935
2045
|
componentExts = [],
|
|
1936
2046
|
gitignore: enableGitignore = true,
|
|
1937
|
-
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),
|
|
2047
|
+
isInEditor = !!((import_node_process3.default.env.VSCODE_PID || import_node_process3.default.env.VSCODE_CWD || import_node_process3.default.env.JETBRAINS_IDE || import_node_process3.default.env.VIM) && !import_node_process3.default.env.CI),
|
|
1938
2048
|
react: enableReact = false,
|
|
1939
2049
|
svelte: enableSvelte = false,
|
|
1940
|
-
typescript: enableTypeScript = (0,
|
|
2050
|
+
typescript: enableTypeScript = (0, import_local_pkg4.isPackageExists)("typescript"),
|
|
1941
2051
|
unocss: enableUnoCSS = false,
|
|
1942
|
-
vue: enableVue = VuePackages.some((i) => (0,
|
|
2052
|
+
vue: enableVue = VuePackages.some((i) => (0, import_local_pkg4.isPackageExists)(i))
|
|
1943
2053
|
} = options;
|
|
1944
2054
|
const stylisticOptions = options.stylistic === false ? false : typeof options.stylistic === "object" ? options.stylistic : {};
|
|
1945
2055
|
if (stylisticOptions && !("jsx" in stylisticOptions))
|
|
@@ -2019,6 +2129,12 @@ async function antfu(options = {}, ...userConfigs) {
|
|
|
2019
2129
|
overrides: getOverrides(options, "unocss")
|
|
2020
2130
|
}));
|
|
2021
2131
|
}
|
|
2132
|
+
if (enableAstro) {
|
|
2133
|
+
configs.push(astro({
|
|
2134
|
+
overrides: getOverrides(options, "astro"),
|
|
2135
|
+
stylistic: stylisticOptions
|
|
2136
|
+
}));
|
|
2137
|
+
}
|
|
2022
2138
|
if (options.jsonc ?? true) {
|
|
2023
2139
|
configs.push(
|
|
2024
2140
|
jsonc({
|
|
@@ -2086,6 +2202,7 @@ var src_default = antfu;
|
|
|
2086
2202
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2087
2203
|
0 && (module.exports = {
|
|
2088
2204
|
GLOB_ALL_SRC,
|
|
2205
|
+
GLOB_ASTRO,
|
|
2089
2206
|
GLOB_CSS,
|
|
2090
2207
|
GLOB_EXCLUDE,
|
|
2091
2208
|
GLOB_HTML,
|
|
@@ -2112,6 +2229,7 @@ var src_default = antfu;
|
|
|
2112
2229
|
GLOB_YAML,
|
|
2113
2230
|
StylisticConfigDefaults,
|
|
2114
2231
|
antfu,
|
|
2232
|
+
astro,
|
|
2115
2233
|
combine,
|
|
2116
2234
|
comments,
|
|
2117
2235
|
ensurePackages,
|
package/dist/index.d.cts
CHANGED
|
@@ -189,6 +189,20 @@ interface OptionsFormatters {
|
|
|
189
189
|
* By default it's controlled by our own config.
|
|
190
190
|
*/
|
|
191
191
|
dprintOptions?: boolean;
|
|
192
|
+
/**
|
|
193
|
+
* Install the prettier plugin for handle Slidev markdown
|
|
194
|
+
*
|
|
195
|
+
* Only works when `markdown` is enabled with `prettier`.
|
|
196
|
+
*/
|
|
197
|
+
slidev?: boolean | {
|
|
198
|
+
files?: string[];
|
|
199
|
+
};
|
|
200
|
+
/**
|
|
201
|
+
* Enable formatting support for Astro.
|
|
202
|
+
*
|
|
203
|
+
* Currently only support Prettier.
|
|
204
|
+
*/
|
|
205
|
+
astro?: 'prettier' | boolean;
|
|
192
206
|
}
|
|
193
207
|
interface OptionsComponentExts {
|
|
194
208
|
/**
|
|
@@ -303,6 +317,12 @@ interface OptionsConfig extends OptionsComponentExts {
|
|
|
303
317
|
* @default true
|
|
304
318
|
*/
|
|
305
319
|
toml?: boolean | OptionsOverrides;
|
|
320
|
+
/**
|
|
321
|
+
* Enable ASTRO support.
|
|
322
|
+
*
|
|
323
|
+
* @default true
|
|
324
|
+
*/
|
|
325
|
+
astro?: boolean | OptionsOverrides;
|
|
306
326
|
/**
|
|
307
327
|
* Enable linting for **code snippets** in Markdown.
|
|
308
328
|
*
|
|
@@ -449,6 +469,8 @@ declare function yaml(options?: OptionsOverrides & OptionsStylistic & OptionsFil
|
|
|
449
469
|
|
|
450
470
|
declare function toml(options?: OptionsOverrides & OptionsStylistic & OptionsFiles): Promise<FlatConfigItem[]>;
|
|
451
471
|
|
|
472
|
+
declare function astro(options?: OptionsOverrides & OptionsStylistic & OptionsFiles): Promise<FlatConfigItem[]>;
|
|
473
|
+
|
|
452
474
|
declare const GLOB_SRC_EXT = "?([cm])[jt]s?(x)";
|
|
453
475
|
declare const GLOB_SRC = "**/*.?([cm])[jt]s?(x)";
|
|
454
476
|
declare const GLOB_JS = "**/*.?([cm])js";
|
|
@@ -470,6 +492,7 @@ declare const GLOB_VUE = "**/*.vue";
|
|
|
470
492
|
declare const GLOB_YAML = "**/*.y?(a)ml";
|
|
471
493
|
declare const GLOB_TOML = "**/*.toml";
|
|
472
494
|
declare const GLOB_HTML = "**/*.htm?(l)";
|
|
495
|
+
declare const GLOB_ASTRO = "**/*.astro";
|
|
473
496
|
declare const GLOB_MARKDOWN_CODE = "**/*.md/**/*.?([cm])[jt]s?(x)";
|
|
474
497
|
declare const GLOB_TESTS: string[];
|
|
475
498
|
declare const GLOB_ALL_SRC: string[];
|
|
@@ -511,6 +534,6 @@ declare function toArray<T>(value: T | T[]): T[];
|
|
|
511
534
|
declare function interopDefault<T>(m: Awaitable<T>): Promise<T extends {
|
|
512
535
|
default: infer U;
|
|
513
536
|
} ? U : T>;
|
|
514
|
-
declare function ensurePackages(packages: string[]): Promise<void>;
|
|
537
|
+
declare function ensurePackages(packages: (string | undefined)[]): Promise<void>;
|
|
515
538
|
|
|
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 };
|
|
539
|
+
export { type Awaitable, type FlatConfigItem, GLOB_ALL_SRC, GLOB_ASTRO, 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, astro, 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
|
@@ -189,6 +189,20 @@ interface OptionsFormatters {
|
|
|
189
189
|
* By default it's controlled by our own config.
|
|
190
190
|
*/
|
|
191
191
|
dprintOptions?: boolean;
|
|
192
|
+
/**
|
|
193
|
+
* Install the prettier plugin for handle Slidev markdown
|
|
194
|
+
*
|
|
195
|
+
* Only works when `markdown` is enabled with `prettier`.
|
|
196
|
+
*/
|
|
197
|
+
slidev?: boolean | {
|
|
198
|
+
files?: string[];
|
|
199
|
+
};
|
|
200
|
+
/**
|
|
201
|
+
* Enable formatting support for Astro.
|
|
202
|
+
*
|
|
203
|
+
* Currently only support Prettier.
|
|
204
|
+
*/
|
|
205
|
+
astro?: 'prettier' | boolean;
|
|
192
206
|
}
|
|
193
207
|
interface OptionsComponentExts {
|
|
194
208
|
/**
|
|
@@ -303,6 +317,12 @@ interface OptionsConfig extends OptionsComponentExts {
|
|
|
303
317
|
* @default true
|
|
304
318
|
*/
|
|
305
319
|
toml?: boolean | OptionsOverrides;
|
|
320
|
+
/**
|
|
321
|
+
* Enable ASTRO support.
|
|
322
|
+
*
|
|
323
|
+
* @default true
|
|
324
|
+
*/
|
|
325
|
+
astro?: boolean | OptionsOverrides;
|
|
306
326
|
/**
|
|
307
327
|
* Enable linting for **code snippets** in Markdown.
|
|
308
328
|
*
|
|
@@ -449,6 +469,8 @@ declare function yaml(options?: OptionsOverrides & OptionsStylistic & OptionsFil
|
|
|
449
469
|
|
|
450
470
|
declare function toml(options?: OptionsOverrides & OptionsStylistic & OptionsFiles): Promise<FlatConfigItem[]>;
|
|
451
471
|
|
|
472
|
+
declare function astro(options?: OptionsOverrides & OptionsStylistic & OptionsFiles): Promise<FlatConfigItem[]>;
|
|
473
|
+
|
|
452
474
|
declare const GLOB_SRC_EXT = "?([cm])[jt]s?(x)";
|
|
453
475
|
declare const GLOB_SRC = "**/*.?([cm])[jt]s?(x)";
|
|
454
476
|
declare const GLOB_JS = "**/*.?([cm])js";
|
|
@@ -470,6 +492,7 @@ declare const GLOB_VUE = "**/*.vue";
|
|
|
470
492
|
declare const GLOB_YAML = "**/*.y?(a)ml";
|
|
471
493
|
declare const GLOB_TOML = "**/*.toml";
|
|
472
494
|
declare const GLOB_HTML = "**/*.htm?(l)";
|
|
495
|
+
declare const GLOB_ASTRO = "**/*.astro";
|
|
473
496
|
declare const GLOB_MARKDOWN_CODE = "**/*.md/**/*.?([cm])[jt]s?(x)";
|
|
474
497
|
declare const GLOB_TESTS: string[];
|
|
475
498
|
declare const GLOB_ALL_SRC: string[];
|
|
@@ -511,6 +534,6 @@ declare function toArray<T>(value: T | T[]): T[];
|
|
|
511
534
|
declare function interopDefault<T>(m: Awaitable<T>): Promise<T extends {
|
|
512
535
|
default: infer U;
|
|
513
536
|
} ? U : T>;
|
|
514
|
-
declare function ensurePackages(packages: string[]): Promise<void>;
|
|
537
|
+
declare function ensurePackages(packages: (string | undefined)[]): Promise<void>;
|
|
515
538
|
|
|
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 };
|
|
539
|
+
export { type Awaitable, type FlatConfigItem, GLOB_ALL_SRC, GLOB_ASTRO, 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, astro, 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
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// src/factory.ts
|
|
2
2
|
import process3 from "process";
|
|
3
3
|
import fs from "fs";
|
|
4
|
-
import { isPackageExists as
|
|
4
|
+
import { isPackageExists as isPackageExists4 } from "local-pkg";
|
|
5
5
|
|
|
6
6
|
// src/plugins.ts
|
|
7
7
|
import { default as default2 } from "eslint-plugin-antfu";
|
|
@@ -52,6 +52,7 @@ var GLOB_VUE = "**/*.vue";
|
|
|
52
52
|
var GLOB_YAML = "**/*.y?(a)ml";
|
|
53
53
|
var GLOB_TOML = "**/*.toml";
|
|
54
54
|
var GLOB_HTML = "**/*.htm?(l)";
|
|
55
|
+
var GLOB_ASTRO = "**/*.astro";
|
|
55
56
|
var GLOB_MARKDOWN_CODE = `${GLOB_MARKDOWN}/${GLOB_SRC}`;
|
|
56
57
|
var GLOB_TESTS = [
|
|
57
58
|
`**/__tests__/**/*.${GLOB_SRC_EXT}`,
|
|
@@ -412,7 +413,7 @@ async function interopDefault(m) {
|
|
|
412
413
|
async function ensurePackages(packages) {
|
|
413
414
|
if (process.env.CI || process.stdout.isTTY === false)
|
|
414
415
|
return;
|
|
415
|
-
const nonExistingPackages = packages.filter((i) => !isPackageExists(i));
|
|
416
|
+
const nonExistingPackages = packages.filter((i) => i && !isPackageExists(i));
|
|
416
417
|
if (nonExistingPackages.length === 0)
|
|
417
418
|
return;
|
|
418
419
|
const { default: prompts } = await import("prompts");
|
|
@@ -669,6 +670,9 @@ async function perfectionist() {
|
|
|
669
670
|
];
|
|
670
671
|
}
|
|
671
672
|
|
|
673
|
+
// src/configs/formatters.ts
|
|
674
|
+
import { isPackageExists as isPackageExists2 } from "local-pkg";
|
|
675
|
+
|
|
672
676
|
// src/configs/stylistic.ts
|
|
673
677
|
var StylisticConfigDefaults = {
|
|
674
678
|
indent: 2,
|
|
@@ -717,17 +721,23 @@ async function stylistic(options = {}) {
|
|
|
717
721
|
|
|
718
722
|
// src/configs/formatters.ts
|
|
719
723
|
async function formatters(options = {}, stylistic2 = {}) {
|
|
720
|
-
await ensurePackages([
|
|
721
|
-
"eslint-plugin-format"
|
|
722
|
-
]);
|
|
723
724
|
if (options === true) {
|
|
724
725
|
options = {
|
|
726
|
+
astro: isPackageExists2("astro"),
|
|
725
727
|
css: true,
|
|
726
728
|
graphql: true,
|
|
727
729
|
html: true,
|
|
728
|
-
markdown: true
|
|
730
|
+
markdown: true,
|
|
731
|
+
slidev: isPackageExists2("@slidev/cli")
|
|
729
732
|
};
|
|
730
733
|
}
|
|
734
|
+
await ensurePackages([
|
|
735
|
+
"eslint-plugin-format",
|
|
736
|
+
options.markdown && options.slidev ? "prettier-plugin-slidev" : void 0,
|
|
737
|
+
options.astro ? "prettier-plugin-astro" : void 0
|
|
738
|
+
]);
|
|
739
|
+
if (options.slidev && options.markdown !== true && options.markdown !== "prettier")
|
|
740
|
+
throw new Error("`slidev` option only works when `markdown` is enabled with `prettier`");
|
|
731
741
|
const {
|
|
732
742
|
indent,
|
|
733
743
|
quotes,
|
|
@@ -836,8 +846,10 @@ async function formatters(options = {}, stylistic2 = {}) {
|
|
|
836
846
|
}
|
|
837
847
|
if (options.markdown) {
|
|
838
848
|
const formater = options.markdown === true ? "prettier" : options.markdown;
|
|
849
|
+
const GLOB_SLIDEV = !options.slidev ? [] : options.slidev === true ? ["**/slides.md"] : options.slidev.files;
|
|
839
850
|
configs.push({
|
|
840
851
|
files: [GLOB_MARKDOWN],
|
|
852
|
+
ignores: GLOB_SLIDEV,
|
|
841
853
|
languageOptions: {
|
|
842
854
|
parser: parserPlain
|
|
843
855
|
},
|
|
@@ -857,6 +869,50 @@ async function formatters(options = {}, stylistic2 = {}) {
|
|
|
857
869
|
]
|
|
858
870
|
}
|
|
859
871
|
});
|
|
872
|
+
if (options.slidev) {
|
|
873
|
+
configs.push({
|
|
874
|
+
files: GLOB_SLIDEV,
|
|
875
|
+
languageOptions: {
|
|
876
|
+
parser: parserPlain
|
|
877
|
+
},
|
|
878
|
+
name: "antfu:formatter:slidev",
|
|
879
|
+
rules: {
|
|
880
|
+
"format/prettier": [
|
|
881
|
+
"error",
|
|
882
|
+
{
|
|
883
|
+
printWidth: 120,
|
|
884
|
+
...prettierOptions,
|
|
885
|
+
embeddedLanguageFormatting: "off",
|
|
886
|
+
parser: "slidev",
|
|
887
|
+
plugins: [
|
|
888
|
+
"prettier-plugin-slidev"
|
|
889
|
+
]
|
|
890
|
+
}
|
|
891
|
+
]
|
|
892
|
+
}
|
|
893
|
+
});
|
|
894
|
+
}
|
|
895
|
+
}
|
|
896
|
+
if (options.astro) {
|
|
897
|
+
configs.push({
|
|
898
|
+
files: [GLOB_ASTRO],
|
|
899
|
+
languageOptions: {
|
|
900
|
+
parser: parserPlain
|
|
901
|
+
},
|
|
902
|
+
name: "antfu:formatter:astro",
|
|
903
|
+
rules: {
|
|
904
|
+
"format/prettier": [
|
|
905
|
+
"error",
|
|
906
|
+
{
|
|
907
|
+
...prettierOptions,
|
|
908
|
+
parser: "astro",
|
|
909
|
+
plugins: [
|
|
910
|
+
"prettier-plugin-astro"
|
|
911
|
+
]
|
|
912
|
+
}
|
|
913
|
+
]
|
|
914
|
+
}
|
|
915
|
+
});
|
|
860
916
|
}
|
|
861
917
|
if (options.graphql) {
|
|
862
918
|
configs.push({
|
|
@@ -880,7 +936,7 @@ async function formatters(options = {}, stylistic2 = {}) {
|
|
|
880
936
|
}
|
|
881
937
|
|
|
882
938
|
// src/configs/react.ts
|
|
883
|
-
import { isPackageExists as
|
|
939
|
+
import { isPackageExists as isPackageExists3 } from "local-pkg";
|
|
884
940
|
var ReactRefreshAllowConstantExportPackages = [
|
|
885
941
|
"vite"
|
|
886
942
|
];
|
|
@@ -905,7 +961,7 @@ async function react(options = {}) {
|
|
|
905
961
|
interopDefault(import("eslint-plugin-react-refresh"))
|
|
906
962
|
]);
|
|
907
963
|
const isAllowConstantExport = ReactRefreshAllowConstantExportPackages.some(
|
|
908
|
-
(i) =>
|
|
964
|
+
(i) => isPackageExists3(i)
|
|
909
965
|
);
|
|
910
966
|
return [
|
|
911
967
|
{
|
|
@@ -1262,6 +1318,8 @@ async function svelte(options = {}) {
|
|
|
1262
1318
|
{ args: "after-used", argsIgnorePattern: "^_", vars: "all", varsIgnorePattern: "^(_|\\$\\$Props$)" }
|
|
1263
1319
|
],
|
|
1264
1320
|
...stylistic2 ? {
|
|
1321
|
+
"style/indent": "off",
|
|
1322
|
+
// superseded by svelte/indent
|
|
1265
1323
|
"style/no-trailing-spaces": "off",
|
|
1266
1324
|
// superseded by svelte/no-trailing-spaces
|
|
1267
1325
|
"svelte/derived-has-same-inputs-outputs": "error",
|
|
@@ -1819,6 +1877,55 @@ async function toml(options = {}) {
|
|
|
1819
1877
|
];
|
|
1820
1878
|
}
|
|
1821
1879
|
|
|
1880
|
+
// src/configs/astro.ts
|
|
1881
|
+
async function astro(options = {}) {
|
|
1882
|
+
const {
|
|
1883
|
+
files = [GLOB_ASTRO],
|
|
1884
|
+
overrides = {},
|
|
1885
|
+
stylistic: stylistic2 = true
|
|
1886
|
+
} = options;
|
|
1887
|
+
const [
|
|
1888
|
+
pluginAstro,
|
|
1889
|
+
parserAstro,
|
|
1890
|
+
parserTs
|
|
1891
|
+
] = await Promise.all([
|
|
1892
|
+
interopDefault(import("eslint-plugin-astro")),
|
|
1893
|
+
interopDefault(import("astro-eslint-parser")),
|
|
1894
|
+
interopDefault(import("@typescript-eslint/parser"))
|
|
1895
|
+
]);
|
|
1896
|
+
return [
|
|
1897
|
+
{
|
|
1898
|
+
name: "antfu:astro:setup",
|
|
1899
|
+
plugins: {
|
|
1900
|
+
astro: pluginAstro
|
|
1901
|
+
}
|
|
1902
|
+
},
|
|
1903
|
+
{
|
|
1904
|
+
files,
|
|
1905
|
+
languageOptions: {
|
|
1906
|
+
parser: parserAstro,
|
|
1907
|
+
parserOptions: {
|
|
1908
|
+
extraFileExtensions: [".astro"],
|
|
1909
|
+
parser: parserTs
|
|
1910
|
+
}
|
|
1911
|
+
},
|
|
1912
|
+
name: "antfu:astro:rules",
|
|
1913
|
+
rules: {
|
|
1914
|
+
"astro/no-set-html-directive": "off",
|
|
1915
|
+
"astro/semi": "off",
|
|
1916
|
+
...stylistic2 ? {
|
|
1917
|
+
"style/indent": "off",
|
|
1918
|
+
"style/jsx-closing-tag-location": "off",
|
|
1919
|
+
"style/jsx-indent": "off",
|
|
1920
|
+
"style/jsx-one-expression-per-line": "off",
|
|
1921
|
+
"style/no-multiple-empty-lines": "off"
|
|
1922
|
+
} : {},
|
|
1923
|
+
...overrides
|
|
1924
|
+
}
|
|
1925
|
+
}
|
|
1926
|
+
];
|
|
1927
|
+
}
|
|
1928
|
+
|
|
1822
1929
|
// src/factory.ts
|
|
1823
1930
|
var flatConfigProps = [
|
|
1824
1931
|
"name",
|
|
@@ -1839,14 +1946,15 @@ var VuePackages = [
|
|
|
1839
1946
|
];
|
|
1840
1947
|
async function antfu(options = {}, ...userConfigs) {
|
|
1841
1948
|
const {
|
|
1949
|
+
astro: enableAstro = false,
|
|
1842
1950
|
componentExts = [],
|
|
1843
1951
|
gitignore: enableGitignore = true,
|
|
1844
|
-
isInEditor = !!((process3.env.VSCODE_PID || process3.env.JETBRAINS_IDE || process3.env.VIM) && !process3.env.CI),
|
|
1952
|
+
isInEditor = !!((process3.env.VSCODE_PID || process3.env.VSCODE_CWD || process3.env.JETBRAINS_IDE || process3.env.VIM) && !process3.env.CI),
|
|
1845
1953
|
react: enableReact = false,
|
|
1846
1954
|
svelte: enableSvelte = false,
|
|
1847
|
-
typescript: enableTypeScript =
|
|
1955
|
+
typescript: enableTypeScript = isPackageExists4("typescript"),
|
|
1848
1956
|
unocss: enableUnoCSS = false,
|
|
1849
|
-
vue: enableVue = VuePackages.some((i) =>
|
|
1957
|
+
vue: enableVue = VuePackages.some((i) => isPackageExists4(i))
|
|
1850
1958
|
} = options;
|
|
1851
1959
|
const stylisticOptions = options.stylistic === false ? false : typeof options.stylistic === "object" ? options.stylistic : {};
|
|
1852
1960
|
if (stylisticOptions && !("jsx" in stylisticOptions))
|
|
@@ -1926,6 +2034,12 @@ async function antfu(options = {}, ...userConfigs) {
|
|
|
1926
2034
|
overrides: getOverrides(options, "unocss")
|
|
1927
2035
|
}));
|
|
1928
2036
|
}
|
|
2037
|
+
if (enableAstro) {
|
|
2038
|
+
configs.push(astro({
|
|
2039
|
+
overrides: getOverrides(options, "astro"),
|
|
2040
|
+
stylistic: stylisticOptions
|
|
2041
|
+
}));
|
|
2042
|
+
}
|
|
1929
2043
|
if (options.jsonc ?? true) {
|
|
1930
2044
|
configs.push(
|
|
1931
2045
|
jsonc({
|
|
@@ -1992,6 +2106,7 @@ function getOverrides(options, key) {
|
|
|
1992
2106
|
var src_default = antfu;
|
|
1993
2107
|
export {
|
|
1994
2108
|
GLOB_ALL_SRC,
|
|
2109
|
+
GLOB_ASTRO,
|
|
1995
2110
|
GLOB_CSS,
|
|
1996
2111
|
GLOB_EXCLUDE,
|
|
1997
2112
|
GLOB_HTML,
|
|
@@ -2018,6 +2133,7 @@ export {
|
|
|
2018
2133
|
GLOB_YAML,
|
|
2019
2134
|
StylisticConfigDefaults,
|
|
2020
2135
|
antfu,
|
|
2136
|
+
astro,
|
|
2021
2137
|
combine,
|
|
2022
2138
|
comments,
|
|
2023
2139
|
src_default as default,
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antfu/eslint-config",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.
|
|
5
|
-
"packageManager": "pnpm@8.15.
|
|
4
|
+
"version": "2.8.0",
|
|
5
|
+
"packageManager": "pnpm@8.15.4",
|
|
6
6
|
"description": "Anthony's ESLint config",
|
|
7
7
|
"author": "Anthony Fu <anthonyfu117@hotmail.com> (https://github.com/antfu/)",
|
|
8
8
|
"license": "MIT",
|
|
@@ -26,18 +26,28 @@
|
|
|
26
26
|
],
|
|
27
27
|
"peerDependencies": {
|
|
28
28
|
"@unocss/eslint-plugin": ">=0.50.0",
|
|
29
|
+
"astro-eslint-parser": "^0.16.3",
|
|
29
30
|
"eslint": ">=8.40.0",
|
|
31
|
+
"eslint-plugin-astro": "^0.31.4",
|
|
30
32
|
"eslint-plugin-format": ">=0.1.0",
|
|
31
33
|
"eslint-plugin-react": "^7.33.2",
|
|
32
34
|
"eslint-plugin-react-hooks": "^4.6.0",
|
|
33
35
|
"eslint-plugin-react-refresh": "^0.4.4",
|
|
34
36
|
"eslint-plugin-svelte": "^2.34.1",
|
|
37
|
+
"prettier-plugin-astro": "^0.13.0",
|
|
38
|
+
"prettier-plugin-slidev": "^1.0.5",
|
|
35
39
|
"svelte-eslint-parser": "^0.33.1"
|
|
36
40
|
},
|
|
37
41
|
"peerDependenciesMeta": {
|
|
38
42
|
"@unocss/eslint-plugin": {
|
|
39
43
|
"optional": true
|
|
40
44
|
},
|
|
45
|
+
"astro-eslint-parser": {
|
|
46
|
+
"optional": true
|
|
47
|
+
},
|
|
48
|
+
"eslint-plugin-astro": {
|
|
49
|
+
"optional": true
|
|
50
|
+
},
|
|
41
51
|
"eslint-plugin-format": {
|
|
42
52
|
"optional": true
|
|
43
53
|
},
|
|
@@ -53,6 +63,12 @@
|
|
|
53
63
|
"eslint-plugin-svelte": {
|
|
54
64
|
"optional": true
|
|
55
65
|
},
|
|
66
|
+
"prettier-plugin-astro": {
|
|
67
|
+
"optional": true
|
|
68
|
+
},
|
|
69
|
+
"prettier-plugin-slidev": {
|
|
70
|
+
"optional": true
|
|
71
|
+
},
|
|
56
72
|
"svelte-eslint-parser": {
|
|
57
73
|
"optional": true
|
|
58
74
|
}
|
|
@@ -61,30 +77,30 @@
|
|
|
61
77
|
"@antfu/eslint-define-config": "^1.23.0-2",
|
|
62
78
|
"@antfu/install-pkg": "^0.3.1",
|
|
63
79
|
"@eslint-types/jsdoc": "46.8.2-1",
|
|
64
|
-
"@eslint-types/typescript-eslint": "^
|
|
65
|
-
"@eslint-types/unicorn": "^
|
|
66
|
-
"@stylistic/eslint-plugin": "^1.
|
|
67
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
68
|
-
"@typescript-eslint/parser": "^
|
|
69
|
-
"eslint-config-flat-gitignore": "^0.1.
|
|
80
|
+
"@eslint-types/typescript-eslint": "^7.0.2",
|
|
81
|
+
"@eslint-types/unicorn": "^51.0.1",
|
|
82
|
+
"@stylistic/eslint-plugin": "^1.6.3",
|
|
83
|
+
"@typescript-eslint/eslint-plugin": "^7.1.1",
|
|
84
|
+
"@typescript-eslint/parser": "^7.1.1",
|
|
85
|
+
"eslint-config-flat-gitignore": "^0.1.3",
|
|
70
86
|
"eslint-merge-processors": "^0.1.0",
|
|
71
87
|
"eslint-plugin-antfu": "^2.1.2",
|
|
72
88
|
"eslint-plugin-eslint-comments": "^3.2.0",
|
|
73
89
|
"eslint-plugin-i": "^2.29.1",
|
|
74
|
-
"eslint-plugin-jsdoc": "^48.0
|
|
90
|
+
"eslint-plugin-jsdoc": "^48.2.0",
|
|
75
91
|
"eslint-plugin-jsonc": "^2.13.0",
|
|
76
92
|
"eslint-plugin-markdown": "^3.0.1",
|
|
77
93
|
"eslint-plugin-n": "^16.6.2",
|
|
78
94
|
"eslint-plugin-no-only-tests": "^3.1.0",
|
|
79
95
|
"eslint-plugin-perfectionist": "^2.5.0",
|
|
80
96
|
"eslint-plugin-toml": "^0.9.2",
|
|
81
|
-
"eslint-plugin-unicorn": "^
|
|
82
|
-
"eslint-plugin-unused-imports": "^3.
|
|
83
|
-
"eslint-plugin-vitest": "^0.3.
|
|
84
|
-
"eslint-plugin-vue": "^9.
|
|
97
|
+
"eslint-plugin-unicorn": "^51.0.1",
|
|
98
|
+
"eslint-plugin-unused-imports": "^3.1.0",
|
|
99
|
+
"eslint-plugin-vitest": "^0.3.22",
|
|
100
|
+
"eslint-plugin-vue": "^9.22.0",
|
|
85
101
|
"eslint-plugin-yml": "^1.12.2",
|
|
86
102
|
"eslint-processor-vue-blocks": "^0.1.1",
|
|
87
|
-
"globals": "^
|
|
103
|
+
"globals": "^14.0.0",
|
|
88
104
|
"jsonc-eslint-parser": "^2.4.0",
|
|
89
105
|
"local-pkg": "^0.5.0",
|
|
90
106
|
"parse-gitignore": "^2.0.0",
|
|
@@ -98,36 +114,40 @@
|
|
|
98
114
|
"devDependencies": {
|
|
99
115
|
"@antfu/eslint-plugin-prettier": "^5.0.1-1",
|
|
100
116
|
"@antfu/ni": "^0.21.12",
|
|
101
|
-
"@stylistic/eslint-plugin-migrate": "^1.
|
|
102
|
-
"@types/eslint": "^8.56.
|
|
117
|
+
"@stylistic/eslint-plugin-migrate": "^1.6.3",
|
|
118
|
+
"@types/eslint": "^8.56.5",
|
|
103
119
|
"@types/fs-extra": "^11.0.4",
|
|
104
|
-
"@types/node": "^20.11.
|
|
120
|
+
"@types/node": "^20.11.24",
|
|
105
121
|
"@types/prompts": "^2.4.9",
|
|
106
122
|
"@types/yargs": "^17.0.32",
|
|
107
|
-
"@unocss/eslint-plugin": "^0.58.
|
|
108
|
-
"
|
|
109
|
-
"
|
|
123
|
+
"@unocss/eslint-plugin": "^0.58.5",
|
|
124
|
+
"astro-eslint-parser": "^0.16.3",
|
|
125
|
+
"bumpp": "^9.4.0",
|
|
126
|
+
"eslint": "npm:eslint-ts-patch@^8.57.0-0",
|
|
110
127
|
"eslint-flat-config-viewer": "^0.1.11",
|
|
128
|
+
"eslint-plugin-astro": "^0.31.4",
|
|
111
129
|
"eslint-plugin-format": "^0.1.0",
|
|
112
|
-
"eslint-plugin-react": "^7.
|
|
130
|
+
"eslint-plugin-react": "^7.34.0",
|
|
113
131
|
"eslint-plugin-react-hooks": "^4.6.0",
|
|
114
132
|
"eslint-plugin-react-refresh": "^0.4.5",
|
|
115
133
|
"eslint-plugin-svelte": "^2.35.1",
|
|
116
|
-
"eslint-ts-patch": "^8.
|
|
117
|
-
"esno": "^4.
|
|
134
|
+
"eslint-ts-patch": "^8.57.0-0",
|
|
135
|
+
"esno": "^4.7.0",
|
|
118
136
|
"execa": "^8.0.1",
|
|
119
137
|
"fast-glob": "^3.3.2",
|
|
120
138
|
"fs-extra": "^11.2.0",
|
|
121
|
-
"lint-staged": "^15.2.
|
|
139
|
+
"lint-staged": "^15.2.2",
|
|
140
|
+
"prettier-plugin-astro": "^0.13.0",
|
|
141
|
+
"prettier-plugin-slidev": "^1.0.5",
|
|
122
142
|
"rimraf": "^5.0.5",
|
|
123
|
-
"simple-git-hooks": "^2.
|
|
124
|
-
"svelte": "^4.2.
|
|
143
|
+
"simple-git-hooks": "^2.10.0",
|
|
144
|
+
"svelte": "^4.2.12",
|
|
125
145
|
"svelte-eslint-parser": "^0.33.1",
|
|
126
|
-
"tsup": "^8.0.
|
|
146
|
+
"tsup": "^8.0.2",
|
|
127
147
|
"typescript": "^5.3.3",
|
|
128
|
-
"vitest": "^1.
|
|
129
|
-
"vue": "^3.4.
|
|
130
|
-
"@antfu/eslint-config": "2.
|
|
148
|
+
"vitest": "^1.3.1",
|
|
149
|
+
"vue": "^3.4.21",
|
|
150
|
+
"@antfu/eslint-config": "2.8.0"
|
|
131
151
|
},
|
|
132
152
|
"simple-git-hooks": {
|
|
133
153
|
"pre-commit": "pnpm lint-staged"
|