Fix TS. Add advice to unused suppression
MODIFY
packages/@romejs/diagnostics/DiagnosticsProcessor.ts
packages/@romejs/diagnostics/DiagnosticsProcessor.ts
@@ -371,8 +371,8 @@ export default class DiagnosticsProcessor {
}
diagnostics.push({
- location: suppression.loc,
- description: descriptions.SUPPRESSIONS.UNUSED,
+ location: suppression.commentLocation,
+ description: descriptions.SUPPRESSIONS.UNUSED(suppression),
});
}

MODIFY
packages/@romejs/diagnostics/descriptions.ts
packages/@romejs/diagnostics/descriptions.ts
@@ -11,6 +11,7 @@ import {
DiagnosticBlessedMessage,
DiagnosticDescription,
DiagnosticLocation,
+ DiagnosticSuppression,
} from './types';
import {escapeMarkup, markup} from '@romejs/string-markup';
import stringDiff from '@romejs/string-diff';
@@ -781,9 +782,30 @@ export const descriptions = createMessages({
}),
},
SUPPRESSIONS: {
- UNUSED: {
+ UNUSED: (suppression: DiagnosticSuppression) => {
+ let description = {
+ next: 'next line',
+ current: 'current line',
+ statement: 'next statement',
+ }[suppression.type];
+
+ if (suppression.startLine === suppression.endLine) {
+ description += ` line ${suppression.startLine}`;
+ } else {
+ description += ` lines ${suppression.startLine}-${suppression.endLine}`;
+ }
+
+ return {
message: 'Unused suppression. Did not hide any errors.',
category: 'suppressions/unused',
+ advice: [
+ {
+ type: 'log',
+ category: 'info',
+ text: `This suppression prefixes hides the <emphasis>${description}</emphasis>`,
+ },
+ ],
+ };
},
MISSING_SPACE: {
category: 'suppressions/missingSpace',

MODIFY
packages/@romejs/diagnostics/types.ts
packages/@romejs/diagnostics/types.ts
@@ -24,7 +24,7 @@ export type DiagnosticFilter = {
export type DiagnosticFilters = Array<DiagnosticFilter>;
-export type DiagnosticSuppressionType = 'next' | 'current' | 'range';
+export type DiagnosticSuppressionType = 'next' | 'current' | 'statement';
export type DiagnosticSuppression = {
type: DiagnosticSuppressionType;

MODIFY
packages/@romejs/js-compiler/suppressions.ts
packages/@romejs/js-compiler/suppressions.ts
@@ -139,7 +139,7 @@ function extractSuppressionsFromComment(
});
continue;
} else {
- suppressionType = 'range';
+ suppressionType = 'statement';
startLine = nextNode.loc.start.line;
endLine = nextNode.loc.end.line;
}

Fix TS. Add advice to unused suppression