diff --git a/lib/rules/no-assigning-return-values.js b/lib/rules/no-assigning-return-values.js index 05b9a2d5..f35570f6 100644 --- a/lib/rules/no-assigning-return-values.js +++ b/lib/rules/no-assigning-return-values.js @@ -35,6 +35,9 @@ function isCypressCommandDeclaration(declarator) { if (!declarator.init.callee) { return; } let object = declarator.init.callee.object; + + if (!object) { return; } + while (object.callee) { object = object.callee.object; } diff --git a/tests/lib/rules/no-assigning-return-values.js b/tests/lib/rules/no-assigning-return-values.js index 427c3b77..7aab85c2 100644 --- a/tests/lib/rules/no-assigning-return-values.js +++ b/tests/lib/rules/no-assigning-return-values.js @@ -13,6 +13,7 @@ ruleTester.run('no-assigning-return-values', rule, { { code: 'var foo = true;', parserOptions }, { code: 'let foo = true;', parserOptions }, { code: 'const foo = true;', parserOptions }, + { code: 'const foo = bar();', parserOptions }, { code: 'cy.get("foo");', parserOptions }, { code: 'cy.contains("foo").click();', parserOptions } ],