Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix: check method(node) returns truthy before trying to using resul…
…ts (#358)

Fixes #357
  • Loading branch information
G-Rath authored and SimenB committed Jul 31, 2019
1 parent 098219b commit 4a6d486
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/rules/__tests__/prefer-to-be-null.test.js
Expand Up @@ -17,6 +17,7 @@ ruleTester.run('prefer-to-be-null', rule, {
'expect("a string").not.toMatchSnapshot();',
"expect(something).toEqual('a string');",
'expect(null).toBe',
'expect("something");',
],

invalid: [
Expand Down
1 change: 1 addition & 0 deletions src/rules/__tests__/prefer-to-be-undefined.test.js
Expand Up @@ -14,6 +14,7 @@ ruleTester.run('prefer-to-be-undefined', rule, {
'expect(something).not.toBe(somethingElse)',
'expect(something).not.toEqual(somethingElse)',
'expect(undefined).toBe',
'expect("something");',
],

invalid: [
Expand Down
4 changes: 2 additions & 2 deletions src/rules/util.js
Expand Up @@ -87,9 +87,9 @@ export const method = node => node.parent.property;

export const method2 = node => node.parent.parent.property;

const methodName = node => method(node).name;
const methodName = node => method(node) && method(node).name;

const methodName2 = node => method2(node).name;
const methodName2 = node => method2(node) && method2(node).name;

export const argument = node =>
node.parent.parent.arguments && node.parent.parent.arguments[0];
Expand Down

0 comments on commit 4a6d486

Please sign in to comment.