-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New rule: jsx-one-expression-per-line #1497
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
ljharb
merged 14 commits into
jsx-eslint:master
from
Vydia:new-rule-one-element-per-line
Oct 30, 2017
Merged
Changes from 1 commit
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
618bdb7
new rule: one-element-per-line
TSMMark 7f6784e
require jsx-one-element-per-line in index.js
TSMMark 256e5bc
fix sibling reporting
TSMMark 3893c3d
short-circuit childrenOnLine finder when a child is found
TSMMark 652683d
refactor rule to simply check parent line instead of all children
TSMMark a45e9c4
credit where credit is due
TSMMark 8e81d90
fix always reporting new line required for all siblings
TSMMark e51c4cf
add an invalid test case using html tags
TSMMark 799dfa6
failing tests describing how to handle non-element jsx nodes
TSMMark 7bdc856
rework internals to check children of JSXElement
TSMMark cb5f447
handle certain cases in one pass
TSMMark a18c30b
rename to jsx-one-expression-per-line
TSMMark 1344f1d
strip spaces but leave line returns
TSMMark cd3648c
use better practices
TSMMark 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
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.
If the lack of whitespace before "foo" is important, then it's just as important after "foo" - meaning, this example can't be autofixed.
However,
definitely should become:
Uh oh!
There was an error while loading. Please reload this page.
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.
@ljharb I believe white space in jsx is differnt from HTML and in your example the two jsx snippets are actually rendered differently.
foo
in the first snippet will be rendered to the DOM with a whitespace on either side, whilefoo
in the second snippet will have no whitespace.However, even if I'm correct the rule still does need to be patched. Currently, the autofix does change the rendered whitespace under certain conditions, which is obviously unacceptable.
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.
Using curlies and transforming into a string literal with spacing on either side seems the most accurate. Is this acceptible?
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.
Sure, that'd be great!
As long as the autofix is not changing the resulting whitespace that's rendered, we're good.