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

jsx-wrap-multilines now catches single missing newlines #1984

Merged
merged 2 commits into from Oct 31, 2018

Conversation

MrHen
Copy link
Contributor

@MrHen MrHen commented Sep 16, 2018

Fixes #1965. The only interesting question is how the fixer should treat the newlines. I chose to make it add a new line if there was exactly zero after or before the parens. This means:

  var Hello = createReactClass({
    render: function() {
      return (<div>
        <p>Hello {this.props.name}</p>
      </div>
      );
    }
  });

Fixes to:

  var Hello = createReactClass({
    render: function() {
      return (
<div>
        <p>Hello {this.props.name}</p>
      </div>
      );
    }
  });

And:

  var Hello = createReactClass({
    render: function() {
      return (<div>
        <p>Hello {this.props.name}</p>
      </div>

      );
    }
  });

Fixes to:

  var Hello = createReactClass({
    render: function() {
      return (
<div>
        <p>Hello {this.props.name}</p>
      </div>

      );
    }
  });

The alternative would be to make exactly one newline regardless of how many there were before -- but I assumed such a behavior should be its own rule instead of attached to this rule.

tests/lib/rules/jsx-wrap-multilines.js Outdated Show resolved Hide resolved
lib/rules/jsx-wrap-multilines.js Outdated Show resolved Hide resolved
var Hello = createReactClass({
render: function() {
return (

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These extra newlines here seem odd - why is this allowed to be here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See my earlier comment:
#1984 (comment)

My first attempts at fixing this caused extraneous newlines to disappear which seemed like an undesired side-effect of this particular rule. The extra newline isn't being added by the fix -- its in the original test condition. The test is making sure the extra newline is not being stripped.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense (although I’d want it stripped, this probably isn’t the rule for it)

@MrHen
Copy link
Contributor Author

MrHen commented Oct 30, 2018

Thanks for the review @ljharb. What's the next step to getting this merged? Anything I need to do?

@ljharb ljharb merged commit 3008e85 into jsx-eslint:master Oct 31, 2018
This was referenced Dec 28, 2018
This was referenced Jan 4, 2019
@ghost ghost mentioned this pull request Jan 12, 2019
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

jsx-wrap-multilines wrong behavior of parens-new-line
2 participants