@icebreakers/eslint-config 3.0.0 → 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/dist/index.cjs CHANGED
@@ -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.js CHANGED
@@ -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": "3.0.0",
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",