我设置了我.eslintrc
的规则"quote-props": [2, "always"]
。当我这样做时eslint --fix
,它会正常工作。
但我用 Prettier 格式化我的代码。不幸的是,Prettieralways
只有as-needed|preserve|consistent
. quote-props
所以结果总是当我用 Prettier 格式化时它会删除我的报价道具。
我怎样才能告诉 Prettier 尊重这条规则?添加// prettier-ignore
不是一种选择。
.eslintrc:
"extends": [
"eslint:recommended",
"plugin:react/recommended",
"plugin:react-hooks/recommended",
"prettier",
"prettier/react"
], // Prettier or Prettier Plugins (here for React) must always be at the end
"env": {
"cypress/globals": true,
"node": true,
"browser": true,
"es6": true
},
"plugins": ["react", "cypress", "prettier"],
"settings": {
"react": {
"createClass": "createClass",
// Regex for Component Factory to use, default to "createClass"
"pragma": "React",
// Pragma to use, default to "React"
"version": "16.13.1"
// React version, default to the latest React stable release
}
},
"parser": "babel-eslint",
"parserOptions": {
"ecmaFeatures": {
"jsx": true
},
"ecmaVersion": 8,
"sourceType": "module"
},
"rules": {
"quote-props": [2, "always"]
...
.prettierrc:
module.exports = {
trailingComma: "none",
tabWidth: 4,
bracketSpacing: true,
arrowParens: "avoid"
};