my-code-style 1.8.1 → 1.8.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/CHANGELOG.md +13 -2
- package/README.md +19 -17
- package/bin/init +12 -4
- package/package.json +31 -15
- package/src/versionrc/index.cjs +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
## 变更日志
|
|
2
2
|
|
|
3
|
+
## [1.8.3](https://github.com/myvn/codeStyle/compare/v1.8.2...v1.8.3) (2026-09-21)
|
|
4
|
+
|
|
5
|
+
### 🐛 Bug Fixes | Bug 修复
|
|
6
|
+
|
|
7
|
+
* 校准 peer 范围,修复 eslint 10 组合被 npm 拒装(BUG-027) ([33d211d](https://github.com/myvn/codeStyle/commit/33d211dcbdb24b2e67962c6c32d02628d13cec32))
|
|
8
|
+
|
|
9
|
+
## [1.8.2](https://github.com/myvn/codeStyle/compare/v1.8.1...v1.8.2) (2026-09-21)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
### 🐛 Bug Fixes | Bug 修复
|
|
13
|
+
|
|
14
|
+
* versionrc 静默压优先级警告 + CHANGELOG 结构修复 + 发布工具迁移 catv@12 ([d1b8abf](https://github.com/myvn/codeStyle/commit/d1b8abfcccb595c33d4b9490e87b0599fe37b6bc))
|
|
15
|
+
|
|
3
16
|
### [1.8.1](https://github.com/myvn/codeStyle/compare/v1.8.0...v1.8.1) (2026-09-20)
|
|
4
17
|
|
|
5
18
|
|
|
@@ -24,8 +37,6 @@
|
|
|
24
37
|
- **publish:** 增强 provenance 校验与日志自证,同步文档与发布流程 ([ba6db63](https://github.com/myvn/codeStyle/commit/ba6db63dce8144f53ad2be9c49278ff67b924518))
|
|
25
38
|
- **修复:** Merge branch 'arena/01a0b214-codestyle' ([7c024dc](https://github.com/myvn/codeStyle/commit/7c024dce1bc1ef9d7fc9ef03b74f936b87a4704a))
|
|
26
39
|
|
|
27
|
-
## [1.5.0](https://github.com/myvn/codeStyle/compare/v1.4.0...v1.5.0) (2026-09-18)
|
|
28
|
-
|
|
29
40
|
### [1.7.2](https://github.com/myvn/codeStyle/compare/v1.7.1...v1.7.2) (2026-09-20)
|
|
30
41
|
|
|
31
42
|
### 🐛 Bug Fixes | Bug 修复
|
package/README.md
CHANGED
|
@@ -189,7 +189,8 @@ module.exports = {
|
|
|
189
189
|
| `my-code-style/stylelint/less-override` | Less 专用覆写配置 |
|
|
190
190
|
| `my-code-style/commitlint` | Commitlint 基础配置 |
|
|
191
191
|
| `my-code-style/commitlint/scopes` | 动态 scope 工具函数 |
|
|
192
|
-
| `my-code-style/versionrc` |
|
|
192
|
+
| `my-code-style/versionrc` | commit-and-tag-version 配置 |
|
|
193
|
+
| `my-code-style/package.json` | 包元数据(工具读取版本用) |
|
|
193
194
|
|
|
194
195
|
## CLI 初始化参数
|
|
195
196
|
|
|
@@ -213,7 +214,7 @@ npx my-code-style-init [--dry-run] [--backup] [--version|-v] [--help|-h]
|
|
|
213
214
|
- **现代化 Git Hooks**:采用 Husky 9 原生极简 hook + lint-staged 互斥文件分组,串行运行、消除并发写入缓存冲突
|
|
214
215
|
- **Stylelint SCSS、Less 及混合工程双支持**:支持纯 SCSS、纯 Less 以及两者共存的混合工程,放行 `@` 变量、小程序 `rpx`/`page`、深度选择器 `::v-deep` 及现代 CSS 伪类,组件内嵌多预处理器样式全面检查
|
|
215
216
|
- **严格暂存区 Scope 猜测**:`guessCurrentScope()` 严格只依据 Git 暂存区推断 scope,支持多目录频次投票、重命名、物理删除、中文路径与空格路径
|
|
216
|
-
- **ESM 兼容的自动版本发布**:支持 CommonJS(`.versionrc.js`)与 ESM(`.versionrc.cjs`)工程无缝对接 standard-version
|
|
217
|
+
- **ESM 兼容的自动版本发布**:支持 CommonJS(`.versionrc.js`)与 ESM(`.versionrc.cjs`)工程无缝对接 commit-and-tag-version(standard-version 的社区维护分支),一键版本递增与 CHANGELOG 生成
|
|
217
218
|
|
|
218
219
|
## 常见问题(使用中遇到的问题)
|
|
219
220
|
|
|
@@ -239,10 +240,10 @@ npx my-code-style-init [--dry-run] [--backup] [--version|-v] [--help|-h]
|
|
|
239
240
|
## 测试套件
|
|
240
241
|
|
|
241
242
|
```bash
|
|
242
|
-
npm run test:all # 全量运行
|
|
243
|
+
npm run test:all # 全量运行 180 项:用例明细 + 分类统计 + 最慢文件定位
|
|
243
244
|
npm run diagnose # 换机器后先跑它:进程 / git / 文件系统 / hooks 各占多少
|
|
244
245
|
npm run sweep # 给本机找最佳文件级并发(扫 integration 套件)
|
|
245
|
-
npm test # 只跑基础 CLI 与配置矩阵(
|
|
246
|
+
npm test # 只跑基础 CLI 与配置矩阵(86 项)
|
|
246
247
|
npm run test:integration:setup # 安装现代化隔离依赖运行环境
|
|
247
248
|
npm run test:integration # Flat Config、真实 Husky 及提交链路测试(59 项)
|
|
248
249
|
npm run test:legacy:setup # 安装 ESLint 8 隔离运行环境
|
|
@@ -257,17 +258,18 @@ npm run test:stylelint17 # Stylelint 17 生态兼容性回归(8 项)
|
|
|
257
258
|
```text
|
|
258
259
|
my-code-style 测试套件
|
|
259
260
|
|
|
260
|
-
▶ [1/4] 基础 CLI 与配置矩阵 (共
|
|
261
|
+
▶ [1/4] 基础 CLI 与配置矩阵 (共 86 项,5 文件 · 3 文件并发(自动:2 核 / 内存 4G))
|
|
261
262
|
✓ 运行器 TAP 解析:统计通过与失败、SKIP 与每用例耗时 · 7ms
|
|
262
263
|
✓ cz 交互提示为中文,且可选类型与 type-enum 一一对应 · 1ms
|
|
263
|
-
✓
|
|
264
|
+
✓ peer 范围覆盖我们声明支持的上游大版本(校准防回退,BUG-027) · 0ms
|
|
265
|
+
✓ 一键安装命令对含 || 的版本范围加引号,可整段粘贴执行 · 40ms
|
|
264
266
|
✓ 初始化结尾指引把 cz 用法说清楚(先 git add + 指到 README 手册) · 80ms
|
|
265
267
|
…
|
|
266
|
-
✓ 通过
|
|
268
|
+
✓ 通过 86 · 3.6s · 最慢文件 init-matrix.test.cjs 3.2s
|
|
267
269
|
|
|
268
270
|
▶ [2/4] 现代工具链与提交链 (共 59 项,23 文件 · 3 文件并发(自动:2 核 / 内存 4G))
|
|
269
271
|
✓ 完整提交链:JS/TS/Vue/nvue/CSS/less 自动修复及二次复检 · 10.4s
|
|
270
|
-
✓ 发布防呆:HEAD 已有 v* tag 时拦截(此时
|
|
272
|
+
✓ 发布防呆:HEAD 已有 v* tag 时拦截(此时 release 工具会静默抬版并写出空 CHANGELOG) · 609ms
|
|
271
273
|
…
|
|
272
274
|
✓ 通过 59 · 41.0s · 最慢文件 commit-chain-both.test.cjs 10.6s
|
|
273
275
|
|
|
@@ -286,17 +288,17 @@ npm run test:stylelint17 # Stylelint 17 生态兼容性回归(8 项)
|
|
|
286
288
|
──────────────────────────────────────────────────────
|
|
287
289
|
套件 通过 失败 跳过 用时
|
|
288
290
|
──────────────────────────────────────────────────────
|
|
289
|
-
基础 CLI 与配置矩阵
|
|
290
|
-
现代工具链与提交链 59 0 -
|
|
291
|
-
ESLint 8 兼容性 27 0 - 18.
|
|
292
|
-
Stylelint 17 兼容性 8 0 - 7.
|
|
291
|
+
基础 CLI 与配置矩阵 86 0 - 3.6s
|
|
292
|
+
现代工具链与提交链 59 0 - 40.7s
|
|
293
|
+
ESLint 8 兼容性 27 0 - 18.7s
|
|
294
|
+
Stylelint 17 兼容性 8 0 - 7.3s
|
|
293
295
|
──────────────────────────────────────────────────────
|
|
294
|
-
合计
|
|
296
|
+
合计 180 0 - 70.3s
|
|
295
297
|
──────────────────────────────────────────────────────
|
|
296
298
|
|
|
297
299
|
⏱ 最慢文件:eslint8.test.cjs 18.3s · commit-chain-both.test.cjs 10.6s · commit-chain-scss.test.cjs 10.6s
|
|
298
300
|
|
|
299
|
-
✅ 全部通过:
|
|
301
|
+
✅ 全部通过:180/180 项,用时 70.3s
|
|
300
302
|
```
|
|
301
303
|
|
|
302
304
|
终端里每个套件下方还有一条实时进度条(`██████░░░░ 38/66 失败 0 4.0s`)。附加参数:
|
|
@@ -353,7 +355,7 @@ npm run test:all -- --profile # 看每个测试文件耗时,定位瓶颈
|
|
|
353
355
|
| `partial-staging{,-unstaged,-invalid-message,-conflict}` | 0.5–1.7s | 部分暂存与冲突恢复 |
|
|
354
356
|
| `error-recovery-{css,scss,less,js,ts,vue,nvue}` | 0.5–1.4s | 不可修复错误的回滚 |
|
|
355
357
|
| `lint` | 3.9s | 32 条规则与格式化行为(无提交链) |
|
|
356
|
-
| `release` | 0.8s |
|
|
358
|
+
| `release` | 0.8s | commit-and-tag-version |
|
|
357
359
|
|
|
358
360
|
两层并发都要控制规模,所以默认并发不交给 Node 猜,而是运行器自己算——**核数 × 1.5
|
|
359
361
|
(至少 核数 - 1),再乘内存上限,最后封顶 8**(16 核机器实测:4/6/8/12/16/24 并发对应
|
|
@@ -374,7 +376,7 @@ npm run test:all -- --profile # 看每个测试文件耗时,定位瓶颈
|
|
|
374
376
|
| `npm run test:integration`(运行器调度,自动并发 3) | 30.6s(只看集成套件那一段) |
|
|
375
377
|
| 串行套件 + 文件级并发 23(全部一波) | ✗ 3.8G 内存沙箱被 OOM 压垮(19 项 SIGKILL) |
|
|
376
378
|
|
|
377
|
-
同机复测(
|
|
379
|
+
同机复测(180 项,同一台 2 核沙箱连续跑;绝对秒数随机器负载波动,相对关系稳定):串行套件 + 文件级并发 1 = 72.7s、默认自动并发 3 = 70.3s、`--parallel` 四套件 = 71.1s、`npm run test:integration` = 43.1s、`node --test demo-test/integration/*.test.cjs` = 71.6s。
|
|
378
380
|
|
|
379
381
|
(2 核沙箱里并行收益被 CPU 争抢吃掉大半,`--concurrency=1` 时单个文件只要 0.7–4.2s;
|
|
380
382
|
16 核机器上集成套件那段 ≈ 最慢子文件,即"一次真实提交"的量级。)
|
|
@@ -399,7 +401,7 @@ npm run release:push
|
|
|
399
401
|
|
|
400
402
|
也可以拆成两步:`npm run release` 只做到打 tag,之后用 `git push --follow-tags origin <分支>` 手动推送。
|
|
401
403
|
|
|
402
|
-
> ⚠️ **别把两条命令连起来跑**:`release` 已经把 tag 打在 HEAD 上了,紧接着跑 `release:push
|
|
404
|
+
> ⚠️ **别把两条命令连起来跑**:`release` 已经把 tag 打在 HEAD 上了,紧接着跑 `release:push`,发布工具 **不会报错**,而是把版本号再抬一级、写出一个没有条目的空 CHANGELOG 并打出第二个 tag —— 等于多发一个空版本(npm 上不可撤销)。
|
|
403
405
|
>
|
|
404
406
|
> 两条命令的第一步都是 `scripts/release-guard.cjs` 发布前防呆,命中下面两种情况会直接中止并打印该执行的命令:HEAD 上已经有 `v*` tag(说明这一版已生成,只差推送)、已跟踪文件还有未提交改动(会被卷进版本提交)。未跟踪文件不拦截。
|
|
405
407
|
|
package/bin/init
CHANGED
|
@@ -621,7 +621,7 @@ module.exports = {
|
|
|
621
621
|
}
|
|
622
622
|
|
|
623
623
|
function versionrcContent() {
|
|
624
|
-
return `//
|
|
624
|
+
return `// commit-and-tag-version config — powered by my-code-style
|
|
625
625
|
module.exports = require("my-code-style/versionrc")
|
|
626
626
|
`
|
|
627
627
|
}
|
|
@@ -876,6 +876,9 @@ function main() {
|
|
|
876
876
|
}
|
|
877
877
|
|
|
878
878
|
const staleVersionrc = isEsm && fileExists(".versionrc.js") && !fileExists(".versionrc.cjs")
|
|
879
|
+
// 发布工具读配置的顺序是 ['.versionrc', '.versionrc.cjs', '.versionrc.json', '.versionrc.js']:
|
|
880
|
+
// 无扩展名或 .json 的旧文件会压过本次生成的 .versionrc.cjs(实测 standard-version 9.5 / catv 均如此)
|
|
881
|
+
const staleVersionrcTop = [".versionrc", ".versionrc.json"].filter((f) => fileExists(f))
|
|
879
882
|
|
|
880
883
|
files.push({
|
|
881
884
|
path: versionrcPath,
|
|
@@ -949,7 +952,12 @@ function main() {
|
|
|
949
952
|
}
|
|
950
953
|
if (staleVersionrc) {
|
|
951
954
|
warn(
|
|
952
|
-
"检测到 ESM 项目 (type: module) 存在旧的 .versionrc.js
|
|
955
|
+
"检测到 ESM 项目 (type: module) 存在旧的 .versionrc.js,发布工具需要使用 .versionrc.cjs",
|
|
956
|
+
)
|
|
957
|
+
}
|
|
958
|
+
if (staleVersionrcTop.length > 0) {
|
|
959
|
+
warn(
|
|
960
|
+
`检测到 ${staleVersionrcTop.join("、")}:发布工具会优先读取它,本次生成的 .versionrc.cjs 不会生效;请把配置合并进来或删除旧文件`,
|
|
953
961
|
)
|
|
954
962
|
}
|
|
955
963
|
|
|
@@ -1098,7 +1106,7 @@ function main() {
|
|
|
1098
1106
|
"lint:fix": `${lintCommand} --fix`,
|
|
1099
1107
|
format: "prettier --write .",
|
|
1100
1108
|
prepare: "husky",
|
|
1101
|
-
release: "
|
|
1109
|
+
release: "commit-and-tag-version",
|
|
1102
1110
|
cz: "czg",
|
|
1103
1111
|
},
|
|
1104
1112
|
"lint-staged": getLintStagedConfig(cssPreprocessor),
|
|
@@ -1215,7 +1223,7 @@ function checkPeerDeps({
|
|
|
1215
1223
|
"husky",
|
|
1216
1224
|
"lint-staged",
|
|
1217
1225
|
"czg",
|
|
1218
|
-
"
|
|
1226
|
+
"commit-and-tag-version",
|
|
1219
1227
|
]
|
|
1220
1228
|
|
|
1221
1229
|
const flatDeps = useFlatConfig
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "my-code-style",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.3",
|
|
4
4
|
"description": "Lint/Format/Git 配置工程化 npm 包(ESLint + Prettier + Stylelint + Commitlint + Husky + standard-version)",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"main": "src/eslint/uniapp.cjs",
|
|
@@ -29,7 +29,8 @@
|
|
|
29
29
|
"./stylelint/less-override": "./src/stylelint/less-override.cjs",
|
|
30
30
|
"./commitlint": "./src/commitlint/base.cjs",
|
|
31
31
|
"./commitlint/scopes": "./src/commitlint/scopes.cjs",
|
|
32
|
-
"./versionrc": "./src/versionrc/index.cjs"
|
|
32
|
+
"./versionrc": "./src/versionrc/index.cjs",
|
|
33
|
+
"./package.json": "./package.json"
|
|
33
34
|
},
|
|
34
35
|
"files": [
|
|
35
36
|
"src",
|
|
@@ -57,8 +58,8 @@
|
|
|
57
58
|
"lint:fix": "eslint . --fix",
|
|
58
59
|
"format": "prettier --write .",
|
|
59
60
|
"prepare": "node -e \"if (!process.env.CI) { try { require('child_process').execSync('husky', { stdio: 'ignore' }) } catch {} }\"",
|
|
60
|
-
"release": "node scripts/release-guard.cjs &&
|
|
61
|
-
"release:push": "node scripts/release-guard.cjs &&
|
|
61
|
+
"release": "node scripts/release-guard.cjs && commit-and-tag-version",
|
|
62
|
+
"release:push": "node scripts/release-guard.cjs && commit-and-tag-version && git push --follow-tags origin HEAD",
|
|
62
63
|
"pub": "npm run release:push",
|
|
63
64
|
"cz": "czg",
|
|
64
65
|
"link": "pnpm link --global",
|
|
@@ -69,27 +70,27 @@
|
|
|
69
70
|
"node": ">=18"
|
|
70
71
|
},
|
|
71
72
|
"peerDependencies": {
|
|
72
|
-
"@commitlint/cli": "^19.0.0",
|
|
73
|
-
"@commitlint/config-conventional": "^19.0.0",
|
|
74
|
-
"@eslint/js": "^9.0.0",
|
|
73
|
+
"@commitlint/cli": "^19.0.0 || ^20.0.0 || ^21.0.0",
|
|
74
|
+
"@commitlint/config-conventional": "^19.0.0 || ^20.0.0 || ^21.0.0",
|
|
75
|
+
"@eslint/js": "^9.0.0 || ^10.0.0",
|
|
75
76
|
"@typescript-eslint/eslint-plugin": "^8.0.0",
|
|
76
77
|
"@typescript-eslint/parser": "^8.0.0",
|
|
78
|
+
"commit-and-tag-version": "^12.0.0",
|
|
77
79
|
"czg": "^1.0.0",
|
|
78
80
|
"eslint": "^8.57.0 || ^9.0.0 || ^10.0.0",
|
|
79
81
|
"eslint-config-prettier": "^10.1.8",
|
|
80
|
-
"eslint-import-resolver-typescript": "^3.0.0",
|
|
82
|
+
"eslint-import-resolver-typescript": "^3.0.0 || ^4.0.0",
|
|
81
83
|
"eslint-plugin-import": "^2.0.0",
|
|
82
84
|
"eslint-plugin-import-x": "^4.0.0",
|
|
83
85
|
"eslint-plugin-prettier": "^5.2.0",
|
|
84
86
|
"eslint-plugin-vue": "^10.0.0",
|
|
85
|
-
"globals": "^16.0.0",
|
|
87
|
+
"globals": "^16.0.0 || ^17.0.0",
|
|
86
88
|
"husky": "^9.0.0",
|
|
87
|
-
"lint-staged": "^16.0.0",
|
|
89
|
+
"lint-staged": "^16.0.0 || ^17.0.0",
|
|
88
90
|
"postcss-html": "^2.0.0",
|
|
89
91
|
"postcss-less": "^6.0.0",
|
|
90
92
|
"postcss-scss": "^4.0.0",
|
|
91
93
|
"prettier": "^3.0.0",
|
|
92
|
-
"standard-version": "^9.0.0",
|
|
93
94
|
"stylelint": "^16.24.0 || ^17.0.0",
|
|
94
95
|
"stylelint-config-html": "^2.0.0",
|
|
95
96
|
"stylelint-config-recess-order": "^5.0.0 || ^6.0.0 || ^7.0.0",
|
|
@@ -163,9 +164,6 @@
|
|
|
163
164
|
"prettier": {
|
|
164
165
|
"optional": true
|
|
165
166
|
},
|
|
166
|
-
"standard-version": {
|
|
167
|
-
"optional": true
|
|
168
|
-
},
|
|
169
167
|
"stylelint": {
|
|
170
168
|
"optional": true
|
|
171
169
|
},
|
|
@@ -198,10 +196,28 @@
|
|
|
198
196
|
},
|
|
199
197
|
"vue-eslint-parser": {
|
|
200
198
|
"optional": true
|
|
199
|
+
},
|
|
200
|
+
"commit-and-tag-version": {
|
|
201
|
+
"optional": true
|
|
201
202
|
}
|
|
202
203
|
},
|
|
203
204
|
"devDependencies": {
|
|
204
|
-
"
|
|
205
|
+
"@commitlint/cli": "^19.8.1",
|
|
206
|
+
"@commitlint/config-conventional": "^19.8.1",
|
|
207
|
+
"@eslint/js": "^9.39.5",
|
|
208
|
+
"commit-and-tag-version": "^12.7.3",
|
|
209
|
+
"czg": "^1.14.0",
|
|
210
|
+
"eslint": "^9.39.5",
|
|
211
|
+
"eslint-config-prettier": "^10.1.8",
|
|
212
|
+
"eslint-import-resolver-typescript": "^3.10.1",
|
|
213
|
+
"eslint-plugin-import-x": "^4.17.1",
|
|
214
|
+
"eslint-plugin-prettier": "^5.5.6",
|
|
215
|
+
"globals": "^16.5.0",
|
|
216
|
+
"husky": "^9.1.7",
|
|
217
|
+
"lint-staged": "^16.4.0",
|
|
218
|
+
"prettier": "^3.9.8",
|
|
219
|
+
"typescript": "^5.9.3",
|
|
220
|
+
"typescript-eslint": "^8.70.0"
|
|
205
221
|
},
|
|
206
222
|
"keywords": [
|
|
207
223
|
"eslint-config",
|
package/src/versionrc/index.cjs
CHANGED