@icebreakers/eslint-config 6.0.0 → 7.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.js CHANGED
@@ -1,8 +1,8 @@
1
- import { i as __reExport, o as __toESM, r as __exportAll } from "./rolldown-runtime-C8SNSOcs.js";
1
+ import { n as __reExport, t as __exportAll } from "./rolldown-runtime-B4FMCO8f.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,38 +150,69 @@ 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);
158
+ function interopPluginDefault(modulePromise) {
159
+ return (0, antfu_exports.interopDefault)(modulePromise);
160
+ }
152
161
  function resolveStylelintConfigLoader(moduleUrl = import.meta.url) {
153
162
  return moduleUrl.endsWith(".ts") ? new URL("./stylelint.ts", moduleUrl).href : new URL("./stylelint.js", moduleUrl).href;
154
163
  }
164
+ function resolveDefaultTailwindCssConfigPath() {
165
+ try {
166
+ return require$1.resolve("tailwindcss/index.css");
167
+ } catch {
168
+ return;
169
+ }
170
+ }
171
+ function normalizeGlobPath(filePath) {
172
+ return filePath.replaceAll(path.sep, "/").replace(/^\.\//, "");
173
+ }
174
+ function resolveBetterTailwindFiles(option) {
175
+ if (option.files?.length) return option.files;
176
+ if (!option.entryPoint || path.isAbsolute(option.entryPoint)) return BETTER_TAILWIND_FILES;
177
+ const sourceDir = normalizeGlobPath(path.dirname(option.entryPoint));
178
+ if (!sourceDir || sourceDir === ".") return BETTER_TAILWIND_FILES;
179
+ return [`${sourceDir}/**/*.{${BETTER_TAILWIND_EXTENSIONS}}`];
180
+ }
181
+ function resolveBetterTailwindRules(plugin, option) {
182
+ if (option.rules === "recommended") return plugin.configs.recommended?.rules ?? {};
183
+ return BETTER_TAILWIND_SYNTAX_RULES;
184
+ }
185
+ function resolveBetterTailwindPresets(option) {
186
+ if (!option) return [];
187
+ if (!hasAllPackages(BETTER_TAILWIND_PACKAGES)) return [];
188
+ const betterTailwindcssOption = typeof option === "object" ? option : {};
189
+ return [interopPluginDefault(import("eslint-plugin-better-tailwindcss")).then((eslintPluginBetterTailwindcss) => {
190
+ const betterTailwindcssRules = resolveBetterTailwindRules(eslintPluginBetterTailwindcss, betterTailwindcssOption);
191
+ return {
192
+ name: "icebreaker/better-tailwindcss",
193
+ files: resolveBetterTailwindFiles(betterTailwindcssOption),
194
+ ignores: BETTER_TAILWIND_IGNORES,
195
+ plugins: { "better-tailwindcss": eslintPluginBetterTailwindcss },
196
+ rules: betterTailwindcssRules,
197
+ settings: { "better-tailwindcss": {
198
+ cwd: betterTailwindcssOption.cwd,
199
+ entryPoint: betterTailwindcssOption.entryPoint,
200
+ tailwindConfig: betterTailwindcssOption.tailwindConfig
201
+ } }
202
+ };
203
+ })];
204
+ }
155
205
  function resolveTailwindPresets(option) {
156
206
  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
207
  if (!hasAllPackages(TAILWIND_PACKAGES)) return [];
180
- return [(0, antfu_exports.interopDefault)(import("eslint-plugin-tailwindcss")).then((tailwind) => {
208
+ const cssConfigPath = resolveDefaultTailwindCssConfigPath();
209
+ return [interopPluginDefault(import("eslint-plugin-tailwindcss")).then((tailwind) => {
181
210
  const tailwindPlugin = tailwind;
182
211
  return tailwindPlugin.configs["flat/recommended"] ?? tailwindPlugin.configs.recommended ?? [];
183
- }), { rules: { "tailwindcss/no-custom-classname": "off" } }];
212
+ }), {
213
+ ...cssConfigPath ? { settings: { tailwindcss: { cssConfigPath } } } : {},
214
+ rules: { "tailwindcss/no-custom-classname": "off" }
215
+ }];
184
216
  }
185
217
  function resolveStylelintBridgeOptions(option) {
186
218
  const { cwd, ...stylelintConfigOptions } = typeof option === "object" ? option : {};
@@ -222,7 +254,7 @@ function resolveStylelintBridgePresets(option) {
222
254
  function resolveMdxPresets(isEnabled) {
223
255
  if (!isEnabled) return [];
224
256
  if (!hasAllPackages(MDX_PACKAGES)) return [];
225
- return [(0, antfu_exports.interopDefault)(import("eslint-plugin-mdx")).then((mdx) => {
257
+ return [interopPluginDefault(import("eslint-plugin-mdx")).then((mdx) => {
226
258
  return [{
227
259
  ...mdx.flat,
228
260
  processor: mdx.createRemarkProcessor({
@@ -238,10 +270,10 @@ function resolveMdxPresets(isEnabled) {
238
270
  function resolveAccessibilityPresets(isEnabled, vueOption, reactOption) {
239
271
  if (!isEnabled) return [];
240
272
  const presets = [];
241
- if (vueOption && hasAllPackages(VUE_A11Y_PACKAGES)) presets.push((0, antfu_exports.interopDefault)(import("./dist-DTWNkNCv.js").then((m) => /* @__PURE__ */ __toESM(m.default, 1))).then((pluginVueA11y) => {
273
+ if (vueOption && hasAllPackages(VUE_A11Y_PACKAGES)) presets.push((0, antfu_exports.interopDefault)(import("eslint-plugin-vuejs-accessibility")).then((pluginVueA11y) => {
242
274
  return pluginVueA11y.configs["flat/recommended"];
243
275
  }));
244
- if (reactOption && hasAllPackages(REACT_A11Y_PACKAGES)) presets.push((0, antfu_exports.interopDefault)(import("./lib-BOuqso-8.js").then((m) => /* @__PURE__ */ __toESM(m.default, 1))).then((jsxA11y) => {
276
+ if (reactOption && hasAllPackages(REACT_A11Y_PACKAGES)) presets.push((0, antfu_exports.interopDefault)(import("eslint-plugin-jsx-a11y")).then((jsxA11y) => {
245
277
  return jsxA11y.flatConfigs.recommended;
246
278
  }));
247
279
  return presets;
@@ -256,7 +288,7 @@ function resolveNestPresets(isEnabled) {
256
288
  function resolveQueryPresets(isEnabled) {
257
289
  if (!isEnabled) return [];
258
290
  if (!hasAllPackages(QUERY_PACKAGES)) return [];
259
- return [(0, antfu_exports.interopDefault)(import("./modern-CoGNcL7O.js")).then((pluginQuery) => pluginQuery.configs["flat/recommended"])];
291
+ return [interopPluginDefault(import("./modern-RpY8mk7x.js")).then((pluginQuery) => pluginQuery.configs["flat/recommended"])];
260
292
  }
261
293
  //#endregion
262
294
  //#region ../../node_modules/.pnpm/defu@6.1.7/node_modules/defu/dist/defu.mjs
@@ -453,6 +485,11 @@ function resolveUserOptions(options) {
453
485
  resolved.miniProgram = true;
454
486
  delete resolved.weapp;
455
487
  }
488
+ const legacyTailwindcssOption = resolved.tailwindcss;
489
+ if (isObject(legacyTailwindcssOption)) {
490
+ resolved.betterTailwindcss ??= legacyTailwindcssOption;
491
+ delete resolved.tailwindcss;
492
+ }
456
493
  const resolvedVue = mergeOptionWithDefaults(resolved.vue, getDefaultVueOptions(options), { postProcess: applyVueVersionSpecificRules });
457
494
  if (resolvedVue === void 0) delete resolved.vue;
458
495
  else resolved.vue = resolvedVue;
@@ -518,7 +555,7 @@ function getPresets(options, mode) {
518
555
  languageOptions: { parser: antfu_exports.parserPlain },
519
556
  rules: {}
520
557
  });
521
- presets.push(...resolveStylelintBridgePresets(resolved.stylelint), ...resolveTailwindPresets(resolved.tailwindcss), ...resolveMdxPresets(resolved.mdx), ...resolveNestPresets(resolved.nestjs), ...resolveQueryPresets(resolved.query), ...resolveAccessibilityPresets(resolved.a11y, resolved.vue, resolved.react));
558
+ 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));
522
559
  return [resolved, ...presets];
523
560
  }
524
561
  //#endregion
@@ -643,7 +680,7 @@ function isComposer(value) {
643
680
  return !!value && typeof value === "object" && "toConfigs" in value && typeof value.toConfigs === "function";
644
681
  }
645
682
  function normalizeUserConfig(userConfig) {
646
- if (typeof userConfig?.then === "function") return Promise.resolve(userConfig).then((resolved) => {
683
+ if (typeof userConfig?.then === "function") return userConfig.then((resolved) => {
647
684
  return isComposer(resolved) ? resolved : normalizeResolvedUserConfig(resolved);
648
685
  });
649
686
  const resolvedUserConfig = userConfig;
@@ -1,5 +1,5 @@
1
1
  let _typescript_eslint_utils = require("@typescript-eslint/utils");
2
- //#region ../../node_modules/.pnpm/@tanstack+eslint-plugin-query@5.101.1_eslint@10.5.0_jiti@2.7.0__typescript@6.0.3/node_modules/@tanstack/eslint-plugin-query/build/modern/chunk-VALYN6GR.js
2
+ //#region ../../node_modules/.pnpm/@tanstack+eslint-plugin-query@5.101.2_eslint@10.6.0_jiti@2.7.0__typescript@6.0.3/node_modules/@tanstack/eslint-plugin-query/build/modern/chunk-VALYN6GR.js
3
3
  function uniqueBy(arr, fn) {
4
4
  return arr.filter((x, i, a) => a.findIndex((y) => fn(x) === fn(y)) === i);
5
5
  }
@@ -1176,7 +1176,7 @@ var rules = {
1176
1176
  [name8]: rule8
1177
1177
  };
1178
1178
  //#endregion
1179
- //#region ../../node_modules/.pnpm/@tanstack+eslint-plugin-query@5.101.1_eslint@10.5.0_jiti@2.7.0__typescript@6.0.3/node_modules/@tanstack/eslint-plugin-query/build/modern/index.js
1179
+ //#region ../../node_modules/.pnpm/@tanstack+eslint-plugin-query@5.101.2_eslint@10.6.0_jiti@2.7.0__typescript@6.0.3/node_modules/@tanstack/eslint-plugin-query/build/modern/index.js
1180
1180
  var recommendedRules = {
1181
1181
  "@tanstack/query/exhaustive-deps": "error",
1182
1182
  "@tanstack/query/no-rest-destructuring": "warn",
@@ -1,5 +1,5 @@
1
1
  import { AST_NODE_TYPES, ESLintUtils, TSESTree } from "@typescript-eslint/utils";
2
- //#region ../../node_modules/.pnpm/@tanstack+eslint-plugin-query@5.101.1_eslint@10.5.0_jiti@2.7.0__typescript@6.0.3/node_modules/@tanstack/eslint-plugin-query/build/modern/chunk-VALYN6GR.js
2
+ //#region ../../node_modules/.pnpm/@tanstack+eslint-plugin-query@5.101.2_eslint@10.6.0_jiti@2.7.0__typescript@6.0.3/node_modules/@tanstack/eslint-plugin-query/build/modern/chunk-VALYN6GR.js
3
3
  function uniqueBy(arr, fn) {
4
4
  return arr.filter((x, i, a) => a.findIndex((y) => fn(x) === fn(y)) === i);
5
5
  }
@@ -1176,7 +1176,7 @@ var rules = {
1176
1176
  [name8]: rule8
1177
1177
  };
1178
1178
  //#endregion
1179
- //#region ../../node_modules/.pnpm/@tanstack+eslint-plugin-query@5.101.1_eslint@10.5.0_jiti@2.7.0__typescript@6.0.3/node_modules/@tanstack/eslint-plugin-query/build/modern/index.js
1179
+ //#region ../../node_modules/.pnpm/@tanstack+eslint-plugin-query@5.101.2_eslint@10.6.0_jiti@2.7.0__typescript@6.0.3/node_modules/@tanstack/eslint-plugin-query/build/modern/index.js
1180
1180
  var recommendedRules = {
1181
1181
  "@tanstack/query/exhaustive-deps": "error",
1182
1182
  "@tanstack/query/no-rest-destructuring": "warn",
@@ -1,20 +1,9 @@
1
- import { createRequire } from "node:module";
1
+ import "node:module";
2
2
  //#region \0rolldown/runtime.js
3
- var __create = Object.create;
4
3
  var __defProp = Object.defineProperty;
5
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
7
- var __getProtoOf = Object.getPrototypeOf;
8
6
  var __hasOwnProp = Object.prototype.hasOwnProperty;
9
- var __esmMin = (fn, res, err) => () => {
10
- if (err) throw err[0];
11
- try {
12
- return fn && (res = fn(fn = 0)), res;
13
- } catch (e) {
14
- throw err = [e], e;
15
- }
16
- };
17
- var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
18
7
  var __exportAll = (all, no_symbols) => {
19
8
  let target = {};
20
9
  for (var name in all) __defProp(target, name, {
@@ -35,10 +24,5 @@ var __copyProps = (to, from, except, desc) => {
35
24
  return to;
36
25
  };
37
26
  var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
38
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
39
- value: mod,
40
- enumerable: true
41
- }) : target, mod));
42
- var __require = /* #__PURE__ */ (() => createRequire(import.meta.url))();
43
27
  //#endregion
44
- export { __require as a, __reExport as i, __esmMin as n, __toESM as o, __exportAll as r, __commonJSMin as t };
28
+ export { __reExport as n, __exportAll as t };
package/index.d.ts CHANGED
@@ -8,13 +8,16 @@ import type { IcebreakerStylelintOptions } from '@icebreakers/stylelint-config'
8
8
  import type { Linter } from 'eslint'
9
9
  import type { FlatConfigComposer } from 'eslint-flat-config-utils'
10
10
 
11
- export interface TailwindcssOption {
11
+ export interface BetterTailwindcssOption {
12
12
  entryPoint?: string
13
+ files?: string[]
14
+ rules?: 'syntax' | 'recommended'
13
15
  cwd?: string
14
16
  tailwindConfig?: string
15
17
  }
16
18
 
17
- export type TailwindcssConfig = boolean | TailwindcssOption
19
+ export type BetterTailwindcssConfig = boolean | BetterTailwindcssOption
20
+ export type TailwindcssConfig = boolean
18
21
  export interface UnocssOption {
19
22
  configPath?: string
20
23
  attributify?: boolean
@@ -29,6 +32,7 @@ export type StylelintBridgeConfig = boolean | StylelintBridgeOption
29
32
  export type UserDefinedOptions = Omit<OptionsConfig, 'unocss'> & TypedFlatConfigItem & {
30
33
  miniProgram?: boolean
31
34
  tailwindcss?: TailwindcssConfig
35
+ betterTailwindcss?: BetterTailwindcssConfig
32
36
  unocss?: UnocssConfig
33
37
  stylelint?: StylelintBridgeConfig
34
38
  mdx?: boolean
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@icebreakers/eslint-config",
3
3
  "type": "module",
4
- "version": "6.0.0",
4
+ "version": "7.0.1",
5
5
  "description": "ESLint preset from Icebreaker's dev-configs",
6
6
  "author": "ice breaker <1324318532@qq.com>",
7
7
  "license": "MIT",
@@ -42,28 +42,32 @@
42
42
  "node": ">=22.12.0"
43
43
  },
44
44
  "peerDependencies": {
45
- "eslint-plugin-pnpm": "^1.6.0"
45
+ "eslint-plugin-pnpm": "^1.6.0",
46
+ "tailwindcss": "^3.3.0 || ^4.1.17"
46
47
  },
47
48
  "peerDependenciesMeta": {
48
49
  "eslint-plugin-pnpm": {
49
50
  "optional": true
51
+ },
52
+ "tailwindcss": {
53
+ "optional": true
50
54
  }
51
55
  },
52
56
  "dependencies": {
53
57
  "@antfu/eslint-config": "9.1.0",
54
- "@eslint-react/eslint-plugin": "^5.9.4",
55
- "@typescript-eslint/rule-tester": "^8.62.0",
56
- "@typescript-eslint/typescript-estree": "^8.62.0",
57
- "@typescript-eslint/utils": "^8.62.0",
58
+ "@eslint-react/eslint-plugin": "^5.11.2",
59
+ "@typescript-eslint/rule-tester": "^8.62.1",
60
+ "@typescript-eslint/typescript-estree": "^8.62.1",
61
+ "@typescript-eslint/utils": "^8.62.1",
58
62
  "@vue/compiler-sfc": "^3.5.39",
59
63
  "eslint-flat-config-utils": "3.2.0",
60
- "eslint-plugin-better-tailwindcss": "^4.6.0",
64
+ "eslint-plugin-better-tailwindcss": "^4.6.1",
61
65
  "eslint-plugin-format": "2.0.1",
62
66
  "eslint-plugin-react-hooks": "^7.1.1",
63
67
  "eslint-plugin-react-refresh": "^0.5.3",
64
- "eslint-plugin-tailwindcss": "4.0.4",
65
- "@icebreakers/stylelint-config": "5.0.0",
66
- "eslint-plugin-better-stylelint": "2.0.0"
68
+ "eslint-plugin-tailwindcss": "4.0.6",
69
+ "@icebreakers/stylelint-config": "5.0.2",
70
+ "eslint-plugin-better-stylelint": "2.0.1"
67
71
  },
68
72
  "publishConfig": {
69
73
  "access": "public",
@@ -85,6 +89,9 @@
85
89
  "skipLibCheck": true
86
90
  }
87
91
  },
92
+ "devDependencies": {
93
+ "semver": "^7.8.5"
94
+ },
88
95
  "scripts": {
89
96
  "dev": "tsdown --watch --sourcemap",
90
97
  "build": "tsdown",