Skip to content

Commit 13ff374

Browse files
fix: Fix no-assigning-return-values 'cannot read property callee of undefined' error (fixes #8)
2 parents 27c2b12 + c7b96f7 commit 13ff374

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

lib/rules/no-assigning-return-values.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ function isCypressCommandDeclaration(declarator) {
3535
if (!declarator.init.callee) { return; }
3636

3737
let object = declarator.init.callee.object;
38+
39+
if (!object) { return; }
40+
3841
while (object.callee) {
3942
object = object.callee.object;
4043
}

tests/lib/rules/no-assigning-return-values.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ ruleTester.run('no-assigning-return-values', rule, {
1313
{ code: 'var foo = true;', parserOptions },
1414
{ code: 'let foo = true;', parserOptions },
1515
{ code: 'const foo = true;', parserOptions },
16+
{ code: 'const foo = bar();', parserOptions },
1617
{ code: 'cy.get("foo");', parserOptions },
1718
{ code: 'cy.contains("foo").click();', parserOptions }
1819
],

0 commit comments

Comments
 (0)