Skip to content

Commit

Permalink
Fix: respect generator function expressions in no-constant-condition (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
helixbass authored and not-an-aardvark committed Sep 5, 2018
1 parent 0a65844 commit 7da36d5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/rules/no-constant-condition.js
Expand Up @@ -207,6 +207,8 @@ module.exports = {
"ForStatement:exit": checkConstantConditionLoopInSet,
FunctionDeclaration: enterFunction,
"FunctionDeclaration:exit": exitFunction,
FunctionExpression: enterFunction,
"FunctionExpression:exit": exitFunction,
YieldExpression: () => loopsInCurrentScope.clear()
};

Expand Down
4 changes: 4 additions & 0 deletions tests/lib/rules/no-constant-condition.js
Expand Up @@ -152,6 +152,10 @@ ruleTester.run("no-constant-condition", rule, {
code: "function foo() {while (true) {function* bar() {while (true) {yield;}}}}",
errors: [{ messageId: "unexpected", type: "Literal" }]
},
{
code: "function foo() {while (true) {const bar = function*() {while (true) {yield;}}}}",
errors: [{ messageId: "unexpected", type: "Literal" }]
},
{
code: "function* foo() { for (let foo = 1 + 2 + 3 + (yield); true; baz) {}}",
errors: [{ messageId: "unexpected", type: "Literal" }]
Expand Down

0 comments on commit 7da36d5

Please sign in to comment.