Require JSX closing tag to be aligned with the opening tag (react/jsx-closing-tag-location)
See original GitHub issueThis rule checks all JSX multiline elements with children (non-self-closing) and verifies the location of the closing tag. The expectation is that the closing tag is aligned with the opening tag on its own line.
https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-closing-tag-location.md
The following patterns are considered warnings:
<Hello>
marklar
</Hello>
<Hello>
marklar</Hello>
The following are not considered warnings:
<Hello>
marklar
</Hello>
<Hello>marklar</Hello>
Issue Analytics
- State:
- Created 4 years ago
- Comments:8 (5 by maintainers)
Top Results From Across the Web
How to fix "react/jsx-closing-bracket-location" in WebStorm
Just created a new line with the /> aligned with the original tag. Share.
Read more >Expected corresponding JSX closing tag error in React
The React.js error "Expected corresponding JSX closing tag" occurs when we forget to close a tag in our JSX code. To solve the...
Read more >Allow reformat to place closing tag in new line in JSX - YouTrack
Trying to follow https://github.com/airbnb/javascript/tree/master/react#alignment with closing tag on it's own line if multi line.
Read more >Tags · Styleguide JavaScript
If a component has multi-line properties, close its tag on a new line. ESLint: react/jsx-closing-bracket-location. Examples. ⇣ Incorrect code for this rule: < ......
Read more >Rule request: JSX indentation and tag positioning #337
9:1 The closing bracket must be aligned with the opening tag (expected column 15) react/jsx-closing-bracket-location ✖ 10:1 Expected closing tag to match ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@joke2k The intended style is to add parens anytime you have a multiline JSX statement.
I’m not sure why the autofixer isn’t doing that for you. Looks like we need to play with the JSX rules some more to get what we want.
@feross I think that @MatanBobi means using non-self-closing tag with return:
With this rule, this style raises an error (not aligned to open tag) and if I try to
--fix
it:which raises
react/jsx-indent-problem
and is ugly.The only way to fix it is putting all in one line:
but is not really sustainable.