Bring pipelineOperator flag in line with minimal
The minimal proposal requires parentheses around arrow functions and bans await from the pipeline.
This commit is contained in:
committed by
Nicolò Ribaudo
parent
1a6855eff2
commit
7142a79eb9
1
packages/babylon/test/fixtures/experimental/pipeline-operator/arrow-requires-parens/input.js
vendored
Normal file
1
packages/babylon/test/fixtures/experimental/pipeline-operator/arrow-requires-parens/input.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
10 |> x => x + 1;
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"plugins": ["pipelineOperator"],
|
||||
"throws": "Unexpected arrow \"=>\" after pipeline body; arrow function in pipeline body must be parenthesized (1:6)"
|
||||
}
|
||||
3
packages/babylon/test/fixtures/experimental/pipeline-operator/await-requires-parens/input.js
vendored
Normal file
3
packages/babylon/test/fixtures/experimental/pipeline-operator/await-requires-parens/input.js
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
async function foo() {
|
||||
return a |> (await f) |> g;
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"plugins": ["pipelineOperator"]
|
||||
}
|
||||
204
packages/babylon/test/fixtures/experimental/pipeline-operator/await-requires-parens/output.json
vendored
Normal file
204
packages/babylon/test/fixtures/experimental/pipeline-operator/await-requires-parens/output.json
vendored
Normal file
@@ -0,0 +1,204 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start": 0,
|
||||
"end": 54,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 1
|
||||
}
|
||||
},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start": 0,
|
||||
"end": 54,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 1
|
||||
}
|
||||
},
|
||||
"sourceType": "script",
|
||||
"body": [
|
||||
{
|
||||
"type": "FunctionDeclaration",
|
||||
"start": 0,
|
||||
"end": 54,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 1
|
||||
}
|
||||
},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start": 15,
|
||||
"end": 18,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 15
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 18
|
||||
},
|
||||
"identifierName": "foo"
|
||||
},
|
||||
"name": "foo"
|
||||
},
|
||||
"generator": false,
|
||||
"async": true,
|
||||
"params": [],
|
||||
"body": {
|
||||
"type": "BlockStatement",
|
||||
"start": 21,
|
||||
"end": 54,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 21
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 1
|
||||
}
|
||||
},
|
||||
"body": [
|
||||
{
|
||||
"type": "ReturnStatement",
|
||||
"start": 25,
|
||||
"end": 52,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 2
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 29
|
||||
}
|
||||
},
|
||||
"argument": {
|
||||
"type": "BinaryExpression",
|
||||
"start": 32,
|
||||
"end": 51,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 9
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 28
|
||||
}
|
||||
},
|
||||
"left": {
|
||||
"type": "BinaryExpression",
|
||||
"start": 32,
|
||||
"end": 46,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 9
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 23
|
||||
}
|
||||
},
|
||||
"left": {
|
||||
"type": "Identifier",
|
||||
"start": 32,
|
||||
"end": 33,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 9
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 10
|
||||
},
|
||||
"identifierName": "a"
|
||||
},
|
||||
"name": "a"
|
||||
},
|
||||
"operator": "|>",
|
||||
"right": {
|
||||
"type": "AwaitExpression",
|
||||
"start": 38,
|
||||
"end": 45,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 15
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 22
|
||||
}
|
||||
},
|
||||
"argument": {
|
||||
"type": "Identifier",
|
||||
"start": 44,
|
||||
"end": 45,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 21
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 22
|
||||
},
|
||||
"identifierName": "f"
|
||||
},
|
||||
"name": "f"
|
||||
},
|
||||
"extra": {
|
||||
"parenthesized": true,
|
||||
"parenStart": 37
|
||||
}
|
||||
}
|
||||
},
|
||||
"operator": "|>",
|
||||
"right": {
|
||||
"type": "Identifier",
|
||||
"start": 50,
|
||||
"end": 51,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 27
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 28
|
||||
},
|
||||
"identifierName": "g"
|
||||
},
|
||||
"name": "g"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
3
packages/babylon/test/fixtures/experimental/pipeline-operator/ban-await-f/input.js
vendored
Normal file
3
packages/babylon/test/fixtures/experimental/pipeline-operator/ban-await-f/input.js
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
async function foo() {
|
||||
return a |> await f |> g;
|
||||
}
|
||||
4
packages/babylon/test/fixtures/experimental/pipeline-operator/ban-await-f/options.json
vendored
Normal file
4
packages/babylon/test/fixtures/experimental/pipeline-operator/ban-await-f/options.json
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"plugins": ["pipelineOperator"],
|
||||
"throws": "Unexpected \"await\" after pipeline body; await must have parentheses in minimal proposal (2:14)"
|
||||
}
|
||||
3
packages/babylon/test/fixtures/experimental/pipeline-operator/ban-await/input.js
vendored
Normal file
3
packages/babylon/test/fixtures/experimental/pipeline-operator/ban-await/input.js
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
async function foo() {
|
||||
return a |> await |> f;
|
||||
}
|
||||
4
packages/babylon/test/fixtures/experimental/pipeline-operator/ban-await/options.json
vendored
Normal file
4
packages/babylon/test/fixtures/experimental/pipeline-operator/ban-await/options.json
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"plugins": ["pipelineOperator"],
|
||||
"throws": "Unexpected \"await\" after pipeline body; await must have parentheses in minimal proposal (2:14)"
|
||||
}
|
||||
@@ -1 +1 @@
|
||||
10 |> x => x + 1;
|
||||
10 |> (x => x + 1);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start": 0,
|
||||
"end": 17,
|
||||
"end": 19,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
@@ -9,13 +9,13 @@
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 17
|
||||
"column": 19
|
||||
}
|
||||
},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start": 0,
|
||||
"end": 17,
|
||||
"end": 19,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
@@ -23,7 +23,7 @@
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 17
|
||||
"column": 19
|
||||
}
|
||||
},
|
||||
"sourceType": "script",
|
||||
@@ -31,7 +31,7 @@
|
||||
{
|
||||
"type": "ExpressionStatement",
|
||||
"start": 0,
|
||||
"end": 17,
|
||||
"end": 19,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
@@ -39,13 +39,13 @@
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 17
|
||||
"column": 19
|
||||
}
|
||||
},
|
||||
"expression": {
|
||||
"type": "BinaryExpression",
|
||||
"start": 0,
|
||||
"end": 16,
|
||||
"end": 18,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
@@ -53,7 +53,7 @@
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 16
|
||||
"column": 18
|
||||
}
|
||||
},
|
||||
"left": {
|
||||
@@ -79,16 +79,16 @@
|
||||
"operator": "|>",
|
||||
"right": {
|
||||
"type": "ArrowFunctionExpression",
|
||||
"start": 6,
|
||||
"end": 16,
|
||||
"start": 7,
|
||||
"end": 17,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 6
|
||||
"column": 7
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 16
|
||||
"column": 17
|
||||
}
|
||||
},
|
||||
"id": null,
|
||||
@@ -97,16 +97,16 @@
|
||||
"params": [
|
||||
{
|
||||
"type": "Identifier",
|
||||
"start": 6,
|
||||
"end": 7,
|
||||
"start": 7,
|
||||
"end": 8,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 6
|
||||
"column": 7
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 7
|
||||
"column": 8
|
||||
},
|
||||
"identifierName": "x"
|
||||
},
|
||||
@@ -115,30 +115,30 @@
|
||||
],
|
||||
"body": {
|
||||
"type": "BinaryExpression",
|
||||
"start": 11,
|
||||
"end": 16,
|
||||
"start": 12,
|
||||
"end": 17,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 11
|
||||
"column": 12
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 16
|
||||
"column": 17
|
||||
}
|
||||
},
|
||||
"left": {
|
||||
"type": "Identifier",
|
||||
"start": 11,
|
||||
"end": 12,
|
||||
"start": 12,
|
||||
"end": 13,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 11
|
||||
"column": 12
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 12
|
||||
"column": 13
|
||||
},
|
||||
"identifierName": "x"
|
||||
},
|
||||
@@ -147,16 +147,16 @@
|
||||
"operator": "+",
|
||||
"right": {
|
||||
"type": "NumericLiteral",
|
||||
"start": 15,
|
||||
"end": 16,
|
||||
"start": 16,
|
||||
"end": 17,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 15
|
||||
"column": 16
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 16
|
||||
"column": 17
|
||||
}
|
||||
},
|
||||
"extra": {
|
||||
@@ -165,6 +165,10 @@
|
||||
},
|
||||
"value": 1
|
||||
}
|
||||
},
|
||||
"extra": {
|
||||
"parenthesized": true,
|
||||
"parenStart": 6
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user