@@ -166,21 +166,22 @@ const ValidJestFnCallChains = [
166
166
'xtest.failing.each' ,
167
167
] ;
168
168
169
- declare module '@ typescript-eslint/utils/dist/ts -eslint' {
170
- export interface SharedConfigurationSettings {
171
- jest ?: {
172
- globalAliases ?: Record < string , string [ ] > ;
173
- globalPackage ?: string ;
174
- version ?: number | string ;
175
- } ;
176
- }
169
+ // todo: switch back to using declaration merging once https://github.com/ typescript-eslint/typescript -eslint/pull/8485
170
+ // is landed
171
+ interface SharedConfigurationSettings {
172
+ jest ?: {
173
+ globalAliases ?: Record < string , string [ ] > ;
174
+ globalPackage ?: string ;
175
+ version ?: number | string ;
176
+ } ;
177
177
}
178
178
179
179
const resolvePossibleAliasedGlobal = (
180
180
global : string ,
181
181
context : TSESLint . RuleContext < string , unknown [ ] > ,
182
182
) => {
183
- const globalAliases = context . settings . jest ?. globalAliases ?? { } ;
183
+ const globalAliases =
184
+ ( context . settings as SharedConfigurationSettings ) . jest ?. globalAliases ?? { } ;
184
185
185
186
const alias = Object . entries ( globalAliases ) . find ( ( [ , aliases ] ) =>
186
187
aliases . includes ( global ) ,
@@ -569,7 +570,8 @@ const resolveToJestFn = (
569
570
570
571
if ( maybeImport ) {
571
572
const globalPackage =
572
- context . settings . jest ?. globalPackage ?? '@jest/globals' ;
573
+ ( context . settings as SharedConfigurationSettings ) . jest ?. globalPackage ??
574
+ '@jest/globals' ;
573
575
574
576
// the identifier is imported from our global package so return the original import name
575
577
if ( maybeImport . source === globalPackage ) {
@@ -595,14 +597,7 @@ const getScope = (
595
597
context : TSESLint . RuleContext < string , unknown [ ] > ,
596
598
node : TSESTree . Node ,
597
599
) => {
598
- const sourceCode =
599
- 'sourceCode' in context
600
- ? ( context . sourceCode as TSESLint . SourceCode )
601
- : context . getSourceCode ( ) ;
602
-
603
- if ( 'getScope' in sourceCode ) {
604
- return sourceCode . getScope ( node ) ;
605
- }
600
+ const sourceCode = context . sourceCode ?? context . getSourceCode ( ) ;
606
601
607
- return context . getScope ( ) ;
602
+ return sourceCode . getScope ?. ( node ) ?? context . getScope ( ) ;
608
603
} ;
0 commit comments