Skip to content

Commit

Permalink
fix: Fix crashing bug in no-force rule when using spread operator (#79)
Browse files Browse the repository at this point in the history
  • Loading branch information
emilgoldsmith authored May 4, 2021
1 parent e9e8a77 commit 61a9de1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion lib/rules/no-force.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ module.exports = {

return node.arguments && node.arguments.length &&
node.arguments.some((arg) => {
return arg.type === 'ObjectExpression' && arg.properties.some((propNode) => propNode.key.name === 'force')
return arg.type === 'ObjectExpression' && arg.properties.some((propNode) => propNode.key && propNode.key.name === 'force')
})
}

Expand Down
15 changes: 8 additions & 7 deletions tests/lib/rules/no-force.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const rule = require('../../../lib/rules/no-force')
const RuleTester = require('eslint').RuleTester

const errors = [{ messageId: 'unexpected' }]
const parserOptions = { ecmaVersion: 6 }
const parserOptions = { ecmaVersion: 2018 }

//------------------------------------------------------------------------------
// Tests
Expand All @@ -24,12 +24,13 @@ ruleTester.run('no-force', rule, {
{ code: `cy.get('button').click({multiple: true})`, parserOptions },
{ code: `cy.get('button').dblclick()`, parserOptions },
{ code: `cy.get('input').type('somth')`, parserOptions },
{ code: `cy.get('input').type('somth', {anyoption: true})`, parserOptions, errors },
{ code: `cy.get('input').trigger('click', {anyoption: true})`, parserOptions, errors },
{ code: `cy.get('input').rightclick({anyoption: true})`, parserOptions, errors },
{ code: `cy.get('input').check()`, parserOptions, errors },
{ code: `cy.get('input').select()`, parserOptions, errors },
{ code: `cy.get('input').focus()`, parserOptions, errors },
{ code: `cy.get('input').type('somth', {anyoption: true})`, parserOptions },
{ code: `cy.get('input').trigger('click', {anyoption: true})`, parserOptions },
{ code: `cy.get('input').rightclick({anyoption: true})`, parserOptions },
{ code: `cy.get('input').check()`, parserOptions },
{ code: `cy.get('input').select()`, parserOptions },
{ code: `cy.get('input').focus()`, parserOptions },
{ code: `cy.document().trigger("keydown", { ...event })`, parserOptions },
],

invalid: [
Expand Down

0 comments on commit 61a9de1

Please sign in to comment.