@antfu/eslint-config 2.5.0 → 2.6.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/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/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.0";
50
50
  var devDependencies = {
51
51
  "@antfu/eslint-config": "workspace:*",
52
52
  "@antfu/eslint-plugin-prettier": "^5.0.1-1",
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.0";
21
21
  var devDependencies = {
22
22
  "@antfu/eslint-config": "workspace:*",
23
23
  "@antfu/eslint-plugin-prettier": "^5.0.1-1",
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,
@@ -1909,7 +1911,6 @@ async function antfu(options = {}, ...userConfigs) {
1909
1911
  componentExts = [],
1910
1912
  gitignore: enableGitignore = true,
1911
1913
  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
1914
  react: enableReact = false,
1914
1915
  svelte: enableSvelte = false,
1915
1916
  typescript: enableTypeScript = (0, import_local_pkg3.isPackageExists)("typescript"),
@@ -1932,7 +1933,7 @@ async function antfu(options = {}, ...userConfigs) {
1932
1933
  ignores(),
1933
1934
  javascript({
1934
1935
  isInEditor,
1935
- overrides: overrides.javascript
1936
+ overrides: getOverrides(options, "javascript")
1936
1937
  }),
1937
1938
  comments(),
1938
1939
  node(),
@@ -1950,53 +1951,52 @@ async function antfu(options = {}, ...userConfigs) {
1950
1951
  componentExts.push("vue");
1951
1952
  if (enableTypeScript) {
1952
1953
  configs.push(typescript({
1953
- ...typeof enableTypeScript !== "boolean" ? enableTypeScript : {},
1954
- componentExts,
1955
- overrides: overrides.typescript
1954
+ ...resolveSubOptions(options, "typescript"),
1955
+ componentExts
1956
1956
  }));
1957
1957
  }
1958
1958
  if (stylisticOptions) {
1959
1959
  configs.push(stylistic({
1960
1960
  ...stylisticOptions,
1961
- overrides: overrides.stylistic
1961
+ overrides: getOverrides(options, "stylistic")
1962
1962
  }));
1963
1963
  }
1964
1964
  if (options.test ?? true) {
1965
1965
  configs.push(test({
1966
1966
  isInEditor,
1967
- overrides: overrides.test
1967
+ overrides: getOverrides(options, "test")
1968
1968
  }));
1969
1969
  }
1970
1970
  if (enableVue) {
1971
1971
  configs.push(vue({
1972
- ...typeof enableVue !== "boolean" ? enableVue : {},
1973
- overrides: overrides.vue,
1972
+ ...resolveSubOptions(options, "vue"),
1974
1973
  stylistic: stylisticOptions,
1975
1974
  typescript: !!enableTypeScript
1976
1975
  }));
1977
1976
  }
1978
1977
  if (enableReact) {
1979
1978
  configs.push(react({
1980
- overrides: overrides.react,
1979
+ overrides: getOverrides(options, "react"),
1981
1980
  typescript: !!enableTypeScript
1982
1981
  }));
1983
1982
  }
1984
1983
  if (enableSvelte) {
1985
1984
  configs.push(svelte({
1986
- overrides: overrides.svelte,
1985
+ overrides: getOverrides(options, "svelte"),
1987
1986
  stylistic: stylisticOptions,
1988
1987
  typescript: !!enableTypeScript
1989
1988
  }));
1990
1989
  }
1991
1990
  if (enableUnoCSS) {
1992
- configs.push(unocss(
1993
- typeof enableUnoCSS === "boolean" ? {} : enableUnoCSS
1994
- ));
1991
+ configs.push(unocss({
1992
+ ...resolveSubOptions(options, "unocss"),
1993
+ overrides: getOverrides(options, "unocss")
1994
+ }));
1995
1995
  }
1996
1996
  if (options.jsonc ?? true) {
1997
1997
  configs.push(
1998
1998
  jsonc({
1999
- overrides: overrides.jsonc,
1999
+ overrides: getOverrides(options, "jsonc"),
2000
2000
  stylistic: stylisticOptions
2001
2001
  }),
2002
2002
  sortPackageJson(),
@@ -2005,13 +2005,13 @@ async function antfu(options = {}, ...userConfigs) {
2005
2005
  }
2006
2006
  if (options.yaml ?? true) {
2007
2007
  configs.push(yaml({
2008
- overrides: overrides.yaml,
2008
+ overrides: getOverrides(options, "yaml"),
2009
2009
  stylistic: stylisticOptions
2010
2010
  }));
2011
2011
  }
2012
2012
  if (options.toml ?? true) {
2013
2013
  configs.push(toml({
2014
- overrides: overrides.toml,
2014
+ overrides: getOverrides(options, "toml"),
2015
2015
  stylistic: stylisticOptions
2016
2016
  }));
2017
2017
  }
@@ -2020,7 +2020,7 @@ async function antfu(options = {}, ...userConfigs) {
2020
2020
  markdown(
2021
2021
  {
2022
2022
  componentExts,
2023
- overrides: overrides.markdown
2023
+ overrides: getOverrides(options, "markdown")
2024
2024
  }
2025
2025
  )
2026
2026
  );
@@ -2044,6 +2044,16 @@ async function antfu(options = {}, ...userConfigs) {
2044
2044
  );
2045
2045
  return merged;
2046
2046
  }
2047
+ function resolveSubOptions(options, key) {
2048
+ return typeof options[key] === "boolean" ? {} : options[key] || {};
2049
+ }
2050
+ function getOverrides(options, key) {
2051
+ const sub = resolveSubOptions(options, key);
2052
+ return {
2053
+ ...options.overrides?.[key],
2054
+ ..."overrides" in sub ? sub.overrides : {}
2055
+ };
2056
+ }
2047
2057
 
2048
2058
  // src/index.ts
2049
2059
  var src_default = antfu;
@@ -2080,6 +2090,7 @@ var src_default = antfu;
2080
2090
  comments,
2081
2091
  ensurePackages,
2082
2092
  formatters,
2093
+ getOverrides,
2083
2094
  ignores,
2084
2095
  imports,
2085
2096
  interopDefault,
@@ -2092,6 +2103,7 @@ var src_default = antfu;
2092
2103
  perfectionist,
2093
2104
  react,
2094
2105
  renameRules,
2106
+ resolveSubOptions,
2095
2107
  sortPackageJson,
2096
2108
  sortTsconfig,
2097
2109
  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
@@ -1818,7 +1818,6 @@ async function antfu(options = {}, ...userConfigs) {
1818
1818
  componentExts = [],
1819
1819
  gitignore: enableGitignore = true,
1820
1820
  isInEditor = !!((process3.env.VSCODE_PID || process3.env.JETBRAINS_IDE || process3.env.VIM) && !process3.env.CI),
1821
- overrides = {},
1822
1821
  react: enableReact = false,
1823
1822
  svelte: enableSvelte = false,
1824
1823
  typescript: enableTypeScript = isPackageExists3("typescript"),
@@ -1841,7 +1840,7 @@ async function antfu(options = {}, ...userConfigs) {
1841
1840
  ignores(),
1842
1841
  javascript({
1843
1842
  isInEditor,
1844
- overrides: overrides.javascript
1843
+ overrides: getOverrides(options, "javascript")
1845
1844
  }),
1846
1845
  comments(),
1847
1846
  node(),
@@ -1859,53 +1858,52 @@ async function antfu(options = {}, ...userConfigs) {
1859
1858
  componentExts.push("vue");
1860
1859
  if (enableTypeScript) {
1861
1860
  configs.push(typescript({
1862
- ...typeof enableTypeScript !== "boolean" ? enableTypeScript : {},
1863
- componentExts,
1864
- overrides: overrides.typescript
1861
+ ...resolveSubOptions(options, "typescript"),
1862
+ componentExts
1865
1863
  }));
1866
1864
  }
1867
1865
  if (stylisticOptions) {
1868
1866
  configs.push(stylistic({
1869
1867
  ...stylisticOptions,
1870
- overrides: overrides.stylistic
1868
+ overrides: getOverrides(options, "stylistic")
1871
1869
  }));
1872
1870
  }
1873
1871
  if (options.test ?? true) {
1874
1872
  configs.push(test({
1875
1873
  isInEditor,
1876
- overrides: overrides.test
1874
+ overrides: getOverrides(options, "test")
1877
1875
  }));
1878
1876
  }
1879
1877
  if (enableVue) {
1880
1878
  configs.push(vue({
1881
- ...typeof enableVue !== "boolean" ? enableVue : {},
1882
- overrides: overrides.vue,
1879
+ ...resolveSubOptions(options, "vue"),
1883
1880
  stylistic: stylisticOptions,
1884
1881
  typescript: !!enableTypeScript
1885
1882
  }));
1886
1883
  }
1887
1884
  if (enableReact) {
1888
1885
  configs.push(react({
1889
- overrides: overrides.react,
1886
+ overrides: getOverrides(options, "react"),
1890
1887
  typescript: !!enableTypeScript
1891
1888
  }));
1892
1889
  }
1893
1890
  if (enableSvelte) {
1894
1891
  configs.push(svelte({
1895
- overrides: overrides.svelte,
1892
+ overrides: getOverrides(options, "svelte"),
1896
1893
  stylistic: stylisticOptions,
1897
1894
  typescript: !!enableTypeScript
1898
1895
  }));
1899
1896
  }
1900
1897
  if (enableUnoCSS) {
1901
- configs.push(unocss(
1902
- typeof enableUnoCSS === "boolean" ? {} : enableUnoCSS
1903
- ));
1898
+ configs.push(unocss({
1899
+ ...resolveSubOptions(options, "unocss"),
1900
+ overrides: getOverrides(options, "unocss")
1901
+ }));
1904
1902
  }
1905
1903
  if (options.jsonc ?? true) {
1906
1904
  configs.push(
1907
1905
  jsonc({
1908
- overrides: overrides.jsonc,
1906
+ overrides: getOverrides(options, "jsonc"),
1909
1907
  stylistic: stylisticOptions
1910
1908
  }),
1911
1909
  sortPackageJson(),
@@ -1914,13 +1912,13 @@ async function antfu(options = {}, ...userConfigs) {
1914
1912
  }
1915
1913
  if (options.yaml ?? true) {
1916
1914
  configs.push(yaml({
1917
- overrides: overrides.yaml,
1915
+ overrides: getOverrides(options, "yaml"),
1918
1916
  stylistic: stylisticOptions
1919
1917
  }));
1920
1918
  }
1921
1919
  if (options.toml ?? true) {
1922
1920
  configs.push(toml({
1923
- overrides: overrides.toml,
1921
+ overrides: getOverrides(options, "toml"),
1924
1922
  stylistic: stylisticOptions
1925
1923
  }));
1926
1924
  }
@@ -1929,7 +1927,7 @@ async function antfu(options = {}, ...userConfigs) {
1929
1927
  markdown(
1930
1928
  {
1931
1929
  componentExts,
1932
- overrides: overrides.markdown
1930
+ overrides: getOverrides(options, "markdown")
1933
1931
  }
1934
1932
  )
1935
1933
  );
@@ -1953,6 +1951,16 @@ async function antfu(options = {}, ...userConfigs) {
1953
1951
  );
1954
1952
  return merged;
1955
1953
  }
1954
+ function resolveSubOptions(options, key) {
1955
+ return typeof options[key] === "boolean" ? {} : options[key] || {};
1956
+ }
1957
+ function getOverrides(options, key) {
1958
+ const sub = resolveSubOptions(options, key);
1959
+ return {
1960
+ ...options.overrides?.[key],
1961
+ ..."overrides" in sub ? sub.overrides : {}
1962
+ };
1963
+ }
1956
1964
 
1957
1965
  // src/index.ts
1958
1966
  var src_default = antfu;
@@ -1989,6 +1997,7 @@ export {
1989
1997
  src_default as default,
1990
1998
  ensurePackages,
1991
1999
  formatters,
2000
+ getOverrides,
1992
2001
  ignores,
1993
2002
  imports,
1994
2003
  interopDefault,
@@ -2001,6 +2010,7 @@ export {
2001
2010
  perfectionist,
2002
2011
  react,
2003
2012
  renameRules,
2013
+ resolveSubOptions,
2004
2014
  sortPackageJson,
2005
2015
  sortTsconfig,
2006
2016
  stylistic,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@antfu/eslint-config",
3
3
  "type": "module",
4
- "version": "2.5.0",
4
+ "version": "2.6.0",
5
5
  "packageManager": "pnpm@8.12.1",
6
6
  "description": "Anthony's ESLint config",
7
7
  "author": "Anthony Fu <anthonyfu117@hotmail.com> (https://github.com/antfu/)",
@@ -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.0"
130
130
  },
131
131
  "simple-git-hooks": {
132
132
  "pre-commit": "pnpm lint-staged"