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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update: Allow JSX exception in no-inline-comments (fixes #11270) #12388

Merged
merged 1 commit into from Nov 1, 2019

Conversation

@mdjermanovic
Copy link
Member

mdjermanovic commented Oct 8, 2019

What is the purpose of this pull request? (put an "X" next to item)

[X] Changes an existing rule #11270

Marked as 'Update' although this change produces fewer warnings by default, because it wasn't a bug.

What rule do you want to change?

no-inline-comments

Does this change cause the rule to produce more or fewer warnings?

fewer

How will the change be implemented? (New option, new default behavior, etc.)?

new default behavior

Please provide some example code that this change will affect:

/*eslint no-inline-comments: "error"*/

var foo = (
    <div>
      {/* These braces are just for this comment and there is nothing else on this line */}
      <h1>Some heading</h1>
    </div>
)

var quux = (
    <div>
      {/*
        Multiline
        comment
      */}
      <h1>Some heading</h1>
    </div>
)

What does the rule currently do for this code?

2 errors.

What will the rule do after it's changed?

No errors.

What changes did you make? (Give an overview)

Allow a comment in JSX to be on the same line as the braces (or one brace), only if it there is nothing else on the same line and the braces are for comment only (this generates JSXEmptyExpression node).

Is there anything you'd like reviewers to focus on?

These are currently errors, and will stay errors:

/*eslint no-inline-comments: "error"*/

var foo = <div>{ /* On the same line with other code */ }<h1>Some heading</h1></div>;

var bar = (
    <div>
    {   // These braces are not just for the comment, so it can't be on the same line
        baz
    }
    </div>
);

This was already allowed, and will stay allowed:

var bar = (
    <div>
    {
        // There is nothing else on this line
        baz
    }
    </div>
);

Also, two comments on the same line are currently an error everywhere (not just in JSX). This behavior is unchanged.

Labeling as evaluating, as I think it isn't decided yet is this a new default behavior or an option.

I 馃憤 for new default behavior.

@eslint eslint bot added the triage label Oct 8, 2019
@kaicataldo
Copy link
Member

kaicataldo commented Oct 10, 2019

Left a thumb, but realized it would be clearer to leave a comment. I think making this the default behavior makes sense, especially since it leads to fewer errors being reported.

@platinumazure
Copy link
Member

platinumazure commented Oct 20, 2019

I agree that making this the default behavior makes more sense.

Copy link
Member

kaicataldo left a comment

LGTM, thanks!

@kaicataldo kaicataldo added accepted and removed enhancement labels Oct 24, 2019
@kaicataldo kaicataldo merged commit c78f4a7 into master Nov 1, 2019
16 checks passed
16 checks passed
Verify Files
Details
Test (ubuntu-latest, 8.x)
Details
Test (ubuntu-latest, 10.x)
Details
Test (ubuntu-latest, 12.x)
Details
Test (windows-latest, 12.x)
Details
Test (macOS-latest, 12.x)
Details
Browser Test
Details
commit-message Commit message follows guidelines
Details
continuous-integration Build #20191008.3 succeeded
Details
continuous-integration (Test on Node.js 10 (Linux)) Test on Node.js 10 (Linux) succeeded
Details
continuous-integration (Test on Node.js 12 (Linux)) Test on Node.js 12 (Linux) succeeded
Details
continuous-integration (Test on Node.js 12 (Windows)) Test on Node.js 12 (Windows) succeeded
Details
continuous-integration (Test on Node.js 12 (macOS)) Test on Node.js 12 (macOS) succeeded
Details
continuous-integration (Test on Node.js 8 (Linux)) Test on Node.js 8 (Linux) succeeded
Details
licence/cla Contributor License Agreement is signed.
Details
release-monitor No patch release is pending
Details
@kaicataldo kaicataldo deleted the noinlinecomment-jsx branch Nov 1, 2019
@eslint eslint bot locked and limited conversation to collaborators May 1, 2020
@eslint eslint bot added the archived due to age label May 1, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants
You can鈥檛 perform that action at this time.