Skip to content
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

'react/jsx-wrap-multilines' behaves strange #1469

Closed
SidKwok opened this issue Oct 10, 2017 · 14 comments
Closed

'react/jsx-wrap-multilines' behaves strange #1469

SidKwok opened this issue Oct 10, 2017 · 14 comments

Comments

@SidKwok
Copy link

SidKwok commented Oct 10, 2017

The rule tells me that this is good:

var hello = (
    <div>
      <p>Hello</p>
    </div>
)

but this is also accepted:

var hello = (<div>
  <p>Hello</p>
</div>)
'react/jsx-wrap-multilines': 'error'

Did I miss something?

@ljharb
Copy link
Member

ljharb commented Oct 10, 2017

Nope. Both of your examples are allowed, but the docs only mention the first one, since it's generally preferred (and more readable) than the second.

@SidKwok
Copy link
Author

SidKwok commented Oct 10, 2017

How can I enforce the first format?

@ljharb
Copy link
Member

ljharb commented Oct 10, 2017

It sounds like we'd need another possible value for the three syntaxes: instead of true/false, we'd want an enum of ignore/parens/parens-separate-lines (or some better name for the last option).

@SidKwok
Copy link
Author

SidKwok commented Oct 10, 2017

That will be a good feature for this rule.

@lukemwillis
Copy link

@ljharb It looks like these options are supported in master now, but in v7.4.0, I get errors. This is my rule:

"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": "parens-new-line", 
    "prop": "parens-new-line"
}]

Which gives me the error:

Error: .eslintrc:
Configuration for rule "react/jsx-wrap-multilines" is invalid:
Value "[object Object]" should NOT have additional properties.

If I remove the rules for condition, logical, and prop, then I get the error:

Error: .eslintrc:
Configuration for rule "react/jsx-wrap-multilines" is invalid:
Value "parens-new-line" should be boolean.

Are the changes to this rule in v7.4.0? Or are they slated for a future release?

@ljharb
Copy link
Member

ljharb commented Nov 2, 2017

Slated for a future release.

@dfsq
Copy link

dfsq commented Nov 8, 2017

Are there plans to make a release in near future? This rule is important.

@vzaidman
Copy link

vzaidman commented Nov 9, 2017

Also, I'd like to specify default behavior:

"react/jsx-wrap-multilines": ["error", "parens-new-line", {
    "arrow": "parens", 
}]

or

"react/jsx-wrap-multilines": ["error", {
    "default": "parens-new-line",
    "arrow": "parens", 
}]

And this rule is very importnat i hope it is updated soon.

@ljharb
Copy link
Member

ljharb commented Apr 13, 2018

I believe this has been released.

@ljharb ljharb closed this as completed Apr 13, 2018
@mqklin
Copy link

mqklin commented Apr 13, 2018

@ljharb can't find it in NPM (last release 2 month ago)

@ljharb ljharb reopened this Apr 13, 2018
@ljharb
Copy link
Member

ljharb commented Apr 13, 2018

Can someone restate, in the latest version, exactly what’s not working as desired here? (Not about changing the defaults, just about an impossible configuration that you need)

@mqklin
Copy link

mqklin commented Apr 15, 2018

If I use the parens-new-line rule, I'm able to write 2 ways:

{showSpinner && (
  <Spinner
    color="red"
  />
)}

And

{showSpinner && 
  (
    <Spinner
      color="red"
    />
  )
}

--fix rule fixes it to the second one, which is not I want. Is there is a possibility to fix only to the first one?

@ljharb
Copy link
Member

ljharb commented Apr 15, 2018

That sounds like something worth doing.

@ljharb
Copy link
Member

ljharb commented Feb 4, 2022

@mqklin i prefer the first one, so if you could file a new issue, with config, input, and expected output, we can get it done.

@ljharb ljharb closed this as completed Feb 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

6 participants