@antfu/eslint-config 2.4.4 → 2.4.5

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,12 +46,12 @@ 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.5";
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",
54
+ "@stylistic/eslint-plugin-migrate": "^1.5.1",
55
55
  "@types/eslint": "^8.44.8",
56
56
  "@types/fs-extra": "^11.0.4",
57
57
  "@types/node": "^20.10.4",
@@ -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,12 +17,12 @@ 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.5";
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",
25
+ "@stylistic/eslint-plugin-migrate": "^1.5.1",
26
26
  "@types/eslint": "^8.44.8",
27
27
  "@types/fs-extra": "^11.0.4",
28
28
  "@types/node": "^20.10.4",
@@ -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,
@@ -76,6 +77,7 @@ __export(src_exports, {
76
77
  stylistic: () => stylistic,
77
78
  test: () => test,
78
79
  toArray: () => toArray,
80
+ toml: () => toml,
79
81
  typescript: () => typescript,
80
82
  unicorn: () => unicorn,
81
83
  unocss: () => unocss,
@@ -135,6 +137,7 @@ var GLOB_MARKDOWN = "**/*.md";
135
137
  var GLOB_MARKDOWN_IN_MARKDOWN = "**/*.md/*.md";
136
138
  var GLOB_VUE = "**/*.vue";
137
139
  var GLOB_YAML = "**/*.y?(a)ml";
140
+ var GLOB_TOML = "**/*.toml";
138
141
  var GLOB_HTML = "**/*.htm?(l)";
139
142
  var GLOB_MARKDOWN_CODE = `${GLOB_MARKDOWN}/${GLOB_SRC}`;
140
143
  var GLOB_TESTS = [
@@ -783,8 +786,7 @@ async function formatters(options = {}, stylistic2 = {}) {
783
786
  css: true,
784
787
  graphql: true,
785
788
  html: true,
786
- markdown: true,
787
- toml: true
789
+ markdown: true
788
790
  };
789
791
  }
790
792
  const {
@@ -893,24 +895,6 @@ async function formatters(options = {}, stylistic2 = {}) {
893
895
  }
894
896
  });
895
897
  }
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
898
  if (options.markdown) {
915
899
  const formater = options.markdown === true ? "prettier" : options.markdown;
916
900
  configs.push({
@@ -1302,6 +1286,7 @@ async function test(options = {}) {
1302
1286
  "node/prefer-global/process": "off",
1303
1287
  "test/consistent-test-it": ["error", { fn: "it", withinDescribe: "it" }],
1304
1288
  "test/no-identical-title": "error",
1289
+ "test/no-import-node-test": "error",
1305
1290
  "test/no-only-tests": isInEditor ? "off" : "error",
1306
1291
  "test/prefer-hooks-in-order": "error",
1307
1292
  "test/prefer-lowercase-title": "error",
@@ -1722,6 +1707,65 @@ async function yaml(options = {}) {
1722
1707
  ];
1723
1708
  }
1724
1709
 
1710
+ // src/configs/toml.ts
1711
+ async function toml(options = {}) {
1712
+ const {
1713
+ files = [GLOB_TOML],
1714
+ overrides = {},
1715
+ stylistic: stylistic2 = true
1716
+ } = options;
1717
+ const {
1718
+ indent = 2
1719
+ } = typeof stylistic2 === "boolean" ? {} : stylistic2;
1720
+ const [
1721
+ pluginToml,
1722
+ parserToml
1723
+ ] = await Promise.all([
1724
+ interopDefault(import("eslint-plugin-toml")),
1725
+ interopDefault(import("toml-eslint-parser"))
1726
+ ]);
1727
+ return [
1728
+ {
1729
+ name: "antfu:toml:setup",
1730
+ plugins: {
1731
+ toml: pluginToml
1732
+ }
1733
+ },
1734
+ {
1735
+ files,
1736
+ languageOptions: {
1737
+ parser: parserToml
1738
+ },
1739
+ name: "antfu:toml:rules",
1740
+ rules: {
1741
+ "style/spaced-comment": "off",
1742
+ "toml/comma-style": "error",
1743
+ "toml/keys-order": "error",
1744
+ "toml/no-space-dots": "error",
1745
+ "toml/no-unreadable-number-separator": "error",
1746
+ "toml/precision-of-fractional-seconds": "error",
1747
+ "toml/precision-of-integer": "error",
1748
+ "toml/tables-order": "error",
1749
+ "toml/vue-custom-block/no-parsing-error": "error",
1750
+ ...stylistic2 ? {
1751
+ "toml/array-bracket-newline": "error",
1752
+ "toml/array-bracket-spacing": "error",
1753
+ "toml/array-element-newline": "error",
1754
+ "toml/indent": ["error", indent === "tab" ? 2 : indent],
1755
+ "toml/inline-table-curly-spacing": "error",
1756
+ "toml/key-spacing": "error",
1757
+ "toml/padding-line-between-pairs": "error",
1758
+ "toml/padding-line-between-tables": "error",
1759
+ "toml/quoted-keys": "error",
1760
+ "toml/spaced-comment": "error",
1761
+ "toml/table-bracket-spacing": "error"
1762
+ } : {},
1763
+ ...overrides
1764
+ }
1765
+ }
1766
+ ];
1767
+ }
1768
+
1725
1769
  // src/factory.ts
1726
1770
  var flatConfigProps = [
1727
1771
  "files",
@@ -1832,6 +1876,12 @@ async function antfu(options = {}, ...userConfigs) {
1832
1876
  stylistic: stylisticOptions
1833
1877
  }));
1834
1878
  }
1879
+ if (options.toml ?? true) {
1880
+ configs.push(toml({
1881
+ overrides: overrides.toml,
1882
+ stylistic: stylisticOptions
1883
+ }));
1884
+ }
1835
1885
  if (options.markdown ?? true) {
1836
1886
  configs.push(
1837
1887
  markdown(
@@ -1885,6 +1935,7 @@ var src_default = antfu;
1885
1935
  GLOB_SRC_EXT,
1886
1936
  GLOB_STYLE,
1887
1937
  GLOB_TESTS,
1938
+ GLOB_TOML,
1888
1939
  GLOB_TS,
1889
1940
  GLOB_TSX,
1890
1941
  GLOB_VUE,
@@ -1911,6 +1962,7 @@ var src_default = antfu;
1911
1962
  stylistic,
1912
1963
  test,
1913
1964
  toArray,
1965
+ toml,
1914
1966
  typescript,
1915
1967
  unicorn,
1916
1968
  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,6 +434,7 @@ 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[];
@@ -450,4 +454,4 @@ declare function interopDefault<T>(m: Awaitable<T>): Promise<T extends {
450
454
  } ? U : T>;
451
455
  declare function ensurePackages(packages: string[]): Promise<void>;
452
456
 
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 };
457
+ 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, 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,6 +434,7 @@ 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[];
@@ -450,4 +454,4 @@ declare function interopDefault<T>(m: Awaitable<T>): Promise<T extends {
450
454
  } ? U : T>;
451
455
  declare function ensurePackages(packages: string[]): Promise<void>;
452
456
 
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 };
457
+ 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, 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 = [
@@ -697,8 +698,7 @@ async function formatters(options = {}, stylistic2 = {}) {
697
698
  css: true,
698
699
  graphql: true,
699
700
  html: true,
700
- markdown: true,
701
- toml: true
701
+ markdown: true
702
702
  };
703
703
  }
704
704
  const {
@@ -807,24 +807,6 @@ async function formatters(options = {}, stylistic2 = {}) {
807
807
  }
808
808
  });
809
809
  }
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
810
  if (options.markdown) {
829
811
  const formater = options.markdown === true ? "prettier" : options.markdown;
830
812
  configs.push({
@@ -1216,6 +1198,7 @@ async function test(options = {}) {
1216
1198
  "node/prefer-global/process": "off",
1217
1199
  "test/consistent-test-it": ["error", { fn: "it", withinDescribe: "it" }],
1218
1200
  "test/no-identical-title": "error",
1201
+ "test/no-import-node-test": "error",
1219
1202
  "test/no-only-tests": isInEditor ? "off" : "error",
1220
1203
  "test/prefer-hooks-in-order": "error",
1221
1204
  "test/prefer-lowercase-title": "error",
@@ -1636,6 +1619,65 @@ async function yaml(options = {}) {
1636
1619
  ];
1637
1620
  }
1638
1621
 
1622
+ // src/configs/toml.ts
1623
+ async function toml(options = {}) {
1624
+ const {
1625
+ files = [GLOB_TOML],
1626
+ overrides = {},
1627
+ stylistic: stylistic2 = true
1628
+ } = options;
1629
+ const {
1630
+ indent = 2
1631
+ } = typeof stylistic2 === "boolean" ? {} : stylistic2;
1632
+ const [
1633
+ pluginToml,
1634
+ parserToml
1635
+ ] = await Promise.all([
1636
+ interopDefault(import("eslint-plugin-toml")),
1637
+ interopDefault(import("toml-eslint-parser"))
1638
+ ]);
1639
+ return [
1640
+ {
1641
+ name: "antfu:toml:setup",
1642
+ plugins: {
1643
+ toml: pluginToml
1644
+ }
1645
+ },
1646
+ {
1647
+ files,
1648
+ languageOptions: {
1649
+ parser: parserToml
1650
+ },
1651
+ name: "antfu:toml:rules",
1652
+ rules: {
1653
+ "style/spaced-comment": "off",
1654
+ "toml/comma-style": "error",
1655
+ "toml/keys-order": "error",
1656
+ "toml/no-space-dots": "error",
1657
+ "toml/no-unreadable-number-separator": "error",
1658
+ "toml/precision-of-fractional-seconds": "error",
1659
+ "toml/precision-of-integer": "error",
1660
+ "toml/tables-order": "error",
1661
+ "toml/vue-custom-block/no-parsing-error": "error",
1662
+ ...stylistic2 ? {
1663
+ "toml/array-bracket-newline": "error",
1664
+ "toml/array-bracket-spacing": "error",
1665
+ "toml/array-element-newline": "error",
1666
+ "toml/indent": ["error", indent === "tab" ? 2 : indent],
1667
+ "toml/inline-table-curly-spacing": "error",
1668
+ "toml/key-spacing": "error",
1669
+ "toml/padding-line-between-pairs": "error",
1670
+ "toml/padding-line-between-tables": "error",
1671
+ "toml/quoted-keys": "error",
1672
+ "toml/spaced-comment": "error",
1673
+ "toml/table-bracket-spacing": "error"
1674
+ } : {},
1675
+ ...overrides
1676
+ }
1677
+ }
1678
+ ];
1679
+ }
1680
+
1639
1681
  // src/factory.ts
1640
1682
  var flatConfigProps = [
1641
1683
  "files",
@@ -1746,6 +1788,12 @@ async function antfu(options = {}, ...userConfigs) {
1746
1788
  stylistic: stylisticOptions
1747
1789
  }));
1748
1790
  }
1791
+ if (options.toml ?? true) {
1792
+ configs.push(toml({
1793
+ overrides: overrides.toml,
1794
+ stylistic: stylisticOptions
1795
+ }));
1796
+ }
1749
1797
  if (options.markdown ?? true) {
1750
1798
  configs.push(
1751
1799
  markdown(
@@ -1798,6 +1846,7 @@ export {
1798
1846
  GLOB_SRC_EXT,
1799
1847
  GLOB_STYLE,
1800
1848
  GLOB_TESTS,
1849
+ GLOB_TOML,
1801
1850
  GLOB_TS,
1802
1851
  GLOB_TSX,
1803
1852
  GLOB_VUE,
@@ -1825,6 +1874,7 @@ export {
1825
1874
  stylistic,
1826
1875
  test,
1827
1876
  toArray,
1877
+ toml,
1828
1878
  typescript,
1829
1879
  unicorn,
1830
1880
  unocss,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@antfu/eslint-config",
3
3
  "type": "module",
4
- "version": "2.4.4",
4
+ "version": "2.4.5",
5
5
  "packageManager": "pnpm@8.12.0",
6
6
  "description": "Anthony's ESLint config",
7
7
  "author": "Anthony Fu <anthonyfu117@hotmail.com> (https://github.com/antfu/)",
@@ -55,7 +55,7 @@
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",
58
+ "@stylistic/eslint-plugin": "^1.5.1",
59
59
  "@typescript-eslint/eslint-plugin": "^6.13.2",
60
60
  "@typescript-eslint/parser": "^6.13.2",
61
61
  "eslint-config-flat-gitignore": "^0.1.2",
@@ -67,12 +67,13 @@
67
67
  "eslint-plugin-jsdoc": "^46.9.0",
68
68
  "eslint-plugin-jsonc": "^2.10.0",
69
69
  "eslint-plugin-markdown": "^3.0.1",
70
- "eslint-plugin-n": "^16.3.1",
70
+ "eslint-plugin-n": "^16.4.0",
71
71
  "eslint-plugin-no-only-tests": "^3.1.0",
72
72
  "eslint-plugin-perfectionist": "^2.5.0",
73
+ "eslint-plugin-toml": "^0.7.1",
73
74
  "eslint-plugin-unicorn": "^49.0.0",
74
75
  "eslint-plugin-unused-imports": "^3.0.0",
75
- "eslint-plugin-vitest": "^0.3.13",
76
+ "eslint-plugin-vitest": "^0.3.15",
76
77
  "eslint-plugin-vue": "^9.19.2",
77
78
  "eslint-plugin-yml": "^1.10.0",
78
79
  "eslint-processor-vue-blocks": "^0.1.1",
@@ -82,6 +83,7 @@
82
83
  "parse-gitignore": "^2.0.0",
83
84
  "picocolors": "^1.0.0",
84
85
  "prompts": "^2.4.2",
86
+ "toml-eslint-parser": "^0.9.3",
85
87
  "vue-eslint-parser": "^9.3.2",
86
88
  "yaml-eslint-parser": "^1.2.2",
87
89
  "yargs": "^17.7.2"
@@ -89,7 +91,7 @@
89
91
  "devDependencies": {
90
92
  "@antfu/eslint-plugin-prettier": "^5.0.1-1",
91
93
  "@antfu/ni": "^0.21.12",
92
- "@stylistic/eslint-plugin-migrate": "^1.5.0",
94
+ "@stylistic/eslint-plugin-migrate": "^1.5.1",
93
95
  "@types/eslint": "^8.44.8",
94
96
  "@types/fs-extra": "^11.0.4",
95
97
  "@types/node": "^20.10.4",
@@ -115,7 +117,7 @@
115
117
  "typescript": "^5.3.3",
116
118
  "vitest": "^1.0.4",
117
119
  "vue": "^3.3.11",
118
- "@antfu/eslint-config": "2.4.4"
120
+ "@antfu/eslint-config": "2.4.5"
119
121
  },
120
122
  "simple-git-hooks": {
121
123
  "pre-commit": "pnpm lint-staged"