@antfu/eslint-config 2.2.1 → 2.3.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 +40 -20
- package/dist/cli.cjs +7 -6
- package/dist/cli.js +7 -6
- package/dist/index.cjs +160 -57
- package/dist/index.d.cts +28 -23
- package/dist/index.d.ts +28 -23
- package/dist/index.js +159 -56
- package/package.json +15 -15
package/README.md
CHANGED
|
@@ -120,7 +120,6 @@ Add the following settings to your `.vscode/settings.json`:
|
|
|
120
120
|
// Silent the stylistic rules in you IDE, but still auto fix them
|
|
121
121
|
"eslint.rules.customizations": [
|
|
122
122
|
{ "rule": "style/*", "severity": "off" },
|
|
123
|
-
{ "rule": "prettier/*", "severity": "off" },
|
|
124
123
|
{ "rule": "*-indent", "severity": "off" },
|
|
125
124
|
{ "rule": "*-spacing", "severity": "off" },
|
|
126
125
|
{ "rule": "*-spaces", "severity": "off" },
|
|
@@ -268,17 +267,17 @@ Check out the [configs](https://github.com/antfu/eslint-config/blob/main/src/con
|
|
|
268
267
|
|
|
269
268
|
### Plugins Renaming
|
|
270
269
|
|
|
271
|
-
Since flat config requires us to explicitly provide the plugin names (instead of mandatory convention from npm package name), we renamed some plugins to make overall scope more consistent and easier to write.
|
|
270
|
+
Since flat config requires us to explicitly provide the plugin names (instead of the mandatory convention from npm package name), we renamed some plugins to make the overall scope more consistent and easier to write.
|
|
272
271
|
|
|
273
|
-
| New Prefix | Original Prefix
|
|
274
|
-
|
|
|
275
|
-
| `import/*` | `i/*`
|
|
276
|
-
| `node/*`
|
|
277
|
-
| `yaml/*`
|
|
278
|
-
| `ts/*`
|
|
279
|
-
| `style/*`
|
|
280
|
-
| `test/*`
|
|
281
|
-
| `test/*`
|
|
272
|
+
| New Prefix | Original Prefix | Source Plugin |
|
|
273
|
+
| ---------- | ---------------------- | ------------------------------------------------------------------------------------------ |
|
|
274
|
+
| `import/*` | `i/*` | [eslint-plugin-i](https://github.com/un-es/eslint-plugin-i) |
|
|
275
|
+
| `node/*` | `n/*` | [eslint-plugin-n](https://github.com/eslint-community/eslint-plugin-n) |
|
|
276
|
+
| `yaml/*` | `yml/*` | [eslint-plugin-yml](https://github.com/ota-meshi/eslint-plugin-yml) |
|
|
277
|
+
| `ts/*` | `@typescript-eslint/*` | [@typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/typescript-eslint) |
|
|
278
|
+
| `style/*` | `@stylistic/*` | [@stylistic/eslint-plugin](https://github.com/eslint-stylistic/eslint-stylistic) |
|
|
279
|
+
| `test/*` | `vitest/*` | [eslint-plugin-vitest](https://github.com/veritem/eslint-plugin-vitest) |
|
|
280
|
+
| `test/*` | `no-only-tests/*` | [eslint-plugin-no-only-tests](https://github.com/levibuzolic/eslint-plugin-no-only-tests) |
|
|
282
281
|
|
|
283
282
|
When you want to override rules, or disable them inline, you need to update to the new prefix:
|
|
284
283
|
|
|
@@ -338,9 +337,36 @@ export default antfu({
|
|
|
338
337
|
|
|
339
338
|
We provide some optional configs for specific use cases, that we don't include their dependencies by default.
|
|
340
339
|
|
|
340
|
+
#### Formatters
|
|
341
|
+
|
|
342
|
+
> [!WARNING]
|
|
343
|
+
> Experimental feature, changes might not follow semver.
|
|
344
|
+
|
|
345
|
+
Use external formatters to format files that ESLint cannot handle yet (`.css`, `.html`, etc). Powered by [`eslint-plugin-format`](https://github.com/antfu/eslint-plugin-format).
|
|
346
|
+
|
|
347
|
+
```js
|
|
348
|
+
// eslint.config.js
|
|
349
|
+
import antfu from '@antfu/eslint-config'
|
|
350
|
+
|
|
351
|
+
export default antfu({
|
|
352
|
+
formatters: {
|
|
353
|
+
css: true, // by default use Prettier
|
|
354
|
+
html: true, // by default use Prettier
|
|
355
|
+
toml: 'dprint', // use dprint for TOML
|
|
356
|
+
markdown: 'prettier' // use prettier for markdown
|
|
357
|
+
}
|
|
358
|
+
})
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
Running `npx eslint` should prompt you to install the required dependencies, otherwise, you can install them manually:
|
|
362
|
+
|
|
363
|
+
```bash
|
|
364
|
+
npm i -D eslint-plugin-format
|
|
365
|
+
```
|
|
366
|
+
|
|
341
367
|
#### React
|
|
342
368
|
|
|
343
|
-
To enable React support
|
|
369
|
+
To enable React support, you need to explicitly turn it on:
|
|
344
370
|
|
|
345
371
|
```js
|
|
346
372
|
// eslint.config.js
|
|
@@ -384,7 +410,7 @@ This config also provides some optional plugins/rules for extended usages.
|
|
|
384
410
|
|
|
385
411
|
This plugin [`eslint-plugin-perfectionist`](https://github.com/azat-io/eslint-plugin-perfectionist) allows you to sorted object keys, imports, etc, with auto-fix.
|
|
386
412
|
|
|
387
|
-
The plugin is installed but no rules are enabled by default.
|
|
413
|
+
The plugin is installed but no rules are enabled by default.
|
|
388
414
|
|
|
389
415
|
It's recommended to opt-in on each file individually using [configuration comments](https://eslint.org/docs/latest/use/configure/rules#using-configuration-comments-1).
|
|
390
416
|
|
|
@@ -477,15 +503,9 @@ If you enjoy this code style, and would like to mention it in your project, here
|
|
|
477
503
|
|
|
478
504
|
[Why I don't use Prettier](https://antfu.me/posts/why-not-prettier)
|
|
479
505
|
|
|
480
|
-
Well, on the other hand, you can [use still Prettier to handle CSS and HTML formatting](#prettier), which is not yet supported by ESLint.
|
|
481
|
-
|
|
482
506
|
### How to format CSS?
|
|
483
507
|
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
Yes, we do now! See [Prettier](#prettier) section for more details.
|
|
487
|
-
|
|
488
|
-
For better linting, we recommend trying [stylelint](https://stylelint.io/).
|
|
508
|
+
This config does NOT lint CSS. I personally use [UnoCSS](https://github.com/unocss/unocss) so I don't write CSS. For better linting, we recommend trying [stylelint](https://stylelint.io/).
|
|
489
509
|
|
|
490
510
|
### I prefer XXX...
|
|
491
511
|
|
package/dist/cli.cjs
CHANGED
|
@@ -46,7 +46,7 @@ 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.3.0";
|
|
50
50
|
var devDependencies = {
|
|
51
51
|
"@antfu/eslint-config": "workspace:*",
|
|
52
52
|
"@antfu/eslint-plugin-prettier": "^5.0.1-1",
|
|
@@ -54,21 +54,22 @@ var devDependencies = {
|
|
|
54
54
|
"@stylistic/eslint-plugin-migrate": "^1.4.1",
|
|
55
55
|
"@types/eslint": "^8.44.8",
|
|
56
56
|
"@types/fs-extra": "^11.0.4",
|
|
57
|
-
"@types/node": "^20.10.
|
|
57
|
+
"@types/node": "^20.10.3",
|
|
58
58
|
"@types/prompts": "^2.4.9",
|
|
59
59
|
"@types/yargs": "^17.0.32",
|
|
60
|
-
"@unocss/eslint-plugin": "^0.
|
|
60
|
+
"@unocss/eslint-plugin": "^0.58.0",
|
|
61
61
|
bumpp: "^9.2.0",
|
|
62
|
-
eslint: "^8.
|
|
62
|
+
eslint: "^8.55.0",
|
|
63
63
|
"eslint-flat-config-viewer": "^0.1.3",
|
|
64
|
+
"eslint-plugin-format": "^0.0.1",
|
|
64
65
|
"eslint-plugin-react": "^7.33.2",
|
|
65
66
|
"eslint-plugin-react-hooks": "^4.6.0",
|
|
66
|
-
"eslint-plugin-react-refresh": "^0.4.
|
|
67
|
+
"eslint-plugin-react-refresh": "^0.4.5",
|
|
67
68
|
esno: "^4.0.0",
|
|
68
69
|
execa: "^8.0.1",
|
|
69
70
|
"fast-glob": "^3.3.2",
|
|
70
71
|
"fs-extra": "^11.2.0",
|
|
71
|
-
"lint-staged": "^15.
|
|
72
|
+
"lint-staged": "^15.2.0",
|
|
72
73
|
rimraf: "^5.0.5",
|
|
73
74
|
"simple-git-hooks": "^2.9.0",
|
|
74
75
|
tsup: "^8.0.1",
|
package/dist/cli.js
CHANGED
|
@@ -17,7 +17,7 @@ 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.3.0";
|
|
21
21
|
var devDependencies = {
|
|
22
22
|
"@antfu/eslint-config": "workspace:*",
|
|
23
23
|
"@antfu/eslint-plugin-prettier": "^5.0.1-1",
|
|
@@ -25,21 +25,22 @@ var devDependencies = {
|
|
|
25
25
|
"@stylistic/eslint-plugin-migrate": "^1.4.1",
|
|
26
26
|
"@types/eslint": "^8.44.8",
|
|
27
27
|
"@types/fs-extra": "^11.0.4",
|
|
28
|
-
"@types/node": "^20.10.
|
|
28
|
+
"@types/node": "^20.10.3",
|
|
29
29
|
"@types/prompts": "^2.4.9",
|
|
30
30
|
"@types/yargs": "^17.0.32",
|
|
31
|
-
"@unocss/eslint-plugin": "^0.
|
|
31
|
+
"@unocss/eslint-plugin": "^0.58.0",
|
|
32
32
|
bumpp: "^9.2.0",
|
|
33
|
-
eslint: "^8.
|
|
33
|
+
eslint: "^8.55.0",
|
|
34
34
|
"eslint-flat-config-viewer": "^0.1.3",
|
|
35
|
+
"eslint-plugin-format": "^0.0.1",
|
|
35
36
|
"eslint-plugin-react": "^7.33.2",
|
|
36
37
|
"eslint-plugin-react-hooks": "^4.6.0",
|
|
37
|
-
"eslint-plugin-react-refresh": "^0.4.
|
|
38
|
+
"eslint-plugin-react-refresh": "^0.4.5",
|
|
38
39
|
esno: "^4.0.0",
|
|
39
40
|
execa: "^8.0.1",
|
|
40
41
|
"fast-glob": "^3.3.2",
|
|
41
42
|
"fs-extra": "^11.2.0",
|
|
42
|
-
"lint-staged": "^15.
|
|
43
|
+
"lint-staged": "^15.2.0",
|
|
43
44
|
rimraf: "^5.0.5",
|
|
44
45
|
"simple-git-hooks": "^2.9.0",
|
|
45
46
|
tsup: "^8.0.1",
|
package/dist/index.cjs
CHANGED
|
@@ -59,6 +59,7 @@ __export(src_exports, {
|
|
|
59
59
|
comments: () => comments,
|
|
60
60
|
default: () => src_default,
|
|
61
61
|
ensurePackages: () => ensurePackages,
|
|
62
|
+
formatters: () => formatters,
|
|
62
63
|
ignores: () => ignores,
|
|
63
64
|
imports: () => imports,
|
|
64
65
|
interopDefault: () => interopDefault,
|
|
@@ -68,7 +69,6 @@ __export(src_exports, {
|
|
|
68
69
|
markdown: () => markdown,
|
|
69
70
|
node: () => node,
|
|
70
71
|
perfectionist: () => perfectionist,
|
|
71
|
-
prettier: () => prettier,
|
|
72
72
|
react: () => react,
|
|
73
73
|
renameRules: () => renameRules,
|
|
74
74
|
sortPackageJson: () => sortPackageJson,
|
|
@@ -595,25 +595,47 @@ async function jsonc(options = {}) {
|
|
|
595
595
|
}
|
|
596
596
|
|
|
597
597
|
// src/configs/markdown.ts
|
|
598
|
-
async function markdown(options = {}) {
|
|
598
|
+
async function markdown(options = {}, formatMarkdown = false) {
|
|
599
599
|
const {
|
|
600
600
|
componentExts = [],
|
|
601
601
|
files = [GLOB_MARKDOWN],
|
|
602
602
|
overrides = {}
|
|
603
603
|
} = options;
|
|
604
|
+
const markdown2 = await interopDefault(import("eslint-plugin-markdown"));
|
|
605
|
+
const baseProcessor = markdown2.processors.markdown;
|
|
606
|
+
const processor = !formatMarkdown ? baseProcessor : {
|
|
607
|
+
...baseProcessor,
|
|
608
|
+
postprocess(messages, filename) {
|
|
609
|
+
const markdownContent = messages.pop();
|
|
610
|
+
const codeSnippets = baseProcessor.postprocess(messages, filename);
|
|
611
|
+
return [
|
|
612
|
+
...markdownContent || [],
|
|
613
|
+
...codeSnippets || []
|
|
614
|
+
];
|
|
615
|
+
},
|
|
616
|
+
preprocess(text, filename) {
|
|
617
|
+
const result = baseProcessor.preprocess(text, filename);
|
|
618
|
+
return [
|
|
619
|
+
...result,
|
|
620
|
+
{
|
|
621
|
+
filename: ".__markdown_content__",
|
|
622
|
+
text
|
|
623
|
+
}
|
|
624
|
+
];
|
|
625
|
+
}
|
|
626
|
+
};
|
|
604
627
|
return [
|
|
605
628
|
{
|
|
606
629
|
name: "antfu:markdown:setup",
|
|
607
630
|
plugins: {
|
|
608
|
-
|
|
609
|
-
markdown: await interopDefault(import("eslint-plugin-markdown"))
|
|
631
|
+
markdown: markdown2
|
|
610
632
|
}
|
|
611
633
|
},
|
|
612
634
|
{
|
|
613
635
|
files,
|
|
614
636
|
ignores: [GLOB_MARKDOWN_IN_MARKDOWN],
|
|
615
637
|
name: "antfu:markdown:processor",
|
|
616
|
-
processor
|
|
638
|
+
processor
|
|
617
639
|
},
|
|
618
640
|
{
|
|
619
641
|
files: [
|
|
@@ -629,7 +651,6 @@ async function markdown(options = {}) {
|
|
|
629
651
|
},
|
|
630
652
|
name: "antfu:markdown:disables",
|
|
631
653
|
rules: {
|
|
632
|
-
"antfu/no-ts-export-equal": "off",
|
|
633
654
|
"import/newline-after-import": "off",
|
|
634
655
|
"no-alert": "off",
|
|
635
656
|
"no-console": "off",
|
|
@@ -749,7 +770,6 @@ async function stylistic(options = {}) {
|
|
|
749
770
|
...config.rules,
|
|
750
771
|
"antfu/consistent-list-newline": "error",
|
|
751
772
|
"antfu/if-newline": "error",
|
|
752
|
-
"antfu/indent-binary-ops": ["error", { indent }],
|
|
753
773
|
"antfu/top-level-function": "error",
|
|
754
774
|
"curly": ["error", "multi-or-nest", "consistent"]
|
|
755
775
|
}
|
|
@@ -757,11 +777,10 @@ async function stylistic(options = {}) {
|
|
|
757
777
|
];
|
|
758
778
|
}
|
|
759
779
|
|
|
760
|
-
// src/configs/
|
|
761
|
-
async function
|
|
762
|
-
console.warn("@antfu/eslint-config: `prettier` option is deprecated, please do not use it anymore. We will find better formatters to support that in the future.");
|
|
780
|
+
// src/configs/formatters.ts
|
|
781
|
+
async function formatters(options = {}, stylistic2 = {}) {
|
|
763
782
|
await ensurePackages([
|
|
764
|
-
"
|
|
783
|
+
"eslint-plugin-format"
|
|
765
784
|
]);
|
|
766
785
|
const {
|
|
767
786
|
indent,
|
|
@@ -771,9 +790,6 @@ async function prettier(options = {}, stylistic2 = {}) {
|
|
|
771
790
|
...StylisticConfigDefaults,
|
|
772
791
|
...stylistic2
|
|
773
792
|
};
|
|
774
|
-
const {
|
|
775
|
-
usePrettierrc = false
|
|
776
|
-
} = options;
|
|
777
793
|
const prettierOptions = Object.assign(
|
|
778
794
|
{
|
|
779
795
|
semi,
|
|
@@ -782,53 +798,137 @@ async function prettier(options = {}, stylistic2 = {}) {
|
|
|
782
798
|
trailingComma: "all",
|
|
783
799
|
useTabs: indent === "tab"
|
|
784
800
|
},
|
|
785
|
-
options.
|
|
801
|
+
options.prettierOptions || {}
|
|
786
802
|
);
|
|
787
|
-
const
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
if (options.graphql)
|
|
798
|
-
rules.graphql || (rules.graphql = ["**/*.graphql", "**/*.gql"]);
|
|
799
|
-
if (!Object.keys(rules).length)
|
|
800
|
-
throw new Error("No languages specified for Prettier");
|
|
801
|
-
const pluginPrettier = await interopDefault(import("@antfu/eslint-plugin-prettier"));
|
|
802
|
-
const parserPlain = await interopDefault(import("eslint-parser-plain"));
|
|
803
|
-
return [
|
|
803
|
+
const dprintOptions = Object.assign(
|
|
804
|
+
{
|
|
805
|
+
indentWidth: typeof indent === "number" ? indent : 2,
|
|
806
|
+
quoteStyle: quotes === "single" ? "preferSingle" : "preferDouble",
|
|
807
|
+
useTabs: indent === "tab"
|
|
808
|
+
},
|
|
809
|
+
options.dprintOptions || {}
|
|
810
|
+
);
|
|
811
|
+
const pluginFormat = await interopDefault(import("eslint-plugin-format"));
|
|
812
|
+
const configs = [
|
|
804
813
|
{
|
|
805
|
-
name: "antfu:
|
|
814
|
+
name: "antfu:formatters:setup",
|
|
806
815
|
plugins: {
|
|
807
|
-
|
|
816
|
+
format: pluginFormat
|
|
808
817
|
}
|
|
809
|
-
}
|
|
810
|
-
|
|
811
|
-
|
|
818
|
+
}
|
|
819
|
+
];
|
|
820
|
+
if (options.css) {
|
|
821
|
+
configs.push(
|
|
822
|
+
{
|
|
823
|
+
files: [GLOB_CSS, GLOB_POSTCSS],
|
|
824
|
+
languageOptions: {
|
|
825
|
+
parser: pluginFormat.parserPlain
|
|
826
|
+
},
|
|
827
|
+
name: "antfu:formatter:css",
|
|
828
|
+
rules: {
|
|
829
|
+
"format/prettier": [
|
|
830
|
+
"error",
|
|
831
|
+
{
|
|
832
|
+
...prettierOptions,
|
|
833
|
+
parser: "css"
|
|
834
|
+
}
|
|
835
|
+
]
|
|
836
|
+
}
|
|
837
|
+
},
|
|
838
|
+
{
|
|
839
|
+
files: [GLOB_SCSS],
|
|
840
|
+
languageOptions: {
|
|
841
|
+
parser: pluginFormat.parserPlain
|
|
842
|
+
},
|
|
843
|
+
name: "antfu:formatter:scss",
|
|
844
|
+
rules: {
|
|
845
|
+
"format/prettier": [
|
|
846
|
+
"error",
|
|
847
|
+
{
|
|
848
|
+
...prettierOptions,
|
|
849
|
+
parser: "scss"
|
|
850
|
+
}
|
|
851
|
+
]
|
|
852
|
+
}
|
|
853
|
+
},
|
|
854
|
+
{
|
|
855
|
+
files: [GLOB_LESS],
|
|
856
|
+
languageOptions: {
|
|
857
|
+
parser: pluginFormat.parserPlain
|
|
858
|
+
},
|
|
859
|
+
name: "antfu:formatter:less",
|
|
860
|
+
rules: {
|
|
861
|
+
"format/prettier": [
|
|
862
|
+
"error",
|
|
863
|
+
{
|
|
864
|
+
...prettierOptions,
|
|
865
|
+
parser: "less"
|
|
866
|
+
}
|
|
867
|
+
]
|
|
868
|
+
}
|
|
869
|
+
}
|
|
870
|
+
);
|
|
871
|
+
}
|
|
872
|
+
if (options.html) {
|
|
873
|
+
configs.push({
|
|
874
|
+
files: ["**/*.html"],
|
|
812
875
|
languageOptions: {
|
|
813
|
-
parser: parserPlain
|
|
876
|
+
parser: pluginFormat.parserPlain
|
|
814
877
|
},
|
|
815
|
-
name:
|
|
878
|
+
name: "antfu:formatter:html",
|
|
816
879
|
rules: {
|
|
817
|
-
"
|
|
880
|
+
"format/prettier": [
|
|
818
881
|
"error",
|
|
819
882
|
{
|
|
820
883
|
...prettierOptions,
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
884
|
+
parser: "html"
|
|
885
|
+
}
|
|
886
|
+
]
|
|
887
|
+
}
|
|
888
|
+
});
|
|
889
|
+
}
|
|
890
|
+
if (options.toml) {
|
|
891
|
+
configs.push({
|
|
892
|
+
files: ["**/*.toml"],
|
|
893
|
+
languageOptions: {
|
|
894
|
+
parser: pluginFormat.parserPlain
|
|
895
|
+
},
|
|
896
|
+
name: "antfu:formatter:toml",
|
|
897
|
+
rules: {
|
|
898
|
+
"format/dprint": [
|
|
899
|
+
"error",
|
|
824
900
|
{
|
|
825
|
-
|
|
826
|
-
|
|
901
|
+
...dprintOptions,
|
|
902
|
+
language: "toml"
|
|
827
903
|
}
|
|
828
904
|
]
|
|
829
905
|
}
|
|
830
|
-
})
|
|
831
|
-
|
|
906
|
+
});
|
|
907
|
+
}
|
|
908
|
+
if (options.markdown) {
|
|
909
|
+
const formater = options.markdown === true ? "prettier" : options.markdown;
|
|
910
|
+
configs.push({
|
|
911
|
+
files: ["**/*.__markdown_content__"],
|
|
912
|
+
languageOptions: {
|
|
913
|
+
parser: pluginFormat.parserPlain
|
|
914
|
+
},
|
|
915
|
+
name: "antfu:formatter:markdown",
|
|
916
|
+
rules: {
|
|
917
|
+
[`format/${formater}`]: [
|
|
918
|
+
"error",
|
|
919
|
+
formater === "prettier" ? {
|
|
920
|
+
...prettierOptions,
|
|
921
|
+
embeddedLanguageFormatting: "off",
|
|
922
|
+
parser: "markdown"
|
|
923
|
+
} : {
|
|
924
|
+
...dprintOptions,
|
|
925
|
+
language: "markdown"
|
|
926
|
+
}
|
|
927
|
+
]
|
|
928
|
+
}
|
|
929
|
+
});
|
|
930
|
+
}
|
|
931
|
+
return configs;
|
|
832
932
|
}
|
|
833
933
|
|
|
834
934
|
// src/configs/react.ts
|
|
@@ -1263,8 +1363,6 @@ async function typescript(options = {}) {
|
|
|
1263
1363
|
"@typescript-eslint/",
|
|
1264
1364
|
"ts/"
|
|
1265
1365
|
),
|
|
1266
|
-
"antfu/generic-spacing": "error",
|
|
1267
|
-
"antfu/named-tuple-spacing": "error",
|
|
1268
1366
|
"no-dupe-class-members": "off",
|
|
1269
1367
|
"no-loss-of-precision": "off",
|
|
1270
1368
|
"no-redeclare": "off",
|
|
@@ -1690,14 +1788,19 @@ async function antfu(options = {}, ...userConfigs) {
|
|
|
1690
1788
|
}));
|
|
1691
1789
|
}
|
|
1692
1790
|
if (options.markdown ?? true) {
|
|
1693
|
-
configs.push(
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1791
|
+
configs.push(
|
|
1792
|
+
markdown(
|
|
1793
|
+
{
|
|
1794
|
+
componentExts,
|
|
1795
|
+
overrides: overrides.markdown
|
|
1796
|
+
},
|
|
1797
|
+
!!options.formatters?.markdown
|
|
1798
|
+
)
|
|
1799
|
+
);
|
|
1697
1800
|
}
|
|
1698
|
-
if (options.
|
|
1699
|
-
configs.push(
|
|
1700
|
-
options.
|
|
1801
|
+
if (options.formatters) {
|
|
1802
|
+
configs.push(formatters(
|
|
1803
|
+
options.formatters,
|
|
1701
1804
|
typeof stylisticOptions === "boolean" ? {} : stylisticOptions
|
|
1702
1805
|
));
|
|
1703
1806
|
}
|
|
@@ -1747,6 +1850,7 @@ var src_default = antfu;
|
|
|
1747
1850
|
combine,
|
|
1748
1851
|
comments,
|
|
1749
1852
|
ensurePackages,
|
|
1853
|
+
formatters,
|
|
1750
1854
|
ignores,
|
|
1751
1855
|
imports,
|
|
1752
1856
|
interopDefault,
|
|
@@ -1756,7 +1860,6 @@ var src_default = antfu;
|
|
|
1756
1860
|
markdown,
|
|
1757
1861
|
node,
|
|
1758
1862
|
perfectionist,
|
|
1759
|
-
prettier,
|
|
1760
1863
|
react,
|
|
1761
1864
|
renameRules,
|
|
1762
1865
|
sortPackageJson,
|
package/dist/index.d.cts
CHANGED
|
@@ -130,37 +130,45 @@ interface OptionsFiles {
|
|
|
130
130
|
*/
|
|
131
131
|
files?: string[];
|
|
132
132
|
}
|
|
133
|
-
interface
|
|
133
|
+
interface OptionsFormatters {
|
|
134
134
|
/**
|
|
135
|
-
* Enable
|
|
135
|
+
* Enable formatting support for CSS, Less, Sass, and SCSS.
|
|
136
|
+
*
|
|
137
|
+
* Currently only support Prettier.
|
|
136
138
|
*/
|
|
137
|
-
css?: boolean;
|
|
139
|
+
css?: 'prettier' | boolean;
|
|
138
140
|
/**
|
|
139
|
-
* Enable
|
|
141
|
+
* Enable formatting support for HTML.
|
|
142
|
+
*
|
|
143
|
+
* Currently only support Prettier.
|
|
140
144
|
*/
|
|
141
|
-
html?: boolean;
|
|
145
|
+
html?: 'prettier' | boolean;
|
|
142
146
|
/**
|
|
143
|
-
* Enable
|
|
147
|
+
* Enable formatting support for TOML.
|
|
148
|
+
*
|
|
149
|
+
* Currently only support dprint.
|
|
144
150
|
*/
|
|
145
|
-
|
|
151
|
+
toml?: 'dprint' | boolean;
|
|
146
152
|
/**
|
|
147
|
-
*
|
|
153
|
+
* Enable formatting support for Markdown.
|
|
154
|
+
*
|
|
155
|
+
* Support both Prettier and dprint.
|
|
148
156
|
*
|
|
149
|
-
*
|
|
157
|
+
* When set to `true`, it will use Prettier.
|
|
150
158
|
*/
|
|
151
|
-
|
|
159
|
+
markdown?: 'prettier' | 'dprint' | boolean;
|
|
152
160
|
/**
|
|
153
161
|
* Custom options for Prettier.
|
|
154
162
|
*
|
|
155
163
|
* By default it's controlled by our own config.
|
|
156
164
|
*/
|
|
157
|
-
|
|
165
|
+
prettierOptions?: VendoredPrettierOptions;
|
|
158
166
|
/**
|
|
159
|
-
*
|
|
167
|
+
* Custom options for dprint.
|
|
160
168
|
*
|
|
161
|
-
*
|
|
169
|
+
* By default it's controlled by our own config.
|
|
162
170
|
*/
|
|
163
|
-
|
|
171
|
+
dprintOptions?: boolean;
|
|
164
172
|
}
|
|
165
173
|
interface OptionsComponentExts {
|
|
166
174
|
/**
|
|
@@ -293,14 +301,14 @@ interface OptionsConfig extends OptionsComponentExts {
|
|
|
293
301
|
*/
|
|
294
302
|
unocss?: boolean | OptionsUnoCSS;
|
|
295
303
|
/**
|
|
296
|
-
* Use
|
|
304
|
+
* Use external formatters to format files.
|
|
297
305
|
*
|
|
298
306
|
* Requires installing:
|
|
299
|
-
* - `eslint-plugin-
|
|
307
|
+
* - `eslint-plugin-format`
|
|
300
308
|
*
|
|
301
309
|
* @default false
|
|
302
310
|
*/
|
|
303
|
-
|
|
311
|
+
formatters?: OptionsFormatters;
|
|
304
312
|
/**
|
|
305
313
|
* Control to disable some rules in editors.
|
|
306
314
|
* @default auto-detect based on the process.env
|
|
@@ -338,7 +346,7 @@ declare function jsdoc(options?: OptionsStylistic): Promise<FlatConfigItem[]>;
|
|
|
338
346
|
|
|
339
347
|
declare function jsonc(options?: OptionsFiles & OptionsStylistic & OptionsOverrides): Promise<FlatConfigItem[]>;
|
|
340
348
|
|
|
341
|
-
declare function markdown(options?: OptionsFiles & OptionsComponentExts & OptionsOverrides): Promise<FlatConfigItem[]>;
|
|
349
|
+
declare function markdown(options?: OptionsFiles & OptionsComponentExts & OptionsOverrides, formatMarkdown?: boolean): Promise<FlatConfigItem[]>;
|
|
342
350
|
|
|
343
351
|
declare function node(): Promise<FlatConfigItem[]>;
|
|
344
352
|
|
|
@@ -349,10 +357,7 @@ declare function node(): Promise<FlatConfigItem[]>;
|
|
|
349
357
|
*/
|
|
350
358
|
declare function perfectionist(): Promise<FlatConfigItem[]>;
|
|
351
359
|
|
|
352
|
-
|
|
353
|
-
* @deprecated
|
|
354
|
-
*/
|
|
355
|
-
declare function prettier(options?: OptionsPrettier, stylistic?: StylisticConfig): Promise<FlatConfigItem[]>;
|
|
360
|
+
declare function formatters(options?: OptionsFormatters, stylistic?: StylisticConfig): Promise<FlatConfigItem[]>;
|
|
356
361
|
|
|
357
362
|
declare function react(options?: OptionsHasTypeScript & OptionsOverrides & OptionsFiles): Promise<FlatConfigItem[]>;
|
|
358
363
|
|
|
@@ -421,4 +426,4 @@ declare function interopDefault<T>(m: Awaitable<T>): Promise<T extends {
|
|
|
421
426
|
} ? U : T>;
|
|
422
427
|
declare function ensurePackages(packages: string[]): Promise<void>;
|
|
423
428
|
|
|
424
|
-
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_TS, GLOB_TSX, GLOB_VUE, GLOB_YAML, type OptionsComponentExts, type OptionsConfig, type OptionsFiles, type
|
|
429
|
+
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_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 Rules, type StylisticConfig, StylisticConfigDefaults, type UserConfigItem, type WrapRuleConfig, antfu, combine, comments, antfu as default, ensurePackages, formatters, ignores, imports, interopDefault, javascript, jsdoc, jsonc, markdown, node, perfectionist, react, renameRules, sortPackageJson, sortTsconfig, stylistic, test, toArray, typescript, unicorn, unocss, vue, yaml };
|
package/dist/index.d.ts
CHANGED
|
@@ -130,37 +130,45 @@ interface OptionsFiles {
|
|
|
130
130
|
*/
|
|
131
131
|
files?: string[];
|
|
132
132
|
}
|
|
133
|
-
interface
|
|
133
|
+
interface OptionsFormatters {
|
|
134
134
|
/**
|
|
135
|
-
* Enable
|
|
135
|
+
* Enable formatting support for CSS, Less, Sass, and SCSS.
|
|
136
|
+
*
|
|
137
|
+
* Currently only support Prettier.
|
|
136
138
|
*/
|
|
137
|
-
css?: boolean;
|
|
139
|
+
css?: 'prettier' | boolean;
|
|
138
140
|
/**
|
|
139
|
-
* Enable
|
|
141
|
+
* Enable formatting support for HTML.
|
|
142
|
+
*
|
|
143
|
+
* Currently only support Prettier.
|
|
140
144
|
*/
|
|
141
|
-
html?: boolean;
|
|
145
|
+
html?: 'prettier' | boolean;
|
|
142
146
|
/**
|
|
143
|
-
* Enable
|
|
147
|
+
* Enable formatting support for TOML.
|
|
148
|
+
*
|
|
149
|
+
* Currently only support dprint.
|
|
144
150
|
*/
|
|
145
|
-
|
|
151
|
+
toml?: 'dprint' | boolean;
|
|
146
152
|
/**
|
|
147
|
-
*
|
|
153
|
+
* Enable formatting support for Markdown.
|
|
154
|
+
*
|
|
155
|
+
* Support both Prettier and dprint.
|
|
148
156
|
*
|
|
149
|
-
*
|
|
157
|
+
* When set to `true`, it will use Prettier.
|
|
150
158
|
*/
|
|
151
|
-
|
|
159
|
+
markdown?: 'prettier' | 'dprint' | boolean;
|
|
152
160
|
/**
|
|
153
161
|
* Custom options for Prettier.
|
|
154
162
|
*
|
|
155
163
|
* By default it's controlled by our own config.
|
|
156
164
|
*/
|
|
157
|
-
|
|
165
|
+
prettierOptions?: VendoredPrettierOptions;
|
|
158
166
|
/**
|
|
159
|
-
*
|
|
167
|
+
* Custom options for dprint.
|
|
160
168
|
*
|
|
161
|
-
*
|
|
169
|
+
* By default it's controlled by our own config.
|
|
162
170
|
*/
|
|
163
|
-
|
|
171
|
+
dprintOptions?: boolean;
|
|
164
172
|
}
|
|
165
173
|
interface OptionsComponentExts {
|
|
166
174
|
/**
|
|
@@ -293,14 +301,14 @@ interface OptionsConfig extends OptionsComponentExts {
|
|
|
293
301
|
*/
|
|
294
302
|
unocss?: boolean | OptionsUnoCSS;
|
|
295
303
|
/**
|
|
296
|
-
* Use
|
|
304
|
+
* Use external formatters to format files.
|
|
297
305
|
*
|
|
298
306
|
* Requires installing:
|
|
299
|
-
* - `eslint-plugin-
|
|
307
|
+
* - `eslint-plugin-format`
|
|
300
308
|
*
|
|
301
309
|
* @default false
|
|
302
310
|
*/
|
|
303
|
-
|
|
311
|
+
formatters?: OptionsFormatters;
|
|
304
312
|
/**
|
|
305
313
|
* Control to disable some rules in editors.
|
|
306
314
|
* @default auto-detect based on the process.env
|
|
@@ -338,7 +346,7 @@ declare function jsdoc(options?: OptionsStylistic): Promise<FlatConfigItem[]>;
|
|
|
338
346
|
|
|
339
347
|
declare function jsonc(options?: OptionsFiles & OptionsStylistic & OptionsOverrides): Promise<FlatConfigItem[]>;
|
|
340
348
|
|
|
341
|
-
declare function markdown(options?: OptionsFiles & OptionsComponentExts & OptionsOverrides): Promise<FlatConfigItem[]>;
|
|
349
|
+
declare function markdown(options?: OptionsFiles & OptionsComponentExts & OptionsOverrides, formatMarkdown?: boolean): Promise<FlatConfigItem[]>;
|
|
342
350
|
|
|
343
351
|
declare function node(): Promise<FlatConfigItem[]>;
|
|
344
352
|
|
|
@@ -349,10 +357,7 @@ declare function node(): Promise<FlatConfigItem[]>;
|
|
|
349
357
|
*/
|
|
350
358
|
declare function perfectionist(): Promise<FlatConfigItem[]>;
|
|
351
359
|
|
|
352
|
-
|
|
353
|
-
* @deprecated
|
|
354
|
-
*/
|
|
355
|
-
declare function prettier(options?: OptionsPrettier, stylistic?: StylisticConfig): Promise<FlatConfigItem[]>;
|
|
360
|
+
declare function formatters(options?: OptionsFormatters, stylistic?: StylisticConfig): Promise<FlatConfigItem[]>;
|
|
356
361
|
|
|
357
362
|
declare function react(options?: OptionsHasTypeScript & OptionsOverrides & OptionsFiles): Promise<FlatConfigItem[]>;
|
|
358
363
|
|
|
@@ -421,4 +426,4 @@ declare function interopDefault<T>(m: Awaitable<T>): Promise<T extends {
|
|
|
421
426
|
} ? U : T>;
|
|
422
427
|
declare function ensurePackages(packages: string[]): Promise<void>;
|
|
423
428
|
|
|
424
|
-
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_TS, GLOB_TSX, GLOB_VUE, GLOB_YAML, type OptionsComponentExts, type OptionsConfig, type OptionsFiles, type
|
|
429
|
+
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_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 Rules, type StylisticConfig, StylisticConfigDefaults, type UserConfigItem, type WrapRuleConfig, antfu, combine, comments, antfu as default, ensurePackages, formatters, ignores, imports, interopDefault, javascript, jsdoc, jsonc, markdown, node, perfectionist, react, renameRules, sortPackageJson, sortTsconfig, stylistic, test, toArray, typescript, unicorn, unocss, vue, yaml };
|
package/dist/index.js
CHANGED
|
@@ -509,25 +509,47 @@ async function jsonc(options = {}) {
|
|
|
509
509
|
}
|
|
510
510
|
|
|
511
511
|
// src/configs/markdown.ts
|
|
512
|
-
async function markdown(options = {}) {
|
|
512
|
+
async function markdown(options = {}, formatMarkdown = false) {
|
|
513
513
|
const {
|
|
514
514
|
componentExts = [],
|
|
515
515
|
files = [GLOB_MARKDOWN],
|
|
516
516
|
overrides = {}
|
|
517
517
|
} = options;
|
|
518
|
+
const markdown2 = await interopDefault(import("eslint-plugin-markdown"));
|
|
519
|
+
const baseProcessor = markdown2.processors.markdown;
|
|
520
|
+
const processor = !formatMarkdown ? baseProcessor : {
|
|
521
|
+
...baseProcessor,
|
|
522
|
+
postprocess(messages, filename) {
|
|
523
|
+
const markdownContent = messages.pop();
|
|
524
|
+
const codeSnippets = baseProcessor.postprocess(messages, filename);
|
|
525
|
+
return [
|
|
526
|
+
...markdownContent || [],
|
|
527
|
+
...codeSnippets || []
|
|
528
|
+
];
|
|
529
|
+
},
|
|
530
|
+
preprocess(text, filename) {
|
|
531
|
+
const result = baseProcessor.preprocess(text, filename);
|
|
532
|
+
return [
|
|
533
|
+
...result,
|
|
534
|
+
{
|
|
535
|
+
filename: ".__markdown_content__",
|
|
536
|
+
text
|
|
537
|
+
}
|
|
538
|
+
];
|
|
539
|
+
}
|
|
540
|
+
};
|
|
518
541
|
return [
|
|
519
542
|
{
|
|
520
543
|
name: "antfu:markdown:setup",
|
|
521
544
|
plugins: {
|
|
522
|
-
|
|
523
|
-
markdown: await interopDefault(import("eslint-plugin-markdown"))
|
|
545
|
+
markdown: markdown2
|
|
524
546
|
}
|
|
525
547
|
},
|
|
526
548
|
{
|
|
527
549
|
files,
|
|
528
550
|
ignores: [GLOB_MARKDOWN_IN_MARKDOWN],
|
|
529
551
|
name: "antfu:markdown:processor",
|
|
530
|
-
processor
|
|
552
|
+
processor
|
|
531
553
|
},
|
|
532
554
|
{
|
|
533
555
|
files: [
|
|
@@ -543,7 +565,6 @@ async function markdown(options = {}) {
|
|
|
543
565
|
},
|
|
544
566
|
name: "antfu:markdown:disables",
|
|
545
567
|
rules: {
|
|
546
|
-
"antfu/no-ts-export-equal": "off",
|
|
547
568
|
"import/newline-after-import": "off",
|
|
548
569
|
"no-alert": "off",
|
|
549
570
|
"no-console": "off",
|
|
@@ -663,7 +684,6 @@ async function stylistic(options = {}) {
|
|
|
663
684
|
...config.rules,
|
|
664
685
|
"antfu/consistent-list-newline": "error",
|
|
665
686
|
"antfu/if-newline": "error",
|
|
666
|
-
"antfu/indent-binary-ops": ["error", { indent }],
|
|
667
687
|
"antfu/top-level-function": "error",
|
|
668
688
|
"curly": ["error", "multi-or-nest", "consistent"]
|
|
669
689
|
}
|
|
@@ -671,11 +691,10 @@ async function stylistic(options = {}) {
|
|
|
671
691
|
];
|
|
672
692
|
}
|
|
673
693
|
|
|
674
|
-
// src/configs/
|
|
675
|
-
async function
|
|
676
|
-
console.warn("@antfu/eslint-config: `prettier` option is deprecated, please do not use it anymore. We will find better formatters to support that in the future.");
|
|
694
|
+
// src/configs/formatters.ts
|
|
695
|
+
async function formatters(options = {}, stylistic2 = {}) {
|
|
677
696
|
await ensurePackages([
|
|
678
|
-
"
|
|
697
|
+
"eslint-plugin-format"
|
|
679
698
|
]);
|
|
680
699
|
const {
|
|
681
700
|
indent,
|
|
@@ -685,9 +704,6 @@ async function prettier(options = {}, stylistic2 = {}) {
|
|
|
685
704
|
...StylisticConfigDefaults,
|
|
686
705
|
...stylistic2
|
|
687
706
|
};
|
|
688
|
-
const {
|
|
689
|
-
usePrettierrc = false
|
|
690
|
-
} = options;
|
|
691
707
|
const prettierOptions = Object.assign(
|
|
692
708
|
{
|
|
693
709
|
semi,
|
|
@@ -696,53 +712,137 @@ async function prettier(options = {}, stylistic2 = {}) {
|
|
|
696
712
|
trailingComma: "all",
|
|
697
713
|
useTabs: indent === "tab"
|
|
698
714
|
},
|
|
699
|
-
options.
|
|
715
|
+
options.prettierOptions || {}
|
|
700
716
|
);
|
|
701
|
-
const
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
if (options.graphql)
|
|
712
|
-
rules.graphql || (rules.graphql = ["**/*.graphql", "**/*.gql"]);
|
|
713
|
-
if (!Object.keys(rules).length)
|
|
714
|
-
throw new Error("No languages specified for Prettier");
|
|
715
|
-
const pluginPrettier = await interopDefault(import("@antfu/eslint-plugin-prettier"));
|
|
716
|
-
const parserPlain = await interopDefault(import("eslint-parser-plain"));
|
|
717
|
-
return [
|
|
717
|
+
const dprintOptions = Object.assign(
|
|
718
|
+
{
|
|
719
|
+
indentWidth: typeof indent === "number" ? indent : 2,
|
|
720
|
+
quoteStyle: quotes === "single" ? "preferSingle" : "preferDouble",
|
|
721
|
+
useTabs: indent === "tab"
|
|
722
|
+
},
|
|
723
|
+
options.dprintOptions || {}
|
|
724
|
+
);
|
|
725
|
+
const pluginFormat = await interopDefault(import("eslint-plugin-format"));
|
|
726
|
+
const configs = [
|
|
718
727
|
{
|
|
719
|
-
name: "antfu:
|
|
728
|
+
name: "antfu:formatters:setup",
|
|
720
729
|
plugins: {
|
|
721
|
-
|
|
730
|
+
format: pluginFormat
|
|
722
731
|
}
|
|
723
|
-
}
|
|
724
|
-
|
|
725
|
-
|
|
732
|
+
}
|
|
733
|
+
];
|
|
734
|
+
if (options.css) {
|
|
735
|
+
configs.push(
|
|
736
|
+
{
|
|
737
|
+
files: [GLOB_CSS, GLOB_POSTCSS],
|
|
738
|
+
languageOptions: {
|
|
739
|
+
parser: pluginFormat.parserPlain
|
|
740
|
+
},
|
|
741
|
+
name: "antfu:formatter:css",
|
|
742
|
+
rules: {
|
|
743
|
+
"format/prettier": [
|
|
744
|
+
"error",
|
|
745
|
+
{
|
|
746
|
+
...prettierOptions,
|
|
747
|
+
parser: "css"
|
|
748
|
+
}
|
|
749
|
+
]
|
|
750
|
+
}
|
|
751
|
+
},
|
|
752
|
+
{
|
|
753
|
+
files: [GLOB_SCSS],
|
|
754
|
+
languageOptions: {
|
|
755
|
+
parser: pluginFormat.parserPlain
|
|
756
|
+
},
|
|
757
|
+
name: "antfu:formatter:scss",
|
|
758
|
+
rules: {
|
|
759
|
+
"format/prettier": [
|
|
760
|
+
"error",
|
|
761
|
+
{
|
|
762
|
+
...prettierOptions,
|
|
763
|
+
parser: "scss"
|
|
764
|
+
}
|
|
765
|
+
]
|
|
766
|
+
}
|
|
767
|
+
},
|
|
768
|
+
{
|
|
769
|
+
files: [GLOB_LESS],
|
|
770
|
+
languageOptions: {
|
|
771
|
+
parser: pluginFormat.parserPlain
|
|
772
|
+
},
|
|
773
|
+
name: "antfu:formatter:less",
|
|
774
|
+
rules: {
|
|
775
|
+
"format/prettier": [
|
|
776
|
+
"error",
|
|
777
|
+
{
|
|
778
|
+
...prettierOptions,
|
|
779
|
+
parser: "less"
|
|
780
|
+
}
|
|
781
|
+
]
|
|
782
|
+
}
|
|
783
|
+
}
|
|
784
|
+
);
|
|
785
|
+
}
|
|
786
|
+
if (options.html) {
|
|
787
|
+
configs.push({
|
|
788
|
+
files: ["**/*.html"],
|
|
726
789
|
languageOptions: {
|
|
727
|
-
parser: parserPlain
|
|
790
|
+
parser: pluginFormat.parserPlain
|
|
728
791
|
},
|
|
729
|
-
name:
|
|
792
|
+
name: "antfu:formatter:html",
|
|
730
793
|
rules: {
|
|
731
|
-
"
|
|
794
|
+
"format/prettier": [
|
|
732
795
|
"error",
|
|
733
796
|
{
|
|
734
797
|
...prettierOptions,
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
798
|
+
parser: "html"
|
|
799
|
+
}
|
|
800
|
+
]
|
|
801
|
+
}
|
|
802
|
+
});
|
|
803
|
+
}
|
|
804
|
+
if (options.toml) {
|
|
805
|
+
configs.push({
|
|
806
|
+
files: ["**/*.toml"],
|
|
807
|
+
languageOptions: {
|
|
808
|
+
parser: pluginFormat.parserPlain
|
|
809
|
+
},
|
|
810
|
+
name: "antfu:formatter:toml",
|
|
811
|
+
rules: {
|
|
812
|
+
"format/dprint": [
|
|
813
|
+
"error",
|
|
738
814
|
{
|
|
739
|
-
|
|
740
|
-
|
|
815
|
+
...dprintOptions,
|
|
816
|
+
language: "toml"
|
|
741
817
|
}
|
|
742
818
|
]
|
|
743
819
|
}
|
|
744
|
-
})
|
|
745
|
-
|
|
820
|
+
});
|
|
821
|
+
}
|
|
822
|
+
if (options.markdown) {
|
|
823
|
+
const formater = options.markdown === true ? "prettier" : options.markdown;
|
|
824
|
+
configs.push({
|
|
825
|
+
files: ["**/*.__markdown_content__"],
|
|
826
|
+
languageOptions: {
|
|
827
|
+
parser: pluginFormat.parserPlain
|
|
828
|
+
},
|
|
829
|
+
name: "antfu:formatter:markdown",
|
|
830
|
+
rules: {
|
|
831
|
+
[`format/${formater}`]: [
|
|
832
|
+
"error",
|
|
833
|
+
formater === "prettier" ? {
|
|
834
|
+
...prettierOptions,
|
|
835
|
+
embeddedLanguageFormatting: "off",
|
|
836
|
+
parser: "markdown"
|
|
837
|
+
} : {
|
|
838
|
+
...dprintOptions,
|
|
839
|
+
language: "markdown"
|
|
840
|
+
}
|
|
841
|
+
]
|
|
842
|
+
}
|
|
843
|
+
});
|
|
844
|
+
}
|
|
845
|
+
return configs;
|
|
746
846
|
}
|
|
747
847
|
|
|
748
848
|
// src/configs/react.ts
|
|
@@ -1177,8 +1277,6 @@ async function typescript(options = {}) {
|
|
|
1177
1277
|
"@typescript-eslint/",
|
|
1178
1278
|
"ts/"
|
|
1179
1279
|
),
|
|
1180
|
-
"antfu/generic-spacing": "error",
|
|
1181
|
-
"antfu/named-tuple-spacing": "error",
|
|
1182
1280
|
"no-dupe-class-members": "off",
|
|
1183
1281
|
"no-loss-of-precision": "off",
|
|
1184
1282
|
"no-redeclare": "off",
|
|
@@ -1604,14 +1702,19 @@ async function antfu(options = {}, ...userConfigs) {
|
|
|
1604
1702
|
}));
|
|
1605
1703
|
}
|
|
1606
1704
|
if (options.markdown ?? true) {
|
|
1607
|
-
configs.push(
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1705
|
+
configs.push(
|
|
1706
|
+
markdown(
|
|
1707
|
+
{
|
|
1708
|
+
componentExts,
|
|
1709
|
+
overrides: overrides.markdown
|
|
1710
|
+
},
|
|
1711
|
+
!!options.formatters?.markdown
|
|
1712
|
+
)
|
|
1713
|
+
);
|
|
1611
1714
|
}
|
|
1612
|
-
if (options.
|
|
1613
|
-
configs.push(
|
|
1614
|
-
options.
|
|
1715
|
+
if (options.formatters) {
|
|
1716
|
+
configs.push(formatters(
|
|
1717
|
+
options.formatters,
|
|
1615
1718
|
typeof stylisticOptions === "boolean" ? {} : stylisticOptions
|
|
1616
1719
|
));
|
|
1617
1720
|
}
|
|
@@ -1661,6 +1764,7 @@ export {
|
|
|
1661
1764
|
comments,
|
|
1662
1765
|
src_default as default,
|
|
1663
1766
|
ensurePackages,
|
|
1767
|
+
formatters,
|
|
1664
1768
|
ignores,
|
|
1665
1769
|
imports,
|
|
1666
1770
|
interopDefault,
|
|
@@ -1670,7 +1774,6 @@ export {
|
|
|
1670
1774
|
markdown,
|
|
1671
1775
|
node,
|
|
1672
1776
|
perfectionist,
|
|
1673
|
-
prettier,
|
|
1674
1777
|
react,
|
|
1675
1778
|
renameRules,
|
|
1676
1779
|
sortPackageJson,
|
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.3.0",
|
|
5
5
|
"packageManager": "pnpm@8.11.0",
|
|
6
6
|
"description": "Anthony's ESLint config",
|
|
7
7
|
"author": "Anthony Fu <anthonyfu117@hotmail.com> (https://github.com/antfu/)",
|
|
@@ -25,15 +25,15 @@
|
|
|
25
25
|
"dist"
|
|
26
26
|
],
|
|
27
27
|
"peerDependencies": {
|
|
28
|
-
"@antfu/eslint-plugin-prettier": "^5.0.1-1",
|
|
29
28
|
"@unocss/eslint-plugin": ">=0.50.0",
|
|
30
29
|
"eslint": ">=8.40.0",
|
|
30
|
+
"eslint-plugin-format": "^0.0.1",
|
|
31
31
|
"eslint-plugin-react": "^7.33.2",
|
|
32
32
|
"eslint-plugin-react-hooks": "^4.6.0",
|
|
33
33
|
"eslint-plugin-react-refresh": "^0.4.4"
|
|
34
34
|
},
|
|
35
35
|
"peerDependenciesMeta": {
|
|
36
|
-
"
|
|
36
|
+
"eslint-plugin-format": {
|
|
37
37
|
"optional": true
|
|
38
38
|
},
|
|
39
39
|
"@unocss/eslint-plugin": {
|
|
@@ -51,16 +51,15 @@
|
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
53
|
"@antfu/eslint-define-config": "^1.23.0-2",
|
|
54
|
-
"@antfu/install-pkg": "^0.3.
|
|
54
|
+
"@antfu/install-pkg": "^0.3.1",
|
|
55
55
|
"@eslint-types/jsdoc": "46.8.2-1",
|
|
56
56
|
"@eslint-types/typescript-eslint": "^6.12.0",
|
|
57
57
|
"@eslint-types/unicorn": "^49.0.0",
|
|
58
|
-
"@stylistic/eslint-plugin": "^1.
|
|
58
|
+
"@stylistic/eslint-plugin": "^1.5.0-beta.0",
|
|
59
59
|
"@typescript-eslint/eslint-plugin": "^6.13.1",
|
|
60
60
|
"@typescript-eslint/parser": "^6.13.1",
|
|
61
|
-
"eslint-config-flat-gitignore": "^0.1.
|
|
62
|
-
"eslint-
|
|
63
|
-
"eslint-plugin-antfu": "^1.0.11",
|
|
61
|
+
"eslint-config-flat-gitignore": "^0.1.2",
|
|
62
|
+
"eslint-plugin-antfu": "^2.0.0",
|
|
64
63
|
"eslint-plugin-eslint-comments": "^3.2.0",
|
|
65
64
|
"eslint-plugin-i": "^2.29.0",
|
|
66
65
|
"eslint-plugin-jsdoc": "^46.9.0",
|
|
@@ -72,7 +71,7 @@
|
|
|
72
71
|
"eslint-plugin-unicorn": "^49.0.0",
|
|
73
72
|
"eslint-plugin-unused-imports": "^3.0.0",
|
|
74
73
|
"eslint-plugin-vitest": "^0.3.10",
|
|
75
|
-
"eslint-plugin-vue": "^9.19.
|
|
74
|
+
"eslint-plugin-vue": "^9.19.2",
|
|
76
75
|
"eslint-plugin-yml": "^1.10.0",
|
|
77
76
|
"globals": "^13.23.0",
|
|
78
77
|
"jsonc-eslint-parser": "^2.4.0",
|
|
@@ -90,27 +89,28 @@
|
|
|
90
89
|
"@stylistic/eslint-plugin-migrate": "^1.4.1",
|
|
91
90
|
"@types/eslint": "^8.44.8",
|
|
92
91
|
"@types/fs-extra": "^11.0.4",
|
|
93
|
-
"@types/node": "^20.10.
|
|
92
|
+
"@types/node": "^20.10.3",
|
|
94
93
|
"@types/prompts": "^2.4.9",
|
|
95
94
|
"@types/yargs": "^17.0.32",
|
|
96
|
-
"@unocss/eslint-plugin": "^0.
|
|
95
|
+
"@unocss/eslint-plugin": "^0.58.0",
|
|
97
96
|
"bumpp": "^9.2.0",
|
|
98
|
-
"eslint": "^8.
|
|
97
|
+
"eslint": "^8.55.0",
|
|
99
98
|
"eslint-flat-config-viewer": "^0.1.3",
|
|
99
|
+
"eslint-plugin-format": "^0.0.1",
|
|
100
100
|
"eslint-plugin-react": "^7.33.2",
|
|
101
101
|
"eslint-plugin-react-hooks": "^4.6.0",
|
|
102
|
-
"eslint-plugin-react-refresh": "^0.4.
|
|
102
|
+
"eslint-plugin-react-refresh": "^0.4.5",
|
|
103
103
|
"esno": "^4.0.0",
|
|
104
104
|
"execa": "^8.0.1",
|
|
105
105
|
"fast-glob": "^3.3.2",
|
|
106
106
|
"fs-extra": "^11.2.0",
|
|
107
|
-
"lint-staged": "^15.
|
|
107
|
+
"lint-staged": "^15.2.0",
|
|
108
108
|
"rimraf": "^5.0.5",
|
|
109
109
|
"simple-git-hooks": "^2.9.0",
|
|
110
110
|
"tsup": "^8.0.1",
|
|
111
111
|
"typescript": "^5.3.2",
|
|
112
112
|
"vitest": "^0.34.6",
|
|
113
|
-
"@antfu/eslint-config": "2.
|
|
113
|
+
"@antfu/eslint-config": "2.3.0"
|
|
114
114
|
},
|
|
115
115
|
"simple-git-hooks": {
|
|
116
116
|
"pre-commit": "pnpm lint-staged"
|