eslint-plugin-react: react/jsx-indent bug with component "extends" syntax
I’m getting a strange indent error only when using the extends component syntax. Stateless components don’t get this error:
Expected indentation of 10 space characters but found 8.
class CreateArticle extends Component {
state = {};
handleContextRef = contextRef => this.setState({ contextRef });
render() {
const { contextRef } = this.state;
return (
<div ref={this.handleContextRef}>
<Shelf title="Create new article" />
<Form <--- Offending line
size="large"
onSubmit={e => {
e.preventDefault();
}}
>
...
</Form>
</div>
)
}
}
eslint-plugin-react version: 7.5.1
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 17 (7 by maintainers)
I had the same issue, my problem was I was using babel-eslint ^8 (which uses the babylon parser - babel-7). Downgrading babel-eslint to 7.2.3 fixed this issue for me.
Try this repo https://github.com/eaardal/eslint-indent-demo I stripped away as much as I could, so the app doesn’t run, but you can use
npm run eslintto see the mentioned error, and using the eslint plugin in your editor (I use VS Code) should also show the errorI can’t seem to replicate it on a clean repo 😦 I’ll try again tomorrow!
I’ll try and get one in tomorrow!