@blueking/bkui-lint 0.1.0-beta.1 → 0.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 +226 -0
- package/package.json +4 -4
- /package/{biome.json → bk-biome.json} +0 -0
package/README.md
ADDED
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
# @blueking/bkui-lint
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@blueking/bkui-lint)
|
|
4
|
+
[](https://opensource.org/licenses/MIT)
|
|
5
|
+
[](https://www.typescriptlang.org/)
|
|
6
|
+
|
|
7
|
+
> 蓝鲸前端通用代码质量检查工具集,提供 ESLint、Prettier、Stylelint、Biome 等工具的标准化配置
|
|
8
|
+
|
|
9
|
+
## ✨ 特性
|
|
10
|
+
|
|
11
|
+
- 🚀 **开箱即用** - 预配置的 ESLint、Prettier、Stylelint、Biome 规则
|
|
12
|
+
- 🎯 **Vue 3 支持** - 针对 Vue 3 项目优化的代码检查规则
|
|
13
|
+
- 📦 **TypeScript 支持** - 完整的 TypeScript 类型检查配置
|
|
14
|
+
- 🎨 **代码格式化** - 统一的代码风格和格式化规则
|
|
15
|
+
- 🔧 **Git Hooks** - 集成 pre-commit 和 commit-msg 钩子
|
|
16
|
+
- 📝 **提交规范** - 标准化的 commit message 格式检查
|
|
17
|
+
- ⚡ **性能优化** - 基于 Biome 的高性能代码检查
|
|
18
|
+
|
|
19
|
+
## 📦 安装
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
# 使用 npm
|
|
23
|
+
npm install --save-dev @blueking/bkui-lint
|
|
24
|
+
|
|
25
|
+
# 使用 yarn
|
|
26
|
+
yarn add -D @blueking/bkui-lint
|
|
27
|
+
|
|
28
|
+
# 使用 pnpm
|
|
29
|
+
pnpm add -D @blueking/bkui-lint
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## 🚀 快速开始
|
|
33
|
+
|
|
34
|
+
### 1. 配置 ESLint
|
|
35
|
+
|
|
36
|
+
创建 `eslint.config.mjs` 文件:
|
|
37
|
+
|
|
38
|
+
```javascript
|
|
39
|
+
import bkuiLint from '@blueking/bkui-lint/eslint.mjs';
|
|
40
|
+
|
|
41
|
+
export default bkuiLint;
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### 2. 配置 Prettier
|
|
45
|
+
|
|
46
|
+
创建 `prettier.config.mjs` 文件:
|
|
47
|
+
|
|
48
|
+
```javascript
|
|
49
|
+
import prettierConfig from '@blueking/bkui-lint/prettier.mjs';
|
|
50
|
+
|
|
51
|
+
export default prettierConfig;
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### 3. 配置 Stylelint
|
|
55
|
+
|
|
56
|
+
创建 `stylelint.config.mjs` 文件:
|
|
57
|
+
|
|
58
|
+
```javascript
|
|
59
|
+
import stylelintConfig from '@blueking/bkui-lint/stylelint.mjs';
|
|
60
|
+
|
|
61
|
+
export default stylelintConfig;
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### 4. 配置 Biome
|
|
65
|
+
|
|
66
|
+
创建 `biome.json` 文件:
|
|
67
|
+
|
|
68
|
+
```json
|
|
69
|
+
{
|
|
70
|
+
"extends": ["@blueking/bkui-lint/bk-biome.json"],
|
|
71
|
+
"root": true
|
|
72
|
+
}
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### 5. 配置 Git Hooks
|
|
76
|
+
|
|
77
|
+
首次使用时执行:
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
npx simple-git-hooks
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
在 `package.json` 中添加:
|
|
84
|
+
|
|
85
|
+
```json
|
|
86
|
+
{
|
|
87
|
+
"simple-git-hooks": {
|
|
88
|
+
"pre-commit": "npx lint-staged --concurrent false",
|
|
89
|
+
"commit-msg": "node ./node_modules/@blueking/bkui-lint/verifiy-commit.mjs $1"
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### 6. 配置 lint-staged
|
|
95
|
+
|
|
96
|
+
创建 `.lintstagedrc.mjs` 文件:
|
|
97
|
+
|
|
98
|
+
```javascript
|
|
99
|
+
import lintStagedConfig from '@blueking/bkui-lint/.lintstagedrc.mjs';
|
|
100
|
+
|
|
101
|
+
export default lintStagedConfig;
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
## 📋 包含的工具
|
|
105
|
+
|
|
106
|
+
### ESLint 配置
|
|
107
|
+
|
|
108
|
+
- **基础规则**: 基于 `@eslint/js` 推荐配置
|
|
109
|
+
- **TypeScript 支持**: 使用 `typescript-eslint` 提供完整的 TS 支持
|
|
110
|
+
- **Vue 3 支持**: 集成 `eslint-plugin-vue` 的 Vue 3 推荐规则
|
|
111
|
+
- **代码风格**: 集成 `eslint-plugin-prettier` 和 `eslint-config-prettier`
|
|
112
|
+
- **代码质量**: 集成腾讯代码规范 `eslint-config-tencent`
|
|
113
|
+
- **代码排序**: 使用 `eslint-plugin-perfectionist` 自动排序导入、属性等
|
|
114
|
+
- **自定义规则**: 包含针对蓝鲸项目的自定义 ESLint 规则
|
|
115
|
+
|
|
116
|
+
### Prettier 配置
|
|
117
|
+
|
|
118
|
+
- **代码格式化**: 统一的代码风格配置
|
|
119
|
+
- **Vue 支持**: 针对 Vue 文件的特殊格式化规则
|
|
120
|
+
- **TypeScript 支持**: 完整的 TS/TSX 文件格式化
|
|
121
|
+
|
|
122
|
+
### Stylelint 配置
|
|
123
|
+
|
|
124
|
+
- **CSS/SCSS 支持**: 基于 `stylelint-config-standard-scss`
|
|
125
|
+
- **Vue 样式支持**: 支持 Vue 单文件组件中的样式检查
|
|
126
|
+
- **Less 支持**: 支持 Less 预处理器
|
|
127
|
+
- **代码排序**: 使用 `stylelint-config-recess-order` 进行属性排序
|
|
128
|
+
|
|
129
|
+
### Biome 配置
|
|
130
|
+
|
|
131
|
+
- **高性能检查**: 基于 Rust 的高性能代码检查
|
|
132
|
+
- **代码格式化**: 快速的代码格式化功能
|
|
133
|
+
- **TypeScript 支持**: 完整的 TS 类型检查
|
|
134
|
+
- **导入排序**: 自动整理和排序导入语句
|
|
135
|
+
|
|
136
|
+
## 🔧 高级配置
|
|
137
|
+
|
|
138
|
+
### 自定义 ESLint 规则
|
|
139
|
+
|
|
140
|
+
```javascript
|
|
141
|
+
import bkuiLint from '@blueking/bkui-lint/eslint.mjs';
|
|
142
|
+
|
|
143
|
+
export default [
|
|
144
|
+
...bkuiLint,
|
|
145
|
+
{
|
|
146
|
+
rules: {
|
|
147
|
+
// 你的自定义规则
|
|
148
|
+
'no-console': 'warn',
|
|
149
|
+
},
|
|
150
|
+
},
|
|
151
|
+
];
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
### 自定义 Prettier 配置
|
|
155
|
+
|
|
156
|
+
```javascript
|
|
157
|
+
import prettierConfig from '@blueking/bkui-lint/prettier.mjs';
|
|
158
|
+
|
|
159
|
+
export default {
|
|
160
|
+
...prettierConfig,
|
|
161
|
+
// 你的自定义配置
|
|
162
|
+
printWidth: 100,
|
|
163
|
+
};
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
### 自定义 Stylelint 配置
|
|
167
|
+
|
|
168
|
+
```javascript
|
|
169
|
+
import stylelintConfig from '@blueking/bkui-lint/stylelint.mjs';
|
|
170
|
+
|
|
171
|
+
export default {
|
|
172
|
+
...stylelintConfig,
|
|
173
|
+
rules: {
|
|
174
|
+
...stylelintConfig.rules,
|
|
175
|
+
// 你的自定义规则
|
|
176
|
+
'selector-max-id': 2,
|
|
177
|
+
},
|
|
178
|
+
};
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
## 📝 提交规范
|
|
182
|
+
|
|
183
|
+
本工具集包含标准的 commit message 格式检查,支持以下格式:
|
|
184
|
+
|
|
185
|
+
### 新格式(推荐)
|
|
186
|
+
|
|
187
|
+
```
|
|
188
|
+
feat: 添加新功能
|
|
189
|
+
fix: 修复 bug
|
|
190
|
+
docs: 文档更新
|
|
191
|
+
style: 代码格式调整
|
|
192
|
+
refactor: 代码重构
|
|
193
|
+
perf: 性能优化
|
|
194
|
+
test: 测试相关
|
|
195
|
+
chore: 构建过程或辅助工具的变动
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
### 旧格式(兼容)
|
|
199
|
+
|
|
200
|
+
```
|
|
201
|
+
feature: 新特性
|
|
202
|
+
bugfix: 线上功能bug
|
|
203
|
+
minor: 不重要的修改
|
|
204
|
+
optimization: 功能优化
|
|
205
|
+
sprintfix: 未上线代码修改
|
|
206
|
+
merge: 分支合并及冲突解决
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
## 🛠️ 脚本命令
|
|
210
|
+
|
|
211
|
+
在 `package.json` 中添加以下脚本:
|
|
212
|
+
|
|
213
|
+
```json
|
|
214
|
+
{
|
|
215
|
+
"scripts": {
|
|
216
|
+
"lint": "eslint . --ext .js,.ts,.vue",
|
|
217
|
+
"lint:fix": "eslint . --ext .js,.ts,.vue --fix",
|
|
218
|
+
"format": "prettier --write .",
|
|
219
|
+
"stylelint": "stylelint \"src/**/*.{css,scss,vue}\"",
|
|
220
|
+
"stylelint:fix": "stylelint \"src/**/*.{css,scss,vue}\" --fix",
|
|
221
|
+
"biome:check": "biome check .",
|
|
222
|
+
"biome:format": "biome format --write .",
|
|
223
|
+
"prepare": "simple-git-hooks"
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blueking/bkui-lint",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "蓝鲸监控平台公共lint工具",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Tencent BlueKing",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"eslint.mjs",
|
|
10
10
|
"stylelint.mjs",
|
|
11
11
|
"prettier.mjs",
|
|
12
|
-
"biome.json",
|
|
12
|
+
"bk-biome.json",
|
|
13
13
|
".lintstagedrc.mjs",
|
|
14
14
|
".simple-git-hooks.mjs",
|
|
15
15
|
"verifiy-commit.mjs"
|
|
@@ -38,8 +38,8 @@
|
|
|
38
38
|
"stylelint": "^16.22.0",
|
|
39
39
|
"stylelint-config-recess-order": "^7.1.0",
|
|
40
40
|
"stylelint-config-recommended-vue": "1.5.0",
|
|
41
|
-
"stylelint-config-standard": "
|
|
42
|
-
"stylelint-config-standard-scss": "
|
|
41
|
+
"stylelint-config-standard": "39.0.0",
|
|
42
|
+
"stylelint-config-standard-scss": "16.0.0",
|
|
43
43
|
"stylelint-order": "^7.0.0",
|
|
44
44
|
"stylelint-scss": "^6.12.1",
|
|
45
45
|
"typescript": "^5.8.3",
|
|
File without changes
|