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-constant-condition doesn't respect generator function expressions #10826

Closed
helixbass opened this issue Sep 2, 2018 · 1 comment
Closed
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

Comments

@helixbass
Copy link
Contributor

Tell us about your environment
Came across this while working on eslint-plugin-coffee custom parser

  • ESLint Version:
    5.4.0
  • Node Version:
    8.11.4
  • npm Version:
    6.2.0

What parser (default, Babel-ESLint, etc.) are you using?
Coffeescript, but the issue seems to apply regardless of parser

Please show your full configuration:
The relevant config would be no-constant-condition: error

What did you do? Please include the actual source code causing the issue, as well as the command that you used to run ESLint.
I was attempting to run equivalent Coffeescript versions of the tests in tests/lib/rules/no-constant-condition.js against the no-constant-condition rule. I saw tests fail eg this was expected to throw an error but didn't:

while true
  foo = -> yield

Which would be basically equivalent in JS to:

while (true) {
  const foo = function*() { yield }
}

What did you expect to happen?
For the test to pass (the nested yield shouldn't suppress the warning for the constant while condition)

What actually happened? Please include the actual, raw output from ESLint.
The test failed (no warning was reported by no-constant-condition)

Looking at the source code for lib/rules/no-constant-condition.js, I saw that it only "resets the yield checker" when entering a FunctionDeclaration (but not a FunctionExpression). Coffeescript doesn't generate FunctionDeclarations so that's why I ran into this

It seems to me that generator FunctionExpressions should behave the same way as generator FunctionDeclarations

Will submit a fixing PR momentarily

@eslint-deprecated eslint-deprecated bot added the triage An ESLint team member will look at this issue soon label Sep 2, 2018
@not-an-aardvark not-an-aardvark 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 and removed triage An ESLint team member will look at this issue soon labels Sep 4, 2018
@not-an-aardvark
Copy link
Member

Closing because this was fixed by #10827.

@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Mar 16, 2019
@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 Mar 16, 2019
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

No branches or pull requests

2 participants