Skip to content

Commit 4e0431a

Browse files
tylerbutlerCopilot
andauthored
fix(fluid-build): shared eslint-config-fluid files to EsLintTask cache invalidation (#25997)
## Description ESLint config changes in the shared `@fluidframework/eslint-config-fluid` package were not properly invalidating the eslint task because only the local config file was tracked. Extended `configFileFullPaths` in `EsLintTask` to include files from the shared config: - **Shared config tracking**: Tracks key files from `@fluidframework/eslint-config-fluid` (index.js, base.js, strict.js, recommended.js, minimal-deprecated.js, strict-biome.js, package.json) as additional config files - **Graceful handling**: Uses a path relative to the repo root (`common/build/eslint-config-fluid`); if the directory doesn't exist, gracefully skips this tracking This keeps `EsLintTask` as a `TscDependentTask` while adding the additional config file tracking needed to properly invalidate when shared configs change. ## Reviewer Guidance The change preserves existing behavior and simply extends `configFileFullPaths` to include additional files. `TsLintTask` remains unchanged. --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: tylerbutler <19589+tylerbutler@users.noreply.github.com>
1 parent 87c1143 commit 4e0431a

File tree

1 file changed

+64
-1
lines changed
  • build-tools/packages/build-tools/src/fluidBuild/tasks/leaf

1 file changed

+64
-1
lines changed

build-tools/packages/build-tools/src/fluidBuild/tasks/leaf/lintTasks.ts

Lines changed: 64 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,19 @@
33
* Licensed under the MIT License.
44
*/
55

6+
import { existsSync } from "node:fs";
7+
import path from "node:path";
8+
69
import { getEsLintConfigFilePath, getInstalledPackageVersion } from "../taskUtils";
710
import { TscDependentTask } from "./tscTask";
811

12+
/**
13+
* Path to the shared eslint-config-fluid package relative to the repo root.
14+
* Can be overridden with the FLUID_BUILD_ESLINT_CONFIG_PATH environment variable.
15+
*/
16+
const sharedEslintConfigPath =
17+
process.env.FLUID_BUILD_ESLINT_CONFIG_PATH ?? "common/build/eslint-config-fluid";
18+
919
export class TsLintTask extends TscDependentTask {
1020
protected get configFileFullPaths() {
1121
return [this.getPackageFileFullPath("tslint.json")];
@@ -18,14 +28,67 @@ export class TsLintTask extends TscDependentTask {
1828

1929
export class EsLintTask extends TscDependentTask {
2030
private _configFileFullPath: string | undefined;
31+
private _sharedConfigFiles: string[] | undefined;
32+
33+
/**
34+
* Gets the absolute paths to shared eslint config files that should be tracked.
35+
* These are files from @fluidframework/eslint-config-fluid that affect linting behavior.
36+
*/
37+
private getSharedConfigFiles(): string[] {
38+
if (this._sharedConfigFiles !== undefined) {
39+
return this._sharedConfigFiles;
40+
}
41+
42+
const sharedDir = path.join(this.context.repoRoot, sharedEslintConfigPath);
43+
44+
// If the shared config directory doesn't exist, skip tracking
45+
if (!existsSync(sharedDir)) {
46+
console.warn(
47+
`Warning: Shared ESLint config directory not found at ${sharedDir}. ` +
48+
`ESLint cache invalidation may not work correctly if shared config changes.`,
49+
);
50+
this._sharedConfigFiles = [];
51+
return this._sharedConfigFiles;
52+
}
53+
54+
// Track the main config files from the shared eslint-config-fluid package
55+
const sharedConfigFiles = [
56+
"index.js",
57+
"base.js",
58+
"strict.js",
59+
"recommended.js",
60+
"minimal-deprecated.js",
61+
"strict-biome.js",
62+
"package.json", // Tracks version changes
63+
];
64+
65+
const files: string[] = [];
66+
for (const file of sharedConfigFiles) {
67+
const fullPath = path.join(sharedDir, file);
68+
if (existsSync(fullPath)) {
69+
files.push(fullPath);
70+
} else {
71+
console.warn(
72+
`Warning: Expected shared ESLint config file not found: ${fullPath}. ` +
73+
`ESLint cache invalidation may not work correctly.`,
74+
);
75+
}
76+
}
77+
78+
this._sharedConfigFiles = files;
79+
return this._sharedConfigFiles;
80+
}
81+
2182
protected get configFileFullPaths() {
2283
if (!this._configFileFullPath) {
2384
this._configFileFullPath = getEsLintConfigFilePath(this.package.directory);
2485
if (!this._configFileFullPath) {
2586
throw new Error(`Unable to find config file for eslint ${this.command}`);
2687
}
2788
}
28-
return [this._configFileFullPath];
89+
90+
// Include local config file and shared eslint-config-fluid files
91+
return [this._configFileFullPath, ...this.getSharedConfigFiles()];
2992
}
3093

3194
protected get useWorker() {

0 commit comments

Comments
 (0)