Skip to content

Commit fe692c2

Browse files
frankieyanclaude
andauthored
feat: show errors with --show-errors regardless of increase (#49)
* feat: show errors with --show-errors regardless of increase Previously, --check-files and --stage-record-file with --show-errors would only display detailed errors when errors had increased. Now errors are shown for all checked files that have errors, matching the behavior of check-all. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * docs: update README and rename "Detailed errors" to "Errors" - Clarify that --show-errors displays errors regardless of increase - Add example showing errors when no increase - Rename "Detailed errors:" heading to "Errors:" for brevity Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 42420a2 commit fe692c2

File tree

3 files changed

+50
-16
lines changed

3 files changed

+50
-16
lines changed

README.md

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,20 +100,28 @@ npx @doist/react-compiler-tracker
100100

101101
### `--show-errors`
102102

103-
Shows error information from the compiler including file path, line number, and error reason. Can be combined with any command.
103+
Shows error information from the compiler including file path, line number, and error reason. Can be combined with any command. Errors are displayed for all checked files regardless of whether they increased.
104104

105105
```bash
106106
npx @doist/react-compiler-tracker --check-files --show-errors src/components/Button.tsx
107107
```
108108

109-
Example output:
109+
Example output when errors have increased:
110110
```
111-
React Compiler errors have increased in:
111+
Errors:
112+
- src/components/Button.tsx: Line 15: Cannot access refs during render (x2)
113+
- src/components/Button.tsx: Line 28: Invalid hook usage
114+
❌ React Compiler errors have increased in:
112115
• src/components/Button.tsx: +3
113116
114-
Detailed errors:
117+
Please fix the errors and run the command again.
118+
```
119+
120+
When no new errors are introduced, you still see the existing errors:
121+
```
122+
Errors:
115123
- src/components/Button.tsx: Line 15: Cannot access refs during render (x2)
116-
- src/components/Button.tsx: Line 28: Invalid hook usage
124+
✅ No new React Compiler errors in checked files
117125
```
118126

119127
## Integration Examples

src/index.integration.test.mts

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ describe('CLI', () => {
4646
const output = runCLI(['--show-errors'])
4747

4848
expect(output).toContain('Found 4 React Compiler issues')
49-
expect(output).toContain('Detailed errors:')
49+
expect(output).toContain('Errors:')
5050
expect(output).toMatch(/Line \d+:/)
5151
})
5252
})
@@ -83,11 +83,23 @@ describe('CLI', () => {
8383
const output = runCLI(['--check-files', '--show-errors', 'src/bad-hook.ts'])
8484

8585
expect(output).toContain('React Compiler errors have increased')
86-
expect(output).toContain('Detailed errors:')
86+
expect(output).toContain('Errors:')
8787
expect(output).toContain(
8888
'src/bad-hook.ts: Line 6: Cannot access refs during render (x3)',
8989
)
9090
})
91+
92+
it('--show-errors shows errors even when no increase', () => {
93+
runCLI(['--overwrite'])
94+
const output = runCLI(['--check-files', '--show-errors', 'src/bad-hook.ts'])
95+
96+
expect(output).toContain('Errors:')
97+
expect(output).toContain(
98+
'src/bad-hook.ts: Line 6: Cannot access refs during render (x3)',
99+
)
100+
expect(output).not.toContain('React Compiler errors have increased')
101+
expect(output).toContain('✅ No new React Compiler errors')
102+
})
91103
})
92104

93105
describe('--overwrite', () => {
@@ -118,7 +130,7 @@ describe('CLI', () => {
118130
const output = runCLI(['--overwrite', '--show-errors'])
119131

120132
expect(output).toContain('Records saved to')
121-
expect(output).toContain('Detailed errors:')
133+
expect(output).toContain('Errors:')
122134
expect(output).toMatch(/Line \d+:/)
123135
})
124136
})
@@ -149,10 +161,21 @@ describe('CLI', () => {
149161
const output = runCLI(['--stage-record-file', '--show-errors', 'src/bad-hook.ts'])
150162

151163
expect(output).toContain('React Compiler errors have increased')
152-
expect(output).toContain('Detailed errors:')
164+
expect(output).toContain('Errors:')
153165
expect(output).toMatch(/Line \d+:/)
154166
})
155167

168+
it('--stage-record-file --show-errors shows errors even when no increase', () => {
169+
runCLI(['--overwrite'])
170+
const output = runCLI(['--stage-record-file', '--show-errors', 'src/bad-hook.ts'])
171+
172+
expect(output).toContain('Errors:')
173+
expect(output).toContain(
174+
'src/bad-hook.ts: Line 6: Cannot access refs during render (x3)',
175+
)
176+
expect(output).not.toContain('React Compiler errors have increased')
177+
})
178+
156179
it('checks provided files with existing records', () => {
157180
// First create records
158181
runCLI(['--overwrite'])

src/index.mts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ async function runOverwriteRecords({
166166
let message = `✅ Records saved to ${recordsFilePath}. Found ${totalErrors} total React Compiler issues across ${compilerErrors.size} files`
167167

168168
if (showErrors) {
169-
message += '\n\nDetailed errors:'
169+
message += '\n\nErrors:'
170170
message += formatErrorDetails()
171171
}
172172

@@ -333,7 +333,7 @@ async function runCheckAllFiles({
333333
let message = `Found ${totalErrors} React Compiler issues across ${compilerErrors.size} files`
334334

335335
if (showErrors) {
336-
message += '\n\nDetailed errors:'
336+
message += '\n\nErrors:'
337337
message += formatErrorDetails()
338338
}
339339

@@ -401,17 +401,20 @@ function checkErrorChanges({
401401
}
402402
}
403403

404+
// Show detailed errors for all checked files if requested
405+
if (showErrors) {
406+
const errorDetails = formatErrorDetails(filePaths)
407+
if (errorDetails) {
408+
console.log('Errors:' + errorDetails)
409+
}
410+
}
411+
404412
// Report increases (exit with error)
405413
if (increaseEntries.length) {
406414
const errorList = increaseEntries.map(([filePath, count]) => ` • ${filePath}: +${count}`)
407415

408416
let errorMessage = `React Compiler errors have increased in:\n${errorList.join('\n')}`
409417

410-
if (showErrors) {
411-
errorMessage += '\n\nDetailed errors:'
412-
errorMessage += formatErrorDetails(increaseEntries.map(([filePath]) => filePath))
413-
}
414-
415418
errorMessage += '\n\nPlease fix the errors and run the command again.'
416419

417420
exitWithError(errorMessage)

0 commit comments

Comments
 (0)