我试图制作简单的组件。但是,当我点击ctrl + s
时,它会执行此操作:
警告和错误是这样的:
[eslint]预期结束标记以匹配开头的缩进。 (react / jsx-closing-tag-location)[eslint]预期的缩进为4 空格字符,但找到2.(react / jsx-indent)
我的.eslintrc
:
{
"extends": "airbnb",
"parserOptions": {
"ecmaFeatures": {
"jsx": true,
"experimentalObjectRestSpread": true
}
},
"rules": {
"max-len": ["warn", 120],
"indent": ["warn", 2],
"react/jsx-indent": ["warn", 4],
"react/forbid-prop-types": 0,
"semi": [2, "never"],
"no-underscore-dangle": 0,
"no-console": 0,
"linebreak-style": 0,
"comma-dangle": [2, {
"arrays": "never",
"objects": "always",
"imports": "never",
"exports": "never",
"functions": "ignore"
}]
},
"globals": {
"localStorage": true
},
"env": {
"browser": true,
"node": true
}
}
出了什么问题?
答案 0 :(得分:0)
在你的gif中,永远不会以同样的缩进结束。应该这样做:
const App = () => (
<button>
<span>asd</span>
</button>
)
在你的gif中你有
const App = () => (
<button>
<span>asd</span>
</button>
)
或
const App = () => (
<button>
<span>asd</span>
</button>
)