@icebreakers/eslint-config 2.1.2 → 3.0.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
@@ -8,7 +8,7 @@
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
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`)
package/README.zh.md CHANGED
@@ -6,7 +6,7 @@
6
6
 
7
7
  ## 环境要求
8
8
 
9
- - Node.js 18 或更高版本
9
+ - Node.js 22 或更高版本
10
10
  - 支持 Flat Config 的 ESLint 9
11
11
  - React 相关插件已随当前包一起分发。Next.js、Query 等生态预设仍保持可选,缺失时会自动跳过对应配置,而不是在解析时直接报错。
12
12
  - 如需启用 Tailwind、MDX、UnoCSS 等,可安装对应的可选依赖:`eslint-plugin-tailwindcss` / `eslint-plugin-better-tailwindcss`、`eslint-plugin-mdx`、`@unocss/eslint-plugin`
package/dist/index.cjs CHANGED
@@ -345,7 +345,7 @@ const BASE_DEFAULTS = {
345
345
  };
346
346
  const BASE_RULES = {
347
347
  "dot-notation": "off",
348
- "e18e/ban-dependencies": "warn",
348
+ "e18e/ban-dependencies": ["warn", { allowed: ["axios", "lint-staged"] }],
349
349
  "e18e/prefer-array-to-sorted": "off",
350
350
  "pnpm/json-enforce-catalog": "off",
351
351
  "pnpm/json-prefer-workspace-settings": "off",
@@ -563,13 +563,41 @@ function normalizeOptionalAntfuFeatures(options) {
563
563
  if (normalized.nextjs && !hasAllPackages([...OPTIONAL_ANTFU_FEATURE_PACKAGES.nextjs])) normalized.nextjs = false;
564
564
  return normalized;
565
565
  }
566
+ function hasGlobalIgnoreShape(config) {
567
+ const keys = Object.keys(config).filter((key) => key !== "name");
568
+ return keys.length === 1 && keys[0] === "ignores";
569
+ }
570
+ function liftConfigIgnores(config) {
571
+ if (!("ignores" in config) || config.ignores == null || hasGlobalIgnoreShape(config) || "files" in config) return config;
572
+ const { ignores, name, ...rest } = config;
573
+ return [{
574
+ ...name ? { name: `${name}/ignores` } : {},
575
+ ignores
576
+ }, {
577
+ ...name ? { name } : {},
578
+ ...rest
579
+ }];
580
+ }
581
+ function normalizeResolvedUserConfig(userConfig) {
582
+ if (Array.isArray(userConfig)) return userConfig.flatMap((config) => liftConfigIgnores(config));
583
+ return liftConfigIgnores(userConfig);
584
+ }
585
+ function isComposer(value) {
586
+ return !!value && typeof value === "object" && "toConfigs" in value && typeof value.toConfigs === "function";
587
+ }
588
+ function normalizeUserConfig(userConfig) {
589
+ if (typeof userConfig?.then === "function") return Promise.resolve(userConfig).then((resolved) => {
590
+ return isComposer(resolved) ? resolved : normalizeResolvedUserConfig(resolved);
591
+ });
592
+ return isComposer(userConfig) ? userConfig : normalizeResolvedUserConfig(userConfig);
593
+ }
566
594
  function icebreaker(options = {}, ...userConfigs) {
567
595
  const [resolved, ...presets] = getPresets(options);
568
- return (0, antfu_exports.antfu)(normalizeOptionalAntfuFeatures(resolved), ...presets, ...userConfigs);
596
+ return (0, antfu_exports.antfu)(normalizeOptionalAntfuFeatures(resolved), ...presets, ...userConfigs.map(normalizeUserConfig));
569
597
  }
570
598
  function icebreakerLegacy(options = {}, ...userConfigs) {
571
599
  const [resolved, ...presets] = getPresets(options, "legacy");
572
- return (0, antfu_exports.antfu)(normalizeOptionalAntfuFeatures(resolved), ...presets, ...userConfigs);
600
+ return (0, antfu_exports.antfu)(normalizeOptionalAntfuFeatures(resolved), ...presets, ...userConfigs.map(normalizeUserConfig));
573
601
  }
574
602
  //#endregion
575
603
  exports.__toESM = __toESM;
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
@@ -336,7 +336,7 @@ const BASE_DEFAULTS = {
336
336
  };
337
337
  const BASE_RULES = {
338
338
  "dot-notation": "off",
339
- "e18e/ban-dependencies": "warn",
339
+ "e18e/ban-dependencies": ["warn", { allowed: ["axios", "lint-staged"] }],
340
340
  "e18e/prefer-array-to-sorted": "off",
341
341
  "pnpm/json-enforce-catalog": "off",
342
342
  "pnpm/json-prefer-workspace-settings": "off",
@@ -554,13 +554,41 @@ function normalizeOptionalAntfuFeatures(options) {
554
554
  if (normalized.nextjs && !hasAllPackages([...OPTIONAL_ANTFU_FEATURE_PACKAGES.nextjs])) normalized.nextjs = false;
555
555
  return normalized;
556
556
  }
557
+ function hasGlobalIgnoreShape(config) {
558
+ const keys = Object.keys(config).filter((key) => key !== "name");
559
+ return keys.length === 1 && keys[0] === "ignores";
560
+ }
561
+ function liftConfigIgnores(config) {
562
+ if (!("ignores" in config) || config.ignores == null || hasGlobalIgnoreShape(config) || "files" in config) return config;
563
+ const { ignores, name, ...rest } = config;
564
+ return [{
565
+ ...name ? { name: `${name}/ignores` } : {},
566
+ ignores
567
+ }, {
568
+ ...name ? { name } : {},
569
+ ...rest
570
+ }];
571
+ }
572
+ function normalizeResolvedUserConfig(userConfig) {
573
+ if (Array.isArray(userConfig)) return userConfig.flatMap((config) => liftConfigIgnores(config));
574
+ return liftConfigIgnores(userConfig);
575
+ }
576
+ function isComposer(value) {
577
+ return !!value && typeof value === "object" && "toConfigs" in value && typeof value.toConfigs === "function";
578
+ }
579
+ function normalizeUserConfig(userConfig) {
580
+ if (typeof userConfig?.then === "function") return Promise.resolve(userConfig).then((resolved) => {
581
+ return isComposer(resolved) ? resolved : normalizeResolvedUserConfig(resolved);
582
+ });
583
+ return isComposer(userConfig) ? userConfig : normalizeResolvedUserConfig(userConfig);
584
+ }
557
585
  function icebreaker(options = {}, ...userConfigs) {
558
586
  const [resolved, ...presets] = getPresets(options);
559
- return (0, antfu_exports.antfu)(normalizeOptionalAntfuFeatures(resolved), ...presets, ...userConfigs);
587
+ return (0, antfu_exports.antfu)(normalizeOptionalAntfuFeatures(resolved), ...presets, ...userConfigs.map(normalizeUserConfig));
560
588
  }
561
589
  function icebreakerLegacy(options = {}, ...userConfigs) {
562
590
  const [resolved, ...presets] = getPresets(options, "legacy");
563
- return (0, antfu_exports.antfu)(normalizeOptionalAntfuFeatures(resolved), ...presets, ...userConfigs);
591
+ return (0, antfu_exports.antfu)(normalizeOptionalAntfuFeatures(resolved), ...presets, ...userConfigs.map(normalizeUserConfig));
564
592
  }
565
593
  //#endregion
566
594
  export { getPresets, icebreaker, icebreakerLegacy };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@icebreakers/eslint-config",
3
3
  "type": "module",
4
- "version": "2.1.2",
4
+ "version": "3.0.1",
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,8 +50,8 @@
47
50
  }
48
51
  },
49
52
  "dependencies": {
50
- "@antfu/eslint-config": "7.7.3",
51
- "@eslint-react/eslint-plugin": "^2.13.0",
53
+ "@antfu/eslint-config": "8.0.0",
54
+ "@eslint-react/eslint-plugin": "^3.0.0",
52
55
  "eslint-plugin-better-tailwindcss": "^4.3.2",
53
56
  "eslint-plugin-format": "2.0.1",
54
57
  "eslint-plugin-jsx-a11y": "^6.10.2",
@@ -57,11 +60,11 @@
57
60
  "eslint-plugin-tailwindcss": "3.18.2",
58
61
  "eslint-plugin-vuejs-accessibility": "^2.5.0",
59
62
  "@icebreakers/stylelint-config": "2.2.1",
60
- "eslint-plugin-better-stylelint": "0.1.2"
63
+ "eslint-plugin-better-stylelint": "0.1.3"
61
64
  },
62
65
  "optionalDependencies": {
63
- "@next/eslint-plugin-next": "^16.2.1",
64
- "@tanstack/eslint-plugin-query": "^5.95.2",
66
+ "@next/eslint-plugin-next": "^16.2.2",
67
+ "@tanstack/eslint-plugin-query": "^5.96.1",
65
68
  "@unocss/eslint-plugin": "66.6.7",
66
69
  "eslint-plugin-mdx": "3.7.0"
67
70
  },