@@ -166,21 +166,22 @@ const ValidJestFnCallChains = [
166166 'xtest.failing.each' ,
167167] ;
168168
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+ } ;
177177}
178178
179179const resolvePossibleAliasedGlobal = (
180180 global : string ,
181181 context : TSESLint . RuleContext < string , unknown [ ] > ,
182182) => {
183- const globalAliases = context . settings . jest ?. globalAliases ?? { } ;
183+ const globalAliases =
184+ ( context . settings as SharedConfigurationSettings ) . jest ?. globalAliases ?? { } ;
184185
185186 const alias = Object . entries ( globalAliases ) . find ( ( [ , aliases ] ) =>
186187 aliases . includes ( global ) ,
@@ -569,7 +570,8 @@ const resolveToJestFn = (
569570
570571 if ( maybeImport ) {
571572 const globalPackage =
572- context . settings . jest ?. globalPackage ?? '@jest/globals' ;
573+ ( context . settings as SharedConfigurationSettings ) . jest ?. globalPackage ??
574+ '@jest/globals' ;
573575
574576 // the identifier is imported from our global package so return the original import name
575577 if ( maybeImport . source === globalPackage ) {
@@ -595,14 +597,7 @@ const getScope = (
595597 context : TSESLint . RuleContext < string , unknown [ ] > ,
596598 node : TSESTree . Node ,
597599) => {
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 ( ) ;
606601
607- return context . getScope ( ) ;
602+ return sourceCode . getScope ?. ( node ) ?? context . getScope ( ) ;
608603} ;
0 commit comments