@antfu/eslint-config 2.5.0 → 2.6.1

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
@@ -305,7 +305,10 @@ Certain rules would only be enabled in specific files, for example, `ts/*` rules
305
305
  import antfu from '@antfu/eslint-config'
306
306
 
307
307
  export default antfu(
308
- { vue: true, typescript: true },
308
+ {
309
+ vue: true,
310
+ typescript: true
311
+ },
309
312
  {
310
313
  // Remember to specify the file glob here, otherwise it might cause the vue plugin to handle non-vue files
311
314
  files: ['**/*.vue'],
@@ -322,23 +325,28 @@ export default antfu(
322
325
  )
323
326
  ```
324
327
 
325
- We also provided an `overrides` options to make it easier:
328
+ We also provided a `overrides` options in each integration to make it easier:
326
329
 
327
330
  ```js
328
331
  // eslint.config.js
329
332
  import antfu from '@antfu/eslint-config'
330
333
 
331
334
  export default antfu({
332
- overrides: {
333
- vue: {
335
+ vue: {
336
+ overrides: {
334
337
  'vue/operator-linebreak': ['error', 'before'],
335
338
  },
336
- typescript: {
339
+ },
340
+ typescript: {
341
+ overrides: {
337
342
  'ts/consistent-type-definitions': ['error', 'interface'],
338
343
  },
339
- yaml: {},
340
- // ...
341
- }
344
+ },
345
+ yaml: {
346
+ overrides: {
347
+ // ...
348
+ },
349
+ },
342
350
  })
343
351
  ```
344
352
 
@@ -444,7 +452,7 @@ npm i -D @unocss/eslint-plugin
444
452
 
445
453
  ### Optional Rules
446
454
 
447
- This config also provides some optional plugins/rules for extended usages.
455
+ This config also provides some optional plugins/rules for extended usage.
448
456
 
449
457
  #### `perfectionist` (sorting)
450
458
 
package/bin/index.js CHANGED
@@ -1,3 +1,2 @@
1
1
  #!/usr/bin/env node
2
- // eslint-disable-next-line antfu/no-import-dist
3
2
  import '../dist/cli.js'
package/dist/cli.cjs CHANGED
@@ -46,7 +46,7 @@ var import_parse_gitignore = __toESM(require("parse-gitignore"), 1);
46
46
  var import_picocolors = __toESM(require("picocolors"), 1);
47
47
 
48
48
  // package.json
49
- var version = "2.5.0";
49
+ var version = "2.6.1";
50
50
  var devDependencies = {
51
51
  "@antfu/eslint-config": "workspace:*",
52
52
  "@antfu/eslint-plugin-prettier": "^5.0.1-1",
@@ -59,14 +59,14 @@ var devDependencies = {
59
59
  "@types/yargs": "^17.0.32",
60
60
  "@unocss/eslint-plugin": "^0.58.0",
61
61
  bumpp: "^9.2.1",
62
- eslint: "npm:eslint-ts-patch@^8.55.0-1",
62
+ eslint: "npm:eslint-ts-patch@^8.56.0-0",
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
68
  "eslint-plugin-svelte": "^2.35.1",
69
- "eslint-ts-patch": "^8.55.0-1",
69
+ "eslint-ts-patch": "^8.56.0-0",
70
70
  esno: "^4.0.0",
71
71
  execa: "^8.0.1",
72
72
  "fast-glob": "^3.3.2",
package/dist/cli.js CHANGED
@@ -17,7 +17,7 @@ import parse from "parse-gitignore";
17
17
  import c from "picocolors";
18
18
 
19
19
  // package.json
20
- var version = "2.5.0";
20
+ var version = "2.6.1";
21
21
  var devDependencies = {
22
22
  "@antfu/eslint-config": "workspace:*",
23
23
  "@antfu/eslint-plugin-prettier": "^5.0.1-1",
@@ -30,14 +30,14 @@ var devDependencies = {
30
30
  "@types/yargs": "^17.0.32",
31
31
  "@unocss/eslint-plugin": "^0.58.0",
32
32
  bumpp: "^9.2.1",
33
- eslint: "npm:eslint-ts-patch@^8.55.0-1",
33
+ eslint: "npm:eslint-ts-patch@^8.56.0-0",
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
39
  "eslint-plugin-svelte": "^2.35.1",
40
- "eslint-ts-patch": "^8.55.0-1",
40
+ "eslint-ts-patch": "^8.56.0-0",
41
41
  esno: "^4.0.0",
42
42
  execa: "^8.0.1",
43
43
  "fast-glob": "^3.3.2",
package/dist/index.cjs CHANGED
@@ -62,6 +62,7 @@ __export(src_exports, {
62
62
  default: () => src_default,
63
63
  ensurePackages: () => ensurePackages,
64
64
  formatters: () => formatters,
65
+ getOverrides: () => getOverrides,
65
66
  ignores: () => ignores,
66
67
  imports: () => imports,
67
68
  interopDefault: () => interopDefault,
@@ -74,6 +75,7 @@ __export(src_exports, {
74
75
  perfectionist: () => perfectionist,
75
76
  react: () => react,
76
77
  renameRules: () => renameRules,
78
+ resolveSubOptions: () => resolveSubOptions,
77
79
  sortPackageJson: () => sortPackageJson,
78
80
  sortTsconfig: () => sortTsconfig,
79
81
  stylistic: () => stylistic,
@@ -229,6 +231,14 @@ async function imports(options = {}) {
229
231
  "import/newline-after-import": ["error", { considerComments: true, count: 1 }]
230
232
  } : {}
231
233
  }
234
+ },
235
+ {
236
+ files: ["**/bin/**/*", `**/bin.${GLOB_SRC_EXT}`],
237
+ name: "antfu:imports:bin",
238
+ rules: {
239
+ "antfu/no-import-dist": "off",
240
+ "antfu/no-import-node-modules-by-path": "off"
241
+ }
232
242
  }
233
243
  ];
234
244
  }
@@ -1909,7 +1919,6 @@ async function antfu(options = {}, ...userConfigs) {
1909
1919
  componentExts = [],
1910
1920
  gitignore: enableGitignore = true,
1911
1921
  isInEditor = !!((import_node_process3.default.env.VSCODE_PID || import_node_process3.default.env.JETBRAINS_IDE || import_node_process3.default.env.VIM) && !import_node_process3.default.env.CI),
1912
- overrides = {},
1913
1922
  react: enableReact = false,
1914
1923
  svelte: enableSvelte = false,
1915
1924
  typescript: enableTypeScript = (0, import_local_pkg3.isPackageExists)("typescript"),
@@ -1932,7 +1941,7 @@ async function antfu(options = {}, ...userConfigs) {
1932
1941
  ignores(),
1933
1942
  javascript({
1934
1943
  isInEditor,
1935
- overrides: overrides.javascript
1944
+ overrides: getOverrides(options, "javascript")
1936
1945
  }),
1937
1946
  comments(),
1938
1947
  node(),
@@ -1950,53 +1959,52 @@ async function antfu(options = {}, ...userConfigs) {
1950
1959
  componentExts.push("vue");
1951
1960
  if (enableTypeScript) {
1952
1961
  configs.push(typescript({
1953
- ...typeof enableTypeScript !== "boolean" ? enableTypeScript : {},
1954
- componentExts,
1955
- overrides: overrides.typescript
1962
+ ...resolveSubOptions(options, "typescript"),
1963
+ componentExts
1956
1964
  }));
1957
1965
  }
1958
1966
  if (stylisticOptions) {
1959
1967
  configs.push(stylistic({
1960
1968
  ...stylisticOptions,
1961
- overrides: overrides.stylistic
1969
+ overrides: getOverrides(options, "stylistic")
1962
1970
  }));
1963
1971
  }
1964
1972
  if (options.test ?? true) {
1965
1973
  configs.push(test({
1966
1974
  isInEditor,
1967
- overrides: overrides.test
1975
+ overrides: getOverrides(options, "test")
1968
1976
  }));
1969
1977
  }
1970
1978
  if (enableVue) {
1971
1979
  configs.push(vue({
1972
- ...typeof enableVue !== "boolean" ? enableVue : {},
1973
- overrides: overrides.vue,
1980
+ ...resolveSubOptions(options, "vue"),
1974
1981
  stylistic: stylisticOptions,
1975
1982
  typescript: !!enableTypeScript
1976
1983
  }));
1977
1984
  }
1978
1985
  if (enableReact) {
1979
1986
  configs.push(react({
1980
- overrides: overrides.react,
1987
+ overrides: getOverrides(options, "react"),
1981
1988
  typescript: !!enableTypeScript
1982
1989
  }));
1983
1990
  }
1984
1991
  if (enableSvelte) {
1985
1992
  configs.push(svelte({
1986
- overrides: overrides.svelte,
1993
+ overrides: getOverrides(options, "svelte"),
1987
1994
  stylistic: stylisticOptions,
1988
1995
  typescript: !!enableTypeScript
1989
1996
  }));
1990
1997
  }
1991
1998
  if (enableUnoCSS) {
1992
- configs.push(unocss(
1993
- typeof enableUnoCSS === "boolean" ? {} : enableUnoCSS
1994
- ));
1999
+ configs.push(unocss({
2000
+ ...resolveSubOptions(options, "unocss"),
2001
+ overrides: getOverrides(options, "unocss")
2002
+ }));
1995
2003
  }
1996
2004
  if (options.jsonc ?? true) {
1997
2005
  configs.push(
1998
2006
  jsonc({
1999
- overrides: overrides.jsonc,
2007
+ overrides: getOverrides(options, "jsonc"),
2000
2008
  stylistic: stylisticOptions
2001
2009
  }),
2002
2010
  sortPackageJson(),
@@ -2005,13 +2013,13 @@ async function antfu(options = {}, ...userConfigs) {
2005
2013
  }
2006
2014
  if (options.yaml ?? true) {
2007
2015
  configs.push(yaml({
2008
- overrides: overrides.yaml,
2016
+ overrides: getOverrides(options, "yaml"),
2009
2017
  stylistic: stylisticOptions
2010
2018
  }));
2011
2019
  }
2012
2020
  if (options.toml ?? true) {
2013
2021
  configs.push(toml({
2014
- overrides: overrides.toml,
2022
+ overrides: getOverrides(options, "toml"),
2015
2023
  stylistic: stylisticOptions
2016
2024
  }));
2017
2025
  }
@@ -2020,7 +2028,7 @@ async function antfu(options = {}, ...userConfigs) {
2020
2028
  markdown(
2021
2029
  {
2022
2030
  componentExts,
2023
- overrides: overrides.markdown
2031
+ overrides: getOverrides(options, "markdown")
2024
2032
  }
2025
2033
  )
2026
2034
  );
@@ -2044,6 +2052,16 @@ async function antfu(options = {}, ...userConfigs) {
2044
2052
  );
2045
2053
  return merged;
2046
2054
  }
2055
+ function resolveSubOptions(options, key) {
2056
+ return typeof options[key] === "boolean" ? {} : options[key] || {};
2057
+ }
2058
+ function getOverrides(options, key) {
2059
+ const sub = resolveSubOptions(options, key);
2060
+ return {
2061
+ ...options.overrides?.[key],
2062
+ ..."overrides" in sub ? sub.overrides : {}
2063
+ };
2064
+ }
2047
2065
 
2048
2066
  // src/index.ts
2049
2067
  var src_default = antfu;
@@ -2080,6 +2098,7 @@ var src_default = antfu;
2080
2098
  comments,
2081
2099
  ensurePackages,
2082
2100
  formatters,
2101
+ getOverrides,
2083
2102
  ignores,
2084
2103
  imports,
2085
2104
  interopDefault,
@@ -2092,6 +2111,7 @@ var src_default = antfu;
2092
2111
  perfectionist,
2093
2112
  react,
2094
2113
  renameRules,
2114
+ resolveSubOptions,
2095
2115
  sortPackageJson,
2096
2116
  sortTsconfig,
2097
2117
  stylistic,
package/dist/index.d.cts CHANGED
@@ -136,7 +136,7 @@ interface OptionsFiles {
136
136
  */
137
137
  files?: string[];
138
138
  }
139
- interface OptionsVue {
139
+ interface OptionsVue extends OptionsOverrides {
140
140
  /**
141
141
  * Create virtual files for Vue SFC blocks to enable linting.
142
142
  *
@@ -151,6 +151,7 @@ interface OptionsVue {
151
151
  */
152
152
  vueVersion?: 2 | 3;
153
153
  }
154
+ type OptionsTypescript = (OptionsTypeScriptWithTypes & OptionsOverrides) | (OptionsTypeScriptParserOptions & OptionsOverrides);
154
155
  interface OptionsFormatters {
155
156
  /**
156
157
  * Enable formatting support for CSS, Less, Sass, and SCSS.
@@ -230,7 +231,7 @@ interface OptionsOverrides {
230
231
  interface OptionsIsInEditor {
231
232
  isInEditor?: boolean;
232
233
  }
233
- interface OptionsUnoCSS {
234
+ interface OptionsUnoCSS extends OptionsOverrides {
234
235
  /**
235
236
  * Enable attributify support.
236
237
  * @default true
@@ -252,6 +253,10 @@ interface OptionsConfig extends OptionsComponentExts {
252
253
  * @default true
253
254
  */
254
255
  gitignore?: boolean | FlatGitignoreOptions;
256
+ /**
257
+ * Core rules. Can't be disabled.
258
+ */
259
+ javascript?: OptionsOverrides;
255
260
  /**
256
261
  * Enable TypeScript support.
257
262
  *
@@ -259,7 +264,7 @@ interface OptionsConfig extends OptionsComponentExts {
259
264
  *
260
265
  * @default auto-detect based on the dependencies
261
266
  */
262
- typescript?: boolean | OptionsTypeScriptWithTypes | OptionsTypeScriptParserOptions;
267
+ typescript?: boolean | OptionsTypescript;
263
268
  /**
264
269
  * Enable JSX related rules.
265
270
  *
@@ -273,7 +278,7 @@ interface OptionsConfig extends OptionsComponentExts {
273
278
  *
274
279
  * @default true
275
280
  */
276
- test?: boolean;
281
+ test?: boolean | OptionsOverrides;
277
282
  /**
278
283
  * Enable Vue support.
279
284
  *
@@ -285,19 +290,19 @@ interface OptionsConfig extends OptionsComponentExts {
285
290
  *
286
291
  * @default true
287
292
  */
288
- jsonc?: boolean;
293
+ jsonc?: boolean | OptionsOverrides;
289
294
  /**
290
295
  * Enable YAML support.
291
296
  *
292
297
  * @default true
293
298
  */
294
- yaml?: boolean;
299
+ yaml?: boolean | OptionsOverrides;
295
300
  /**
296
301
  * Enable TOML support.
297
302
  *
298
303
  * @default true
299
304
  */
300
- toml?: boolean;
305
+ toml?: boolean | OptionsOverrides;
301
306
  /**
302
307
  * Enable linting for **code snippets** in Markdown.
303
308
  *
@@ -305,7 +310,7 @@ interface OptionsConfig extends OptionsComponentExts {
305
310
  *
306
311
  * @default true
307
312
  */
308
- markdown?: boolean;
313
+ markdown?: boolean | OptionsOverrides;
309
314
  /**
310
315
  * Enable stylistic rules.
311
316
  *
@@ -322,7 +327,7 @@ interface OptionsConfig extends OptionsComponentExts {
322
327
  *
323
328
  * @default false
324
329
  */
325
- react?: boolean;
330
+ react?: boolean | OptionsOverrides;
326
331
  /**
327
332
  * Enable svelte rules.
328
333
  *
@@ -359,6 +364,8 @@ interface OptionsConfig extends OptionsComponentExts {
359
364
  isInEditor?: boolean;
360
365
  /**
361
366
  * Provide overrides for rules for each integration.
367
+ *
368
+ * @deprecated use `overrides` option in each integration key instead
362
369
  */
363
370
  overrides?: {
364
371
  stylistic?: FlatConfigItem['rules'];
@@ -379,6 +386,9 @@ interface OptionsConfig extends OptionsComponentExts {
379
386
  * Construct an array of ESLint flat config items.
380
387
  */
381
388
  declare function antfu(options?: OptionsConfig & FlatConfigItem, ...userConfigs: Awaitable<UserConfigItem | UserConfigItem[]>[]): Promise<UserConfigItem[]>;
389
+ type ResolvedOptions<T> = T extends boolean ? never : NonNullable<T>;
390
+ declare function resolveSubOptions<K extends keyof OptionsConfig>(options: OptionsConfig, key: K): ResolvedOptions<OptionsConfig[K]>;
391
+ declare function getOverrides<K extends keyof OptionsConfig>(options: OptionsConfig, key: K): any;
382
392
 
383
393
  declare function comments(): Promise<FlatConfigItem[]>;
384
394
 
@@ -503,4 +513,4 @@ declare function interopDefault<T>(m: Awaitable<T>): Promise<T extends {
503
513
  } ? U : T>;
504
514
  declare function ensurePackages(packages: string[]): Promise<void>;
505
515
 
506
- 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_SVELTE, 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, svelte, test, toArray, toml, typescript, unicorn, unocss, vue, yaml };
516
+ 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_SVELTE, 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 OptionsTypescript, type OptionsUnoCSS, type OptionsVue, type ResolvedOptions, type Rules, type StylisticConfig, StylisticConfigDefaults, type UserConfigItem, type WrapRuleConfig, antfu, combine, comments, antfu as default, ensurePackages, formatters, getOverrides, ignores, imports, interopDefault, javascript, jsdoc, jsonc, markdown, node, parserPlain, perfectionist, react, renameRules, resolveSubOptions, sortPackageJson, sortTsconfig, stylistic, svelte, test, toArray, toml, typescript, unicorn, unocss, vue, yaml };
package/dist/index.d.ts CHANGED
@@ -136,7 +136,7 @@ interface OptionsFiles {
136
136
  */
137
137
  files?: string[];
138
138
  }
139
- interface OptionsVue {
139
+ interface OptionsVue extends OptionsOverrides {
140
140
  /**
141
141
  * Create virtual files for Vue SFC blocks to enable linting.
142
142
  *
@@ -151,6 +151,7 @@ interface OptionsVue {
151
151
  */
152
152
  vueVersion?: 2 | 3;
153
153
  }
154
+ type OptionsTypescript = (OptionsTypeScriptWithTypes & OptionsOverrides) | (OptionsTypeScriptParserOptions & OptionsOverrides);
154
155
  interface OptionsFormatters {
155
156
  /**
156
157
  * Enable formatting support for CSS, Less, Sass, and SCSS.
@@ -230,7 +231,7 @@ interface OptionsOverrides {
230
231
  interface OptionsIsInEditor {
231
232
  isInEditor?: boolean;
232
233
  }
233
- interface OptionsUnoCSS {
234
+ interface OptionsUnoCSS extends OptionsOverrides {
234
235
  /**
235
236
  * Enable attributify support.
236
237
  * @default true
@@ -252,6 +253,10 @@ interface OptionsConfig extends OptionsComponentExts {
252
253
  * @default true
253
254
  */
254
255
  gitignore?: boolean | FlatGitignoreOptions;
256
+ /**
257
+ * Core rules. Can't be disabled.
258
+ */
259
+ javascript?: OptionsOverrides;
255
260
  /**
256
261
  * Enable TypeScript support.
257
262
  *
@@ -259,7 +264,7 @@ interface OptionsConfig extends OptionsComponentExts {
259
264
  *
260
265
  * @default auto-detect based on the dependencies
261
266
  */
262
- typescript?: boolean | OptionsTypeScriptWithTypes | OptionsTypeScriptParserOptions;
267
+ typescript?: boolean | OptionsTypescript;
263
268
  /**
264
269
  * Enable JSX related rules.
265
270
  *
@@ -273,7 +278,7 @@ interface OptionsConfig extends OptionsComponentExts {
273
278
  *
274
279
  * @default true
275
280
  */
276
- test?: boolean;
281
+ test?: boolean | OptionsOverrides;
277
282
  /**
278
283
  * Enable Vue support.
279
284
  *
@@ -285,19 +290,19 @@ interface OptionsConfig extends OptionsComponentExts {
285
290
  *
286
291
  * @default true
287
292
  */
288
- jsonc?: boolean;
293
+ jsonc?: boolean | OptionsOverrides;
289
294
  /**
290
295
  * Enable YAML support.
291
296
  *
292
297
  * @default true
293
298
  */
294
- yaml?: boolean;
299
+ yaml?: boolean | OptionsOverrides;
295
300
  /**
296
301
  * Enable TOML support.
297
302
  *
298
303
  * @default true
299
304
  */
300
- toml?: boolean;
305
+ toml?: boolean | OptionsOverrides;
301
306
  /**
302
307
  * Enable linting for **code snippets** in Markdown.
303
308
  *
@@ -305,7 +310,7 @@ interface OptionsConfig extends OptionsComponentExts {
305
310
  *
306
311
  * @default true
307
312
  */
308
- markdown?: boolean;
313
+ markdown?: boolean | OptionsOverrides;
309
314
  /**
310
315
  * Enable stylistic rules.
311
316
  *
@@ -322,7 +327,7 @@ interface OptionsConfig extends OptionsComponentExts {
322
327
  *
323
328
  * @default false
324
329
  */
325
- react?: boolean;
330
+ react?: boolean | OptionsOverrides;
326
331
  /**
327
332
  * Enable svelte rules.
328
333
  *
@@ -359,6 +364,8 @@ interface OptionsConfig extends OptionsComponentExts {
359
364
  isInEditor?: boolean;
360
365
  /**
361
366
  * Provide overrides for rules for each integration.
367
+ *
368
+ * @deprecated use `overrides` option in each integration key instead
362
369
  */
363
370
  overrides?: {
364
371
  stylistic?: FlatConfigItem['rules'];
@@ -379,6 +386,9 @@ interface OptionsConfig extends OptionsComponentExts {
379
386
  * Construct an array of ESLint flat config items.
380
387
  */
381
388
  declare function antfu(options?: OptionsConfig & FlatConfigItem, ...userConfigs: Awaitable<UserConfigItem | UserConfigItem[]>[]): Promise<UserConfigItem[]>;
389
+ type ResolvedOptions<T> = T extends boolean ? never : NonNullable<T>;
390
+ declare function resolveSubOptions<K extends keyof OptionsConfig>(options: OptionsConfig, key: K): ResolvedOptions<OptionsConfig[K]>;
391
+ declare function getOverrides<K extends keyof OptionsConfig>(options: OptionsConfig, key: K): any;
382
392
 
383
393
  declare function comments(): Promise<FlatConfigItem[]>;
384
394
 
@@ -503,4 +513,4 @@ declare function interopDefault<T>(m: Awaitable<T>): Promise<T extends {
503
513
  } ? U : T>;
504
514
  declare function ensurePackages(packages: string[]): Promise<void>;
505
515
 
506
- 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_SVELTE, 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, svelte, test, toArray, toml, typescript, unicorn, unocss, vue, yaml };
516
+ 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_SVELTE, 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 OptionsTypescript, type OptionsUnoCSS, type OptionsVue, type ResolvedOptions, type Rules, type StylisticConfig, StylisticConfigDefaults, type UserConfigItem, type WrapRuleConfig, antfu, combine, comments, antfu as default, ensurePackages, formatters, getOverrides, ignores, imports, interopDefault, javascript, jsdoc, jsonc, markdown, node, parserPlain, perfectionist, react, renameRules, resolveSubOptions, sortPackageJson, sortTsconfig, stylistic, svelte, test, toArray, toml, typescript, unicorn, unocss, vue, yaml };
package/dist/index.js CHANGED
@@ -138,6 +138,14 @@ async function imports(options = {}) {
138
138
  "import/newline-after-import": ["error", { considerComments: true, count: 1 }]
139
139
  } : {}
140
140
  }
141
+ },
142
+ {
143
+ files: ["**/bin/**/*", `**/bin.${GLOB_SRC_EXT}`],
144
+ name: "antfu:imports:bin",
145
+ rules: {
146
+ "antfu/no-import-dist": "off",
147
+ "antfu/no-import-node-modules-by-path": "off"
148
+ }
141
149
  }
142
150
  ];
143
151
  }
@@ -1818,7 +1826,6 @@ async function antfu(options = {}, ...userConfigs) {
1818
1826
  componentExts = [],
1819
1827
  gitignore: enableGitignore = true,
1820
1828
  isInEditor = !!((process3.env.VSCODE_PID || process3.env.JETBRAINS_IDE || process3.env.VIM) && !process3.env.CI),
1821
- overrides = {},
1822
1829
  react: enableReact = false,
1823
1830
  svelte: enableSvelte = false,
1824
1831
  typescript: enableTypeScript = isPackageExists3("typescript"),
@@ -1841,7 +1848,7 @@ async function antfu(options = {}, ...userConfigs) {
1841
1848
  ignores(),
1842
1849
  javascript({
1843
1850
  isInEditor,
1844
- overrides: overrides.javascript
1851
+ overrides: getOverrides(options, "javascript")
1845
1852
  }),
1846
1853
  comments(),
1847
1854
  node(),
@@ -1859,53 +1866,52 @@ async function antfu(options = {}, ...userConfigs) {
1859
1866
  componentExts.push("vue");
1860
1867
  if (enableTypeScript) {
1861
1868
  configs.push(typescript({
1862
- ...typeof enableTypeScript !== "boolean" ? enableTypeScript : {},
1863
- componentExts,
1864
- overrides: overrides.typescript
1869
+ ...resolveSubOptions(options, "typescript"),
1870
+ componentExts
1865
1871
  }));
1866
1872
  }
1867
1873
  if (stylisticOptions) {
1868
1874
  configs.push(stylistic({
1869
1875
  ...stylisticOptions,
1870
- overrides: overrides.stylistic
1876
+ overrides: getOverrides(options, "stylistic")
1871
1877
  }));
1872
1878
  }
1873
1879
  if (options.test ?? true) {
1874
1880
  configs.push(test({
1875
1881
  isInEditor,
1876
- overrides: overrides.test
1882
+ overrides: getOverrides(options, "test")
1877
1883
  }));
1878
1884
  }
1879
1885
  if (enableVue) {
1880
1886
  configs.push(vue({
1881
- ...typeof enableVue !== "boolean" ? enableVue : {},
1882
- overrides: overrides.vue,
1887
+ ...resolveSubOptions(options, "vue"),
1883
1888
  stylistic: stylisticOptions,
1884
1889
  typescript: !!enableTypeScript
1885
1890
  }));
1886
1891
  }
1887
1892
  if (enableReact) {
1888
1893
  configs.push(react({
1889
- overrides: overrides.react,
1894
+ overrides: getOverrides(options, "react"),
1890
1895
  typescript: !!enableTypeScript
1891
1896
  }));
1892
1897
  }
1893
1898
  if (enableSvelte) {
1894
1899
  configs.push(svelte({
1895
- overrides: overrides.svelte,
1900
+ overrides: getOverrides(options, "svelte"),
1896
1901
  stylistic: stylisticOptions,
1897
1902
  typescript: !!enableTypeScript
1898
1903
  }));
1899
1904
  }
1900
1905
  if (enableUnoCSS) {
1901
- configs.push(unocss(
1902
- typeof enableUnoCSS === "boolean" ? {} : enableUnoCSS
1903
- ));
1906
+ configs.push(unocss({
1907
+ ...resolveSubOptions(options, "unocss"),
1908
+ overrides: getOverrides(options, "unocss")
1909
+ }));
1904
1910
  }
1905
1911
  if (options.jsonc ?? true) {
1906
1912
  configs.push(
1907
1913
  jsonc({
1908
- overrides: overrides.jsonc,
1914
+ overrides: getOverrides(options, "jsonc"),
1909
1915
  stylistic: stylisticOptions
1910
1916
  }),
1911
1917
  sortPackageJson(),
@@ -1914,13 +1920,13 @@ async function antfu(options = {}, ...userConfigs) {
1914
1920
  }
1915
1921
  if (options.yaml ?? true) {
1916
1922
  configs.push(yaml({
1917
- overrides: overrides.yaml,
1923
+ overrides: getOverrides(options, "yaml"),
1918
1924
  stylistic: stylisticOptions
1919
1925
  }));
1920
1926
  }
1921
1927
  if (options.toml ?? true) {
1922
1928
  configs.push(toml({
1923
- overrides: overrides.toml,
1929
+ overrides: getOverrides(options, "toml"),
1924
1930
  stylistic: stylisticOptions
1925
1931
  }));
1926
1932
  }
@@ -1929,7 +1935,7 @@ async function antfu(options = {}, ...userConfigs) {
1929
1935
  markdown(
1930
1936
  {
1931
1937
  componentExts,
1932
- overrides: overrides.markdown
1938
+ overrides: getOverrides(options, "markdown")
1933
1939
  }
1934
1940
  )
1935
1941
  );
@@ -1953,6 +1959,16 @@ async function antfu(options = {}, ...userConfigs) {
1953
1959
  );
1954
1960
  return merged;
1955
1961
  }
1962
+ function resolveSubOptions(options, key) {
1963
+ return typeof options[key] === "boolean" ? {} : options[key] || {};
1964
+ }
1965
+ function getOverrides(options, key) {
1966
+ const sub = resolveSubOptions(options, key);
1967
+ return {
1968
+ ...options.overrides?.[key],
1969
+ ..."overrides" in sub ? sub.overrides : {}
1970
+ };
1971
+ }
1956
1972
 
1957
1973
  // src/index.ts
1958
1974
  var src_default = antfu;
@@ -1989,6 +2005,7 @@ export {
1989
2005
  src_default as default,
1990
2006
  ensurePackages,
1991
2007
  formatters,
2008
+ getOverrides,
1992
2009
  ignores,
1993
2010
  imports,
1994
2011
  interopDefault,
@@ -2001,6 +2018,7 @@ export {
2001
2018
  perfectionist,
2002
2019
  react,
2003
2020
  renameRules,
2021
+ resolveSubOptions,
2004
2022
  sortPackageJson,
2005
2023
  sortTsconfig,
2006
2024
  stylistic,
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@antfu/eslint-config",
3
3
  "type": "module",
4
- "version": "2.5.0",
5
- "packageManager": "pnpm@8.12.1",
4
+ "version": "2.6.1",
5
+ "packageManager": "pnpm@8.13.1",
6
6
  "description": "Anthony's ESLint config",
7
7
  "author": "Anthony Fu <anthonyfu117@hotmail.com> (https://github.com/antfu/)",
8
8
  "license": "MIT",
@@ -61,14 +61,14 @@
61
61
  "@antfu/eslint-define-config": "^1.23.0-2",
62
62
  "@antfu/install-pkg": "^0.3.1",
63
63
  "@eslint-types/jsdoc": "46.8.2-1",
64
- "@eslint-types/typescript-eslint": "^6.12.0",
65
- "@eslint-types/unicorn": "^49.0.0",
64
+ "@eslint-types/typescript-eslint": "^6.16.0",
65
+ "@eslint-types/unicorn": "^50.0.1",
66
66
  "@stylistic/eslint-plugin": "^1.5.1",
67
- "@typescript-eslint/eslint-plugin": "^6.15.0",
68
- "@typescript-eslint/parser": "^6.15.0",
67
+ "@typescript-eslint/eslint-plugin": "^6.16.0",
68
+ "@typescript-eslint/parser": "^6.16.0",
69
69
  "eslint-config-flat-gitignore": "^0.1.2",
70
70
  "eslint-merge-processors": "^0.1.0",
71
- "eslint-plugin-antfu": "^2.1.0",
71
+ "eslint-plugin-antfu": "^2.1.1",
72
72
  "eslint-plugin-eslint-comments": "^3.2.0",
73
73
  "eslint-plugin-i": "^2.29.1",
74
74
  "eslint-plugin-jsdoc": "^46.9.1",
@@ -106,14 +106,14 @@
106
106
  "@types/yargs": "^17.0.32",
107
107
  "@unocss/eslint-plugin": "^0.58.0",
108
108
  "bumpp": "^9.2.1",
109
- "eslint": "npm:eslint-ts-patch@^8.55.0-1",
109
+ "eslint": "npm:eslint-ts-patch@^8.56.0-0",
110
110
  "eslint-flat-config-viewer": "^0.1.3",
111
111
  "eslint-plugin-format": "^0.1.0",
112
112
  "eslint-plugin-react": "^7.33.2",
113
113
  "eslint-plugin-react-hooks": "^4.6.0",
114
114
  "eslint-plugin-react-refresh": "^0.4.5",
115
115
  "eslint-plugin-svelte": "^2.35.1",
116
- "eslint-ts-patch": "^8.55.0-1",
116
+ "eslint-ts-patch": "^8.56.0-0",
117
117
  "esno": "^4.0.0",
118
118
  "execa": "^8.0.1",
119
119
  "fast-glob": "^3.3.2",
@@ -126,7 +126,7 @@
126
126
  "typescript": "^5.3.3",
127
127
  "vitest": "^1.1.0",
128
128
  "vue": "^3.3.13",
129
- "@antfu/eslint-config": "2.5.0"
129
+ "@antfu/eslint-config": "2.6.1"
130
130
  },
131
131
  "simple-git-hooks": {
132
132
  "pre-commit": "pnpm lint-staged"