Add support for passing along suppressions in the bundler
MODIFY
packages/@romejs/cli-diagnostics/DiagnosticsPrinter.ts
packages/@romejs/cli-diagnostics/DiagnosticsPrinter.ts
@@ -367,6 +367,12 @@ export default class DiagnosticsPrinter extends Error {
print() {
const filteredDiagnostics = this.filterDiagnostics();
+ if (filteredDiagnostics.length === 0) {
+ this.reporter.error(
+ 'No diagnostics provided. They have likely all been filtered.',
+ );
+ }
+
this.fetchFileSources(filteredDiagnostics);
this.displayDiagnostics(filteredDiagnostics);
}

MODIFY
packages/@romejs/cli-diagnostics/types.ts
packages/@romejs/cli-diagnostics/types.ts
import {Reporter} from '@romejs/cli-reporter';
import {AbsoluteFilePath} from '@romejs/path';
-import {DiagnosticOrigin} from '@romejs/diagnostics';
+import {DiagnosticOrigin, DiagnosticFilterJSON} from '@romejs/diagnostics';
export type DiagnosticsPrinterFlags = {
grep: string;
@@ -31,4 +31,5 @@ export type DiagnosticsPrinterOptions = {
cwd?: AbsoluteFilePath;
flags?: DiagnosticsPrinterFlags;
readFile?: DiagnosticsFileReader;
+ filters?: Array<DiagnosticFilterJSON>;
};

MODIFY
packages/@romejs/core/master/bundler/BundleRequest.ts
packages/@romejs/core/master/bundler/BundleRequest.ts
@@ -174,6 +174,10 @@ export default class BundleRequest {
this.diagnostics.addDiagnostics(res.diagnostics);
}
+ if (res.filters.length > 0) {
+ this.diagnostics.addFilters(res.filters);
+ }
+
this.compiles.set(source, res);
return res;
}

MODIFY
packages/@romejs/core/master/commands/compile.ts
packages/@romejs/core/master/commands/compile.ts
@@ -49,10 +49,10 @@ export default createMasterCommand({
res = await req.requestWorkerCompile(resolved.path, 'compile');
}
- const {code, diagnostics}: WorkerCompileResult = res;
+ const {code, diagnostics, filters}: WorkerCompileResult = res;
if (diagnostics.length > 0) {
- throw new DiagnosticsError('Compile diagnostics', diagnostics);
+ throw new DiagnosticsError('Compile diagnostics', diagnostics, filters);
}
reporter.writeAll(code);

MODIFY
packages/@romejs/diagnostics/DiagnosticsProcessor.ts
packages/@romejs/diagnostics/DiagnosticsProcessor.ts
@@ -30,6 +30,7 @@ type UniqueRule = Array<UniquePart>;
type UniqueRules = Array<UniqueRule>;
export type CollectorOptions = {
+ filters?: Array<DiagnosticFilter>;
unique?: UniqueRules;
max?: number;
onDiagnostics?: (diags: PartialDiagnostics) => void;
@@ -43,7 +44,7 @@ const DEFAULT_UNIQUE: UniqueRules = [
export default class DiagnosticsProcessor {
constructor(options: CollectorOptions) {
this.diagnostics = [];
- this.filters = [];
+ this.filters = options.filters === undefined ? [] : options.filters;
this.options = options;
this.includedKeys = new Set();
this.unique =

MODIFY
packages/@romejs/diagnostics/errors.ts
packages/@romejs/diagnostics/errors.ts
* LICENSE file in the root directory of this source tree.
*/
-import {PartialDiagnostics} from '@romejs/diagnostics';
+import {PartialDiagnostics, DiagnosticsProcessor} from '@romejs/diagnostics';
import {escapeMarkup} from '@romejs/string-markup';
import {stripAnsi} from '@romejs/string-ansi';
import {printDiagnosticsToString} from '@romejs/cli-diagnostics';
-import {PartialDiagnostic} from './types';
+import {PartialDiagnostic, DiagnosticFilterJSON} from './types';
export class DiagnosticsError extends Error {
- constructor(message: string, diagnostics: PartialDiagnostics) {
+ constructor(
+ message: string,
+ diagnostics: PartialDiagnostics,
+ filters: Array<DiagnosticFilterJSON> = [],
+ ) {
if (diagnostics.length === 0) {
throw new Error('No diagnostics');
}
@@ -29,23 +33,30 @@ export class DiagnosticsError extends Error {
super(escapeMarkup(message));
this.diagnostics = diagnostics;
+ this.filters = filters;
this.name = 'DiagnosticsError';
}
diagnostics: PartialDiagnostics;
+ filters: Array<DiagnosticFilterJSON>;
}
export function createSingleDiagnosticError(
diag: PartialDiagnostic,
+ filters?: Array<DiagnosticFilterJSON>,
): DiagnosticsError {
- return new DiagnosticsError(diag.message, [diag]);
+ return new DiagnosticsError(diag.message, [diag], filters);
}
export function getDiagnosticsFromError(
err: Error,
): undefined | PartialDiagnostics {
if (err instanceof DiagnosticsError) {
- return err.diagnostics;
+ const processor = new DiagnosticsProcessor({
+ filters: err.filters,
+ });
+ processor.addDiagnostics(err.diagnostics);
+ return processor.getPartialDiagnostics();
}
return undefined;

Add support for passing along suppressions in the bundler