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

Update: check ternary : even if ? was reported in space-infix-ops #13963

Merged
merged 1 commit into from Jan 30, 2021

Conversation

mdjermanovic
Copy link
Member

Prerequisites checklist

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

[ ] Documentation update
[X] Bug fix (template)
[ ] New rule (template)
[ ] Changes an existing rule (template)
[ ] Add autofixing to a rule
[ ] Add a CLI option
[ ] Add something to the core
[ ] Other, please explain:

Tell us about your environment

  • ESLint Version: v7.16.0
  • Node Version: v12.18.4
  • npm Version: v6.14.6

What parser (default, @babel/eslint-parser, @typescript-eslint/parser, etc.) are you using?

default

Please show your full configuration:

Configuration
module.exports = {
  parserOptions: {
    ecmaVersion: 2015
  }
};

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

Online Demo

/* eslint space-infix-ops: "error" */

a ?b :c

What did you expect to happen?

Since this rule reports and underlines operator tokens, I'd expect two errors: one for ?, the other for :.

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

Only 1 error, and it underlines only ?

  3:3  error  Operator '?' must be spaced  space-infix-ops

Nonetheless, the multi-pass --fix correctly fixes the code to a ? b : c, because fixing the error for ? causes the error for : to appear.

What changes did you make? (Give an overview)

Changed the space-infix-ops rule to report : if it isn't spaced, even when ? from the same ternary expression was already reported.

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

  • Am I missing something?
  • One report used to hide another, so this change shouldn't normally cause new reports in a lint-free code. However, I marked this as an Update since it can produce more reports (which might matter with --max-warnings), and it could even make a lint-free code to fail in some edge cases, like this:
/* eslint space-infix-ops: "error" */

a
    ?b // eslint-disable-line space-infix-ops
    :c

@mdjermanovic mdjermanovic added bug ESLint is working incorrectly rule Relates to ESLint's core rules accepted There is consensus among the team that this change meets the criteria for inclusion labels Dec 28, 2020
@nzakas
Copy link
Member

nzakas commented Jan 1, 2021

Stylistic rules are frozen because we don’t want to spend time maintaining them anymore. I’m not sure this is worth fixing at this point.

@mdjermanovic
Copy link
Member Author

I found this while checking how the newly added multiline-ternary fixer works together with space-infix-ops. It looked like an oversight and an easy fix, but I'd be fine with closing this.

@nzakas
Copy link
Member

nzakas commented Jan 8, 2021

Understood. It’s just that if we say rules are frozen, and then constantly make little changes, we lose credibility and basically end up in the same situation we had prior to freezing the rules where we need to evaluate every request. Unless you or someone else feels strongly about this, I’d rather stick to our policy.

@nzakas nzakas added the tsc agenda This issue will be discussed by ESLint's TSC at the next meeting label Jan 28, 2021
@nzakas
Copy link
Member

nzakas commented Jan 28, 2021

TSC Summary: this PR fixes a slight bug in space-infix-ops. Per our policy, this rule is frozen so we are no longer making changes to it.

TSC Question: Should we close this PR without merging?

@btmills btmills removed the tsc agenda This issue will be discussed by ESLint's TSC at the next meeting label Jan 29, 2021
@btmills
Copy link
Member

btmills commented Jan 29, 2021

We collectively forgot that our policy already says we'll fix bugs, so this PR is good to go.

This was referenced Mar 17, 2021
@eslint-github-bot eslint-github-bot bot locked and limited conversation to collaborators Jul 30, 2021
@eslint-github-bot eslint-github-bot bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Jul 30, 2021
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 rule Relates to ESLint's core rules
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants