diff --git a/src/rules/__tests__/prefer-to-be-null.test.js b/src/rules/__tests__/prefer-to-be-null.test.js index 43fb7f033..91631e8b0 100644 --- a/src/rules/__tests__/prefer-to-be-null.test.js +++ b/src/rules/__tests__/prefer-to-be-null.test.js @@ -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: [ diff --git a/src/rules/__tests__/prefer-to-be-undefined.test.js b/src/rules/__tests__/prefer-to-be-undefined.test.js index 622c408fe..f75767a29 100644 --- a/src/rules/__tests__/prefer-to-be-undefined.test.js +++ b/src/rules/__tests__/prefer-to-be-undefined.test.js @@ -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: [ diff --git a/src/rules/util.js b/src/rules/util.js index e1edfd291..a180aa14d 100644 --- a/src/rules/util.js +++ b/src/rules/util.js @@ -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];