@icebreakers/eslint-config 2.1.1 → 2.1.2

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
@@ -10,7 +10,7 @@
10
10
 
11
11
  - Node.js 18 or newer
12
12
  - ESLint 9 with flat config support
13
- - React and Next related plugins are optional. If they are missing, `react`, `nextjs`, `query`, and React-side `a11y` helpers are skipped automatically instead of failing config resolution.
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`)
15
15
 
16
16
  ## Installation
@@ -64,7 +64,7 @@ export default icebreaker({
64
64
 
65
65
  - `miniProgram` – injects Mini Program globals, ignores common outputs/config files, and enables Vue-side Mini Program compatibility tweaks when `vue` is on.
66
66
  - `vue` – enables Vue + optionally version specific overrides (Vue 2/3) and ionic/miniProgram adjustments.
67
- - `react` – defers to the upstream React preset and unlocks accessibility helpers when `a11y` is enabled. If the React plugin set is not installed, this flag is ignored automatically.
67
+ - `react` – defers to the upstream React preset and unlocks accessibility helpers when `a11y` is enabled. The required React lint plugins are bundled with this package.
68
68
  - `query` – toggles the TanStack Query plugin (`@tanstack/eslint-plugin-query`) and its recommended lint rules. Missing plugin installs are treated as a no-op.
69
69
  - `tailwindcss` – pass `true` to use the built-in Tailwind flat config or provide `{ entryPoint, tailwindConfig }` for Tailwind v4/v3 projects.
70
70
  - `mdx` – activates MDX linting via `eslint-plugin-mdx`.
package/README.zh.md CHANGED
@@ -8,7 +8,7 @@
8
8
 
9
9
  - Node.js 18 或更高版本
10
10
  - 支持 Flat Config 的 ESLint 9
11
- - React / Next 相关插件现在是可选项。缺失时会自动跳过 `react`、`nextjs`、`query` 以及 React 侧的 `a11y` 配置,而不是在解析配置时直接报错。
11
+ - React 相关插件已随当前包一起分发。Next.js、Query 等生态预设仍保持可选,缺失时会自动跳过对应配置,而不是在解析时直接报错。
12
12
  - 如需启用 Tailwind、MDX、UnoCSS 等,可安装对应的可选依赖:`eslint-plugin-tailwindcss` / `eslint-plugin-better-tailwindcss`、`eslint-plugin-mdx`、`@unocss/eslint-plugin`
13
13
 
14
14
  ## 安装
@@ -62,7 +62,7 @@ export default icebreaker({
62
62
 
63
63
  - `miniProgram`:启用小程序预设,注入全局变量、忽略常见产物/配置文件,并在 `vue: true` 时补充小程序模板兼容调整。
64
64
  - `vue`:启用 Vue 规则,可根据 Vue 2/3 自动切换,并在 `ionic`、`miniProgram` 选项开启时追加对应覆盖。
65
- - `react`:复用上游 React 预设,配合 `a11y` 注入无障碍插件;如果 React 插件组未安装,会自动忽略该选项。
65
+ - `react`:复用上游 React 预设,配合 `a11y` 注入无障碍插件;所需的 React lint 插件已内置在当前包里。
66
66
  - `query`:按需启用 TanStack Query 插件(`@tanstack/eslint-plugin-query`)及其推荐规则;缺少插件时按 no-op 处理。
67
67
  - `tailwindcss`:传入 `true` 使用内置 Tailwind flat 配置,或通过对象指定 Tailwind v4 的入口文件 / v3 的配置文件路径。
68
68
  - `mdx`:激活 `eslint-plugin-mdx` 处理 `.mdx` 文件。
package/dist/index.cjs CHANGED
@@ -31,14 +31,14 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
31
31
  enumerable: true
32
32
  }) : target, mod));
33
33
  //#endregion
34
+ let node_fs = require("node:fs");
35
+ node_fs = __toESM(node_fs);
34
36
  let node_module = require("node:module");
35
37
  let node_path = require("node:path");
36
38
  node_path = __toESM(node_path);
37
39
  let node_process = require("node:process");
38
40
  node_process = __toESM(node_process);
39
41
  let node_url = require("node:url");
40
- let node_fs = require("node:fs");
41
- node_fs = __toESM(node_fs);
42
42
  //#region src/antfu.ts
43
43
  var antfu_exports = /* @__PURE__ */ __exportAll({});
44
44
  __reExport(antfu_exports, require("@antfu/eslint-config"));
@@ -163,7 +163,17 @@ function isPackageAvailable$1(name, searchPaths = [node_process.default.cwd(), P
163
163
  require$2.resolve(name, { paths: searchPaths });
164
164
  return true;
165
165
  } catch {
166
- return false;
166
+ const packageSegments = name.split("/");
167
+ return searchPaths.some((searchPath) => {
168
+ let currentDir = node_path.default.resolve(searchPath);
169
+ while (true) {
170
+ const packageJsonPath = node_path.default.join(currentDir, "node_modules", ...packageSegments, "package.json");
171
+ if (node_fs.default.existsSync(packageJsonPath)) return true;
172
+ const parentDir = node_path.default.dirname(currentDir);
173
+ if (parentDir === currentDir) return false;
174
+ currentDir = parentDir;
175
+ }
176
+ });
167
177
  }
168
178
  }
169
179
  function hasAllPackages(names, searchPaths) {
package/dist/index.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import { createRequire } from "node:module";
2
+ import fs from "node:fs";
2
3
  import path from "node:path";
3
4
  import process from "node:process";
4
5
  import { fileURLToPath } from "node:url";
5
- import fs from "node:fs";
6
6
  //#region \0rolldown/runtime.js
7
7
  var __defProp = Object.defineProperty;
8
8
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -154,7 +154,17 @@ function isPackageAvailable$1(name, searchPaths = [process.cwd(), PACKAGE_DIR])
154
154
  require$1.resolve(name, { paths: searchPaths });
155
155
  return true;
156
156
  } catch {
157
- return false;
157
+ const packageSegments = name.split("/");
158
+ return searchPaths.some((searchPath) => {
159
+ let currentDir = path.resolve(searchPath);
160
+ while (true) {
161
+ const packageJsonPath = path.join(currentDir, "node_modules", ...packageSegments, "package.json");
162
+ if (fs.existsSync(packageJsonPath)) return true;
163
+ const parentDir = path.dirname(currentDir);
164
+ if (parentDir === currentDir) return false;
165
+ currentDir = parentDir;
166
+ }
167
+ });
158
168
  }
159
169
  }
160
170
  function hasAllPackages(names, searchPaths) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@icebreakers/eslint-config",
3
3
  "type": "module",
4
- "version": "2.1.1",
4
+ "version": "2.1.2",
5
5
  "description": "ESLint preset from Icebreaker's dev-configs",
6
6
  "author": "ice breaker <1324318532@qq.com>",
7
7
  "license": "MIT",
@@ -48,22 +48,22 @@
48
48
  },
49
49
  "dependencies": {
50
50
  "@antfu/eslint-config": "7.7.3",
51
+ "@eslint-react/eslint-plugin": "^2.13.0",
51
52
  "eslint-plugin-better-tailwindcss": "^4.3.2",
52
53
  "eslint-plugin-format": "2.0.1",
54
+ "eslint-plugin-jsx-a11y": "^6.10.2",
55
+ "eslint-plugin-react-hooks": "^7.0.1",
56
+ "eslint-plugin-react-refresh": "^0.5.2",
53
57
  "eslint-plugin-tailwindcss": "3.18.2",
54
58
  "eslint-plugin-vuejs-accessibility": "^2.5.0",
55
59
  "@icebreakers/stylelint-config": "2.2.1",
56
- "eslint-plugin-better-stylelint": "0.1.1"
60
+ "eslint-plugin-better-stylelint": "0.1.2"
57
61
  },
58
62
  "optionalDependencies": {
59
- "@eslint-react/eslint-plugin": "^3.0.0",
60
63
  "@next/eslint-plugin-next": "^16.2.1",
61
64
  "@tanstack/eslint-plugin-query": "^5.95.2",
62
65
  "@unocss/eslint-plugin": "66.6.7",
63
- "eslint-plugin-jsx-a11y": "^6.10.2",
64
- "eslint-plugin-mdx": "3.7.0",
65
- "eslint-plugin-react-hooks": "^7.0.1",
66
- "eslint-plugin-react-refresh": "^0.5.2"
66
+ "eslint-plugin-mdx": "3.7.0"
67
67
  },
68
68
  "publishConfig": {
69
69
  "access": "public",