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 left-hand side assignment (#10416)
* Throw errors for invalid left-hand side assignment * Fix tests * FIx tests * Add tests from babel/babel#12933
- Loading branch information
Showing
12 changed files
with
248 additions
and
38 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
28 changes: 0 additions & 28 deletions
28
tests/js/logical-assignment/__snapshots__/jsfmt.spec.js.snap
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 was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,3 +1 @@ | ||
run_spec(__dirname, ["babel", "typescript"], { | ||
errors: { espree: ["invalid.js"], meriyah: ["invalid.js"] }, | ||
}); | ||
run_spec(__dirname, ["babel", "typescript"]); |
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
25 changes: 25 additions & 0 deletions
25
tests/misc/errors/js/assignment/__snapshots__/jsfmt.spec.js.snap
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,25 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`snippet: #0 [babel] format 1`] = ` | ||
"Invalid parenthesized assignment pattern (1:1) | ||
> 1 | ({}) = x; | ||
| ^" | ||
`; | ||
|
||
exports[`snippet: #0 [babel-ts] format 1`] = ` | ||
"Invalid parenthesized assignment pattern (1:1) | ||
> 1 | ({}) = x; | ||
| ^" | ||
`; | ||
|
||
exports[`snippet: #0 [espree] format 1`] = ` | ||
"Parenthesized pattern (1:1) | ||
> 1 | ({}) = x; | ||
| ^" | ||
`; | ||
|
||
exports[`snippet: #0 [meriyah] format 1`] = ` | ||
"[1:6]: Invalid left-hand side in assignment (1:6) | ||
> 1 | ({}) = x; | ||
| ^" | ||
`; |
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,7 @@ | ||
run_spec( | ||
{ | ||
dirname: __dirname, | ||
snippets: ["({}) = x;"], | ||
}, | ||
["babel", "babel-ts", "espree", "meriyah"] | ||
); |
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,6 @@ | ||
// https://github.com/babel/babel/pull/12933/files | ||
(<number>x) = null; | ||
(x!) = null; | ||
(a as any) = null; | ||
(a as number) = 42; | ||
((a as any) as string) = null; |
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