@@ -36,23 +36,22 @@ export type TestingLibrarySettings = {
36
36
} ;
37
37
38
38
export type TestingLibraryContext <
39
- TOptions extends readonly unknown [ ] ,
40
39
TMessageIds extends string ,
40
+ TOptions extends readonly unknown [ ] ,
41
41
> = Readonly <
42
42
TSESLint . RuleContext < TMessageIds , TOptions > & {
43
43
settings : TestingLibrarySettings ;
44
44
}
45
45
> ;
46
46
47
47
export type EnhancedRuleCreate <
48
- TOptions extends readonly unknown [ ] ,
49
48
TMessageIds extends string ,
50
- TRuleListener extends TSESLint . RuleListener = TSESLint . RuleListener ,
49
+ TOptions extends readonly unknown [ ] ,
51
50
> = (
52
- context : TestingLibraryContext < TOptions , TMessageIds > ,
51
+ context : TestingLibraryContext < TMessageIds , TOptions > ,
53
52
optionsWithDefault : Readonly < TOptions > ,
54
53
detectionHelpers : Readonly < DetectionHelpers >
55
- ) => TRuleListener ;
54
+ ) => TSESLint . RuleListener ;
56
55
57
56
// Helpers methods
58
57
type GetTestingLibraryImportNodeFn = ( ) => ImportModuleNode | null ;
@@ -156,15 +155,14 @@ export type DetectionOptions = {
156
155
* Enhances a given rule `create` with helpers to detect Testing Library utils.
157
156
*/
158
157
export function detectTestingLibraryUtils <
159
- TOptions extends readonly unknown [ ] ,
160
158
TMessageIds extends string ,
161
- TRuleListener extends TSESLint . RuleListener = TSESLint . RuleListener ,
159
+ TOptions extends readonly unknown [ ] ,
162
160
> (
163
- ruleCreate : EnhancedRuleCreate < TOptions , TMessageIds , TRuleListener > ,
161
+ ruleCreate : EnhancedRuleCreate < TMessageIds , TOptions > ,
164
162
{ skipRuleReportingCheck = false } : Partial < DetectionOptions > = { }
165
163
) {
166
164
return (
167
- context : TestingLibraryContext < TOptions , TMessageIds > ,
165
+ context : TestingLibraryContext < TMessageIds , TOptions > ,
168
166
optionsWithDefault : Readonly < TOptions >
169
167
) : TSESLint . RuleListener => {
170
168
const importedTestingLibraryNodes : ImportModuleNode [ ] = [ ] ;
@@ -214,6 +212,7 @@ export function detectTestingLibraryUtils<
214
212
215
213
const originalNodeName =
216
214
isImportSpecifier ( importedUtilSpecifier ) &&
215
+ ASTUtils . isIdentifier ( importedUtilSpecifier . imported ) &&
217
216
importedUtilSpecifier . local . name !== importedUtilSpecifier . imported . name
218
217
? importedUtilSpecifier . imported . name
219
218
: undefined ;
0 commit comments