Skip to content

Commit

Permalink
fix: allow assignment of children of whitelisted commands in no-assig…
Browse files Browse the repository at this point in the history
…ning-return-values rule (#60)
  • Loading branch information
JaKXz authored May 27, 2020
1 parent bcc04a6 commit 2d127d0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/rules/no-assigning-return-values.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ function isCypressCommandDeclaration (declarator) {

const commandName = get(declarator, 'init.callee.property.name')

if (commandName && whitelistedCommands[commandName]) return
const parent = get(object, 'parent.property.name') || get(declarator, 'id.name')

if (commandName && (whitelistedCommands[commandName] || whitelistedCommands[parent])) return

return object.name === 'cy'
}
1 change: 1 addition & 0 deletions tests/lib/rules/no-assigning-return-values.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ ruleTester.run('no-assigning-return-values', rule, {
{ code: 'const foo = bar();', parserOptions },
{ code: 'const foo = bar().baz();', parserOptions },
{ code: 'const spy = cy.spy();', parserOptions },
{ code: 'const spy = cy.spy().as();', parserOptions },
{ code: 'const stub = cy.stub();', parserOptions },
{ code: 'const result = cy.now();', parserOptions },
{ code: 'const state = cy.state();', parserOptions },
Expand Down

0 comments on commit 2d127d0

Please sign in to comment.