Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: allow assignment of children of whitelisted commands in no-assigning-return-values rule #60

Merged
merged 2 commits into from
May 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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