@antfu/eslint-config 2.20.0 → 2.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.cjs CHANGED
@@ -48,8 +48,8 @@ var import_picocolors = __toESM(require("picocolors"), 1);
48
48
  var package_default = {
49
49
  name: "@antfu/eslint-config",
50
50
  type: "module",
51
- version: "2.20.0",
52
- packageManager: "pnpm@9.1.4",
51
+ version: "2.21.0",
52
+ packageManager: "pnpm@9.2.0",
53
53
  description: "Anthony's ESLint config",
54
54
  author: "Anthony Fu <anthonyfu117@hotmail.com> (https://github.com/antfu/)",
55
55
  license: "MIT",
@@ -146,8 +146,8 @@ var package_default = {
146
146
  "@antfu/install-pkg": "^0.3.3",
147
147
  "@clack/prompts": "^0.7.0",
148
148
  "@stylistic/eslint-plugin": "^2.1.0",
149
- "@typescript-eslint/eslint-plugin": "^7.11.0",
150
- "@typescript-eslint/parser": "^7.11.0",
149
+ "@typescript-eslint/eslint-plugin": "^7.12.0",
150
+ "@typescript-eslint/parser": "^7.12.0",
151
151
  "eslint-config-flat-gitignore": "^0.1.5",
152
152
  "eslint-flat-config-utils": "^0.2.5",
153
153
  "eslint-merge-processors": "^0.1.0",
@@ -155,10 +155,10 @@ var package_default = {
155
155
  "eslint-plugin-command": "^0.2.3",
156
156
  "eslint-plugin-eslint-comments": "^3.2.0",
157
157
  "eslint-plugin-import-x": "^0.5.1",
158
- "eslint-plugin-jsdoc": "^48.2.7",
158
+ "eslint-plugin-jsdoc": "^48.2.9",
159
159
  "eslint-plugin-jsonc": "^2.16.0",
160
160
  "eslint-plugin-markdown": "^5.0.0",
161
- "eslint-plugin-n": "^17.7.0",
161
+ "eslint-plugin-n": "^17.8.1",
162
162
  "eslint-plugin-no-only-tests": "^3.1.0",
163
163
  "eslint-plugin-perfectionist": "^2.10.0",
164
164
  "eslint-plugin-regexp": "^2.6.0",
@@ -169,7 +169,7 @@ var package_default = {
169
169
  "eslint-plugin-vue": "^9.26.0",
170
170
  "eslint-plugin-yml": "^1.14.0",
171
171
  "eslint-processor-vue-blocks": "^0.1.2",
172
- globals: "^15.3.0",
172
+ globals: "^15.4.0",
173
173
  "jsonc-eslint-parser": "^2.4.0",
174
174
  "local-pkg": "^0.5.0",
175
175
  "parse-gitignore": "^2.0.0",
@@ -182,13 +182,13 @@ var package_default = {
182
182
  devDependencies: {
183
183
  "@antfu/eslint-config": "workspace:*",
184
184
  "@antfu/ni": "^0.21.12",
185
- "@eslint-react/eslint-plugin": "^1.5.14",
185
+ "@eslint-react/eslint-plugin": "^1.5.15",
186
186
  "@eslint/config-inspector": "^0.4.10",
187
187
  "@prettier/plugin-xml": "^3.4.1",
188
188
  "@stylistic/eslint-plugin-migrate": "^2.1.0",
189
189
  "@types/eslint": "^8.56.10",
190
190
  "@types/fs-extra": "^11.0.4",
191
- "@types/node": "^20.13.0",
191
+ "@types/node": "^20.14.2",
192
192
  "@types/prompts": "^2.4.9",
193
193
  "@types/yargs": "^17.0.32",
194
194
  "@unocss/eslint-plugin": "^0.60.4",
@@ -204,7 +204,7 @@ var package_default = {
204
204
  "eslint-ts-patch": "9.4.0-0",
205
205
  "eslint-typegen": "^0.2.4",
206
206
  esno: "^4.7.0",
207
- execa: "^9.1.0",
207
+ execa: "^9.2.0",
208
208
  "fast-glob": "^3.3.2",
209
209
  "fs-extra": "^11.2.0",
210
210
  "lint-staged": "^15.2.5",
@@ -212,10 +212,10 @@ var package_default = {
212
212
  "prettier-plugin-slidev": "^1.0.5",
213
213
  rimraf: "^5.0.7",
214
214
  "simple-git-hooks": "^2.11.1",
215
- svelte: "^4.2.17",
215
+ svelte: "^4.2.18",
216
216
  "svelte-eslint-parser": "^0.36.0",
217
- tsup: "^8.0.2",
218
- tsx: "^4.11.0",
217
+ tsup: "^8.1.0",
218
+ tsx: "^4.14.0",
219
219
  typescript: "^5.4.5",
220
220
  vitest: "^1.6.0",
221
221
  vue: "^3.4.27"
package/dist/cli.js CHANGED
@@ -19,8 +19,8 @@ import c from "picocolors";
19
19
  var package_default = {
20
20
  name: "@antfu/eslint-config",
21
21
  type: "module",
22
- version: "2.20.0",
23
- packageManager: "pnpm@9.1.4",
22
+ version: "2.21.0",
23
+ packageManager: "pnpm@9.2.0",
24
24
  description: "Anthony's ESLint config",
25
25
  author: "Anthony Fu <anthonyfu117@hotmail.com> (https://github.com/antfu/)",
26
26
  license: "MIT",
@@ -117,8 +117,8 @@ var package_default = {
117
117
  "@antfu/install-pkg": "^0.3.3",
118
118
  "@clack/prompts": "^0.7.0",
119
119
  "@stylistic/eslint-plugin": "^2.1.0",
120
- "@typescript-eslint/eslint-plugin": "^7.11.0",
121
- "@typescript-eslint/parser": "^7.11.0",
120
+ "@typescript-eslint/eslint-plugin": "^7.12.0",
121
+ "@typescript-eslint/parser": "^7.12.0",
122
122
  "eslint-config-flat-gitignore": "^0.1.5",
123
123
  "eslint-flat-config-utils": "^0.2.5",
124
124
  "eslint-merge-processors": "^0.1.0",
@@ -126,10 +126,10 @@ var package_default = {
126
126
  "eslint-plugin-command": "^0.2.3",
127
127
  "eslint-plugin-eslint-comments": "^3.2.0",
128
128
  "eslint-plugin-import-x": "^0.5.1",
129
- "eslint-plugin-jsdoc": "^48.2.7",
129
+ "eslint-plugin-jsdoc": "^48.2.9",
130
130
  "eslint-plugin-jsonc": "^2.16.0",
131
131
  "eslint-plugin-markdown": "^5.0.0",
132
- "eslint-plugin-n": "^17.7.0",
132
+ "eslint-plugin-n": "^17.8.1",
133
133
  "eslint-plugin-no-only-tests": "^3.1.0",
134
134
  "eslint-plugin-perfectionist": "^2.10.0",
135
135
  "eslint-plugin-regexp": "^2.6.0",
@@ -140,7 +140,7 @@ var package_default = {
140
140
  "eslint-plugin-vue": "^9.26.0",
141
141
  "eslint-plugin-yml": "^1.14.0",
142
142
  "eslint-processor-vue-blocks": "^0.1.2",
143
- globals: "^15.3.0",
143
+ globals: "^15.4.0",
144
144
  "jsonc-eslint-parser": "^2.4.0",
145
145
  "local-pkg": "^0.5.0",
146
146
  "parse-gitignore": "^2.0.0",
@@ -153,13 +153,13 @@ var package_default = {
153
153
  devDependencies: {
154
154
  "@antfu/eslint-config": "workspace:*",
155
155
  "@antfu/ni": "^0.21.12",
156
- "@eslint-react/eslint-plugin": "^1.5.14",
156
+ "@eslint-react/eslint-plugin": "^1.5.15",
157
157
  "@eslint/config-inspector": "^0.4.10",
158
158
  "@prettier/plugin-xml": "^3.4.1",
159
159
  "@stylistic/eslint-plugin-migrate": "^2.1.0",
160
160
  "@types/eslint": "^8.56.10",
161
161
  "@types/fs-extra": "^11.0.4",
162
- "@types/node": "^20.13.0",
162
+ "@types/node": "^20.14.2",
163
163
  "@types/prompts": "^2.4.9",
164
164
  "@types/yargs": "^17.0.32",
165
165
  "@unocss/eslint-plugin": "^0.60.4",
@@ -175,7 +175,7 @@ var package_default = {
175
175
  "eslint-ts-patch": "9.4.0-0",
176
176
  "eslint-typegen": "^0.2.4",
177
177
  esno: "^4.7.0",
178
- execa: "^9.1.0",
178
+ execa: "^9.2.0",
179
179
  "fast-glob": "^3.3.2",
180
180
  "fs-extra": "^11.2.0",
181
181
  "lint-staged": "^15.2.5",
@@ -183,10 +183,10 @@ var package_default = {
183
183
  "prettier-plugin-slidev": "^1.0.5",
184
184
  rimraf: "^5.0.7",
185
185
  "simple-git-hooks": "^2.11.1",
186
- svelte: "^4.2.17",
186
+ svelte: "^4.2.18",
187
187
  "svelte-eslint-parser": "^0.36.0",
188
- tsup: "^8.0.2",
189
- tsx: "^4.11.0",
188
+ tsup: "^8.1.0",
189
+ tsx: "^4.14.0",
190
190
  typescript: "^5.4.5",
191
191
  vitest: "^1.6.0",
192
192
  vue: "^3.4.27"
package/dist/index.cjs CHANGED
@@ -32,6 +32,7 @@ var src_exports = {};
32
32
  __export(src_exports, {
33
33
  GLOB_ALL_SRC: () => GLOB_ALL_SRC,
34
34
  GLOB_ASTRO: () => GLOB_ASTRO,
35
+ GLOB_ASTRO_TS: () => GLOB_ASTRO_TS,
35
36
  GLOB_CSS: () => GLOB_CSS,
36
37
  GLOB_EXCLUDE: () => GLOB_EXCLUDE,
37
38
  GLOB_GRAPHQL: () => GLOB_GRAPHQL,
@@ -75,6 +76,7 @@ __export(src_exports, {
75
76
  javascript: () => javascript,
76
77
  jsdoc: () => jsdoc,
77
78
  jsonc: () => jsonc,
79
+ jsx: () => jsx,
78
80
  markdown: () => markdown,
79
81
  node: () => node,
80
82
  parserPlain: () => parserPlain,
@@ -130,6 +132,7 @@ var GLOB_TOML = "**/*.toml";
130
132
  var GLOB_XML = "**/*.xml";
131
133
  var GLOB_HTML = "**/*.htm?(l)";
132
134
  var GLOB_ASTRO = "**/*.astro";
135
+ var GLOB_ASTRO_TS = "**/*.astro/*.ts";
133
136
  var GLOB_GRAPHQL = "**/*.{g,graph}ql";
134
137
  var GLOB_MARKDOWN_CODE = `${GLOB_MARKDOWN}/${GLOB_SRC}`;
135
138
  var GLOB_TESTS = [
@@ -371,7 +374,7 @@ var StylisticConfigDefaults = {
371
374
  async function stylistic(options = {}) {
372
375
  const {
373
376
  indent,
374
- jsx,
377
+ jsx: jsx2,
375
378
  lessOpinionated = false,
376
379
  overrides = {},
377
380
  quotes,
@@ -384,7 +387,7 @@ async function stylistic(options = {}) {
384
387
  const config = pluginStylistic.configs.customize({
385
388
  flat: true,
386
389
  indent,
387
- jsx,
390
+ jsx: jsx2,
388
391
  pluginName: "style",
389
392
  quotes,
390
393
  semi
@@ -416,7 +419,7 @@ async function stylistic(options = {}) {
416
419
  async function formatters(options = {}, stylistic2 = {}) {
417
420
  if (options === true) {
418
421
  options = {
419
- astro: (0, import_local_pkg2.isPackageExists)("astro"),
422
+ astro: (0, import_local_pkg2.isPackageExists)("prettier-plugin-astro"),
420
423
  css: true,
421
424
  graphql: true,
422
425
  html: true,
@@ -636,6 +639,19 @@ async function formatters(options = {}, stylistic2 = {}) {
636
639
  ]
637
640
  }
638
641
  });
642
+ configs2.push({
643
+ files: [GLOB_ASTRO, GLOB_ASTRO_TS],
644
+ name: "antfu/formatter/astro/disables",
645
+ rules: {
646
+ "style/arrow-parens": "off",
647
+ "style/block-spacing": "off",
648
+ "style/comma-dangle": "off",
649
+ "style/indent": "off",
650
+ "style/no-multi-spaces": "off",
651
+ "style/quotes": "off",
652
+ "style/semi": "off"
653
+ }
654
+ });
639
655
  }
640
656
  if (options.graphql) {
641
657
  configs2.push({
@@ -739,6 +755,9 @@ async function javascript(options = {}) {
739
755
  linterOptions: {
740
756
  reportUnusedDisableDirectives: true
741
757
  },
758
+ name: "antfu/javascript/setup"
759
+ },
760
+ {
742
761
  name: "antfu/javascript/rules",
743
762
  plugins: {
744
763
  "antfu": import_eslint_plugin_antfu.default,
@@ -966,6 +985,23 @@ async function jsdoc(options = {}) {
966
985
  ];
967
986
  }
968
987
 
988
+ // src/configs/jsx.ts
989
+ async function jsx() {
990
+ return [
991
+ {
992
+ files: [GLOB_JSX, GLOB_TSX],
993
+ languageOptions: {
994
+ parserOptions: {
995
+ ecmaFeatures: {
996
+ jsx: true
997
+ }
998
+ }
999
+ },
1000
+ name: "antfu/jsx/setup"
1001
+ }
1002
+ ];
1003
+ }
1004
+
969
1005
  // src/configs/jsonc.ts
970
1006
  async function jsonc(options = {}) {
971
1007
  const {
@@ -1113,25 +1149,6 @@ async function markdown(options = {}) {
1113
1149
  "unicode-bom": "off",
1114
1150
  "unused-imports/no-unused-imports": "off",
1115
1151
  "unused-imports/no-unused-vars": "off",
1116
- // Type aware rules
1117
- ...{
1118
- "ts/await-thenable": "off",
1119
- "ts/dot-notation": "off",
1120
- "ts/no-floating-promises": "off",
1121
- "ts/no-for-in-array": "off",
1122
- "ts/no-implied-eval": "off",
1123
- "ts/no-misused-promises": "off",
1124
- "ts/no-throw-literal": "off",
1125
- "ts/no-unnecessary-type-assertion": "off",
1126
- "ts/no-unsafe-argument": "off",
1127
- "ts/no-unsafe-assignment": "off",
1128
- "ts/no-unsafe-call": "off",
1129
- "ts/no-unsafe-member-access": "off",
1130
- "ts/no-unsafe-return": "off",
1131
- "ts/restrict-plus-operands": "off",
1132
- "ts/restrict-template-expressions": "off",
1133
- "ts/unbound-method": "off"
1134
- },
1135
1152
  ...overrides
1136
1153
  }
1137
1154
  }
@@ -1840,10 +1857,15 @@ async function typescript(options = {}) {
1840
1857
  parserOptions = {}
1841
1858
  } = options;
1842
1859
  const files = options.files ?? [
1843
- GLOB_SRC,
1860
+ GLOB_TS,
1861
+ GLOB_TSX,
1844
1862
  ...componentExts.map((ext) => `**/*.${ext}`)
1845
1863
  ];
1846
1864
  const filesTypeAware = options.filesTypeAware ?? [GLOB_TS, GLOB_TSX];
1865
+ const ignoresTypeAware = options.ignoresTypeAware ?? [
1866
+ `${GLOB_MARKDOWN}/**`,
1867
+ GLOB_ASTRO_TS
1868
+ ];
1847
1869
  const tsconfigPath = options?.tsconfigPath ? toArray(options.tsconfigPath) : void 0;
1848
1870
  const isTypeAware = !!tsconfigPath;
1849
1871
  const typeAwareRules = {
@@ -1905,9 +1927,11 @@ async function typescript(options = {}) {
1905
1927
  },
1906
1928
  // assign type-aware parser for type-aware files and type-unaware parser for the rest
1907
1929
  ...isTypeAware ? [
1908
- makeParser(true, filesTypeAware),
1930
+ makeParser(true, filesTypeAware, ignoresTypeAware),
1909
1931
  makeParser(false, files, filesTypeAware)
1910
- ] : [makeParser(false, files)],
1932
+ ] : [
1933
+ makeParser(false, files)
1934
+ ],
1911
1935
  {
1912
1936
  files,
1913
1937
  name: "antfu/typescript/rules",
@@ -1952,6 +1976,7 @@ async function typescript(options = {}) {
1952
1976
  },
1953
1977
  ...isTypeAware ? [{
1954
1978
  files: filesTypeAware,
1979
+ ignores: ignoresTypeAware,
1955
1980
  name: "antfu/typescript/rules-type-aware",
1956
1981
  rules: {
1957
1982
  ...tsconfigPath ? typeAwareRules : {},
@@ -1959,7 +1984,7 @@ async function typescript(options = {}) {
1959
1984
  }
1960
1985
  }] : [],
1961
1986
  {
1962
- files: ["**/*.d.ts"],
1987
+ files: ["**/*.d.([cm])ts"],
1963
1988
  name: "antfu/typescript/disables/dts",
1964
1989
  rules: {
1965
1990
  "eslint-comments/no-unlimited-disable": "off",
@@ -2347,6 +2372,7 @@ function antfu(options = {}, ...userConfigs) {
2347
2372
  componentExts = [],
2348
2373
  gitignore: enableGitignore = true,
2349
2374
  isInEditor = !!((import_node_process3.default.env.VSCODE_PID || import_node_process3.default.env.VSCODE_CWD || import_node_process3.default.env.JETBRAINS_IDE || import_node_process3.default.env.VIM) && !import_node_process3.default.env.CI),
2375
+ jsx: enableJsx = true,
2350
2376
  react: enableReact = false,
2351
2377
  regexp: enableRegexp = true,
2352
2378
  solid: enableSolid = false,
@@ -2357,7 +2383,7 @@ function antfu(options = {}, ...userConfigs) {
2357
2383
  } = options;
2358
2384
  const stylisticOptions = options.stylistic === false ? false : typeof options.stylistic === "object" ? options.stylistic : {};
2359
2385
  if (stylisticOptions && !("jsx" in stylisticOptions))
2360
- stylisticOptions.jsx = options.jsx ?? true;
2386
+ stylisticOptions.jsx = enableJsx;
2361
2387
  const configs2 = [];
2362
2388
  if (enableGitignore) {
2363
2389
  if (typeof enableGitignore !== "boolean") {
@@ -2391,6 +2417,9 @@ function antfu(options = {}, ...userConfigs) {
2391
2417
  if (enableVue) {
2392
2418
  componentExts.push("vue");
2393
2419
  }
2420
+ if (enableJsx) {
2421
+ configs2.push(jsx());
2422
+ }
2394
2423
  if (enableTypeScript) {
2395
2424
  configs2.push(typescript({
2396
2425
  ...typescriptOptions,
@@ -2526,6 +2555,7 @@ var src_default = antfu;
2526
2555
  0 && (module.exports = {
2527
2556
  GLOB_ALL_SRC,
2528
2557
  GLOB_ASTRO,
2558
+ GLOB_ASTRO_TS,
2529
2559
  GLOB_CSS,
2530
2560
  GLOB_EXCLUDE,
2531
2561
  GLOB_GRAPHQL,
@@ -2568,6 +2598,7 @@ var src_default = antfu;
2568
2598
  javascript,
2569
2599
  jsdoc,
2570
2600
  jsonc,
2601
+ jsx,
2571
2602
  markdown,
2572
2603
  node,
2573
2604
  parserPlain,