@blueking/bkui-lint 0.1.0-beta.1 → 0.1.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.
Files changed (2) hide show
  1. package/README.md +225 -0
  2. package/package.json +3 -3
package/README.md ADDED
@@ -0,0 +1,225 @@
1
+ # @blueking/bkui-lint
2
+
3
+ [![npm version](https://img.shields.io/npm/v/@blueking/bkui-lint.svg)](https://www.npmjs.com/package/@blueking/bkui-lint)
4
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
5
+ [![TypeScript](https://img.shields.io/badge/TypeScript-5.8+-blue.svg)](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/biome.json"]
71
+ }
72
+ ```
73
+
74
+ ### 5. 配置 Git Hooks
75
+
76
+ 首次使用时执行:
77
+
78
+ ```bash
79
+ npx simple-git-hooks
80
+ ```
81
+
82
+ 在 `package.json` 中添加:
83
+
84
+ ```json
85
+ {
86
+ "simple-git-hooks": {
87
+ "pre-commit": "npx lint-staged --concurrent false",
88
+ "commit-msg": "node ./node_modules/@blueking/bkui-lint/verifiy-commit.mjs $1"
89
+ }
90
+ }
91
+ ```
92
+
93
+ ### 6. 配置 lint-staged
94
+
95
+ 创建 `.lintstagedrc.mjs` 文件:
96
+
97
+ ```javascript
98
+ import lintStagedConfig from '@blueking/bkui-lint/.lintstagedrc.mjs';
99
+
100
+ export default lintStagedConfig;
101
+ ```
102
+
103
+ ## 📋 包含的工具
104
+
105
+ ### ESLint 配置
106
+
107
+ - **基础规则**: 基于 `@eslint/js` 推荐配置
108
+ - **TypeScript 支持**: 使用 `typescript-eslint` 提供完整的 TS 支持
109
+ - **Vue 3 支持**: 集成 `eslint-plugin-vue` 的 Vue 3 推荐规则
110
+ - **代码风格**: 集成 `eslint-plugin-prettier` 和 `eslint-config-prettier`
111
+ - **代码质量**: 集成腾讯代码规范 `eslint-config-tencent`
112
+ - **代码排序**: 使用 `eslint-plugin-perfectionist` 自动排序导入、属性等
113
+ - **自定义规则**: 包含针对蓝鲸项目的自定义 ESLint 规则
114
+
115
+ ### Prettier 配置
116
+
117
+ - **代码格式化**: 统一的代码风格配置
118
+ - **Vue 支持**: 针对 Vue 文件的特殊格式化规则
119
+ - **TypeScript 支持**: 完整的 TS/TSX 文件格式化
120
+
121
+ ### Stylelint 配置
122
+
123
+ - **CSS/SCSS 支持**: 基于 `stylelint-config-standard-scss`
124
+ - **Vue 样式支持**: 支持 Vue 单文件组件中的样式检查
125
+ - **Less 支持**: 支持 Less 预处理器
126
+ - **代码排序**: 使用 `stylelint-config-recess-order` 进行属性排序
127
+
128
+ ### Biome 配置
129
+
130
+ - **高性能检查**: 基于 Rust 的高性能代码检查
131
+ - **代码格式化**: 快速的代码格式化功能
132
+ - **TypeScript 支持**: 完整的 TS 类型检查
133
+ - **导入排序**: 自动整理和排序导入语句
134
+
135
+ ## 🔧 高级配置
136
+
137
+ ### 自定义 ESLint 规则
138
+
139
+ ```javascript
140
+ import bkuiLint from '@blueking/bkui-lint/eslint.mjs';
141
+
142
+ export default [
143
+ ...bkuiLint,
144
+ {
145
+ rules: {
146
+ // 你的自定义规则
147
+ 'no-console': 'warn',
148
+ },
149
+ },
150
+ ];
151
+ ```
152
+
153
+ ### 自定义 Prettier 配置
154
+
155
+ ```javascript
156
+ import prettierConfig from '@blueking/bkui-lint/prettier.mjs';
157
+
158
+ export default {
159
+ ...prettierConfig,
160
+ // 你的自定义配置
161
+ printWidth: 100,
162
+ };
163
+ ```
164
+
165
+ ### 自定义 Stylelint 配置
166
+
167
+ ```javascript
168
+ import stylelintConfig from '@blueking/bkui-lint/stylelint.mjs';
169
+
170
+ export default {
171
+ ...stylelintConfig,
172
+ rules: {
173
+ ...stylelintConfig.rules,
174
+ // 你的自定义规则
175
+ 'selector-max-id': 2,
176
+ },
177
+ };
178
+ ```
179
+
180
+ ## 📝 提交规范
181
+
182
+ 本工具集包含标准的 commit message 格式检查,支持以下格式:
183
+
184
+ ### 新格式(推荐)
185
+
186
+ ```
187
+ feat: 添加新功能
188
+ fix: 修复 bug
189
+ docs: 文档更新
190
+ style: 代码格式调整
191
+ refactor: 代码重构
192
+ perf: 性能优化
193
+ test: 测试相关
194
+ chore: 构建过程或辅助工具的变动
195
+ ```
196
+
197
+ ### 旧格式(兼容)
198
+
199
+ ```
200
+ feature: 新特性
201
+ bugfix: 线上功能bug
202
+ minor: 不重要的修改
203
+ optimization: 功能优化
204
+ sprintfix: 未上线代码修改
205
+ merge: 分支合并及冲突解决
206
+ ```
207
+
208
+ ## 🛠️ 脚本命令
209
+
210
+ 在 `package.json` 中添加以下脚本:
211
+
212
+ ```json
213
+ {
214
+ "scripts": {
215
+ "lint": "eslint . --ext .js,.ts,.vue",
216
+ "lint:fix": "eslint . --ext .js,.ts,.vue --fix",
217
+ "format": "prettier --write .",
218
+ "stylelint": "stylelint \"src/**/*.{css,scss,vue}\"",
219
+ "stylelint:fix": "stylelint \"src/**/*.{css,scss,vue}\" --fix",
220
+ "biome:check": "biome check .",
221
+ "biome:format": "biome format --write .",
222
+ "prepare": "simple-git-hooks"
223
+ }
224
+ }
225
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blueking/bkui-lint",
3
- "version": "0.1.0-beta.1",
3
+ "version": "0.1.1",
4
4
  "description": "蓝鲸监控平台公共lint工具",
5
5
  "license": "MIT",
6
6
  "author": "Tencent BlueKing",
@@ -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": "^38.0.0",
42
- "stylelint-config-standard-scss": "^15.0.1",
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",