Better handling when all diagnostics have been filtered
MODIFY
packages/@romejs/cli-diagnostics/DiagnosticsPrinter.ts
packages/@romejs/cli-diagnostics/DiagnosticsPrinter.ts
@@ -367,11 +367,13 @@ export default class DiagnosticsPrinter extends Error {
}
print() {
- const filteredDiagnostics = this.filterDiagnostics();
+ let filteredDiagnostics = this.filterDiagnostics();
+
if (filteredDiagnostics.length === 0) {
this.reporter.error(
- 'No diagnostics provided. They have likely all been filtered.',
+ 'No diagnostics provided. They have likely all been filtered but this operation does not support suppressions. Showing complete diagnostics instead.',
);
+ filteredDiagnostics = this.processor.getCompleteUnfilteredDiagnostics();
}
this.fetchFileSources(filteredDiagnostics);

MODIFY
packages/@romejs/diagnostics/DiagnosticsProcessor.ts
packages/@romejs/diagnostics/DiagnosticsProcessor.ts
@@ -50,6 +50,7 @@ export default class DiagnosticsProcessor {
this.unique =
options.unique === undefined ? DEFAULT_UNIQUE : options.unique;
this.throwAfter = undefined;
+ this.unfilteredDiagnostics = [];
}
static createImmediateThrower(
@@ -66,6 +67,7 @@ export default class DiagnosticsProcessor {
unique: UniqueRules;
includedKeys: Set<string>;
+ unfilteredDiagnostics: PartialDiagnostics;
diagnostics: PartialDiagnostics;
filters: Array<DiagnosticFilterWithTest>;
options: CollectorOptions;
@@ -196,6 +198,8 @@ export default class DiagnosticsProcessor {
// Filter diagnostics
diagLoop: for (const diag of diags) {
+ this.unfilteredDiagnostics.push(diag);
+
if (max !== undefined && this.diagnostics.length > max) {
break;
}
@@ -233,6 +237,14 @@ export default class DiagnosticsProcessor {
return added;
}
+ getUnfilteredDiagnostics(): PartialDiagnostics {
+ return [...this.unfilteredDiagnostics];
+ }
+
+ getCompleteUnfilteredDiagnostics(): Diagnostics {
+ return normalizeDiagnostics(this.unfilteredDiagnostics, markupOptions);
+ }
+
getPartialDiagnostics(): PartialDiagnostics {
return [...this.diagnostics];
}

Better handling when all diagnostics have been filtered