@antfu/eslint-config 2.3.0 → 2.3.2
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 +1 -0
- package/dist/cli.cjs +3 -3
- package/dist/cli.js +3 -3
- package/dist/index.cjs +40 -4
- package/dist/index.d.cts +8 -2
- package/dist/index.d.ts +8 -2
- package/dist/index.js +40 -4
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -120,6 +120,7 @@ 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": "format/*", "severity": "off" },
|
|
123
124
|
{ "rule": "*-indent", "severity": "off" },
|
|
124
125
|
{ "rule": "*-spacing", "severity": "off" },
|
|
125
126
|
{ "rule": "*-spaces", "severity": "off" },
|
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.3.
|
|
49
|
+
var version = "2.3.2";
|
|
50
50
|
var devDependencies = {
|
|
51
51
|
"@antfu/eslint-config": "workspace:*",
|
|
52
52
|
"@antfu/eslint-plugin-prettier": "^5.0.1-1",
|
|
@@ -74,7 +74,7 @@ var devDependencies = {
|
|
|
74
74
|
"simple-git-hooks": "^2.9.0",
|
|
75
75
|
tsup: "^8.0.1",
|
|
76
76
|
typescript: "^5.3.2",
|
|
77
|
-
vitest: "^0.
|
|
77
|
+
vitest: "^1.0.1"
|
|
78
78
|
};
|
|
79
79
|
|
|
80
80
|
// src/cli/constants.ts
|
|
@@ -100,7 +100,7 @@ var vscodeSettingsString = `
|
|
|
100
100
|
// Silent the stylistic rules in you IDE, but still auto fix them
|
|
101
101
|
"eslint.rules.customizations": [
|
|
102
102
|
{ "rule": "style/*", "severity": "off" },
|
|
103
|
-
{ "rule": "
|
|
103
|
+
{ "rule": "format/*", "severity": "off" },
|
|
104
104
|
{ "rule": "*-indent", "severity": "off" },
|
|
105
105
|
{ "rule": "*-spacing", "severity": "off" },
|
|
106
106
|
{ "rule": "*-spaces", "severity": "off" },
|
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.3.
|
|
20
|
+
var version = "2.3.2";
|
|
21
21
|
var devDependencies = {
|
|
22
22
|
"@antfu/eslint-config": "workspace:*",
|
|
23
23
|
"@antfu/eslint-plugin-prettier": "^5.0.1-1",
|
|
@@ -45,7 +45,7 @@ var devDependencies = {
|
|
|
45
45
|
"simple-git-hooks": "^2.9.0",
|
|
46
46
|
tsup: "^8.0.1",
|
|
47
47
|
typescript: "^5.3.2",
|
|
48
|
-
vitest: "^0.
|
|
48
|
+
vitest: "^1.0.1"
|
|
49
49
|
};
|
|
50
50
|
|
|
51
51
|
// src/cli/constants.ts
|
|
@@ -71,7 +71,7 @@ var vscodeSettingsString = `
|
|
|
71
71
|
// Silent the stylistic rules in you IDE, but still auto fix them
|
|
72
72
|
"eslint.rules.customizations": [
|
|
73
73
|
{ "rule": "style/*", "severity": "off" },
|
|
74
|
-
{ "rule": "
|
|
74
|
+
{ "rule": "format/*", "severity": "off" },
|
|
75
75
|
{ "rule": "*-indent", "severity": "off" },
|
|
76
76
|
{ "rule": "*-spacing", "severity": "off" },
|
|
77
77
|
{ "rule": "*-spaces", "severity": "off" },
|
package/dist/index.cjs
CHANGED
|
@@ -603,8 +603,16 @@ async function markdown(options = {}, formatMarkdown = false) {
|
|
|
603
603
|
} = options;
|
|
604
604
|
const markdown2 = await interopDefault(import("eslint-plugin-markdown"));
|
|
605
605
|
const baseProcessor = markdown2.processors.markdown;
|
|
606
|
-
const processor = !formatMarkdown ?
|
|
607
|
-
|
|
606
|
+
const processor = !formatMarkdown ? {
|
|
607
|
+
meta: {
|
|
608
|
+
name: "markdown-processor"
|
|
609
|
+
},
|
|
610
|
+
supportsAutofix: true,
|
|
611
|
+
...baseProcessor
|
|
612
|
+
} : {
|
|
613
|
+
meta: {
|
|
614
|
+
name: "markdown-processor-with-content"
|
|
615
|
+
},
|
|
608
616
|
postprocess(messages, filename) {
|
|
609
617
|
const markdownContent = messages.pop();
|
|
610
618
|
const codeSnippets = baseProcessor.postprocess(messages, filename);
|
|
@@ -622,7 +630,8 @@ async function markdown(options = {}, formatMarkdown = false) {
|
|
|
622
630
|
text
|
|
623
631
|
}
|
|
624
632
|
];
|
|
625
|
-
}
|
|
633
|
+
},
|
|
634
|
+
supportsAutofix: true
|
|
626
635
|
};
|
|
627
636
|
return [
|
|
628
637
|
{
|
|
@@ -782,6 +791,15 @@ async function formatters(options = {}, stylistic2 = {}) {
|
|
|
782
791
|
await ensurePackages([
|
|
783
792
|
"eslint-plugin-format"
|
|
784
793
|
]);
|
|
794
|
+
if (options === true) {
|
|
795
|
+
options = {
|
|
796
|
+
css: true,
|
|
797
|
+
graphql: true,
|
|
798
|
+
html: true,
|
|
799
|
+
markdown: true,
|
|
800
|
+
toml: true
|
|
801
|
+
};
|
|
802
|
+
}
|
|
785
803
|
const {
|
|
786
804
|
indent,
|
|
787
805
|
quotes,
|
|
@@ -928,6 +946,24 @@ async function formatters(options = {}, stylistic2 = {}) {
|
|
|
928
946
|
}
|
|
929
947
|
});
|
|
930
948
|
}
|
|
949
|
+
if (options.graphql) {
|
|
950
|
+
configs.push({
|
|
951
|
+
files: ["**/*.graphql"],
|
|
952
|
+
languageOptions: {
|
|
953
|
+
parser: pluginFormat.parserPlain
|
|
954
|
+
},
|
|
955
|
+
name: "antfu:formatter:graphql",
|
|
956
|
+
rules: {
|
|
957
|
+
"format/prettier": [
|
|
958
|
+
"error",
|
|
959
|
+
{
|
|
960
|
+
...prettierOptions,
|
|
961
|
+
parser: "graphql"
|
|
962
|
+
}
|
|
963
|
+
]
|
|
964
|
+
}
|
|
965
|
+
});
|
|
966
|
+
}
|
|
931
967
|
return configs;
|
|
932
968
|
}
|
|
933
969
|
|
|
@@ -1794,7 +1830,7 @@ async function antfu(options = {}, ...userConfigs) {
|
|
|
1794
1830
|
componentExts,
|
|
1795
1831
|
overrides: overrides.markdown
|
|
1796
1832
|
},
|
|
1797
|
-
!!options.formatters?.markdown
|
|
1833
|
+
options.formatters === true || !!(options.formatters || {})?.markdown
|
|
1798
1834
|
)
|
|
1799
1835
|
);
|
|
1800
1836
|
}
|
package/dist/index.d.cts
CHANGED
|
@@ -157,6 +157,10 @@ interface OptionsFormatters {
|
|
|
157
157
|
* When set to `true`, it will use Prettier.
|
|
158
158
|
*/
|
|
159
159
|
markdown?: 'prettier' | 'dprint' | boolean;
|
|
160
|
+
/**
|
|
161
|
+
* Enable formatting support for GraphQL.
|
|
162
|
+
*/
|
|
163
|
+
graphql?: 'prettier' | boolean;
|
|
160
164
|
/**
|
|
161
165
|
* Custom options for Prettier.
|
|
162
166
|
*
|
|
@@ -306,9 +310,11 @@ interface OptionsConfig extends OptionsComponentExts {
|
|
|
306
310
|
* Requires installing:
|
|
307
311
|
* - `eslint-plugin-format`
|
|
308
312
|
*
|
|
313
|
+
* When set to `true`, it will enable all formatters.
|
|
314
|
+
*
|
|
309
315
|
* @default false
|
|
310
316
|
*/
|
|
311
|
-
formatters?: OptionsFormatters;
|
|
317
|
+
formatters?: boolean | OptionsFormatters;
|
|
312
318
|
/**
|
|
313
319
|
* Control to disable some rules in editors.
|
|
314
320
|
* @default auto-detect based on the process.env
|
|
@@ -357,7 +363,7 @@ declare function node(): Promise<FlatConfigItem[]>;
|
|
|
357
363
|
*/
|
|
358
364
|
declare function perfectionist(): Promise<FlatConfigItem[]>;
|
|
359
365
|
|
|
360
|
-
declare function formatters(options?: OptionsFormatters, stylistic?: StylisticConfig): Promise<FlatConfigItem[]>;
|
|
366
|
+
declare function formatters(options?: OptionsFormatters | true, stylistic?: StylisticConfig): Promise<FlatConfigItem[]>;
|
|
361
367
|
|
|
362
368
|
declare function react(options?: OptionsHasTypeScript & OptionsOverrides & OptionsFiles): Promise<FlatConfigItem[]>;
|
|
363
369
|
|
package/dist/index.d.ts
CHANGED
|
@@ -157,6 +157,10 @@ interface OptionsFormatters {
|
|
|
157
157
|
* When set to `true`, it will use Prettier.
|
|
158
158
|
*/
|
|
159
159
|
markdown?: 'prettier' | 'dprint' | boolean;
|
|
160
|
+
/**
|
|
161
|
+
* Enable formatting support for GraphQL.
|
|
162
|
+
*/
|
|
163
|
+
graphql?: 'prettier' | boolean;
|
|
160
164
|
/**
|
|
161
165
|
* Custom options for Prettier.
|
|
162
166
|
*
|
|
@@ -306,9 +310,11 @@ interface OptionsConfig extends OptionsComponentExts {
|
|
|
306
310
|
* Requires installing:
|
|
307
311
|
* - `eslint-plugin-format`
|
|
308
312
|
*
|
|
313
|
+
* When set to `true`, it will enable all formatters.
|
|
314
|
+
*
|
|
309
315
|
* @default false
|
|
310
316
|
*/
|
|
311
|
-
formatters?: OptionsFormatters;
|
|
317
|
+
formatters?: boolean | OptionsFormatters;
|
|
312
318
|
/**
|
|
313
319
|
* Control to disable some rules in editors.
|
|
314
320
|
* @default auto-detect based on the process.env
|
|
@@ -357,7 +363,7 @@ declare function node(): Promise<FlatConfigItem[]>;
|
|
|
357
363
|
*/
|
|
358
364
|
declare function perfectionist(): Promise<FlatConfigItem[]>;
|
|
359
365
|
|
|
360
|
-
declare function formatters(options?: OptionsFormatters, stylistic?: StylisticConfig): Promise<FlatConfigItem[]>;
|
|
366
|
+
declare function formatters(options?: OptionsFormatters | true, stylistic?: StylisticConfig): Promise<FlatConfigItem[]>;
|
|
361
367
|
|
|
362
368
|
declare function react(options?: OptionsHasTypeScript & OptionsOverrides & OptionsFiles): Promise<FlatConfigItem[]>;
|
|
363
369
|
|
package/dist/index.js
CHANGED
|
@@ -517,8 +517,16 @@ async function markdown(options = {}, formatMarkdown = false) {
|
|
|
517
517
|
} = options;
|
|
518
518
|
const markdown2 = await interopDefault(import("eslint-plugin-markdown"));
|
|
519
519
|
const baseProcessor = markdown2.processors.markdown;
|
|
520
|
-
const processor = !formatMarkdown ?
|
|
521
|
-
|
|
520
|
+
const processor = !formatMarkdown ? {
|
|
521
|
+
meta: {
|
|
522
|
+
name: "markdown-processor"
|
|
523
|
+
},
|
|
524
|
+
supportsAutofix: true,
|
|
525
|
+
...baseProcessor
|
|
526
|
+
} : {
|
|
527
|
+
meta: {
|
|
528
|
+
name: "markdown-processor-with-content"
|
|
529
|
+
},
|
|
522
530
|
postprocess(messages, filename) {
|
|
523
531
|
const markdownContent = messages.pop();
|
|
524
532
|
const codeSnippets = baseProcessor.postprocess(messages, filename);
|
|
@@ -536,7 +544,8 @@ async function markdown(options = {}, formatMarkdown = false) {
|
|
|
536
544
|
text
|
|
537
545
|
}
|
|
538
546
|
];
|
|
539
|
-
}
|
|
547
|
+
},
|
|
548
|
+
supportsAutofix: true
|
|
540
549
|
};
|
|
541
550
|
return [
|
|
542
551
|
{
|
|
@@ -696,6 +705,15 @@ async function formatters(options = {}, stylistic2 = {}) {
|
|
|
696
705
|
await ensurePackages([
|
|
697
706
|
"eslint-plugin-format"
|
|
698
707
|
]);
|
|
708
|
+
if (options === true) {
|
|
709
|
+
options = {
|
|
710
|
+
css: true,
|
|
711
|
+
graphql: true,
|
|
712
|
+
html: true,
|
|
713
|
+
markdown: true,
|
|
714
|
+
toml: true
|
|
715
|
+
};
|
|
716
|
+
}
|
|
699
717
|
const {
|
|
700
718
|
indent,
|
|
701
719
|
quotes,
|
|
@@ -842,6 +860,24 @@ async function formatters(options = {}, stylistic2 = {}) {
|
|
|
842
860
|
}
|
|
843
861
|
});
|
|
844
862
|
}
|
|
863
|
+
if (options.graphql) {
|
|
864
|
+
configs.push({
|
|
865
|
+
files: ["**/*.graphql"],
|
|
866
|
+
languageOptions: {
|
|
867
|
+
parser: pluginFormat.parserPlain
|
|
868
|
+
},
|
|
869
|
+
name: "antfu:formatter:graphql",
|
|
870
|
+
rules: {
|
|
871
|
+
"format/prettier": [
|
|
872
|
+
"error",
|
|
873
|
+
{
|
|
874
|
+
...prettierOptions,
|
|
875
|
+
parser: "graphql"
|
|
876
|
+
}
|
|
877
|
+
]
|
|
878
|
+
}
|
|
879
|
+
});
|
|
880
|
+
}
|
|
845
881
|
return configs;
|
|
846
882
|
}
|
|
847
883
|
|
|
@@ -1708,7 +1744,7 @@ async function antfu(options = {}, ...userConfigs) {
|
|
|
1708
1744
|
componentExts,
|
|
1709
1745
|
overrides: overrides.markdown
|
|
1710
1746
|
},
|
|
1711
|
-
!!options.formatters?.markdown
|
|
1747
|
+
options.formatters === true || !!(options.formatters || {})?.markdown
|
|
1712
1748
|
)
|
|
1713
1749
|
);
|
|
1714
1750
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antfu/eslint-config",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.3.
|
|
4
|
+
"version": "2.3.2",
|
|
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/)",
|
|
@@ -56,8 +56,8 @@
|
|
|
56
56
|
"@eslint-types/typescript-eslint": "^6.12.0",
|
|
57
57
|
"@eslint-types/unicorn": "^49.0.0",
|
|
58
58
|
"@stylistic/eslint-plugin": "^1.5.0-beta.0",
|
|
59
|
-
"@typescript-eslint/eslint-plugin": "^6.13.
|
|
60
|
-
"@typescript-eslint/parser": "^6.13.
|
|
59
|
+
"@typescript-eslint/eslint-plugin": "^6.13.2",
|
|
60
|
+
"@typescript-eslint/parser": "^6.13.2",
|
|
61
61
|
"eslint-config-flat-gitignore": "^0.1.2",
|
|
62
62
|
"eslint-plugin-antfu": "^2.0.0",
|
|
63
63
|
"eslint-plugin-eslint-comments": "^3.2.0",
|
|
@@ -109,8 +109,8 @@
|
|
|
109
109
|
"simple-git-hooks": "^2.9.0",
|
|
110
110
|
"tsup": "^8.0.1",
|
|
111
111
|
"typescript": "^5.3.2",
|
|
112
|
-
"vitest": "^0.
|
|
113
|
-
"@antfu/eslint-config": "2.3.
|
|
112
|
+
"vitest": "^1.0.1",
|
|
113
|
+
"@antfu/eslint-config": "2.3.2"
|
|
114
114
|
},
|
|
115
115
|
"simple-git-hooks": {
|
|
116
116
|
"pre-commit": "pnpm lint-staged"
|