Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Better error for disallowed trailing commas/parameters after rest ele…
…ments (#9046) * handle disordered rest parameter in function expressions * remove spaces [lint] * polish function parameters validation * add test with arrow function and comma after rest parameter [babel-parser]
- Loading branch information
1 parent
61c1c77
commit 445b141
Showing
13 changed files
with
49 additions
and
11 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
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
2 changes: 1 addition & 1 deletion
2
packages/babel-parser/test/fixtures/core/uncategorised/396/options.json
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,3 @@ | ||
{ | ||
"throws": "Unexpected token, expected \")\" (1:18)" | ||
"throws": "Rest parameter must be last formal parameter (1:18)" | ||
} |
6 changes: 6 additions & 0 deletions
6
packages/babel-parser/test/fixtures/core/uncategorised/555/input.js
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 @@ | ||
function foo ( | ||
first, | ||
...second, | ||
third, | ||
) { | ||
}; |
4 changes: 4 additions & 0 deletions
4
packages/babel-parser/test/fixtures/core/uncategorised/555/options.json
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,4 @@ | ||
{ | ||
"throws": "Rest parameter must be last formal parameter (3:13)" | ||
} | ||
|
1 change: 1 addition & 0 deletions
1
packages/babel-parser/test/fixtures/es2015/arrow-functions/comma-after-rest-param/input.js
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 @@ | ||
(...rest,) => {} |
3 changes: 3 additions & 0 deletions
3
...ges/babel-parser/test/fixtures/es2015/arrow-functions/comma-after-rest-param/options.json
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,3 @@ | ||
{ | ||
"throws": "A trailing comma is not permitted after the rest element (1:8)" | ||
} |
5 changes: 5 additions & 0 deletions
5
packages/babel-parser/test/fixtures/es2015/arrow-functions/invalid-rest-in-params/input.js
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,5 @@ | ||
( | ||
first, | ||
...second, | ||
third | ||
) => {}; |
4 changes: 4 additions & 0 deletions
4
...ges/babel-parser/test/fixtures/es2015/arrow-functions/invalid-rest-in-params/options.json
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,4 @@ | ||
{ | ||
"throws": "Rest parameter must be last formal parameter (3:13)" | ||
} | ||
|
2 changes: 1 addition & 1 deletion
2
packages/babel-parser/test/fixtures/es2015/uncategorised/277/options.json
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,3 @@ | ||
{ | ||
"throws": "Unexpected token, expected \")\" (1:18)" | ||
"throws": "Rest parameter must be last formal parameter (1:18)" | ||
} |
2 changes: 1 addition & 1 deletion
2
packages/babel-parser/test/fixtures/es2015/uncategorised/283/options.json
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,3 @@ | ||
{ | ||
"throws": "Unexpected token, expected \")\" (1:5)" | ||
"throws": "Rest parameter must be last formal parameter (1:5)" | ||
} |
2 changes: 1 addition & 1 deletion
2
...-parser/test/fixtures/esprima/es2015-arrow-function/arrow-with-multiple-rest/options.json
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,3 @@ | ||
{ | ||
"throws": "Unexpected token, expected \")\" (1:5)" | ||
"throws": "Rest parameter must be last formal parameter (1:5)" | ||
} |
2 changes: 1 addition & 1 deletion
2
packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0258/options.json
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,3 @@ | ||
{ | ||
"throws": "Unexpected token, expected \")\" (1:18)" | ||
"throws": "Rest parameter must be last formal parameter (1:18)" | ||
} |