-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Add auto fix for self-closing-comp #770
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
Merged
yannickcr
merged 5 commits into
jsx-eslint:master
from
pl12133:feature/autofix-self-closing-comp
Aug 20, 2016
Merged
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
0cf9fc9
Add auto-fixer for rule `self-closing-comp`. Update documentation and…
pl12133 f6cc36a
Add whitespace before self-closing tag
pl12133 301e08c
Revert "Add whitespace before self-closing tag"
pl12133 8caa590
Update docs for `jsx-space-before-closing` to show it is fixable
pl12133 376fac1
Revert "Revert "Add whitespace before self-closing tag""
pl12133 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 should all autofix with a space before 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.
I'm not sure I understand, as that change makes the tests fail. It seems that if there is no space before the
>
then after fixing there should continue to be no space before the>
.Would you prefer that the replacing value located in lib/rules/self-closing-comp.js - Line 88 be changed from
"/>"
to" />"
?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.
Yes, that's exactly what i'm suggesting.
<div />
is correct, not<div/>
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.
Thank you for clarifying, I didn't realize the white space was part of the rule. I have added that behavior now. Do you specifically want to enforce a single white space character, or would multiple be valid? For example, would the following be invalid:
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.
I think multiple would be ok, but we'd want to encourage single.
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.
I believe that is the only ordering possible, because the
jsx-space-before-closing
rule does not produce a warning unless there is a self-closing tag. This obviously cannot happen ifself-closing-comp
is in violation, because that rule implies there is no self-closing tag. Therefore I think it is impossible forjsx-space-before-closing
to produce an error on the same node asself-closing-comp
, and the warning conditions for the two rules are mutually exclusive.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.
Yes but someone may not have enabled
jsx-space-before-closing
- I want the burden of running that extra autofixer to be on someone who has chosen "never" - which is a very unconventional choice - not on the vast majority of JSX authors who always put a space there.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.
I see, in that case I can re-commit the white space character before a self-closing tag. Should there be any other behavior for white space than what is in f6cc36a?
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.
nope, that looks fine to me!
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.
Sounds good, let me know if you want commits squashed before merging.