前端代码风格自动化系列(五)之共同出击
我们在前面的四篇中介绍了husky
、commitlint
、lint-staged
、prettier
这些工具,可以完成以最小的代价在Git提交到远程仓库前,格式化为统一风格的代码,eslint大家都很熟悉这里就不列举了。下面举一个配置。
{ "devDependencies": { "babel-eslint": "^10.0.1", "eslint": "^5.4.0", "eslint-config-airbnb": "^17.0.0", "eslint-config-prettier": "^3.0.1", "eslint-plugin-babel": "^5.1.0", "eslint-plugin-compat": "^2.6.2", "eslint-plugin-import": "^2.14.0", "eslint-plugin-jsx-a11y": "^6.1.2", "eslint-plugin-markdown": "^1.0.0-beta.6", "eslint-plugin-react": "^7.11.1", "husky": "^1.1.2", "lint-staged": "^8.0.4", "prettier": "1.14.3", "stylelint": "^9.4.0", "stylelint-config-prettier": "^4.0.0", "stylelint-config-standard": "^18.0.0", "tslint": "^5.10.0", "tslint-config-prettier": "^1.10.0", "tslint-react": "^3.6.0", }, "lint-staged": { "**/*.{js,jsx,less}": [ "prettier --write", "git add" ], "**/*.{js,jsx}": "npm run lint-staged:js", "**/*.less": "stylelint --syntax less" }, "husky": { "hooks": { "pre-commit": "npm run lint-staged", "commit-msg": "commitlint -e $HUSKY_GIT_PARAMS" } } }
这里对于项目里ts
、js
、jsx
、less
分别做了提交前格式化操作,对于提交规范做了校验。
相关推荐
FavoriteStudent 2018-08-20
zhglinux 2020-07-17
Dimples 2020-06-07
tianzyc 2020-01-24
James0 2019-12-15
qiupu 2019-11-08
meylovezn 2019-10-25
terabits的钵壳 2012-03-24
微麦PHP 2019-07-01
wenjiusui0 2019-07-01
shiningchen 2019-06-30
WKYCSDN 2019-06-30
pythonxuexi 2019-06-30
wenjiusui0 2019-06-29
hualala 2019-06-28
hualala 2019-06-27
sundehui0 2019-06-21
GATSBYER 2007-11-07