no-constant-condition doesn't respect generator function expressions #10826
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
Tell us about your environment
Came across this while working on
eslint-plugin-coffee
custom parser5.4.0
8.11.4
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 theno-constant-condition
rule. I saw tests fail eg this was expected to throw an error but didn't:Which would be basically equivalent in JS to:
What did you expect to happen?
For the test to pass (the nested
yield
shouldn't suppress the warning for the constantwhile
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 theyield
checker" when entering aFunctionDeclaration
(but not aFunctionExpression
). Coffeescript doesn't generateFunctionDeclaration
s so that's why I ran into thisIt seems to me that generator
FunctionExpression
s should behave the same way as generatorFunctionDeclaration
sWill submit a fixing PR momentarily
The text was updated successfully, but these errors were encountered: