Skip to content

Commit 5fdf911

Browse files
committed
chore: show enhanced syntax error for all syntax errors
1 parent 1a06c2c commit 5fdf911

File tree

2 files changed

+1
-2
lines changed

2 files changed

+1
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
- `[jest-resolve-dependencies]` Resolve mocks as dependencies ([#10713](https://github.com/facebook/jest/pull/10713))
1616
- `[jest-runtime]` Handle file URLs in dynamic imports ([#10744](https://github.com/facebook/jest/pull/10744))
1717
- `[jest-transform]` Link to ESM docs on syntax errors ([#10748](https://github.com/facebook/jest/pull/10748))
18+
- `[jest-transform]` Show enhanced `SyntaxError` message for all `SyntaxError`s ([#10749](https://github.com/facebook/jest/pull/10749))
1819

1920
### Chore & Maintenance
2021

packages/jest-transform/src/enhanceUnexpectedTokenMessage.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ export default function handlePotentialSyntaxError(
2323
if (
2424
// `instanceof` might come from the wrong context
2525
e.name === 'SyntaxError' &&
26-
(e.message.includes('Unexpected token') ||
27-
e.message.includes('Cannot use import')) &&
2826
!e.message.includes(' expected')
2927
) {
3028
throw enhanceUnexpectedTokenMessage(e);

0 commit comments

Comments
 (0)