@antfu/eslint-config 2.4.3 → 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]
@@ -46,6 +46,9 @@ const antfu = require('@antfu/eslint-config').default
46
46
  module.exports = antfu()
47
47
  ```
48
48
 
49
+ > [!TIP]
50
+ > ESLint only detects `eslint.config.js` as the flat config entry, meaning you need to put `type: module` in your `package.json` or you have to use CJS in `eslint.config.js`. If you want explicit extension like `.mjs` or `.cjs`, or even `eslint.config.ts`, you can install [`eslint-ts-patch`](https://github.com/antfu/eslint-ts-patch) to fix it.
51
+
49
52
  Combined with legacy config:
50
53
 
51
54
  ```js
@@ -143,7 +146,8 @@ Add the following settings to your `.vscode/settings.json`:
143
146
  "markdown",
144
147
  "json",
145
148
  "jsonc",
146
- "yaml"
149
+ "yaml",
150
+ "toml"
147
151
  ]
148
152
  }
149
153
  ```
@@ -238,6 +242,7 @@ import {
238
242
  sortPackageJson,
239
243
  sortTsconfig,
240
244
  stylistic,
245
+ toml,
241
246
  typescript,
242
247
  unicorn,
243
248
  vue,
@@ -257,6 +262,7 @@ export default combine(
257
262
  vue(),
258
263
  jsonc(),
259
264
  yaml(),
265
+ toml(),
260
266
  markdown(),
261
267
  )
262
268
  ```
@@ -362,11 +368,6 @@ export default antfu({
362
368
  * By default uses Prettier
363
369
  */
364
370
  html: true,
365
- /**
366
- * Format TOML files
367
- * Currently only supports dprint
368
- */
369
- toml: 'dprint',
370
371
  /**
371
372
  * Format Markdown files
372
373
  * Supports Prettier and dprint
@@ -528,7 +529,7 @@ Well, you can still use Prettier to format files that are not supported well by
528
529
 
529
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.
530
531
 
531
- 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.
532
533
 
533
534
  ### How to format CSS?
534
535
 
package/dist/cli.cjs CHANGED
@@ -46,25 +46,26 @@ 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.3";
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",
58
58
  "@types/prompts": "^2.4.9",
59
59
  "@types/yargs": "^17.0.32",
60
60
  "@unocss/eslint-plugin": "^0.58.0",
61
- bumpp: "^9.2.0",
62
- eslint: "^8.55.0",
61
+ bumpp: "^9.2.1",
62
+ eslint: "npm:eslint-ts-patch@^8.55.0-1",
63
63
  "eslint-flat-config-viewer": "^0.1.3",
64
64
  "eslint-plugin-format": "^0.1.0",
65
65
  "eslint-plugin-react": "^7.33.2",
66
66
  "eslint-plugin-react-hooks": "^4.6.0",
67
67
  "eslint-plugin-react-refresh": "^0.4.5",
68
+ "eslint-ts-patch": "^8.55.0-1",
68
69
  esno: "^4.0.0",
69
70
  execa: "^8.0.1",
70
71
  "fast-glob": "^3.3.2",
@@ -74,8 +75,8 @@ var devDependencies = {
74
75
  "simple-git-hooks": "^2.9.0",
75
76
  tsup: "^8.0.1",
76
77
  typescript: "^5.3.3",
77
- vitest: "^1.0.2",
78
- vue: "^3.3.10"
78
+ vitest: "^1.0.4",
79
+ vue: "^3.3.11"
79
80
  };
80
81
 
81
82
  // src/cli/constants.ts
@@ -123,7 +124,8 @@ var vscodeSettingsString = `
123
124
  "markdown",
124
125
  "json",
125
126
  "jsonc",
126
- "yaml"
127
+ "yaml",
128
+ "toml"
127
129
  ]
128
130
  `;
129
131
 
@@ -148,10 +150,18 @@ async function run(options = {}) {
148
150
  const pathESLintIgnore = import_node_path.default.join(cwd, ".eslintignore");
149
151
  if (import_node_fs.default.existsSync(pathFlatConfig)) {
150
152
  console.log(import_picocolors2.default.yellow(`${WARN} eslint.config.js already exists, migration wizard exited.`));
151
- return;
153
+ return import_node_process.default.exit(1);
154
+ }
155
+ if (!SKIP_GIT_CHECK && !isGitClean()) {
156
+ const { confirmed } = await (0, import_prompts.default)({
157
+ initial: false,
158
+ message: "There are uncommitted changes in the current repository, are you sure to continue?",
159
+ name: "confirmed",
160
+ type: "confirm"
161
+ });
162
+ if (!confirmed)
163
+ return import_node_process.default.exit(1);
152
164
  }
153
- if (!SKIP_GIT_CHECK && !isGitClean())
154
- throw new Error("There are uncommitted changes in the current repository, please commit them and try again");
155
165
  console.log(import_picocolors2.default.cyan(`${ARROW} bumping @antfu/eslint-config to v${version}`));
156
166
  const pkgContent = await import_promises.default.readFile(pathPackageJSON, "utf-8");
157
167
  const pkg = JSON.parse(pkgContent);
package/dist/cli.js CHANGED
@@ -17,25 +17,26 @@ import parse from "parse-gitignore";
17
17
  import c from "picocolors";
18
18
 
19
19
  // package.json
20
- var version = "2.4.3";
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",
29
29
  "@types/prompts": "^2.4.9",
30
30
  "@types/yargs": "^17.0.32",
31
31
  "@unocss/eslint-plugin": "^0.58.0",
32
- bumpp: "^9.2.0",
33
- eslint: "^8.55.0",
32
+ bumpp: "^9.2.1",
33
+ eslint: "npm:eslint-ts-patch@^8.55.0-1",
34
34
  "eslint-flat-config-viewer": "^0.1.3",
35
35
  "eslint-plugin-format": "^0.1.0",
36
36
  "eslint-plugin-react": "^7.33.2",
37
37
  "eslint-plugin-react-hooks": "^4.6.0",
38
38
  "eslint-plugin-react-refresh": "^0.4.5",
39
+ "eslint-ts-patch": "^8.55.0-1",
39
40
  esno: "^4.0.0",
40
41
  execa: "^8.0.1",
41
42
  "fast-glob": "^3.3.2",
@@ -45,8 +46,8 @@ var devDependencies = {
45
46
  "simple-git-hooks": "^2.9.0",
46
47
  tsup: "^8.0.1",
47
48
  typescript: "^5.3.3",
48
- vitest: "^1.0.2",
49
- vue: "^3.3.10"
49
+ vitest: "^1.0.4",
50
+ vue: "^3.3.11"
50
51
  };
51
52
 
52
53
  // src/cli/constants.ts
@@ -94,7 +95,8 @@ var vscodeSettingsString = `
94
95
  "markdown",
95
96
  "json",
96
97
  "jsonc",
97
- "yaml"
98
+ "yaml",
99
+ "toml"
98
100
  ]
99
101
  `;
100
102
 
@@ -119,10 +121,18 @@ async function run(options = {}) {
119
121
  const pathESLintIgnore = path.join(cwd, ".eslintignore");
120
122
  if (fs.existsSync(pathFlatConfig)) {
121
123
  console.log(c2.yellow(`${WARN} eslint.config.js already exists, migration wizard exited.`));
122
- return;
124
+ return process.exit(1);
125
+ }
126
+ if (!SKIP_GIT_CHECK && !isGitClean()) {
127
+ const { confirmed } = await prompts({
128
+ initial: false,
129
+ message: "There are uncommitted changes in the current repository, are you sure to continue?",
130
+ name: "confirmed",
131
+ type: "confirm"
132
+ });
133
+ if (!confirmed)
134
+ return process.exit(1);
123
135
  }
124
- if (!SKIP_GIT_CHECK && !isGitClean())
125
- throw new Error("There are uncommitted changes in the current repository, please commit them and try again");
126
136
  console.log(c2.cyan(`${ARROW} bumping @antfu/eslint-config to v${version}`));
127
137
  const pkgContent = await fsp.readFile(pathPackageJSON, "utf-8");
128
138
  const pkg = JSON.parse(pkgContent);
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,8 +1,8 @@
1
1
  {
2
2
  "name": "@antfu/eslint-config",
3
3
  "type": "module",
4
- "version": "2.4.3",
5
- "packageManager": "pnpm@8.11.0",
4
+ "version": "2.4.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/)",
8
8
  "license": "MIT",
@@ -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,21 +67,23 @@
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.10",
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",
79
- "globals": "^13.23.0",
80
+ "globals": "^13.24.0",
80
81
  "jsonc-eslint-parser": "^2.4.0",
81
82
  "local-pkg": "^0.5.0",
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,20 +91,21 @@
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",
96
98
  "@types/prompts": "^2.4.9",
97
99
  "@types/yargs": "^17.0.32",
98
100
  "@unocss/eslint-plugin": "^0.58.0",
99
- "bumpp": "^9.2.0",
100
- "eslint": "^8.55.0",
101
+ "bumpp": "^9.2.1",
102
+ "eslint": "npm:eslint-ts-patch@^8.55.0-1",
101
103
  "eslint-flat-config-viewer": "^0.1.3",
102
104
  "eslint-plugin-format": "^0.1.0",
103
105
  "eslint-plugin-react": "^7.33.2",
104
106
  "eslint-plugin-react-hooks": "^4.6.0",
105
107
  "eslint-plugin-react-refresh": "^0.4.5",
108
+ "eslint-ts-patch": "^8.55.0-1",
106
109
  "esno": "^4.0.0",
107
110
  "execa": "^8.0.1",
108
111
  "fast-glob": "^3.3.2",
@@ -112,9 +115,9 @@
112
115
  "simple-git-hooks": "^2.9.0",
113
116
  "tsup": "^8.0.1",
114
117
  "typescript": "^5.3.3",
115
- "vitest": "^1.0.2",
116
- "vue": "^3.3.10",
117
- "@antfu/eslint-config": "2.4.3"
118
+ "vitest": "^1.0.4",
119
+ "vue": "^3.3.11",
120
+ "@antfu/eslint-config": "2.4.5"
118
121
  },
119
122
  "simple-git-hooks": {
120
123
  "pre-commit": "pnpm lint-staged"
@@ -127,7 +130,7 @@
127
130
  "stub": "tsup --format esm",
128
131
  "dev": "tsup --format esm,cjs --watch & eslint-flat-config-viewer",
129
132
  "watch": "tsup --format esm,cjs --watch",
130
- "lint": "pnpm run stub && eslint .",
133
+ "lint": "eslint .",
131
134
  "release": "bumpp && pnpm publish",
132
135
  "test": "vitest",
133
136
  "typecheck": "tsc --noEmit"