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

4.1.0 indent regression on jsx binary expressions when using parenthesis #8832

Closed
lukeapage opened this issue Jun 28, 2017 · 2 comments · Fixed by homezen/eslint-config-homezen#43
Assignees
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 bug ESLint is working incorrectly indent Relates to the `indent` rule rule Relates to ESLint's core rules

Comments

@lukeapage
Copy link
Contributor

Tell us about your environment

  • ESLint Version: 4.1.1
  • Node Version: 6.9.1
  • npm Version: 4.5.0

What parser (default, Babel-ESLint, etc.) are you using?
default

Please show your full configuration:

        "indent": [
            "error",
            4,
            {
                "SwitchCase": 1
            }
        ],

What did you do? Please include the actual source code causing the issue.

function A() {
    return (
        <div>
            {
                b && (
                    <div>
                    </div>
                )
            }
        </div>
    );
}

What did you expect to happen?

No errors - this code is fine in 4.0

What actually happened? Please include the actual, raw output from ESLint.

indentation errors:

image

passing code:

function A() {
    return (
        <div>
            {
                b && (
                <div>
                </div>
            )
            }
        </div>
    );
}

Note it seems that without parenthesis it works fine.. this code passes..

function A() {
    return (
        <div>
            {
                b &&
                    <div>
                    </div>
            }
        </div>
    );
}
@eslintbot eslintbot added the triage An ESLint team member will look at this issue soon label Jun 28, 2017
@not-an-aardvark not-an-aardvark added accepted There is consensus among the team that this change meets the criteria for inclusion bug ESLint is working incorrectly indent Relates to the `indent` rule rule Relates to ESLint's core rules and removed triage An ESLint team member will look at this issue soon labels Jun 28, 2017
@not-an-aardvark
Copy link
Member

not-an-aardvark commented Jun 28, 2017

Thanks for reporting, I can reproduce this. It was probably caused by b5a70b4.

Simplified reproduction case:

/* eslint indent: error */
<div>
    {
        (
            1
        )
    }
</div>

An error is reported, and the rule corrects it to the following (incorrect) code:

/* eslint indent: error */
<div>
    {
    (
        1
    )
    }
</div>

@not-an-aardvark not-an-aardvark self-assigned this Jun 28, 2017
not-an-aardvark added a commit that referenced this issue Jul 1, 2017
Previously, the `indent` rule handled JSXExpressionContainer nodes by only setting the first token's offset, incorrectly assuming that all the other tokens in the expression would be dependent on the first token. (This had been a problem since JSX support was added to the rule.) As a result of an unrelated, correct fix in b5a70b4, the bug ended up also appearing for BinaryExpressions in JSXExpressionContainers.

This commit updates the JSXExpression logic to offset all of its inner tokens.
@lukeapage
Copy link
Contributor Author

Thanks @not-an-aardvark and thanks in general for the great work on indent, it's very much appreciated

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 bug ESLint is working incorrectly indent Relates to the `indent` rule rule Relates to ESLint's core rules
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants