Better error for disallowed trailing commas/parameters after rest elements (#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]
This commit is contained in:
committed by
Nicolò Ribaudo
parent
61c1c77a28
commit
445b14148e
@@ -1,3 +1,3 @@
|
||||
{
|
||||
"throws": "Unexpected token, expected \")\" (1:18)"
|
||||
"throws": "Rest parameter must be last formal parameter (1:18)"
|
||||
}
|
||||
|
||||
6
packages/babel-parser/test/fixtures/core/uncategorised/555/input.js
vendored
Normal file
6
packages/babel-parser/test/fixtures/core/uncategorised/555/input.js
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
function foo (
|
||||
first,
|
||||
...second,
|
||||
third,
|
||||
) {
|
||||
};
|
||||
4
packages/babel-parser/test/fixtures/core/uncategorised/555/options.json
vendored
Normal file
4
packages/babel-parser/test/fixtures/core/uncategorised/555/options.json
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"throws": "Rest parameter must be last formal parameter (3:13)"
|
||||
}
|
||||
|
||||
1
packages/babel-parser/test/fixtures/es2015/arrow-functions/comma-after-rest-param/input.js
vendored
Normal file
1
packages/babel-parser/test/fixtures/es2015/arrow-functions/comma-after-rest-param/input.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
(...rest,) => {}
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"throws": "A trailing comma is not permitted after the rest element (1:8)"
|
||||
}
|
||||
5
packages/babel-parser/test/fixtures/es2015/arrow-functions/invalid-rest-in-params/input.js
vendored
Normal file
5
packages/babel-parser/test/fixtures/es2015/arrow-functions/invalid-rest-in-params/input.js
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
(
|
||||
first,
|
||||
...second,
|
||||
third
|
||||
) => {};
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"throws": "Rest parameter must be last formal parameter (3:13)"
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
{
|
||||
"throws": "Unexpected token, expected \")\" (1:18)"
|
||||
"throws": "Rest parameter must be last formal parameter (1:18)"
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
{
|
||||
"throws": "Unexpected token, expected \")\" (1:5)"
|
||||
"throws": "Rest parameter must be last formal parameter (1:5)"
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
{
|
||||
"throws": "Unexpected token, expected \")\" (1:5)"
|
||||
"throws": "Rest parameter must be last formal parameter (1:5)"
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
{
|
||||
"throws": "Unexpected token, expected \")\" (1:18)"
|
||||
"throws": "Rest parameter must be last formal parameter (1:18)"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user