用 UMI 创建项目后,开发模式下可以通过设置 FORK_TS_CHECKER 变量值来开启 TS 校验,我想在提交 commit 时像 ESlint 那样对所有文件做 TS 校验,通过后才允许提交,这个要怎么实现呢?
找到一个方案,在 pre-commit 里再添加一个运行 TS 编译检查的命令,但感觉不够优雅 🤨
~~~json
{
"scripts": {
"ts-compile-check": "tsc -p tsconfig.json"
},
"husky": {
"hooks": {
"pre-commit": "npm run ts-compile-check && npm run lint-staged"
}
}
}
~~~
👍
tsconfig.json 中加入
"noEmit": true,
就够优雅了吧
Most helpful comment
找到一个方案,在
pre-commit里再添加一个运行 TS 编译检查的命令,但感觉不够优雅 🤨~~~json
{
"scripts": {
"ts-compile-check": "tsc -p tsconfig.json"
},
"husky": {
"hooks": {
"pre-commit": "npm run ts-compile-check && npm run lint-staged"
}
}
}
~~~