From b5c22dce3602bbffd136a1984090881009a896f5 Mon Sep 17 00:00:00 2001 From: Simen Bekkhus Date: Wed, 9 Jan 2019 13:03:46 +0100 Subject: [PATCH] fix(no-alias-methods): handle missing assertion node Fixes #213 --- rules/__tests__/no-alias-methods.test.js | 1 + rules/no-alias-methods.js | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/rules/__tests__/no-alias-methods.test.js b/rules/__tests__/no-alias-methods.test.js index 3b3567c44..46c043d1e 100644 --- a/rules/__tests__/no-alias-methods.test.js +++ b/rules/__tests__/no-alias-methods.test.js @@ -18,6 +18,7 @@ ruleTester.run('no-alias-methods', rule, { 'expect(a).toHaveLastReturnedWith()', 'expect(a).toHaveNthReturnedWith()', 'expect(a).toThrow()', + 'expect(a).rejects;', ], invalid: [ diff --git a/rules/no-alias-methods.js b/rules/no-alias-methods.js index 0c2b9b668..b69101034 100644 --- a/rules/no-alias-methods.js +++ b/rules/no-alias-methods.js @@ -41,6 +41,10 @@ module.exports = { targetNode = method(node.parent); } + if (!targetNode) { + return; + } + // Check if the method used matches any of ours const methodItem = methodNames.find( item => item[1] === targetNode.name