我们使用pretty-quick
实现了预提交挂钩。这意味着每次提交时都要美化我们的前端文件。
但是,会发生以下情况:
develop
这是我们package.json
的相关部分:
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": [">0.2%", "not dead", "not ie <= 11", "not op_mini all"],
"devDependencies": {
"husky": "^1.3.1",
"prettier": "1.17.0",
"pretty-quick": "^1.10.0",
"redux-devtools-extension": "^2.13.8"
},
"husky": {
"hooks": {
"pre-commit": "pretty-quick --staged --pattern \"**/*.*(js|jsx)\""
}
},
"prettier": {
"arrowParens": "avoid",
"bracketSpacing": true,
"jsxBracketSameLine": false,
"jsxSingleQuote": false,
"printWidth": 100,
"proseWrap": "preserve",
"requirePragma": false,
"tabWidth": 4,
"useTabs": false,
"singleQuote": true,
"trailingComma": "es5",
"semi": false
}