@antfu/eslint-config 2.4.4 → 2.4.6

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 CHANGED
@@ -5,14 +5,14 @@
5
5
  - Single quotes, no semi
6
6
  - Auto fix for formatting (aimed to be used standalone **without** Prettier)
7
7
  - Designed to work with TypeScript, JSX, Vue out-of-box
8
- - Lints also for json, yaml, markdown
8
+ - Lints also for json, yaml, toml, markdown
9
9
  - Sorted imports, dangling commas
10
10
  - Reasonable defaults, best practices, only one-line of config
11
11
  - Opinionated, but [very customizable](#customization)
12
12
  - [ESLint Flat config](https://eslint.org/docs/latest/use/configure/configuration-files-new), compose easily!
13
13
  - Using [ESLint Stylistic](https://github.com/eslint-stylistic/eslint-stylistic)
14
14
  - Respects `.gitignore` by default
15
- - Optional [formatters](#formatters) support for CSS, HTML, TOML, etc.
15
+ - Optional [formatters](#formatters) support for CSS, HTML, etc.
16
16
  - **Style principle**: Minimal for reading, stable for diff, consistent
17
17
 
18
18
  > [!IMPORTANT]
@@ -146,7 +146,8 @@ Add the following settings to your `.vscode/settings.json`:
146
146
  "markdown",
147
147
  "json",
148
148
  "jsonc",
149
- "yaml"
149
+ "yaml",
150
+ "toml"
150
151
  ]
151
152
  }
152
153
  ```
@@ -241,6 +242,7 @@ import {
241
242
  sortPackageJson,
242
243
  sortTsconfig,
243
244
  stylistic,
245
+ toml,
244
246
  typescript,
245
247
  unicorn,
246
248
  vue,
@@ -260,6 +262,7 @@ export default combine(
260
262
  vue(),
261
263
  jsonc(),
262
264
  yaml(),
265
+ toml(),
263
266
  markdown(),
264
267
  )
265
268
  ```
@@ -365,11 +368,6 @@ export default antfu({
365
368
  * By default uses Prettier
366
369
  */
367
370
  html: true,
368
- /**
369
- * Format TOML files
370
- * Currently only supports dprint
371
- */
372
- toml: 'dprint',
373
371
  /**
374
372
  * Format Markdown files
375
373
  * Supports Prettier and dprint
@@ -531,7 +529,7 @@ Well, you can still use Prettier to format files that are not supported well by
531
529
 
532
530
  [dprint](https://dprint.dev/) is also a great formatter that with more abilities to customize. However, it's in the same model as Prettier which reads the AST and reprints the code from scratch. This means it's similar to Prettier, which ignores the original line breaks and might also cause the inconsistent diff. So in general, we prefer to use ESLint to format and lint JavaScript/TypeScript code.
533
531
 
534
- Meanwhile, we do have dprint integrations for formatting other files such as `.toml` and `.md`. See [formatters](#formatters) for more details.
532
+ Meanwhile, we do have dprint integrations for formatting other files such as `.md`. See [formatters](#formatters) for more details.
535
533
 
536
534
  ### How to format CSS?
537
535
 
package/dist/cli.cjs CHANGED
@@ -46,13 +46,13 @@ 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.4.4";
49
+ var version = "2.4.6";
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.5.0",
55
- "@types/eslint": "^8.44.8",
54
+ "@stylistic/eslint-plugin-migrate": "^1.5.1",
55
+ "@types/eslint": "^8.44.9",
56
56
  "@types/fs-extra": "^11.0.4",
57
57
  "@types/node": "^20.10.4",
58
58
  "@types/prompts": "^2.4.9",
@@ -124,7 +124,8 @@ var vscodeSettingsString = `
124
124
  "markdown",
125
125
  "json",
126
126
  "jsonc",
127
- "yaml"
127
+ "yaml",
128
+ "toml"
128
129
  ]
129
130
  `;
130
131
 
package/dist/cli.js CHANGED
@@ -17,13 +17,13 @@ import parse from "parse-gitignore";
17
17
  import c from "picocolors";
18
18
 
19
19
  // package.json
20
- var version = "2.4.4";
20
+ var version = "2.4.6";
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.5.0",
26
- "@types/eslint": "^8.44.8",
25
+ "@stylistic/eslint-plugin-migrate": "^1.5.1",
26
+ "@types/eslint": "^8.44.9",
27
27
  "@types/fs-extra": "^11.0.4",
28
28
  "@types/node": "^20.10.4",
29
29
  "@types/prompts": "^2.4.9",
@@ -95,7 +95,8 @@ var vscodeSettingsString = `
95
95
  "markdown",
96
96
  "json",
97
97
  "jsonc",
98
- "yaml"
98
+ "yaml",
99
+ "toml"
99
100
  ]
100
101
  `;
101
102
 
package/dist/index.cjs CHANGED
@@ -49,6 +49,7 @@ __export(src_exports, {
49
49
  GLOB_SRC_EXT: () => GLOB_SRC_EXT,
50
50
  GLOB_STYLE: () => GLOB_STYLE,
51
51
  GLOB_TESTS: () => GLOB_TESTS,
52
+ GLOB_TOML: () => GLOB_TOML,
52
53
  GLOB_TS: () => GLOB_TS,
53
54
  GLOB_TSX: () => GLOB_TSX,
54
55
  GLOB_VUE: () => GLOB_VUE,
@@ -68,6 +69,7 @@ __export(src_exports, {
68
69
  jsonc: () => jsonc,
69
70
  markdown: () => markdown,
70
71
  node: () => node,
72
+ parserPlain: () => parserPlain,
71
73
  perfectionist: () => perfectionist,
72
74
  react: () => react,
73
75
  renameRules: () => renameRules,
@@ -76,6 +78,7 @@ __export(src_exports, {
76
78
  stylistic: () => stylistic,
77
79
  test: () => test,
78
80
  toArray: () => toArray,
81
+ toml: () => toml,
79
82
  typescript: () => typescript,
80
83
  unicorn: () => unicorn,
81
84
  unocss: () => unocss,
@@ -135,6 +138,7 @@ var GLOB_MARKDOWN = "**/*.md";
135
138
  var GLOB_MARKDOWN_IN_MARKDOWN = "**/*.md/*.md";
136
139
  var GLOB_VUE = "**/*.vue";
137
140
  var GLOB_YAML = "**/*.y?(a)ml";
141
+ var GLOB_TOML = "**/*.toml";
138
142
  var GLOB_HTML = "**/*.htm?(l)";
139
143
  var GLOB_MARKDOWN_CODE = `${GLOB_MARKDOWN}/${GLOB_SRC}`;
140
144
  var GLOB_TESTS = [
@@ -444,6 +448,26 @@ async function javascript(options = {}) {
444
448
  // src/utils.ts
445
449
  var import_node_process = __toESM(require("process"), 1);
446
450
  var import_local_pkg = require("local-pkg");
451
+ var parserPlain = {
452
+ meta: {
453
+ name: "parser-plain"
454
+ },
455
+ parseForESLint: (code) => ({
456
+ ast: {
457
+ body: [],
458
+ comments: [],
459
+ loc: { end: code.length, start: 0 },
460
+ range: [0, code.length],
461
+ tokens: [],
462
+ type: "Program"
463
+ },
464
+ scopeManager: null,
465
+ services: { isPlain: true },
466
+ visitorKeys: {
467
+ Program: []
468
+ }
469
+ })
470
+ };
447
471
  async function combine(...configs) {
448
472
  const resolved = await Promise.all(configs);
449
473
  return resolved.flat();
@@ -595,7 +619,6 @@ async function jsonc(options = {}) {
595
619
  }
596
620
 
597
621
  // src/configs/markdown.ts
598
- var parserPlain = __toESM(require("eslint-parser-plain"), 1);
599
622
  var import_eslint_merge_processors = require("eslint-merge-processors");
600
623
  async function markdown(options = {}) {
601
624
  const {
@@ -726,9 +749,6 @@ async function perfectionist() {
726
749
  ];
727
750
  }
728
751
 
729
- // src/configs/formatters.ts
730
- var parserPlain2 = __toESM(require("eslint-parser-plain"), 1);
731
-
732
752
  // src/configs/stylistic.ts
733
753
  var StylisticConfigDefaults = {
734
754
  indent: 2,
@@ -783,8 +803,7 @@ async function formatters(options = {}, stylistic2 = {}) {
783
803
  css: true,
784
804
  graphql: true,
785
805
  html: true,
786
- markdown: true,
787
- toml: true
806
+ markdown: true
788
807
  };
789
808
  }
790
809
  const {
@@ -828,7 +847,7 @@ async function formatters(options = {}, stylistic2 = {}) {
828
847
  {
829
848
  files: [GLOB_CSS, GLOB_POSTCSS],
830
849
  languageOptions: {
831
- parser: parserPlain2
850
+ parser: parserPlain
832
851
  },
833
852
  name: "antfu:formatter:css",
834
853
  rules: {
@@ -844,7 +863,7 @@ async function formatters(options = {}, stylistic2 = {}) {
844
863
  {
845
864
  files: [GLOB_SCSS],
846
865
  languageOptions: {
847
- parser: parserPlain2
866
+ parser: parserPlain
848
867
  },
849
868
  name: "antfu:formatter:scss",
850
869
  rules: {
@@ -860,7 +879,7 @@ async function formatters(options = {}, stylistic2 = {}) {
860
879
  {
861
880
  files: [GLOB_LESS],
862
881
  languageOptions: {
863
- parser: parserPlain2
882
+ parser: parserPlain
864
883
  },
865
884
  name: "antfu:formatter:less",
866
885
  rules: {
@@ -879,7 +898,7 @@ async function formatters(options = {}, stylistic2 = {}) {
879
898
  configs.push({
880
899
  files: ["**/*.html"],
881
900
  languageOptions: {
882
- parser: parserPlain2
901
+ parser: parserPlain
883
902
  },
884
903
  name: "antfu:formatter:html",
885
904
  rules: {
@@ -893,30 +912,12 @@ async function formatters(options = {}, stylistic2 = {}) {
893
912
  }
894
913
  });
895
914
  }
896
- if (options.toml) {
897
- configs.push({
898
- files: ["**/*.toml"],
899
- languageOptions: {
900
- parser: parserPlain2
901
- },
902
- name: "antfu:formatter:toml",
903
- rules: {
904
- "format/dprint": [
905
- "error",
906
- {
907
- ...dprintOptions,
908
- language: "toml"
909
- }
910
- ]
911
- }
912
- });
913
- }
914
915
  if (options.markdown) {
915
916
  const formater = options.markdown === true ? "prettier" : options.markdown;
916
917
  configs.push({
917
918
  files: [GLOB_MARKDOWN],
918
919
  languageOptions: {
919
- parser: parserPlain2
920
+ parser: parserPlain
920
921
  },
921
922
  name: "antfu:formatter:markdown",
922
923
  rules: {
@@ -938,7 +939,7 @@ async function formatters(options = {}, stylistic2 = {}) {
938
939
  configs.push({
939
940
  files: ["**/*.graphql"],
940
941
  languageOptions: {
941
- parser: parserPlain2
942
+ parser: parserPlain
942
943
  },
943
944
  name: "antfu:formatter:graphql",
944
945
  rules: {
@@ -1116,15 +1117,11 @@ async function sortPackageJson() {
1116
1117
  },
1117
1118
  {
1118
1119
  order: { type: "asc" },
1119
- pathPattern: "^(?:dev|peer|optional|bundled)?[Dd]ependencies$"
1120
- },
1121
- {
1122
- order: { type: "asc" },
1123
- pathPattern: "^resolutions$"
1120
+ pathPattern: "^(?:dev|peer|optional|bundled)?[Dd]ependencies(Meta)?$"
1124
1121
  },
1125
1122
  {
1126
1123
  order: { type: "asc" },
1127
- pathPattern: "^pnpm.overrides$"
1124
+ pathPattern: "^(?:resolutions|overrides|pnpm.overrides)$"
1128
1125
  },
1129
1126
  {
1130
1127
  order: [
@@ -1302,6 +1299,7 @@ async function test(options = {}) {
1302
1299
  "node/prefer-global/process": "off",
1303
1300
  "test/consistent-test-it": ["error", { fn: "it", withinDescribe: "it" }],
1304
1301
  "test/no-identical-title": "error",
1302
+ "test/no-import-node-test": "error",
1305
1303
  "test/no-only-tests": isInEditor ? "off" : "error",
1306
1304
  "test/prefer-hooks-in-order": "error",
1307
1305
  "test/prefer-lowercase-title": "error",
@@ -1722,6 +1720,65 @@ async function yaml(options = {}) {
1722
1720
  ];
1723
1721
  }
1724
1722
 
1723
+ // src/configs/toml.ts
1724
+ async function toml(options = {}) {
1725
+ const {
1726
+ files = [GLOB_TOML],
1727
+ overrides = {},
1728
+ stylistic: stylistic2 = true
1729
+ } = options;
1730
+ const {
1731
+ indent = 2
1732
+ } = typeof stylistic2 === "boolean" ? {} : stylistic2;
1733
+ const [
1734
+ pluginToml,
1735
+ parserToml
1736
+ ] = await Promise.all([
1737
+ interopDefault(import("eslint-plugin-toml")),
1738
+ interopDefault(import("toml-eslint-parser"))
1739
+ ]);
1740
+ return [
1741
+ {
1742
+ name: "antfu:toml:setup",
1743
+ plugins: {
1744
+ toml: pluginToml
1745
+ }
1746
+ },
1747
+ {
1748
+ files,
1749
+ languageOptions: {
1750
+ parser: parserToml
1751
+ },
1752
+ name: "antfu:toml:rules",
1753
+ rules: {
1754
+ "style/spaced-comment": "off",
1755
+ "toml/comma-style": "error",
1756
+ "toml/keys-order": "error",
1757
+ "toml/no-space-dots": "error",
1758
+ "toml/no-unreadable-number-separator": "error",
1759
+ "toml/precision-of-fractional-seconds": "error",
1760
+ "toml/precision-of-integer": "error",
1761
+ "toml/tables-order": "error",
1762
+ "toml/vue-custom-block/no-parsing-error": "error",
1763
+ ...stylistic2 ? {
1764
+ "toml/array-bracket-newline": "error",
1765
+ "toml/array-bracket-spacing": "error",
1766
+ "toml/array-element-newline": "error",
1767
+ "toml/indent": ["error", indent === "tab" ? 2 : indent],
1768
+ "toml/inline-table-curly-spacing": "error",
1769
+ "toml/key-spacing": "error",
1770
+ "toml/padding-line-between-pairs": "error",
1771
+ "toml/padding-line-between-tables": "error",
1772
+ "toml/quoted-keys": "error",
1773
+ "toml/spaced-comment": "error",
1774
+ "toml/table-bracket-spacing": "error"
1775
+ } : {},
1776
+ ...overrides
1777
+ }
1778
+ }
1779
+ ];
1780
+ }
1781
+
1725
1782
  // src/factory.ts
1726
1783
  var flatConfigProps = [
1727
1784
  "files",
@@ -1832,6 +1889,12 @@ async function antfu(options = {}, ...userConfigs) {
1832
1889
  stylistic: stylisticOptions
1833
1890
  }));
1834
1891
  }
1892
+ if (options.toml ?? true) {
1893
+ configs.push(toml({
1894
+ overrides: overrides.toml,
1895
+ stylistic: stylisticOptions
1896
+ }));
1897
+ }
1835
1898
  if (options.markdown ?? true) {
1836
1899
  configs.push(
1837
1900
  markdown(
@@ -1885,6 +1948,7 @@ var src_default = antfu;
1885
1948
  GLOB_SRC_EXT,
1886
1949
  GLOB_STYLE,
1887
1950
  GLOB_TESTS,
1951
+ GLOB_TOML,
1888
1952
  GLOB_TS,
1889
1953
  GLOB_TSX,
1890
1954
  GLOB_VUE,
@@ -1903,6 +1967,7 @@ var src_default = antfu;
1903
1967
  jsonc,
1904
1968
  markdown,
1905
1969
  node,
1970
+ parserPlain,
1906
1971
  perfectionist,
1907
1972
  react,
1908
1973
  renameRules,
@@ -1911,6 +1976,7 @@ var src_default = antfu;
1911
1976
  stylistic,
1912
1977
  test,
1913
1978
  toArray,
1979
+ toml,
1914
1980
  typescript,
1915
1981
  unicorn,
1916
1982
  unocss,
package/dist/index.d.cts CHANGED
@@ -159,12 +159,6 @@ interface OptionsFormatters {
159
159
  * Currently only support Prettier.
160
160
  */
161
161
  html?: 'prettier' | boolean;
162
- /**
163
- * Enable formatting support for TOML.
164
- *
165
- * Currently only support dprint.
166
- */
167
- toml?: 'dprint' | boolean;
168
162
  /**
169
163
  * Enable formatting support for Markdown.
170
164
  *
@@ -288,6 +282,12 @@ interface OptionsConfig extends OptionsComponentExts {
288
282
  * @default true
289
283
  */
290
284
  yaml?: boolean;
285
+ /**
286
+ * Enable TOML support.
287
+ *
288
+ * @default true
289
+ */
290
+ toml?: boolean;
291
291
  /**
292
292
  * Enable linting for **code snippets** in Markdown.
293
293
  *
@@ -349,6 +349,7 @@ interface OptionsConfig extends OptionsComponentExts {
349
349
  jsonc?: FlatConfigItem['rules'];
350
350
  markdown?: FlatConfigItem['rules'];
351
351
  yaml?: FlatConfigItem['rules'];
352
+ toml?: FlatConfigItem['rules'];
352
353
  react?: FlatConfigItem['rules'];
353
354
  };
354
355
  }
@@ -413,6 +414,8 @@ declare function vue(options?: OptionsVue & OptionsHasTypeScript & OptionsOverri
413
414
 
414
415
  declare function yaml(options?: OptionsOverrides & OptionsStylistic & OptionsFiles): Promise<FlatConfigItem[]>;
415
416
 
417
+ declare function toml(options?: OptionsOverrides & OptionsStylistic & OptionsFiles): Promise<FlatConfigItem[]>;
418
+
416
419
  declare const GLOB_SRC_EXT = "?([cm])[jt]s?(x)";
417
420
  declare const GLOB_SRC = "**/*.?([cm])[jt]s?(x)";
418
421
  declare const GLOB_JS = "**/*.?([cm])js";
@@ -431,12 +434,38 @@ declare const GLOB_MARKDOWN = "**/*.md";
431
434
  declare const GLOB_MARKDOWN_IN_MARKDOWN = "**/*.md/*.md";
432
435
  declare const GLOB_VUE = "**/*.vue";
433
436
  declare const GLOB_YAML = "**/*.y?(a)ml";
437
+ declare const GLOB_TOML = "**/*.toml";
434
438
  declare const GLOB_HTML = "**/*.htm?(l)";
435
439
  declare const GLOB_MARKDOWN_CODE = "**/*.md/**/*.?([cm])[jt]s?(x)";
436
440
  declare const GLOB_TESTS: string[];
437
441
  declare const GLOB_ALL_SRC: string[];
438
442
  declare const GLOB_EXCLUDE: string[];
439
443
 
444
+ declare const parserPlain: {
445
+ meta: {
446
+ name: string;
447
+ };
448
+ parseForESLint: (code: string) => {
449
+ ast: {
450
+ body: never[];
451
+ comments: never[];
452
+ loc: {
453
+ end: number;
454
+ start: number;
455
+ };
456
+ range: number[];
457
+ tokens: never[];
458
+ type: string;
459
+ };
460
+ scopeManager: null;
461
+ services: {
462
+ isPlain: boolean;
463
+ };
464
+ visitorKeys: {
465
+ Program: never[];
466
+ };
467
+ };
468
+ };
440
469
  /**
441
470
  * Combine array and non-array configs into a single array.
442
471
  */
@@ -450,4 +479,4 @@ declare function interopDefault<T>(m: Awaitable<T>): Promise<T extends {
450
479
  } ? U : T>;
451
480
  declare function ensurePackages(packages: string[]): Promise<void>;
452
481
 
453
- 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 OptionsVue, type Rules, type StylisticConfig, StylisticConfigDefaults, type UserConfigItem, type WrapRuleConfig, antfu, combine, comments, antfu as default, ensurePackages, formatters, ignores, imports, interopDefault, javascript, jsdoc, jsonc, markdown, node, perfectionist, react, renameRules, sortPackageJson, sortTsconfig, stylistic, test, toArray, typescript, unicorn, unocss, vue, yaml };
482
+ export { type Awaitable, type FlatConfigItem, GLOB_ALL_SRC, GLOB_CSS, GLOB_EXCLUDE, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_LESS, GLOB_MARKDOWN, GLOB_MARKDOWN_CODE, GLOB_MARKDOWN_IN_MARKDOWN, GLOB_POSTCSS, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLE, GLOB_TESTS, GLOB_TOML, GLOB_TS, GLOB_TSX, GLOB_VUE, GLOB_YAML, type OptionsComponentExts, type OptionsConfig, type OptionsFiles, type OptionsFormatters, type OptionsHasTypeScript, type OptionsIsInEditor, type OptionsOverrides, type OptionsStylistic, type OptionsTypeScriptParserOptions, type OptionsTypeScriptWithTypes, type OptionsUnoCSS, type OptionsVue, type Rules, type StylisticConfig, StylisticConfigDefaults, type UserConfigItem, type WrapRuleConfig, antfu, combine, comments, antfu as default, ensurePackages, formatters, ignores, imports, interopDefault, javascript, jsdoc, jsonc, markdown, node, parserPlain, perfectionist, react, renameRules, sortPackageJson, sortTsconfig, stylistic, test, toArray, toml, typescript, unicorn, unocss, vue, yaml };
package/dist/index.d.ts CHANGED
@@ -159,12 +159,6 @@ interface OptionsFormatters {
159
159
  * Currently only support Prettier.
160
160
  */
161
161
  html?: 'prettier' | boolean;
162
- /**
163
- * Enable formatting support for TOML.
164
- *
165
- * Currently only support dprint.
166
- */
167
- toml?: 'dprint' | boolean;
168
162
  /**
169
163
  * Enable formatting support for Markdown.
170
164
  *
@@ -288,6 +282,12 @@ interface OptionsConfig extends OptionsComponentExts {
288
282
  * @default true
289
283
  */
290
284
  yaml?: boolean;
285
+ /**
286
+ * Enable TOML support.
287
+ *
288
+ * @default true
289
+ */
290
+ toml?: boolean;
291
291
  /**
292
292
  * Enable linting for **code snippets** in Markdown.
293
293
  *
@@ -349,6 +349,7 @@ interface OptionsConfig extends OptionsComponentExts {
349
349
  jsonc?: FlatConfigItem['rules'];
350
350
  markdown?: FlatConfigItem['rules'];
351
351
  yaml?: FlatConfigItem['rules'];
352
+ toml?: FlatConfigItem['rules'];
352
353
  react?: FlatConfigItem['rules'];
353
354
  };
354
355
  }
@@ -413,6 +414,8 @@ declare function vue(options?: OptionsVue & OptionsHasTypeScript & OptionsOverri
413
414
 
414
415
  declare function yaml(options?: OptionsOverrides & OptionsStylistic & OptionsFiles): Promise<FlatConfigItem[]>;
415
416
 
417
+ declare function toml(options?: OptionsOverrides & OptionsStylistic & OptionsFiles): Promise<FlatConfigItem[]>;
418
+
416
419
  declare const GLOB_SRC_EXT = "?([cm])[jt]s?(x)";
417
420
  declare const GLOB_SRC = "**/*.?([cm])[jt]s?(x)";
418
421
  declare const GLOB_JS = "**/*.?([cm])js";
@@ -431,12 +434,38 @@ declare const GLOB_MARKDOWN = "**/*.md";
431
434
  declare const GLOB_MARKDOWN_IN_MARKDOWN = "**/*.md/*.md";
432
435
  declare const GLOB_VUE = "**/*.vue";
433
436
  declare const GLOB_YAML = "**/*.y?(a)ml";
437
+ declare const GLOB_TOML = "**/*.toml";
434
438
  declare const GLOB_HTML = "**/*.htm?(l)";
435
439
  declare const GLOB_MARKDOWN_CODE = "**/*.md/**/*.?([cm])[jt]s?(x)";
436
440
  declare const GLOB_TESTS: string[];
437
441
  declare const GLOB_ALL_SRC: string[];
438
442
  declare const GLOB_EXCLUDE: string[];
439
443
 
444
+ declare const parserPlain: {
445
+ meta: {
446
+ name: string;
447
+ };
448
+ parseForESLint: (code: string) => {
449
+ ast: {
450
+ body: never[];
451
+ comments: never[];
452
+ loc: {
453
+ end: number;
454
+ start: number;
455
+ };
456
+ range: number[];
457
+ tokens: never[];
458
+ type: string;
459
+ };
460
+ scopeManager: null;
461
+ services: {
462
+ isPlain: boolean;
463
+ };
464
+ visitorKeys: {
465
+ Program: never[];
466
+ };
467
+ };
468
+ };
440
469
  /**
441
470
  * Combine array and non-array configs into a single array.
442
471
  */
@@ -450,4 +479,4 @@ declare function interopDefault<T>(m: Awaitable<T>): Promise<T extends {
450
479
  } ? U : T>;
451
480
  declare function ensurePackages(packages: string[]): Promise<void>;
452
481
 
453
- 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 OptionsVue, type Rules, type StylisticConfig, StylisticConfigDefaults, type UserConfigItem, type WrapRuleConfig, antfu, combine, comments, antfu as default, ensurePackages, formatters, ignores, imports, interopDefault, javascript, jsdoc, jsonc, markdown, node, perfectionist, react, renameRules, sortPackageJson, sortTsconfig, stylistic, test, toArray, typescript, unicorn, unocss, vue, yaml };
482
+ export { type Awaitable, type FlatConfigItem, GLOB_ALL_SRC, GLOB_CSS, GLOB_EXCLUDE, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_LESS, GLOB_MARKDOWN, GLOB_MARKDOWN_CODE, GLOB_MARKDOWN_IN_MARKDOWN, GLOB_POSTCSS, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLE, GLOB_TESTS, GLOB_TOML, GLOB_TS, GLOB_TSX, GLOB_VUE, GLOB_YAML, type OptionsComponentExts, type OptionsConfig, type OptionsFiles, type OptionsFormatters, type OptionsHasTypeScript, type OptionsIsInEditor, type OptionsOverrides, type OptionsStylistic, type OptionsTypeScriptParserOptions, type OptionsTypeScriptWithTypes, type OptionsUnoCSS, type OptionsVue, type Rules, type StylisticConfig, StylisticConfigDefaults, type UserConfigItem, type WrapRuleConfig, antfu, combine, comments, antfu as default, ensurePackages, formatters, ignores, imports, interopDefault, javascript, jsdoc, jsonc, markdown, node, parserPlain, perfectionist, react, renameRules, sortPackageJson, sortTsconfig, stylistic, test, toArray, toml, typescript, unicorn, unocss, vue, yaml };
package/dist/index.js CHANGED
@@ -49,6 +49,7 @@ var GLOB_MARKDOWN = "**/*.md";
49
49
  var GLOB_MARKDOWN_IN_MARKDOWN = "**/*.md/*.md";
50
50
  var GLOB_VUE = "**/*.vue";
51
51
  var GLOB_YAML = "**/*.y?(a)ml";
52
+ var GLOB_TOML = "**/*.toml";
52
53
  var GLOB_HTML = "**/*.htm?(l)";
53
54
  var GLOB_MARKDOWN_CODE = `${GLOB_MARKDOWN}/${GLOB_SRC}`;
54
55
  var GLOB_TESTS = [
@@ -358,6 +359,26 @@ async function javascript(options = {}) {
358
359
  // src/utils.ts
359
360
  import process from "process";
360
361
  import { isPackageExists } from "local-pkg";
362
+ var parserPlain = {
363
+ meta: {
364
+ name: "parser-plain"
365
+ },
366
+ parseForESLint: (code) => ({
367
+ ast: {
368
+ body: [],
369
+ comments: [],
370
+ loc: { end: code.length, start: 0 },
371
+ range: [0, code.length],
372
+ tokens: [],
373
+ type: "Program"
374
+ },
375
+ scopeManager: null,
376
+ services: { isPlain: true },
377
+ visitorKeys: {
378
+ Program: []
379
+ }
380
+ })
381
+ };
361
382
  async function combine(...configs) {
362
383
  const resolved = await Promise.all(configs);
363
384
  return resolved.flat();
@@ -509,7 +530,6 @@ async function jsonc(options = {}) {
509
530
  }
510
531
 
511
532
  // src/configs/markdown.ts
512
- import * as parserPlain from "eslint-parser-plain";
513
533
  import { mergeProcessors, processorPassThrough } from "eslint-merge-processors";
514
534
  async function markdown(options = {}) {
515
535
  const {
@@ -640,9 +660,6 @@ async function perfectionist() {
640
660
  ];
641
661
  }
642
662
 
643
- // src/configs/formatters.ts
644
- import * as parserPlain2 from "eslint-parser-plain";
645
-
646
663
  // src/configs/stylistic.ts
647
664
  var StylisticConfigDefaults = {
648
665
  indent: 2,
@@ -697,8 +714,7 @@ async function formatters(options = {}, stylistic2 = {}) {
697
714
  css: true,
698
715
  graphql: true,
699
716
  html: true,
700
- markdown: true,
701
- toml: true
717
+ markdown: true
702
718
  };
703
719
  }
704
720
  const {
@@ -742,7 +758,7 @@ async function formatters(options = {}, stylistic2 = {}) {
742
758
  {
743
759
  files: [GLOB_CSS, GLOB_POSTCSS],
744
760
  languageOptions: {
745
- parser: parserPlain2
761
+ parser: parserPlain
746
762
  },
747
763
  name: "antfu:formatter:css",
748
764
  rules: {
@@ -758,7 +774,7 @@ async function formatters(options = {}, stylistic2 = {}) {
758
774
  {
759
775
  files: [GLOB_SCSS],
760
776
  languageOptions: {
761
- parser: parserPlain2
777
+ parser: parserPlain
762
778
  },
763
779
  name: "antfu:formatter:scss",
764
780
  rules: {
@@ -774,7 +790,7 @@ async function formatters(options = {}, stylistic2 = {}) {
774
790
  {
775
791
  files: [GLOB_LESS],
776
792
  languageOptions: {
777
- parser: parserPlain2
793
+ parser: parserPlain
778
794
  },
779
795
  name: "antfu:formatter:less",
780
796
  rules: {
@@ -793,7 +809,7 @@ async function formatters(options = {}, stylistic2 = {}) {
793
809
  configs.push({
794
810
  files: ["**/*.html"],
795
811
  languageOptions: {
796
- parser: parserPlain2
812
+ parser: parserPlain
797
813
  },
798
814
  name: "antfu:formatter:html",
799
815
  rules: {
@@ -807,30 +823,12 @@ async function formatters(options = {}, stylistic2 = {}) {
807
823
  }
808
824
  });
809
825
  }
810
- if (options.toml) {
811
- configs.push({
812
- files: ["**/*.toml"],
813
- languageOptions: {
814
- parser: parserPlain2
815
- },
816
- name: "antfu:formatter:toml",
817
- rules: {
818
- "format/dprint": [
819
- "error",
820
- {
821
- ...dprintOptions,
822
- language: "toml"
823
- }
824
- ]
825
- }
826
- });
827
- }
828
826
  if (options.markdown) {
829
827
  const formater = options.markdown === true ? "prettier" : options.markdown;
830
828
  configs.push({
831
829
  files: [GLOB_MARKDOWN],
832
830
  languageOptions: {
833
- parser: parserPlain2
831
+ parser: parserPlain
834
832
  },
835
833
  name: "antfu:formatter:markdown",
836
834
  rules: {
@@ -852,7 +850,7 @@ async function formatters(options = {}, stylistic2 = {}) {
852
850
  configs.push({
853
851
  files: ["**/*.graphql"],
854
852
  languageOptions: {
855
- parser: parserPlain2
853
+ parser: parserPlain
856
854
  },
857
855
  name: "antfu:formatter:graphql",
858
856
  rules: {
@@ -1030,15 +1028,11 @@ async function sortPackageJson() {
1030
1028
  },
1031
1029
  {
1032
1030
  order: { type: "asc" },
1033
- pathPattern: "^(?:dev|peer|optional|bundled)?[Dd]ependencies$"
1034
- },
1035
- {
1036
- order: { type: "asc" },
1037
- pathPattern: "^resolutions$"
1031
+ pathPattern: "^(?:dev|peer|optional|bundled)?[Dd]ependencies(Meta)?$"
1038
1032
  },
1039
1033
  {
1040
1034
  order: { type: "asc" },
1041
- pathPattern: "^pnpm.overrides$"
1035
+ pathPattern: "^(?:resolutions|overrides|pnpm.overrides)$"
1042
1036
  },
1043
1037
  {
1044
1038
  order: [
@@ -1216,6 +1210,7 @@ async function test(options = {}) {
1216
1210
  "node/prefer-global/process": "off",
1217
1211
  "test/consistent-test-it": ["error", { fn: "it", withinDescribe: "it" }],
1218
1212
  "test/no-identical-title": "error",
1213
+ "test/no-import-node-test": "error",
1219
1214
  "test/no-only-tests": isInEditor ? "off" : "error",
1220
1215
  "test/prefer-hooks-in-order": "error",
1221
1216
  "test/prefer-lowercase-title": "error",
@@ -1636,6 +1631,65 @@ async function yaml(options = {}) {
1636
1631
  ];
1637
1632
  }
1638
1633
 
1634
+ // src/configs/toml.ts
1635
+ async function toml(options = {}) {
1636
+ const {
1637
+ files = [GLOB_TOML],
1638
+ overrides = {},
1639
+ stylistic: stylistic2 = true
1640
+ } = options;
1641
+ const {
1642
+ indent = 2
1643
+ } = typeof stylistic2 === "boolean" ? {} : stylistic2;
1644
+ const [
1645
+ pluginToml,
1646
+ parserToml
1647
+ ] = await Promise.all([
1648
+ interopDefault(import("eslint-plugin-toml")),
1649
+ interopDefault(import("toml-eslint-parser"))
1650
+ ]);
1651
+ return [
1652
+ {
1653
+ name: "antfu:toml:setup",
1654
+ plugins: {
1655
+ toml: pluginToml
1656
+ }
1657
+ },
1658
+ {
1659
+ files,
1660
+ languageOptions: {
1661
+ parser: parserToml
1662
+ },
1663
+ name: "antfu:toml:rules",
1664
+ rules: {
1665
+ "style/spaced-comment": "off",
1666
+ "toml/comma-style": "error",
1667
+ "toml/keys-order": "error",
1668
+ "toml/no-space-dots": "error",
1669
+ "toml/no-unreadable-number-separator": "error",
1670
+ "toml/precision-of-fractional-seconds": "error",
1671
+ "toml/precision-of-integer": "error",
1672
+ "toml/tables-order": "error",
1673
+ "toml/vue-custom-block/no-parsing-error": "error",
1674
+ ...stylistic2 ? {
1675
+ "toml/array-bracket-newline": "error",
1676
+ "toml/array-bracket-spacing": "error",
1677
+ "toml/array-element-newline": "error",
1678
+ "toml/indent": ["error", indent === "tab" ? 2 : indent],
1679
+ "toml/inline-table-curly-spacing": "error",
1680
+ "toml/key-spacing": "error",
1681
+ "toml/padding-line-between-pairs": "error",
1682
+ "toml/padding-line-between-tables": "error",
1683
+ "toml/quoted-keys": "error",
1684
+ "toml/spaced-comment": "error",
1685
+ "toml/table-bracket-spacing": "error"
1686
+ } : {},
1687
+ ...overrides
1688
+ }
1689
+ }
1690
+ ];
1691
+ }
1692
+
1639
1693
  // src/factory.ts
1640
1694
  var flatConfigProps = [
1641
1695
  "files",
@@ -1746,6 +1800,12 @@ async function antfu(options = {}, ...userConfigs) {
1746
1800
  stylistic: stylisticOptions
1747
1801
  }));
1748
1802
  }
1803
+ if (options.toml ?? true) {
1804
+ configs.push(toml({
1805
+ overrides: overrides.toml,
1806
+ stylistic: stylisticOptions
1807
+ }));
1808
+ }
1749
1809
  if (options.markdown ?? true) {
1750
1810
  configs.push(
1751
1811
  markdown(
@@ -1798,6 +1858,7 @@ export {
1798
1858
  GLOB_SRC_EXT,
1799
1859
  GLOB_STYLE,
1800
1860
  GLOB_TESTS,
1861
+ GLOB_TOML,
1801
1862
  GLOB_TS,
1802
1863
  GLOB_TSX,
1803
1864
  GLOB_VUE,
@@ -1817,6 +1878,7 @@ export {
1817
1878
  jsonc,
1818
1879
  markdown,
1819
1880
  node,
1881
+ parserPlain,
1820
1882
  perfectionist,
1821
1883
  react,
1822
1884
  renameRules,
@@ -1825,6 +1887,7 @@ export {
1825
1887
  stylistic,
1826
1888
  test,
1827
1889
  toArray,
1890
+ toml,
1828
1891
  typescript,
1829
1892
  unicorn,
1830
1893
  unocss,
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@antfu/eslint-config",
3
3
  "type": "module",
4
- "version": "2.4.4",
5
- "packageManager": "pnpm@8.12.0",
4
+ "version": "2.4.6",
5
+ "packageManager": "pnpm@8.12.1",
6
6
  "description": "Anthony's ESLint config",
7
7
  "author": "Anthony Fu <anthonyfu117@hotmail.com> (https://github.com/antfu/)",
8
8
  "license": "MIT",
@@ -33,10 +33,10 @@
33
33
  "eslint-plugin-react-refresh": "^0.4.4"
34
34
  },
35
35
  "peerDependenciesMeta": {
36
- "eslint-plugin-format": {
36
+ "@unocss/eslint-plugin": {
37
37
  "optional": true
38
38
  },
39
- "@unocss/eslint-plugin": {
39
+ "eslint-plugin-format": {
40
40
  "optional": true
41
41
  },
42
42
  "eslint-plugin-react": {
@@ -55,26 +55,26 @@
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.5.0",
59
- "@typescript-eslint/eslint-plugin": "^6.13.2",
60
- "@typescript-eslint/parser": "^6.13.2",
58
+ "@stylistic/eslint-plugin": "^1.5.1",
59
+ "@typescript-eslint/eslint-plugin": "^6.14.0",
60
+ "@typescript-eslint/parser": "^6.14.0",
61
61
  "eslint-config-flat-gitignore": "^0.1.2",
62
62
  "eslint-merge-processors": "^0.1.0",
63
- "eslint-parser-plain": "^0.1.0",
64
63
  "eslint-plugin-antfu": "^2.0.0",
65
64
  "eslint-plugin-eslint-comments": "^3.2.0",
66
65
  "eslint-plugin-i": "^2.29.0",
67
- "eslint-plugin-jsdoc": "^46.9.0",
68
- "eslint-plugin-jsonc": "^2.10.0",
66
+ "eslint-plugin-jsdoc": "^46.9.1",
67
+ "eslint-plugin-jsonc": "^2.11.1",
69
68
  "eslint-plugin-markdown": "^3.0.1",
70
- "eslint-plugin-n": "^16.3.1",
69
+ "eslint-plugin-n": "^16.4.0",
71
70
  "eslint-plugin-no-only-tests": "^3.1.0",
72
71
  "eslint-plugin-perfectionist": "^2.5.0",
72
+ "eslint-plugin-toml": "^0.8.0",
73
73
  "eslint-plugin-unicorn": "^49.0.0",
74
74
  "eslint-plugin-unused-imports": "^3.0.0",
75
- "eslint-plugin-vitest": "^0.3.13",
75
+ "eslint-plugin-vitest": "^0.3.17",
76
76
  "eslint-plugin-vue": "^9.19.2",
77
- "eslint-plugin-yml": "^1.10.0",
77
+ "eslint-plugin-yml": "^1.11.0",
78
78
  "eslint-processor-vue-blocks": "^0.1.1",
79
79
  "globals": "^13.24.0",
80
80
  "jsonc-eslint-parser": "^2.4.0",
@@ -82,6 +82,7 @@
82
82
  "parse-gitignore": "^2.0.0",
83
83
  "picocolors": "^1.0.0",
84
84
  "prompts": "^2.4.2",
85
+ "toml-eslint-parser": "^0.9.3",
85
86
  "vue-eslint-parser": "^9.3.2",
86
87
  "yaml-eslint-parser": "^1.2.2",
87
88
  "yargs": "^17.7.2"
@@ -89,8 +90,8 @@
89
90
  "devDependencies": {
90
91
  "@antfu/eslint-plugin-prettier": "^5.0.1-1",
91
92
  "@antfu/ni": "^0.21.12",
92
- "@stylistic/eslint-plugin-migrate": "^1.5.0",
93
- "@types/eslint": "^8.44.8",
93
+ "@stylistic/eslint-plugin-migrate": "^1.5.1",
94
+ "@types/eslint": "^8.44.9",
94
95
  "@types/fs-extra": "^11.0.4",
95
96
  "@types/node": "^20.10.4",
96
97
  "@types/prompts": "^2.4.9",
@@ -115,7 +116,7 @@
115
116
  "typescript": "^5.3.3",
116
117
  "vitest": "^1.0.4",
117
118
  "vue": "^3.3.11",
118
- "@antfu/eslint-config": "2.4.4"
119
+ "@antfu/eslint-config": "2.4.6"
119
120
  },
120
121
  "simple-git-hooks": {
121
122
  "pre-commit": "pnpm lint-staged"