在提高开发人员效率中,初期只处理了编译中,及集中路由的eslint的代码规范。
基于现有人员已经熟悉了react、vue工程化的开发,为了保证代码提交的统一性,现在对所有提交的code进行eslint修正,及拦截。
不符合规范的,将不再允许提交到git中。
在package.json中 增加
"lint-staged": "eslint -c ./app/web/.eslintrc.js ./app/web --fix --ignore-path .eslintignore",
"husky": {
"hooks": {
"pre-commit": "npm run lint-staged"
}
},
添加依赖
"eslint-config-umi": "^1.5.0",
"eslint-plugin-react-hooks": "^1.7.0",
在.eslintignore中 增加
node_modules
app/public
app/publish
src/main
app/web/config
app/web/scripts
app/web/functions
*.e2e.js
*.test.js
运行 npm run lint-staged 检测错误


成功

SourceTree 提交完成


网友评论