From b030cc748361ecd7692845e22114be041700e9b3 Mon Sep 17 00:00:00 2001 From: Hasegawa-Yukihiro Date: Mon, 29 Apr 2024 17:00:02 +0900 Subject: [PATCH] fix: addressed feedback and made necessary corrections --- src/rules/__tests__/unbound-method.test.ts | 40 ++++++++++------------ src/rules/valid-expect-in-promise.ts | 5 ++- 2 files changed, 20 insertions(+), 25 deletions(-) diff --git a/src/rules/__tests__/unbound-method.test.ts b/src/rules/__tests__/unbound-method.test.ts index 8fcb802db..119593bc4 100644 --- a/src/rules/__tests__/unbound-method.test.ts +++ b/src/rules/__tests__/unbound-method.test.ts @@ -113,37 +113,33 @@ const invalidTestCases: Array> = [ ], }, // toThrow matchers call the expected value (which is expected to be a function) - ...toThrowMatchers.map>( - matcher => ({ - code: dedent` + ...toThrowMatchers.map(matcher => ({ + code: dedent` ${ConsoleClassAndVariableCode} expect(console.log).${matcher}(); `, - errors: [ - { - line: 9, - messageId: 'unboundWithoutThisAnnotation', - }, - ], - }), - ), + errors: [ + { + line: 9, + messageId: 'unboundWithoutThisAnnotation' as const, + }, + ], + })), // toThrow matchers call the expected value (which is expected to be a function) - ...toThrowMatchers.map>( - matcher => ({ - code: dedent` + ...toThrowMatchers.map(matcher => ({ + code: dedent` ${ConsoleClassAndVariableCode} expect(console.log).not.${matcher}(); `, - errors: [ - { - line: 9, - messageId: 'unboundWithoutThisAnnotation', - }, - ], - }), - ), + errors: [ + { + line: 9, + messageId: 'unboundWithoutThisAnnotation' as const, + }, + ], + })), ]; const requireRule = (throwWhenRequiring: boolean) => { diff --git a/src/rules/valid-expect-in-promise.ts b/src/rules/valid-expect-in-promise.ts index 21f5bc8af..8570f8ed5 100644 --- a/src/rules/valid-expect-in-promise.ts +++ b/src/rules/valid-expect-in-promise.ts @@ -98,7 +98,7 @@ const isPromiseMethodThatUsesValue = ( ) { const nodeName = getNodeName(node.argument); - if (nodeName && ['Promise.all', 'Promise.allSettled'].includes(nodeName)) { + if (['Promise.all', 'Promise.allSettled'].includes(nodeName as string)) { const [firstArg] = node.argument.arguments; if ( @@ -110,8 +110,7 @@ const isPromiseMethodThatUsesValue = ( } if ( - nodeName && - ['Promise.resolve', 'Promise.reject'].includes(nodeName) && + ['Promise.resolve', 'Promise.reject'].includes(nodeName as string) && node.argument.arguments.length === 1 ) { return isIdentifier(node.argument.arguments[0], name);