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

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-deprecated eslint-deprecated bot added the triage An ESLint team member will look at this issue soon label Oct 8, 2019
@mdjermanovic mdjermanovic added enhancement This change enhances an existing feature of ESLint evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion rule Relates to ESLint's core rules and removed triage An ESLint team member will look at this issue soon labels Oct 8, 2019
@kaicataldo
Copy link
Member

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

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

Copy link
Member

@kaicataldo kaicataldo left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@kaicataldo kaicataldo added accepted There is consensus among the team that this change meets the criteria for inclusion and removed enhancement This change enhances an existing feature of ESLint labels Oct 24, 2019
@kaicataldo kaicataldo merged commit c78f4a7 into master Nov 1, 2019
@kaicataldo kaicataldo deleted the noinlinecomment-jsx branch November 1, 2019 18:40
@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators May 1, 2020
@eslint-deprecated eslint-deprecated bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label May 1, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion rule Relates to ESLint's core rules
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants