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

"no-mixed-operators" always outputs errors in pairs of two #8051

Closed
feross opened this issue Feb 9, 2017 · 6 comments · Fixed by #9404
Closed

"no-mixed-operators" always outputs errors in pairs of two #8051

feross opened this issue Feb 9, 2017 · 6 comments · Fixed by #9404
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 documentation Relates to ESLint's documentation good first issue Good for people who haven't worked on ESLint before

Comments

@feross
Copy link
Contributor

feross commented Feb 9, 2017

Tell us about your environment

  • ESLint Version: 3.15.0
  • Node Version: 7.5.0
  • npm Version: 4.1.2

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

Please show your full configuration:

    "no-mixed-operators": ["error", {
        "groups": [
            ["+", "-", "*", "/", "%", "**"],
            ["==", "!=", "===", "!==", ">", ">=", "<", "<="],
            ["&&", "||"],
            ["in", "instanceof"]
        ],
        "allowSamePrecedence": true
    }],

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

var eLen = nBytes * 8 - mLen - 1

What did you expect to happen?

One error about mixed operators.

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

Two errors about mixed operators, one for each operator:

  index.js:3:21: Unexpected mix of '*' and '-'. (no-mixed-operators)
  index.js:3:25: Unexpected mix of '*' and '-'. (no-mixed-operators)

Is this expected behavior? It seems there is no case where this rule emits a single error, since by definition "mixing" operators requires 2 operators. It would be more intuitive to me if a single error was emitted.

@eslintbot eslintbot added the triage An ESLint team member will look at this issue soon label Feb 9, 2017
@not-an-aardvark
Copy link
Member

This seems like a bug. Thanks for the report!

@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 rule Relates to ESLint's core rules and removed triage An ESLint team member will look at this issue soon labels Feb 9, 2017
@mysticatea
Copy link
Member

Actually, this is intentional.

Unexpected mix of '*' and '-'., in this case, it shows 2 warnings at the * and - to make clear what operators are mixed.

@feross
Copy link
Contributor Author

feross commented Feb 9, 2017

@mysticatea Wouldn't showing a single warning at the first operator suffice?

@mysticatea
Copy link
Member

I will not oppose it. However, this rule warns consecutive 2 operators on AST, so it might be at far locations on source code text if the expression is complex. It was the reason that I made 2 warnings.

@not-an-aardvark not-an-aardvark added evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion and removed accepted There is consensus among the team that this change meets the criteria for inclusion labels Feb 9, 2017
@feross
Copy link
Contributor Author

feross commented Feb 9, 2017

Makes sense. Either way is fine, though I was initially confused by the double error.

@nzakas
Copy link
Member

nzakas commented Feb 12, 2017

I think this is the correct behavior as well. Perhaps we should update the docs to mention this?

@not-an-aardvark not-an-aardvark added accepted There is consensus among the team that this change meets the criteria for inclusion good first issue Good for people who haven't worked on ESLint before documentation Relates to ESLint's documentation and removed bug ESLint is working incorrectly evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion rule Relates to ESLint's core rules labels Jul 11, 2017
ruxandrafed added a commit to ruxandrafed/eslint that referenced this issue Oct 9, 2017
Update docs for `no-mixed-operators` to clarify that a pair of errors will be triggered for each pair of mixed consecutive operators used. Fixes eslint#8051.
ruxandrafed added a commit to ruxandrafed/eslint that referenced this issue Oct 9, 2017
Update docs for `no-mixed-operators` to clarify that a pair of errors will be triggered for each pair of mixed consecutive operators used. Fixes eslint#8051.
ruxandrafed added a commit to ruxandrafed/eslint that referenced this issue Oct 10, 2017
Update docs for `no-mixed-operators` to clarify that a pair of errors will be triggered for each pair of mixed consecutive operators used. Fixes eslint#8051.
ruxandrafed added a commit to ruxandrafed/eslint that referenced this issue Oct 11, 2017
Update docs for `no-mixed-operators` to clarify that a pair of errors will be triggered for each pair of mixed consecutive operators used. Fixes eslint#8051.
kaicataldo pushed a commit that referenced this issue Oct 11, 2017
Update docs for `no-mixed-operators` to clarify that a pair of errors will be triggered for each pair of mixed consecutive operators used. Fixes #8051.
@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Apr 10, 2018
@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 Apr 10, 2018
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 documentation Relates to ESLint's documentation good first issue Good for people who haven't worked on ESLint before
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants