@@ -40,7 +40,7 @@ export function createLinter(
4040 const lintResults = new Map <
4141 /* fileName */ string ,
4242 [
43- sourceFile : ts . SourceFile ,
43+ file : ts . SourceFile ,
4444 diagnostic2Fixes : Map < ts . DiagnosticWithLocation , {
4545 title : string ;
4646 getEdits : ( ) => ts . FileTextChanges [ ] ;
@@ -76,7 +76,12 @@ export function createLinter(
7676 const rulesContext : RuleContext = typeAwareMode
7777 ? {
7878 ...ctx ,
79- sourceFile : ctx . languageService . getProgram ( ) ! . getSourceFile ( fileName ) ! ,
79+ get file ( ) {
80+ return ctx . languageService . getProgram ( ) ! . getSourceFile ( fileName ) ! ;
81+ } ,
82+ get sourceFile ( ) {
83+ return ctx . languageService . getProgram ( ) ! . getSourceFile ( fileName ) ! ;
84+ } ,
8085 get program ( ) {
8186 return ctx . languageService . getProgram ( ) ! ;
8287 } ,
@@ -91,7 +96,12 @@ export function createLinter(
9196 get program ( ) : ts . Program {
9297 throw new Error ( 'Not supported' ) ;
9398 } ,
94- sourceFile : getNonBoundSourceFile ( fileName ) ,
99+ get file ( ) {
100+ return getNonBoundSourceFile ( fileName ) ;
101+ } ,
102+ get sourceFile ( ) {
103+ return getNonBoundSourceFile ( fileName ) ;
104+ } ,
95105 report,
96106 reportError : report ,
97107 reportWarning : report ,
@@ -100,7 +110,7 @@ export function createLinter(
100110 const token = ctx . languageServiceHost . getCancellationToken ?.( ) ;
101111 const configs = getConfigsForFile ( fileName , cache ?. [ 2 ] ) ;
102112
103- lintResults . set ( fileName , [ rulesContext . sourceFile , new Map ( ) , [ ] ] ) ;
113+ lintResults . set ( fileName , [ rulesContext . file , new Map ( ) , [ ] ] ) ;
104114
105115 const lintResult = lintResults . get ( fileName ) ! ;
106116
@@ -115,12 +125,12 @@ export function createLinter(
115125 if ( ruleCache ) {
116126 let lintResult = lintResults . get ( fileName ) ;
117127 if ( ! lintResult ) {
118- lintResults . set ( fileName , lintResult = [ rulesContext . sourceFile , new Map ( ) , [ ] ] ) ;
128+ lintResults . set ( fileName , lintResult = [ rulesContext . file , new Map ( ) , [ ] ] ) ;
119129 }
120130 for ( const cacheDiagnostic of ruleCache [ 1 ] ) {
121131 lintResult [ 1 ] . set ( {
122132 ...cacheDiagnostic ,
123- file : rulesContext . sourceFile ,
133+ file : rulesContext . file ,
124134 relatedInformation : cacheDiagnostic . relatedInformation ?. map ( info => ( {
125135 ...info ,
126136 file : info . file ? ( syntaxOnlyLanguageService as any ) . getNonBoundSourceFile ( info . file . fileName ) : undefined ,
@@ -174,7 +184,7 @@ export function createLinter(
174184 for ( const { plugins } of configs ) {
175185 for ( const { resolveDiagnostics } of plugins ) {
176186 if ( resolveDiagnostics ) {
177- diagnostics = resolveDiagnostics ( rulesContext . sourceFile , diagnostics ) ;
187+ diagnostics = resolveDiagnostics ( rulesContext . file , diagnostics ) ;
178188 }
179189 }
180190 }
@@ -203,7 +213,7 @@ export function createLinter(
203213 category : ts . DiagnosticCategory . Message ,
204214 code : currentRuleId as any ,
205215 messageText : message ,
206- file : rulesContext . sourceFile ,
216+ file : rulesContext . file ,
207217 start,
208218 length : end - start ,
209219 source : 'tsslint' ,
@@ -226,7 +236,7 @@ export function createLinter(
226236
227237 let lintResult = lintResults . get ( fileName ) ;
228238 if ( ! lintResult ) {
229- lintResults . set ( fileName , lintResult = [ rulesContext . sourceFile , new Map ( ) , [ ] ] ) ;
239+ lintResults . set ( fileName , lintResult = [ rulesContext . file , new Map ( ) , [ ] ] ) ;
230240 }
231241 const diagnostic2Fixes = lintResult [ 1 ] ;
232242 const refactors = lintResult [ 2 ] ;
@@ -281,7 +291,7 @@ export function createLinter(
281291 return [ ] ;
282292 }
283293
284- const sourceFile = lintResult [ 0 ] ;
294+ const file = lintResult [ 0 ] ;
285295 const configs = getConfigsForFile ( fileName , minimatchCache ) ;
286296 const result : ts . CodeFixAction [ ] = [ ] ;
287297
@@ -310,7 +320,7 @@ export function createLinter(
310320 for ( const { plugins } of configs ) {
311321 for ( const { resolveCodeFixes } of plugins ) {
312322 if ( resolveCodeFixes ) {
313- codeFixes = resolveCodeFixes ( sourceFile , diagnostic , codeFixes ) ;
323+ codeFixes = resolveCodeFixes ( file , diagnostic , codeFixes ) ;
314324 }
315325 }
316326 }
0 commit comments