-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add indentation rule for closing tag of multi-line jsx #1215
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It'd be great if we could ship this rule such that it's autofixable :-)
const rule = require('../../../lib/rules/jsx-closing-tag-location'); | ||
const {RuleTester} = require('eslint'); | ||
const parserOptions = { | ||
ecmaVersion: 8, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These tests don't need an ecmaVersion specified, nor rest/spread enabled
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops! Will fix.
* Remove rest/spread on import * Add fixer
@ljharb I think I've addressed your concerns. The one situation this doesn't fix is the following:
It will fix it to:
When ideally it would be fixed to:
I opted not to handle it in this rule because I imagine multiline children location should be handled in a separate rule entirely (maybe it already is?) |
I agree with you that it should be handled in a separate rule. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! Could we also add some tests for the autofixing?
Pardon my ignorance (this is the first eslint rule I've written), but isn't that what the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
whoops, you're right :-)
Thanks!
@rsolomon Would this rule also cover the situation below? // Considered a warning
<App>
{ condition && <Component>
...
</Component> }
</App>
// Not considered a warning
<App>
{ condition && (
<Component>
...
</Component>
) }
</App> |
For issue #1206:
This rule validates that the closing tag for a multi-line jsx component matches the indentation of the opening tag.