Enable logical assignment by default in @babel/parser (#11860) (#11869)

This commit is contained in:
Vahagn Aharonian 2020-07-22 21:14:37 +04:00 committed by Huáng Jùnliàng
parent 0e985fb287
commit b651a6f6ab
19 changed files with 15 additions and 44 deletions

View File

@ -129,16 +129,6 @@ const pluginNameMap = {
url: "https://git.io/JfeDR", url: "https://git.io/JfeDR",
}, },
}, },
logicalAssignment: {
syntax: {
name: "@babel/plugin-syntax-logical-assignment-operators",
url: "https://git.io/vAlBp",
},
transform: {
name: "@babel/plugin-proposal-logical-assignment-operators",
url: "https://git.io/vAlRe",
},
},
moduleAttributes: { moduleAttributes: {
syntax: { syntax: {
name: "@babel/plugin-syntax-module-attributes", name: "@babel/plugin-syntax-module-attributes",
@ -226,6 +216,16 @@ const pluginNameMap = {
url: "https://git.io/vb4yp", url: "https://git.io/vb4yp",
}, },
}, },
logicalAssignment: {
syntax: {
name: "@babel/plugin-syntax-logical-assignment-operators",
url: "https://git.io/vAlBp",
},
transform: {
name: "@babel/plugin-proposal-logical-assignment-operators",
url: "https://git.io/vAlRe",
},
},
nullishCoalescingOperator: { nullishCoalescingOperator: {
syntax: { syntax: {
name: "@babel/plugin-syntax-nullish-coalescing-operator", name: "@babel/plugin-syntax-nullish-coalescing-operator",

View File

@ -804,10 +804,10 @@ describe("api", function () {
options, options,
function (err) { function (err) {
expect(err.message).toMatch( expect(err.message).toMatch(
"Support for the experimental syntax 'logicalAssignment' isn't currently enabled (1:3):", "Support for the experimental syntax 'doExpressions' isn't currently enabled (1:2):",
); );
expect(err.message).toMatch( expect(err.message).toMatch(
"Add @babel/plugin-proposal-logical-assignment-operators (https://git.io/vAlRe) to the " + "Add @babel/plugin-proposal-do-expressions (https://git.io/vb4S3) to the " +
"'plugins' section of your Babel config to enable transformation.", "'plugins' section of your Babel config to enable transformation.",
); );
done(); done();

View File

@ -1 +1,3 @@
a ||= 2; (do {
x;
});

View File

@ -229,12 +229,6 @@ export default class ExpressionParser extends LValParser {
const operator = this.state.value; const operator = this.state.value;
node.operator = operator; node.operator = operator;
if (operator === "??=") {
this.expectPlugin("logicalAssignment");
}
if (operator === "||=" || operator === "&&=") {
this.expectPlugin("logicalAssignment");
}
if (this.match(tt.eq)) { if (this.match(tt.eq)) {
node.left = this.toAssignable(left); node.left = this.toAssignable(left);
refExpressionErrors.doubleProto = -1; // reset because double __proto__ is valid in assignment expression refExpressionErrors.doubleProto = -1; // reset because double __proto__ is valid in assignment expression

View File

@ -1,4 +0,0 @@
{
"plugins": [],
"throws": "This experimental syntax requires enabling the parser plugin: 'logicalAssignment' (1:2)"
}

View File

@ -1,3 +0,0 @@
{
"plugins": ["logicalAssignment"]
}

View File

@ -1,4 +0,0 @@
{
"plugins": [],
"throws": "This experimental syntax requires enabling the parser plugin: 'logicalAssignment' (1:2)"
}

View File

@ -1,3 +0,0 @@
{
"plugins": ["logicalAssignment"]
}

View File

@ -1,3 +0,0 @@
{
"throws": "This experimental syntax requires enabling the parser plugin: 'logicalAssignment' (1:2)"
}

View File

@ -1,3 +0,0 @@
{
"plugins": ["logicalAssignment"]
}