Skip to content

Commit 22e1dfa

Browse files
committed
refactor: use isFindQueryVariant
1 parent 58daeed commit 22e1dfa

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

lib/rules/prefer-find-by.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,6 @@ export function getFindByQueryVariant(
2424
return queryMethod.includes('All') ? 'findAllBy' : 'findBy';
2525
}
2626

27-
function isFindByQuery(name: string): boolean {
28-
return /^find(All)?By/.test(name);
29-
}
30-
3127
function findRenderDefinitionDeclaration(
3228
scope: TSESLint.Scope.Scope | null,
3329
query: string
@@ -367,13 +363,12 @@ export default createTestingLibraryRule<Options, MessageIds>({
367363
}
368364

369365
const { callee } = declaration.init.argument;
370-
371-
const name = getDeepestIdentifierNode(callee)?.name;
372-
return name ? isFindByQuery(name) : false;
366+
const node = getDeepestIdentifierNode(callee);
367+
return node ? helpers.isFindQueryVariant(node) : false;
373368
});
374369

375370
const init = ASTUtils.isAwaitExpression(findByDeclarator?.init)
376-
? findByDeclarator.init?.argument
371+
? findByDeclarator.init.argument
377372
: null;
378373

379374
if (!isCallExpression(init)) {

0 commit comments

Comments
 (0)