Skip to content

Commit

Permalink
Enable nullish coalescing by default in @babel/parser (#10819)
Browse files Browse the repository at this point in the history
* move files, remove hasPlugin() & expectPlugin()

* restore permissions
  • Loading branch information
layershifter authored and nicolo-ribaudo committed Jan 10, 2020
1 parent 5b907e9 commit c3388ea
Show file tree
Hide file tree
Showing 41 changed files with 13 additions and 54 deletions.
20 changes: 10 additions & 10 deletions packages/babel-core/src/parser/util/missing-plugin-helper.js
Expand Up @@ -113,16 +113,6 @@ const pluginNameMap = {
url: "https://git.io/vAlRe",
},
},
nullishCoalescingOperator: {
syntax: {
name: "@babel/plugin-syntax-nullish-coalescing-operator",
url: "https://git.io/vb4yx",
},
transform: {
name: "@babel/plugin-proposal-nullish-coalescing-operator",
url: "https://git.io/vb4Se",
},
},
numericSeparator: {
syntax: {
name: "@babel/plugin-syntax-numeric-separator",
Expand Down Expand Up @@ -188,6 +178,16 @@ const pluginNameMap = {
url: "https://git.io/vb4yp",
},
},
nullishCoalescingOperator: {
syntax: {
name: "@babel/plugin-syntax-nullish-coalescing-operator",
url: "https://git.io/vb4yx",
},
transform: {
name: "@babel/plugin-proposal-nullish-coalescing-operator",
url: "https://git.io/vb4Se",
},
},
objectRestSpread: {
syntax: {
name: "@babel/plugin-syntax-object-rest-spread",
Expand Down

This file was deleted.

3 changes: 0 additions & 3 deletions packages/babel-parser/src/parser/expression.js
Expand Up @@ -196,7 +196,6 @@ export default class ExpressionParser extends LValParser {
node.operator = operator;

if (operator === "??=") {
this.expectPlugin("nullishCoalescingOperator");
this.expectPlugin("logicalAssignment");
}
if (operator === "||=" || operator === "&&=") {
Expand Down Expand Up @@ -333,8 +332,6 @@ export default class ExpressionParser extends LValParser {
this.expectPlugin("pipelineOperator");
this.state.inPipeline = true;
this.checkPipelineAtInfixOperator(left, leftStartPos);
} else if (op === tt.nullishCoalescing) {
this.expectPlugin("nullishCoalescingOperator");
}

this.next();
Expand Down
@@ -1,4 +1,4 @@
{
"plugins": ["nullishCoalescingOperator", "estree"],
"plugins": ["estree"],
"throws": "Nullish coalescing operator(??) requires parens when mixing with logical operators (1:0)"
}
@@ -1,4 +1,3 @@
{
"plugins": ["nullishCoalescingOperator"],
"throws": "Nullish coalescing operator(??) requires parens when mixing with logical operators (1:5)"
}
@@ -1,4 +1,3 @@
{
"plugins": ["nullishCoalescingOperator"],
"throws": "Nullish coalescing operator(??) requires parens when mixing with logical operators (1:10)"
}
@@ -1,4 +1,4 @@
{
"plugins": ["nullishCoalescingOperator", "estree"],
"plugins": ["estree"],
"throws": "Nullish coalescing operator(??) requires parens when mixing with logical operators (1:0)"
}
@@ -1,6 +1,5 @@
{
"plugins": [
"nullishCoalescingOperator",
["pipelineOperator", { "proposal": "minimal" }]
]
}

This file was deleted.

This file was deleted.

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

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

0 comments on commit c3388ea

Please sign in to comment.