@@ -39,6 +39,7 @@ interface ILintOptions {
3939 taskSession : IHeftTaskSession ;
4040 heftConfiguration : HeftConfiguration ;
4141 tsProgram : IExtendedProgram ;
42+ tsconfigFilePath : string ;
4243 fix ?: boolean ;
4344 sarifLogPath ?: string ;
4445 changedFiles ?: ReadonlySet < IExtendedSourceFile > ;
@@ -104,7 +105,8 @@ export default class LintPlugin implements IHeftTaskPlugin<ILintPluginOptions> {
104105 let inTypescriptPhase : boolean = false ;
105106
106107 // Use the changed files hook to collect the files and programs from TypeScript
107- let typescriptChangedFiles : [ IExtendedProgram , ReadonlySet < IExtendedSourceFile > ] [ ] = [ ] ;
108+ // Also track the tsconfig path for cache file naming
109+ let typescriptChangedFiles : [ IExtendedProgram , ReadonlySet < IExtendedSourceFile > , string ] [ ] = [ ] ;
108110 taskSession . requestAccessToPluginByName (
109111 TYPESCRIPT_PLUGIN_PACKAGE_NAME ,
110112 TYPESCRIPT_PLUGIN_NAME ,
@@ -114,9 +116,13 @@ export default class LintPlugin implements IHeftTaskPlugin<ILintPluginOptions> {
114116
115117 // Hook into the changed files hook to collect the changed files and their programs
116118 accessor . onChangedFilesHook . tap ( PLUGIN_NAME , ( changedFilesHookOptions : IChangedFilesHookOptions ) => {
119+ // When using the TypeScript plugin, we need to determine the tsconfig path
120+ // The default tsconfig path is used when not explicitly specified
121+ const tsconfigPath : string = path . resolve ( heftConfiguration . buildFolderPath , 'tsconfig.json' ) ;
117122 typescriptChangedFiles . push ( [
118123 changedFilesHookOptions . program as IExtendedProgram ,
119- changedFilesHookOptions . changedFiles as ReadonlySet < IExtendedSourceFile >
124+ changedFilesHookOptions . changedFiles as ReadonlySet < IExtendedSourceFile > ,
125+ tsconfigPath
120126 ] ) ;
121127 } ) ;
122128 }
@@ -126,20 +132,22 @@ export default class LintPlugin implements IHeftTaskPlugin<ILintPluginOptions> {
126132 // If we are not in the typescript phase, we need to create a typescript program
127133 // from the tsconfig file
128134 if ( ! inTypescriptPhase ) {
135+ const tsconfigPath : string = path . resolve ( heftConfiguration . buildFolderPath , 'tsconfig.json' ) ;
129136 const tsProgram : IExtendedProgram = await this . _createTypescriptProgramAsync (
130137 heftConfiguration ,
131138 taskSession
132139 ) ;
133- typescriptChangedFiles . push ( [ tsProgram , new Set ( tsProgram . getSourceFiles ( ) ) ] ) ;
140+ typescriptChangedFiles . push ( [ tsProgram , new Set ( tsProgram . getSourceFiles ( ) ) , tsconfigPath ] ) ;
134141 }
135142
136143 // Run the linters to completion. Linters emit errors and warnings to the logger.
137- for ( const [ tsProgram , changedFiles ] of typescriptChangedFiles ) {
144+ for ( const [ tsProgram , changedFiles , tsconfigFilePath ] of typescriptChangedFiles ) {
138145 try {
139146 await this . _lintAsync ( {
140147 taskSession,
141148 heftConfiguration,
142149 tsProgram,
150+ tsconfigFilePath,
143151 changedFiles,
144152 fix,
145153 sarifLogPath
@@ -222,7 +230,8 @@ export default class LintPlugin implements IHeftTaskPlugin<ILintPluginOptions> {
222230 }
223231
224232 private async _lintAsync ( options : ILintOptions ) : Promise < void > {
225- const { taskSession, heftConfiguration, tsProgram, changedFiles, fix, sarifLogPath } = options ;
233+ const { taskSession, heftConfiguration, tsProgram, tsconfigFilePath, changedFiles, fix, sarifLogPath } =
234+ options ;
226235
227236 // Ensure that we have initialized. This promise is cached, so calling init
228237 // multiple times will only init once.
@@ -232,6 +241,7 @@ export default class LintPlugin implements IHeftTaskPlugin<ILintPluginOptions> {
232241 if ( this . _eslintConfigFilePath && this . _eslintToolPath ) {
233242 const eslintLinter : Eslint = await Eslint . initializeAsync ( {
234243 tsProgram,
244+ tsconfigFilePath,
235245 fix,
236246 sarifLogPath,
237247 scopedLogger : taskSession . logger ,
@@ -246,6 +256,7 @@ export default class LintPlugin implements IHeftTaskPlugin<ILintPluginOptions> {
246256 if ( this . _tslintConfigFilePath && this . _tslintToolPath ) {
247257 const tslintLinter : Tslint = await Tslint . initializeAsync ( {
248258 tsProgram,
259+ tsconfigFilePath,
249260 fix,
250261 scopedLogger : taskSession . logger ,
251262 linterToolPath : this . _tslintToolPath ,
0 commit comments