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
Incorrect formatting when running ---fix for JSX with missing parentheses (jsx-wrap-multilines) #1382
Comments
Sorry about the issue here. This is a bug in I'll temporarily disable this rule and release a new version of Note to self: re-add the following rule to "react/jsx-wrap-multilines": ["error", {
"declaration": "parens-new-line",
"assignment": "parens-new-line",
"return": "parens-new-line",
"arrow": "parens-new-line",
"condition": "parens-new-line",
"logical": "ignore",
"prop": "ignore"
}], |
Released |
I realized that without exact versions, we don't have to release a new version of standard when we relax a rule in one of the configs, like I just did for #1382 I would rather be forced to release a new version when I do this, so we have to add a changelog entry and document the change.
Thanks @feross, great work on the update by the way! I have noticed something else strange which the Original code:
Formatted code:
I expected this to happen:
Original code:
Formatted code:
I expected this to happen:
|
@jakefb I agree with your expectations in the first example. As for the second example, we have a rule that ternary operators need to be at the start of the line, like this: const x = condition
? 'true'
: 'false So when it comes to JSX, I guess it should format to this? But it's kind of terrible... const Component = props => (
<div>
{true
? (
<div>
<p>Some text</p>
</div>
)
: null}
</div>
) |
That makes sense. When writing plain JavaScript instead of JSX I think putting ternary operators on a newline makes the code more readable. In my opinion when writing JSX it's more familiar to do it the same way as in the React docs because the formatting and indentation is similar to writing and if else tag in the Django template language or something similar. |
The first issue you reported has been fixed upstream (but not in a release yet): #1382 The second two issues may still remain, though we should test it out. |
What version of this package are you using?
^14.0.0
What operating system, Node.js, and npm version?
macOS 10.14.5
node v12.8.0
npm 6.10.2
What happened?
It appears that jsx-wrap-multilines #710 has been implemented in standard v14, however when I run
standard --fix
the following happens.Original code:
Formatted code:
What did you expect to happen?
I expected the export statement to be on a newline. Something strange is going on with the JSX formatting as well.
Are you willing to submit a pull request to fix this bug?
I could take a look into it and see if I can find what's causing the issue.
The text was updated successfully, but these errors were encountered: