Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Throw errors for invalid
TSEmptyBodyFunctionExpression
node (#12982)
- Loading branch information
Showing
6 changed files
with
195 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#### Stop parsing invalid code (#12982 by @fisker) | ||
|
||
<!-- prettier-ignore --> | ||
```tsx | ||
// Input | ||
const object = ({ methodName() }); | ||
|
||
// Prettier stable | ||
const object = { methodName(); }; | ||
|
||
// Prettier main | ||
SyntaxError: Unexpected token. (1:29) | ||
> 1 | const object = ({ methodName() }); | ||
| ^^ | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
"use strict"; | ||
const createError = require("../../../common/parser-create-error.js"); | ||
|
||
function throwSyntaxError(node, message) { | ||
const { start, end } = node.loc; | ||
throw createError(message, { | ||
start: { line: start.line, column: start.column + 1 }, | ||
end: { line: end.line, column: end.column + 1 }, | ||
}); | ||
} | ||
|
||
module.exports = throwSyntaxError; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters