@icebreakers/eslint-config 3.0.0 → 4.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/dist/index.cjs CHANGED
@@ -293,7 +293,7 @@ function resolveQueryPresets(isEnabled) {
293
293
  return [(0, antfu_exports.interopDefault)(import("@tanstack/eslint-plugin-query")).then((pluginQuery) => pluginQuery.configs["flat/recommended"])];
294
294
  }
295
295
  //#endregion
296
- //#region ../../node_modules/.pnpm/defu@6.1.4/node_modules/defu/dist/defu.mjs
296
+ //#region ../../node_modules/.pnpm/defu@6.1.6/node_modules/defu/dist/defu.mjs
297
297
  function isPlainObject(value) {
298
298
  if (value === null || typeof value !== "object") return false;
299
299
  const prototype = Object.getPrototypeOf(value);
@@ -304,8 +304,8 @@ function isPlainObject(value) {
304
304
  }
305
305
  function _defu(baseObject, defaults, namespace = ".", merger) {
306
306
  if (!isPlainObject(defaults)) return _defu(baseObject, {}, namespace, merger);
307
- const object = Object.assign({}, defaults);
308
- for (const key in baseObject) {
307
+ const object = { ...defaults };
308
+ for (const key of Object.keys(baseObject)) {
309
309
  if (key === "__proto__" || key === "constructor") continue;
310
310
  const value = baseObject[key];
311
311
  if (value === null || value === void 0) continue;
@@ -548,6 +548,29 @@ function getPresets(options, mode) {
548
548
  return [resolved, ...presets];
549
549
  }
550
550
  //#endregion
551
+ //#region src/polyfills.ts
552
+ function createObjectGroupBy() {
553
+ return function groupBy(items, callback) {
554
+ const groups = {};
555
+ let index = 0;
556
+ for (const item of items) {
557
+ const key = callback(item, index++);
558
+ groups[key] ??= [];
559
+ groups[key].push(item);
560
+ }
561
+ return groups;
562
+ };
563
+ }
564
+ function ensureObjectGroupBy() {
565
+ if (typeof Object.groupBy === "function") return;
566
+ Object.defineProperty(Object, "groupBy", {
567
+ value: createObjectGroupBy(),
568
+ configurable: true,
569
+ writable: true
570
+ });
571
+ }
572
+ ensureObjectGroupBy();
573
+ //#endregion
551
574
  //#region src/factory.ts
552
575
  const OPTIONAL_ANTFU_FEATURE_PACKAGES = {
553
576
  react: [
@@ -563,13 +586,42 @@ function normalizeOptionalAntfuFeatures(options) {
563
586
  if (normalized.nextjs && !hasAllPackages([...OPTIONAL_ANTFU_FEATURE_PACKAGES.nextjs])) normalized.nextjs = false;
564
587
  return normalized;
565
588
  }
589
+ function hasGlobalIgnoreShape(config) {
590
+ const keys = Object.keys(config).filter((key) => key !== "name");
591
+ return keys.length === 1 && keys[0] === "ignores";
592
+ }
593
+ function liftConfigIgnores(config) {
594
+ if (!("ignores" in config) || config.ignores == null || hasGlobalIgnoreShape(config) || "files" in config) return config;
595
+ const { ignores, name, ...rest } = config;
596
+ return [{
597
+ ...name ? { name: `${name}/ignores` } : {},
598
+ ignores
599
+ }, {
600
+ ...name ? { name } : {},
601
+ ...rest
602
+ }];
603
+ }
604
+ function normalizeResolvedUserConfig(userConfig) {
605
+ if (Array.isArray(userConfig)) return userConfig.flatMap((config) => liftConfigIgnores(config));
606
+ return liftConfigIgnores(userConfig);
607
+ }
608
+ function isComposer(value) {
609
+ return !!value && typeof value === "object" && "toConfigs" in value && typeof value.toConfigs === "function";
610
+ }
611
+ function normalizeUserConfig(userConfig) {
612
+ if (typeof userConfig?.then === "function") return Promise.resolve(userConfig).then((resolved) => {
613
+ return isComposer(resolved) ? resolved : normalizeResolvedUserConfig(resolved);
614
+ });
615
+ const resolvedUserConfig = userConfig;
616
+ return isComposer(resolvedUserConfig) ? resolvedUserConfig : normalizeResolvedUserConfig(resolvedUserConfig);
617
+ }
566
618
  function icebreaker(options = {}, ...userConfigs) {
567
619
  const [resolved, ...presets] = getPresets(options);
568
- return (0, antfu_exports.antfu)(normalizeOptionalAntfuFeatures(resolved), ...presets, ...userConfigs);
620
+ return (0, antfu_exports.antfu)(normalizeOptionalAntfuFeatures(resolved), ...presets, ...userConfigs.map(normalizeUserConfig));
569
621
  }
570
622
  function icebreakerLegacy(options = {}, ...userConfigs) {
571
623
  const [resolved, ...presets] = getPresets(options, "legacy");
572
- return (0, antfu_exports.antfu)(normalizeOptionalAntfuFeatures(resolved), ...presets, ...userConfigs);
624
+ return (0, antfu_exports.antfu)(normalizeOptionalAntfuFeatures(resolved), ...presets, ...userConfigs.map(normalizeUserConfig));
573
625
  }
574
626
  //#endregion
575
627
  exports.__toESM = __toESM;
package/dist/index.d.cts CHANGED
@@ -3008,6 +3008,7 @@ interface StylelintBridgeOption extends IcebreakerStylelintOptions {
3008
3008
  cwd?: string;
3009
3009
  }
3010
3010
  type StylelintBridgeConfig = boolean | StylelintBridgeOption;
3011
+ type ResolvableUserConfig = TypedFlatConfigItem$1 | TypedFlatConfigItem$1[] | FlatConfigComposer<any, any> | Linter.Config[];
3011
3012
  type UserDefinedOptions = OptionsConfig & TypedFlatConfigItem$1 & {
3012
3013
  /**
3013
3014
  * Enable Mini Program support.
@@ -3056,7 +3057,7 @@ type UserDefinedOptions = OptionsConfig & TypedFlatConfigItem$1 & {
3056
3057
  */
3057
3058
  weapp?: boolean;
3058
3059
  };
3059
- type UserConfigItem = Awaitable<TypedFlatConfigItem$1 | TypedFlatConfigItem$1[] | FlatConfigComposer<any, any> | Linter.Config[]>;
3060
+ type UserConfigItem = Awaitable<ResolvableUserConfig>;
3060
3061
  //#endregion
3061
3062
  //#region src/factory.d.ts
3062
3063
  declare function icebreaker(options?: UserDefinedOptions, ...userConfigs: UserConfigItem[]): FlatConfigComposer<TypedFlatConfigItem, ConfigNames>;
package/dist/index.d.ts CHANGED
@@ -3008,6 +3008,7 @@ interface StylelintBridgeOption extends IcebreakerStylelintOptions {
3008
3008
  cwd?: string;
3009
3009
  }
3010
3010
  type StylelintBridgeConfig = boolean | StylelintBridgeOption;
3011
+ type ResolvableUserConfig = TypedFlatConfigItem$1 | TypedFlatConfigItem$1[] | FlatConfigComposer<any, any> | Linter.Config[];
3011
3012
  type UserDefinedOptions = OptionsConfig & TypedFlatConfigItem$1 & {
3012
3013
  /**
3013
3014
  * Enable Mini Program support.
@@ -3056,7 +3057,7 @@ type UserDefinedOptions = OptionsConfig & TypedFlatConfigItem$1 & {
3056
3057
  */
3057
3058
  weapp?: boolean;
3058
3059
  };
3059
- type UserConfigItem = Awaitable<TypedFlatConfigItem$1 | TypedFlatConfigItem$1[] | FlatConfigComposer<any, any> | Linter.Config[]>;
3060
+ type UserConfigItem = Awaitable<ResolvableUserConfig>;
3060
3061
  //#endregion
3061
3062
  //#region src/factory.d.ts
3062
3063
  declare function icebreaker(options?: UserDefinedOptions, ...userConfigs: UserConfigItem[]): FlatConfigComposer<TypedFlatConfigItem, ConfigNames>;
package/dist/index.js CHANGED
@@ -284,7 +284,7 @@ function resolveQueryPresets(isEnabled) {
284
284
  return [(0, antfu_exports.interopDefault)(import("@tanstack/eslint-plugin-query")).then((pluginQuery) => pluginQuery.configs["flat/recommended"])];
285
285
  }
286
286
  //#endregion
287
- //#region ../../node_modules/.pnpm/defu@6.1.4/node_modules/defu/dist/defu.mjs
287
+ //#region ../../node_modules/.pnpm/defu@6.1.6/node_modules/defu/dist/defu.mjs
288
288
  function isPlainObject(value) {
289
289
  if (value === null || typeof value !== "object") return false;
290
290
  const prototype = Object.getPrototypeOf(value);
@@ -295,8 +295,8 @@ function isPlainObject(value) {
295
295
  }
296
296
  function _defu(baseObject, defaults, namespace = ".", merger) {
297
297
  if (!isPlainObject(defaults)) return _defu(baseObject, {}, namespace, merger);
298
- const object = Object.assign({}, defaults);
299
- for (const key in baseObject) {
298
+ const object = { ...defaults };
299
+ for (const key of Object.keys(baseObject)) {
300
300
  if (key === "__proto__" || key === "constructor") continue;
301
301
  const value = baseObject[key];
302
302
  if (value === null || value === void 0) continue;
@@ -539,6 +539,29 @@ function getPresets(options, mode) {
539
539
  return [resolved, ...presets];
540
540
  }
541
541
  //#endregion
542
+ //#region src/polyfills.ts
543
+ function createObjectGroupBy() {
544
+ return function groupBy(items, callback) {
545
+ const groups = {};
546
+ let index = 0;
547
+ for (const item of items) {
548
+ const key = callback(item, index++);
549
+ groups[key] ??= [];
550
+ groups[key].push(item);
551
+ }
552
+ return groups;
553
+ };
554
+ }
555
+ function ensureObjectGroupBy() {
556
+ if (typeof Object.groupBy === "function") return;
557
+ Object.defineProperty(Object, "groupBy", {
558
+ value: createObjectGroupBy(),
559
+ configurable: true,
560
+ writable: true
561
+ });
562
+ }
563
+ ensureObjectGroupBy();
564
+ //#endregion
542
565
  //#region src/factory.ts
543
566
  const OPTIONAL_ANTFU_FEATURE_PACKAGES = {
544
567
  react: [
@@ -554,13 +577,42 @@ function normalizeOptionalAntfuFeatures(options) {
554
577
  if (normalized.nextjs && !hasAllPackages([...OPTIONAL_ANTFU_FEATURE_PACKAGES.nextjs])) normalized.nextjs = false;
555
578
  return normalized;
556
579
  }
580
+ function hasGlobalIgnoreShape(config) {
581
+ const keys = Object.keys(config).filter((key) => key !== "name");
582
+ return keys.length === 1 && keys[0] === "ignores";
583
+ }
584
+ function liftConfigIgnores(config) {
585
+ if (!("ignores" in config) || config.ignores == null || hasGlobalIgnoreShape(config) || "files" in config) return config;
586
+ const { ignores, name, ...rest } = config;
587
+ return [{
588
+ ...name ? { name: `${name}/ignores` } : {},
589
+ ignores
590
+ }, {
591
+ ...name ? { name } : {},
592
+ ...rest
593
+ }];
594
+ }
595
+ function normalizeResolvedUserConfig(userConfig) {
596
+ if (Array.isArray(userConfig)) return userConfig.flatMap((config) => liftConfigIgnores(config));
597
+ return liftConfigIgnores(userConfig);
598
+ }
599
+ function isComposer(value) {
600
+ return !!value && typeof value === "object" && "toConfigs" in value && typeof value.toConfigs === "function";
601
+ }
602
+ function normalizeUserConfig(userConfig) {
603
+ if (typeof userConfig?.then === "function") return Promise.resolve(userConfig).then((resolved) => {
604
+ return isComposer(resolved) ? resolved : normalizeResolvedUserConfig(resolved);
605
+ });
606
+ const resolvedUserConfig = userConfig;
607
+ return isComposer(resolvedUserConfig) ? resolvedUserConfig : normalizeResolvedUserConfig(resolvedUserConfig);
608
+ }
557
609
  function icebreaker(options = {}, ...userConfigs) {
558
610
  const [resolved, ...presets] = getPresets(options);
559
- return (0, antfu_exports.antfu)(normalizeOptionalAntfuFeatures(resolved), ...presets, ...userConfigs);
611
+ return (0, antfu_exports.antfu)(normalizeOptionalAntfuFeatures(resolved), ...presets, ...userConfigs.map(normalizeUserConfig));
560
612
  }
561
613
  function icebreakerLegacy(options = {}, ...userConfigs) {
562
614
  const [resolved, ...presets] = getPresets(options, "legacy");
563
- return (0, antfu_exports.antfu)(normalizeOptionalAntfuFeatures(resolved), ...presets, ...userConfigs);
615
+ return (0, antfu_exports.antfu)(normalizeOptionalAntfuFeatures(resolved), ...presets, ...userConfigs.map(normalizeUserConfig));
564
616
  }
565
617
  //#endregion
566
618
  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": "3.0.0",
4
+ "version": "4.0.0",
5
5
  "description": "ESLint preset from Icebreaker's dev-configs",
6
6
  "author": "ice breaker <1324318532@qq.com>",
7
7
  "license": "MIT",
@@ -39,7 +39,7 @@
39
39
  "index.d.ts"
40
40
  ],
41
41
  "engines": {
42
- "node": ">=22.0.0"
42
+ "node": "^20.19.0 || >=22.12.0"
43
43
  },
44
44
  "peerDependencies": {
45
45
  "eslint-plugin-pnpm": "^1.4.3"
@@ -59,8 +59,8 @@
59
59
  "eslint-plugin-react-refresh": "^0.5.2",
60
60
  "eslint-plugin-tailwindcss": "3.18.2",
61
61
  "eslint-plugin-vuejs-accessibility": "^2.5.0",
62
- "@icebreakers/stylelint-config": "2.2.1",
63
- "eslint-plugin-better-stylelint": "0.1.3"
62
+ "@icebreakers/stylelint-config": "3.0.0",
63
+ "eslint-plugin-better-stylelint": "1.0.0"
64
64
  },
65
65
  "optionalDependencies": {
66
66
  "@next/eslint-plugin-next": "^16.2.2",