@@ -2,11 +2,7 @@ import type * as TSSLint from '@tsslint/types';
22import type * as ESLint from 'eslint' ;
33import type * as ts from 'typescript' ;
44
5- const estrees = new WeakMap < ts . SourceFile , {
6- estree : ESLint . AST . Program ;
7- sourceCode : ESLint . SourceCode ;
8- eventQueue : any [ ] ;
9- } > ( ) ;
5+ let cachedEstree : [ sourceFile : ts . SourceFile , sourceCode : ESLint . SourceCode , eventQueue : any [ ] ] | undefined ;
106
117export function convertRule (
128 eslintRule : ESLint . Rule . RuleModule ,
@@ -381,7 +377,7 @@ function getEstree(
381377 file : ts . SourceFile ,
382378 getProgram : ( ) => ts . Program ,
383379) {
384- if ( ! estrees . has ( file ) ) {
380+ if ( cachedEstree ?. [ 0 ] !== file ) {
385381 let program : ts . Program | undefined ;
386382 let SourceCode ;
387383
@@ -422,7 +418,10 @@ function getEstree(
422418 } ,
423419 } ) ;
424420 const eventQueue = sourceCode . traverse ( ) ;
425- estrees . set ( file , { estree : ast , sourceCode, eventQueue } ) ;
421+ cachedEstree = [ file , sourceCode , eventQueue ] ;
426422 }
427- return estrees . get ( file ) ! ;
423+ return {
424+ sourceCode : cachedEstree [ 1 ] ,
425+ eventQueue : cachedEstree [ 2 ] ,
426+ } ;
428427}
0 commit comments