Rule proposal: indentation of closing bracket
See original GitHub issueSimilar to #14 and #15, it might be nice to have a rule that specifies the indentation of closing brackets for JSX.
For non-self-closing tags, I’ve seen three different patterns: on the same line as last prop (should maybe be handled by #14), on new line but same indentation as props, and on new line but same indentation as opening bracket.
Same line:
<MyComponent
myProp="...">
Children
</MyComponent>
New line, same indentation as props:
<MyComponent
myProp="..."
>
Children
</MyComponent>
New line, same indentation as opening bracket:
<MyComponent
myProp="..."
>
Children
</MyComponent>
For self-closing tags, I’ve seen the same patterns, but one might want to be able to specify differences. For example, one might want to have non-self-closing be at same indentation as props, but self closing to be at same indentation as opening bracket:
<MyComponent
myProp="..."
>
Children
</MyComponent>
<MyComponent
myProp="..."
/>
Issue Analytics
- State:
- Created 8 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Closing bracket does not match indentation of ... - Flake8 Rules
Closing brackets should match the same indentation level of the line that their opening bracket started on.
Read more >PEP 8: Hanging Indentation and Closing Brackets in Python
This article shows how to line up the closing braces, brackets, and parentheses correctly in Python. This is called “hanging indentation” and it's...
Read more >Optional Braces - Scala 3 - EPFL
Scala 3 enforces some rules on indentation and allows some occurrences of braces {. ... This rule is helpful for finding missing closing...
Read more >ESlint enforce closing brackets for functions etc on same ...
The indent rule covers what you're looking for, though it make be overkill if this one case is all you want to check....
Read more >Tags · Styleguide JavaScript
Closing Bracket Indentation. If a component has multi-line properties, close its tag on a new line. ESLint: react/jsx-closing-bracket-location ...
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 FreeTop 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
Top GitHub Comments
Since
v3.4.0
you can enforce different style for non-empty and self-closing tags.You should be able to enforce this style with the following configuration:
Ah! I see. Thanks. I think I misread the documentation. 😃