问题
I'm trying to make simple component. But when I click on ctrl + s
it does this:
warning and error is this:
[eslint] Expected closing tag to match indentation of opening. (react/jsx-closing-tag-location) [eslint] Expected indentation of 4 space characters but found 2. (react/jsx-indent)
my .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
}
}
What's wrong?
回答1:
In your gif the never closes with the same indentation. That should do it:
const App = () => (
<button>
<span>asd</span>
</button>
)
In your gif you have either
const App = () => (
<button>
<span>asd</span>
</button>
)
or
const App = () => (
<button>
<span>asd</span>
</button>
)
来源:https://stackoverflow.com/questions/49632949/indentation-with-eslint-on-jsx