【发布时间】:2021-07-13 03:57:56
【问题描述】:
我注意到我文件中的所有 JavaScript 格式都正确(Prettier 在运算符之间正确插入空格),但对于 JSX 代码,空格没有正确插入。
这是我的.eslintrc.json 文件-
{
"env": {
"browser": true,
"es6": true
},
"extends": ["react-app", "prettier"],
"parserOptions": {
"ecmaVersion": 12
},
"plugins": ["react", "prettier"],
"rules": {
"prettier/prettier": [
"error",
{
"singleQuote": true,
"trailingComma": "es5",
"jsxBracketSameLine": true,
"useTabs": true,
"endOfLine": "auto",
"jsxSingleQuote": true
}
],
"arrow-body-style": "off",
"prefer-arrow-callback": "off",
"quotes": ["error", "single"],
"space-infix-ops": ["warn", { "int32Hint": false }],
"space-unary-ops": [
"warn",
{
"words": true,
"nonwords": false,
"overrides": {
"++": true
}
}
]
}
}
我可以为 Prettier 或 Eslint 添加任何属性,允许我在 JSX 中的运算符之间添加空格。或者扩展或任何其他方式来解决这样的格式不一致?
【问题讨论】:
标签: javascript reactjs jsx eslint prettier