在提高開發(fā)人員效率中,初期只處理了編譯中,及集中路由的eslint的代碼規(guī)范。
基于現(xiàn)有人員已經(jīng)熟悉了react、vue工程化的開發(fā),為了保證代碼提交的統(tǒng)一性,現(xiàn)在對所有提交的code進(jìn)行eslint修正,及攔截。
不符合規(guī)范的,將不再允許提交到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
運(yùn)行 npm run lint-staged 檢測錯(cuò)誤

image.png

image.png
成功

image.png
SourceTree 提交完成

image.png

image.png