@icebreakers/eslint-config 2.1.1 → 3.0.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
@@ -8,9 +8,9 @@
8
8
 
9
9
  ## Requirements
10
10
 
11
- - Node.js 18 or newer
11
+ - Node.js 22 or newer
12
12
  - ESLint 9 with flat config support
13
- - React and Next related plugins are optional. If they are missing, `react`, `nextjs`, `query`, and React-side `a11y` helpers are skipped automatically instead of failing config resolution.
13
+ - React related plugins are bundled with this package. Next.js, Query, and other ecosystem presets remain optional and are skipped automatically when their plugins are missing.
14
14
  - Install optional peer plugins when you turn on Tailwind (`eslint-plugin-tailwindcss` or `eslint-plugin-better-tailwindcss`), MDX (`eslint-plugin-mdx`), or UnoCSS (`@unocss/eslint-plugin`)
15
15
 
16
16
  ## Installation
@@ -64,7 +64,7 @@ export default icebreaker({
64
64
 
65
65
  - `miniProgram` – injects Mini Program globals, ignores common outputs/config files, and enables Vue-side Mini Program compatibility tweaks when `vue` is on.
66
66
  - `vue` – enables Vue + optionally version specific overrides (Vue 2/3) and ionic/miniProgram adjustments.
67
- - `react` – defers to the upstream React preset and unlocks accessibility helpers when `a11y` is enabled. If the React plugin set is not installed, this flag is ignored automatically.
67
+ - `react` – defers to the upstream React preset and unlocks accessibility helpers when `a11y` is enabled. The required React lint plugins are bundled with this package.
68
68
  - `query` – toggles the TanStack Query plugin (`@tanstack/eslint-plugin-query`) and its recommended lint rules. Missing plugin installs are treated as a no-op.
69
69
  - `tailwindcss` – pass `true` to use the built-in Tailwind flat config or provide `{ entryPoint, tailwindConfig }` for Tailwind v4/v3 projects.
70
70
  - `mdx` – activates MDX linting via `eslint-plugin-mdx`.
package/README.zh.md CHANGED
@@ -6,9 +6,9 @@
6
6
 
7
7
  ## 环境要求
8
8
 
9
- - Node.js 18 或更高版本
9
+ - Node.js 22 或更高版本
10
10
  - 支持 Flat Config 的 ESLint 9
11
- - React / Next 相关插件现在是可选项。缺失时会自动跳过 `react`、`nextjs`、`query` 以及 React 侧的 `a11y` 配置,而不是在解析配置时直接报错。
11
+ - React 相关插件已随当前包一起分发。Next.js、Query 等生态预设仍保持可选,缺失时会自动跳过对应配置,而不是在解析时直接报错。
12
12
  - 如需启用 Tailwind、MDX、UnoCSS 等,可安装对应的可选依赖:`eslint-plugin-tailwindcss` / `eslint-plugin-better-tailwindcss`、`eslint-plugin-mdx`、`@unocss/eslint-plugin`
13
13
 
14
14
  ## 安装
@@ -62,7 +62,7 @@ export default icebreaker({
62
62
 
63
63
  - `miniProgram`:启用小程序预设,注入全局变量、忽略常见产物/配置文件,并在 `vue: true` 时补充小程序模板兼容调整。
64
64
  - `vue`:启用 Vue 规则,可根据 Vue 2/3 自动切换,并在 `ionic`、`miniProgram` 选项开启时追加对应覆盖。
65
- - `react`:复用上游 React 预设,配合 `a11y` 注入无障碍插件;如果 React 插件组未安装,会自动忽略该选项。
65
+ - `react`:复用上游 React 预设,配合 `a11y` 注入无障碍插件;所需的 React lint 插件已内置在当前包里。
66
66
  - `query`:按需启用 TanStack Query 插件(`@tanstack/eslint-plugin-query`)及其推荐规则;缺少插件时按 no-op 处理。
67
67
  - `tailwindcss`:传入 `true` 使用内置 Tailwind flat 配置,或通过对象指定 Tailwind v4 的入口文件 / v3 的配置文件路径。
68
68
  - `mdx`:激活 `eslint-plugin-mdx` 处理 `.mdx` 文件。
package/dist/index.cjs CHANGED
@@ -31,14 +31,14 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
31
31
  enumerable: true
32
32
  }) : target, mod));
33
33
  //#endregion
34
+ let node_fs = require("node:fs");
35
+ node_fs = __toESM(node_fs);
34
36
  let node_module = require("node:module");
35
37
  let node_path = require("node:path");
36
38
  node_path = __toESM(node_path);
37
39
  let node_process = require("node:process");
38
40
  node_process = __toESM(node_process);
39
41
  let node_url = require("node:url");
40
- let node_fs = require("node:fs");
41
- node_fs = __toESM(node_fs);
42
42
  //#region src/antfu.ts
43
43
  var antfu_exports = /* @__PURE__ */ __exportAll({});
44
44
  __reExport(antfu_exports, require("@antfu/eslint-config"));
@@ -163,7 +163,17 @@ function isPackageAvailable$1(name, searchPaths = [node_process.default.cwd(), P
163
163
  require$2.resolve(name, { paths: searchPaths });
164
164
  return true;
165
165
  } catch {
166
- return false;
166
+ const packageSegments = name.split("/");
167
+ return searchPaths.some((searchPath) => {
168
+ let currentDir = node_path.default.resolve(searchPath);
169
+ while (true) {
170
+ const packageJsonPath = node_path.default.join(currentDir, "node_modules", ...packageSegments, "package.json");
171
+ if (node_fs.default.existsSync(packageJsonPath)) return true;
172
+ const parentDir = node_path.default.dirname(currentDir);
173
+ if (parentDir === currentDir) return false;
174
+ currentDir = parentDir;
175
+ }
176
+ });
167
177
  }
168
178
  }
169
179
  function hasAllPackages(names, searchPaths) {
@@ -335,7 +345,7 @@ const BASE_DEFAULTS = {
335
345
  };
336
346
  const BASE_RULES = {
337
347
  "dot-notation": "off",
338
- "e18e/ban-dependencies": "warn",
348
+ "e18e/ban-dependencies": ["warn", { allowed: ["axios", "lint-staged"] }],
339
349
  "e18e/prefer-array-to-sorted": "off",
340
350
  "pnpm/json-enforce-catalog": "off",
341
351
  "pnpm/json-prefer-workspace-settings": "off",
package/dist/index.d.cts CHANGED
@@ -758,7 +758,7 @@ interface ConfigObject<Rules extends RulesConfig = RulesConfig> {
758
758
  * An object containing a name-value mapping of plugin names to plugin objects.
759
759
  * When files is specified, these plugins are only available to the matching files.
760
760
  */
761
- plugins?: Record<string, Plugin$1>;
761
+ plugins?: Record<string, Plugin$2>;
762
762
  /**
763
763
  * An object containing the configured rules. When files or ignores are specified,
764
764
  * these rule configurations are only available to the matching files.
@@ -974,7 +974,7 @@ interface Processor<T extends string | ProcessorFile$1 = string | ProcessorFile$
974
974
  /** The function to merge messages. */
975
975
  postprocess?(messages: LintMessage$1[][], filename: string): LintMessage$1[];
976
976
  }
977
- interface Plugin$1 extends ObjectMetaProperties {
977
+ interface Plugin$2 extends ObjectMetaProperties {
978
978
  meta?: ObjectMetaProperties["meta"] & {
979
979
  namespace?: string | undefined;
980
980
  };
@@ -1327,6 +1327,7 @@ interface ConfigWithExtends$1 extends ConfigObject {
1327
1327
  }
1328
1328
  //#endregion
1329
1329
  //#region ../../node_modules/.pnpm/@eslint+config-helpers@0.5.3/node_modules/@eslint/config-helpers/dist/esm/index.d.ts
1330
+ type Plugin$1 = Plugin$2;
1330
1331
  type ConfigWithExtends = ConfigWithExtends$1;
1331
1332
  //#endregion
1332
1333
  //#region ../../node_modules/.pnpm/@types+estree@1.0.8/node_modules/@types/estree/index.d.ts
@@ -2536,7 +2537,7 @@ declare namespace ESLint {
2536
2537
  type ConfigData<Rules extends Linter.RulesRecord = RulesConfig> = Omit<Linter.LegacyConfig<Rules>, "$schema">;
2537
2538
  type Environment = EnvironmentConfig;
2538
2539
  type ObjectMetaProperties = ObjectMetaProperties;
2539
- type Plugin = Plugin$1;
2540
+ type Plugin = Plugin$2;
2540
2541
  type FixType = "directive" | "problem" | "suggestion" | "layout";
2541
2542
  type CacheStrategy = "content" | "metadata";
2542
2543
  /** The options with which to configure the ESLint instance. */
@@ -2704,7 +2705,34 @@ declare namespace ESLint {
2704
2705
  type EditInfo = Rule.Fix;
2705
2706
  }
2706
2707
  //#endregion
2707
- //#region ../../node_modules/.pnpm/eslint-flat-config-utils@3.0.2/node_modules/eslint-flat-config-utils/dist/index.d.mts
2708
+ //#region ../../node_modules/.pnpm/eslint-flat-config-utils@3.1.0/node_modules/eslint-flat-config-utils/dist/index.d.mts
2709
+ /**
2710
+ * The options for `renamePluginsInConfigs`
2711
+ */
2712
+ interface RenamePluginsInConfigsOptions {
2713
+ /**
2714
+ * Resolve conflicts by merging plugins.
2715
+ *
2716
+ * Note there is no guarantee that the result works the same as the original configs.
2717
+ *
2718
+ * @default false
2719
+ */
2720
+ mergePlugins?: boolean;
2721
+ }
2722
+ /**
2723
+ * Rename plugin names a flat configs array
2724
+ *
2725
+ * @example
2726
+ * ```ts
2727
+ * import { renamePluginsInConfigs } from 'eslint-flat-config-utils'
2728
+ * import someConfigs from './some-configs'
2729
+ *
2730
+ * export default renamePluginsInConfigs(someConfigs, {
2731
+ * '@typescript-eslint': 'ts',
2732
+ * 'import-x': 'import',
2733
+ * })
2734
+ * ```
2735
+ */
2708
2736
  /**
2709
2737
  * A type that can be awaited. Promise<T> or T.
2710
2738
  */
@@ -2800,6 +2828,7 @@ declare class FlatConfigComposer<T extends object = ConfigWithExtends, ConfigNam
2800
2828
  private _operationsOverrides;
2801
2829
  private _operationsResolved;
2802
2830
  private _renames;
2831
+ private _renamesOptions;
2803
2832
  private _pluginsConflictsError;
2804
2833
  constructor(...configs: ResolvableFlatConfig<T>[]);
2805
2834
  /**
@@ -2807,7 +2836,7 @@ declare class FlatConfigComposer<T extends object = ConfigWithExtends, ConfigNam
2807
2836
  *
2808
2837
  * This will runs after all config items are resolved. Applies to `plugins` and `rules`.
2809
2838
  */
2810
- renamePlugins(renames: Record<string, string>): this;
2839
+ renamePlugins(renames: Record<string, string>, options?: RenamePluginsInConfigsOptions): this;
2811
2840
  /**
2812
2841
  * Append configs to the end of the current configs array.
2813
2842
  */
@@ -2883,7 +2912,25 @@ declare class FlatConfigComposer<T extends object = ConfigWithExtends, ConfigNam
2883
2912
  /**
2884
2913
  * Remove a specific config by name or index.
2885
2914
  */
2886
- remove(nameOrIndex: ConfigNames | string | number): this;
2915
+ remove(nameOrIndex: StringLiteralUnion<ConfigNames, string | number>): this;
2916
+ /**
2917
+ * Replace a plugin with another.
2918
+ *
2919
+ * @example
2920
+ * ```ts
2921
+ * composer
2922
+ * .replacePlugin('foo', (fooPlugin) => ({
2923
+ * ...fooPlugin,
2924
+ * rules: {
2925
+ * ...fooPlugin.rules,
2926
+ * someNewRule,
2927
+ * },
2928
+ * }))
2929
+ * ```
2930
+ *
2931
+ * The `plugins: { foo }` will be replaced from all configs with a new plugin that is a merge of it and the `bar` plugin
2932
+ */
2933
+ replacePlugin(name: string, replacement: Awaitable$1<Plugin$1> | ((original: Plugin$1) => Awaitable$1<Plugin$1>)): this;
2887
2934
  /**
2888
2935
  * Replace a specific config by name or index.
2889
2936
  *
package/dist/index.d.ts CHANGED
@@ -758,7 +758,7 @@ interface ConfigObject<Rules extends RulesConfig = RulesConfig> {
758
758
  * An object containing a name-value mapping of plugin names to plugin objects.
759
759
  * When files is specified, these plugins are only available to the matching files.
760
760
  */
761
- plugins?: Record<string, Plugin$1>;
761
+ plugins?: Record<string, Plugin$2>;
762
762
  /**
763
763
  * An object containing the configured rules. When files or ignores are specified,
764
764
  * these rule configurations are only available to the matching files.
@@ -974,7 +974,7 @@ interface Processor<T extends string | ProcessorFile$1 = string | ProcessorFile$
974
974
  /** The function to merge messages. */
975
975
  postprocess?(messages: LintMessage$1[][], filename: string): LintMessage$1[];
976
976
  }
977
- interface Plugin$1 extends ObjectMetaProperties {
977
+ interface Plugin$2 extends ObjectMetaProperties {
978
978
  meta?: ObjectMetaProperties["meta"] & {
979
979
  namespace?: string | undefined;
980
980
  };
@@ -1327,6 +1327,7 @@ interface ConfigWithExtends$1 extends ConfigObject {
1327
1327
  }
1328
1328
  //#endregion
1329
1329
  //#region ../../node_modules/.pnpm/@eslint+config-helpers@0.5.3/node_modules/@eslint/config-helpers/dist/esm/index.d.ts
1330
+ type Plugin$1 = Plugin$2;
1330
1331
  type ConfigWithExtends = ConfigWithExtends$1;
1331
1332
  //#endregion
1332
1333
  //#region ../../node_modules/.pnpm/@types+estree@1.0.8/node_modules/@types/estree/index.d.ts
@@ -2536,7 +2537,7 @@ declare namespace ESLint {
2536
2537
  type ConfigData<Rules extends Linter.RulesRecord = RulesConfig> = Omit<Linter.LegacyConfig<Rules>, "$schema">;
2537
2538
  type Environment = EnvironmentConfig;
2538
2539
  type ObjectMetaProperties = ObjectMetaProperties;
2539
- type Plugin = Plugin$1;
2540
+ type Plugin = Plugin$2;
2540
2541
  type FixType = "directive" | "problem" | "suggestion" | "layout";
2541
2542
  type CacheStrategy = "content" | "metadata";
2542
2543
  /** The options with which to configure the ESLint instance. */
@@ -2704,7 +2705,34 @@ declare namespace ESLint {
2704
2705
  type EditInfo = Rule.Fix;
2705
2706
  }
2706
2707
  //#endregion
2707
- //#region ../../node_modules/.pnpm/eslint-flat-config-utils@3.0.2/node_modules/eslint-flat-config-utils/dist/index.d.mts
2708
+ //#region ../../node_modules/.pnpm/eslint-flat-config-utils@3.1.0/node_modules/eslint-flat-config-utils/dist/index.d.mts
2709
+ /**
2710
+ * The options for `renamePluginsInConfigs`
2711
+ */
2712
+ interface RenamePluginsInConfigsOptions {
2713
+ /**
2714
+ * Resolve conflicts by merging plugins.
2715
+ *
2716
+ * Note there is no guarantee that the result works the same as the original configs.
2717
+ *
2718
+ * @default false
2719
+ */
2720
+ mergePlugins?: boolean;
2721
+ }
2722
+ /**
2723
+ * Rename plugin names a flat configs array
2724
+ *
2725
+ * @example
2726
+ * ```ts
2727
+ * import { renamePluginsInConfigs } from 'eslint-flat-config-utils'
2728
+ * import someConfigs from './some-configs'
2729
+ *
2730
+ * export default renamePluginsInConfigs(someConfigs, {
2731
+ * '@typescript-eslint': 'ts',
2732
+ * 'import-x': 'import',
2733
+ * })
2734
+ * ```
2735
+ */
2708
2736
  /**
2709
2737
  * A type that can be awaited. Promise<T> or T.
2710
2738
  */
@@ -2800,6 +2828,7 @@ declare class FlatConfigComposer<T extends object = ConfigWithExtends, ConfigNam
2800
2828
  private _operationsOverrides;
2801
2829
  private _operationsResolved;
2802
2830
  private _renames;
2831
+ private _renamesOptions;
2803
2832
  private _pluginsConflictsError;
2804
2833
  constructor(...configs: ResolvableFlatConfig<T>[]);
2805
2834
  /**
@@ -2807,7 +2836,7 @@ declare class FlatConfigComposer<T extends object = ConfigWithExtends, ConfigNam
2807
2836
  *
2808
2837
  * This will runs after all config items are resolved. Applies to `plugins` and `rules`.
2809
2838
  */
2810
- renamePlugins(renames: Record<string, string>): this;
2839
+ renamePlugins(renames: Record<string, string>, options?: RenamePluginsInConfigsOptions): this;
2811
2840
  /**
2812
2841
  * Append configs to the end of the current configs array.
2813
2842
  */
@@ -2883,7 +2912,25 @@ declare class FlatConfigComposer<T extends object = ConfigWithExtends, ConfigNam
2883
2912
  /**
2884
2913
  * Remove a specific config by name or index.
2885
2914
  */
2886
- remove(nameOrIndex: ConfigNames | string | number): this;
2915
+ remove(nameOrIndex: StringLiteralUnion<ConfigNames, string | number>): this;
2916
+ /**
2917
+ * Replace a plugin with another.
2918
+ *
2919
+ * @example
2920
+ * ```ts
2921
+ * composer
2922
+ * .replacePlugin('foo', (fooPlugin) => ({
2923
+ * ...fooPlugin,
2924
+ * rules: {
2925
+ * ...fooPlugin.rules,
2926
+ * someNewRule,
2927
+ * },
2928
+ * }))
2929
+ * ```
2930
+ *
2931
+ * The `plugins: { foo }` will be replaced from all configs with a new plugin that is a merge of it and the `bar` plugin
2932
+ */
2933
+ replacePlugin(name: string, replacement: Awaitable$1<Plugin$1> | ((original: Plugin$1) => Awaitable$1<Plugin$1>)): this;
2887
2934
  /**
2888
2935
  * Replace a specific config by name or index.
2889
2936
  *
package/dist/index.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import { createRequire } from "node:module";
2
+ import fs from "node:fs";
2
3
  import path from "node:path";
3
4
  import process from "node:process";
4
5
  import { fileURLToPath } from "node:url";
5
- import fs from "node:fs";
6
6
  //#region \0rolldown/runtime.js
7
7
  var __defProp = Object.defineProperty;
8
8
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -154,7 +154,17 @@ function isPackageAvailable$1(name, searchPaths = [process.cwd(), PACKAGE_DIR])
154
154
  require$1.resolve(name, { paths: searchPaths });
155
155
  return true;
156
156
  } catch {
157
- return false;
157
+ const packageSegments = name.split("/");
158
+ return searchPaths.some((searchPath) => {
159
+ let currentDir = path.resolve(searchPath);
160
+ while (true) {
161
+ const packageJsonPath = path.join(currentDir, "node_modules", ...packageSegments, "package.json");
162
+ if (fs.existsSync(packageJsonPath)) return true;
163
+ const parentDir = path.dirname(currentDir);
164
+ if (parentDir === currentDir) return false;
165
+ currentDir = parentDir;
166
+ }
167
+ });
158
168
  }
159
169
  }
160
170
  function hasAllPackages(names, searchPaths) {
@@ -326,7 +336,7 @@ const BASE_DEFAULTS = {
326
336
  };
327
337
  const BASE_RULES = {
328
338
  "dot-notation": "off",
329
- "e18e/ban-dependencies": "warn",
339
+ "e18e/ban-dependencies": ["warn", { allowed: ["axios", "lint-staged"] }],
330
340
  "e18e/prefer-array-to-sorted": "off",
331
341
  "pnpm/json-enforce-catalog": "off",
332
342
  "pnpm/json-prefer-workspace-settings": "off",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@icebreakers/eslint-config",
3
3
  "type": "module",
4
- "version": "2.1.1",
4
+ "version": "3.0.0",
5
5
  "description": "ESLint preset from Icebreaker's dev-configs",
6
6
  "author": "ice breaker <1324318532@qq.com>",
7
7
  "license": "MIT",
@@ -38,6 +38,9 @@
38
38
  "dist",
39
39
  "index.d.ts"
40
40
  ],
41
+ "engines": {
42
+ "node": ">=22.0.0"
43
+ },
41
44
  "peerDependencies": {
42
45
  "eslint-plugin-pnpm": "^1.4.3"
43
46
  },
@@ -47,23 +50,23 @@
47
50
  }
48
51
  },
49
52
  "dependencies": {
50
- "@antfu/eslint-config": "7.7.3",
53
+ "@antfu/eslint-config": "8.0.0",
54
+ "@eslint-react/eslint-plugin": "^3.0.0",
51
55
  "eslint-plugin-better-tailwindcss": "^4.3.2",
52
56
  "eslint-plugin-format": "2.0.1",
57
+ "eslint-plugin-jsx-a11y": "^6.10.2",
58
+ "eslint-plugin-react-hooks": "^7.0.1",
59
+ "eslint-plugin-react-refresh": "^0.5.2",
53
60
  "eslint-plugin-tailwindcss": "3.18.2",
54
61
  "eslint-plugin-vuejs-accessibility": "^2.5.0",
55
62
  "@icebreakers/stylelint-config": "2.2.1",
56
- "eslint-plugin-better-stylelint": "0.1.1"
63
+ "eslint-plugin-better-stylelint": "0.1.3"
57
64
  },
58
65
  "optionalDependencies": {
59
- "@eslint-react/eslint-plugin": "^3.0.0",
60
- "@next/eslint-plugin-next": "^16.2.1",
61
- "@tanstack/eslint-plugin-query": "^5.95.2",
66
+ "@next/eslint-plugin-next": "^16.2.2",
67
+ "@tanstack/eslint-plugin-query": "^5.96.1",
62
68
  "@unocss/eslint-plugin": "66.6.7",
63
- "eslint-plugin-jsx-a11y": "^6.10.2",
64
- "eslint-plugin-mdx": "3.7.0",
65
- "eslint-plugin-react-hooks": "^7.0.1",
66
- "eslint-plugin-react-refresh": "^0.5.2"
69
+ "eslint-plugin-mdx": "3.7.0"
67
70
  },
68
71
  "publishConfig": {
69
72
  "access": "public",