[projectManager] Warn when multiple configs
MODIFY
internal/core/server/fs/MemoryFileSystem.ts
internal/core/server/fs/MemoryFileSystem.ts
@@ -20,6 +20,7 @@ import {
Diagnostics,
DiagnosticsProcessor,
catchDiagnostics,
+ descriptions,
} from "@internal/diagnostics";
import {EventQueue} from "@internal/events";
import {consumeJSON} from "@internal/codec-json";
@@ -935,6 +936,15 @@ export default class MemoryFileSystem {
dirname.getBasename() === PROJECT_CONFIG_DIRECTORY &&
PROJECT_CONFIG_FILENAMES.includes(basename)
) {
+ if (projectManager.hasLoadedProjectDirectory(dirname.getParent())) {
+ opts.diagnostics.addDiagnostic({
+ description: descriptions.PROJECT_MANAGER.MULTIPLE_CONFIGS,
+ location: {
+ filename: path.join(),
+ },
+ });
+ }
+
await projectManager.addDiskProject({
// Get the directory above .config
projectDirectory: dirname.getParent(),

MODIFY
internal/core/server/project/ProjectManager.ts
internal/core/server/project/ProjectManager.ts
@@ -763,7 +763,7 @@ export default class ProjectManager {
}
}
- private hasLoadedProjectDirectory(path: AbsoluteFilePath): boolean {
+ public hasLoadedProjectDirectory(path: AbsoluteFilePath): boolean {
return this.projectDirectoryToProject.has(path);
}
@@ -878,12 +878,10 @@ export default class ProjectManager {
// Would have emitted a diagnostic
return;
}
-
await this.server.memoryFs.watch(dir);
return this.assertProjectExisting(cwd);
}
}
-
// Check for package.json
const packagePath = dir.append("package.json");
if (await this.server.memoryFs.existsHard(packagePath)) {

MODIFY
internal/diagnostics/categories.ts
internal/diagnostics/categories.ts
@@ -48,6 +48,7 @@ export type DiagnosticCategory =
| "parse/url/query"
| "parse/vscodeTheme"
| "projectManager/sensitiveDirectory"
+ | "projectManager/multipleConfigFiles"
| "projectManager/typoConfigFilename"
| "projectManager/misplacedConfig"
| "projectManager/missing"

MODIFY
internal/diagnostics/descriptions/projectManager.ts
internal/diagnostics/descriptions/projectManager.ts
@@ -44,6 +44,17 @@ export const projectManager = createDiagnosticsCategory({
},
],
}),
+ MULTIPLE_CONFIGS: {
+ category: "projectManager/multipleConfigFiles",
+ message: markup`Multiple config files were found`,
+ advice: [
+ {
+ type: "log",
+ category: "info",
+ text: markup`There should be a single config file. Remove those that are unnecessary.`,
+ },
+ ],
+ },
NOT_FOUND: {
category: "projectManager/missing",
message: markup`Couldn't find a project`,

[projectManager] Warn when multiple configs (#1031)