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

Extend react/jsx-props-no-multi-spaces to catch extra line breaks. #2223

Closed
jsphstls opened this issue Apr 2, 2019 · 10 comments · Fixed by #2756
Closed

Extend react/jsx-props-no-multi-spaces to catch extra line breaks. #2223

jsphstls opened this issue Apr 2, 2019 · 10 comments · Fixed by #2756

Comments

@jsphstls
Copy link
Contributor

jsphstls commented Apr 2, 2019

<button
  title='Some button'

  type='button'
/>

I was unable to find a rule that would prevent this and I think react/jsx-props-no-multi-spaces would be the most relevant one to extend. The issue is not that people would really do this. Instead, the goal is to improve the autofixing benefits of an existing rule with a hopefully minor adjustment.

@jsphstls jsphstls changed the title Extend react/jsx-props-no-multi-spaces to catch line breaks. Extend react/jsx-props-no-multi-spaces to catch extra line breaks. Apr 2, 2019
@ljharb
Copy link
Member

ljharb commented Apr 2, 2019

That sounds reasonable - want to make a PR?

@iiison
Copy link
Contributor

iiison commented May 7, 2019

is someone working on this?

@ljharb
Copy link
Member

ljharb commented May 7, 2019

nope, go for it.

@iiison
Copy link
Contributor

iiison commented May 8, 2019

so, as far as I understand, we need to add auto-fixing functionality to this plugin?

@ljharb
Copy link
Member

ljharb commented May 8, 2019

@iiison this issue is for adding additional warnings to the rule.

Separately, it would be ideal to maximize what can be safely autofixed.

@RisingGeek
Copy link

It's still not auto fixing extra line breaks
Versions that I'm using
eslint: 7.32.0
eslint-plugin-react: 7.28.0

Am I missing something?

@ljharb
Copy link
Member

ljharb commented Dec 30, 2021

It isn’t supposed to; it just warns on them.

@roryabraham
Copy link

roryabraham commented Mar 11, 2022

I actually am not a fan of this change, since it disallows comments over certain props in multiline jsx code. Leading to lots of ugly code like this:

<MyComponent
    someProp

    // Some comment about a prop's usage
    // eslint-disable-next-line react/jsx-props-no-multi-spaces
    someOtherProp
/>

As opposed to this:

<MyComponent
    someProp

    // Some comment about a prop's usage
    someOtherProp
/>

@jsphstls stated in his original posting:

The issue is not that people would really do this. Instead, the goal is to improve the autofixing benefits of an existing rule with a hopefully minor adjustment.

But the PR that was merged actually doesn't introduce any autofixing benefits. In my opinion #2756 should be reverted, or barring that, we should allow the user to configure a maximum number of allowable line breaks in multiline components.

@roryabraham
Copy link

roryabraham commented Mar 11, 2022

Actually though, this isn't really necessary since no-multi-spaces covers single-line JSX props. So this rule is really just helpful in disabling multiple newlines between props, which I am fine turning off. It would still be nice to be able to set a maximum of 1 blank line between JSX props (allowing for comments on props but not multiple blank lines).

@ljharb
Copy link
Member

ljharb commented Mar 11, 2022

@roryabraham that seems like a reasonable option to add, if you wanted to send a PR with lots of test cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging a pull request may close this issue.

5 participants