Skip to content

Commit 7f9210c

Browse files
committed
feat(fmt): improve formatting check output
1 parent 510d22b commit 7f9210c

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

‎packages/rstack/src/fmt/cli.ts‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ const logFmtResult = (result: FmtRunResult, mode: FmtMode, cwd: string): void =>
9494
logger.success(displayPath);
9595
} else if (file.status === 'different') {
9696
differentCount++;
97-
logger[mode === 'check' ? 'warn' : 'log'](displayPath);
97+
logger[mode === 'check' ? 'error' : 'log'](displayPath);
9898
} else if (file.status === 'error') {
9999
errorCount++;
100100
logger.error(`${displayPath}: ${String(file.error)}`);
@@ -107,9 +107,9 @@ const logFmtResult = (result: FmtRunResult, mode: FmtMode, cwd: string): void =>
107107

108108
if (differentCount > 0) {
109109
const files = differentCount === 1 ? 'file' : 'files';
110-
logger.warn(
111-
`Code style issues found in ${differentCount} ${files}. Run rs fmt --write to fix.`,
112-
);
110+
const count = color.bold(color.red(differentCount));
111+
const writeCommand = color.cyan('rs fmt --write');
112+
logger.error(`Code style issues found in ${count} ${files}. Run ${writeCommand} to fix.`);
113113
} else if (errorCount === 0) {
114114
logger.success('All matched files are correctly formatted.');
115115
}

‎packages/rstack/tests/cli/fmt/index.test.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,9 +222,9 @@ test('checks formatting without writing files', () => {
222222

223223
expect(result.status).toBe(1);
224224
expect(result.stdout).toBe('start Checking formatting...\n');
225-
expect(result.stderr).toContain('warn index.ts');
225+
expect(result.stderr).toContain('error index.ts');
226226
expect(result.stderr).toContain(
227-
'warn Code style issues found in 1 file. Run rs fmt --write to fix.',
227+
'error Code style issues found in 1 file. Run rs fmt --write to fix.',
228228
);
229229
expect(readProjectFile('index.ts')).toBe(source);
230230

0 commit comments

Comments
 (0)