@icebreakers/eslint-config 1.5.2 → 1.5.3
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 +73 -16
- package/README.zh.md +100 -0
- package/package.json +8 -7
package/README.md
CHANGED
|
@@ -1,45 +1,102 @@
|
|
|
1
1
|
# @icebreakers/eslint-config
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
- [简体中文指南](./README.zh.md)
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
`@icebreakers/eslint-config` extends the `@antfu/eslint-config` flat presets and layers extra rules for Tailwind CSS, MDX, Vue accessibility, and Icebreaker specific TypeScript defaults. It returns a `FlatConfigComposer`, so you can opt into only the presets you need and keep adding workspace specific overrides.
|
|
8
|
+
|
|
9
|
+
## Requirements
|
|
10
|
+
|
|
11
|
+
- Node.js 18 or newer
|
|
12
|
+
- ESLint 9 with flat config support
|
|
13
|
+
- 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`)
|
|
14
|
+
|
|
15
|
+
## Installation
|
|
6
16
|
|
|
7
17
|
```bash
|
|
8
|
-
pnpm
|
|
18
|
+
pnpm add -D eslint @icebreakers/eslint-config
|
|
9
19
|
```
|
|
10
20
|
|
|
21
|
+
## Quick Start
|
|
22
|
+
|
|
23
|
+
Create `eslint.config.ts` (or `.mjs`) in your project root:
|
|
24
|
+
|
|
11
25
|
```ts
|
|
12
|
-
// eslint.config.mjs
|
|
13
26
|
import { icebreaker } from '@icebreakers/eslint-config'
|
|
14
27
|
|
|
15
28
|
export default icebreaker()
|
|
16
29
|
```
|
|
17
30
|
|
|
18
|
-
|
|
31
|
+
Run ESLint via your package manager:
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
pnpm eslint "src/**/*.ts"
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
If you need the legacy array config, call `icebreakerLegacy()` instead.
|
|
38
|
+
|
|
39
|
+
## Enabling Presets
|
|
19
40
|
|
|
20
|
-
|
|
41
|
+
Each optional preset mirrors the flags in `@antfu/eslint-config` and adds Icebreaker tweaks:
|
|
21
42
|
|
|
22
43
|
```ts
|
|
23
44
|
import { icebreaker } from '@icebreakers/eslint-config'
|
|
24
45
|
|
|
25
46
|
export default icebreaker({
|
|
26
|
-
vue: true,
|
|
47
|
+
vue: true, // or { vueVersion: 2 }
|
|
48
|
+
react: true,
|
|
27
49
|
typescript: true,
|
|
50
|
+
test: true,
|
|
28
51
|
tailwindcss: {
|
|
29
52
|
tailwindConfig: './tailwind.config.ts',
|
|
30
53
|
},
|
|
31
|
-
mdx: process.env.
|
|
32
|
-
a11y: true,
|
|
54
|
+
mdx: process.env.LINT_MDX === 'true',
|
|
55
|
+
a11y: true,
|
|
56
|
+
nestjs: true,
|
|
57
|
+
ionic: true,
|
|
58
|
+
weapp: true,
|
|
59
|
+
formatters: true,
|
|
33
60
|
})
|
|
34
61
|
```
|
|
35
62
|
|
|
36
|
-
- `
|
|
37
|
-
- `
|
|
38
|
-
- `
|
|
39
|
-
- `
|
|
63
|
+
- `vue` – enables Vue + optionally version specific overrides (Vue 2/3) and ionic/weapp adjustments.
|
|
64
|
+
- `react` – defers to the upstream React preset and unlocks accessibility helpers when `a11y` is enabled.
|
|
65
|
+
- `tailwindcss` – pass `true` to use the built-in Tailwind flat config or provide `{ entryPoint, tailwindConfig }` for Tailwind v4/v3 projects.
|
|
66
|
+
- `mdx` – activates MDX linting via `eslint-plugin-mdx`.
|
|
67
|
+
- `a11y` – wires in JSX (React) and Vue accessibility plugins.
|
|
68
|
+
- `typescript` – extends the TypeScript preset and applies stricter unused diagnostics plus NestJS conveniences when `nestjs` is true.
|
|
69
|
+
- `formatters` – keeps the built-in formatting rules enabled by default.
|
|
70
|
+
- `test` – relaxes certain Vitest/Jest style rules (`test/prefer-lowercase-title`).
|
|
71
|
+
|
|
72
|
+
## Adding Extra Config Items
|
|
73
|
+
|
|
74
|
+
Because `icebreaker()` returns a composer you can append overrides:
|
|
75
|
+
|
|
76
|
+
```ts
|
|
77
|
+
import { icebreaker } from '@icebreakers/eslint-config'
|
|
78
|
+
|
|
79
|
+
export default icebreaker(
|
|
80
|
+
{ typescript: true },
|
|
81
|
+
{
|
|
82
|
+
files: ['*.vue'],
|
|
83
|
+
rules: {
|
|
84
|
+
'vue/no-undef-components': 'off',
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
)
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
You may also pass other flat configs (e.g. from in-house presets) as additional arguments.
|
|
91
|
+
|
|
92
|
+
## IDE Integration
|
|
40
93
|
|
|
41
|
-
|
|
94
|
+
- Install the VS Code ESLint extension (`>=3.0.10`).
|
|
95
|
+
- Set `"eslint.experimental.useFlatConfig": true` for older VS Code builds.
|
|
96
|
+
- Use `pnpm lint -- --fix` in a pre-commit hook for consistent formatting.
|
|
42
97
|
|
|
43
|
-
|
|
98
|
+
## Troubleshooting
|
|
44
99
|
|
|
45
|
-
|
|
100
|
+
- Missing plugin errors usually mean the optional dependency is not installed in the current workspace. Add it with `pnpm add -D`.
|
|
101
|
+
- When combining legacy `.eslintrc` projects, prefer `icebreakerLegacy()` and move overrides into flat config format incrementally.
|
|
102
|
+
- Tailwind class validation reads from your `tailwind.config.*`; double check the path when using monorepo roots or custom build tooling.
|
package/README.zh.md
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
# @icebreakers/eslint-config
|
|
2
|
+
|
|
3
|
+
## 简介
|
|
4
|
+
|
|
5
|
+
`@icebreakers/eslint-config` 基于 `@antfu/eslint-config` 的 flat config 预设,额外补充了 Tailwind CSS、MDX、Vue 无障碍以及 Icebreaker 团队常用的 TypeScript 默认规则。它返回一个 `FlatConfigComposer`,可以按需启用不同预设,并继续追加工作区特定的覆盖项。
|
|
6
|
+
|
|
7
|
+
## 环境要求
|
|
8
|
+
|
|
9
|
+
- Node.js 18 或更高版本
|
|
10
|
+
- 支持 Flat Config 的 ESLint 9
|
|
11
|
+
- 如需启用 Tailwind、MDX、UnoCSS 等,可安装对应的可选依赖:`eslint-plugin-tailwindcss` / `eslint-plugin-better-tailwindcss`、`eslint-plugin-mdx`、`@unocss/eslint-plugin`
|
|
12
|
+
|
|
13
|
+
## 安装
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
pnpm add -D eslint @icebreakers/eslint-config
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## 快速上手
|
|
20
|
+
|
|
21
|
+
在项目根目录创建 `eslint.config.ts`(或 `.mjs`):
|
|
22
|
+
|
|
23
|
+
```ts
|
|
24
|
+
import { icebreaker } from '@icebreakers/eslint-config'
|
|
25
|
+
|
|
26
|
+
export default icebreaker()
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
使用包管理器运行 ESLint:
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
pnpm eslint "src/**/*.ts"
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
如果仍需兼容旧的 `.eslintrc` 流程,可改用 `icebreakerLegacy()`。
|
|
36
|
+
|
|
37
|
+
## 启用可选预设
|
|
38
|
+
|
|
39
|
+
所有可选项与 `@antfu/eslint-config` 保持一致,并叠加 Icebreaker 的调整:
|
|
40
|
+
|
|
41
|
+
```ts
|
|
42
|
+
import { icebreaker } from '@icebreakers/eslint-config'
|
|
43
|
+
|
|
44
|
+
export default icebreaker({
|
|
45
|
+
vue: true, // 或 { vueVersion: 2 }
|
|
46
|
+
react: true,
|
|
47
|
+
typescript: true,
|
|
48
|
+
test: true,
|
|
49
|
+
tailwindcss: {
|
|
50
|
+
tailwindConfig: './tailwind.config.ts',
|
|
51
|
+
},
|
|
52
|
+
mdx: process.env.LINT_MDX === 'true',
|
|
53
|
+
a11y: true,
|
|
54
|
+
nestjs: true,
|
|
55
|
+
ionic: true,
|
|
56
|
+
weapp: true,
|
|
57
|
+
formatters: true,
|
|
58
|
+
})
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
- `vue`:启用 Vue 规则,可根据 Vue 2/3 自动切换,并在 `ionic`、`weapp` 选项开启时追加对应覆盖。
|
|
62
|
+
- `react`:复用上游 React 预设,配合 `a11y` 注入无障碍插件。
|
|
63
|
+
- `tailwindcss`:传入 `true` 使用内置 Tailwind flat 配置,或通过对象指定 Tailwind v4 的入口文件 / v3 的配置文件路径。
|
|
64
|
+
- `mdx`:激活 `eslint-plugin-mdx` 处理 `.mdx` 文件。
|
|
65
|
+
- `a11y`:按需引入 JSX 与 Vue 的无障碍规则。
|
|
66
|
+
- `typescript`:开启 TypeScript 预设,并在 `nestjs` 为 `true` 时放宽 NestJS 场景常见限制。
|
|
67
|
+
- `formatters`:默认启用格式化辅助规则。
|
|
68
|
+
- `test`:放宽 Vitest / Jest 常见规则,例如关闭 `test/prefer-lowercase-title`。
|
|
69
|
+
|
|
70
|
+
## 追加自定义配置
|
|
71
|
+
|
|
72
|
+
`icebreaker()` 返回的 composer 支持继续拼接 Flat Config:
|
|
73
|
+
|
|
74
|
+
```ts
|
|
75
|
+
import { icebreaker } from '@icebreakers/eslint-config'
|
|
76
|
+
|
|
77
|
+
export default icebreaker(
|
|
78
|
+
{ typescript: true },
|
|
79
|
+
{
|
|
80
|
+
files: ['*.vue'],
|
|
81
|
+
rules: {
|
|
82
|
+
'vue/no-undef-components': 'off',
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
)
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
亦可追加其它第三方或内部预设,统一合并。
|
|
89
|
+
|
|
90
|
+
## IDE 集成
|
|
91
|
+
|
|
92
|
+
- VS Code 安装 ESLint 扩展(版本需 ≥ 3.0.10)。
|
|
93
|
+
- 老版本 VS Code 需在设置中启用 `"eslint.experimental.useFlatConfig": true`。
|
|
94
|
+
- 在 Git 钩子或 CI 中执行 `pnpm lint -- --fix` 确保格式一致。
|
|
95
|
+
|
|
96
|
+
## 常见问题
|
|
97
|
+
|
|
98
|
+
- 如果提示缺少插件,说明当前工作区未安装对应可选依赖,可通过 `pnpm add -D` 补齐。
|
|
99
|
+
- 与旧版 `.eslintrc` 混用时建议先改用 `icebreakerLegacy()`,逐步迁移至 Flat Config。
|
|
100
|
+
- Tailwind 校验依赖 `tailwind.config.*`,Monorepo 或自定义构建路径时请确认配置文件位置。
|
package/package.json
CHANGED
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@icebreakers/eslint-config",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.5.
|
|
5
|
-
"description": "
|
|
4
|
+
"version": "1.5.3",
|
|
5
|
+
"description": "ESLint preset from Icebreaker's dev-configs",
|
|
6
6
|
"author": "ice breaker <1324318532@qq.com>",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"repository": {
|
|
9
9
|
"type": "git",
|
|
10
|
-
"url": "git+https://github.com/sonofmagic/
|
|
11
|
-
"directory": "packages/
|
|
10
|
+
"url": "git+https://github.com/sonofmagic/dev-configs.git",
|
|
11
|
+
"directory": "packages/eslint"
|
|
12
12
|
},
|
|
13
13
|
"bugs": {
|
|
14
|
-
"url": "https://github.com/sonofmagic/
|
|
14
|
+
"url": "https://github.com/sonofmagic/dev-configs/issues"
|
|
15
15
|
},
|
|
16
16
|
"keywords": [
|
|
17
|
+
"dev-configs",
|
|
17
18
|
"eslint-config",
|
|
18
19
|
"icebreaker"
|
|
19
20
|
],
|
|
@@ -42,12 +43,12 @@
|
|
|
42
43
|
"dependencies": {
|
|
43
44
|
"@antfu/eslint-config": "6.0.0",
|
|
44
45
|
"@eslint-react/eslint-plugin": "^2.2.2",
|
|
45
|
-
"@next/eslint-plugin-next": "^15.5.
|
|
46
|
+
"@next/eslint-plugin-next": "^15.5.6",
|
|
46
47
|
"eslint-plugin-better-tailwindcss": "^3.7.10",
|
|
47
48
|
"eslint-plugin-format": "1.0.2",
|
|
48
49
|
"eslint-plugin-jsx-a11y": "^6.10.2",
|
|
49
50
|
"eslint-plugin-react-hooks": "^7.0.0",
|
|
50
|
-
"eslint-plugin-react-refresh": "^0.4.
|
|
51
|
+
"eslint-plugin-react-refresh": "^0.4.24",
|
|
51
52
|
"eslint-plugin-tailwindcss": "3.18.2",
|
|
52
53
|
"eslint-plugin-vuejs-accessibility": "^2.4.1"
|
|
53
54
|
},
|