Add info when pending fixes are available in lint
MODIFY
packages/@romejs/cli-diagnostics/DiagnosticsPrinter.ts
packages/@romejs/cli-diagnostics/DiagnosticsPrinter.ts
@@ -86,7 +86,7 @@ function equalPosition(
return true;
}
-type BeforeFooterPrintFn = (reporter: Reporter) => void;
+type BeforeFooterPrintFn = (reporter: Reporter, error: boolean) => void;
export const DEFAULT_PRINTER_FLAGS: DiagnosticsPrinterFlags = {
grep: '',
@@ -525,15 +525,17 @@ export default class DiagnosticsPrinter extends Error {
footer() {
const {reporter, problemCount} = this;
- if (problemCount > 0) {
+ const isError = problemCount > 0;
+
+ if (isError) {
reporter.hr();
}
for (const handler of this.beforeFooterPrint) {
- handler(reporter);
+ handler(reporter, isError);
}
- if (problemCount > 0) {
+ if (isError) {
this.footerError();
} else {
this.footerSuccess();

MODIFY
packages/@romejs/core/master/linter/Linter.ts
packages/@romejs/core/master/linter/Linter.ts
@@ -10,7 +10,6 @@ import CompilerLinter from './CompilerLinter';
import {LINTABLE_EXTENSIONS} from '@romejs/core/common/fileHandlers';
import {AbsoluteFilePathSet} from '@romejs/path';
import DependencyGraph from '../dependencies/DependencyGraph';
-import {humanizeNumber} from '@romejs/string-utils';
export default class Linter {
constructor(req: MasterRequest, fix: boolean) {
@@ -59,7 +58,21 @@ export default class Linter {
extensions: LINTABLE_EXTENSIONS,
});
- printer.onBeforeFooterPrint(() => {
+ printer.onBeforeFooterPrint((reporter, isError) => {
+ if (isError) {
+ let hasPendingFixes = false;
+
+ for (const {category} of printer.processor.getPartialDiagnostics()) {
+ if (category === 'lint/pendingFixes') {
+ hasPendingFixes = true;
+ break;
+ }
+ }
+
+ if (hasPendingFixes) {
+ reporter.info('Fixes available. Run <command>rome lint --fix</command> to apply.');
+ }
+ } else {
const fileCount = paths.size;
if (fileCount === 0) {
reporter.warn('No files linted');
@@ -67,9 +80,10 @@ export default class Linter {
reporter.info(`<emphasis>1</emphasis> file linted`);
} else {
reporter.info(
- `<emphasis>${humanizeNumber(fileCount)}</emphasis> files linted`,
+ `<number emphasis>${fileCount}</number> files linted`,
);
}
+ }
});
// Add a filter so that only files that are explicitly referenced will be included

MODIFY
packages/@romejs/js-generator/Generator.ts
packages/@romejs/js-generator/Generator.ts
@@ -355,6 +355,7 @@ export default class Generator {
return;
}
+ this.buf.removeTrailing(' ');
this.append('\n');
}

Add info when pending fixes are available in lint