temporarily forbid AssignmentExpression destructuring outside of ExpressionStatement
This commit is contained in:
parent
751ea7a12c
commit
8ff21b407d
@ -1,3 +1,7 @@
|
|||||||
|
# 1.12.8
|
||||||
|
|
||||||
|
* Temporarily forbid `AssignmentExpression` destructuring outside of `ExpressionStatement`.
|
||||||
|
|
||||||
# 1.12.7
|
# 1.12.7
|
||||||
|
|
||||||
* Update to latest `acorn-6to5`.
|
* Update to latest `acorn-6to5`.
|
||||||
|
|||||||
@ -146,6 +146,12 @@ exports.ExpressionStatement = function (node, parent, file, scope) {
|
|||||||
return nodes;
|
return nodes;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
exports.AssignmentExpression = function (node, parent, file) {
|
||||||
|
if (parent.type === "ExpressionStatement") return;
|
||||||
|
if (!t.isPattern(node.left)) return;
|
||||||
|
throw file.errorWithNode(node, "AssignmentExpression destructuring outside of a ExpressionStatement is forbidden due to current limitations");
|
||||||
|
};
|
||||||
|
|
||||||
exports.VariableDeclaration = function (node, parent, file, scope) {
|
exports.VariableDeclaration = function (node, parent, file, scope) {
|
||||||
if (t.isForInStatement(parent) || t.isForOfStatement(parent)) return;
|
if (t.isForInStatement(parent) || t.isForOfStatement(parent)) return;
|
||||||
|
|
||||||
|
|||||||
1
test/fixtures/transformation/destructuring/assignment-expression/actual.js
vendored
Normal file
1
test/fixtures/transformation/destructuring/assignment-expression/actual.js
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
console.log([x] = [123]);
|
||||||
3
test/fixtures/transformation/destructuring/assignment-expression/options.json
vendored
Normal file
3
test/fixtures/transformation/destructuring/assignment-expression/options.json
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"throws": "AssignmentExpression destructuring outside of a ExpressionStatement is forbidden due to current limitations"
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user