@antfu/eslint-config 2.22.4 → 2.23.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
@@ -172,6 +172,9 @@ And that's it! Or you can configure each integration individually, for example:
172
172
  import antfu from '@antfu/eslint-config'
173
173
 
174
174
  export default antfu({
175
+ // Type of the project. 'lib' for libraries, the default is 'app'
176
+ type: 'lib',
177
+
175
178
  // Enable stylistic formatting rules
176
179
  // stylistic: true,
177
180
 
@@ -181,7 +184,7 @@ export default antfu({
181
184
  quotes: 'single', // or 'double'
182
185
  },
183
186
 
184
- // TypeScript and Vue are auto-detected, you can also explicitly enable them:
187
+ // TypeScript and Vue are autoetected, you can also explicitly enable them:
185
188
  typescript: true,
186
189
  vue: true,
187
190
 
package/dist/cli.cjs CHANGED
@@ -48,7 +48,7 @@ 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.22.4",
51
+ version: "2.23.0",
52
52
  packageManager: "pnpm@9.5.0",
53
53
  description: "Anthony's ESLint config",
54
54
  author: "Anthony Fu <anthonyfu117@hotmail.com> (https://github.com/antfu/)",
@@ -143,6 +143,7 @@ var package_default = {
143
143
  }
144
144
  },
145
145
  dependencies: {
146
+ "@antfu/eslint-plugin-unused-imports": "^4.0.0",
146
147
  "@antfu/install-pkg": "^0.3.3",
147
148
  "@clack/prompts": "^0.7.0",
148
149
  "@stylistic/eslint-plugin": "^2.6.0-beta.0",
@@ -164,7 +165,6 @@ var package_default = {
164
165
  "eslint-plugin-regexp": "^2.6.0",
165
166
  "eslint-plugin-toml": "^0.11.1",
166
167
  "eslint-plugin-unicorn": "^54.0.0",
167
- "eslint-plugin-unused-imports": "^4.0.0",
168
168
  "eslint-plugin-vitest": "^0.5.4",
169
169
  "eslint-plugin-vue": "^9.27.0",
170
170
  "eslint-plugin-yml": "^1.14.0",
@@ -182,16 +182,16 @@ var package_default = {
182
182
  devDependencies: {
183
183
  "@antfu/eslint-config": "workspace:*",
184
184
  "@antfu/ni": "^0.22.0",
185
- "@eslint-react/eslint-plugin": "^1.5.26",
185
+ "@eslint-react/eslint-plugin": "^1.5.27",
186
186
  "@eslint/config-inspector": "^0.5.1",
187
187
  "@prettier/plugin-xml": "^3.4.1",
188
188
  "@stylistic/eslint-plugin-migrate": "^2.3.0",
189
189
  "@types/eslint": "^8.56.10",
190
190
  "@types/fs-extra": "^11.0.4",
191
- "@types/node": "^20.14.10",
191
+ "@types/node": "^20.14.11",
192
192
  "@types/prompts": "^2.4.9",
193
193
  "@types/yargs": "^17.0.32",
194
- "@unocss/eslint-plugin": "^0.61.4",
194
+ "@unocss/eslint-plugin": "^0.61.5",
195
195
  "astro-eslint-parser": "^1.0.2",
196
196
  bumpp: "^9.4.1",
197
197
  eslint: "npm:eslint-ts-patch@9.5.0-0",
@@ -208,17 +208,17 @@ var package_default = {
208
208
  "fast-glob": "^3.3.2",
209
209
  "fs-extra": "^11.2.0",
210
210
  "lint-staged": "^15.2.7",
211
- "prettier-plugin-astro": "^0.14.0",
211
+ "prettier-plugin-astro": "^0.14.1",
212
212
  "prettier-plugin-slidev": "^1.0.5",
213
213
  rimraf: "^6.0.1",
214
214
  "simple-git-hooks": "^2.11.1",
215
215
  svelte: "^4.2.18",
216
216
  "svelte-eslint-parser": "^0.40.0",
217
- tsup: "^8.1.0",
217
+ tsup: "^8.1.2",
218
218
  tsx: "^4.16.2",
219
219
  typescript: "^5.5.3",
220
220
  vitest: "^2.0.3",
221
- vue: "^3.4.31"
221
+ vue: "^3.4.32"
222
222
  },
223
223
  resolutions: {
224
224
  tsx: "~4.16.2"
package/dist/cli.js CHANGED
@@ -19,7 +19,7 @@ import c from "picocolors";
19
19
  var package_default = {
20
20
  name: "@antfu/eslint-config",
21
21
  type: "module",
22
- version: "2.22.4",
22
+ version: "2.23.0",
23
23
  packageManager: "pnpm@9.5.0",
24
24
  description: "Anthony's ESLint config",
25
25
  author: "Anthony Fu <anthonyfu117@hotmail.com> (https://github.com/antfu/)",
@@ -114,6 +114,7 @@ var package_default = {
114
114
  }
115
115
  },
116
116
  dependencies: {
117
+ "@antfu/eslint-plugin-unused-imports": "^4.0.0",
117
118
  "@antfu/install-pkg": "^0.3.3",
118
119
  "@clack/prompts": "^0.7.0",
119
120
  "@stylistic/eslint-plugin": "^2.6.0-beta.0",
@@ -135,7 +136,6 @@ var package_default = {
135
136
  "eslint-plugin-regexp": "^2.6.0",
136
137
  "eslint-plugin-toml": "^0.11.1",
137
138
  "eslint-plugin-unicorn": "^54.0.0",
138
- "eslint-plugin-unused-imports": "^4.0.0",
139
139
  "eslint-plugin-vitest": "^0.5.4",
140
140
  "eslint-plugin-vue": "^9.27.0",
141
141
  "eslint-plugin-yml": "^1.14.0",
@@ -153,16 +153,16 @@ var package_default = {
153
153
  devDependencies: {
154
154
  "@antfu/eslint-config": "workspace:*",
155
155
  "@antfu/ni": "^0.22.0",
156
- "@eslint-react/eslint-plugin": "^1.5.26",
156
+ "@eslint-react/eslint-plugin": "^1.5.27",
157
157
  "@eslint/config-inspector": "^0.5.1",
158
158
  "@prettier/plugin-xml": "^3.4.1",
159
159
  "@stylistic/eslint-plugin-migrate": "^2.3.0",
160
160
  "@types/eslint": "^8.56.10",
161
161
  "@types/fs-extra": "^11.0.4",
162
- "@types/node": "^20.14.10",
162
+ "@types/node": "^20.14.11",
163
163
  "@types/prompts": "^2.4.9",
164
164
  "@types/yargs": "^17.0.32",
165
- "@unocss/eslint-plugin": "^0.61.4",
165
+ "@unocss/eslint-plugin": "^0.61.5",
166
166
  "astro-eslint-parser": "^1.0.2",
167
167
  bumpp: "^9.4.1",
168
168
  eslint: "npm:eslint-ts-patch@9.5.0-0",
@@ -179,17 +179,17 @@ var package_default = {
179
179
  "fast-glob": "^3.3.2",
180
180
  "fs-extra": "^11.2.0",
181
181
  "lint-staged": "^15.2.7",
182
- "prettier-plugin-astro": "^0.14.0",
182
+ "prettier-plugin-astro": "^0.14.1",
183
183
  "prettier-plugin-slidev": "^1.0.5",
184
184
  rimraf: "^6.0.1",
185
185
  "simple-git-hooks": "^2.11.1",
186
186
  svelte: "^4.2.18",
187
187
  "svelte-eslint-parser": "^0.40.0",
188
- tsup: "^8.1.0",
188
+ tsup: "^8.1.2",
189
189
  tsx: "^4.16.2",
190
190
  typescript: "^5.5.3",
191
191
  vitest: "^2.0.3",
192
- vue: "^3.4.31"
192
+ vue: "^3.4.32"
193
193
  },
194
194
  resolutions: {
195
195
  tsx: "~4.16.2"
package/dist/index.cjs CHANGED
@@ -104,7 +104,6 @@ module.exports = __toCommonJS(src_exports);
104
104
 
105
105
  // src/factory.ts
106
106
  var import_node_process3 = __toESM(require("process"), 1);
107
- var import_node_fs = __toESM(require("fs"), 1);
108
107
  var import_local_pkg4 = require("local-pkg");
109
108
  var import_eslint_flat_config_utils = require("eslint-flat-config-utils");
110
109
 
@@ -342,7 +341,7 @@ var import_eslint_plugin_eslint_comments = __toESM(require("eslint-plugin-eslint
342
341
  var pluginImport = __toESM(require("eslint-plugin-import-x"), 1);
343
342
  var import_eslint_plugin_n = __toESM(require("eslint-plugin-n"), 1);
344
343
  var import_eslint_plugin_unicorn = __toESM(require("eslint-plugin-unicorn"), 1);
345
- var import_eslint_plugin_unused_imports = __toESM(require("eslint-plugin-unused-imports"), 1);
344
+ var import_eslint_plugin_unused_imports = __toESM(require("@antfu/eslint-plugin-unused-imports"), 1);
346
345
  var import_eslint_plugin_perfectionist = __toESM(require("eslint-plugin-perfectionist"), 1);
347
346
 
348
347
  // src/configs/comments.ts
@@ -1791,6 +1790,7 @@ async function test(options = {}) {
1791
1790
  "test/no-only-tests": isInEditor ? "off" : "error",
1792
1791
  "test/prefer-hooks-in-order": "error",
1793
1792
  "test/prefer-lowercase-title": "error",
1793
+ "ts/explicit-function-return-type": "off",
1794
1794
  ...overrides
1795
1795
  }
1796
1796
  }
@@ -1862,7 +1862,8 @@ async function typescript(options = {}) {
1862
1862
  const {
1863
1863
  componentExts = [],
1864
1864
  overrides = {},
1865
- parserOptions = {}
1865
+ parserOptions = {},
1866
+ type = "app"
1866
1867
  } = options;
1867
1868
  const files = options.files ?? [
1868
1869
  GLOB_TS,
@@ -1963,7 +1964,10 @@ async function typescript(options = {}) {
1963
1964
  "no-useless-constructor": "off",
1964
1965
  "ts/ban-ts-comment": ["error", { "ts-expect-error": "allow-with-description" }],
1965
1966
  "ts/consistent-type-definitions": ["error", "interface"],
1966
- "ts/consistent-type-imports": ["error", { disallowTypeAnnotations: false, prefer: "type-imports" }],
1967
+ "ts/consistent-type-imports": ["error", {
1968
+ disallowTypeAnnotations: false,
1969
+ prefer: "type-imports"
1970
+ }],
1967
1971
  "ts/method-signature-style": ["error", "property"],
1968
1972
  // https://www.totaltypescript.com/method-shorthand-syntax-considered-harmful
1969
1973
  "ts/no-dupe-class-members": "error",
@@ -1984,6 +1988,13 @@ async function typescript(options = {}) {
1984
1988
  "ts/prefer-ts-expect-error": "error",
1985
1989
  "ts/triple-slash-reference": "off",
1986
1990
  "ts/unified-signatures": "off",
1991
+ ...type === "lib" ? {
1992
+ "ts/explicit-function-return-type": ["error", {
1993
+ allowExpressions: true,
1994
+ allowHigherOrderFunctions: true,
1995
+ allowIIFEs: true
1996
+ }]
1997
+ } : {},
1987
1998
  ...overrides
1988
1999
  }
1989
2000
  },
@@ -2399,8 +2410,7 @@ function antfu(options = {}, ...userConfigs) {
2399
2410
  if (typeof enableGitignore !== "boolean") {
2400
2411
  configs2.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r(enableGitignore)]));
2401
2412
  } else {
2402
- if (import_node_fs.default.existsSync(".gitignore"))
2403
- configs2.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r()]));
2413
+ configs2.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r({ strict: false })]));
2404
2414
  }
2405
2415
  }
2406
2416
  const typescriptOptions = resolveSubOptions(options, "typescript");
@@ -2434,7 +2444,8 @@ function antfu(options = {}, ...userConfigs) {
2434
2444
  configs2.push(typescript({
2435
2445
  ...typescriptOptions,
2436
2446
  componentExts,
2437
- overrides: getOverrides(options, "typescript")
2447
+ overrides: getOverrides(options, "typescript"),
2448
+ type: options.type
2438
2449
  }));
2439
2450
  }
2440
2451
  if (stylisticOptions) {
package/dist/index.d.cts CHANGED
@@ -14890,6 +14890,14 @@ interface StylisticConfig extends Pick<StylisticCustomizeOptions, 'indent' | 'qu
14890
14890
  interface OptionsOverrides {
14891
14891
  overrides?: TypedFlatConfigItem['rules'];
14892
14892
  }
14893
+ interface OptionsProjectType {
14894
+ /**
14895
+ * Type of the project. `lib` will enable more strict rules for libraries.
14896
+ *
14897
+ * @default 'app'
14898
+ */
14899
+ type?: 'app' | 'lib';
14900
+ }
14893
14901
  interface OptionsRegExp {
14894
14902
  /**
14895
14903
  * Override rulelevels
@@ -14911,7 +14919,7 @@ interface OptionsUnoCSS extends OptionsOverrides {
14911
14919
  */
14912
14920
  strict?: boolean;
14913
14921
  }
14914
- interface OptionsConfig extends OptionsComponentExts {
14922
+ interface OptionsConfig extends OptionsComponentExts, OptionsProjectType {
14915
14923
  /**
14916
14924
  * Enable gitignore support.
14917
14925
  *
@@ -15120,7 +15128,7 @@ declare const defaultPluginRenaming: {
15120
15128
  declare function antfu(options?: OptionsConfig & TypedFlatConfigItem, ...userConfigs: Awaitable<TypedFlatConfigItem | TypedFlatConfigItem[] | FlatConfigComposer<any, any> | Linter.FlatConfig[]>[]): FlatConfigComposer<TypedFlatConfigItem, ConfigNames>;
15121
15129
  type ResolvedOptions<T> = T extends boolean ? never : NonNullable<T>;
15122
15130
  declare function resolveSubOptions<K extends keyof OptionsConfig>(options: OptionsConfig, key: K): ResolvedOptions<OptionsConfig[K]>;
15123
- declare function getOverrides<K extends keyof OptionsConfig>(options: OptionsConfig, key: K): any;
15131
+ declare function getOverrides<K extends keyof OptionsConfig>(options: OptionsConfig, key: K): Partial<Linter.RulesRecord & RuleOptions>;
15124
15132
 
15125
15133
  declare function astro(options?: OptionsOverrides & OptionsStylistic & OptionsFiles): Promise<TypedFlatConfigItem[]>;
15126
15134
 
@@ -15182,7 +15190,7 @@ declare function test(options?: OptionsFiles & OptionsIsInEditor & OptionsOverri
15182
15190
 
15183
15191
  declare function toml(options?: OptionsOverrides & OptionsStylistic & OptionsFiles): Promise<TypedFlatConfigItem[]>;
15184
15192
 
15185
- declare function typescript(options?: OptionsFiles & OptionsComponentExts & OptionsOverrides & OptionsTypeScriptWithTypes & OptionsTypeScriptParserOptions): Promise<TypedFlatConfigItem[]>;
15193
+ declare function typescript(options?: OptionsFiles & OptionsComponentExts & OptionsOverrides & OptionsTypeScriptWithTypes & OptionsTypeScriptParserOptions & OptionsProjectType): Promise<TypedFlatConfigItem[]>;
15186
15194
 
15187
15195
  declare function unicorn(): Promise<TypedFlatConfigItem[]>;
15188
15196
 
@@ -15271,9 +15279,7 @@ declare function combine(...configs: Awaitable<TypedFlatConfigItem | TypedFlatCo
15271
15279
  * }]
15272
15280
  * ```
15273
15281
  */
15274
- declare function renameRules(rules: Record<string, any>, map: Record<string, string>): {
15275
- [k: string]: any;
15276
- };
15282
+ declare function renameRules(rules: Record<string, any>, map: Record<string, string>): Record<string, any>;
15277
15283
  /**
15278
15284
  * Rename plugin names a flat configs array
15279
15285
  *
@@ -15295,4 +15301,4 @@ declare function interopDefault<T>(m: Awaitable<T>): Promise<T extends {
15295
15301
  } ? U : T>;
15296
15302
  declare function ensurePackages(packages: (string | undefined)[]): Promise<void>;
15297
15303
 
15298
- export { type Awaitable, type ConfigNames, GLOB_ALL_SRC, GLOB_ASTRO, GLOB_ASTRO_TS, GLOB_CSS, GLOB_EXCLUDE, GLOB_GRAPHQL, 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_XML, GLOB_YAML, type OptionsComponentExts, type OptionsConfig, type OptionsFiles, type OptionsFormatters, type OptionsHasTypeScript, type OptionsIsInEditor, type OptionsOverrides, type OptionsRegExp, type OptionsStylistic, type OptionsTypeScriptParserOptions, type OptionsTypeScriptWithTypes, type OptionsTypescript, type OptionsUnoCSS, type OptionsVue, type ResolvedOptions, type Rules, type StylisticConfig, StylisticConfigDefaults, type StylisticOptions, type TypedFlatConfigItem, antfu, astro, combine, command, comments, antfu as default, defaultPluginRenaming, ensurePackages, formatters, getOverrides, ignores, imports, interopDefault, javascript, jsdoc, jsonc, jsx, markdown, node, parserPlain, perfectionist, react, regexp, renamePluginInConfigs, renameRules, resolveSubOptions, solid, sortPackageJson, sortTsconfig, stylistic, svelte, test, toArray, toml, typescript, unicorn, unocss, vue, yaml };
15304
+ export { type Awaitable, type ConfigNames, GLOB_ALL_SRC, GLOB_ASTRO, GLOB_ASTRO_TS, GLOB_CSS, GLOB_EXCLUDE, GLOB_GRAPHQL, 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_XML, GLOB_YAML, type OptionsComponentExts, type OptionsConfig, type OptionsFiles, type OptionsFormatters, type OptionsHasTypeScript, type OptionsIsInEditor, type OptionsOverrides, type OptionsProjectType, type OptionsRegExp, type OptionsStylistic, type OptionsTypeScriptParserOptions, type OptionsTypeScriptWithTypes, type OptionsTypescript, type OptionsUnoCSS, type OptionsVue, type ResolvedOptions, type Rules, type StylisticConfig, StylisticConfigDefaults, type StylisticOptions, type TypedFlatConfigItem, antfu, astro, combine, command, comments, antfu as default, defaultPluginRenaming, ensurePackages, formatters, getOverrides, ignores, imports, interopDefault, javascript, jsdoc, jsonc, jsx, markdown, node, parserPlain, perfectionist, react, regexp, renamePluginInConfigs, renameRules, resolveSubOptions, solid, sortPackageJson, sortTsconfig, stylistic, svelte, test, toArray, toml, typescript, unicorn, unocss, vue, yaml };
package/dist/index.d.ts CHANGED
@@ -14890,6 +14890,14 @@ interface StylisticConfig extends Pick<StylisticCustomizeOptions, 'indent' | 'qu
14890
14890
  interface OptionsOverrides {
14891
14891
  overrides?: TypedFlatConfigItem['rules'];
14892
14892
  }
14893
+ interface OptionsProjectType {
14894
+ /**
14895
+ * Type of the project. `lib` will enable more strict rules for libraries.
14896
+ *
14897
+ * @default 'app'
14898
+ */
14899
+ type?: 'app' | 'lib';
14900
+ }
14893
14901
  interface OptionsRegExp {
14894
14902
  /**
14895
14903
  * Override rulelevels
@@ -14911,7 +14919,7 @@ interface OptionsUnoCSS extends OptionsOverrides {
14911
14919
  */
14912
14920
  strict?: boolean;
14913
14921
  }
14914
- interface OptionsConfig extends OptionsComponentExts {
14922
+ interface OptionsConfig extends OptionsComponentExts, OptionsProjectType {
14915
14923
  /**
14916
14924
  * Enable gitignore support.
14917
14925
  *
@@ -15120,7 +15128,7 @@ declare const defaultPluginRenaming: {
15120
15128
  declare function antfu(options?: OptionsConfig & TypedFlatConfigItem, ...userConfigs: Awaitable<TypedFlatConfigItem | TypedFlatConfigItem[] | FlatConfigComposer<any, any> | Linter.FlatConfig[]>[]): FlatConfigComposer<TypedFlatConfigItem, ConfigNames>;
15121
15129
  type ResolvedOptions<T> = T extends boolean ? never : NonNullable<T>;
15122
15130
  declare function resolveSubOptions<K extends keyof OptionsConfig>(options: OptionsConfig, key: K): ResolvedOptions<OptionsConfig[K]>;
15123
- declare function getOverrides<K extends keyof OptionsConfig>(options: OptionsConfig, key: K): any;
15131
+ declare function getOverrides<K extends keyof OptionsConfig>(options: OptionsConfig, key: K): Partial<Linter.RulesRecord & RuleOptions>;
15124
15132
 
15125
15133
  declare function astro(options?: OptionsOverrides & OptionsStylistic & OptionsFiles): Promise<TypedFlatConfigItem[]>;
15126
15134
 
@@ -15182,7 +15190,7 @@ declare function test(options?: OptionsFiles & OptionsIsInEditor & OptionsOverri
15182
15190
 
15183
15191
  declare function toml(options?: OptionsOverrides & OptionsStylistic & OptionsFiles): Promise<TypedFlatConfigItem[]>;
15184
15192
 
15185
- declare function typescript(options?: OptionsFiles & OptionsComponentExts & OptionsOverrides & OptionsTypeScriptWithTypes & OptionsTypeScriptParserOptions): Promise<TypedFlatConfigItem[]>;
15193
+ declare function typescript(options?: OptionsFiles & OptionsComponentExts & OptionsOverrides & OptionsTypeScriptWithTypes & OptionsTypeScriptParserOptions & OptionsProjectType): Promise<TypedFlatConfigItem[]>;
15186
15194
 
15187
15195
  declare function unicorn(): Promise<TypedFlatConfigItem[]>;
15188
15196
 
@@ -15271,9 +15279,7 @@ declare function combine(...configs: Awaitable<TypedFlatConfigItem | TypedFlatCo
15271
15279
  * }]
15272
15280
  * ```
15273
15281
  */
15274
- declare function renameRules(rules: Record<string, any>, map: Record<string, string>): {
15275
- [k: string]: any;
15276
- };
15282
+ declare function renameRules(rules: Record<string, any>, map: Record<string, string>): Record<string, any>;
15277
15283
  /**
15278
15284
  * Rename plugin names a flat configs array
15279
15285
  *
@@ -15295,4 +15301,4 @@ declare function interopDefault<T>(m: Awaitable<T>): Promise<T extends {
15295
15301
  } ? U : T>;
15296
15302
  declare function ensurePackages(packages: (string | undefined)[]): Promise<void>;
15297
15303
 
15298
- export { type Awaitable, type ConfigNames, GLOB_ALL_SRC, GLOB_ASTRO, GLOB_ASTRO_TS, GLOB_CSS, GLOB_EXCLUDE, GLOB_GRAPHQL, 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_XML, GLOB_YAML, type OptionsComponentExts, type OptionsConfig, type OptionsFiles, type OptionsFormatters, type OptionsHasTypeScript, type OptionsIsInEditor, type OptionsOverrides, type OptionsRegExp, type OptionsStylistic, type OptionsTypeScriptParserOptions, type OptionsTypeScriptWithTypes, type OptionsTypescript, type OptionsUnoCSS, type OptionsVue, type ResolvedOptions, type Rules, type StylisticConfig, StylisticConfigDefaults, type StylisticOptions, type TypedFlatConfigItem, antfu, astro, combine, command, comments, antfu as default, defaultPluginRenaming, ensurePackages, formatters, getOverrides, ignores, imports, interopDefault, javascript, jsdoc, jsonc, jsx, markdown, node, parserPlain, perfectionist, react, regexp, renamePluginInConfigs, renameRules, resolveSubOptions, solid, sortPackageJson, sortTsconfig, stylistic, svelte, test, toArray, toml, typescript, unicorn, unocss, vue, yaml };
15304
+ export { type Awaitable, type ConfigNames, GLOB_ALL_SRC, GLOB_ASTRO, GLOB_ASTRO_TS, GLOB_CSS, GLOB_EXCLUDE, GLOB_GRAPHQL, 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_XML, GLOB_YAML, type OptionsComponentExts, type OptionsConfig, type OptionsFiles, type OptionsFormatters, type OptionsHasTypeScript, type OptionsIsInEditor, type OptionsOverrides, type OptionsProjectType, type OptionsRegExp, type OptionsStylistic, type OptionsTypeScriptParserOptions, type OptionsTypeScriptWithTypes, type OptionsTypescript, type OptionsUnoCSS, type OptionsVue, type ResolvedOptions, type Rules, type StylisticConfig, StylisticConfigDefaults, type StylisticOptions, type TypedFlatConfigItem, antfu, astro, combine, command, comments, antfu as default, defaultPluginRenaming, ensurePackages, formatters, getOverrides, ignores, imports, interopDefault, javascript, jsdoc, jsonc, jsx, markdown, node, parserPlain, perfectionist, react, regexp, renamePluginInConfigs, renameRules, resolveSubOptions, solid, sortPackageJson, sortTsconfig, stylistic, svelte, test, toArray, toml, typescript, unicorn, unocss, vue, yaml };
package/dist/index.js CHANGED
@@ -1,6 +1,5 @@
1
1
  // src/factory.ts
2
2
  import process3 from "node:process";
3
- import fs from "node:fs";
4
3
  import { isPackageExists as isPackageExists4 } from "local-pkg";
5
4
  import { FlatConfigComposer } from "eslint-flat-config-utils";
6
5
 
@@ -238,7 +237,7 @@ import { default as default3 } from "eslint-plugin-eslint-comments";
238
237
  import * as pluginImport from "eslint-plugin-import-x";
239
238
  import { default as default4 } from "eslint-plugin-n";
240
239
  import { default as default5 } from "eslint-plugin-unicorn";
241
- import { default as default6 } from "eslint-plugin-unused-imports";
240
+ import { default as default6 } from "@antfu/eslint-plugin-unused-imports";
242
241
  import { default as default7 } from "eslint-plugin-perfectionist";
243
242
 
244
243
  // src/configs/comments.ts
@@ -1687,6 +1686,7 @@ async function test(options = {}) {
1687
1686
  "test/no-only-tests": isInEditor ? "off" : "error",
1688
1687
  "test/prefer-hooks-in-order": "error",
1689
1688
  "test/prefer-lowercase-title": "error",
1689
+ "ts/explicit-function-return-type": "off",
1690
1690
  ...overrides
1691
1691
  }
1692
1692
  }
@@ -1758,7 +1758,8 @@ async function typescript(options = {}) {
1758
1758
  const {
1759
1759
  componentExts = [],
1760
1760
  overrides = {},
1761
- parserOptions = {}
1761
+ parserOptions = {},
1762
+ type = "app"
1762
1763
  } = options;
1763
1764
  const files = options.files ?? [
1764
1765
  GLOB_TS,
@@ -1859,7 +1860,10 @@ async function typescript(options = {}) {
1859
1860
  "no-useless-constructor": "off",
1860
1861
  "ts/ban-ts-comment": ["error", { "ts-expect-error": "allow-with-description" }],
1861
1862
  "ts/consistent-type-definitions": ["error", "interface"],
1862
- "ts/consistent-type-imports": ["error", { disallowTypeAnnotations: false, prefer: "type-imports" }],
1863
+ "ts/consistent-type-imports": ["error", {
1864
+ disallowTypeAnnotations: false,
1865
+ prefer: "type-imports"
1866
+ }],
1863
1867
  "ts/method-signature-style": ["error", "property"],
1864
1868
  // https://www.totaltypescript.com/method-shorthand-syntax-considered-harmful
1865
1869
  "ts/no-dupe-class-members": "error",
@@ -1880,6 +1884,13 @@ async function typescript(options = {}) {
1880
1884
  "ts/prefer-ts-expect-error": "error",
1881
1885
  "ts/triple-slash-reference": "off",
1882
1886
  "ts/unified-signatures": "off",
1887
+ ...type === "lib" ? {
1888
+ "ts/explicit-function-return-type": ["error", {
1889
+ allowExpressions: true,
1890
+ allowHigherOrderFunctions: true,
1891
+ allowIIFEs: true
1892
+ }]
1893
+ } : {},
1883
1894
  ...overrides
1884
1895
  }
1885
1896
  },
@@ -2295,8 +2306,7 @@ function antfu(options = {}, ...userConfigs) {
2295
2306
  if (typeof enableGitignore !== "boolean") {
2296
2307
  configs2.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r(enableGitignore)]));
2297
2308
  } else {
2298
- if (fs.existsSync(".gitignore"))
2299
- configs2.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r()]));
2309
+ configs2.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r({ strict: false })]));
2300
2310
  }
2301
2311
  }
2302
2312
  const typescriptOptions = resolveSubOptions(options, "typescript");
@@ -2330,7 +2340,8 @@ function antfu(options = {}, ...userConfigs) {
2330
2340
  configs2.push(typescript({
2331
2341
  ...typescriptOptions,
2332
2342
  componentExts,
2333
- overrides: getOverrides(options, "typescript")
2343
+ overrides: getOverrides(options, "typescript"),
2344
+ type: options.type
2334
2345
  }));
2335
2346
  }
2336
2347
  if (stylisticOptions) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@antfu/eslint-config",
3
3
  "type": "module",
4
- "version": "2.22.4",
4
+ "version": "2.23.0",
5
5
  "description": "Anthony's ESLint config",
6
6
  "author": "Anthony Fu <anthonyfu117@hotmail.com> (https://github.com/antfu/)",
7
7
  "license": "MIT",
@@ -81,6 +81,7 @@
81
81
  }
82
82
  },
83
83
  "dependencies": {
84
+ "@antfu/eslint-plugin-unused-imports": "^4.0.0",
84
85
  "@antfu/install-pkg": "^0.3.3",
85
86
  "@clack/prompts": "^0.7.0",
86
87
  "@stylistic/eslint-plugin": "^2.6.0-beta.0",
@@ -102,7 +103,6 @@
102
103
  "eslint-plugin-regexp": "^2.6.0",
103
104
  "eslint-plugin-toml": "^0.11.1",
104
105
  "eslint-plugin-unicorn": "^54.0.0",
105
- "eslint-plugin-unused-imports": "^4.0.0",
106
106
  "eslint-plugin-vitest": "^0.5.4",
107
107
  "eslint-plugin-vue": "^9.27.0",
108
108
  "eslint-plugin-yml": "^1.14.0",
@@ -119,16 +119,16 @@
119
119
  },
120
120
  "devDependencies": {
121
121
  "@antfu/ni": "^0.22.0",
122
- "@eslint-react/eslint-plugin": "^1.5.26",
122
+ "@eslint-react/eslint-plugin": "^1.5.27",
123
123
  "@eslint/config-inspector": "^0.5.1",
124
124
  "@prettier/plugin-xml": "^3.4.1",
125
125
  "@stylistic/eslint-plugin-migrate": "^2.3.0",
126
126
  "@types/eslint": "^8.56.10",
127
127
  "@types/fs-extra": "^11.0.4",
128
- "@types/node": "^20.14.10",
128
+ "@types/node": "^20.14.11",
129
129
  "@types/prompts": "^2.4.9",
130
130
  "@types/yargs": "^17.0.32",
131
- "@unocss/eslint-plugin": "^0.61.4",
131
+ "@unocss/eslint-plugin": "^0.61.5",
132
132
  "astro-eslint-parser": "^1.0.2",
133
133
  "bumpp": "^9.4.1",
134
134
  "eslint": "npm:eslint-ts-patch@9.5.0-0",
@@ -145,18 +145,18 @@
145
145
  "fast-glob": "^3.3.2",
146
146
  "fs-extra": "^11.2.0",
147
147
  "lint-staged": "^15.2.7",
148
- "prettier-plugin-astro": "^0.14.0",
148
+ "prettier-plugin-astro": "^0.14.1",
149
149
  "prettier-plugin-slidev": "^1.0.5",
150
150
  "rimraf": "^6.0.1",
151
151
  "simple-git-hooks": "^2.11.1",
152
152
  "svelte": "^4.2.18",
153
153
  "svelte-eslint-parser": "^0.40.0",
154
- "tsup": "^8.1.0",
154
+ "tsup": "^8.1.2",
155
155
  "tsx": "^4.16.2",
156
156
  "typescript": "^5.5.3",
157
157
  "vitest": "^2.0.3",
158
- "vue": "^3.4.31",
159
- "@antfu/eslint-config": "2.22.4"
158
+ "vue": "^3.4.32",
159
+ "@antfu/eslint-config": "2.23.0"
160
160
  },
161
161
  "resolutions": {
162
162
  "tsx": "~4.16.2"