@icebreakers/eslint-config 5.0.4 → 7.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.js CHANGED
@@ -1,8 +1,8 @@
1
- import { i as __reExport, o as __toESM, r as __exportAll } from "./chunk-yCSr5jVb.js";
1
+ import { i as __reExport, o as __toESM, r as __exportAll } from "./rolldown-runtime-C8SNSOcs.js";
2
2
  import { createRequire } from "node:module";
3
3
  import path from "node:path";
4
- import process from "node:process";
5
4
  import fs from "node:fs";
5
+ import process from "node:process";
6
6
  import { fileURLToPath } from "node:url";
7
7
  //#region src/antfu.ts
8
8
  var antfu_exports = /* @__PURE__ */ __exportAll({});
@@ -96,14 +96,14 @@ function getDefaultTypescriptOptions(opts) {
96
96
  }
97
97
  //#endregion
98
98
  //#region src/utils.ts
99
- const require$1 = createRequire(import.meta.url);
99
+ const require$2 = createRequire(import.meta.url);
100
100
  const PACKAGE_DIR = path.dirname(fileURLToPath(import.meta.url));
101
101
  function isObject(o) {
102
102
  return Object.prototype.toString.call(o) === "[object Object]";
103
103
  }
104
104
  function isPackageAvailable$1(name, searchPaths = [process.cwd(), PACKAGE_DIR]) {
105
105
  try {
106
- require$1.resolve(name, { paths: searchPaths });
106
+ require$2.resolve(name, { paths: searchPaths });
107
107
  return true;
108
108
  } catch {
109
109
  const packageSegments = name.split("/");
@@ -125,13 +125,14 @@ function hasAllPackages(names, searchPaths) {
125
125
  //#endregion
126
126
  //#region src/features.ts
127
127
  const BETTER_TAILWIND_PACKAGES = ["eslint-plugin-better-tailwindcss"];
128
- const TAILWIND_PACKAGES = ["eslint-plugin-tailwindcss"];
128
+ const TAILWIND_PACKAGES = ["eslint-plugin-tailwindcss", "tailwindcss"];
129
129
  const STYLELINT_BRIDGE_PACKAGES = ["eslint-plugin-better-stylelint"];
130
130
  const MDX_PACKAGES = ["eslint-plugin-mdx"];
131
131
  const VUE_A11Y_PACKAGES = ["eslint-plugin-vuejs-accessibility"];
132
132
  const REACT_A11Y_PACKAGES = ["eslint-plugin-jsx-a11y"];
133
133
  const QUERY_PACKAGES = ["@tanstack/eslint-plugin-query"];
134
- const BETTER_TAILWIND_FILES = ["**/*.{js,mjs,cjs,ts,mts,cts,jsx,tsx,vue,html,md,mdx,astro,svelte}"];
134
+ const BETTER_TAILWIND_EXTENSIONS = "js,mjs,cjs,ts,mts,cts,jsx,tsx,vue,html,md,mdx,astro,svelte";
135
+ const BETTER_TAILWIND_FILES = [`**/*.{${BETTER_TAILWIND_EXTENSIONS}}`];
135
136
  const BETTER_TAILWIND_IGNORES = [
136
137
  "**/*.json",
137
138
  "**/*.json5",
@@ -149,37 +150,66 @@ const BETTER_TAILWIND_IGNORES = [
149
150
  "**/Gemfile.lock",
150
151
  "**/go.sum"
151
152
  ];
153
+ const BETTER_TAILWIND_SYNTAX_RULES = {
154
+ "better-tailwindcss/no-duplicate-classes": "warn",
155
+ "better-tailwindcss/no-unnecessary-whitespace": "warn"
156
+ };
157
+ const require$1 = createRequire(import.meta.url);
152
158
  function resolveStylelintConfigLoader(moduleUrl = import.meta.url) {
153
159
  return moduleUrl.endsWith(".ts") ? new URL("./stylelint.ts", moduleUrl).href : new URL("./stylelint.js", moduleUrl).href;
154
160
  }
161
+ function resolveDefaultTailwindCssConfigPath() {
162
+ try {
163
+ return require$1.resolve("tailwindcss/index.css");
164
+ } catch {
165
+ return;
166
+ }
167
+ }
168
+ function normalizeGlobPath(filePath) {
169
+ return filePath.replaceAll(path.sep, "/").replace(/^\.\//, "");
170
+ }
171
+ function resolveBetterTailwindFiles(option) {
172
+ if (option.files?.length) return option.files;
173
+ if (!option.entryPoint || path.isAbsolute(option.entryPoint)) return BETTER_TAILWIND_FILES;
174
+ const sourceDir = normalizeGlobPath(path.dirname(option.entryPoint));
175
+ if (!sourceDir || sourceDir === ".") return BETTER_TAILWIND_FILES;
176
+ return [`${sourceDir}/**/*.{${BETTER_TAILWIND_EXTENSIONS}}`];
177
+ }
178
+ function resolveBetterTailwindRules(plugin, option) {
179
+ if (option.rules === "recommended") return plugin.configs.recommended?.rules ?? {};
180
+ return BETTER_TAILWIND_SYNTAX_RULES;
181
+ }
182
+ function resolveBetterTailwindPresets(option) {
183
+ if (!option) return [];
184
+ if (!hasAllPackages(BETTER_TAILWIND_PACKAGES)) return [];
185
+ const betterTailwindcssOption = typeof option === "object" ? option : {};
186
+ return [(0, antfu_exports.interopDefault)(import("eslint-plugin-better-tailwindcss")).then((eslintPluginBetterTailwindcss) => {
187
+ const betterTailwindcssRules = resolveBetterTailwindRules(eslintPluginBetterTailwindcss, betterTailwindcssOption);
188
+ return {
189
+ name: "icebreaker/better-tailwindcss",
190
+ files: resolveBetterTailwindFiles(betterTailwindcssOption),
191
+ ignores: BETTER_TAILWIND_IGNORES,
192
+ plugins: { "better-tailwindcss": eslintPluginBetterTailwindcss },
193
+ rules: betterTailwindcssRules,
194
+ settings: { "better-tailwindcss": {
195
+ cwd: betterTailwindcssOption.cwd,
196
+ entryPoint: betterTailwindcssOption.entryPoint,
197
+ tailwindConfig: betterTailwindcssOption.tailwindConfig
198
+ } }
199
+ };
200
+ })];
201
+ }
155
202
  function resolveTailwindPresets(option) {
156
203
  if (!option) return [];
157
- if (typeof option === "object") {
158
- if (!hasAllPackages(BETTER_TAILWIND_PACKAGES)) return [];
159
- return [(0, antfu_exports.interopDefault)(import("eslint-plugin-better-tailwindcss")).then((eslintPluginBetterTailwindcss) => {
160
- const cwd = option.cwd ?? (option.entryPoint ? path.dirname(option.entryPoint) : void 0) ?? process.cwd();
161
- const betterTailwindcssRules = {
162
- ...eslintPluginBetterTailwindcss.configs["recommended-warn"].rules,
163
- ...eslintPluginBetterTailwindcss.configs["recommended-error"].rules
164
- };
165
- return {
166
- name: "icebreaker/better-tailwindcss",
167
- files: BETTER_TAILWIND_FILES,
168
- ignores: BETTER_TAILWIND_IGNORES,
169
- plugins: { "better-tailwindcss": eslintPluginBetterTailwindcss },
170
- rules: betterTailwindcssRules,
171
- settings: { "better-tailwindcss": {
172
- cwd,
173
- entryPoint: option.entryPoint,
174
- tailwindConfig: option.tailwindConfig
175
- } }
176
- };
177
- })];
178
- }
179
204
  if (!hasAllPackages(TAILWIND_PACKAGES)) return [];
205
+ const cssConfigPath = resolveDefaultTailwindCssConfigPath();
180
206
  return [(0, antfu_exports.interopDefault)(import("eslint-plugin-tailwindcss")).then((tailwind) => {
181
- return tailwind.configs["flat/recommended"];
182
- }), { rules: { "tailwindcss/no-custom-classname": "off" } }];
207
+ const tailwindPlugin = tailwind;
208
+ return tailwindPlugin.configs["flat/recommended"] ?? tailwindPlugin.configs.recommended ?? [];
209
+ }), {
210
+ ...cssConfigPath ? { settings: { tailwindcss: { cssConfigPath } } } : {},
211
+ rules: { "tailwindcss/no-custom-classname": "off" }
212
+ }];
183
213
  }
184
214
  function resolveStylelintBridgeOptions(option) {
185
215
  const { cwd, ...stylelintConfigOptions } = typeof option === "object" ? option : {};
@@ -237,10 +267,10 @@ function resolveMdxPresets(isEnabled) {
237
267
  function resolveAccessibilityPresets(isEnabled, vueOption, reactOption) {
238
268
  if (!isEnabled) return [];
239
269
  const presets = [];
240
- if (vueOption && hasAllPackages(VUE_A11Y_PACKAGES)) presets.push((0, antfu_exports.interopDefault)(import("./dist-Bhh5YMxq.js").then((m) => /* @__PURE__ */ __toESM(m.default, 1))).then((pluginVueA11y) => {
270
+ if (vueOption && hasAllPackages(VUE_A11Y_PACKAGES)) presets.push((0, antfu_exports.interopDefault)(import("./dist-CfNAWugK.js").then((m) => /* @__PURE__ */ __toESM(m.default, 1))).then((pluginVueA11y) => {
241
271
  return pluginVueA11y.configs["flat/recommended"];
242
272
  }));
243
- if (reactOption && hasAllPackages(REACT_A11Y_PACKAGES)) presets.push((0, antfu_exports.interopDefault)(import("./lib-Mwx9Doks.js").then((m) => /* @__PURE__ */ __toESM(m.default, 1))).then((jsxA11y) => {
273
+ if (reactOption && hasAllPackages(REACT_A11Y_PACKAGES)) presets.push((0, antfu_exports.interopDefault)(import("./lib-BiNYUSxy.js").then((m) => /* @__PURE__ */ __toESM(m.default, 1))).then((jsxA11y) => {
244
274
  return jsxA11y.flatConfigs.recommended;
245
275
  }));
246
276
  return presets;
@@ -255,7 +285,7 @@ function resolveNestPresets(isEnabled) {
255
285
  function resolveQueryPresets(isEnabled) {
256
286
  if (!isEnabled) return [];
257
287
  if (!hasAllPackages(QUERY_PACKAGES)) return [];
258
- return [(0, antfu_exports.interopDefault)(import("./modern-Dr_fOGoK.js")).then((pluginQuery) => pluginQuery.configs["flat/recommended"])];
288
+ return [(0, antfu_exports.interopDefault)(import("./modern-RpY8mk7x.js")).then((pluginQuery) => pluginQuery.configs["flat/recommended"])];
259
289
  }
260
290
  //#endregion
261
291
  //#region ../../node_modules/.pnpm/defu@6.1.7/node_modules/defu/dist/defu.mjs
@@ -311,7 +341,7 @@ const BASE_RULES = {
311
341
  };
312
342
  const require = createRequire(import.meta.url);
313
343
  const ANTFU_PACKAGE_DIR = path.dirname(require.resolve("@antfu/eslint-config/package.json"));
314
- const GENERAL_EDITORCONFIG_SECTIONS = new Set([
344
+ const GENERAL_EDITORCONFIG_SECTIONS = /* @__PURE__ */ new Set([
315
345
  "*",
316
346
  "**",
317
347
  "**/*",
@@ -452,6 +482,11 @@ function resolveUserOptions(options) {
452
482
  resolved.miniProgram = true;
453
483
  delete resolved.weapp;
454
484
  }
485
+ const legacyTailwindcssOption = resolved.tailwindcss;
486
+ if (isObject(legacyTailwindcssOption)) {
487
+ resolved.betterTailwindcss ??= legacyTailwindcssOption;
488
+ delete resolved.tailwindcss;
489
+ }
455
490
  const resolvedVue = mergeOptionWithDefaults(resolved.vue, getDefaultVueOptions(options), { postProcess: applyVueVersionSpecificRules });
456
491
  if (resolvedVue === void 0) delete resolved.vue;
457
492
  else resolved.vue = resolvedVue;
@@ -499,6 +534,10 @@ function getPresets(options, mode) {
499
534
  {
500
535
  files: ["**/*.{css,scss,sass,less,pcss,postcss,json,jsonc,json5}"],
501
536
  rules: { "style/eol-last": "off" }
537
+ },
538
+ {
539
+ files: ["**/*.{json,jsonc,json5}"],
540
+ rules: { "unicorn/prefer-number-properties": "off" }
502
541
  }
503
542
  ];
504
543
  if (resolved.vue !== false && resolved.vue !== void 0) presets.push({
@@ -513,7 +552,7 @@ function getPresets(options, mode) {
513
552
  languageOptions: { parser: antfu_exports.parserPlain },
514
553
  rules: {}
515
554
  });
516
- presets.push(...resolveStylelintBridgePresets(resolved.stylelint), ...resolveTailwindPresets(resolved.tailwindcss), ...resolveMdxPresets(resolved.mdx), ...resolveNestPresets(resolved.nestjs), ...resolveQueryPresets(resolved.query), ...resolveAccessibilityPresets(resolved.a11y, resolved.vue, resolved.react));
555
+ presets.push(...resolveStylelintBridgePresets(resolved.stylelint), ...resolveTailwindPresets(resolved.tailwindcss), ...resolveBetterTailwindPresets(resolved.betterTailwindcss), ...resolveMdxPresets(resolved.mdx), ...resolveNestPresets(resolved.nestjs), ...resolveQueryPresets(resolved.query), ...resolveAccessibilityPresets(resolved.a11y, resolved.vue, resolved.react));
517
556
  return [resolved, ...presets];
518
557
  }
519
558
  //#endregion
@@ -1,4 +1,4 @@
1
- import { a as __require, n as __esmMin, o as __toESM, t as __commonJSMin } from "./chunk-yCSr5jVb.js";
1
+ import { a as __require, n as __esmMin, o as __toESM, t as __commonJSMin } from "./rolldown-runtime-C8SNSOcs.js";
2
2
  import { createRequire } from "node:module";
3
3
  //#region ../../node_modules/.pnpm/jiti@2.7.0/node_modules/jiti/dist/jiti.cjs
4
4
  var require_jiti = /* @__PURE__ */ __commonJSMin(((exports, module) => {
@@ -4208,7 +4208,7 @@ var require_jiti = /* @__PURE__ */ __commonJSMin(((exports, module) => {
4208
4208
  function normalizeSlash(e) {
4209
4209
  return e.replace(/\\/g, "/");
4210
4210
  }
4211
- const rt = {}.hasOwnProperty, nt = /^([A-Z][a-z\d]*)+$/, at = new Set([
4211
+ const rt = {}.hasOwnProperty, nt = /^([A-Z][a-z\d]*)+$/, at = /* @__PURE__ */ new Set([
4212
4212
  "string",
4213
4213
  "function",
4214
4214
  "number",
@@ -4704,12 +4704,12 @@ var require_jiti = /* @__PURE__ */ __commonJSMin(((exports, module) => {
4704
4704
  function pathToFileURL(e) {
4705
4705
  return (0, Qe.pathToFileURL)(fileURLToPath(e)).toString();
4706
4706
  }
4707
- const Ut = new Set(["node", "import"]), Mt = [
4707
+ const Ut = /* @__PURE__ */ new Set(["node", "import"]), Mt = [
4708
4708
  ".mjs",
4709
4709
  ".cjs",
4710
4710
  ".js",
4711
4711
  ".json"
4712
- ], jt = new Set([
4712
+ ], jt = /* @__PURE__ */ new Set([
4713
4713
  "ERR_MODULE_NOT_FOUND",
4714
4714
  "ERR_UNSUPPORTED_DIR_IMPORT",
4715
4715
  "MODULE_NOT_FOUND",
@@ -4769,7 +4769,7 @@ var require_jiti = /* @__PURE__ */ __commonJSMin(((exports, module) => {
4769
4769
  if ("string" != typeof e) throw new TypeError("Expected a string");
4770
4770
  return e.replace(/[|\\{}()[\]^$+*?.]/g, "\\$&").replace(/-/g, "\\x2d");
4771
4771
  }
4772
- const $t = new Set([
4772
+ const $t = /* @__PURE__ */ new Set([
4773
4773
  "/",
4774
4774
  "\\",
4775
4775
  void 0
@@ -1,7 +1,7 @@
1
- const require_index = require("./index.cjs");
1
+ const require_rolldown_runtime = require("./rolldown-runtime-DzWaZAza.cjs");
2
2
  let node_module = require("node:module");
3
3
  //#region ../../node_modules/.pnpm/jiti@2.7.0/node_modules/jiti/dist/jiti.cjs
4
- var require_jiti = /* @__PURE__ */ require_index.__commonJSMin(((exports, module) => {
4
+ var require_jiti = /* @__PURE__ */ require_rolldown_runtime.__commonJSMin(((exports, module) => {
5
5
  (() => {
6
6
  var e = {
7
7
  "./node_modules/.pnpm/mlly@1.8.2/node_modules/mlly/dist lazy recursive"(e) {
@@ -4208,7 +4208,7 @@ var require_jiti = /* @__PURE__ */ require_index.__commonJSMin(((exports, module
4208
4208
  function normalizeSlash(e) {
4209
4209
  return e.replace(/\\/g, "/");
4210
4210
  }
4211
- const rt = {}.hasOwnProperty, nt = /^([A-Z][a-z\d]*)+$/, at = new Set([
4211
+ const rt = {}.hasOwnProperty, nt = /^([A-Z][a-z\d]*)+$/, at = /* @__PURE__ */ new Set([
4212
4212
  "string",
4213
4213
  "function",
4214
4214
  "number",
@@ -4704,12 +4704,12 @@ var require_jiti = /* @__PURE__ */ require_index.__commonJSMin(((exports, module
4704
4704
  function pathToFileURL(e) {
4705
4705
  return (0, Qe.pathToFileURL)(fileURLToPath(e)).toString();
4706
4706
  }
4707
- const Ut = new Set(["node", "import"]), Mt = [
4707
+ const Ut = /* @__PURE__ */ new Set(["node", "import"]), Mt = [
4708
4708
  ".mjs",
4709
4709
  ".cjs",
4710
4710
  ".js",
4711
4711
  ".json"
4712
- ], jt = new Set([
4712
+ ], jt = /* @__PURE__ */ new Set([
4713
4713
  "ERR_MODULE_NOT_FOUND",
4714
4714
  "ERR_UNSUPPORTED_DIR_IMPORT",
4715
4715
  "MODULE_NOT_FOUND",
@@ -4769,7 +4769,7 @@ var require_jiti = /* @__PURE__ */ require_index.__commonJSMin(((exports, module
4769
4769
  if ("string" != typeof e) throw new TypeError("Expected a string");
4770
4770
  return e.replace(/[|\\{}()[\]^$+*?.]/g, "\\$&").replace(/-/g, "\\x2d");
4771
4771
  }
4772
- const $t = new Set([
4772
+ const $t = /* @__PURE__ */ new Set([
4773
4773
  "/",
4774
4774
  "\\",
4775
4775
  void 0
@@ -5453,8 +5453,8 @@ function createJiti(id, opts = {}) {
5453
5453
  }
5454
5454
  var import_jiti, nativeImport, _transform;
5455
5455
  //#endregion
5456
- require_index.__esmMin((() => {
5457
- import_jiti = /* @__PURE__ */ require_index.__toESM(require_jiti(), 1);
5456
+ require_rolldown_runtime.__esmMin((() => {
5457
+ import_jiti = /* @__PURE__ */ require_rolldown_runtime.__toESM(require_jiti(), 1);
5458
5458
  nativeImport = (id) => import(id);
5459
5459
  }))();
5460
5460
  exports.createJiti = createJiti;