From 4450daa17ae542bbfed85d16845c5dac1c310dea Mon Sep 17 00:00:00 2001 From: Gareth Jones Date: Wed, 19 Oct 2022 07:48:37 +1300 Subject: [PATCH] fix(no-restricted-jest-methods): don't crash on `jest()` (#1269) --- src/rules/__tests__/no-restricted-jest-methods.test.ts | 1 + src/rules/no-restricted-jest-methods.ts | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/rules/__tests__/no-restricted-jest-methods.test.ts b/src/rules/__tests__/no-restricted-jest-methods.test.ts index 39c4081ca..dc60aba1d 100644 --- a/src/rules/__tests__/no-restricted-jest-methods.test.ts +++ b/src/rules/__tests__/no-restricted-jest-methods.test.ts @@ -13,6 +13,7 @@ const ruleTester = new TSESLint.RuleTester({ ruleTester.run('no-restricted-jest-methods', rule, { valid: [ 'jest', + 'jest()', 'jest.mock()', 'expect(a).rejects;', 'expect(a);', diff --git a/src/rules/no-restricted-jest-methods.ts b/src/rules/no-restricted-jest-methods.ts index a2a4a6ded..37947fce5 100644 --- a/src/rules/no-restricted-jest-methods.ts +++ b/src/rules/no-restricted-jest-methods.ts @@ -33,7 +33,7 @@ export default createRule< CallExpression(node) { const jestFnCall = parseJestFnCall(node, context); - if (jestFnCall?.type !== 'jest') { + if (jestFnCall?.type !== 'jest' || jestFnCall.members.length === 0) { return; }