Skip to content

Commit 61a9de1

Browse files
fix: Fix crashing bug in no-force rule when using spread operator (#79)
1 parent e9e8a77 commit 61a9de1

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

lib/rules/no-force.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ module.exports = {
4242

4343
return node.arguments && node.arguments.length &&
4444
node.arguments.some((arg) => {
45-
return arg.type === 'ObjectExpression' && arg.properties.some((propNode) => propNode.key.name === 'force')
45+
return arg.type === 'ObjectExpression' && arg.properties.some((propNode) => propNode.key && propNode.key.name === 'force')
4646
})
4747
}
4848

tests/lib/rules/no-force.js

+8-7
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const rule = require('../../../lib/rules/no-force')
99
const RuleTester = require('eslint').RuleTester
1010

1111
const errors = [{ messageId: 'unexpected' }]
12-
const parserOptions = { ecmaVersion: 6 }
12+
const parserOptions = { ecmaVersion: 2018 }
1313

1414
//------------------------------------------------------------------------------
1515
// Tests
@@ -24,12 +24,13 @@ ruleTester.run('no-force', rule, {
2424
{ code: `cy.get('button').click({multiple: true})`, parserOptions },
2525
{ code: `cy.get('button').dblclick()`, parserOptions },
2626
{ code: `cy.get('input').type('somth')`, parserOptions },
27-
{ code: `cy.get('input').type('somth', {anyoption: true})`, parserOptions, errors },
28-
{ code: `cy.get('input').trigger('click', {anyoption: true})`, parserOptions, errors },
29-
{ code: `cy.get('input').rightclick({anyoption: true})`, parserOptions, errors },
30-
{ code: `cy.get('input').check()`, parserOptions, errors },
31-
{ code: `cy.get('input').select()`, parserOptions, errors },
32-
{ code: `cy.get('input').focus()`, parserOptions, errors },
27+
{ code: `cy.get('input').type('somth', {anyoption: true})`, parserOptions },
28+
{ code: `cy.get('input').trigger('click', {anyoption: true})`, parserOptions },
29+
{ code: `cy.get('input').rightclick({anyoption: true})`, parserOptions },
30+
{ code: `cy.get('input').check()`, parserOptions },
31+
{ code: `cy.get('input').select()`, parserOptions },
32+
{ code: `cy.get('input').focus()`, parserOptions },
33+
{ code: `cy.document().trigger("keydown", { ...event })`, parserOptions },
3334
],
3435

3536
invalid: [

0 commit comments

Comments
 (0)