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

Operator-Linebreak Default Option Behaves Differently When Option Is Actually Specified #7459

Closed
epmatsw opened this issue Oct 27, 2016 · 3 comments · Fixed by #7726
Closed
Labels
archived due to age This issue has been archived; please open a new issue for any further discussion documentation Relates to ESLint's documentation

Comments

@epmatsw
Copy link

epmatsw commented Oct 27, 2016

Tell us about your environment

  • ESLint Version: 3.8.1
  • Node Version: 7.0.0
  • npm Version: 3.10.9

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

Please show your full configuration:

A

{
    "rules": {
        "operator-linebreak": [2, "after"]
    }
}

B

{
    "rules": {
        "operator-linebreak": [2]
    }
}

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

var blah = hey ?
    a : b;

What did you expect to happen?
"after" (default) requires linebreaks to be placed after the operator (except for the ternary operator characters ? and :)

Based on the docs, I would expect this code to pass with both configs.
What actually happened? Please include the actual, raw output from ESLint.
If you use config B, the line is flagged as an error. Config A passes as expected.

I think this is really a doc issue. It should be more clear that the after option and the default behavior are not interchangeable.

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

not-an-aardvark commented Oct 27, 2016

Thanks for the report. I was going to say that this is a bug, but based on the source code it appears to be intentional. I'm not sure why, though.

If it is intentional, then I agree that the documentation should point it out.

edit: It looks like this was introduced in 4ade378

@not-an-aardvark not-an-aardvark added bug ESLint is working incorrectly rule Relates to ESLint's core rules evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion and removed triage An ESLint team member will look at this issue soon labels Oct 27, 2016
@epmatsw
Copy link
Author

epmatsw commented Oct 27, 2016

Yeah, it definitely feels buggy. And even the docs in that commit seem unclear on what the behavior should be.

@not-an-aardvark not-an-aardvark added 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 Dec 8, 2016
@not-an-aardvark
Copy link
Member

I figured it out: it's not that there's a bug in the rule, it's that the default configuration has overrides for ? and :. In other words, the default configuration is not just after, it's after, {overrides: {'?': before, ':': before}}.

I made a PR to update the docs at #7726.

@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Feb 6, 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 Feb 6, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
archived due to age This issue has been archived; please open a new issue for any further discussion documentation Relates to ESLint's documentation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants