Skip to content

Commit 6781117

Browse files
committed
feat: add support for settings['testing-library/utils-module']
1 parent 9e49403 commit 6781117

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

lib/utils/resolve-to-testing-library-fn.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
TSESTree,
77
} from '@typescript-eslint/utils';
88

9+
import { TestingLibraryContext } from '../create-testing-library-rule/detect-testing-library-utils';
910
import {
1011
isImportDefaultSpecifier,
1112
isImportExpression,
@@ -153,9 +154,12 @@ interface ResolvedTestingLibraryUserEventFn {
153154

154155
const USER_EVENT_PACKAGE = '@testing-library/user-event';
155156

156-
export const resolveToTestingLibraryFn = (
157+
export const resolveToTestingLibraryFn = <
158+
TMessageIds extends string,
159+
TOptions extends readonly unknown[],
160+
>(
157161
node: TSESTree.CallExpression,
158-
context: TSESLint.RuleContext<string, unknown[]>
162+
context: TestingLibraryContext<TMessageIds, TOptions>
159163
): ResolvedTestingLibraryUserEventFn | null => {
160164
const chain = getNodeChain(node);
161165
if (!chain?.length) return null;
@@ -168,8 +172,9 @@ export const resolveToTestingLibraryFn = (
168172
return null;
169173
}
170174

175+
const customModuleSetting = context.settings['testing-library/utils-module'];
171176
if (
172-
[...LIBRARY_MODULES, USER_EVENT_PACKAGE].some(
177+
[...LIBRARY_MODULES, USER_EVENT_PACKAGE, customModuleSetting].some(
173178
(module) => module === maybeImport.source
174179
)
175180
) {

0 commit comments

Comments
 (0)