diff --git a/packages/babel-parser/src/parser/error-message.js b/packages/babel-parser/src/parser/error-message.js index 4953b5acd5..8b7f1c6182 100644 --- a/packages/babel-parser/src/parser/error-message.js +++ b/packages/babel-parser/src/parser/error-message.js @@ -140,6 +140,8 @@ export const ErrorMessages = makeErrorTemplates( 'Topic reference is used, but the pipelineOperator plugin was not passed a "proposal": "hack" or "smart" option.', PipeTopicUnbound: "Topic reference is unbound; it must be inside a pipe body.", + PipeTopicUnconfiguredToken: + 'Invalid topic token %0. In order to use %0 as a topic reference, the pipelineOperator plugin must be configured with { "proposal": "hack", "topicToken": "%0" }.', PipeTopicUnused: "Hack-style pipe body does not contain a topic reference; Hack-style pipes must use topic at least once.", diff --git a/packages/babel-parser/src/parser/expression.js b/packages/babel-parser/src/parser/expression.js index 8271ab1711..51156faed2 100644 --- a/packages/babel-parser/src/parser/expression.js +++ b/packages/babel-parser/src/parser/expression.js @@ -1227,10 +1227,32 @@ export default class ExpressionParser extends LValParser { return node; } + case tt.modulo: case tt.hash: { - node = this.maybeParseTopicReference(); - if (node) { - return node; + const pipeProposal = this.getPluginOption( + "pipelineOperator", + "proposal", + ); + + if (pipeProposal) { + // A pipe-operator proposal is active, + // although its configuration might not match the current token’s type. + node = this.startNode(); + const start = this.state.start; + const tokenType = this.state.type; + + // Consume the current token. + this.next(); + + // If the pipe-operator plugin’s configuration matches the current token’s type, + // then this will return `node`, will have been finished as a topic reference. + // Otherwise, this will throw a `PipeTopicUnconfiguredToken` error. + return this.finishTopicReference( + node, + start, + pipeProposal, + tokenType, + ); } } @@ -1253,64 +1275,64 @@ export default class ExpressionParser extends LValParser { } } - // https://github.com/js-choi/proposal-hack-pipes - maybeParseTopicReference(): ?N.Expression { - const pipeProposal = this.getPluginOption("pipelineOperator", "proposal"); + // This helper method attempts to finish the given `node` + // into a topic-reference node for the given `pipeProposal`. + // See . + // + // The method assumes that any topic token was consumed before it was called. + // + // If the `pipelineOperator` plugin is active, + // and if the given `tokenType` matches the plugin’s configuration, + // then this method will return the finished `node`. + // + // If the `pipelineOperator` plugin is active, + // but if the given `tokenType` does not match the plugin’s configuration, + // then this method will throw a `PipeTopicUnconfiguredToken` error. + finishTopicReference( + node: N.Node, + start: number, + pipeProposal: string, + tokenType: TokenType, + ): N.Expression { + if (this.testTopicReferenceConfiguration(pipeProposal, start, tokenType)) { + // The token matches the plugin’s configuration. + // The token is therefore a topic reference. - // `pipeProposal` is falsy when an input program - // contains a topic reference on its own, - // outside of a pipe expression, - // and without having turned on the pipelineOperator plugin. - if (pipeProposal) { - // A pipe-operator proposal is active. - - const { type: tokenType, start } = this.state; - - if (this.testTopicReferenceConfiguration(pipeProposal, tokenType)) { - // The token matches the plugin’s configuration. - // The token is therefore a topic reference. - - const node = this.startNode(); - - // Determine the node type for the topic reference - // that is appropriate for the active pipe-operator proposal. - let nodeType; - if (pipeProposal === "smart") { - nodeType = "PipelinePrimaryTopicReference"; - } else { - // The proposal must otherwise be "hack", - // as enforced by testTopicReferenceConfiguration. - nodeType = "TopicReference"; - } - - // Consume the token. - this.next(); - - // Register the topic reference so that its pipe body knows - // that its topic was used at least once. - this.registerTopicReference(); - - if (!this.topicReferenceIsAllowedInCurrentContext()) { - // The topic reference is not allowed in the current context: - // it is outside of a pipe body. - // Raise recoverable errors. - if (pipeProposal === "smart") { - this.raise(start, Errors.PrimaryTopicNotAllowed); - } else { - // In this case, `pipeProposal === "hack"` is true. - this.raise(start, Errors.PipeTopicUnbound); - } - } - - return this.finishNode(node, nodeType); + // Determine the node type for the topic reference + // that is appropriate for the active pipe-operator proposal. + let nodeType; + if (pipeProposal === "smart") { + nodeType = "PipelinePrimaryTopicReference"; } else { - // The token does not match the plugin’s configuration. - throw this.raise( - start, - Errors.PipeTopicUnconfiguredToken, - tokenType.label, - ); + // The proposal must otherwise be "hack", + // as enforced by testTopicReferenceConfiguration. + nodeType = "TopicReference"; } + + if (!this.topicReferenceIsAllowedInCurrentContext()) { + // The topic reference is not allowed in the current context: + // it is outside of a pipe body. + // Raise recoverable errors. + if (pipeProposal === "smart") { + this.raise(start, Errors.PrimaryTopicNotAllowed); + } else { + // In this case, `pipeProposal === "hack"` is true. + this.raise(start, Errors.PipeTopicUnbound); + } + } + + // Register the topic reference so that its pipe body knows + // that its topic was used at least once. + this.registerTopicReference(); + + return this.finishNode(node, nodeType); + } else { + // The token does not match the plugin’s configuration. + throw this.raise( + start, + Errors.PipeTopicUnconfiguredToken, + tokenType.label, + ); } } @@ -1325,6 +1347,7 @@ export default class ExpressionParser extends LValParser { // then an error is thrown. testTopicReferenceConfiguration( pipeProposal: string, + start: number, tokenType: TokenType, ): boolean { switch (pipeProposal) { @@ -1338,7 +1361,7 @@ export default class ExpressionParser extends LValParser { case "smart": return tokenType === tt.hash; default: - throw this.raise(this.state.start, Errors.PipeTopicRequiresHackPipes); + throw this.raise(start, Errors.PipeTopicRequiresHackPipes); } } diff --git a/packages/babel-parser/src/plugin-utils.js b/packages/babel-parser/src/plugin-utils.js index 73e2a63488..017d158bfc 100644 --- a/packages/babel-parser/src/plugin-utils.js +++ b/packages/babel-parser/src/plugin-utils.js @@ -90,6 +90,18 @@ export function validatePlugins(plugins: PluginList) { getPluginOption(plugins, "recordAndTuple", "syntaxType") === "hash"; if (proposal === "hack") { + if (hasPlugin(plugins, "placeholders")) { + throw new Error( + "Cannot combine placeholders plugin and Hack-style pipes.", + ); + } + + if (hasPlugin(plugins, "v8intrinsic")) { + throw new Error( + "Cannot combine v8intrinsic plugin and Hack-style pipes.", + ); + } + const topicToken = getPluginOption( plugins, "pipelineOperator", diff --git a/packages/babel-parser/src/tokenizer/types.js b/packages/babel-parser/src/tokenizer/types.js index 8b48205d1e..6b394ba4db 100644 --- a/packages/babel-parser/src/tokenizer/types.js +++ b/packages/babel-parser/src/tokenizer/types.js @@ -155,7 +155,7 @@ export const types: { [name: string]: TokenType } = { bitShift: createBinop("<>/>>>", 8), plusMin: new TokenType("+/-", { beforeExpr, binop: 9, prefix, startsExpr }), // startsExpr: required by v8intrinsic plugin - modulo: new TokenType("%", { beforeExpr, binop: 10, startsExpr }), + modulo: new TokenType("%", { binop: 10, startsExpr }), // unset `beforeExpr` as it can be `function *` star: new TokenType("*", { binop: 10 }), slash: createBinop("/", 10), diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-assignment-to-topic/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-assignment-to-topic/input.js new file mode 100644 index 0000000000..4411c99418 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-assignment-to-topic/input.js @@ -0,0 +1 @@ +value |> (# = 1); diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-assignment-to-topic/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-assignment-to-topic/options.json new file mode 100644 index 0000000000..be2b04c70d --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-assignment-to-topic/options.json @@ -0,0 +1,3 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "hack", "topicToken": "#" }]] +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-assignment-to-topic/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-assignment-to-topic/output.json new file mode 100644 index 0000000000..34b61d929f --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-assignment-to-topic/output.json @@ -0,0 +1,52 @@ +{ + "type": "File", + "start":0,"end":17,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":17}}, + "errors": [ + "SyntaxError: Invalid left-hand side in assignment expression. (1:10)" + ], + "program": { + "type": "Program", + "start":0,"end":17,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":17}}, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start":0,"end":17,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":17}}, + "expression": { + "type": "BinaryExpression", + "start":0,"end":16,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":16}}, + "left": { + "type": "Identifier", + "start":0,"end":5,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":5},"identifierName":"value"}, + "name": "value" + }, + "operator": "|>", + "right": { + "type": "AssignmentExpression", + "start":10,"end":15,"loc":{"start":{"line":1,"column":10},"end":{"line":1,"column":15}}, + "extra": { + "parenthesized": true, + "parenStart": 9 + }, + "operator": "=", + "left": { + "type": "TopicReference", + "start":10,"end":11,"loc":{"start":{"line":1,"column":10},"end":{"line":1,"column":11}} + }, + "right": { + "type": "NumericLiteral", + "start":14,"end":15,"loc":{"start":{"line":1,"column":14},"end":{"line":1,"column":15}}, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-percent-topic/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-percent-topic/input.js new file mode 100644 index 0000000000..d63a725e72 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-percent-topic/input.js @@ -0,0 +1 @@ +value |> % diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-percent-topic/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-percent-topic/options.json new file mode 100644 index 0000000000..2b8981cde5 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-percent-topic/options.json @@ -0,0 +1,4 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "hack", "topicToken": "#" }]], + "throws": "Invalid topic token %. In order to use % as a topic reference, the pipelineOperator plugin must be configured with { \"proposal\": \"hack\", \"topicToken\": \"%\" }. (1:9)" +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-placeholder-template/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-placeholder-template/input.js new file mode 100644 index 0000000000..df29480f70 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-placeholder-template/input.js @@ -0,0 +1 @@ +%%FUNCTION%%(0, %%VALUE%%); diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-placeholder-template/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-placeholder-template/options.json new file mode 100644 index 0000000000..9f692d54a8 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-placeholder-template/options.json @@ -0,0 +1,7 @@ +{ + "plugins": [ + ["pipelineOperator", { "proposal": "hack", "topicToken": "#" }], + "placeholders" + ], + "throws": "Cannot combine placeholders plugin and Hack-style pipes." +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-topic-then-digit/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-topic-then-digit/input.js new file mode 100644 index 0000000000..b18a6404b5 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-topic-then-digit/input.js @@ -0,0 +1 @@ +x |> #42; diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-topic-then-digit/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-topic-then-digit/options.json new file mode 100644 index 0000000000..c48dfc11c7 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-topic-then-digit/options.json @@ -0,0 +1,12 @@ +{ + "plugins": [ + [ + "pipelineOperator", + { + "proposal": "hack", + "topicToken": "#" + } + ] + ], + "throws": "Unexpected digit after hash token. (1:5)" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-v8intrinsic/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-v8intrinsic/input.js new file mode 100644 index 0000000000..4c6a361dae --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-v8intrinsic/input.js @@ -0,0 +1 @@ +%GetOptimizationStatus(f); diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-v8intrinsic/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-v8intrinsic/options.json new file mode 100644 index 0000000000..1446e68a7d --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-v8intrinsic/options.json @@ -0,0 +1,7 @@ +{ + "plugins": [ + ["pipelineOperator", { "proposal": "hack", "topicToken": "#" }], + "v8intrinsic" + ], + "throws": "Cannot combine v8intrinsic plugin and Hack-style pipes." +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-addition-with-topic-first/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-addition-with-topic-first/input.js new file mode 100644 index 0000000000..c50cec5672 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-addition-with-topic-first/input.js @@ -0,0 +1 @@ +value |> % + 1 diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-addition-with-topic-first/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-addition-with-topic-first/options.json new file mode 100644 index 0000000000..cfbb793386 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-addition-with-topic-first/options.json @@ -0,0 +1,3 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "hack", "topicToken": "%" }]] +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-addition-with-topic-first/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-addition-with-topic-first/output.json new file mode 100644 index 0000000000..4af6702b93 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-addition-with-topic-first/output.json @@ -0,0 +1,45 @@ +{ + "type": "File", + "start":0,"end":14,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":14}}, + "program": { + "type": "Program", + "start":0,"end":14,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":14}}, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start":0,"end":14,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":14}}, + "expression": { + "type": "BinaryExpression", + "start":0,"end":14,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":14}}, + "left": { + "type": "Identifier", + "start":0,"end":5,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":5},"identifierName":"value"}, + "name": "value" + }, + "operator": "|>", + "right": { + "type": "BinaryExpression", + "start":9,"end":14,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":14}}, + "left": { + "type": "TopicReference", + "start":9,"end":10,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":10}} + }, + "operator": "+", + "right": { + "type": "NumericLiteral", + "start":13,"end":14,"loc":{"start":{"line":1,"column":13},"end":{"line":1,"column":14}}, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-addition-with-topic-last/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-addition-with-topic-last/input.js new file mode 100644 index 0000000000..0b4a969895 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-addition-with-topic-last/input.js @@ -0,0 +1 @@ +value |> 1 + % diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-addition-with-topic-last/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-addition-with-topic-last/options.json new file mode 100644 index 0000000000..cfbb793386 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-addition-with-topic-last/options.json @@ -0,0 +1,3 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "hack", "topicToken": "%" }]] +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-addition-with-topic-last/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-addition-with-topic-last/output.json new file mode 100644 index 0000000000..09d48e0129 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-addition-with-topic-last/output.json @@ -0,0 +1,45 @@ +{ + "type": "File", + "start":0,"end":14,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":14}}, + "program": { + "type": "Program", + "start":0,"end":14,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":14}}, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start":0,"end":14,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":14}}, + "expression": { + "type": "BinaryExpression", + "start":0,"end":14,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":14}}, + "left": { + "type": "Identifier", + "start":0,"end":5,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":5},"identifierName":"value"}, + "name": "value" + }, + "operator": "|>", + "right": { + "type": "BinaryExpression", + "start":9,"end":14,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":14}}, + "left": { + "type": "NumericLiteral", + "start":9,"end":10,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":10}}, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + }, + "operator": "+", + "right": { + "type": "TopicReference", + "start":13,"end":14,"loc":{"start":{"line":1,"column":13},"end":{"line":1,"column":14}} + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-addition-without-topic/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-addition-without-topic/input.js new file mode 100644 index 0000000000..e952adac15 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-addition-without-topic/input.js @@ -0,0 +1 @@ +value |> a + b diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-addition-without-topic/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-addition-without-topic/options.json new file mode 100644 index 0000000000..cfbb793386 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-addition-without-topic/options.json @@ -0,0 +1,3 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "hack", "topicToken": "%" }]] +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-addition-without-topic/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-addition-without-topic/output.json new file mode 100644 index 0000000000..6565ae6d9a --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-addition-without-topic/output.json @@ -0,0 +1,45 @@ +{ + "type": "File", + "start":0,"end":14,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":14}}, + "errors": [ + "SyntaxError: Hack-style pipe body does not contain a topic reference; Hack-style pipes must use topic at least once. (1:9)" + ], + "program": { + "type": "Program", + "start":0,"end":14,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":14}}, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start":0,"end":14,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":14}}, + "expression": { + "type": "BinaryExpression", + "start":0,"end":14,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":14}}, + "left": { + "type": "Identifier", + "start":0,"end":5,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":5},"identifierName":"value"}, + "name": "value" + }, + "operator": "|>", + "right": { + "type": "BinaryExpression", + "start":9,"end":14,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":14}}, + "left": { + "type": "Identifier", + "start":9,"end":10,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":10},"identifierName":"a"}, + "name": "a" + }, + "operator": "+", + "right": { + "type": "Identifier", + "start":13,"end":14,"loc":{"start":{"line":1,"column":13},"end":{"line":1,"column":14},"identifierName":"b"}, + "name": "b" + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-arrow-function-parenthesized/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-arrow-function-parenthesized/input.js new file mode 100644 index 0000000000..4d87e86694 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-arrow-function-parenthesized/input.js @@ -0,0 +1 @@ +value |> (() => % + 1) diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-arrow-function-parenthesized/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-arrow-function-parenthesized/options.json new file mode 100644 index 0000000000..cfbb793386 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-arrow-function-parenthesized/options.json @@ -0,0 +1,3 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "hack", "topicToken": "%" }]] +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-arrow-function-parenthesized/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-arrow-function-parenthesized/output.json new file mode 100644 index 0000000000..3bb77cf7bf --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-arrow-function-parenthesized/output.json @@ -0,0 +1,57 @@ +{ + "type": "File", + "start":0,"end":22,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":22}}, + "program": { + "type": "Program", + "start":0,"end":22,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":22}}, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start":0,"end":22,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":22}}, + "expression": { + "type": "BinaryExpression", + "start":0,"end":22,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":22}}, + "left": { + "type": "Identifier", + "start":0,"end":5,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":5},"identifierName":"value"}, + "name": "value" + }, + "operator": "|>", + "right": { + "type": "ArrowFunctionExpression", + "start":10,"end":21,"loc":{"start":{"line":1,"column":10},"end":{"line":1,"column":21}}, + "extra": { + "parenthesized": true, + "parenStart": 9 + }, + "id": null, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BinaryExpression", + "start":16,"end":21,"loc":{"start":{"line":1,"column":16},"end":{"line":1,"column":21}}, + "left": { + "type": "TopicReference", + "start":16,"end":17,"loc":{"start":{"line":1,"column":16},"end":{"line":1,"column":17}} + }, + "operator": "+", + "right": { + "type": "NumericLiteral", + "start":20,"end":21,"loc":{"start":{"line":1,"column":20},"end":{"line":1,"column":21}}, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + } + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-arrow-function-unparenthesized/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-arrow-function-unparenthesized/input.js new file mode 100644 index 0000000000..e4b82b1250 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-arrow-function-unparenthesized/input.js @@ -0,0 +1 @@ +10 |> x => x + %; diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-arrow-function-unparenthesized/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-arrow-function-unparenthesized/options.json new file mode 100644 index 0000000000..d96fd5fb58 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-arrow-function-unparenthesized/options.json @@ -0,0 +1,12 @@ +{ + "plugins": [ + [ + "pipelineOperator", + { + "proposal": "hack", + "topicToken": "%" + } + ] + ], + "throws": "Unexpected => after pipeline body; any => expression acting as Hack-style pipe body must be parenthesized due to its loose operator precedence. (1:8)" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-assignment-logical-and/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-assignment-logical-and/input.js new file mode 100644 index 0000000000..6eed41b3b1 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-assignment-logical-and/input.js @@ -0,0 +1 @@ +value |> x &&= % diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-assignment-logical-and/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-assignment-logical-and/options.json new file mode 100644 index 0000000000..9b71dd195e --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-assignment-logical-and/options.json @@ -0,0 +1,12 @@ +{ + "plugins": [ + [ + "pipelineOperator", + { + "proposal": "hack", + "topicToken": "%" + } + ] + ], + "throws": "Unexpected &&= after pipeline body; any &&= expression acting as Hack-style pipe body must be parenthesized due to its loose operator precedence. (1:11)" +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-assignment-normal/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-assignment-normal/input.js new file mode 100644 index 0000000000..45f41c1eb9 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-assignment-normal/input.js @@ -0,0 +1 @@ +value |> [x, y] = % diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-assignment-normal/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-assignment-normal/options.json new file mode 100644 index 0000000000..363e504916 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-assignment-normal/options.json @@ -0,0 +1,12 @@ +{ + "plugins": [ + [ + "pipelineOperator", + { + "proposal": "hack", + "topicToken": "%" + } + ] + ], + "throws": "Unexpected = after pipeline body; any = expression acting as Hack-style pipe body must be parenthesized due to its loose operator precedence. (1:16)" +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-assignment-plus/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-assignment-plus/input.js new file mode 100644 index 0000000000..d7d3ae4de1 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-assignment-plus/input.js @@ -0,0 +1 @@ +value |> x += % diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-assignment-plus/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-assignment-plus/options.json new file mode 100644 index 0000000000..624a1edca2 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-assignment-plus/options.json @@ -0,0 +1,12 @@ +{ + "plugins": [ + [ + "pipelineOperator", + { + "proposal": "hack", + "topicToken": "%" + } + ] + ], + "throws": "Unexpected += after pipeline body; any += expression acting as Hack-style pipe body must be parenthesized due to its loose operator precedence. (1:11)" +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-assignment-to-topic/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-assignment-to-topic/input.js new file mode 100644 index 0000000000..e1e7080f6a --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-assignment-to-topic/input.js @@ -0,0 +1 @@ +value |> (% = 1); diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-assignment-to-topic/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-assignment-to-topic/options.json new file mode 100644 index 0000000000..cfbb793386 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-assignment-to-topic/options.json @@ -0,0 +1,3 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "hack", "topicToken": "%" }]] +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-assignment-to-topic/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-assignment-to-topic/output.json new file mode 100644 index 0000000000..34b61d929f --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-assignment-to-topic/output.json @@ -0,0 +1,52 @@ +{ + "type": "File", + "start":0,"end":17,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":17}}, + "errors": [ + "SyntaxError: Invalid left-hand side in assignment expression. (1:10)" + ], + "program": { + "type": "Program", + "start":0,"end":17,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":17}}, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start":0,"end":17,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":17}}, + "expression": { + "type": "BinaryExpression", + "start":0,"end":16,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":16}}, + "left": { + "type": "Identifier", + "start":0,"end":5,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":5},"identifierName":"value"}, + "name": "value" + }, + "operator": "|>", + "right": { + "type": "AssignmentExpression", + "start":10,"end":15,"loc":{"start":{"line":1,"column":10},"end":{"line":1,"column":15}}, + "extra": { + "parenthesized": true, + "parenStart": 9 + }, + "operator": "=", + "left": { + "type": "TopicReference", + "start":10,"end":11,"loc":{"start":{"line":1,"column":10},"end":{"line":1,"column":11}} + }, + "right": { + "type": "NumericLiteral", + "start":14,"end":15,"loc":{"start":{"line":1,"column":14},"end":{"line":1,"column":15}}, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-async-await/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-async-await/input.js new file mode 100644 index 0000000000..fd2ec1fd2c --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-async-await/input.js @@ -0,0 +1,3 @@ +async function f () { + return x |> await %; +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-async-await/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-async-await/options.json new file mode 100644 index 0000000000..cfbb793386 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-async-await/options.json @@ -0,0 +1,3 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "hack", "topicToken": "%" }]] +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-async-await/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-async-await/output.json new file mode 100644 index 0000000000..ce3d60256e --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-async-await/output.json @@ -0,0 +1,54 @@ +{ + "type": "File", + "start":0,"end":46,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}}, + "program": { + "type": "Program", + "start":0,"end":46,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}}, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start":0,"end":46,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}}, + "id": { + "type": "Identifier", + "start":15,"end":16,"loc":{"start":{"line":1,"column":15},"end":{"line":1,"column":16},"identifierName":"f"}, + "name": "f" + }, + "generator": false, + "async": true, + "params": [], + "body": { + "type": "BlockStatement", + "start":20,"end":46,"loc":{"start":{"line":1,"column":20},"end":{"line":3,"column":1}}, + "body": [ + { + "type": "ReturnStatement", + "start":24,"end":44,"loc":{"start":{"line":2,"column":2},"end":{"line":2,"column":22}}, + "argument": { + "type": "BinaryExpression", + "start":31,"end":43,"loc":{"start":{"line":2,"column":9},"end":{"line":2,"column":21}}, + "left": { + "type": "Identifier", + "start":31,"end":32,"loc":{"start":{"line":2,"column":9},"end":{"line":2,"column":10},"identifierName":"x"}, + "name": "x" + }, + "operator": "|>", + "right": { + "type": "AwaitExpression", + "start":36,"end":43,"loc":{"start":{"line":2,"column":14},"end":{"line":2,"column":21}}, + "argument": { + "type": "TopicReference", + "start":42,"end":43,"loc":{"start":{"line":2,"column":20},"end":{"line":2,"column":21}} + } + } + } + } + ], + "directives": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-class-expression-with-decorators/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-class-expression-with-decorators/input.js new file mode 100644 index 0000000000..410ab0bb4c --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-class-expression-with-decorators/input.js @@ -0,0 +1,9 @@ +value |> new ( + @classDecorator + class Thing { + @methodDecorator + method () { + return % + this.property; + } + } +); diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-class-expression-with-decorators/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-class-expression-with-decorators/options.json new file mode 100644 index 0000000000..9d7f220356 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-class-expression-with-decorators/options.json @@ -0,0 +1,6 @@ +{ + "plugins": [ + ["pipelineOperator", { "proposal": "hack", "topicToken": "%" }], + ["decorators", {"decoratorsBeforeExport": true}] + ] +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-class-expression-with-decorators/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-class-expression-with-decorators/output.json new file mode 100644 index 0000000000..5f6fe6d44c --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-class-expression-with-decorators/output.json @@ -0,0 +1,124 @@ +{ + "type": "File", + "start":0,"end":130,"loc":{"start":{"line":1,"column":0},"end":{"line":9,"column":2}}, + "program": { + "type": "Program", + "start":0,"end":130,"loc":{"start":{"line":1,"column":0},"end":{"line":9,"column":2}}, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start":0,"end":130,"loc":{"start":{"line":1,"column":0},"end":{"line":9,"column":2}}, + "expression": { + "type": "BinaryExpression", + "start":0,"end":129,"loc":{"start":{"line":1,"column":0},"end":{"line":9,"column":1}}, + "left": { + "type": "Identifier", + "start":0,"end":5,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":5},"identifierName":"value"}, + "name": "value" + }, + "operator": "|>", + "right": { + "type": "NewExpression", + "start":9,"end":129,"loc":{"start":{"line":1,"column":9},"end":{"line":9,"column":1}}, + "callee": { + "type": "ClassExpression", + "start":17,"end":127,"loc":{"start":{"line":2,"column":2},"end":{"line":8,"column":3}}, + "extra": { + "parenthesized": true, + "parenStart": 13 + }, + "decorators": [ + { + "type": "Decorator", + "start":17,"end":32,"loc":{"start":{"line":2,"column":2},"end":{"line":2,"column":17}}, + "expression": { + "type": "Identifier", + "start":18,"end":32,"loc":{"start":{"line":2,"column":3},"end":{"line":2,"column":17},"identifierName":"classDecorator"}, + "name": "classDecorator" + } + } + ], + "id": { + "type": "Identifier", + "start":41,"end":46,"loc":{"start":{"line":3,"column":8},"end":{"line":3,"column":13},"identifierName":"Thing"}, + "name": "Thing" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "start":47,"end":127,"loc":{"start":{"line":3,"column":14},"end":{"line":8,"column":3}}, + "body": [ + { + "type": "ClassMethod", + "start":53,"end":123,"loc":{"start":{"line":4,"column":4},"end":{"line":7,"column":5}}, + "decorators": [ + { + "type": "Decorator", + "start":53,"end":69,"loc":{"start":{"line":4,"column":4},"end":{"line":4,"column":20}}, + "expression": { + "type": "Identifier", + "start":54,"end":69,"loc":{"start":{"line":4,"column":5},"end":{"line":4,"column":20},"identifierName":"methodDecorator"}, + "name": "methodDecorator" + } + } + ], + "static": false, + "key": { + "type": "Identifier", + "start":74,"end":80,"loc":{"start":{"line":5,"column":4},"end":{"line":5,"column":10},"identifierName":"method"}, + "name": "method" + }, + "computed": false, + "kind": "method", + "id": null, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start":84,"end":123,"loc":{"start":{"line":5,"column":14},"end":{"line":7,"column":5}}, + "body": [ + { + "type": "ReturnStatement", + "start":92,"end":117,"loc":{"start":{"line":6,"column":6},"end":{"line":6,"column":31}}, + "argument": { + "type": "BinaryExpression", + "start":99,"end":116,"loc":{"start":{"line":6,"column":13},"end":{"line":6,"column":30}}, + "left": { + "type": "TopicReference", + "start":99,"end":100,"loc":{"start":{"line":6,"column":13},"end":{"line":6,"column":14}} + }, + "operator": "+", + "right": { + "type": "MemberExpression", + "start":103,"end":116,"loc":{"start":{"line":6,"column":17},"end":{"line":6,"column":30}}, + "object": { + "type": "ThisExpression", + "start":103,"end":107,"loc":{"start":{"line":6,"column":17},"end":{"line":6,"column":21}} + }, + "computed": false, + "property": { + "type": "Identifier", + "start":108,"end":116,"loc":{"start":{"line":6,"column":22},"end":{"line":6,"column":30},"identifierName":"property"}, + "name": "property" + } + } + } + } + ], + "directives": [] + } + } + ] + } + }, + "arguments": [] + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-class-expression-with-private-property/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-class-expression-with-private-property/input.js new file mode 100644 index 0000000000..bc16c3956b --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-class-expression-with-private-property/input.js @@ -0,0 +1,7 @@ +value |> new (class Thing { + #property; + + method () { + return % + this.#property; + } +}); diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-class-expression-with-private-property/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-class-expression-with-private-property/options.json new file mode 100644 index 0000000000..626290f4e5 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-class-expression-with-private-property/options.json @@ -0,0 +1,7 @@ +{ + "plugins": [ + ["pipelineOperator", { "proposal": "hack", "topicToken": "%" }], + "classPrivateProperties", + "classPrivateMethods" + ] +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-class-expression-with-private-property/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-class-expression-with-private-property/output.json new file mode 100644 index 0000000000..f6c7e7a65d --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-class-expression-with-private-property/output.json @@ -0,0 +1,121 @@ +{ + "type": "File", + "start":0,"end":94,"loc":{"start":{"line":1,"column":0},"end":{"line":7,"column":3}}, + "program": { + "type": "Program", + "start":0,"end":94,"loc":{"start":{"line":1,"column":0},"end":{"line":7,"column":3}}, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start":0,"end":94,"loc":{"start":{"line":1,"column":0},"end":{"line":7,"column":3}}, + "expression": { + "type": "BinaryExpression", + "start":0,"end":93,"loc":{"start":{"line":1,"column":0},"end":{"line":7,"column":2}}, + "left": { + "type": "Identifier", + "start":0,"end":5,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":5},"identifierName":"value"}, + "name": "value" + }, + "operator": "|>", + "right": { + "type": "NewExpression", + "start":9,"end":93,"loc":{"start":{"line":1,"column":9},"end":{"line":7,"column":2}}, + "callee": { + "type": "ClassExpression", + "start":14,"end":92,"loc":{"start":{"line":1,"column":14},"end":{"line":7,"column":1}}, + "extra": { + "parenthesized": true, + "parenStart": 13 + }, + "id": { + "type": "Identifier", + "start":20,"end":25,"loc":{"start":{"line":1,"column":20},"end":{"line":1,"column":25},"identifierName":"Thing"}, + "name": "Thing" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "start":26,"end":92,"loc":{"start":{"line":1,"column":26},"end":{"line":7,"column":1}}, + "body": [ + { + "type": "ClassPrivateProperty", + "start":30,"end":40,"loc":{"start":{"line":2,"column":2},"end":{"line":2,"column":12}}, + "static": false, + "key": { + "type": "PrivateName", + "start":30,"end":39,"loc":{"start":{"line":2,"column":2},"end":{"line":2,"column":11}}, + "id": { + "type": "Identifier", + "start":31,"end":39,"loc":{"start":{"line":2,"column":3},"end":{"line":2,"column":11},"identifierName":"property"}, + "name": "property" + } + }, + "value": null + }, + { + "type": "ClassMethod", + "start":44,"end":90,"loc":{"start":{"line":4,"column":2},"end":{"line":6,"column":3}}, + "static": false, + "key": { + "type": "Identifier", + "start":44,"end":50,"loc":{"start":{"line":4,"column":2},"end":{"line":4,"column":8},"identifierName":"method"}, + "name": "method" + }, + "computed": false, + "kind": "method", + "id": null, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start":54,"end":90,"loc":{"start":{"line":4,"column":12},"end":{"line":6,"column":3}}, + "body": [ + { + "type": "ReturnStatement", + "start":60,"end":86,"loc":{"start":{"line":5,"column":4},"end":{"line":5,"column":30}}, + "argument": { + "type": "BinaryExpression", + "start":67,"end":85,"loc":{"start":{"line":5,"column":11},"end":{"line":5,"column":29}}, + "left": { + "type": "TopicReference", + "start":67,"end":68,"loc":{"start":{"line":5,"column":11},"end":{"line":5,"column":12}} + }, + "operator": "+", + "right": { + "type": "MemberExpression", + "start":71,"end":85,"loc":{"start":{"line":5,"column":15},"end":{"line":5,"column":29}}, + "object": { + "type": "ThisExpression", + "start":71,"end":75,"loc":{"start":{"line":5,"column":15},"end":{"line":5,"column":19}} + }, + "computed": false, + "property": { + "type": "PrivateName", + "start":76,"end":85,"loc":{"start":{"line":5,"column":20},"end":{"line":5,"column":29}}, + "id": { + "type": "Identifier", + "start":77,"end":85,"loc":{"start":{"line":5,"column":21},"end":{"line":5,"column":29},"identifierName":"property"}, + "name": "property" + } + } + } + } + } + ], + "directives": [] + } + } + ] + } + }, + "arguments": [] + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-class-expression-without-private-property/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-class-expression-without-private-property/input.js new file mode 100644 index 0000000000..3a48cc58d7 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-class-expression-without-private-property/input.js @@ -0,0 +1 @@ +x |> class { constructor () { this.x = %; } } diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-class-expression-without-private-property/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-class-expression-without-private-property/options.json new file mode 100644 index 0000000000..cfbb793386 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-class-expression-without-private-property/options.json @@ -0,0 +1,3 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "hack", "topicToken": "%" }]] +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-class-expression-without-private-property/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-class-expression-without-private-property/output.json new file mode 100644 index 0000000000..201caee151 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-class-expression-without-private-property/output.json @@ -0,0 +1,89 @@ +{ + "type": "File", + "start":0,"end":45,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":45}}, + "program": { + "type": "Program", + "start":0,"end":45,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":45}}, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start":0,"end":45,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":45}}, + "expression": { + "type": "BinaryExpression", + "start":0,"end":45,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":45}}, + "left": { + "type": "Identifier", + "start":0,"end":1,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":1},"identifierName":"x"}, + "name": "x" + }, + "operator": "|>", + "right": { + "type": "ClassExpression", + "start":5,"end":45,"loc":{"start":{"line":1,"column":5},"end":{"line":1,"column":45}}, + "id": null, + "superClass": null, + "body": { + "type": "ClassBody", + "start":11,"end":45,"loc":{"start":{"line":1,"column":11},"end":{"line":1,"column":45}}, + "body": [ + { + "type": "ClassMethod", + "start":13,"end":43,"loc":{"start":{"line":1,"column":13},"end":{"line":1,"column":43}}, + "static": false, + "key": { + "type": "Identifier", + "start":13,"end":24,"loc":{"start":{"line":1,"column":13},"end":{"line":1,"column":24},"identifierName":"constructor"}, + "name": "constructor" + }, + "computed": false, + "kind": "constructor", + "id": null, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start":28,"end":43,"loc":{"start":{"line":1,"column":28},"end":{"line":1,"column":43}}, + "body": [ + { + "type": "ExpressionStatement", + "start":30,"end":41,"loc":{"start":{"line":1,"column":30},"end":{"line":1,"column":41}}, + "expression": { + "type": "AssignmentExpression", + "start":30,"end":40,"loc":{"start":{"line":1,"column":30},"end":{"line":1,"column":40}}, + "operator": "=", + "left": { + "type": "MemberExpression", + "start":30,"end":36,"loc":{"start":{"line":1,"column":30},"end":{"line":1,"column":36}}, + "object": { + "type": "ThisExpression", + "start":30,"end":34,"loc":{"start":{"line":1,"column":30},"end":{"line":1,"column":34}} + }, + "computed": false, + "property": { + "type": "Identifier", + "start":35,"end":36,"loc":{"start":{"line":1,"column":35},"end":{"line":1,"column":36},"identifierName":"x"}, + "name": "x" + } + }, + "right": { + "type": "TopicReference", + "start":39,"end":40,"loc":{"start":{"line":1,"column":39},"end":{"line":1,"column":40}} + } + } + } + ], + "directives": [] + } + } + ] + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-comma-topic-pair/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-comma-topic-pair/input.js new file mode 100644 index 0000000000..a7883788fe --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-comma-topic-pair/input.js @@ -0,0 +1 @@ +10 |> (%, %); diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-comma-topic-pair/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-comma-topic-pair/options.json new file mode 100644 index 0000000000..cfbb793386 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-comma-topic-pair/options.json @@ -0,0 +1,3 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "hack", "topicToken": "%" }]] +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-comma-topic-pair/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-comma-topic-pair/output.json new file mode 100644 index 0000000000..12c0cb49ed --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-comma-topic-pair/output.json @@ -0,0 +1,49 @@ +{ + "type": "File", + "start":0,"end":13,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":13}}, + "program": { + "type": "Program", + "start":0,"end":13,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":13}}, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start":0,"end":13,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":13}}, + "expression": { + "type": "BinaryExpression", + "start":0,"end":12,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":12}}, + "left": { + "type": "NumericLiteral", + "start":0,"end":2,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":2}}, + "extra": { + "rawValue": 10, + "raw": "10" + }, + "value": 10 + }, + "operator": "|>", + "right": { + "type": "SequenceExpression", + "start":7,"end":11,"loc":{"start":{"line":1,"column":7},"end":{"line":1,"column":11}}, + "extra": { + "parenthesized": true, + "parenStart": 6 + }, + "expressions": [ + { + "type": "TopicReference", + "start":7,"end":8,"loc":{"start":{"line":1,"column":7},"end":{"line":1,"column":8}} + }, + { + "type": "TopicReference", + "start":10,"end":11,"loc":{"start":{"line":1,"column":10},"end":{"line":1,"column":11}} + } + ] + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-computed-no-topic/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-computed-no-topic/input.js new file mode 100644 index 0000000000..5a02dee8ec --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-computed-no-topic/input.js @@ -0,0 +1 @@ +value |> a[b] diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-computed-no-topic/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-computed-no-topic/options.json new file mode 100644 index 0000000000..cfbb793386 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-computed-no-topic/options.json @@ -0,0 +1,3 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "hack", "topicToken": "%" }]] +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-computed-no-topic/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-computed-no-topic/output.json new file mode 100644 index 0000000000..3959a09863 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-computed-no-topic/output.json @@ -0,0 +1,45 @@ +{ + "type": "File", + "start":0,"end":13,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":13}}, + "errors": [ + "SyntaxError: Hack-style pipe body does not contain a topic reference; Hack-style pipes must use topic at least once. (1:9)" + ], + "program": { + "type": "Program", + "start":0,"end":13,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":13}}, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start":0,"end":13,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":13}}, + "expression": { + "type": "BinaryExpression", + "start":0,"end":13,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":13}}, + "left": { + "type": "Identifier", + "start":0,"end":5,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":5},"identifierName":"value"}, + "name": "value" + }, + "operator": "|>", + "right": { + "type": "MemberExpression", + "start":9,"end":13,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":13}}, + "object": { + "type": "Identifier", + "start":9,"end":10,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":10},"identifierName":"a"}, + "name": "a" + }, + "computed": true, + "property": { + "type": "Identifier", + "start":11,"end":12,"loc":{"start":{"line":1,"column":11},"end":{"line":1,"column":12},"identifierName":"b"}, + "name": "b" + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-division/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-division/input.js new file mode 100644 index 0000000000..34f42157ba --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-division/input.js @@ -0,0 +1 @@ +value |> % / 2 diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-division/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-division/options.json new file mode 100644 index 0000000000..cfbb793386 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-division/options.json @@ -0,0 +1,3 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "hack", "topicToken": "%" }]] +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-division/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-division/output.json new file mode 100644 index 0000000000..0c5a673e7b --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-division/output.json @@ -0,0 +1,45 @@ +{ + "type": "File", + "start":0,"end":14,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":14}}, + "program": { + "type": "Program", + "start":0,"end":14,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":14}}, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start":0,"end":14,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":14}}, + "expression": { + "type": "BinaryExpression", + "start":0,"end":14,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":14}}, + "left": { + "type": "Identifier", + "start":0,"end":5,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":5},"identifierName":"value"}, + "name": "value" + }, + "operator": "|>", + "right": { + "type": "BinaryExpression", + "start":9,"end":14,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":14}}, + "left": { + "type": "TopicReference", + "start":9,"end":10,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":10}} + }, + "operator": "/", + "right": { + "type": "NumericLiteral", + "start":13,"end":14,"loc":{"start":{"line":1,"column":13},"end":{"line":1,"column":14}}, + "extra": { + "rawValue": 2, + "raw": "2" + }, + "value": 2 + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-do-while-loop-and-topic-in-loop-body/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-do-while-loop-and-topic-in-loop-body/input.js new file mode 100644 index 0000000000..4d0b3dcf9c --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-do-while-loop-and-topic-in-loop-body/input.js @@ -0,0 +1 @@ +value |> do { do x += %; while (x < 50); } diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-do-while-loop-and-topic-in-loop-body/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-do-while-loop-and-topic-in-loop-body/options.json new file mode 100644 index 0000000000..59d88314f0 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-do-while-loop-and-topic-in-loop-body/options.json @@ -0,0 +1,3 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "hack", "topicToken": "%" }], "doExpressions"] +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-do-while-loop-and-topic-in-loop-body/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-do-while-loop-and-topic-in-loop-body/output.json new file mode 100644 index 0000000000..e14ccc735f --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-do-while-loop-and-topic-in-loop-body/output.json @@ -0,0 +1,80 @@ +{ + "type": "File", + "start":0,"end":42,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":42}}, + "program": { + "type": "Program", + "start":0,"end":42,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":42}}, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start":0,"end":42,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":42}}, + "expression": { + "type": "BinaryExpression", + "start":0,"end":42,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":42}}, + "left": { + "type": "Identifier", + "start":0,"end":5,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":5},"identifierName":"value"}, + "name": "value" + }, + "operator": "|>", + "right": { + "type": "DoExpression", + "start":9,"end":42,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":42}}, + "async": false, + "body": { + "type": "BlockStatement", + "start":12,"end":42,"loc":{"start":{"line":1,"column":12},"end":{"line":1,"column":42}}, + "body": [ + { + "type": "DoWhileStatement", + "start":14,"end":40,"loc":{"start":{"line":1,"column":14},"end":{"line":1,"column":40}}, + "body": { + "type": "ExpressionStatement", + "start":17,"end":24,"loc":{"start":{"line":1,"column":17},"end":{"line":1,"column":24}}, + "expression": { + "type": "AssignmentExpression", + "start":17,"end":23,"loc":{"start":{"line":1,"column":17},"end":{"line":1,"column":23}}, + "operator": "+=", + "left": { + "type": "Identifier", + "start":17,"end":18,"loc":{"start":{"line":1,"column":17},"end":{"line":1,"column":18},"identifierName":"x"}, + "name": "x" + }, + "right": { + "type": "TopicReference", + "start":22,"end":23,"loc":{"start":{"line":1,"column":22},"end":{"line":1,"column":23}} + } + } + }, + "test": { + "type": "BinaryExpression", + "start":32,"end":38,"loc":{"start":{"line":1,"column":32},"end":{"line":1,"column":38}}, + "left": { + "type": "Identifier", + "start":32,"end":33,"loc":{"start":{"line":1,"column":32},"end":{"line":1,"column":33},"identifierName":"x"}, + "name": "x" + }, + "operator": "<", + "right": { + "type": "NumericLiteral", + "start":36,"end":38,"loc":{"start":{"line":1,"column":36},"end":{"line":1,"column":38}}, + "extra": { + "rawValue": 50, + "raw": "50" + }, + "value": 50 + } + } + } + ], + "directives": [] + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-do-while-loop-and-topic-in-loop-head/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-do-while-loop-and-topic-in-loop-head/input.js new file mode 100644 index 0000000000..23b6a53b95 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-do-while-loop-and-topic-in-loop-head/input.js @@ -0,0 +1 @@ +value |> do { do x += 1; while (x < %); } diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-do-while-loop-and-topic-in-loop-head/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-do-while-loop-and-topic-in-loop-head/options.json new file mode 100644 index 0000000000..59d88314f0 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-do-while-loop-and-topic-in-loop-head/options.json @@ -0,0 +1,3 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "hack", "topicToken": "%" }], "doExpressions"] +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-do-while-loop-and-topic-in-loop-head/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-do-while-loop-and-topic-in-loop-head/output.json new file mode 100644 index 0000000000..48f0ec3c67 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-do-while-loop-and-topic-in-loop-head/output.json @@ -0,0 +1,80 @@ +{ + "type": "File", + "start":0,"end":41,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":41}}, + "program": { + "type": "Program", + "start":0,"end":41,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":41}}, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start":0,"end":41,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":41}}, + "expression": { + "type": "BinaryExpression", + "start":0,"end":41,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":41}}, + "left": { + "type": "Identifier", + "start":0,"end":5,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":5},"identifierName":"value"}, + "name": "value" + }, + "operator": "|>", + "right": { + "type": "DoExpression", + "start":9,"end":41,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":41}}, + "async": false, + "body": { + "type": "BlockStatement", + "start":12,"end":41,"loc":{"start":{"line":1,"column":12},"end":{"line":1,"column":41}}, + "body": [ + { + "type": "DoWhileStatement", + "start":14,"end":39,"loc":{"start":{"line":1,"column":14},"end":{"line":1,"column":39}}, + "body": { + "type": "ExpressionStatement", + "start":17,"end":24,"loc":{"start":{"line":1,"column":17},"end":{"line":1,"column":24}}, + "expression": { + "type": "AssignmentExpression", + "start":17,"end":23,"loc":{"start":{"line":1,"column":17},"end":{"line":1,"column":23}}, + "operator": "+=", + "left": { + "type": "Identifier", + "start":17,"end":18,"loc":{"start":{"line":1,"column":17},"end":{"line":1,"column":18},"identifierName":"x"}, + "name": "x" + }, + "right": { + "type": "NumericLiteral", + "start":22,"end":23,"loc":{"start":{"line":1,"column":22},"end":{"line":1,"column":23}}, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + } + } + }, + "test": { + "type": "BinaryExpression", + "start":32,"end":37,"loc":{"start":{"line":1,"column":32},"end":{"line":1,"column":37}}, + "left": { + "type": "Identifier", + "start":32,"end":33,"loc":{"start":{"line":1,"column":32},"end":{"line":1,"column":33},"identifierName":"x"}, + "name": "x" + }, + "operator": "<", + "right": { + "type": "TopicReference", + "start":36,"end":37,"loc":{"start":{"line":1,"column":36},"end":{"line":1,"column":37}} + } + } + } + ], + "directives": [] + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-for-await-of-loop-and-topic-in-loop-body/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-for-await-of-loop-and-topic-in-loop-body/input.js new file mode 100644 index 0000000000..660fdde3a8 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-for-await-of-loop-and-topic-in-loop-body/input.js @@ -0,0 +1,3 @@ +async function af () { + value |> do { for await (const e of sequence) %; } +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-for-await-of-loop-and-topic-in-loop-body/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-for-await-of-loop-and-topic-in-loop-body/options.json new file mode 100644 index 0000000000..ce2d1bb4c5 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-for-await-of-loop-and-topic-in-loop-body/options.json @@ -0,0 +1,6 @@ +{ + "plugins": [ + ["pipelineOperator", { "proposal": "hack", "topicToken": "%" }], + "doExpressions" + ] +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-for-await-of-loop-and-topic-in-loop-body/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-for-await-of-loop-and-topic-in-loop-body/output.json new file mode 100644 index 0000000000..8fbe9b326e --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-for-await-of-loop-and-topic-in-loop-body/output.json @@ -0,0 +1,93 @@ +{ + "type": "File", + "start":0,"end":77,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}}, + "program": { + "type": "Program", + "start":0,"end":77,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}}, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start":0,"end":77,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}}, + "id": { + "type": "Identifier", + "start":15,"end":17,"loc":{"start":{"line":1,"column":15},"end":{"line":1,"column":17},"identifierName":"af"}, + "name": "af" + }, + "generator": false, + "async": true, + "params": [], + "body": { + "type": "BlockStatement", + "start":21,"end":77,"loc":{"start":{"line":1,"column":21},"end":{"line":3,"column":1}}, + "body": [ + { + "type": "ExpressionStatement", + "start":25,"end":75,"loc":{"start":{"line":2,"column":2},"end":{"line":2,"column":52}}, + "expression": { + "type": "BinaryExpression", + "start":25,"end":75,"loc":{"start":{"line":2,"column":2},"end":{"line":2,"column":52}}, + "left": { + "type": "Identifier", + "start":25,"end":30,"loc":{"start":{"line":2,"column":2},"end":{"line":2,"column":7},"identifierName":"value"}, + "name": "value" + }, + "operator": "|>", + "right": { + "type": "DoExpression", + "start":34,"end":75,"loc":{"start":{"line":2,"column":11},"end":{"line":2,"column":52}}, + "async": false, + "body": { + "type": "BlockStatement", + "start":37,"end":75,"loc":{"start":{"line":2,"column":14},"end":{"line":2,"column":52}}, + "body": [ + { + "type": "ForOfStatement", + "start":39,"end":73,"loc":{"start":{"line":2,"column":16},"end":{"line":2,"column":50}}, + "await": true, + "left": { + "type": "VariableDeclaration", + "start":50,"end":57,"loc":{"start":{"line":2,"column":27},"end":{"line":2,"column":34}}, + "declarations": [ + { + "type": "VariableDeclarator", + "start":56,"end":57,"loc":{"start":{"line":2,"column":33},"end":{"line":2,"column":34}}, + "id": { + "type": "Identifier", + "start":56,"end":57,"loc":{"start":{"line":2,"column":33},"end":{"line":2,"column":34},"identifierName":"e"}, + "name": "e" + }, + "init": null + } + ], + "kind": "const" + }, + "right": { + "type": "Identifier", + "start":61,"end":69,"loc":{"start":{"line":2,"column":38},"end":{"line":2,"column":46},"identifierName":"sequence"}, + "name": "sequence" + }, + "body": { + "type": "ExpressionStatement", + "start":71,"end":73,"loc":{"start":{"line":2,"column":48},"end":{"line":2,"column":50}}, + "expression": { + "type": "TopicReference", + "start":71,"end":72,"loc":{"start":{"line":2,"column":48},"end":{"line":2,"column":49}} + } + } + } + ], + "directives": [] + } + } + } + } + ], + "directives": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-for-await-of-loop-and-topic-in-loop-head/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-for-await-of-loop-and-topic-in-loop-head/input.js new file mode 100644 index 0000000000..6e1c32d68f --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-for-await-of-loop-and-topic-in-loop-head/input.js @@ -0,0 +1,3 @@ +async function af () { + value |> do { for await (const e of %) e; } +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-for-await-of-loop-and-topic-in-loop-head/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-for-await-of-loop-and-topic-in-loop-head/options.json new file mode 100644 index 0000000000..ce2d1bb4c5 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-for-await-of-loop-and-topic-in-loop-head/options.json @@ -0,0 +1,6 @@ +{ + "plugins": [ + ["pipelineOperator", { "proposal": "hack", "topicToken": "%" }], + "doExpressions" + ] +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-for-await-of-loop-and-topic-in-loop-head/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-for-await-of-loop-and-topic-in-loop-head/output.json new file mode 100644 index 0000000000..bdc716f071 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-for-await-of-loop-and-topic-in-loop-head/output.json @@ -0,0 +1,93 @@ +{ + "type": "File", + "start":0,"end":70,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}}, + "program": { + "type": "Program", + "start":0,"end":70,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}}, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start":0,"end":70,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}}, + "id": { + "type": "Identifier", + "start":15,"end":17,"loc":{"start":{"line":1,"column":15},"end":{"line":1,"column":17},"identifierName":"af"}, + "name": "af" + }, + "generator": false, + "async": true, + "params": [], + "body": { + "type": "BlockStatement", + "start":21,"end":70,"loc":{"start":{"line":1,"column":21},"end":{"line":3,"column":1}}, + "body": [ + { + "type": "ExpressionStatement", + "start":25,"end":68,"loc":{"start":{"line":2,"column":2},"end":{"line":2,"column":45}}, + "expression": { + "type": "BinaryExpression", + "start":25,"end":68,"loc":{"start":{"line":2,"column":2},"end":{"line":2,"column":45}}, + "left": { + "type": "Identifier", + "start":25,"end":30,"loc":{"start":{"line":2,"column":2},"end":{"line":2,"column":7},"identifierName":"value"}, + "name": "value" + }, + "operator": "|>", + "right": { + "type": "DoExpression", + "start":34,"end":68,"loc":{"start":{"line":2,"column":11},"end":{"line":2,"column":45}}, + "async": false, + "body": { + "type": "BlockStatement", + "start":37,"end":68,"loc":{"start":{"line":2,"column":14},"end":{"line":2,"column":45}}, + "body": [ + { + "type": "ForOfStatement", + "start":39,"end":66,"loc":{"start":{"line":2,"column":16},"end":{"line":2,"column":43}}, + "await": true, + "left": { + "type": "VariableDeclaration", + "start":50,"end":57,"loc":{"start":{"line":2,"column":27},"end":{"line":2,"column":34}}, + "declarations": [ + { + "type": "VariableDeclarator", + "start":56,"end":57,"loc":{"start":{"line":2,"column":33},"end":{"line":2,"column":34}}, + "id": { + "type": "Identifier", + "start":56,"end":57,"loc":{"start":{"line":2,"column":33},"end":{"line":2,"column":34},"identifierName":"e"}, + "name": "e" + }, + "init": null + } + ], + "kind": "const" + }, + "right": { + "type": "TopicReference", + "start":61,"end":62,"loc":{"start":{"line":2,"column":38},"end":{"line":2,"column":39}} + }, + "body": { + "type": "ExpressionStatement", + "start":64,"end":66,"loc":{"start":{"line":2,"column":41},"end":{"line":2,"column":43}}, + "expression": { + "type": "Identifier", + "start":64,"end":65,"loc":{"start":{"line":2,"column":41},"end":{"line":2,"column":42},"identifierName":"e"}, + "name": "e" + } + } + } + ], + "directives": [] + } + } + } + } + ], + "directives": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-for-await-of-loop-transform-and-topic-in-loop-body/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-for-await-of-loop-transform-and-topic-in-loop-body/input.js new file mode 100644 index 0000000000..660fdde3a8 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-for-await-of-loop-transform-and-topic-in-loop-body/input.js @@ -0,0 +1,3 @@ +async function af () { + value |> do { for await (const e of sequence) %; } +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-for-await-of-loop-transform-and-topic-in-loop-body/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-for-await-of-loop-transform-and-topic-in-loop-body/options.json new file mode 100644 index 0000000000..d800706331 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-for-await-of-loop-transform-and-topic-in-loop-body/options.json @@ -0,0 +1,7 @@ +{ + "plugins": [ + ["pipelineOperator", { "proposal": "hack", "topicToken": "%" }], + "doExpressions", + "asyncGenerators" + ] +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-for-await-of-loop-transform-and-topic-in-loop-body/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-for-await-of-loop-transform-and-topic-in-loop-body/output.json new file mode 100644 index 0000000000..8fbe9b326e --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-for-await-of-loop-transform-and-topic-in-loop-body/output.json @@ -0,0 +1,93 @@ +{ + "type": "File", + "start":0,"end":77,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}}, + "program": { + "type": "Program", + "start":0,"end":77,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}}, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start":0,"end":77,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}}, + "id": { + "type": "Identifier", + "start":15,"end":17,"loc":{"start":{"line":1,"column":15},"end":{"line":1,"column":17},"identifierName":"af"}, + "name": "af" + }, + "generator": false, + "async": true, + "params": [], + "body": { + "type": "BlockStatement", + "start":21,"end":77,"loc":{"start":{"line":1,"column":21},"end":{"line":3,"column":1}}, + "body": [ + { + "type": "ExpressionStatement", + "start":25,"end":75,"loc":{"start":{"line":2,"column":2},"end":{"line":2,"column":52}}, + "expression": { + "type": "BinaryExpression", + "start":25,"end":75,"loc":{"start":{"line":2,"column":2},"end":{"line":2,"column":52}}, + "left": { + "type": "Identifier", + "start":25,"end":30,"loc":{"start":{"line":2,"column":2},"end":{"line":2,"column":7},"identifierName":"value"}, + "name": "value" + }, + "operator": "|>", + "right": { + "type": "DoExpression", + "start":34,"end":75,"loc":{"start":{"line":2,"column":11},"end":{"line":2,"column":52}}, + "async": false, + "body": { + "type": "BlockStatement", + "start":37,"end":75,"loc":{"start":{"line":2,"column":14},"end":{"line":2,"column":52}}, + "body": [ + { + "type": "ForOfStatement", + "start":39,"end":73,"loc":{"start":{"line":2,"column":16},"end":{"line":2,"column":50}}, + "await": true, + "left": { + "type": "VariableDeclaration", + "start":50,"end":57,"loc":{"start":{"line":2,"column":27},"end":{"line":2,"column":34}}, + "declarations": [ + { + "type": "VariableDeclarator", + "start":56,"end":57,"loc":{"start":{"line":2,"column":33},"end":{"line":2,"column":34}}, + "id": { + "type": "Identifier", + "start":56,"end":57,"loc":{"start":{"line":2,"column":33},"end":{"line":2,"column":34},"identifierName":"e"}, + "name": "e" + }, + "init": null + } + ], + "kind": "const" + }, + "right": { + "type": "Identifier", + "start":61,"end":69,"loc":{"start":{"line":2,"column":38},"end":{"line":2,"column":46},"identifierName":"sequence"}, + "name": "sequence" + }, + "body": { + "type": "ExpressionStatement", + "start":71,"end":73,"loc":{"start":{"line":2,"column":48},"end":{"line":2,"column":50}}, + "expression": { + "type": "TopicReference", + "start":71,"end":72,"loc":{"start":{"line":2,"column":48},"end":{"line":2,"column":49}} + } + } + } + ], + "directives": [] + } + } + } + } + ], + "directives": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-for-await-of-loop-transform-and-topic-in-loop-head/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-for-await-of-loop-transform-and-topic-in-loop-head/input.js new file mode 100644 index 0000000000..6e1c32d68f --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-for-await-of-loop-transform-and-topic-in-loop-head/input.js @@ -0,0 +1,3 @@ +async function af () { + value |> do { for await (const e of %) e; } +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-for-await-of-loop-transform-and-topic-in-loop-head/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-for-await-of-loop-transform-and-topic-in-loop-head/options.json new file mode 100644 index 0000000000..d800706331 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-for-await-of-loop-transform-and-topic-in-loop-head/options.json @@ -0,0 +1,7 @@ +{ + "plugins": [ + ["pipelineOperator", { "proposal": "hack", "topicToken": "%" }], + "doExpressions", + "asyncGenerators" + ] +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-for-await-of-loop-transform-and-topic-in-loop-head/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-for-await-of-loop-transform-and-topic-in-loop-head/output.json new file mode 100644 index 0000000000..bdc716f071 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-for-await-of-loop-transform-and-topic-in-loop-head/output.json @@ -0,0 +1,93 @@ +{ + "type": "File", + "start":0,"end":70,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}}, + "program": { + "type": "Program", + "start":0,"end":70,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}}, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start":0,"end":70,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}}, + "id": { + "type": "Identifier", + "start":15,"end":17,"loc":{"start":{"line":1,"column":15},"end":{"line":1,"column":17},"identifierName":"af"}, + "name": "af" + }, + "generator": false, + "async": true, + "params": [], + "body": { + "type": "BlockStatement", + "start":21,"end":70,"loc":{"start":{"line":1,"column":21},"end":{"line":3,"column":1}}, + "body": [ + { + "type": "ExpressionStatement", + "start":25,"end":68,"loc":{"start":{"line":2,"column":2},"end":{"line":2,"column":45}}, + "expression": { + "type": "BinaryExpression", + "start":25,"end":68,"loc":{"start":{"line":2,"column":2},"end":{"line":2,"column":45}}, + "left": { + "type": "Identifier", + "start":25,"end":30,"loc":{"start":{"line":2,"column":2},"end":{"line":2,"column":7},"identifierName":"value"}, + "name": "value" + }, + "operator": "|>", + "right": { + "type": "DoExpression", + "start":34,"end":68,"loc":{"start":{"line":2,"column":11},"end":{"line":2,"column":45}}, + "async": false, + "body": { + "type": "BlockStatement", + "start":37,"end":68,"loc":{"start":{"line":2,"column":14},"end":{"line":2,"column":45}}, + "body": [ + { + "type": "ForOfStatement", + "start":39,"end":66,"loc":{"start":{"line":2,"column":16},"end":{"line":2,"column":43}}, + "await": true, + "left": { + "type": "VariableDeclaration", + "start":50,"end":57,"loc":{"start":{"line":2,"column":27},"end":{"line":2,"column":34}}, + "declarations": [ + { + "type": "VariableDeclarator", + "start":56,"end":57,"loc":{"start":{"line":2,"column":33},"end":{"line":2,"column":34}}, + "id": { + "type": "Identifier", + "start":56,"end":57,"loc":{"start":{"line":2,"column":33},"end":{"line":2,"column":34},"identifierName":"e"}, + "name": "e" + }, + "init": null + } + ], + "kind": "const" + }, + "right": { + "type": "TopicReference", + "start":61,"end":62,"loc":{"start":{"line":2,"column":38},"end":{"line":2,"column":39}} + }, + "body": { + "type": "ExpressionStatement", + "start":64,"end":66,"loc":{"start":{"line":2,"column":41},"end":{"line":2,"column":43}}, + "expression": { + "type": "Identifier", + "start":64,"end":65,"loc":{"start":{"line":2,"column":41},"end":{"line":2,"column":42},"identifierName":"e"}, + "name": "e" + } + } + } + ], + "directives": [] + } + } + } + } + ], + "directives": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-for-classic-loop-and-topic-in-loop-body/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-for-classic-loop-and-topic-in-loop-body/input.js new file mode 100644 index 0000000000..d4d678eb95 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-for-classic-loop-and-topic-in-loop-body/input.js @@ -0,0 +1 @@ +value |> do { for (let i = 0; i < n; i += 1) %; } diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-for-classic-loop-and-topic-in-loop-body/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-for-classic-loop-and-topic-in-loop-body/options.json new file mode 100644 index 0000000000..59d88314f0 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-for-classic-loop-and-topic-in-loop-body/options.json @@ -0,0 +1,3 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "hack", "topicToken": "%" }], "doExpressions"] +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-for-classic-loop-and-topic-in-loop-body/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-for-classic-loop-and-topic-in-loop-body/output.json new file mode 100644 index 0000000000..9a2cfce898 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-for-classic-loop-and-topic-in-loop-body/output.json @@ -0,0 +1,110 @@ +{ + "type": "File", + "start":0,"end":49,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":49}}, + "program": { + "type": "Program", + "start":0,"end":49,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":49}}, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start":0,"end":49,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":49}}, + "expression": { + "type": "BinaryExpression", + "start":0,"end":49,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":49}}, + "left": { + "type": "Identifier", + "start":0,"end":5,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":5},"identifierName":"value"}, + "name": "value" + }, + "operator": "|>", + "right": { + "type": "DoExpression", + "start":9,"end":49,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":49}}, + "async": false, + "body": { + "type": "BlockStatement", + "start":12,"end":49,"loc":{"start":{"line":1,"column":12},"end":{"line":1,"column":49}}, + "body": [ + { + "type": "ForStatement", + "start":14,"end":47,"loc":{"start":{"line":1,"column":14},"end":{"line":1,"column":47}}, + "init": { + "type": "VariableDeclaration", + "start":19,"end":28,"loc":{"start":{"line":1,"column":19},"end":{"line":1,"column":28}}, + "declarations": [ + { + "type": "VariableDeclarator", + "start":23,"end":28,"loc":{"start":{"line":1,"column":23},"end":{"line":1,"column":28}}, + "id": { + "type": "Identifier", + "start":23,"end":24,"loc":{"start":{"line":1,"column":23},"end":{"line":1,"column":24},"identifierName":"i"}, + "name": "i" + }, + "init": { + "type": "NumericLiteral", + "start":27,"end":28,"loc":{"start":{"line":1,"column":27},"end":{"line":1,"column":28}}, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + } + } + ], + "kind": "let" + }, + "test": { + "type": "BinaryExpression", + "start":30,"end":35,"loc":{"start":{"line":1,"column":30},"end":{"line":1,"column":35}}, + "left": { + "type": "Identifier", + "start":30,"end":31,"loc":{"start":{"line":1,"column":30},"end":{"line":1,"column":31},"identifierName":"i"}, + "name": "i" + }, + "operator": "<", + "right": { + "type": "Identifier", + "start":34,"end":35,"loc":{"start":{"line":1,"column":34},"end":{"line":1,"column":35},"identifierName":"n"}, + "name": "n" + } + }, + "update": { + "type": "AssignmentExpression", + "start":37,"end":43,"loc":{"start":{"line":1,"column":37},"end":{"line":1,"column":43}}, + "operator": "+=", + "left": { + "type": "Identifier", + "start":37,"end":38,"loc":{"start":{"line":1,"column":37},"end":{"line":1,"column":38},"identifierName":"i"}, + "name": "i" + }, + "right": { + "type": "NumericLiteral", + "start":42,"end":43,"loc":{"start":{"line":1,"column":42},"end":{"line":1,"column":43}}, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + } + }, + "body": { + "type": "ExpressionStatement", + "start":45,"end":47,"loc":{"start":{"line":1,"column":45},"end":{"line":1,"column":47}}, + "expression": { + "type": "TopicReference", + "start":45,"end":46,"loc":{"start":{"line":1,"column":45},"end":{"line":1,"column":46}} + } + } + } + ], + "directives": [] + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-for-classic-loop-and-topic-in-loop-head/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-for-classic-loop-and-topic-in-loop-head/input.js new file mode 100644 index 0000000000..df54af9ba6 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-for-classic-loop-and-topic-in-loop-head/input.js @@ -0,0 +1 @@ +value |> do { for (let i = %; predicate(i, %); i += %) i; } diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-for-classic-loop-and-topic-in-loop-head/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-for-classic-loop-and-topic-in-loop-head/options.json new file mode 100644 index 0000000000..59d88314f0 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-for-classic-loop-and-topic-in-loop-head/options.json @@ -0,0 +1,3 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "hack", "topicToken": "%" }], "doExpressions"] +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-for-classic-loop-and-topic-in-loop-head/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-for-classic-loop-and-topic-in-loop-head/output.json new file mode 100644 index 0000000000..7df2f583e2 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-for-classic-loop-and-topic-in-loop-head/output.json @@ -0,0 +1,106 @@ +{ + "type": "File", + "start":0,"end":59,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":59}}, + "program": { + "type": "Program", + "start":0,"end":59,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":59}}, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start":0,"end":59,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":59}}, + "expression": { + "type": "BinaryExpression", + "start":0,"end":59,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":59}}, + "left": { + "type": "Identifier", + "start":0,"end":5,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":5},"identifierName":"value"}, + "name": "value" + }, + "operator": "|>", + "right": { + "type": "DoExpression", + "start":9,"end":59,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":59}}, + "async": false, + "body": { + "type": "BlockStatement", + "start":12,"end":59,"loc":{"start":{"line":1,"column":12},"end":{"line":1,"column":59}}, + "body": [ + { + "type": "ForStatement", + "start":14,"end":57,"loc":{"start":{"line":1,"column":14},"end":{"line":1,"column":57}}, + "init": { + "type": "VariableDeclaration", + "start":19,"end":28,"loc":{"start":{"line":1,"column":19},"end":{"line":1,"column":28}}, + "declarations": [ + { + "type": "VariableDeclarator", + "start":23,"end":28,"loc":{"start":{"line":1,"column":23},"end":{"line":1,"column":28}}, + "id": { + "type": "Identifier", + "start":23,"end":24,"loc":{"start":{"line":1,"column":23},"end":{"line":1,"column":24},"identifierName":"i"}, + "name": "i" + }, + "init": { + "type": "TopicReference", + "start":27,"end":28,"loc":{"start":{"line":1,"column":27},"end":{"line":1,"column":28}} + } + } + ], + "kind": "let" + }, + "test": { + "type": "CallExpression", + "start":30,"end":45,"loc":{"start":{"line":1,"column":30},"end":{"line":1,"column":45}}, + "callee": { + "type": "Identifier", + "start":30,"end":39,"loc":{"start":{"line":1,"column":30},"end":{"line":1,"column":39},"identifierName":"predicate"}, + "name": "predicate" + }, + "arguments": [ + { + "type": "Identifier", + "start":40,"end":41,"loc":{"start":{"line":1,"column":40},"end":{"line":1,"column":41},"identifierName":"i"}, + "name": "i" + }, + { + "type": "TopicReference", + "start":43,"end":44,"loc":{"start":{"line":1,"column":43},"end":{"line":1,"column":44}} + } + ] + }, + "update": { + "type": "AssignmentExpression", + "start":47,"end":53,"loc":{"start":{"line":1,"column":47},"end":{"line":1,"column":53}}, + "operator": "+=", + "left": { + "type": "Identifier", + "start":47,"end":48,"loc":{"start":{"line":1,"column":47},"end":{"line":1,"column":48},"identifierName":"i"}, + "name": "i" + }, + "right": { + "type": "TopicReference", + "start":52,"end":53,"loc":{"start":{"line":1,"column":52},"end":{"line":1,"column":53}} + } + }, + "body": { + "type": "ExpressionStatement", + "start":55,"end":57,"loc":{"start":{"line":1,"column":55},"end":{"line":1,"column":57}}, + "expression": { + "type": "Identifier", + "start":55,"end":56,"loc":{"start":{"line":1,"column":55},"end":{"line":1,"column":56},"identifierName":"i"}, + "name": "i" + } + } + } + ], + "directives": [] + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-for-in-loop-and-topic-in-loop-body/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-for-in-loop-and-topic-in-loop-body/input.js new file mode 100644 index 0000000000..834922627d --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-for-in-loop-and-topic-in-loop-body/input.js @@ -0,0 +1 @@ +value |> do { for (e in object) %; } diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-for-in-loop-and-topic-in-loop-body/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-for-in-loop-and-topic-in-loop-body/options.json new file mode 100644 index 0000000000..59d88314f0 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-for-in-loop-and-topic-in-loop-body/options.json @@ -0,0 +1,3 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "hack", "topicToken": "%" }], "doExpressions"] +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-for-in-loop-and-topic-in-loop-body/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-for-in-loop-and-topic-in-loop-body/output.json new file mode 100644 index 0000000000..3c3dc20a51 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-for-in-loop-and-topic-in-loop-body/output.json @@ -0,0 +1,61 @@ +{ + "type": "File", + "start":0,"end":36,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":36}}, + "program": { + "type": "Program", + "start":0,"end":36,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":36}}, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start":0,"end":36,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":36}}, + "expression": { + "type": "BinaryExpression", + "start":0,"end":36,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":36}}, + "left": { + "type": "Identifier", + "start":0,"end":5,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":5},"identifierName":"value"}, + "name": "value" + }, + "operator": "|>", + "right": { + "type": "DoExpression", + "start":9,"end":36,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":36}}, + "async": false, + "body": { + "type": "BlockStatement", + "start":12,"end":36,"loc":{"start":{"line":1,"column":12},"end":{"line":1,"column":36}}, + "body": [ + { + "type": "ForInStatement", + "start":14,"end":34,"loc":{"start":{"line":1,"column":14},"end":{"line":1,"column":34}}, + "left": { + "type": "Identifier", + "start":19,"end":20,"loc":{"start":{"line":1,"column":19},"end":{"line":1,"column":20},"identifierName":"e"}, + "name": "e" + }, + "right": { + "type": "Identifier", + "start":24,"end":30,"loc":{"start":{"line":1,"column":24},"end":{"line":1,"column":30},"identifierName":"object"}, + "name": "object" + }, + "body": { + "type": "ExpressionStatement", + "start":32,"end":34,"loc":{"start":{"line":1,"column":32},"end":{"line":1,"column":34}}, + "expression": { + "type": "TopicReference", + "start":32,"end":33,"loc":{"start":{"line":1,"column":32},"end":{"line":1,"column":33}} + } + } + } + ], + "directives": [] + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-for-in-loop-and-topic-in-loop-head/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-for-in-loop-and-topic-in-loop-head/input.js new file mode 100644 index 0000000000..1816ecf226 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-for-in-loop-and-topic-in-loop-head/input.js @@ -0,0 +1 @@ +value |> do { for (e in %) e; } diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-for-in-loop-and-topic-in-loop-head/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-for-in-loop-and-topic-in-loop-head/options.json new file mode 100644 index 0000000000..59d88314f0 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-for-in-loop-and-topic-in-loop-head/options.json @@ -0,0 +1,3 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "hack", "topicToken": "%" }], "doExpressions"] +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-for-in-loop-and-topic-in-loop-head/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-for-in-loop-and-topic-in-loop-head/output.json new file mode 100644 index 0000000000..230eafa0e7 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-for-in-loop-and-topic-in-loop-head/output.json @@ -0,0 +1,61 @@ +{ + "type": "File", + "start":0,"end":31,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":31}}, + "program": { + "type": "Program", + "start":0,"end":31,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":31}}, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start":0,"end":31,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":31}}, + "expression": { + "type": "BinaryExpression", + "start":0,"end":31,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":31}}, + "left": { + "type": "Identifier", + "start":0,"end":5,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":5},"identifierName":"value"}, + "name": "value" + }, + "operator": "|>", + "right": { + "type": "DoExpression", + "start":9,"end":31,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":31}}, + "async": false, + "body": { + "type": "BlockStatement", + "start":12,"end":31,"loc":{"start":{"line":1,"column":12},"end":{"line":1,"column":31}}, + "body": [ + { + "type": "ForInStatement", + "start":14,"end":29,"loc":{"start":{"line":1,"column":14},"end":{"line":1,"column":29}}, + "left": { + "type": "Identifier", + "start":19,"end":20,"loc":{"start":{"line":1,"column":19},"end":{"line":1,"column":20},"identifierName":"e"}, + "name": "e" + }, + "right": { + "type": "TopicReference", + "start":24,"end":25,"loc":{"start":{"line":1,"column":24},"end":{"line":1,"column":25}} + }, + "body": { + "type": "ExpressionStatement", + "start":27,"end":29,"loc":{"start":{"line":1,"column":27},"end":{"line":1,"column":29}}, + "expression": { + "type": "Identifier", + "start":27,"end":28,"loc":{"start":{"line":1,"column":27},"end":{"line":1,"column":28},"identifierName":"e"}, + "name": "e" + } + } + } + ], + "directives": [] + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-for-of-loop-and-topic-in-loop-body/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-for-of-loop-and-topic-in-loop-body/input.js new file mode 100644 index 0000000000..4411a34715 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-for-of-loop-and-topic-in-loop-body/input.js @@ -0,0 +1 @@ +value |> do { for (e of sequence) %; } diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-for-of-loop-and-topic-in-loop-body/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-for-of-loop-and-topic-in-loop-body/options.json new file mode 100644 index 0000000000..59d88314f0 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-for-of-loop-and-topic-in-loop-body/options.json @@ -0,0 +1,3 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "hack", "topicToken": "%" }], "doExpressions"] +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-for-of-loop-and-topic-in-loop-body/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-for-of-loop-and-topic-in-loop-body/output.json new file mode 100644 index 0000000000..33829839a9 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-for-of-loop-and-topic-in-loop-body/output.json @@ -0,0 +1,62 @@ +{ + "type": "File", + "start":0,"end":38,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":38}}, + "program": { + "type": "Program", + "start":0,"end":38,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":38}}, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start":0,"end":38,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":38}}, + "expression": { + "type": "BinaryExpression", + "start":0,"end":38,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":38}}, + "left": { + "type": "Identifier", + "start":0,"end":5,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":5},"identifierName":"value"}, + "name": "value" + }, + "operator": "|>", + "right": { + "type": "DoExpression", + "start":9,"end":38,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":38}}, + "async": false, + "body": { + "type": "BlockStatement", + "start":12,"end":38,"loc":{"start":{"line":1,"column":12},"end":{"line":1,"column":38}}, + "body": [ + { + "type": "ForOfStatement", + "start":14,"end":36,"loc":{"start":{"line":1,"column":14},"end":{"line":1,"column":36}}, + "await": false, + "left": { + "type": "Identifier", + "start":19,"end":20,"loc":{"start":{"line":1,"column":19},"end":{"line":1,"column":20},"identifierName":"e"}, + "name": "e" + }, + "right": { + "type": "Identifier", + "start":24,"end":32,"loc":{"start":{"line":1,"column":24},"end":{"line":1,"column":32},"identifierName":"sequence"}, + "name": "sequence" + }, + "body": { + "type": "ExpressionStatement", + "start":34,"end":36,"loc":{"start":{"line":1,"column":34},"end":{"line":1,"column":36}}, + "expression": { + "type": "TopicReference", + "start":34,"end":35,"loc":{"start":{"line":1,"column":34},"end":{"line":1,"column":35}} + } + } + } + ], + "directives": [] + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-for-of-loop-and-topic-in-loop-head/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-for-of-loop-and-topic-in-loop-head/input.js new file mode 100644 index 0000000000..392a3f98ff --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-for-of-loop-and-topic-in-loop-head/input.js @@ -0,0 +1 @@ +value |> do { for (e of %) e; } diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-for-of-loop-and-topic-in-loop-head/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-for-of-loop-and-topic-in-loop-head/options.json new file mode 100644 index 0000000000..59d88314f0 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-for-of-loop-and-topic-in-loop-head/options.json @@ -0,0 +1,3 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "hack", "topicToken": "%" }], "doExpressions"] +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-for-of-loop-and-topic-in-loop-head/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-for-of-loop-and-topic-in-loop-head/output.json new file mode 100644 index 0000000000..8edea4e4e6 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-for-of-loop-and-topic-in-loop-head/output.json @@ -0,0 +1,62 @@ +{ + "type": "File", + "start":0,"end":31,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":31}}, + "program": { + "type": "Program", + "start":0,"end":31,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":31}}, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start":0,"end":31,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":31}}, + "expression": { + "type": "BinaryExpression", + "start":0,"end":31,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":31}}, + "left": { + "type": "Identifier", + "start":0,"end":5,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":5},"identifierName":"value"}, + "name": "value" + }, + "operator": "|>", + "right": { + "type": "DoExpression", + "start":9,"end":31,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":31}}, + "async": false, + "body": { + "type": "BlockStatement", + "start":12,"end":31,"loc":{"start":{"line":1,"column":12},"end":{"line":1,"column":31}}, + "body": [ + { + "type": "ForOfStatement", + "start":14,"end":29,"loc":{"start":{"line":1,"column":14},"end":{"line":1,"column":29}}, + "await": false, + "left": { + "type": "Identifier", + "start":19,"end":20,"loc":{"start":{"line":1,"column":19},"end":{"line":1,"column":20},"identifierName":"e"}, + "name": "e" + }, + "right": { + "type": "TopicReference", + "start":24,"end":25,"loc":{"start":{"line":1,"column":24},"end":{"line":1,"column":25}} + }, + "body": { + "type": "ExpressionStatement", + "start":27,"end":29,"loc":{"start":{"line":1,"column":27},"end":{"line":1,"column":29}}, + "expression": { + "type": "Identifier", + "start":27,"end":28,"loc":{"start":{"line":1,"column":27},"end":{"line":1,"column":28},"identifierName":"e"}, + "name": "e" + } + } + } + ], + "directives": [] + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-if-statement-and-topic-in-else-body/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-if-statement-and-topic-in-else-body/input.js new file mode 100644 index 0000000000..e493c67f14 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-if-statement-and-topic-in-else-body/input.js @@ -0,0 +1 @@ +value |> do { if (yes) null; else if (no) %; } diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-if-statement-and-topic-in-else-body/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-if-statement-and-topic-in-else-body/options.json new file mode 100644 index 0000000000..59d88314f0 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-if-statement-and-topic-in-else-body/options.json @@ -0,0 +1,3 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "hack", "topicToken": "%" }], "doExpressions"] +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-if-statement-and-topic-in-else-body/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-if-statement-and-topic-in-else-body/output.json new file mode 100644 index 0000000000..f1d076f6b5 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-if-statement-and-topic-in-else-body/output.json @@ -0,0 +1,74 @@ +{ + "type": "File", + "start":0,"end":46,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":46}}, + "program": { + "type": "Program", + "start":0,"end":46,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":46}}, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start":0,"end":46,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":46}}, + "expression": { + "type": "BinaryExpression", + "start":0,"end":46,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":46}}, + "left": { + "type": "Identifier", + "start":0,"end":5,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":5},"identifierName":"value"}, + "name": "value" + }, + "operator": "|>", + "right": { + "type": "DoExpression", + "start":9,"end":46,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":46}}, + "async": false, + "body": { + "type": "BlockStatement", + "start":12,"end":46,"loc":{"start":{"line":1,"column":12},"end":{"line":1,"column":46}}, + "body": [ + { + "type": "IfStatement", + "start":14,"end":44,"loc":{"start":{"line":1,"column":14},"end":{"line":1,"column":44}}, + "test": { + "type": "Identifier", + "start":18,"end":21,"loc":{"start":{"line":1,"column":18},"end":{"line":1,"column":21},"identifierName":"yes"}, + "name": "yes" + }, + "consequent": { + "type": "ExpressionStatement", + "start":23,"end":28,"loc":{"start":{"line":1,"column":23},"end":{"line":1,"column":28}}, + "expression": { + "type": "NullLiteral", + "start":23,"end":27,"loc":{"start":{"line":1,"column":23},"end":{"line":1,"column":27}} + } + }, + "alternate": { + "type": "IfStatement", + "start":34,"end":44,"loc":{"start":{"line":1,"column":34},"end":{"line":1,"column":44}}, + "test": { + "type": "Identifier", + "start":38,"end":40,"loc":{"start":{"line":1,"column":38},"end":{"line":1,"column":40},"identifierName":"no"}, + "name": "no" + }, + "consequent": { + "type": "ExpressionStatement", + "start":42,"end":44,"loc":{"start":{"line":1,"column":42},"end":{"line":1,"column":44}}, + "expression": { + "type": "TopicReference", + "start":42,"end":43,"loc":{"start":{"line":1,"column":42},"end":{"line":1,"column":43}} + } + }, + "alternate": null + } + } + ], + "directives": [] + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-if-statement-and-topic-in-else-if-body/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-if-statement-and-topic-in-else-if-body/input.js new file mode 100644 index 0000000000..f562b4b9a3 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-if-statement-and-topic-in-else-if-body/input.js @@ -0,0 +1 @@ +value |> do { if (yes) null; else %; } diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-if-statement-and-topic-in-else-if-body/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-if-statement-and-topic-in-else-if-body/options.json new file mode 100644 index 0000000000..59d88314f0 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-if-statement-and-topic-in-else-if-body/options.json @@ -0,0 +1,3 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "hack", "topicToken": "%" }], "doExpressions"] +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-if-statement-and-topic-in-else-if-body/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-if-statement-and-topic-in-else-if-body/output.json new file mode 100644 index 0000000000..1543c9a557 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-if-statement-and-topic-in-else-if-body/output.json @@ -0,0 +1,64 @@ +{ + "type": "File", + "start":0,"end":38,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":38}}, + "program": { + "type": "Program", + "start":0,"end":38,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":38}}, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start":0,"end":38,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":38}}, + "expression": { + "type": "BinaryExpression", + "start":0,"end":38,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":38}}, + "left": { + "type": "Identifier", + "start":0,"end":5,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":5},"identifierName":"value"}, + "name": "value" + }, + "operator": "|>", + "right": { + "type": "DoExpression", + "start":9,"end":38,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":38}}, + "async": false, + "body": { + "type": "BlockStatement", + "start":12,"end":38,"loc":{"start":{"line":1,"column":12},"end":{"line":1,"column":38}}, + "body": [ + { + "type": "IfStatement", + "start":14,"end":36,"loc":{"start":{"line":1,"column":14},"end":{"line":1,"column":36}}, + "test": { + "type": "Identifier", + "start":18,"end":21,"loc":{"start":{"line":1,"column":18},"end":{"line":1,"column":21},"identifierName":"yes"}, + "name": "yes" + }, + "consequent": { + "type": "ExpressionStatement", + "start":23,"end":28,"loc":{"start":{"line":1,"column":23},"end":{"line":1,"column":28}}, + "expression": { + "type": "NullLiteral", + "start":23,"end":27,"loc":{"start":{"line":1,"column":23},"end":{"line":1,"column":27}} + } + }, + "alternate": { + "type": "ExpressionStatement", + "start":34,"end":36,"loc":{"start":{"line":1,"column":34},"end":{"line":1,"column":36}}, + "expression": { + "type": "TopicReference", + "start":34,"end":35,"loc":{"start":{"line":1,"column":34},"end":{"line":1,"column":35}} + } + } + } + ], + "directives": [] + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-if-statement-and-topic-in-if-body/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-if-statement-and-topic-in-if-body/input.js new file mode 100644 index 0000000000..96b4279d2e --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-if-statement-and-topic-in-if-body/input.js @@ -0,0 +1 @@ +value |> do { if (yes) %; } diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-if-statement-and-topic-in-if-body/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-if-statement-and-topic-in-if-body/options.json new file mode 100644 index 0000000000..59d88314f0 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-if-statement-and-topic-in-if-body/options.json @@ -0,0 +1,3 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "hack", "topicToken": "%" }], "doExpressions"] +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-if-statement-and-topic-in-if-body/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-if-statement-and-topic-in-if-body/output.json new file mode 100644 index 0000000000..a98abe3fb6 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-if-statement-and-topic-in-if-body/output.json @@ -0,0 +1,57 @@ +{ + "type": "File", + "start":0,"end":27,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":27}}, + "program": { + "type": "Program", + "start":0,"end":27,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":27}}, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start":0,"end":27,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":27}}, + "expression": { + "type": "BinaryExpression", + "start":0,"end":27,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":27}}, + "left": { + "type": "Identifier", + "start":0,"end":5,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":5},"identifierName":"value"}, + "name": "value" + }, + "operator": "|>", + "right": { + "type": "DoExpression", + "start":9,"end":27,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":27}}, + "async": false, + "body": { + "type": "BlockStatement", + "start":12,"end":27,"loc":{"start":{"line":1,"column":12},"end":{"line":1,"column":27}}, + "body": [ + { + "type": "IfStatement", + "start":14,"end":25,"loc":{"start":{"line":1,"column":14},"end":{"line":1,"column":25}}, + "test": { + "type": "Identifier", + "start":18,"end":21,"loc":{"start":{"line":1,"column":18},"end":{"line":1,"column":21},"identifierName":"yes"}, + "name": "yes" + }, + "consequent": { + "type": "ExpressionStatement", + "start":23,"end":25,"loc":{"start":{"line":1,"column":23},"end":{"line":1,"column":25}}, + "expression": { + "type": "TopicReference", + "start":23,"end":24,"loc":{"start":{"line":1,"column":23},"end":{"line":1,"column":24}} + } + }, + "alternate": null + } + ], + "directives": [] + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-if-statement-and-topic-in-if-head/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-if-statement-and-topic-in-if-head/input.js new file mode 100644 index 0000000000..2e808692f4 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-if-statement-and-topic-in-if-head/input.js @@ -0,0 +1 @@ +value |> do { if (%) 1; else 0; } diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-if-statement-and-topic-in-if-head/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-if-statement-and-topic-in-if-head/options.json new file mode 100644 index 0000000000..59d88314f0 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-if-statement-and-topic-in-if-head/options.json @@ -0,0 +1,3 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "hack", "topicToken": "%" }], "doExpressions"] +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-if-statement-and-topic-in-if-head/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-if-statement-and-topic-in-if-head/output.json new file mode 100644 index 0000000000..eb2faae4ae --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-if-statement-and-topic-in-if-head/output.json @@ -0,0 +1,73 @@ +{ + "type": "File", + "start":0,"end":33,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":33}}, + "program": { + "type": "Program", + "start":0,"end":33,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":33}}, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start":0,"end":33,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":33}}, + "expression": { + "type": "BinaryExpression", + "start":0,"end":33,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":33}}, + "left": { + "type": "Identifier", + "start":0,"end":5,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":5},"identifierName":"value"}, + "name": "value" + }, + "operator": "|>", + "right": { + "type": "DoExpression", + "start":9,"end":33,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":33}}, + "async": false, + "body": { + "type": "BlockStatement", + "start":12,"end":33,"loc":{"start":{"line":1,"column":12},"end":{"line":1,"column":33}}, + "body": [ + { + "type": "IfStatement", + "start":14,"end":31,"loc":{"start":{"line":1,"column":14},"end":{"line":1,"column":31}}, + "test": { + "type": "TopicReference", + "start":18,"end":19,"loc":{"start":{"line":1,"column":18},"end":{"line":1,"column":19}} + }, + "consequent": { + "type": "ExpressionStatement", + "start":21,"end":23,"loc":{"start":{"line":1,"column":21},"end":{"line":1,"column":23}}, + "expression": { + "type": "NumericLiteral", + "start":21,"end":22,"loc":{"start":{"line":1,"column":21},"end":{"line":1,"column":22}}, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + } + }, + "alternate": { + "type": "ExpressionStatement", + "start":29,"end":31,"loc":{"start":{"line":1,"column":29},"end":{"line":1,"column":31}}, + "expression": { + "type": "NumericLiteral", + "start":29,"end":30,"loc":{"start":{"line":1,"column":29},"end":{"line":1,"column":30}}, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + } + } + } + ], + "directives": [] + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-switch-statement-and-topic-in-switch-body/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-switch-statement-and-topic-in-switch-body/input.js new file mode 100644 index 0000000000..583b5bcd42 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-switch-statement-and-topic-in-switch-body/input.js @@ -0,0 +1,7 @@ +value |> do { + switch (number) { + case 0: %; + case 1: % + 1; + default: % + 10; + } +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-switch-statement-and-topic-in-switch-body/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-switch-statement-and-topic-in-switch-body/options.json new file mode 100644 index 0000000000..59d88314f0 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-switch-statement-and-topic-in-switch-body/options.json @@ -0,0 +1,3 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "hack", "topicToken": "%" }], "doExpressions"] +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-switch-statement-and-topic-in-switch-body/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-switch-statement-and-topic-in-switch-body/output.json new file mode 100644 index 0000000000..51c3d25a2e --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-switch-statement-and-topic-in-switch-body/output.json @@ -0,0 +1,139 @@ +{ + "type": "File", + "start":0,"end":94,"loc":{"start":{"line":1,"column":0},"end":{"line":7,"column":1}}, + "program": { + "type": "Program", + "start":0,"end":94,"loc":{"start":{"line":1,"column":0},"end":{"line":7,"column":1}}, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start":0,"end":94,"loc":{"start":{"line":1,"column":0},"end":{"line":7,"column":1}}, + "expression": { + "type": "BinaryExpression", + "start":0,"end":94,"loc":{"start":{"line":1,"column":0},"end":{"line":7,"column":1}}, + "left": { + "type": "Identifier", + "start":0,"end":5,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":5},"identifierName":"value"}, + "name": "value" + }, + "operator": "|>", + "right": { + "type": "DoExpression", + "start":9,"end":94,"loc":{"start":{"line":1,"column":9},"end":{"line":7,"column":1}}, + "async": false, + "body": { + "type": "BlockStatement", + "start":12,"end":94,"loc":{"start":{"line":1,"column":12},"end":{"line":7,"column":1}}, + "body": [ + { + "type": "SwitchStatement", + "start":16,"end":92,"loc":{"start":{"line":2,"column":2},"end":{"line":6,"column":3}}, + "discriminant": { + "type": "Identifier", + "start":24,"end":30,"loc":{"start":{"line":2,"column":10},"end":{"line":2,"column":16},"identifierName":"number"}, + "name": "number" + }, + "cases": [ + { + "type": "SwitchCase", + "start":38,"end":48,"loc":{"start":{"line":3,"column":4},"end":{"line":3,"column":14}}, + "consequent": [ + { + "type": "ExpressionStatement", + "start":46,"end":48,"loc":{"start":{"line":3,"column":12},"end":{"line":3,"column":14}}, + "expression": { + "type": "TopicReference", + "start":46,"end":47,"loc":{"start":{"line":3,"column":12},"end":{"line":3,"column":13}} + } + } + ], + "test": { + "type": "NumericLiteral", + "start":43,"end":44,"loc":{"start":{"line":3,"column":9},"end":{"line":3,"column":10}}, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + } + }, + { + "type": "SwitchCase", + "start":53,"end":67,"loc":{"start":{"line":4,"column":4},"end":{"line":4,"column":18}}, + "consequent": [ + { + "type": "ExpressionStatement", + "start":61,"end":67,"loc":{"start":{"line":4,"column":12},"end":{"line":4,"column":18}}, + "expression": { + "type": "BinaryExpression", + "start":61,"end":66,"loc":{"start":{"line":4,"column":12},"end":{"line":4,"column":17}}, + "left": { + "type": "TopicReference", + "start":61,"end":62,"loc":{"start":{"line":4,"column":12},"end":{"line":4,"column":13}} + }, + "operator": "+", + "right": { + "type": "NumericLiteral", + "start":65,"end":66,"loc":{"start":{"line":4,"column":16},"end":{"line":4,"column":17}}, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + } + } + } + ], + "test": { + "type": "NumericLiteral", + "start":58,"end":59,"loc":{"start":{"line":4,"column":9},"end":{"line":4,"column":10}}, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + } + }, + { + "type": "SwitchCase", + "start":72,"end":88,"loc":{"start":{"line":5,"column":4},"end":{"line":5,"column":20}}, + "consequent": [ + { + "type": "ExpressionStatement", + "start":81,"end":88,"loc":{"start":{"line":5,"column":13},"end":{"line":5,"column":20}}, + "expression": { + "type": "BinaryExpression", + "start":81,"end":87,"loc":{"start":{"line":5,"column":13},"end":{"line":5,"column":19}}, + "left": { + "type": "TopicReference", + "start":81,"end":82,"loc":{"start":{"line":5,"column":13},"end":{"line":5,"column":14}} + }, + "operator": "+", + "right": { + "type": "NumericLiteral", + "start":85,"end":87,"loc":{"start":{"line":5,"column":17},"end":{"line":5,"column":19}}, + "extra": { + "rawValue": 10, + "raw": "10" + }, + "value": 10 + } + } + } + ], + "test": null + } + ] + } + ], + "directives": [] + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-switch-statement-and-topic-in-switch-head/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-switch-statement-and-topic-in-switch-head/input.js new file mode 100644 index 0000000000..830b7a52ce --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-switch-statement-and-topic-in-switch-head/input.js @@ -0,0 +1,7 @@ +value |> do { + switch (%) { + case 0: 50; + case 1: 60; + default: 70; + } +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-switch-statement-and-topic-in-switch-head/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-switch-statement-and-topic-in-switch-head/options.json new file mode 100644 index 0000000000..59d88314f0 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-switch-statement-and-topic-in-switch-head/options.json @@ -0,0 +1,3 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "hack", "topicToken": "%" }], "doExpressions"] +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-switch-statement-and-topic-in-switch-head/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-switch-statement-and-topic-in-switch-head/output.json new file mode 100644 index 0000000000..769f6ecb57 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-switch-statement-and-topic-in-switch-head/output.json @@ -0,0 +1,125 @@ +{ + "type": "File", + "start":0,"end":83,"loc":{"start":{"line":1,"column":0},"end":{"line":7,"column":1}}, + "program": { + "type": "Program", + "start":0,"end":83,"loc":{"start":{"line":1,"column":0},"end":{"line":7,"column":1}}, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start":0,"end":83,"loc":{"start":{"line":1,"column":0},"end":{"line":7,"column":1}}, + "expression": { + "type": "BinaryExpression", + "start":0,"end":83,"loc":{"start":{"line":1,"column":0},"end":{"line":7,"column":1}}, + "left": { + "type": "Identifier", + "start":0,"end":5,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":5},"identifierName":"value"}, + "name": "value" + }, + "operator": "|>", + "right": { + "type": "DoExpression", + "start":9,"end":83,"loc":{"start":{"line":1,"column":9},"end":{"line":7,"column":1}}, + "async": false, + "body": { + "type": "BlockStatement", + "start":12,"end":83,"loc":{"start":{"line":1,"column":12},"end":{"line":7,"column":1}}, + "body": [ + { + "type": "SwitchStatement", + "start":16,"end":81,"loc":{"start":{"line":2,"column":2},"end":{"line":6,"column":3}}, + "discriminant": { + "type": "TopicReference", + "start":24,"end":25,"loc":{"start":{"line":2,"column":10},"end":{"line":2,"column":11}} + }, + "cases": [ + { + "type": "SwitchCase", + "start":33,"end":44,"loc":{"start":{"line":3,"column":4},"end":{"line":3,"column":15}}, + "consequent": [ + { + "type": "ExpressionStatement", + "start":41,"end":44,"loc":{"start":{"line":3,"column":12},"end":{"line":3,"column":15}}, + "expression": { + "type": "NumericLiteral", + "start":41,"end":43,"loc":{"start":{"line":3,"column":12},"end":{"line":3,"column":14}}, + "extra": { + "rawValue": 50, + "raw": "50" + }, + "value": 50 + } + } + ], + "test": { + "type": "NumericLiteral", + "start":38,"end":39,"loc":{"start":{"line":3,"column":9},"end":{"line":3,"column":10}}, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + } + }, + { + "type": "SwitchCase", + "start":49,"end":60,"loc":{"start":{"line":4,"column":4},"end":{"line":4,"column":15}}, + "consequent": [ + { + "type": "ExpressionStatement", + "start":57,"end":60,"loc":{"start":{"line":4,"column":12},"end":{"line":4,"column":15}}, + "expression": { + "type": "NumericLiteral", + "start":57,"end":59,"loc":{"start":{"line":4,"column":12},"end":{"line":4,"column":14}}, + "extra": { + "rawValue": 60, + "raw": "60" + }, + "value": 60 + } + } + ], + "test": { + "type": "NumericLiteral", + "start":54,"end":55,"loc":{"start":{"line":4,"column":9},"end":{"line":4,"column":10}}, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + } + }, + { + "type": "SwitchCase", + "start":65,"end":77,"loc":{"start":{"line":5,"column":4},"end":{"line":5,"column":16}}, + "consequent": [ + { + "type": "ExpressionStatement", + "start":74,"end":77,"loc":{"start":{"line":5,"column":13},"end":{"line":5,"column":16}}, + "expression": { + "type": "NumericLiteral", + "start":74,"end":76,"loc":{"start":{"line":5,"column":13},"end":{"line":5,"column":15}}, + "extra": { + "rawValue": 70, + "raw": "70" + }, + "value": 70 + } + } + ], + "test": null + } + ] + } + ], + "directives": [] + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-topic-identity/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-topic-identity/input.js new file mode 100644 index 0000000000..6e40629494 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-topic-identity/input.js @@ -0,0 +1 @@ +value |> do { %; } diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-topic-identity/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-topic-identity/options.json new file mode 100644 index 0000000000..59d88314f0 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-topic-identity/options.json @@ -0,0 +1,3 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "hack", "topicToken": "%" }], "doExpressions"] +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-topic-identity/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-topic-identity/output.json new file mode 100644 index 0000000000..46172d09d0 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-topic-identity/output.json @@ -0,0 +1,47 @@ +{ + "type": "File", + "start":0,"end":18,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":18}}, + "program": { + "type": "Program", + "start":0,"end":18,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":18}}, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start":0,"end":18,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":18}}, + "expression": { + "type": "BinaryExpression", + "start":0,"end":18,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":18}}, + "left": { + "type": "Identifier", + "start":0,"end":5,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":5},"identifierName":"value"}, + "name": "value" + }, + "operator": "|>", + "right": { + "type": "DoExpression", + "start":9,"end":18,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":18}}, + "async": false, + "body": { + "type": "BlockStatement", + "start":12,"end":18,"loc":{"start":{"line":1,"column":12},"end":{"line":1,"column":18}}, + "body": [ + { + "type": "ExpressionStatement", + "start":14,"end":16,"loc":{"start":{"line":1,"column":14},"end":{"line":1,"column":16}}, + "expression": { + "type": "TopicReference", + "start":14,"end":15,"loc":{"start":{"line":1,"column":14},"end":{"line":1,"column":15}} + } + } + ], + "directives": [] + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-try-catch-finally-statements-and-topic-in-catch-clause/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-try-catch-finally-statements-and-topic-in-catch-clause/input.js new file mode 100644 index 0000000000..d925d74f50 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-try-catch-finally-statements-and-topic-in-catch-clause/input.js @@ -0,0 +1,4 @@ +value |> do { + try { JSON.parse(%); } + catch (error) { console.error(%); } +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-try-catch-finally-statements-and-topic-in-catch-clause/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-try-catch-finally-statements-and-topic-in-catch-clause/options.json new file mode 100644 index 0000000000..59d88314f0 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-try-catch-finally-statements-and-topic-in-catch-clause/options.json @@ -0,0 +1,3 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "hack", "topicToken": "%" }], "doExpressions"] +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-try-catch-finally-statements-and-topic-in-catch-clause/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-try-catch-finally-statements-and-topic-in-catch-clause/output.json new file mode 100644 index 0000000000..e9be28defe --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-try-catch-finally-statements-and-topic-in-catch-clause/output.json @@ -0,0 +1,125 @@ +{ + "type": "File", + "start":0,"end":78,"loc":{"start":{"line":1,"column":0},"end":{"line":4,"column":1}}, + "program": { + "type": "Program", + "start":0,"end":78,"loc":{"start":{"line":1,"column":0},"end":{"line":4,"column":1}}, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start":0,"end":78,"loc":{"start":{"line":1,"column":0},"end":{"line":4,"column":1}}, + "expression": { + "type": "BinaryExpression", + "start":0,"end":78,"loc":{"start":{"line":1,"column":0},"end":{"line":4,"column":1}}, + "left": { + "type": "Identifier", + "start":0,"end":5,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":5},"identifierName":"value"}, + "name": "value" + }, + "operator": "|>", + "right": { + "type": "DoExpression", + "start":9,"end":78,"loc":{"start":{"line":1,"column":9},"end":{"line":4,"column":1}}, + "async": false, + "body": { + "type": "BlockStatement", + "start":12,"end":78,"loc":{"start":{"line":1,"column":12},"end":{"line":4,"column":1}}, + "body": [ + { + "type": "TryStatement", + "start":16,"end":76,"loc":{"start":{"line":2,"column":2},"end":{"line":3,"column":37}}, + "block": { + "type": "BlockStatement", + "start":20,"end":38,"loc":{"start":{"line":2,"column":6},"end":{"line":2,"column":24}}, + "body": [ + { + "type": "ExpressionStatement", + "start":22,"end":36,"loc":{"start":{"line":2,"column":8},"end":{"line":2,"column":22}}, + "expression": { + "type": "CallExpression", + "start":22,"end":35,"loc":{"start":{"line":2,"column":8},"end":{"line":2,"column":21}}, + "callee": { + "type": "MemberExpression", + "start":22,"end":32,"loc":{"start":{"line":2,"column":8},"end":{"line":2,"column":18}}, + "object": { + "type": "Identifier", + "start":22,"end":26,"loc":{"start":{"line":2,"column":8},"end":{"line":2,"column":12},"identifierName":"JSON"}, + "name": "JSON" + }, + "computed": false, + "property": { + "type": "Identifier", + "start":27,"end":32,"loc":{"start":{"line":2,"column":13},"end":{"line":2,"column":18},"identifierName":"parse"}, + "name": "parse" + } + }, + "arguments": [ + { + "type": "TopicReference", + "start":33,"end":34,"loc":{"start":{"line":2,"column":19},"end":{"line":2,"column":20}} + } + ] + } + } + ], + "directives": [] + }, + "handler": { + "type": "CatchClause", + "start":41,"end":76,"loc":{"start":{"line":3,"column":2},"end":{"line":3,"column":37}}, + "param": { + "type": "Identifier", + "start":48,"end":53,"loc":{"start":{"line":3,"column":9},"end":{"line":3,"column":14},"identifierName":"error"}, + "name": "error" + }, + "body": { + "type": "BlockStatement", + "start":55,"end":76,"loc":{"start":{"line":3,"column":16},"end":{"line":3,"column":37}}, + "body": [ + { + "type": "ExpressionStatement", + "start":57,"end":74,"loc":{"start":{"line":3,"column":18},"end":{"line":3,"column":35}}, + "expression": { + "type": "CallExpression", + "start":57,"end":73,"loc":{"start":{"line":3,"column":18},"end":{"line":3,"column":34}}, + "callee": { + "type": "MemberExpression", + "start":57,"end":70,"loc":{"start":{"line":3,"column":18},"end":{"line":3,"column":31}}, + "object": { + "type": "Identifier", + "start":57,"end":64,"loc":{"start":{"line":3,"column":18},"end":{"line":3,"column":25},"identifierName":"console"}, + "name": "console" + }, + "computed": false, + "property": { + "type": "Identifier", + "start":65,"end":70,"loc":{"start":{"line":3,"column":26},"end":{"line":3,"column":31},"identifierName":"error"}, + "name": "error" + } + }, + "arguments": [ + { + "type": "TopicReference", + "start":71,"end":72,"loc":{"start":{"line":3,"column":32},"end":{"line":3,"column":33}} + } + ] + } + } + ], + "directives": [] + } + }, + "finalizer": null + } + ], + "directives": [] + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-try-catch-finally-statements-and-topic-in-finally-clause/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-try-catch-finally-statements-and-topic-in-finally-clause/input.js new file mode 100644 index 0000000000..a0989fab8b --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-try-catch-finally-statements-and-topic-in-finally-clause/input.js @@ -0,0 +1,5 @@ +value |> do { + try { JSON.parse(whatever); } + catch (error) { console.error(error); } + finally { something(%); } +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-try-catch-finally-statements-and-topic-in-finally-clause/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-try-catch-finally-statements-and-topic-in-finally-clause/options.json new file mode 100644 index 0000000000..59d88314f0 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-try-catch-finally-statements-and-topic-in-finally-clause/options.json @@ -0,0 +1,3 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "hack", "topicToken": "%" }], "doExpressions"] +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-try-catch-finally-statements-and-topic-in-finally-clause/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-try-catch-finally-statements-and-topic-in-finally-clause/output.json new file mode 100644 index 0000000000..da5098b0f2 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-try-catch-finally-statements-and-topic-in-finally-clause/output.json @@ -0,0 +1,152 @@ +{ + "type": "File", + "start":0,"end":117,"loc":{"start":{"line":1,"column":0},"end":{"line":5,"column":1}}, + "program": { + "type": "Program", + "start":0,"end":117,"loc":{"start":{"line":1,"column":0},"end":{"line":5,"column":1}}, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start":0,"end":117,"loc":{"start":{"line":1,"column":0},"end":{"line":5,"column":1}}, + "expression": { + "type": "BinaryExpression", + "start":0,"end":117,"loc":{"start":{"line":1,"column":0},"end":{"line":5,"column":1}}, + "left": { + "type": "Identifier", + "start":0,"end":5,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":5},"identifierName":"value"}, + "name": "value" + }, + "operator": "|>", + "right": { + "type": "DoExpression", + "start":9,"end":117,"loc":{"start":{"line":1,"column":9},"end":{"line":5,"column":1}}, + "async": false, + "body": { + "type": "BlockStatement", + "start":12,"end":117,"loc":{"start":{"line":1,"column":12},"end":{"line":5,"column":1}}, + "body": [ + { + "type": "TryStatement", + "start":16,"end":115,"loc":{"start":{"line":2,"column":2},"end":{"line":4,"column":27}}, + "block": { + "type": "BlockStatement", + "start":20,"end":45,"loc":{"start":{"line":2,"column":6},"end":{"line":2,"column":31}}, + "body": [ + { + "type": "ExpressionStatement", + "start":22,"end":43,"loc":{"start":{"line":2,"column":8},"end":{"line":2,"column":29}}, + "expression": { + "type": "CallExpression", + "start":22,"end":42,"loc":{"start":{"line":2,"column":8},"end":{"line":2,"column":28}}, + "callee": { + "type": "MemberExpression", + "start":22,"end":32,"loc":{"start":{"line":2,"column":8},"end":{"line":2,"column":18}}, + "object": { + "type": "Identifier", + "start":22,"end":26,"loc":{"start":{"line":2,"column":8},"end":{"line":2,"column":12},"identifierName":"JSON"}, + "name": "JSON" + }, + "computed": false, + "property": { + "type": "Identifier", + "start":27,"end":32,"loc":{"start":{"line":2,"column":13},"end":{"line":2,"column":18},"identifierName":"parse"}, + "name": "parse" + } + }, + "arguments": [ + { + "type": "Identifier", + "start":33,"end":41,"loc":{"start":{"line":2,"column":19},"end":{"line":2,"column":27},"identifierName":"whatever"}, + "name": "whatever" + } + ] + } + } + ], + "directives": [] + }, + "handler": { + "type": "CatchClause", + "start":48,"end":87,"loc":{"start":{"line":3,"column":2},"end":{"line":3,"column":41}}, + "param": { + "type": "Identifier", + "start":55,"end":60,"loc":{"start":{"line":3,"column":9},"end":{"line":3,"column":14},"identifierName":"error"}, + "name": "error" + }, + "body": { + "type": "BlockStatement", + "start":62,"end":87,"loc":{"start":{"line":3,"column":16},"end":{"line":3,"column":41}}, + "body": [ + { + "type": "ExpressionStatement", + "start":64,"end":85,"loc":{"start":{"line":3,"column":18},"end":{"line":3,"column":39}}, + "expression": { + "type": "CallExpression", + "start":64,"end":84,"loc":{"start":{"line":3,"column":18},"end":{"line":3,"column":38}}, + "callee": { + "type": "MemberExpression", + "start":64,"end":77,"loc":{"start":{"line":3,"column":18},"end":{"line":3,"column":31}}, + "object": { + "type": "Identifier", + "start":64,"end":71,"loc":{"start":{"line":3,"column":18},"end":{"line":3,"column":25},"identifierName":"console"}, + "name": "console" + }, + "computed": false, + "property": { + "type": "Identifier", + "start":72,"end":77,"loc":{"start":{"line":3,"column":26},"end":{"line":3,"column":31},"identifierName":"error"}, + "name": "error" + } + }, + "arguments": [ + { + "type": "Identifier", + "start":78,"end":83,"loc":{"start":{"line":3,"column":32},"end":{"line":3,"column":37},"identifierName":"error"}, + "name": "error" + } + ] + } + } + ], + "directives": [] + } + }, + "finalizer": { + "type": "BlockStatement", + "start":98,"end":115,"loc":{"start":{"line":4,"column":10},"end":{"line":4,"column":27}}, + "body": [ + { + "type": "ExpressionStatement", + "start":100,"end":113,"loc":{"start":{"line":4,"column":12},"end":{"line":4,"column":25}}, + "expression": { + "type": "CallExpression", + "start":100,"end":112,"loc":{"start":{"line":4,"column":12},"end":{"line":4,"column":24}}, + "callee": { + "type": "Identifier", + "start":100,"end":109,"loc":{"start":{"line":4,"column":12},"end":{"line":4,"column":21},"identifierName":"something"}, + "name": "something" + }, + "arguments": [ + { + "type": "TopicReference", + "start":110,"end":111,"loc":{"start":{"line":4,"column":22},"end":{"line":4,"column":23}} + } + ] + } + } + ], + "directives": [] + } + } + ], + "directives": [] + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-try-catch-finally-statements-and-topic-in-try-clause/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-try-catch-finally-statements-and-topic-in-try-clause/input.js new file mode 100644 index 0000000000..5c9d17d44c --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-try-catch-finally-statements-and-topic-in-try-clause/input.js @@ -0,0 +1,5 @@ +value |> do { + try { JSON.parse(%); } + catch (error) { console.error(error); } + finally { something(); } +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-try-catch-finally-statements-and-topic-in-try-clause/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-try-catch-finally-statements-and-topic-in-try-clause/options.json new file mode 100644 index 0000000000..59d88314f0 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-try-catch-finally-statements-and-topic-in-try-clause/options.json @@ -0,0 +1,3 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "hack", "topicToken": "%" }], "doExpressions"] +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-try-catch-finally-statements-and-topic-in-try-clause/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-try-catch-finally-statements-and-topic-in-try-clause/output.json new file mode 100644 index 0000000000..06e9624daa --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-try-catch-finally-statements-and-topic-in-try-clause/output.json @@ -0,0 +1,146 @@ +{ + "type": "File", + "start":0,"end":109,"loc":{"start":{"line":1,"column":0},"end":{"line":5,"column":1}}, + "program": { + "type": "Program", + "start":0,"end":109,"loc":{"start":{"line":1,"column":0},"end":{"line":5,"column":1}}, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start":0,"end":109,"loc":{"start":{"line":1,"column":0},"end":{"line":5,"column":1}}, + "expression": { + "type": "BinaryExpression", + "start":0,"end":109,"loc":{"start":{"line":1,"column":0},"end":{"line":5,"column":1}}, + "left": { + "type": "Identifier", + "start":0,"end":5,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":5},"identifierName":"value"}, + "name": "value" + }, + "operator": "|>", + "right": { + "type": "DoExpression", + "start":9,"end":109,"loc":{"start":{"line":1,"column":9},"end":{"line":5,"column":1}}, + "async": false, + "body": { + "type": "BlockStatement", + "start":12,"end":109,"loc":{"start":{"line":1,"column":12},"end":{"line":5,"column":1}}, + "body": [ + { + "type": "TryStatement", + "start":16,"end":107,"loc":{"start":{"line":2,"column":2},"end":{"line":4,"column":26}}, + "block": { + "type": "BlockStatement", + "start":20,"end":38,"loc":{"start":{"line":2,"column":6},"end":{"line":2,"column":24}}, + "body": [ + { + "type": "ExpressionStatement", + "start":22,"end":36,"loc":{"start":{"line":2,"column":8},"end":{"line":2,"column":22}}, + "expression": { + "type": "CallExpression", + "start":22,"end":35,"loc":{"start":{"line":2,"column":8},"end":{"line":2,"column":21}}, + "callee": { + "type": "MemberExpression", + "start":22,"end":32,"loc":{"start":{"line":2,"column":8},"end":{"line":2,"column":18}}, + "object": { + "type": "Identifier", + "start":22,"end":26,"loc":{"start":{"line":2,"column":8},"end":{"line":2,"column":12},"identifierName":"JSON"}, + "name": "JSON" + }, + "computed": false, + "property": { + "type": "Identifier", + "start":27,"end":32,"loc":{"start":{"line":2,"column":13},"end":{"line":2,"column":18},"identifierName":"parse"}, + "name": "parse" + } + }, + "arguments": [ + { + "type": "TopicReference", + "start":33,"end":34,"loc":{"start":{"line":2,"column":19},"end":{"line":2,"column":20}} + } + ] + } + } + ], + "directives": [] + }, + "handler": { + "type": "CatchClause", + "start":41,"end":80,"loc":{"start":{"line":3,"column":2},"end":{"line":3,"column":41}}, + "param": { + "type": "Identifier", + "start":48,"end":53,"loc":{"start":{"line":3,"column":9},"end":{"line":3,"column":14},"identifierName":"error"}, + "name": "error" + }, + "body": { + "type": "BlockStatement", + "start":55,"end":80,"loc":{"start":{"line":3,"column":16},"end":{"line":3,"column":41}}, + "body": [ + { + "type": "ExpressionStatement", + "start":57,"end":78,"loc":{"start":{"line":3,"column":18},"end":{"line":3,"column":39}}, + "expression": { + "type": "CallExpression", + "start":57,"end":77,"loc":{"start":{"line":3,"column":18},"end":{"line":3,"column":38}}, + "callee": { + "type": "MemberExpression", + "start":57,"end":70,"loc":{"start":{"line":3,"column":18},"end":{"line":3,"column":31}}, + "object": { + "type": "Identifier", + "start":57,"end":64,"loc":{"start":{"line":3,"column":18},"end":{"line":3,"column":25},"identifierName":"console"}, + "name": "console" + }, + "computed": false, + "property": { + "type": "Identifier", + "start":65,"end":70,"loc":{"start":{"line":3,"column":26},"end":{"line":3,"column":31},"identifierName":"error"}, + "name": "error" + } + }, + "arguments": [ + { + "type": "Identifier", + "start":71,"end":76,"loc":{"start":{"line":3,"column":32},"end":{"line":3,"column":37},"identifierName":"error"}, + "name": "error" + } + ] + } + } + ], + "directives": [] + } + }, + "finalizer": { + "type": "BlockStatement", + "start":91,"end":107,"loc":{"start":{"line":4,"column":10},"end":{"line":4,"column":26}}, + "body": [ + { + "type": "ExpressionStatement", + "start":93,"end":105,"loc":{"start":{"line":4,"column":12},"end":{"line":4,"column":24}}, + "expression": { + "type": "CallExpression", + "start":93,"end":104,"loc":{"start":{"line":4,"column":12},"end":{"line":4,"column":23}}, + "callee": { + "type": "Identifier", + "start":93,"end":102,"loc":{"start":{"line":4,"column":12},"end":{"line":4,"column":21},"identifierName":"something"}, + "name": "something" + }, + "arguments": [] + } + } + ], + "directives": [] + } + } + ], + "directives": [] + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-try-catch-statements-topic-in-try-clause/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-try-catch-statements-topic-in-try-clause/input.js new file mode 100644 index 0000000000..8c0bc16585 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-try-catch-statements-topic-in-try-clause/input.js @@ -0,0 +1,4 @@ +value |> do { + try { JSON.parse(%); } + catch (error) { console.error(error); } +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-try-catch-statements-topic-in-try-clause/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-try-catch-statements-topic-in-try-clause/options.json new file mode 100644 index 0000000000..59d88314f0 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-try-catch-statements-topic-in-try-clause/options.json @@ -0,0 +1,3 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "hack", "topicToken": "%" }], "doExpressions"] +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-try-catch-statements-topic-in-try-clause/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-try-catch-statements-topic-in-try-clause/output.json new file mode 100644 index 0000000000..7ce5dce3c2 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-try-catch-statements-topic-in-try-clause/output.json @@ -0,0 +1,126 @@ +{ + "type": "File", + "start":0,"end":82,"loc":{"start":{"line":1,"column":0},"end":{"line":4,"column":1}}, + "program": { + "type": "Program", + "start":0,"end":82,"loc":{"start":{"line":1,"column":0},"end":{"line":4,"column":1}}, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start":0,"end":82,"loc":{"start":{"line":1,"column":0},"end":{"line":4,"column":1}}, + "expression": { + "type": "BinaryExpression", + "start":0,"end":82,"loc":{"start":{"line":1,"column":0},"end":{"line":4,"column":1}}, + "left": { + "type": "Identifier", + "start":0,"end":5,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":5},"identifierName":"value"}, + "name": "value" + }, + "operator": "|>", + "right": { + "type": "DoExpression", + "start":9,"end":82,"loc":{"start":{"line":1,"column":9},"end":{"line":4,"column":1}}, + "async": false, + "body": { + "type": "BlockStatement", + "start":12,"end":82,"loc":{"start":{"line":1,"column":12},"end":{"line":4,"column":1}}, + "body": [ + { + "type": "TryStatement", + "start":16,"end":80,"loc":{"start":{"line":2,"column":2},"end":{"line":3,"column":41}}, + "block": { + "type": "BlockStatement", + "start":20,"end":38,"loc":{"start":{"line":2,"column":6},"end":{"line":2,"column":24}}, + "body": [ + { + "type": "ExpressionStatement", + "start":22,"end":36,"loc":{"start":{"line":2,"column":8},"end":{"line":2,"column":22}}, + "expression": { + "type": "CallExpression", + "start":22,"end":35,"loc":{"start":{"line":2,"column":8},"end":{"line":2,"column":21}}, + "callee": { + "type": "MemberExpression", + "start":22,"end":32,"loc":{"start":{"line":2,"column":8},"end":{"line":2,"column":18}}, + "object": { + "type": "Identifier", + "start":22,"end":26,"loc":{"start":{"line":2,"column":8},"end":{"line":2,"column":12},"identifierName":"JSON"}, + "name": "JSON" + }, + "computed": false, + "property": { + "type": "Identifier", + "start":27,"end":32,"loc":{"start":{"line":2,"column":13},"end":{"line":2,"column":18},"identifierName":"parse"}, + "name": "parse" + } + }, + "arguments": [ + { + "type": "TopicReference", + "start":33,"end":34,"loc":{"start":{"line":2,"column":19},"end":{"line":2,"column":20}} + } + ] + } + } + ], + "directives": [] + }, + "handler": { + "type": "CatchClause", + "start":41,"end":80,"loc":{"start":{"line":3,"column":2},"end":{"line":3,"column":41}}, + "param": { + "type": "Identifier", + "start":48,"end":53,"loc":{"start":{"line":3,"column":9},"end":{"line":3,"column":14},"identifierName":"error"}, + "name": "error" + }, + "body": { + "type": "BlockStatement", + "start":55,"end":80,"loc":{"start":{"line":3,"column":16},"end":{"line":3,"column":41}}, + "body": [ + { + "type": "ExpressionStatement", + "start":57,"end":78,"loc":{"start":{"line":3,"column":18},"end":{"line":3,"column":39}}, + "expression": { + "type": "CallExpression", + "start":57,"end":77,"loc":{"start":{"line":3,"column":18},"end":{"line":3,"column":38}}, + "callee": { + "type": "MemberExpression", + "start":57,"end":70,"loc":{"start":{"line":3,"column":18},"end":{"line":3,"column":31}}, + "object": { + "type": "Identifier", + "start":57,"end":64,"loc":{"start":{"line":3,"column":18},"end":{"line":3,"column":25},"identifierName":"console"}, + "name": "console" + }, + "computed": false, + "property": { + "type": "Identifier", + "start":65,"end":70,"loc":{"start":{"line":3,"column":26},"end":{"line":3,"column":31},"identifierName":"error"}, + "name": "error" + } + }, + "arguments": [ + { + "type": "Identifier", + "start":71,"end":76,"loc":{"start":{"line":3,"column":32},"end":{"line":3,"column":37},"identifierName":"error"}, + "name": "error" + } + ] + } + } + ], + "directives": [] + } + }, + "finalizer": null + } + ], + "directives": [] + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-while-loop-topic-in-loop-body/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-while-loop-topic-in-loop-body/input.js new file mode 100644 index 0000000000..5e38aadc91 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-while-loop-topic-in-loop-body/input.js @@ -0,0 +1 @@ +value |> do { while (x < 50) x += %; } diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-while-loop-topic-in-loop-body/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-while-loop-topic-in-loop-body/options.json new file mode 100644 index 0000000000..59d88314f0 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-while-loop-topic-in-loop-body/options.json @@ -0,0 +1,3 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "hack", "topicToken": "%" }], "doExpressions"] +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-while-loop-topic-in-loop-body/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-while-loop-topic-in-loop-body/output.json new file mode 100644 index 0000000000..39d0d923a8 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-while-loop-topic-in-loop-body/output.json @@ -0,0 +1,80 @@ +{ + "type": "File", + "start":0,"end":38,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":38}}, + "program": { + "type": "Program", + "start":0,"end":38,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":38}}, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start":0,"end":38,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":38}}, + "expression": { + "type": "BinaryExpression", + "start":0,"end":38,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":38}}, + "left": { + "type": "Identifier", + "start":0,"end":5,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":5},"identifierName":"value"}, + "name": "value" + }, + "operator": "|>", + "right": { + "type": "DoExpression", + "start":9,"end":38,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":38}}, + "async": false, + "body": { + "type": "BlockStatement", + "start":12,"end":38,"loc":{"start":{"line":1,"column":12},"end":{"line":1,"column":38}}, + "body": [ + { + "type": "WhileStatement", + "start":14,"end":36,"loc":{"start":{"line":1,"column":14},"end":{"line":1,"column":36}}, + "test": { + "type": "BinaryExpression", + "start":21,"end":27,"loc":{"start":{"line":1,"column":21},"end":{"line":1,"column":27}}, + "left": { + "type": "Identifier", + "start":21,"end":22,"loc":{"start":{"line":1,"column":21},"end":{"line":1,"column":22},"identifierName":"x"}, + "name": "x" + }, + "operator": "<", + "right": { + "type": "NumericLiteral", + "start":25,"end":27,"loc":{"start":{"line":1,"column":25},"end":{"line":1,"column":27}}, + "extra": { + "rawValue": 50, + "raw": "50" + }, + "value": 50 + } + }, + "body": { + "type": "ExpressionStatement", + "start":29,"end":36,"loc":{"start":{"line":1,"column":29},"end":{"line":1,"column":36}}, + "expression": { + "type": "AssignmentExpression", + "start":29,"end":35,"loc":{"start":{"line":1,"column":29},"end":{"line":1,"column":35}}, + "operator": "+=", + "left": { + "type": "Identifier", + "start":29,"end":30,"loc":{"start":{"line":1,"column":29},"end":{"line":1,"column":30},"identifierName":"x"}, + "name": "x" + }, + "right": { + "type": "TopicReference", + "start":34,"end":35,"loc":{"start":{"line":1,"column":34},"end":{"line":1,"column":35}} + } + } + } + } + ], + "directives": [] + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-while-loop-topic-in-loop-head/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-while-loop-topic-in-loop-head/input.js new file mode 100644 index 0000000000..621f14b936 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-while-loop-topic-in-loop-head/input.js @@ -0,0 +1 @@ +value |> do { while (x < %) x += 1; } diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-while-loop-topic-in-loop-head/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-while-loop-topic-in-loop-head/options.json new file mode 100644 index 0000000000..59d88314f0 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-while-loop-topic-in-loop-head/options.json @@ -0,0 +1,3 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "hack", "topicToken": "%" }], "doExpressions"] +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-while-loop-topic-in-loop-head/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-while-loop-topic-in-loop-head/output.json new file mode 100644 index 0000000000..56f5af6523 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-while-loop-topic-in-loop-head/output.json @@ -0,0 +1,80 @@ +{ + "type": "File", + "start":0,"end":37,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":37}}, + "program": { + "type": "Program", + "start":0,"end":37,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":37}}, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start":0,"end":37,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":37}}, + "expression": { + "type": "BinaryExpression", + "start":0,"end":37,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":37}}, + "left": { + "type": "Identifier", + "start":0,"end":5,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":5},"identifierName":"value"}, + "name": "value" + }, + "operator": "|>", + "right": { + "type": "DoExpression", + "start":9,"end":37,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":37}}, + "async": false, + "body": { + "type": "BlockStatement", + "start":12,"end":37,"loc":{"start":{"line":1,"column":12},"end":{"line":1,"column":37}}, + "body": [ + { + "type": "WhileStatement", + "start":14,"end":35,"loc":{"start":{"line":1,"column":14},"end":{"line":1,"column":35}}, + "test": { + "type": "BinaryExpression", + "start":21,"end":26,"loc":{"start":{"line":1,"column":21},"end":{"line":1,"column":26}}, + "left": { + "type": "Identifier", + "start":21,"end":22,"loc":{"start":{"line":1,"column":21},"end":{"line":1,"column":22},"identifierName":"x"}, + "name": "x" + }, + "operator": "<", + "right": { + "type": "TopicReference", + "start":25,"end":26,"loc":{"start":{"line":1,"column":25},"end":{"line":1,"column":26}} + } + }, + "body": { + "type": "ExpressionStatement", + "start":28,"end":35,"loc":{"start":{"line":1,"column":28},"end":{"line":1,"column":35}}, + "expression": { + "type": "AssignmentExpression", + "start":28,"end":34,"loc":{"start":{"line":1,"column":28},"end":{"line":1,"column":34}}, + "operator": "+=", + "left": { + "type": "Identifier", + "start":28,"end":29,"loc":{"start":{"line":1,"column":28},"end":{"line":1,"column":29},"identifierName":"x"}, + "name": "x" + }, + "right": { + "type": "NumericLiteral", + "start":33,"end":34,"loc":{"start":{"line":1,"column":33},"end":{"line":1,"column":34}}, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + } + } + } + } + ], + "directives": [] + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-with-block-topic-in-body/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-with-block-topic-in-body/input.js new file mode 100644 index 0000000000..5f89c3d3b2 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-with-block-topic-in-body/input.js @@ -0,0 +1 @@ +value |> do { with ({}) %; } diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-with-block-topic-in-body/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-with-block-topic-in-body/options.json new file mode 100644 index 0000000000..59d88314f0 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-with-block-topic-in-body/options.json @@ -0,0 +1,3 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "hack", "topicToken": "%" }], "doExpressions"] +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-with-block-topic-in-body/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-with-block-topic-in-body/output.json new file mode 100644 index 0000000000..9c21b42532 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-do-transform-with-block-topic-in-body/output.json @@ -0,0 +1,56 @@ +{ + "type": "File", + "start":0,"end":28,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":28}}, + "program": { + "type": "Program", + "start":0,"end":28,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":28}}, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start":0,"end":28,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":28}}, + "expression": { + "type": "BinaryExpression", + "start":0,"end":28,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":28}}, + "left": { + "type": "Identifier", + "start":0,"end":5,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":5},"identifierName":"value"}, + "name": "value" + }, + "operator": "|>", + "right": { + "type": "DoExpression", + "start":9,"end":28,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":28}}, + "async": false, + "body": { + "type": "BlockStatement", + "start":12,"end":28,"loc":{"start":{"line":1,"column":12},"end":{"line":1,"column":28}}, + "body": [ + { + "type": "WithStatement", + "start":14,"end":26,"loc":{"start":{"line":1,"column":14},"end":{"line":1,"column":26}}, + "object": { + "type": "ObjectExpression", + "start":20,"end":22,"loc":{"start":{"line":1,"column":20},"end":{"line":1,"column":22}}, + "properties": [] + }, + "body": { + "type": "ExpressionStatement", + "start":24,"end":26,"loc":{"start":{"line":1,"column":24},"end":{"line":1,"column":26}}, + "expression": { + "type": "TopicReference", + "start":24,"end":25,"loc":{"start":{"line":1,"column":24},"end":{"line":1,"column":25}} + } + } + } + ], + "directives": [] + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-equality-loose-with-topic-first-without-spaces/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-equality-loose-with-topic-first-without-spaces/input.js new file mode 100644 index 0000000000..ba8145cdfb --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-equality-loose-with-topic-first-without-spaces/input.js @@ -0,0 +1 @@ +value |> %==1 diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-equality-loose-with-topic-first-without-spaces/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-equality-loose-with-topic-first-without-spaces/options.json new file mode 100644 index 0000000000..cfbb793386 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-equality-loose-with-topic-first-without-spaces/options.json @@ -0,0 +1,3 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "hack", "topicToken": "%" }]] +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-equality-loose-with-topic-first-without-spaces/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-equality-loose-with-topic-first-without-spaces/output.json new file mode 100644 index 0000000000..7ade0b76cf --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-equality-loose-with-topic-first-without-spaces/output.json @@ -0,0 +1,45 @@ +{ + "type": "File", + "start":0,"end":13,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":13}}, + "program": { + "type": "Program", + "start":0,"end":13,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":13}}, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start":0,"end":13,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":13}}, + "expression": { + "type": "BinaryExpression", + "start":0,"end":13,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":13}}, + "left": { + "type": "Identifier", + "start":0,"end":5,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":5},"identifierName":"value"}, + "name": "value" + }, + "operator": "|>", + "right": { + "type": "BinaryExpression", + "start":9,"end":13,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":13}}, + "left": { + "type": "TopicReference", + "start":9,"end":10,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":10}} + }, + "operator": "==", + "right": { + "type": "NumericLiteral", + "start":12,"end":13,"loc":{"start":{"line":1,"column":12},"end":{"line":1,"column":13}}, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-equality-strict-with-topic-first-without-spaces/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-equality-strict-with-topic-first-without-spaces/input.js new file mode 100644 index 0000000000..99e5cbd826 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-equality-strict-with-topic-first-without-spaces/input.js @@ -0,0 +1 @@ +value |> %===1 diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-equality-strict-with-topic-first-without-spaces/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-equality-strict-with-topic-first-without-spaces/options.json new file mode 100644 index 0000000000..cfbb793386 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-equality-strict-with-topic-first-without-spaces/options.json @@ -0,0 +1,3 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "hack", "topicToken": "%" }]] +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-equality-strict-with-topic-first-without-spaces/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-equality-strict-with-topic-first-without-spaces/output.json new file mode 100644 index 0000000000..229fcca783 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-equality-strict-with-topic-first-without-spaces/output.json @@ -0,0 +1,45 @@ +{ + "type": "File", + "start":0,"end":14,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":14}}, + "program": { + "type": "Program", + "start":0,"end":14,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":14}}, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start":0,"end":14,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":14}}, + "expression": { + "type": "BinaryExpression", + "start":0,"end":14,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":14}}, + "left": { + "type": "Identifier", + "start":0,"end":5,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":5},"identifierName":"value"}, + "name": "value" + }, + "operator": "|>", + "right": { + "type": "BinaryExpression", + "start":9,"end":14,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":14}}, + "left": { + "type": "TopicReference", + "start":9,"end":10,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":10}} + }, + "operator": "===", + "right": { + "type": "NumericLiteral", + "start":13,"end":14,"loc":{"start":{"line":1,"column":13},"end":{"line":1,"column":14}}, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-function-call-with-topic-in-argument/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-function-call-with-topic-in-argument/input.js new file mode 100644 index 0000000000..b88b64f9de --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-function-call-with-topic-in-argument/input.js @@ -0,0 +1 @@ +value |> f(%) diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-function-call-with-topic-in-argument/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-function-call-with-topic-in-argument/options.json new file mode 100644 index 0000000000..cfbb793386 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-function-call-with-topic-in-argument/options.json @@ -0,0 +1,3 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "hack", "topicToken": "%" }]] +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-function-call-with-topic-in-argument/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-function-call-with-topic-in-argument/output.json new file mode 100644 index 0000000000..81ae12185c --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-function-call-with-topic-in-argument/output.json @@ -0,0 +1,42 @@ +{ + "type": "File", + "start":0,"end":13,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":13}}, + "program": { + "type": "Program", + "start":0,"end":13,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":13}}, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start":0,"end":13,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":13}}, + "expression": { + "type": "BinaryExpression", + "start":0,"end":13,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":13}}, + "left": { + "type": "Identifier", + "start":0,"end":5,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":5},"identifierName":"value"}, + "name": "value" + }, + "operator": "|>", + "right": { + "type": "CallExpression", + "start":9,"end":13,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":13}}, + "callee": { + "type": "Identifier", + "start":9,"end":10,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":10},"identifierName":"f"}, + "name": "f" + }, + "arguments": [ + { + "type": "TopicReference", + "start":11,"end":12,"loc":{"start":{"line":1,"column":11},"end":{"line":1,"column":12}} + } + ] + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-function-call-without-topic/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-function-call-without-topic/input.js new file mode 100644 index 0000000000..15a3d7657b --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-function-call-without-topic/input.js @@ -0,0 +1 @@ +value |> f diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-function-call-without-topic/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-function-call-without-topic/options.json new file mode 100644 index 0000000000..cfbb793386 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-function-call-without-topic/options.json @@ -0,0 +1,3 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "hack", "topicToken": "%" }]] +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-function-call-without-topic/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-function-call-without-topic/output.json new file mode 100644 index 0000000000..3917568d72 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-function-call-without-topic/output.json @@ -0,0 +1,35 @@ +{ + "type": "File", + "start":0,"end":10,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":10}}, + "errors": [ + "SyntaxError: Hack-style pipe body does not contain a topic reference; Hack-style pipes must use topic at least once. (1:9)" + ], + "program": { + "type": "Program", + "start":0,"end":10,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":10}}, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start":0,"end":10,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":10}}, + "expression": { + "type": "BinaryExpression", + "start":0,"end":10,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":10}}, + "left": { + "type": "Identifier", + "start":0,"end":5,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":5},"identifierName":"value"}, + "name": "value" + }, + "operator": "|>", + "right": { + "type": "Identifier", + "start":9,"end":10,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":10},"identifierName":"f"}, + "name": "f" + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-function-definition-with-another-pipe-in-function-body/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-function-definition-with-another-pipe-in-function-body/input.js new file mode 100644 index 0000000000..02f06172d6 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-function-definition-with-another-pipe-in-function-body/input.js @@ -0,0 +1 @@ +x |> function () { % |> % } diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-function-definition-with-another-pipe-in-function-body/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-function-definition-with-another-pipe-in-function-body/options.json new file mode 100644 index 0000000000..cfbb793386 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-function-definition-with-another-pipe-in-function-body/options.json @@ -0,0 +1,3 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "hack", "topicToken": "%" }]] +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-function-definition-with-another-pipe-in-function-body/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-function-definition-with-another-pipe-in-function-body/output.json new file mode 100644 index 0000000000..78c6b8cd0a --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-function-definition-with-another-pipe-in-function-body/output.json @@ -0,0 +1,59 @@ +{ + "type": "File", + "start":0,"end":27,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":27}}, + "program": { + "type": "Program", + "start":0,"end":27,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":27}}, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start":0,"end":27,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":27}}, + "expression": { + "type": "BinaryExpression", + "start":0,"end":27,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":27}}, + "left": { + "type": "Identifier", + "start":0,"end":1,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":1},"identifierName":"x"}, + "name": "x" + }, + "operator": "|>", + "right": { + "type": "FunctionExpression", + "start":5,"end":27,"loc":{"start":{"line":1,"column":5},"end":{"line":1,"column":27}}, + "id": null, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start":17,"end":27,"loc":{"start":{"line":1,"column":17},"end":{"line":1,"column":27}}, + "body": [ + { + "type": "ExpressionStatement", + "start":19,"end":25,"loc":{"start":{"line":1,"column":19},"end":{"line":1,"column":25}}, + "expression": { + "type": "BinaryExpression", + "start":19,"end":25,"loc":{"start":{"line":1,"column":19},"end":{"line":1,"column":25}}, + "left": { + "type": "TopicReference", + "start":19,"end":20,"loc":{"start":{"line":1,"column":19},"end":{"line":1,"column":20}} + }, + "operator": "|>", + "right": { + "type": "TopicReference", + "start":24,"end":25,"loc":{"start":{"line":1,"column":24},"end":{"line":1,"column":25}} + } + } + } + ], + "directives": [] + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-function-definition-with-topic-in-default-parameter/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-function-definition-with-topic-in-default-parameter/input.js new file mode 100644 index 0000000000..bca4dee82a --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-function-definition-with-topic-in-default-parameter/input.js @@ -0,0 +1 @@ +value |> function (x = %) { return x; } diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-function-definition-with-topic-in-default-parameter/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-function-definition-with-topic-in-default-parameter/options.json new file mode 100644 index 0000000000..cfbb793386 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-function-definition-with-topic-in-default-parameter/options.json @@ -0,0 +1,3 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "hack", "topicToken": "%" }]] +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-function-definition-with-topic-in-default-parameter/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-function-definition-with-topic-in-default-parameter/output.json new file mode 100644 index 0000000000..3895abf6bf --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-function-definition-with-topic-in-default-parameter/output.json @@ -0,0 +1,65 @@ +{ + "type": "File", + "start":0,"end":39,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":39}}, + "program": { + "type": "Program", + "start":0,"end":39,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":39}}, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start":0,"end":39,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":39}}, + "expression": { + "type": "BinaryExpression", + "start":0,"end":39,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":39}}, + "left": { + "type": "Identifier", + "start":0,"end":5,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":5},"identifierName":"value"}, + "name": "value" + }, + "operator": "|>", + "right": { + "type": "FunctionExpression", + "start":9,"end":39,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":39}}, + "id": null, + "generator": false, + "async": false, + "params": [ + { + "type": "AssignmentPattern", + "start":19,"end":24,"loc":{"start":{"line":1,"column":19},"end":{"line":1,"column":24}}, + "left": { + "type": "Identifier", + "start":19,"end":20,"loc":{"start":{"line":1,"column":19},"end":{"line":1,"column":20},"identifierName":"x"}, + "name": "x" + }, + "right": { + "type": "TopicReference", + "start":23,"end":24,"loc":{"start":{"line":1,"column":23},"end":{"line":1,"column":24}} + } + } + ], + "body": { + "type": "BlockStatement", + "start":26,"end":39,"loc":{"start":{"line":1,"column":26},"end":{"line":1,"column":39}}, + "body": [ + { + "type": "ReturnStatement", + "start":28,"end":37,"loc":{"start":{"line":1,"column":28},"end":{"line":1,"column":37}}, + "argument": { + "type": "Identifier", + "start":35,"end":36,"loc":{"start":{"line":1,"column":35},"end":{"line":1,"column":36},"identifierName":"x"}, + "name": "x" + } + } + ], + "directives": [] + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-function-definition-with-topic-in-function-body/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-function-definition-with-topic-in-function-body/input.js new file mode 100644 index 0000000000..b50efddbeb --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-function-definition-with-topic-in-function-body/input.js @@ -0,0 +1 @@ +x |> function () { % } diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-function-definition-with-topic-in-function-body/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-function-definition-with-topic-in-function-body/options.json new file mode 100644 index 0000000000..cfbb793386 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-function-definition-with-topic-in-function-body/options.json @@ -0,0 +1,3 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "hack", "topicToken": "%" }]] +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-function-definition-with-topic-in-function-body/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-function-definition-with-topic-in-function-body/output.json new file mode 100644 index 0000000000..8dc59aef9a --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-function-definition-with-topic-in-function-body/output.json @@ -0,0 +1,50 @@ +{ + "type": "File", + "start":0,"end":22,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":22}}, + "program": { + "type": "Program", + "start":0,"end":22,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":22}}, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start":0,"end":22,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":22}}, + "expression": { + "type": "BinaryExpression", + "start":0,"end":22,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":22}}, + "left": { + "type": "Identifier", + "start":0,"end":1,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":1},"identifierName":"x"}, + "name": "x" + }, + "operator": "|>", + "right": { + "type": "FunctionExpression", + "start":5,"end":22,"loc":{"start":{"line":1,"column":5},"end":{"line":1,"column":22}}, + "id": null, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start":17,"end":22,"loc":{"start":{"line":1,"column":17},"end":{"line":1,"column":22}}, + "body": [ + { + "type": "ExpressionStatement", + "start":19,"end":20,"loc":{"start":{"line":1,"column":19},"end":{"line":1,"column":20}}, + "expression": { + "type": "TopicReference", + "start":19,"end":20,"loc":{"start":{"line":1,"column":19},"end":{"line":1,"column":20}} + } + } + ], + "directives": [] + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-generator-yield-parenthesized/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-generator-yield-parenthesized/input.js new file mode 100644 index 0000000000..b9e4f761c9 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-generator-yield-parenthesized/input.js @@ -0,0 +1,3 @@ +function * f (x) { + return x |> (yield %); +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-generator-yield-parenthesized/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-generator-yield-parenthesized/options.json new file mode 100644 index 0000000000..cfbb793386 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-generator-yield-parenthesized/options.json @@ -0,0 +1,3 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "hack", "topicToken": "%" }]] +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-generator-yield-parenthesized/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-generator-yield-parenthesized/output.json new file mode 100644 index 0000000000..e9e11c6eef --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-generator-yield-parenthesized/output.json @@ -0,0 +1,65 @@ +{ + "type": "File", + "start":0,"end":45,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}}, + "program": { + "type": "Program", + "start":0,"end":45,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}}, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start":0,"end":45,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}}, + "id": { + "type": "Identifier", + "start":11,"end":12,"loc":{"start":{"line":1,"column":11},"end":{"line":1,"column":12},"identifierName":"f"}, + "name": "f" + }, + "generator": true, + "async": false, + "params": [ + { + "type": "Identifier", + "start":14,"end":15,"loc":{"start":{"line":1,"column":14},"end":{"line":1,"column":15},"identifierName":"x"}, + "name": "x" + } + ], + "body": { + "type": "BlockStatement", + "start":17,"end":45,"loc":{"start":{"line":1,"column":17},"end":{"line":3,"column":1}}, + "body": [ + { + "type": "ReturnStatement", + "start":21,"end":43,"loc":{"start":{"line":2,"column":2},"end":{"line":2,"column":24}}, + "argument": { + "type": "BinaryExpression", + "start":28,"end":42,"loc":{"start":{"line":2,"column":9},"end":{"line":2,"column":23}}, + "left": { + "type": "Identifier", + "start":28,"end":29,"loc":{"start":{"line":2,"column":9},"end":{"line":2,"column":10},"identifierName":"x"}, + "name": "x" + }, + "operator": "|>", + "right": { + "type": "YieldExpression", + "start":34,"end":41,"loc":{"start":{"line":2,"column":15},"end":{"line":2,"column":22}}, + "extra": { + "parenthesized": true, + "parenStart": 33 + }, + "delegate": false, + "argument": { + "type": "TopicReference", + "start":40,"end":41,"loc":{"start":{"line":2,"column":21},"end":{"line":2,"column":22}} + } + } + } + } + ], + "directives": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-generator-yield-unparenthesized/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-generator-yield-unparenthesized/input.js new file mode 100644 index 0000000000..4fe9d94e7c --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-generator-yield-unparenthesized/input.js @@ -0,0 +1,3 @@ +function * f (x) { + return x |> yield %; +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-generator-yield-unparenthesized/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-generator-yield-unparenthesized/options.json new file mode 100644 index 0000000000..c75a5d4a54 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-generator-yield-unparenthesized/options.json @@ -0,0 +1,4 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "hack", "topicToken": "%" }]], + "throws": "Unexpected yield after pipeline body; any yield expression acting as Hack-style pipe body must be parenthesized due to its loose operator precedence. (2:14)" +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-hash-topic/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-hash-topic/input.js new file mode 100644 index 0000000000..a18cbd0f1b --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-hash-topic/input.js @@ -0,0 +1 @@ +value |> # diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-hash-topic/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-hash-topic/options.json new file mode 100644 index 0000000000..86ccb2e67e --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-hash-topic/options.json @@ -0,0 +1,4 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "hack", "topicToken": "%" }]], + "throws": "Invalid topic token #. In order to use # as a topic reference, the pipelineOperator plugin must be configured with { \"proposal\": \"hack\", \"topicToken\": \"#\" }. (1:9)" +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-hash-tuple/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-hash-tuple/input.js new file mode 100644 index 0000000000..dd96171689 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-hash-tuple/input.js @@ -0,0 +1,2 @@ +#[0]; +1 |> #[0, %]; diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-hash-tuple/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-hash-tuple/options.json new file mode 100644 index 0000000000..d2463c4b82 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-hash-tuple/options.json @@ -0,0 +1,6 @@ +{ + "plugins": [ + ["pipelineOperator", { "proposal": "hack", "topicToken": "%" }], + ["recordAndTuple", { "syntaxType": "hash" }] + ] +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-hash-tuple/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-hash-tuple/output.json new file mode 100644 index 0000000000..cb9f008888 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-hash-tuple/output.json @@ -0,0 +1,69 @@ +{ + "type": "File", + "start":0,"end":19,"loc":{"start":{"line":1,"column":0},"end":{"line":2,"column":13}}, + "program": { + "type": "Program", + "start":0,"end":19,"loc":{"start":{"line":1,"column":0},"end":{"line":2,"column":13}}, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start":0,"end":5,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":5}}, + "expression": { + "type": "TupleExpression", + "start":0,"end":4,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":4}}, + "elements": [ + { + "type": "NumericLiteral", + "start":2,"end":3,"loc":{"start":{"line":1,"column":2},"end":{"line":1,"column":3}}, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + } + ] + } + }, + { + "type": "ExpressionStatement", + "start":6,"end":19,"loc":{"start":{"line":2,"column":0},"end":{"line":2,"column":13}}, + "expression": { + "type": "BinaryExpression", + "start":6,"end":18,"loc":{"start":{"line":2,"column":0},"end":{"line":2,"column":12}}, + "left": { + "type": "NumericLiteral", + "start":6,"end":7,"loc":{"start":{"line":2,"column":0},"end":{"line":2,"column":1}}, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + }, + "operator": "|>", + "right": { + "type": "TupleExpression", + "start":11,"end":18,"loc":{"start":{"line":2,"column":5},"end":{"line":2,"column":12}}, + "elements": [ + { + "type": "NumericLiteral", + "start":13,"end":14,"loc":{"start":{"line":2,"column":7},"end":{"line":2,"column":8}}, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + }, + { + "type": "TopicReference", + "start":16,"end":17,"loc":{"start":{"line":2,"column":10},"end":{"line":2,"column":11}} + } + ] + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-mixed-pipeline-plugins/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-mixed-pipeline-plugins/input.js new file mode 100644 index 0000000000..d63a725e72 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-mixed-pipeline-plugins/input.js @@ -0,0 +1 @@ +value |> % diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-mixed-pipeline-plugins/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-mixed-pipeline-plugins/options.json new file mode 100644 index 0000000000..2e7affda4f --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-mixed-pipeline-plugins/options.json @@ -0,0 +1,3 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "hack", "topicToken": "%" }], "pipelineOperator"] +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-mixed-pipeline-plugins/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-mixed-pipeline-plugins/output.json new file mode 100644 index 0000000000..26d454dbfd --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-mixed-pipeline-plugins/output.json @@ -0,0 +1,31 @@ +{ + "type": "File", + "start":0,"end":10,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":10}}, + "program": { + "type": "Program", + "start":0,"end":10,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":10}}, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start":0,"end":10,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":10}}, + "expression": { + "type": "BinaryExpression", + "start":0,"end":10,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":10}}, + "left": { + "type": "Identifier", + "start":0,"end":5,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":5},"identifierName":"value"}, + "name": "value" + }, + "operator": "|>", + "right": { + "type": "TopicReference", + "start":9,"end":10,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":10}} + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-modulo-assignment-with-spaces/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-modulo-assignment-with-spaces/input.js new file mode 100644 index 0000000000..59813118ce --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-modulo-assignment-with-spaces/input.js @@ -0,0 +1 @@ +value |> (variable %= %); diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-modulo-assignment-with-spaces/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-modulo-assignment-with-spaces/options.json new file mode 100644 index 0000000000..cfbb793386 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-modulo-assignment-with-spaces/options.json @@ -0,0 +1,3 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "hack", "topicToken": "%" }]] +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-modulo-assignment-with-spaces/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-modulo-assignment-with-spaces/output.json new file mode 100644 index 0000000000..94ab834b16 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-modulo-assignment-with-spaces/output.json @@ -0,0 +1,45 @@ +{ + "type": "File", + "start":0,"end":25,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":25}}, + "program": { + "type": "Program", + "start":0,"end":25,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":25}}, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start":0,"end":25,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":25}}, + "expression": { + "type": "BinaryExpression", + "start":0,"end":24,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":24}}, + "left": { + "type": "Identifier", + "start":0,"end":5,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":5},"identifierName":"value"}, + "name": "value" + }, + "operator": "|>", + "right": { + "type": "AssignmentExpression", + "start":10,"end":23,"loc":{"start":{"line":1,"column":10},"end":{"line":1,"column":23}}, + "extra": { + "parenthesized": true, + "parenStart": 9 + }, + "operator": "%=", + "left": { + "type": "Identifier", + "start":10,"end":18,"loc":{"start":{"line":1,"column":10},"end":{"line":1,"column":18},"identifierName":"variable"}, + "name": "variable" + }, + "right": { + "type": "TopicReference", + "start":22,"end":23,"loc":{"start":{"line":1,"column":22},"end":{"line":1,"column":23}} + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-modulo-assignment-without-spaces/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-modulo-assignment-without-spaces/input.js new file mode 100644 index 0000000000..6fac4290fb --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-modulo-assignment-without-spaces/input.js @@ -0,0 +1 @@ +value |> (variable%=%); diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-modulo-assignment-without-spaces/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-modulo-assignment-without-spaces/options.json new file mode 100644 index 0000000000..cfbb793386 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-modulo-assignment-without-spaces/options.json @@ -0,0 +1,3 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "hack", "topicToken": "%" }]] +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-modulo-assignment-without-spaces/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-modulo-assignment-without-spaces/output.json new file mode 100644 index 0000000000..e9a58291fe --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-modulo-assignment-without-spaces/output.json @@ -0,0 +1,45 @@ +{ + "type": "File", + "start":0,"end":23,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":23}}, + "program": { + "type": "Program", + "start":0,"end":23,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":23}}, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start":0,"end":23,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":23}}, + "expression": { + "type": "BinaryExpression", + "start":0,"end":22,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":22}}, + "left": { + "type": "Identifier", + "start":0,"end":5,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":5},"identifierName":"value"}, + "name": "value" + }, + "operator": "|>", + "right": { + "type": "AssignmentExpression", + "start":10,"end":21,"loc":{"start":{"line":1,"column":10},"end":{"line":1,"column":21}}, + "extra": { + "parenthesized": true, + "parenStart": 9 + }, + "operator": "%=", + "left": { + "type": "Identifier", + "start":10,"end":18,"loc":{"start":{"line":1,"column":10},"end":{"line":1,"column":18},"identifierName":"variable"}, + "name": "variable" + }, + "right": { + "type": "TopicReference", + "start":20,"end":21,"loc":{"start":{"line":1,"column":20},"end":{"line":1,"column":21}} + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-modulo-inside-pipe-then-newline-then-function/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-modulo-inside-pipe-then-newline-then-function/input.js new file mode 100644 index 0000000000..556341da51 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-modulo-inside-pipe-then-newline-then-function/input.js @@ -0,0 +1,2 @@ +a |> % +function f() {} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-modulo-inside-pipe-then-newline-then-function/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-modulo-inside-pipe-then-newline-then-function/options.json new file mode 100644 index 0000000000..cfbb793386 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-modulo-inside-pipe-then-newline-then-function/options.json @@ -0,0 +1,3 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "hack", "topicToken": "%" }]] +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-modulo-inside-pipe-then-newline-then-function/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-modulo-inside-pipe-then-newline-then-function/output.json new file mode 100644 index 0000000000..a2a036276d --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-modulo-inside-pipe-then-newline-then-function/output.json @@ -0,0 +1,49 @@ +{ + "type": "File", + "start":0,"end":22,"loc":{"start":{"line":1,"column":0},"end":{"line":2,"column":15}}, + "program": { + "type": "Program", + "start":0,"end":22,"loc":{"start":{"line":1,"column":0},"end":{"line":2,"column":15}}, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start":0,"end":6,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":6}}, + "expression": { + "type": "BinaryExpression", + "start":0,"end":6,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":6}}, + "left": { + "type": "Identifier", + "start":0,"end":1,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":1},"identifierName":"a"}, + "name": "a" + }, + "operator": "|>", + "right": { + "type": "TopicReference", + "start":5,"end":6,"loc":{"start":{"line":1,"column":5},"end":{"line":1,"column":6}} + } + } + }, + { + "type": "FunctionDeclaration", + "start":7,"end":22,"loc":{"start":{"line":2,"column":0},"end":{"line":2,"column":15}}, + "id": { + "type": "Identifier", + "start":16,"end":17,"loc":{"start":{"line":2,"column":9},"end":{"line":2,"column":10},"identifierName":"f"}, + "name": "f" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start":20,"end":22,"loc":{"start":{"line":2,"column":13},"end":{"line":2,"column":15}}, + "body": [], + "directives": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-modulo-outside-pipe-then-newline-then-function/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-modulo-outside-pipe-then-newline-then-function/input.js new file mode 100644 index 0000000000..e2574ed3f1 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-modulo-outside-pipe-then-newline-then-function/input.js @@ -0,0 +1,2 @@ +a % +function f() {} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-modulo-outside-pipe-then-newline-then-function/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-modulo-outside-pipe-then-newline-then-function/options.json new file mode 100644 index 0000000000..cfbb793386 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-modulo-outside-pipe-then-newline-then-function/options.json @@ -0,0 +1,3 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "hack", "topicToken": "%" }]] +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-modulo-outside-pipe-then-newline-then-function/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-modulo-outside-pipe-then-newline-then-function/output.json new file mode 100644 index 0000000000..f9262118ab --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-modulo-outside-pipe-then-newline-then-function/output.json @@ -0,0 +1,45 @@ +{ + "type": "File", + "start":0,"end":19,"loc":{"start":{"line":1,"column":0},"end":{"line":2,"column":15}}, + "program": { + "type": "Program", + "start":0,"end":19,"loc":{"start":{"line":1,"column":0},"end":{"line":2,"column":15}}, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start":0,"end":19,"loc":{"start":{"line":1,"column":0},"end":{"line":2,"column":15}}, + "expression": { + "type": "BinaryExpression", + "start":0,"end":19,"loc":{"start":{"line":1,"column":0},"end":{"line":2,"column":15}}, + "left": { + "type": "Identifier", + "start":0,"end":1,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":1},"identifierName":"a"}, + "name": "a" + }, + "operator": "%", + "right": { + "type": "FunctionExpression", + "start":4,"end":19,"loc":{"start":{"line":2,"column":0},"end":{"line":2,"column":15}}, + "id": { + "type": "Identifier", + "start":13,"end":14,"loc":{"start":{"line":2,"column":9},"end":{"line":2,"column":10},"identifierName":"f"}, + "name": "f" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start":17,"end":19,"loc":{"start":{"line":2,"column":13},"end":{"line":2,"column":15}}, + "body": [], + "directives": [] + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-modulo-regex-outside-pipe/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-modulo-regex-outside-pipe/input.js new file mode 100644 index 0000000000..d2fa335cea --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-modulo-regex-outside-pipe/input.js @@ -0,0 +1 @@ +5 % /3/g; diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-modulo-regex-outside-pipe/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-modulo-regex-outside-pipe/options.json new file mode 100644 index 0000000000..cfbb793386 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-modulo-regex-outside-pipe/options.json @@ -0,0 +1,3 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "hack", "topicToken": "%" }]] +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-modulo-regex-outside-pipe/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-modulo-regex-outside-pipe/output.json new file mode 100644 index 0000000000..b6fb84b72f --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-modulo-regex-outside-pipe/output.json @@ -0,0 +1,40 @@ +{ + "type": "File", + "start":0,"end":9,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":9}}, + "program": { + "type": "Program", + "start":0,"end":9,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":9}}, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start":0,"end":9,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":9}}, + "expression": { + "type": "BinaryExpression", + "start":0,"end":8,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":8}}, + "left": { + "type": "NumericLiteral", + "start":0,"end":1,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":1}}, + "extra": { + "rawValue": 5, + "raw": "5" + }, + "value": 5 + }, + "operator": "%", + "right": { + "type": "RegExpLiteral", + "start":4,"end":8,"loc":{"start":{"line":1,"column":4},"end":{"line":1,"column":8}}, + "extra": { + "raw": "/3/g" + }, + "pattern": "3", + "flags": "g" + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-modulo-topic-first-with-spaces/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-modulo-topic-first-with-spaces/input.js new file mode 100644 index 0000000000..85af27d722 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-modulo-topic-first-with-spaces/input.js @@ -0,0 +1 @@ +value |> % % 2; diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-modulo-topic-first-with-spaces/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-modulo-topic-first-with-spaces/options.json new file mode 100644 index 0000000000..cfbb793386 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-modulo-topic-first-with-spaces/options.json @@ -0,0 +1,3 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "hack", "topicToken": "%" }]] +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-modulo-topic-first-with-spaces/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-modulo-topic-first-with-spaces/output.json new file mode 100644 index 0000000000..cbae73f8dd --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-modulo-topic-first-with-spaces/output.json @@ -0,0 +1,45 @@ +{ + "type": "File", + "start":0,"end":15,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":15}}, + "program": { + "type": "Program", + "start":0,"end":15,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":15}}, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start":0,"end":15,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":15}}, + "expression": { + "type": "BinaryExpression", + "start":0,"end":14,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":14}}, + "left": { + "type": "Identifier", + "start":0,"end":5,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":5},"identifierName":"value"}, + "name": "value" + }, + "operator": "|>", + "right": { + "type": "BinaryExpression", + "start":9,"end":14,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":14}}, + "left": { + "type": "TopicReference", + "start":9,"end":10,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":10}} + }, + "operator": "%", + "right": { + "type": "NumericLiteral", + "start":13,"end":14,"loc":{"start":{"line":1,"column":13},"end":{"line":1,"column":14}}, + "extra": { + "rawValue": 2, + "raw": "2" + }, + "value": 2 + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-modulo-topic-first-without-spaces/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-modulo-topic-first-without-spaces/input.js new file mode 100644 index 0000000000..8762c574ae --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-modulo-topic-first-without-spaces/input.js @@ -0,0 +1 @@ +value |> %%2; diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-modulo-topic-first-without-spaces/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-modulo-topic-first-without-spaces/options.json new file mode 100644 index 0000000000..cfbb793386 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-modulo-topic-first-without-spaces/options.json @@ -0,0 +1,3 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "hack", "topicToken": "%" }]] +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-modulo-topic-first-without-spaces/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-modulo-topic-first-without-spaces/output.json new file mode 100644 index 0000000000..149402010e --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-modulo-topic-first-without-spaces/output.json @@ -0,0 +1,45 @@ +{ + "type": "File", + "start":0,"end":13,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":13}}, + "program": { + "type": "Program", + "start":0,"end":13,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":13}}, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start":0,"end":13,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":13}}, + "expression": { + "type": "BinaryExpression", + "start":0,"end":12,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":12}}, + "left": { + "type": "Identifier", + "start":0,"end":5,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":5},"identifierName":"value"}, + "name": "value" + }, + "operator": "|>", + "right": { + "type": "BinaryExpression", + "start":9,"end":12,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":12}}, + "left": { + "type": "TopicReference", + "start":9,"end":10,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":10}} + }, + "operator": "%", + "right": { + "type": "NumericLiteral", + "start":11,"end":12,"loc":{"start":{"line":1,"column":11},"end":{"line":1,"column":12}}, + "extra": { + "rawValue": 2, + "raw": "2" + }, + "value": 2 + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-modulo-topic-last-with-spaces/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-modulo-topic-last-with-spaces/input.js new file mode 100644 index 0000000000..97bf65e822 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-modulo-topic-last-with-spaces/input.js @@ -0,0 +1 @@ +value |> 2 % %; diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-modulo-topic-last-with-spaces/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-modulo-topic-last-with-spaces/options.json new file mode 100644 index 0000000000..cfbb793386 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-modulo-topic-last-with-spaces/options.json @@ -0,0 +1,3 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "hack", "topicToken": "%" }]] +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-modulo-topic-last-with-spaces/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-modulo-topic-last-with-spaces/output.json new file mode 100644 index 0000000000..4cbe073276 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-modulo-topic-last-with-spaces/output.json @@ -0,0 +1,45 @@ +{ + "type": "File", + "start":0,"end":15,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":15}}, + "program": { + "type": "Program", + "start":0,"end":15,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":15}}, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start":0,"end":15,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":15}}, + "expression": { + "type": "BinaryExpression", + "start":0,"end":14,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":14}}, + "left": { + "type": "Identifier", + "start":0,"end":5,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":5},"identifierName":"value"}, + "name": "value" + }, + "operator": "|>", + "right": { + "type": "BinaryExpression", + "start":9,"end":14,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":14}}, + "left": { + "type": "NumericLiteral", + "start":9,"end":10,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":10}}, + "extra": { + "rawValue": 2, + "raw": "2" + }, + "value": 2 + }, + "operator": "%", + "right": { + "type": "TopicReference", + "start":13,"end":14,"loc":{"start":{"line":1,"column":13},"end":{"line":1,"column":14}} + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-modulo-topic-last-without-spaces/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-modulo-topic-last-without-spaces/input.js new file mode 100644 index 0000000000..31e9464b43 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-modulo-topic-last-without-spaces/input.js @@ -0,0 +1 @@ +value |> 2%%; diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-modulo-topic-last-without-spaces/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-modulo-topic-last-without-spaces/options.json new file mode 100644 index 0000000000..cfbb793386 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-modulo-topic-last-without-spaces/options.json @@ -0,0 +1,3 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "hack", "topicToken": "%" }]] +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-modulo-topic-last-without-spaces/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-modulo-topic-last-without-spaces/output.json new file mode 100644 index 0000000000..9f5487030f --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-modulo-topic-last-without-spaces/output.json @@ -0,0 +1,45 @@ +{ + "type": "File", + "start":0,"end":13,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":13}}, + "program": { + "type": "Program", + "start":0,"end":13,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":13}}, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start":0,"end":13,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":13}}, + "expression": { + "type": "BinaryExpression", + "start":0,"end":12,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":12}}, + "left": { + "type": "Identifier", + "start":0,"end":5,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":5},"identifierName":"value"}, + "name": "value" + }, + "operator": "|>", + "right": { + "type": "BinaryExpression", + "start":9,"end":12,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":12}}, + "left": { + "type": "NumericLiteral", + "start":9,"end":10,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":10}}, + "extra": { + "rawValue": 2, + "raw": "2" + }, + "value": 2 + }, + "operator": "%", + "right": { + "type": "TopicReference", + "start":11,"end":12,"loc":{"start":{"line":1,"column":11},"end":{"line":1,"column":12}} + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-nested-pipelines-with-arrow-function-with-required-topics/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-nested-pipelines-with-arrow-function-with-required-topics/input.js new file mode 100644 index 0000000000..b4e55e4c9a --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-nested-pipelines-with-arrow-function-with-required-topics/input.js @@ -0,0 +1 @@ +x |> ($ => % |> f(%, $) |> % > 1) diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-nested-pipelines-with-arrow-function-with-required-topics/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-nested-pipelines-with-arrow-function-with-required-topics/options.json new file mode 100644 index 0000000000..cfbb793386 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-nested-pipelines-with-arrow-function-with-required-topics/options.json @@ -0,0 +1,3 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "hack", "topicToken": "%" }]] +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-nested-pipelines-with-arrow-function-with-required-topics/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-nested-pipelines-with-arrow-function-with-required-topics/output.json new file mode 100644 index 0000000000..4fcf20826e --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-nested-pipelines-with-arrow-function-with-required-topics/output.json @@ -0,0 +1,97 @@ +{ + "type": "File", + "start":0,"end":33,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":33}}, + "program": { + "type": "Program", + "start":0,"end":33,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":33}}, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start":0,"end":33,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":33}}, + "expression": { + "type": "BinaryExpression", + "start":0,"end":33,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":33}}, + "left": { + "type": "Identifier", + "start":0,"end":1,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":1},"identifierName":"x"}, + "name": "x" + }, + "operator": "|>", + "right": { + "type": "ArrowFunctionExpression", + "start":6,"end":32,"loc":{"start":{"line":1,"column":6},"end":{"line":1,"column":32}}, + "extra": { + "parenthesized": true, + "parenStart": 5 + }, + "id": null, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "start":6,"end":7,"loc":{"start":{"line":1,"column":6},"end":{"line":1,"column":7},"identifierName":"$"}, + "name": "$" + } + ], + "body": { + "type": "BinaryExpression", + "start":11,"end":32,"loc":{"start":{"line":1,"column":11},"end":{"line":1,"column":32}}, + "left": { + "type": "BinaryExpression", + "start":11,"end":23,"loc":{"start":{"line":1,"column":11},"end":{"line":1,"column":23}}, + "left": { + "type": "TopicReference", + "start":11,"end":12,"loc":{"start":{"line":1,"column":11},"end":{"line":1,"column":12}} + }, + "operator": "|>", + "right": { + "type": "CallExpression", + "start":16,"end":23,"loc":{"start":{"line":1,"column":16},"end":{"line":1,"column":23}}, + "callee": { + "type": "Identifier", + "start":16,"end":17,"loc":{"start":{"line":1,"column":16},"end":{"line":1,"column":17},"identifierName":"f"}, + "name": "f" + }, + "arguments": [ + { + "type": "TopicReference", + "start":18,"end":19,"loc":{"start":{"line":1,"column":18},"end":{"line":1,"column":19}} + }, + { + "type": "Identifier", + "start":21,"end":22,"loc":{"start":{"line":1,"column":21},"end":{"line":1,"column":22},"identifierName":"$"}, + "name": "$" + } + ] + } + }, + "operator": "|>", + "right": { + "type": "BinaryExpression", + "start":27,"end":32,"loc":{"start":{"line":1,"column":27},"end":{"line":1,"column":32}}, + "left": { + "type": "TopicReference", + "start":27,"end":28,"loc":{"start":{"line":1,"column":27},"end":{"line":1,"column":28}} + }, + "operator": ">", + "right": { + "type": "NumericLiteral", + "start":31,"end":32,"loc":{"start":{"line":1,"column":31},"end":{"line":1,"column":32}}, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + } + } + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-nested-pipelines-with-arrow-function-without-inner-topic/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-nested-pipelines-with-arrow-function-without-inner-topic/input.js new file mode 100644 index 0000000000..33bc09792b --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-nested-pipelines-with-arrow-function-without-inner-topic/input.js @@ -0,0 +1 @@ +x |> ($ => % |> $ + 1) diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-nested-pipelines-with-arrow-function-without-inner-topic/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-nested-pipelines-with-arrow-function-without-inner-topic/options.json new file mode 100644 index 0000000000..cfbb793386 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-nested-pipelines-with-arrow-function-without-inner-topic/options.json @@ -0,0 +1,3 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "hack", "topicToken": "%" }]] +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-nested-pipelines-with-arrow-function-without-inner-topic/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-nested-pipelines-with-arrow-function-without-inner-topic/output.json new file mode 100644 index 0000000000..e04f68fe79 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-nested-pipelines-with-arrow-function-without-inner-topic/output.json @@ -0,0 +1,76 @@ +{ + "type": "File", + "start":0,"end":22,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":22}}, + "errors": [ + "SyntaxError: Hack-style pipe body does not contain a topic reference; Hack-style pipes must use topic at least once. (1:16)" + ], + "program": { + "type": "Program", + "start":0,"end":22,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":22}}, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start":0,"end":22,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":22}}, + "expression": { + "type": "BinaryExpression", + "start":0,"end":22,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":22}}, + "left": { + "type": "Identifier", + "start":0,"end":1,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":1},"identifierName":"x"}, + "name": "x" + }, + "operator": "|>", + "right": { + "type": "ArrowFunctionExpression", + "start":6,"end":21,"loc":{"start":{"line":1,"column":6},"end":{"line":1,"column":21}}, + "extra": { + "parenthesized": true, + "parenStart": 5 + }, + "id": null, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "start":6,"end":7,"loc":{"start":{"line":1,"column":6},"end":{"line":1,"column":7},"identifierName":"$"}, + "name": "$" + } + ], + "body": { + "type": "BinaryExpression", + "start":11,"end":21,"loc":{"start":{"line":1,"column":11},"end":{"line":1,"column":21}}, + "left": { + "type": "TopicReference", + "start":11,"end":12,"loc":{"start":{"line":1,"column":11},"end":{"line":1,"column":12}} + }, + "operator": "|>", + "right": { + "type": "BinaryExpression", + "start":16,"end":21,"loc":{"start":{"line":1,"column":16},"end":{"line":1,"column":21}}, + "left": { + "type": "Identifier", + "start":16,"end":17,"loc":{"start":{"line":1,"column":16},"end":{"line":1,"column":17},"identifierName":"$"}, + "name": "$" + }, + "operator": "+", + "right": { + "type": "NumericLiteral", + "start":20,"end":21,"loc":{"start":{"line":1,"column":20},"end":{"line":1,"column":21}}, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + } + } + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-nested-pipelines-with-arrow-function-without-outer-topic/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-nested-pipelines-with-arrow-function-without-outer-topic/input.js new file mode 100644 index 0000000000..d7242b5f11 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-nested-pipelines-with-arrow-function-without-outer-topic/input.js @@ -0,0 +1 @@ +x |> ($ => $ |> %) diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-nested-pipelines-with-arrow-function-without-outer-topic/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-nested-pipelines-with-arrow-function-without-outer-topic/options.json new file mode 100644 index 0000000000..cfbb793386 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-nested-pipelines-with-arrow-function-without-outer-topic/options.json @@ -0,0 +1,3 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "hack", "topicToken": "%" }]] +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-nested-pipelines-with-arrow-function-without-outer-topic/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-nested-pipelines-with-arrow-function-without-outer-topic/output.json new file mode 100644 index 0000000000..2ec88e5332 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-nested-pipelines-with-arrow-function-without-outer-topic/output.json @@ -0,0 +1,62 @@ +{ + "type": "File", + "start":0,"end":18,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":18}}, + "errors": [ + "SyntaxError: Hack-style pipe body does not contain a topic reference; Hack-style pipes must use topic at least once. (1:5)" + ], + "program": { + "type": "Program", + "start":0,"end":18,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":18}}, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start":0,"end":18,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":18}}, + "expression": { + "type": "BinaryExpression", + "start":0,"end":18,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":18}}, + "left": { + "type": "Identifier", + "start":0,"end":1,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":1},"identifierName":"x"}, + "name": "x" + }, + "operator": "|>", + "right": { + "type": "ArrowFunctionExpression", + "start":6,"end":17,"loc":{"start":{"line":1,"column":6},"end":{"line":1,"column":17}}, + "extra": { + "parenthesized": true, + "parenStart": 5 + }, + "id": null, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "start":6,"end":7,"loc":{"start":{"line":1,"column":6},"end":{"line":1,"column":7},"identifierName":"$"}, + "name": "$" + } + ], + "body": { + "type": "BinaryExpression", + "start":11,"end":17,"loc":{"start":{"line":1,"column":11},"end":{"line":1,"column":17}}, + "left": { + "type": "Identifier", + "start":11,"end":12,"loc":{"start":{"line":1,"column":11},"end":{"line":1,"column":12},"identifierName":"$"}, + "name": "$" + }, + "operator": "|>", + "right": { + "type": "TopicReference", + "start":16,"end":17,"loc":{"start":{"line":1,"column":16},"end":{"line":1,"column":17}} + } + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-nested-pipelines-with-function-call/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-nested-pipelines-with-function-call/input.js new file mode 100644 index 0000000000..2d3ba6f6d4 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-nested-pipelines-with-function-call/input.js @@ -0,0 +1 @@ +x |> (% |> f(%, x)) diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-nested-pipelines-with-function-call/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-nested-pipelines-with-function-call/options.json new file mode 100644 index 0000000000..cfbb793386 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-nested-pipelines-with-function-call/options.json @@ -0,0 +1,3 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "hack", "topicToken": "%" }]] +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-nested-pipelines-with-function-call/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-nested-pipelines-with-function-call/output.json new file mode 100644 index 0000000000..12c2619c00 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-nested-pipelines-with-function-call/output.json @@ -0,0 +1,60 @@ +{ + "type": "File", + "start":0,"end":19,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":19}}, + "program": { + "type": "Program", + "start":0,"end":19,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":19}}, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start":0,"end":19,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":19}}, + "expression": { + "type": "BinaryExpression", + "start":0,"end":19,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":19}}, + "left": { + "type": "Identifier", + "start":0,"end":1,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":1},"identifierName":"x"}, + "name": "x" + }, + "operator": "|>", + "right": { + "type": "BinaryExpression", + "start":6,"end":18,"loc":{"start":{"line":1,"column":6},"end":{"line":1,"column":18}}, + "extra": { + "parenthesized": true, + "parenStart": 5 + }, + "left": { + "type": "TopicReference", + "start":6,"end":7,"loc":{"start":{"line":1,"column":6},"end":{"line":1,"column":7}} + }, + "operator": "|>", + "right": { + "type": "CallExpression", + "start":11,"end":18,"loc":{"start":{"line":1,"column":11},"end":{"line":1,"column":18}}, + "callee": { + "type": "Identifier", + "start":11,"end":12,"loc":{"start":{"line":1,"column":11},"end":{"line":1,"column":12},"identifierName":"f"}, + "name": "f" + }, + "arguments": [ + { + "type": "TopicReference", + "start":13,"end":14,"loc":{"start":{"line":1,"column":13},"end":{"line":1,"column":14}} + }, + { + "type": "Identifier", + "start":16,"end":17,"loc":{"start":{"line":1,"column":16},"end":{"line":1,"column":17},"identifierName":"x"}, + "name": "x" + } + ] + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-nested-pipelines-without-inner-topic/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-nested-pipelines-without-inner-topic/input.js new file mode 100644 index 0000000000..5bcae596f9 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-nested-pipelines-without-inner-topic/input.js @@ -0,0 +1 @@ +x |> (% |> f()) diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-nested-pipelines-without-inner-topic/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-nested-pipelines-without-inner-topic/options.json new file mode 100644 index 0000000000..cfbb793386 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-nested-pipelines-without-inner-topic/options.json @@ -0,0 +1,3 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "hack", "topicToken": "%" }]] +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-nested-pipelines-without-inner-topic/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-nested-pipelines-without-inner-topic/output.json new file mode 100644 index 0000000000..fd53f606c9 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-nested-pipelines-without-inner-topic/output.json @@ -0,0 +1,53 @@ +{ + "type": "File", + "start":0,"end":15,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":15}}, + "errors": [ + "SyntaxError: Hack-style pipe body does not contain a topic reference; Hack-style pipes must use topic at least once. (1:11)" + ], + "program": { + "type": "Program", + "start":0,"end":15,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":15}}, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start":0,"end":15,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":15}}, + "expression": { + "type": "BinaryExpression", + "start":0,"end":15,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":15}}, + "left": { + "type": "Identifier", + "start":0,"end":1,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":1},"identifierName":"x"}, + "name": "x" + }, + "operator": "|>", + "right": { + "type": "BinaryExpression", + "start":6,"end":14,"loc":{"start":{"line":1,"column":6},"end":{"line":1,"column":14}}, + "extra": { + "parenthesized": true, + "parenStart": 5 + }, + "left": { + "type": "TopicReference", + "start":6,"end":7,"loc":{"start":{"line":1,"column":6},"end":{"line":1,"column":7}} + }, + "operator": "|>", + "right": { + "type": "CallExpression", + "start":11,"end":14,"loc":{"start":{"line":1,"column":11},"end":{"line":1,"column":14}}, + "callee": { + "type": "Identifier", + "start":11,"end":12,"loc":{"start":{"line":1,"column":11},"end":{"line":1,"column":12},"identifierName":"f"}, + "name": "f" + }, + "arguments": [] + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-nested-pipelines-without-outer-topic/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-nested-pipelines-without-outer-topic/input.js new file mode 100644 index 0000000000..9d00837048 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-nested-pipelines-without-outer-topic/input.js @@ -0,0 +1 @@ +x |> ($ |> f) diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-nested-pipelines-without-outer-topic/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-nested-pipelines-without-outer-topic/options.json new file mode 100644 index 0000000000..cfbb793386 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-nested-pipelines-without-outer-topic/options.json @@ -0,0 +1,3 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "hack", "topicToken": "%" }]] +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-nested-pipelines-without-outer-topic/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-nested-pipelines-without-outer-topic/output.json new file mode 100644 index 0000000000..8223c338ae --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-nested-pipelines-without-outer-topic/output.json @@ -0,0 +1,50 @@ +{ + "type": "File", + "start":0,"end":13,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":13}}, + "errors": [ + "SyntaxError: Hack-style pipe body does not contain a topic reference; Hack-style pipes must use topic at least once. (1:11)", + "SyntaxError: Hack-style pipe body does not contain a topic reference; Hack-style pipes must use topic at least once. (1:5)" + ], + "program": { + "type": "Program", + "start":0,"end":13,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":13}}, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start":0,"end":13,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":13}}, + "expression": { + "type": "BinaryExpression", + "start":0,"end":13,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":13}}, + "left": { + "type": "Identifier", + "start":0,"end":1,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":1},"identifierName":"x"}, + "name": "x" + }, + "operator": "|>", + "right": { + "type": "BinaryExpression", + "start":6,"end":12,"loc":{"start":{"line":1,"column":6},"end":{"line":1,"column":12}}, + "extra": { + "parenthesized": true, + "parenStart": 5 + }, + "left": { + "type": "Identifier", + "start":6,"end":7,"loc":{"start":{"line":1,"column":6},"end":{"line":1,"column":7},"identifierName":"$"}, + "name": "$" + }, + "operator": "|>", + "right": { + "type": "Identifier", + "start":11,"end":12,"loc":{"start":{"line":1,"column":11},"end":{"line":1,"column":12},"identifierName":"f"}, + "name": "f" + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-no-topic-class-expression/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-no-topic-class-expression/input.js new file mode 100644 index 0000000000..6ccb6ca133 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-no-topic-class-expression/input.js @@ -0,0 +1 @@ +value |> class { } diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-no-topic-class-expression/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-no-topic-class-expression/options.json new file mode 100644 index 0000000000..cfbb793386 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-no-topic-class-expression/options.json @@ -0,0 +1,3 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "hack", "topicToken": "%" }]] +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-no-topic-class-expression/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-no-topic-class-expression/output.json new file mode 100644 index 0000000000..1e904fe3dd --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-no-topic-class-expression/output.json @@ -0,0 +1,41 @@ +{ + "type": "File", + "start":0,"end":18,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":18}}, + "errors": [ + "SyntaxError: Hack-style pipe body does not contain a topic reference; Hack-style pipes must use topic at least once. (1:9)" + ], + "program": { + "type": "Program", + "start":0,"end":18,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":18}}, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start":0,"end":18,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":18}}, + "expression": { + "type": "BinaryExpression", + "start":0,"end":18,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":18}}, + "left": { + "type": "Identifier", + "start":0,"end":5,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":5},"identifierName":"value"}, + "name": "value" + }, + "operator": "|>", + "right": { + "type": "ClassExpression", + "start":9,"end":18,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":18}}, + "id": null, + "superClass": null, + "body": { + "type": "ClassBody", + "start":15,"end":18,"loc":{"start":{"line":1,"column":15},"end":{"line":1,"column":18}}, + "body": [] + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-no-topic-function-expression/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-no-topic-function-expression/input.js new file mode 100644 index 0000000000..faf09879d6 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-no-topic-function-expression/input.js @@ -0,0 +1 @@ +value |> function (x) { return; } diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-no-topic-function-expression/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-no-topic-function-expression/options.json new file mode 100644 index 0000000000..cfbb793386 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-no-topic-function-expression/options.json @@ -0,0 +1,3 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "hack", "topicToken": "%" }]] +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-no-topic-function-expression/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-no-topic-function-expression/output.json new file mode 100644 index 0000000000..4a53253559 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-no-topic-function-expression/output.json @@ -0,0 +1,56 @@ +{ + "type": "File", + "start":0,"end":33,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":33}}, + "errors": [ + "SyntaxError: Hack-style pipe body does not contain a topic reference; Hack-style pipes must use topic at least once. (1:9)" + ], + "program": { + "type": "Program", + "start":0,"end":33,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":33}}, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start":0,"end":33,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":33}}, + "expression": { + "type": "BinaryExpression", + "start":0,"end":33,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":33}}, + "left": { + "type": "Identifier", + "start":0,"end":5,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":5},"identifierName":"value"}, + "name": "value" + }, + "operator": "|>", + "right": { + "type": "FunctionExpression", + "start":9,"end":33,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":33}}, + "id": null, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "start":19,"end":20,"loc":{"start":{"line":1,"column":19},"end":{"line":1,"column":20},"identifierName":"x"}, + "name": "x" + } + ], + "body": { + "type": "BlockStatement", + "start":22,"end":33,"loc":{"start":{"line":1,"column":22},"end":{"line":1,"column":33}}, + "body": [ + { + "type": "ReturnStatement", + "start":24,"end":31,"loc":{"start":{"line":1,"column":24},"end":{"line":1,"column":31}}, + "argument": null + } + ], + "directives": [] + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-non-generator-yield-identifier/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-non-generator-yield-identifier/input.js new file mode 100644 index 0000000000..736fab70cf --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-non-generator-yield-identifier/input.js @@ -0,0 +1 @@ +x |> yield + %; diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-non-generator-yield-identifier/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-non-generator-yield-identifier/options.json new file mode 100644 index 0000000000..cfbb793386 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-non-generator-yield-identifier/options.json @@ -0,0 +1,3 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "hack", "topicToken": "%" }]] +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-non-generator-yield-identifier/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-non-generator-yield-identifier/output.json new file mode 100644 index 0000000000..cdd141011b --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-non-generator-yield-identifier/output.json @@ -0,0 +1,41 @@ +{ + "type": "File", + "start":0,"end":15,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":15}}, + "program": { + "type": "Program", + "start":0,"end":15,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":15}}, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start":0,"end":15,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":15}}, + "expression": { + "type": "BinaryExpression", + "start":0,"end":14,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":14}}, + "left": { + "type": "Identifier", + "start":0,"end":1,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":1},"identifierName":"x"}, + "name": "x" + }, + "operator": "|>", + "right": { + "type": "BinaryExpression", + "start":5,"end":14,"loc":{"start":{"line":1,"column":5},"end":{"line":1,"column":14}}, + "left": { + "type": "Identifier", + "start":5,"end":10,"loc":{"start":{"line":1,"column":5},"end":{"line":1,"column":10},"identifierName":"yield"}, + "name": "yield" + }, + "operator": "+", + "right": { + "type": "TopicReference", + "start":13,"end":14,"loc":{"start":{"line":1,"column":13},"end":{"line":1,"column":14}} + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-placeholder-template/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-placeholder-template/input.js new file mode 100644 index 0000000000..df29480f70 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-placeholder-template/input.js @@ -0,0 +1 @@ +%%FUNCTION%%(0, %%VALUE%%); diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-placeholder-template/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-placeholder-template/options.json new file mode 100644 index 0000000000..20d7171a90 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-placeholder-template/options.json @@ -0,0 +1,7 @@ +{ + "plugins": [ + ["pipelineOperator", { "proposal": "hack", "topicToken": "%" }], + "placeholders" + ], + "throws": "Cannot combine placeholders plugin and Hack-style pipes." +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-private-property-in-private-method/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-private-property-in-private-method/input.js new file mode 100644 index 0000000000..98f05c7167 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-private-property-in-private-method/input.js @@ -0,0 +1,7 @@ +class Thing { + #property; + + #method () { + value |> this.#property + %; + } +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-private-property-in-private-method/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-private-property-in-private-method/options.json new file mode 100644 index 0000000000..626290f4e5 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-private-property-in-private-method/options.json @@ -0,0 +1,7 @@ +{ + "plugins": [ + ["pipelineOperator", { "proposal": "hack", "topicToken": "%" }], + "classPrivateProperties", + "classPrivateMethods" + ] +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-private-property-in-private-method/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-private-property-in-private-method/output.json new file mode 100644 index 0000000000..0a1b91986a --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-private-property-in-private-method/output.json @@ -0,0 +1,111 @@ +{ + "type": "File", + "start":0,"end":81,"loc":{"start":{"line":1,"column":0},"end":{"line":7,"column":1}}, + "program": { + "type": "Program", + "start":0,"end":81,"loc":{"start":{"line":1,"column":0},"end":{"line":7,"column":1}}, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ClassDeclaration", + "start":0,"end":81,"loc":{"start":{"line":1,"column":0},"end":{"line":7,"column":1}}, + "id": { + "type": "Identifier", + "start":6,"end":11,"loc":{"start":{"line":1,"column":6},"end":{"line":1,"column":11},"identifierName":"Thing"}, + "name": "Thing" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "start":12,"end":81,"loc":{"start":{"line":1,"column":12},"end":{"line":7,"column":1}}, + "body": [ + { + "type": "ClassPrivateProperty", + "start":16,"end":26,"loc":{"start":{"line":2,"column":2},"end":{"line":2,"column":12}}, + "static": false, + "key": { + "type": "PrivateName", + "start":16,"end":25,"loc":{"start":{"line":2,"column":2},"end":{"line":2,"column":11}}, + "id": { + "type": "Identifier", + "start":17,"end":25,"loc":{"start":{"line":2,"column":3},"end":{"line":2,"column":11},"identifierName":"property"}, + "name": "property" + } + }, + "value": null + }, + { + "type": "ClassPrivateMethod", + "start":30,"end":79,"loc":{"start":{"line":4,"column":2},"end":{"line":6,"column":3}}, + "static": false, + "key": { + "type": "PrivateName", + "start":30,"end":37,"loc":{"start":{"line":4,"column":2},"end":{"line":4,"column":9}}, + "id": { + "type": "Identifier", + "start":31,"end":37,"loc":{"start":{"line":4,"column":3},"end":{"line":4,"column":9},"identifierName":"method"}, + "name": "method" + } + }, + "kind": "method", + "id": null, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start":41,"end":79,"loc":{"start":{"line":4,"column":13},"end":{"line":6,"column":3}}, + "body": [ + { + "type": "ExpressionStatement", + "start":47,"end":75,"loc":{"start":{"line":5,"column":4},"end":{"line":5,"column":32}}, + "expression": { + "type": "BinaryExpression", + "start":47,"end":74,"loc":{"start":{"line":5,"column":4},"end":{"line":5,"column":31}}, + "left": { + "type": "Identifier", + "start":47,"end":52,"loc":{"start":{"line":5,"column":4},"end":{"line":5,"column":9},"identifierName":"value"}, + "name": "value" + }, + "operator": "|>", + "right": { + "type": "BinaryExpression", + "start":56,"end":74,"loc":{"start":{"line":5,"column":13},"end":{"line":5,"column":31}}, + "left": { + "type": "MemberExpression", + "start":56,"end":70,"loc":{"start":{"line":5,"column":13},"end":{"line":5,"column":27}}, + "object": { + "type": "ThisExpression", + "start":56,"end":60,"loc":{"start":{"line":5,"column":13},"end":{"line":5,"column":17}} + }, + "computed": false, + "property": { + "type": "PrivateName", + "start":61,"end":70,"loc":{"start":{"line":5,"column":18},"end":{"line":5,"column":27}}, + "id": { + "type": "Identifier", + "start":62,"end":70,"loc":{"start":{"line":5,"column":19},"end":{"line":5,"column":27},"identifierName":"property"}, + "name": "property" + } + } + }, + "operator": "+", + "right": { + "type": "TopicReference", + "start":73,"end":74,"loc":{"start":{"line":5,"column":30},"end":{"line":5,"column":31}} + } + } + } + } + ], + "directives": [] + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-topic-identity-parenthesized/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-topic-identity-parenthesized/input.js new file mode 100644 index 0000000000..48875c2668 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-topic-identity-parenthesized/input.js @@ -0,0 +1 @@ +value |> (%) diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-topic-identity-parenthesized/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-topic-identity-parenthesized/options.json new file mode 100644 index 0000000000..cfbb793386 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-topic-identity-parenthesized/options.json @@ -0,0 +1,3 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "hack", "topicToken": "%" }]] +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-topic-identity-parenthesized/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-topic-identity-parenthesized/output.json new file mode 100644 index 0000000000..90324568fe --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-topic-identity-parenthesized/output.json @@ -0,0 +1,35 @@ +{ + "type": "File", + "start":0,"end":12,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":12}}, + "program": { + "type": "Program", + "start":0,"end":12,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":12}}, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start":0,"end":12,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":12}}, + "expression": { + "type": "BinaryExpression", + "start":0,"end":12,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":12}}, + "left": { + "type": "Identifier", + "start":0,"end":5,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":5},"identifierName":"value"}, + "name": "value" + }, + "operator": "|>", + "right": { + "type": "TopicReference", + "start":10,"end":11,"loc":{"start":{"line":1,"column":10},"end":{"line":1,"column":11}}, + "extra": { + "parenthesized": true, + "parenStart": 9 + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-topic-identity-unparenthesized/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-topic-identity-unparenthesized/input.js new file mode 100644 index 0000000000..d63a725e72 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-topic-identity-unparenthesized/input.js @@ -0,0 +1 @@ +value |> % diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-topic-identity-unparenthesized/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-topic-identity-unparenthesized/options.json new file mode 100644 index 0000000000..cfbb793386 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-topic-identity-unparenthesized/options.json @@ -0,0 +1,3 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "hack", "topicToken": "%" }]] +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-topic-identity-unparenthesized/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-topic-identity-unparenthesized/output.json new file mode 100644 index 0000000000..26d454dbfd --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-topic-identity-unparenthesized/output.json @@ -0,0 +1,31 @@ +{ + "type": "File", + "start":0,"end":10,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":10}}, + "program": { + "type": "Program", + "start":0,"end":10,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":10}}, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start":0,"end":10,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":10}}, + "expression": { + "type": "BinaryExpression", + "start":0,"end":10,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":10}}, + "left": { + "type": "Identifier", + "start":0,"end":5,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":5},"identifierName":"value"}, + "name": "value" + }, + "operator": "|>", + "right": { + "type": "TopicReference", + "start":9,"end":10,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":10}} + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-topic-then-digit/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-topic-then-digit/input.js new file mode 100644 index 0000000000..d6facbabbd --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-topic-then-digit/input.js @@ -0,0 +1 @@ +x |> %42; diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-topic-then-digit/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-topic-then-digit/options.json new file mode 100644 index 0000000000..ff2224a905 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-topic-then-digit/options.json @@ -0,0 +1,11 @@ +{ + "plugins": [ + [ + "pipelineOperator", + { + "proposal": "hack", + "topicToken": "%" + } + ] + ] +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-topic-then-digit/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-topic-then-digit/output.json new file mode 100644 index 0000000000..5326190e17 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-topic-then-digit/output.json @@ -0,0 +1,47 @@ +{ + "type": "File", + "start":0,"end":9,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":9}}, + "errors": [ + "SyntaxError: Missing semicolon. (1:6)" + ], + "program": { + "type": "Program", + "start":0,"end":9,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":9}}, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start":0,"end":6,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":6}}, + "expression": { + "type": "BinaryExpression", + "start":0,"end":6,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":6}}, + "left": { + "type": "Identifier", + "start":0,"end":1,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":1},"identifierName":"x"}, + "name": "x" + }, + "operator": "|>", + "right": { + "type": "TopicReference", + "start":5,"end":6,"loc":{"start":{"line":1,"column":5},"end":{"line":1,"column":6}} + } + } + }, + { + "type": "ExpressionStatement", + "start":6,"end":9,"loc":{"start":{"line":1,"column":6},"end":{"line":1,"column":9}}, + "expression": { + "type": "NumericLiteral", + "start":6,"end":8,"loc":{"start":{"line":1,"column":6},"end":{"line":1,"column":8}}, + "extra": { + "rawValue": 42, + "raw": "42" + }, + "value": 42 + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-topic-with-optional-method-call/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-topic-with-optional-method-call/input.js new file mode 100644 index 0000000000..ac3a50e6a8 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-topic-with-optional-method-call/input.js @@ -0,0 +1 @@ +value |> %?.method() diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-topic-with-optional-method-call/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-topic-with-optional-method-call/options.json new file mode 100644 index 0000000000..cfbb793386 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-topic-with-optional-method-call/options.json @@ -0,0 +1,3 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "hack", "topicToken": "%" }]] +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-topic-with-optional-method-call/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-topic-with-optional-method-call/output.json new file mode 100644 index 0000000000..cfe7f18f72 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-topic-with-optional-method-call/output.json @@ -0,0 +1,48 @@ +{ + "type": "File", + "start":0,"end":20,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":20}}, + "program": { + "type": "Program", + "start":0,"end":20,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":20}}, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start":0,"end":20,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":20}}, + "expression": { + "type": "BinaryExpression", + "start":0,"end":20,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":20}}, + "left": { + "type": "Identifier", + "start":0,"end":5,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":5},"identifierName":"value"}, + "name": "value" + }, + "operator": "|>", + "right": { + "type": "OptionalCallExpression", + "start":9,"end":20,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":20}}, + "callee": { + "type": "OptionalMemberExpression", + "start":9,"end":18,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":18}}, + "object": { + "type": "TopicReference", + "start":9,"end":10,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":10}} + }, + "computed": false, + "property": { + "type": "Identifier", + "start":12,"end":18,"loc":{"start":{"line":1,"column":12},"end":{"line":1,"column":18},"identifierName":"method"}, + "name": "method" + }, + "optional": true + }, + "optional": false, + "arguments": [] + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-unbound-topic/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-unbound-topic/input.js new file mode 100644 index 0000000000..aff79c2a88 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-unbound-topic/input.js @@ -0,0 +1 @@ +1 + % diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-unbound-topic/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-unbound-topic/options.json new file mode 100644 index 0000000000..cfbb793386 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-unbound-topic/options.json @@ -0,0 +1,3 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "hack", "topicToken": "%" }]] +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-unbound-topic/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-unbound-topic/output.json new file mode 100644 index 0000000000..9b2253f1b1 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-unbound-topic/output.json @@ -0,0 +1,38 @@ +{ + "type": "File", + "start":0,"end":5,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":5}}, + "errors": [ + "SyntaxError: Topic reference is unbound; it must be inside a pipe body. (1:4)" + ], + "program": { + "type": "Program", + "start":0,"end":5,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":5}}, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start":0,"end":5,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":5}}, + "expression": { + "type": "BinaryExpression", + "start":0,"end":5,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":5}}, + "left": { + "type": "NumericLiteral", + "start":0,"end":1,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":1}}, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + }, + "operator": "+", + "right": { + "type": "TopicReference", + "start":4,"end":5,"loc":{"start":{"line":1,"column":4},"end":{"line":1,"column":5}} + } + } + } + ], + "directives": [] + } +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-v8intrinsic/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-v8intrinsic/input.js new file mode 100644 index 0000000000..4c6a361dae --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-v8intrinsic/input.js @@ -0,0 +1 @@ +%GetOptimizationStatus(f); diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-v8intrinsic/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-v8intrinsic/options.json new file mode 100644 index 0000000000..6651041a09 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-v8intrinsic/options.json @@ -0,0 +1,7 @@ +{ + "plugins": [ + ["pipelineOperator", { "proposal": "hack", "topicToken": "%" }], + "v8intrinsic" + ], + "throws": "Cannot combine v8intrinsic plugin and Hack-style pipes." +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-within-assignment/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-within-assignment/input.js new file mode 100644 index 0000000000..b790585022 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-within-assignment/input.js @@ -0,0 +1 @@ +x = 0 |> %; diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-within-assignment/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-within-assignment/options.json new file mode 100644 index 0000000000..cfbb793386 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-within-assignment/options.json @@ -0,0 +1,3 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "hack", "topicToken": "%" }]] +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-within-assignment/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-within-assignment/output.json new file mode 100644 index 0000000000..b6929c77f6 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-within-assignment/output.json @@ -0,0 +1,45 @@ +{ + "type": "File", + "start":0,"end":11,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":11}}, + "program": { + "type": "Program", + "start":0,"end":11,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":11}}, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start":0,"end":11,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":11}}, + "expression": { + "type": "AssignmentExpression", + "start":0,"end":10,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":10}}, + "operator": "=", + "left": { + "type": "Identifier", + "start":0,"end":1,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":1},"identifierName":"x"}, + "name": "x" + }, + "right": { + "type": "BinaryExpression", + "start":4,"end":10,"loc":{"start":{"line":1,"column":4},"end":{"line":1,"column":10}}, + "left": { + "type": "NumericLiteral", + "start":4,"end":5,"loc":{"start":{"line":1,"column":4},"end":{"line":1,"column":5}}, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + }, + "operator": "|>", + "right": { + "type": "TopicReference", + "start":9,"end":10,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":10}} + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-within-classic-for-statement-init/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-within-classic-for-statement-init/input.js new file mode 100644 index 0000000000..4c328db661 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-within-classic-for-statement-init/input.js @@ -0,0 +1,2 @@ +for (var i = 0 |> %; i <= 10; i++) + sum = sum + i; diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-within-classic-for-statement-init/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-within-classic-for-statement-init/options.json new file mode 100644 index 0000000000..cfbb793386 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-within-classic-for-statement-init/options.json @@ -0,0 +1,3 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "hack", "topicToken": "%" }]] +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-within-classic-for-statement-init/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-within-classic-for-statement-init/output.json new file mode 100644 index 0000000000..a00ebbb4ba --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-within-classic-for-statement-init/output.json @@ -0,0 +1,110 @@ +{ + "type": "File", + "start":0,"end":51,"loc":{"start":{"line":1,"column":0},"end":{"line":2,"column":16}}, + "program": { + "type": "Program", + "start":0,"end":51,"loc":{"start":{"line":1,"column":0},"end":{"line":2,"column":16}}, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ForStatement", + "start":0,"end":51,"loc":{"start":{"line":1,"column":0},"end":{"line":2,"column":16}}, + "init": { + "type": "VariableDeclaration", + "start":5,"end":19,"loc":{"start":{"line":1,"column":5},"end":{"line":1,"column":19}}, + "declarations": [ + { + "type": "VariableDeclarator", + "start":9,"end":19,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":19}}, + "id": { + "type": "Identifier", + "start":9,"end":10,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":10},"identifierName":"i"}, + "name": "i" + }, + "init": { + "type": "BinaryExpression", + "start":13,"end":19,"loc":{"start":{"line":1,"column":13},"end":{"line":1,"column":19}}, + "left": { + "type": "NumericLiteral", + "start":13,"end":14,"loc":{"start":{"line":1,"column":13},"end":{"line":1,"column":14}}, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + }, + "operator": "|>", + "right": { + "type": "TopicReference", + "start":18,"end":19,"loc":{"start":{"line":1,"column":18},"end":{"line":1,"column":19}} + } + } + } + ], + "kind": "var" + }, + "test": { + "type": "BinaryExpression", + "start":21,"end":28,"loc":{"start":{"line":1,"column":21},"end":{"line":1,"column":28}}, + "left": { + "type": "Identifier", + "start":21,"end":22,"loc":{"start":{"line":1,"column":21},"end":{"line":1,"column":22},"identifierName":"i"}, + "name": "i" + }, + "operator": "<=", + "right": { + "type": "NumericLiteral", + "start":26,"end":28,"loc":{"start":{"line":1,"column":26},"end":{"line":1,"column":28}}, + "extra": { + "rawValue": 10, + "raw": "10" + }, + "value": 10 + } + }, + "update": { + "type": "UpdateExpression", + "start":30,"end":33,"loc":{"start":{"line":1,"column":30},"end":{"line":1,"column":33}}, + "operator": "++", + "prefix": false, + "argument": { + "type": "Identifier", + "start":30,"end":31,"loc":{"start":{"line":1,"column":30},"end":{"line":1,"column":31},"identifierName":"i"}, + "name": "i" + } + }, + "body": { + "type": "ExpressionStatement", + "start":37,"end":51,"loc":{"start":{"line":2,"column":2},"end":{"line":2,"column":16}}, + "expression": { + "type": "AssignmentExpression", + "start":37,"end":50,"loc":{"start":{"line":2,"column":2},"end":{"line":2,"column":15}}, + "operator": "=", + "left": { + "type": "Identifier", + "start":37,"end":40,"loc":{"start":{"line":2,"column":2},"end":{"line":2,"column":5},"identifierName":"sum"}, + "name": "sum" + }, + "right": { + "type": "BinaryExpression", + "start":43,"end":50,"loc":{"start":{"line":2,"column":8},"end":{"line":2,"column":15}}, + "left": { + "type": "Identifier", + "start":43,"end":46,"loc":{"start":{"line":2,"column":8},"end":{"line":2,"column":11},"identifierName":"sum"}, + "name": "sum" + }, + "operator": "+", + "right": { + "type": "Identifier", + "start":49,"end":50,"loc":{"start":{"line":2,"column":14},"end":{"line":2,"column":15},"identifierName":"i"}, + "name": "i" + } + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-within-modulo-assignment-with-spaces/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-within-modulo-assignment-with-spaces/input.js new file mode 100644 index 0000000000..cf93fdf68f --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-within-modulo-assignment-with-spaces/input.js @@ -0,0 +1 @@ +variable %= value |> %; diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-within-modulo-assignment-with-spaces/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-within-modulo-assignment-with-spaces/options.json new file mode 100644 index 0000000000..cfbb793386 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-within-modulo-assignment-with-spaces/options.json @@ -0,0 +1,3 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "hack", "topicToken": "%" }]] +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-within-modulo-assignment-with-spaces/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-within-modulo-assignment-with-spaces/output.json new file mode 100644 index 0000000000..60818d5b2b --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-within-modulo-assignment-with-spaces/output.json @@ -0,0 +1,41 @@ +{ + "type": "File", + "start":0,"end":23,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":23}}, + "program": { + "type": "Program", + "start":0,"end":23,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":23}}, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start":0,"end":23,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":23}}, + "expression": { + "type": "AssignmentExpression", + "start":0,"end":22,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":22}}, + "operator": "%=", + "left": { + "type": "Identifier", + "start":0,"end":8,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":8},"identifierName":"variable"}, + "name": "variable" + }, + "right": { + "type": "BinaryExpression", + "start":12,"end":22,"loc":{"start":{"line":1,"column":12},"end":{"line":1,"column":22}}, + "left": { + "type": "Identifier", + "start":12,"end":17,"loc":{"start":{"line":1,"column":12},"end":{"line":1,"column":17},"identifierName":"value"}, + "name": "value" + }, + "operator": "|>", + "right": { + "type": "TopicReference", + "start":21,"end":22,"loc":{"start":{"line":1,"column":21},"end":{"line":1,"column":22}} + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-within-modulo-assignment-without-spaces/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-within-modulo-assignment-without-spaces/input.js new file mode 100644 index 0000000000..eef896e1d8 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-within-modulo-assignment-without-spaces/input.js @@ -0,0 +1 @@ +variable%=value |> %; diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-within-modulo-assignment-without-spaces/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-within-modulo-assignment-without-spaces/options.json new file mode 100644 index 0000000000..cfbb793386 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-within-modulo-assignment-without-spaces/options.json @@ -0,0 +1,3 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "hack", "topicToken": "%" }]] +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-within-modulo-assignment-without-spaces/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-within-modulo-assignment-without-spaces/output.json new file mode 100644 index 0000000000..997ad681f3 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-within-modulo-assignment-without-spaces/output.json @@ -0,0 +1,41 @@ +{ + "type": "File", + "start":0,"end":21,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":21}}, + "program": { + "type": "Program", + "start":0,"end":21,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":21}}, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start":0,"end":21,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":21}}, + "expression": { + "type": "AssignmentExpression", + "start":0,"end":20,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":20}}, + "operator": "%=", + "left": { + "type": "Identifier", + "start":0,"end":8,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":8},"identifierName":"variable"}, + "name": "variable" + }, + "right": { + "type": "BinaryExpression", + "start":10,"end":20,"loc":{"start":{"line":1,"column":10},"end":{"line":1,"column":20}}, + "left": { + "type": "Identifier", + "start":10,"end":15,"loc":{"start":{"line":1,"column":10},"end":{"line":1,"column":15},"identifierName":"value"}, + "name": "value" + }, + "operator": "|>", + "right": { + "type": "TopicReference", + "start":19,"end":20,"loc":{"start":{"line":1,"column":19},"end":{"line":1,"column":20}} + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-within-variable-declaration/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-within-variable-declaration/input.js new file mode 100644 index 0000000000..45e1111f25 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-within-variable-declaration/input.js @@ -0,0 +1 @@ +const x = 0 |> %; diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-within-variable-declaration/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-within-variable-declaration/options.json new file mode 100644 index 0000000000..cfbb793386 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-within-variable-declaration/options.json @@ -0,0 +1,3 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "hack", "topicToken": "%" }]] +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-within-variable-declaration/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-within-variable-declaration/output.json new file mode 100644 index 0000000000..a1e01654c8 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-within-variable-declaration/output.json @@ -0,0 +1,47 @@ +{ + "type": "File", + "start":0,"end":17,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":17}}, + "program": { + "type": "Program", + "start":0,"end":17,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":17}}, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "VariableDeclaration", + "start":0,"end":17,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":17}}, + "declarations": [ + { + "type": "VariableDeclarator", + "start":6,"end":16,"loc":{"start":{"line":1,"column":6},"end":{"line":1,"column":16}}, + "id": { + "type": "Identifier", + "start":6,"end":7,"loc":{"start":{"line":1,"column":6},"end":{"line":1,"column":7},"identifierName":"x"}, + "name": "x" + }, + "init": { + "type": "BinaryExpression", + "start":10,"end":16,"loc":{"start":{"line":1,"column":10},"end":{"line":1,"column":16}}, + "left": { + "type": "NumericLiteral", + "start":10,"end":11,"loc":{"start":{"line":1,"column":10},"end":{"line":1,"column":11}}, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + }, + "operator": "|>", + "right": { + "type": "TopicReference", + "start":15,"end":16,"loc":{"start":{"line":1,"column":15},"end":{"line":1,"column":16}} + } + } + } + ], + "kind": "const" + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-v8intrinsic/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-v8intrinsic/input.js new file mode 100644 index 0000000000..b2bf71dddd --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-v8intrinsic/input.js @@ -0,0 +1 @@ +input |> %GetOptimizationStatus(#); diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-v8intrinsic/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-v8intrinsic/options.json new file mode 100644 index 0000000000..b1cf880db9 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-v8intrinsic/options.json @@ -0,0 +1,6 @@ +{ + "plugins": [ + ["pipelineOperator", { "proposal": "smart" }], + "v8intrinsic" + ] +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-v8intrinsic/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-v8intrinsic/output.json new file mode 100644 index 0000000000..4be1d28fb3 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-v8intrinsic/output.json @@ -0,0 +1,46 @@ +{ + "type": "File", + "start":0,"end":35,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":35}}, + "program": { + "type": "Program", + "start":0,"end":35,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":35}}, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start":0,"end":35,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":35}}, + "expression": { + "type": "BinaryExpression", + "start":0,"end":34,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":34}}, + "left": { + "type": "Identifier", + "start":0,"end":5,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":5},"identifierName":"input"}, + "name": "input" + }, + "operator": "|>", + "right": { + "type": "PipelineTopicExpression", + "start":9,"end":34,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":34}}, + "expression": { + "type": "CallExpression", + "start":9,"end":34,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":34}}, + "callee": { + "type": "V8IntrinsicIdentifier", + "start":9,"end":31,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":31},"identifierName":"GetOptimizationStatus"}, + "name": "GetOptimizationStatus" + }, + "arguments": [ + { + "type": "PipelinePrimaryTopicReference", + "start":32,"end":33,"loc":{"start":{"line":1,"column":32},"end":{"line":1,"column":33}} + } + ] + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/typings/babel-parser.d.ts b/packages/babel-parser/typings/babel-parser.d.ts index ead74592e0..26907c0bc9 100644 --- a/packages/babel-parser/typings/babel-parser.d.ts +++ b/packages/babel-parser/typings/babel-parser.d.ts @@ -161,7 +161,7 @@ export interface DecoratorsPluginOptions { export interface PipelineOperatorPluginOptions { proposal: "minimal" | "fsharp" | "hack" | "smart"; - topicToken?: "#"; + topicToken?: "%" | "#"; } export interface RecordAndTuplePluginOptions { diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/hash-tuple/input.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/hash-tuple/input.js new file mode 100644 index 0000000000..dd96171689 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/hash-tuple/input.js @@ -0,0 +1,2 @@ +#[0]; +1 |> #[0, %]; diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/hash-tuple/options.json b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/hash-tuple/options.json new file mode 100644 index 0000000000..1d4946f1ad --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/hash-tuple/options.json @@ -0,0 +1,6 @@ +{ + "plugins": [ + ["proposal-pipeline-operator", { "proposal": "hack", "topicToken": "%" }], + ["proposal-record-and-tuple", { "syntaxType": "hash" }] + ] +} diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/hash-tuple/output.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/hash-tuple/output.js new file mode 100644 index 0000000000..877d41141f --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/hash-tuple/output.js @@ -0,0 +1,4 @@ +var _ref; + +Tuple(0); +_ref = 1, Tuple(0, _ref); diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/options.json b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/options.json new file mode 100644 index 0000000000..bc35d180b6 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/options.json @@ -0,0 +1,3 @@ +{ + "plugins": [["proposal-pipeline-operator", { "proposal": "hack", "topicToken": "%" }]] +} diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-identity/exec.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-identity/exec.js new file mode 100644 index 0000000000..b6c9872a18 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-identity/exec.js @@ -0,0 +1,3 @@ +const result = 5 |> %; + +expect(result).toBe(5); diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-identity/input.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-identity/input.js new file mode 100644 index 0000000000..b6c9872a18 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-identity/input.js @@ -0,0 +1,3 @@ +const result = 5 |> %; + +expect(result).toBe(5); diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-identity/output.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-identity/output.js new file mode 100644 index 0000000000..ab1b473690 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-identity/output.js @@ -0,0 +1,4 @@ +var _ref; + +const result = (_ref = 5, _ref); +expect(result).toBe(5); diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-with-addition/exec.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-with-addition/exec.js new file mode 100644 index 0000000000..aaeaa5f793 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-with-addition/exec.js @@ -0,0 +1,3 @@ +const result = 5 |> % + 1 |> % + %; + +expect(result).toBe(12); diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-with-addition/input.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-with-addition/input.js new file mode 100644 index 0000000000..aaeaa5f793 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-with-addition/input.js @@ -0,0 +1,3 @@ +const result = 5 |> % + 1 |> % + %; + +expect(result).toBe(12); diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-with-addition/output.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-with-addition/output.js new file mode 100644 index 0000000000..73bb5a695b --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-with-addition/output.js @@ -0,0 +1,4 @@ +var _ref, _ref2; + +const result = (_ref2 = (_ref = 5, _ref + 1), _ref2 + _ref2); +expect(result).toBe(12); diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-with-arrow-function-and-nested-pipe/exec.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-with-arrow-function-and-nested-pipe/exec.js new file mode 100644 index 0000000000..8f25f757cb --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-with-arrow-function-and-nested-pipe/exec.js @@ -0,0 +1,9 @@ +const result = 5 + |> Math.pow(%, 2) + |> [1, 2, 3].map(n => n + % + |> % * 2 + |> `${%} apples` + |> %.toUpperCase()) + |> %.join(); + +expect(result).toEqual('52 APPLES,54 APPLES,56 APPLES'); diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-with-arrow-function-and-nested-pipe/input.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-with-arrow-function-and-nested-pipe/input.js new file mode 100644 index 0000000000..8f25f757cb --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-with-arrow-function-and-nested-pipe/input.js @@ -0,0 +1,9 @@ +const result = 5 + |> Math.pow(%, 2) + |> [1, 2, 3].map(n => n + % + |> % * 2 + |> `${%} apples` + |> %.toUpperCase()) + |> %.join(); + +expect(result).toEqual('52 APPLES,54 APPLES,56 APPLES'); diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-with-arrow-function-and-nested-pipe/output.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-with-arrow-function-and-nested-pipe/output.js new file mode 100644 index 0000000000..01bf3aa32c --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-with-arrow-function-and-nested-pipe/output.js @@ -0,0 +1,8 @@ +var _ref, _ref5, _ref6; + +const result = (_ref6 = (_ref5 = (_ref = 5, Math.pow(_ref, 2)), [1, 2, 3].map(n => { + var _ref2, _ref3, _ref4; + + return _ref4 = (_ref3 = (_ref2 = n + _ref5, _ref2 * 2), `${_ref3} apples`), _ref4.toUpperCase(); +})), _ref6.join()); +expect(result).toEqual('52 APPLES,54 APPLES,56 APPLES'); diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-with-arrow-function/exec.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-with-arrow-function/exec.js new file mode 100644 index 0000000000..25578da875 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-with-arrow-function/exec.js @@ -0,0 +1,6 @@ +const result = -2.2 // -2.2 + |> Math.floor(%) // -3 + |> (() => Math.pow(%, 5)) // () => -243 + |> %(); // -243 + +expect(result).toBe(-243); diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-with-arrow-function/input.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-with-arrow-function/input.js new file mode 100644 index 0000000000..25578da875 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-with-arrow-function/input.js @@ -0,0 +1,6 @@ +const result = -2.2 // -2.2 + |> Math.floor(%) // -3 + |> (() => Math.pow(%, 5)) // () => -243 + |> %(); // -243 + +expect(result).toBe(-243); diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-with-arrow-function/output.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-with-arrow-function/output.js new file mode 100644 index 0000000000..08ae200f6e --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-with-arrow-function/output.js @@ -0,0 +1,8 @@ +var _ref, _ref2, _ref3; + +const result = (_ref3 = (_ref2 = (_ref = -2.2 // -2.2 +, Math.floor(_ref) // -3 +), () => Math.pow(_ref2, 5) // () => -243 +), _ref3()); // -243 + +expect(result).toBe(-243); diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-with-await/exec.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-with-await/exec.js new file mode 100644 index 0000000000..9a6895ab32 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-with-await/exec.js @@ -0,0 +1,14 @@ +function triple (x) { + return x * 3 +} + +async function asyncFunction(n) { + return n + |> Math.abs(%) + |> await Promise.resolve(%) + |> triple(%); +} + +asyncFunction(-7).then(result => { + expect(result).toBe(21); +}); diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-with-await/input.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-with-await/input.js new file mode 100644 index 0000000000..9a6895ab32 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-with-await/input.js @@ -0,0 +1,14 @@ +function triple (x) { + return x * 3 +} + +async function asyncFunction(n) { + return n + |> Math.abs(%) + |> await Promise.resolve(%) + |> triple(%); +} + +asyncFunction(-7).then(result => { + expect(result).toBe(21); +}); diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-with-await/options.json b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-with-await/options.json new file mode 100644 index 0000000000..f19c36b8ee --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-with-await/options.json @@ -0,0 +1,6 @@ +{ + "parserOpts": { + "allowReturnOutsideFunction": true + }, + "minNodeVersion": "8.0.0" +} diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-with-await/output.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-with-await/output.js new file mode 100644 index 0000000000..133f8dbab2 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-with-await/output.js @@ -0,0 +1,13 @@ +function triple(x) { + return x * 3; +} + +async function asyncFunction(n) { + var _ref, _ref2, _ref3; + + return _ref3 = (_ref2 = (_ref = n, Math.abs(_ref)), await Promise.resolve(_ref2)), triple(_ref3); +} + +asyncFunction(-7).then(result => { + expect(result).toBe(21); +}); diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-with-class-expression-and-private-properties/exec.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-with-class-expression-and-private-properties/exec.js new file mode 100644 index 0000000000..7d3c443e48 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-with-class-expression-and-private-properties/exec.js @@ -0,0 +1,20 @@ +const result = 1 + |> class { + #baz; + + constructor () { + this.#baz = %; + } + + #bar () { + return this.#baz + 2; + } + + foo () { + return this.#bar() + 3; + } + } + |> new % + |> %.foo(); + +expect(result).toBe(1 + 2 + 3); diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-with-class-expression-and-private-properties/input.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-with-class-expression-and-private-properties/input.js new file mode 100644 index 0000000000..7d3c443e48 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-with-class-expression-and-private-properties/input.js @@ -0,0 +1,20 @@ +const result = 1 + |> class { + #baz; + + constructor () { + this.#baz = %; + } + + #bar () { + return this.#baz + 2; + } + + foo () { + return this.#bar() + 3; + } + } + |> new % + |> %.foo(); + +expect(result).toBe(1 + 2 + 3); diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-with-class-expression-and-private-properties/options.json b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-with-class-expression-and-private-properties/options.json new file mode 100644 index 0000000000..13cd0f42c6 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-with-class-expression-and-private-properties/options.json @@ -0,0 +1,6 @@ +{ + "plugins": [ + ["proposal-pipeline-operator", { "proposal": "hack", "topicToken": "%" }] + ], + "minNodeVersion": "14.0.0" +} diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-with-class-expression-and-private-properties/output.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-with-class-expression-and-private-properties/output.js new file mode 100644 index 0000000000..dcb947391c --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-with-class-expression-and-private-properties/output.js @@ -0,0 +1,19 @@ +var _ref, _ref2, _ref3; + +const result = (_ref3 = (_ref2 = (_ref = 1, class { + #baz; + + constructor() { + this.#baz = _ref; + } + + #bar() { + return this.#baz + 2; + } + + foo() { + return this.#bar() + 3; + } + +}), new _ref2()), _ref3.foo()); +expect(result).toBe(1 + 2 + 3); diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-with-eval/exec.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-with-eval/exec.js new file mode 100644 index 0000000000..c48331465f --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-with-eval/exec.js @@ -0,0 +1,4 @@ +const program = '(function() { return this; })()'; +const result = program |> eval(%); + +expect(result).not.toBeUndefined(); diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-with-eval/input.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-with-eval/input.js new file mode 100644 index 0000000000..c48331465f --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-with-eval/input.js @@ -0,0 +1,4 @@ +const program = '(function() { return this; })()'; +const result = program |> eval(%); + +expect(result).not.toBeUndefined(); diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-with-eval/output.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-with-eval/output.js new file mode 100644 index 0000000000..c5dbd6107a --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-with-eval/output.js @@ -0,0 +1,5 @@ +var _ref; + +const program = '(function() { return this; })()'; +const result = (_ref = program, eval(_ref)); +expect(result).not.toBeUndefined(); diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-with-nested-pipe/exec.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-with-nested-pipe/exec.js new file mode 100644 index 0000000000..64a4168961 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-with-nested-pipe/exec.js @@ -0,0 +1,7 @@ +const result = 5 + |> Math.pow(%, 2) + |> (% + 1 + |> `${%} apples` + |> %.toUpperCase()); + +expect(result).toEqual('26 APPLES'); diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-with-nested-pipe/input.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-with-nested-pipe/input.js new file mode 100644 index 0000000000..64a4168961 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-with-nested-pipe/input.js @@ -0,0 +1,7 @@ +const result = 5 + |> Math.pow(%, 2) + |> (% + 1 + |> `${%} apples` + |> %.toUpperCase()); + +expect(result).toEqual('26 APPLES'); diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-with-nested-pipe/output.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-with-nested-pipe/output.js new file mode 100644 index 0000000000..482706ff44 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-with-nested-pipe/output.js @@ -0,0 +1,4 @@ +var _ref, _ref2, _ref3, _ref4; + +const result = (_ref4 = (_ref = 5, Math.pow(_ref, 2)), (_ref3 = (_ref2 = _ref4 + 1, `${_ref2} apples`), _ref3.toUpperCase())); +expect(result).toEqual('26 APPLES'); diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-with-object-literal/exec.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-with-object-literal/exec.js new file mode 100644 index 0000000000..6d8ddc7118 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-with-object-literal/exec.js @@ -0,0 +1,10 @@ +function area(rect) { + return rect.width * rect.height; +} + +const result = -5 + |> Math.abs(%) + |> { width: %, height: % + 3 } + |> area(%); + +expect(result).toBe(40); diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-with-object-literal/input.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-with-object-literal/input.js new file mode 100644 index 0000000000..6d8ddc7118 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-with-object-literal/input.js @@ -0,0 +1,10 @@ +function area(rect) { + return rect.width * rect.height; +} + +const result = -5 + |> Math.abs(%) + |> { width: %, height: % + 3 } + |> area(%); + +expect(result).toBe(40); diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-with-object-literal/output.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-with-object-literal/output.js new file mode 100644 index 0000000000..397577ac5a --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-with-object-literal/output.js @@ -0,0 +1,11 @@ +var _ref, _ref2, _ref3; + +function area(rect) { + return rect.width * rect.height; +} + +const result = (_ref3 = (_ref2 = (_ref = -5, Math.abs(_ref)), { + width: _ref2, + height: _ref2 + 3 +}), area(_ref3)); +expect(result).toBe(40); diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-with-topic-method-call/exec.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-with-topic-method-call/exec.js new file mode 100644 index 0000000000..2231b1d412 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-with-topic-method-call/exec.js @@ -0,0 +1,3 @@ +const result = 'Hello' |> %.toUpperCase(); + +expect(result).toBe('HELLO'); diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-with-topic-method-call/input.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-with-topic-method-call/input.js new file mode 100644 index 0000000000..2231b1d412 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-with-topic-method-call/input.js @@ -0,0 +1,3 @@ +const result = 'Hello' |> %.toUpperCase(); + +expect(result).toBe('HELLO'); diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-with-topic-method-call/output.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-with-topic-method-call/output.js new file mode 100644 index 0000000000..029efa5642 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-with-topic-method-call/output.js @@ -0,0 +1,4 @@ +var _ref; + +const result = (_ref = 'Hello', _ref.toUpperCase()); +expect(result).toBe('HELLO'); diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-with-yield/exec.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-with-yield/exec.js new file mode 100644 index 0000000000..afc5492ab5 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-with-yield/exec.js @@ -0,0 +1,13 @@ +function *myGenerator(n) { + return n + |> (yield %) + |> Math.abs(%); +} + +const myIterator = myGenerator(15); + +const yieldedValue = myIterator.next().value; +const returnedValue = myIterator.next(-30).value; + +expect(yieldedValue).toBe(15); +expect(returnedValue).toBe(30); diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-with-yield/input.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-with-yield/input.js new file mode 100644 index 0000000000..afc5492ab5 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-with-yield/input.js @@ -0,0 +1,13 @@ +function *myGenerator(n) { + return n + |> (yield %) + |> Math.abs(%); +} + +const myIterator = myGenerator(15); + +const yieldedValue = myIterator.next().value; +const returnedValue = myIterator.next(-30).value; + +expect(yieldedValue).toBe(15); +expect(returnedValue).toBe(30); diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-with-yield/output.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-with-yield/output.js new file mode 100644 index 0000000000..6323364b3f --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-body-with-yield/output.js @@ -0,0 +1,11 @@ +function* myGenerator(n) { + var _ref, _ref2; + + return _ref2 = (_ref = n, yield _ref), Math.abs(_ref2); +} + +const myIterator = myGenerator(15); +const yieldedValue = myIterator.next().value; +const returnedValue = myIterator.next(-30).value; +expect(yieldedValue).toBe(15); +expect(returnedValue).toBe(30); diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-head-with-nested-pipe/exec.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-head-with-nested-pipe/exec.js new file mode 100644 index 0000000000..8d359b5ae1 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-head-with-nested-pipe/exec.js @@ -0,0 +1,3 @@ +const result = (5 |> Math.pow(%, 2)) |> % + 1; + +expect(result).toEqual(26); diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-head-with-nested-pipe/input.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-head-with-nested-pipe/input.js new file mode 100644 index 0000000000..8d359b5ae1 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-head-with-nested-pipe/input.js @@ -0,0 +1,3 @@ +const result = (5 |> Math.pow(%, 2)) |> % + 1; + +expect(result).toEqual(26); diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-head-with-nested-pipe/output.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-head-with-nested-pipe/output.js new file mode 100644 index 0000000000..1adde65820 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-head-with-nested-pipe/output.js @@ -0,0 +1,4 @@ +var _ref, _ref2; + +const result = (_ref2 = (_ref = 5, Math.pow(_ref, 2)), _ref2 + 1); +expect(result).toEqual(26); diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-in-arrow-function/exec.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-in-arrow-function/exec.js new file mode 100644 index 0000000000..a273c2cf95 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-in-arrow-function/exec.js @@ -0,0 +1,6 @@ +const result = () => -2.2 // -2.2 + |> Math.floor(%) // -3 + |> (() => Math.pow(%, 5)) // () => -243 + |> %(); // -243 + +expect(result()).toBe(-243); diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-in-arrow-function/input.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-in-arrow-function/input.js new file mode 100644 index 0000000000..a273c2cf95 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-in-arrow-function/input.js @@ -0,0 +1,6 @@ +const result = () => -2.2 // -2.2 + |> Math.floor(%) // -3 + |> (() => Math.pow(%, 5)) // () => -243 + |> %(); // -243 + +expect(result()).toBe(-243); diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-in-arrow-function/output.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-in-arrow-function/output.js new file mode 100644 index 0000000000..573e312f0f --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/pipe-in-arrow-function/output.js @@ -0,0 +1,11 @@ +const result = () => { + var _ref, _ref2, _ref3; + + return _ref3 = (_ref2 = (_ref = -2.2 // -2.2 + , Math.floor(_ref) // -3 + ), () => Math.pow(_ref2, 5) // () => -243 + ), _ref3(); +}; // -243 + + +expect(result()).toBe(-243); diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/transform-arrow-functions/exec.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/transform-arrow-functions/exec.js new file mode 100644 index 0000000000..d4c0af4d77 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/transform-arrow-functions/exec.js @@ -0,0 +1,5 @@ +const triple = x => x * 3; + +const result = -7 |> Math.abs(%) |> triple(%); + +return expect(result).toBe(21); diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/transform-arrow-functions/input.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/transform-arrow-functions/input.js new file mode 100644 index 0000000000..d4c0af4d77 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/transform-arrow-functions/input.js @@ -0,0 +1,5 @@ +const triple = x => x * 3; + +const result = -7 |> Math.abs(%) |> triple(%); + +return expect(result).toBe(21); diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/transform-arrow-functions/options.json b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/transform-arrow-functions/options.json new file mode 100644 index 0000000000..55d4d425fe --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/transform-arrow-functions/options.json @@ -0,0 +1,9 @@ +{ + "plugins": [ + ["proposal-pipeline-operator", { "proposal": "hack", "topicToken": "%" }], + "transform-arrow-functions" + ], + "parserOpts": { + "allowReturnOutsideFunction": true + } +} diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/transform-arrow-functions/output.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/transform-arrow-functions/output.js new file mode 100644 index 0000000000..556ae36b83 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/transform-arrow-functions/output.js @@ -0,0 +1,8 @@ +var _ref, _ref2; + +const triple = function (x) { + return x * 3; +}; + +const result = (_ref2 = (_ref = -7, Math.abs(_ref)), triple(_ref2)); +return expect(result).toBe(21); diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/transform-await-and-arrow-functions/exec.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/transform-await-and-arrow-functions/exec.js new file mode 100644 index 0000000000..7dae9c7c94 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/transform-await-and-arrow-functions/exec.js @@ -0,0 +1,13 @@ +const triple = (x) => x * 3; + +async function myFunction(n) { + return n + |> Math.abs(%) + |> Promise.resolve(%) + |> await % + |> triple(%); +} + +return myFunction(-7).then(result => { + expect(result).toBe(21); +}); diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/transform-await-and-arrow-functions/input.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/transform-await-and-arrow-functions/input.js new file mode 100644 index 0000000000..7dae9c7c94 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/transform-await-and-arrow-functions/input.js @@ -0,0 +1,13 @@ +const triple = (x) => x * 3; + +async function myFunction(n) { + return n + |> Math.abs(%) + |> Promise.resolve(%) + |> await % + |> triple(%); +} + +return myFunction(-7).then(result => { + expect(result).toBe(21); +}); diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/transform-await-and-arrow-functions/options.json b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/transform-await-and-arrow-functions/options.json new file mode 100644 index 0000000000..ff943f38a6 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/transform-await-and-arrow-functions/options.json @@ -0,0 +1,10 @@ +{ + "plugins": [ + ["proposal-pipeline-operator", { "proposal": "hack", "topicToken": "%" }], + "transform-arrow-functions" + ], + "parserOpts": { + "allowReturnOutsideFunction": true + }, + "minNodeVersion": "8.0.0" +} diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/transform-await-and-arrow-functions/output.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/transform-await-and-arrow-functions/output.js new file mode 100644 index 0000000000..f7bf29a5fa --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/transform-await-and-arrow-functions/output.js @@ -0,0 +1,13 @@ +const triple = function (x) { + return x * 3; +}; + +async function myFunction(n) { + var _ref, _ref2, _ref3, _ref4; + + return _ref4 = (_ref3 = (_ref2 = (_ref = n, Math.abs(_ref)), Promise.resolve(_ref2)), await _ref3), triple(_ref4); +} + +return myFunction(-7).then(function (result) { + expect(result).toBe(21); +}); diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/while-statement-with-pipe-in-condition/exec.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/while-statement-with-pipe-in-condition/exec.js new file mode 100644 index 0000000000..46cab09aa4 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/while-statement-with-pipe-in-condition/exec.js @@ -0,0 +1,7 @@ +let i = 0; +let sum = 0; + +while (i |> (i = % + 1) |> % <= 10) + sum += i; + +expect(sum).toBe(10 + 9 + 8 + 7 + 6 + 5 + 4 + 3 + 2 + 1); diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/while-statement-with-pipe-in-condition/input.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/while-statement-with-pipe-in-condition/input.js new file mode 100644 index 0000000000..46cab09aa4 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/while-statement-with-pipe-in-condition/input.js @@ -0,0 +1,7 @@ +let i = 0; +let sum = 0; + +while (i |> (i = % + 1) |> % <= 10) + sum += i; + +expect(sum).toBe(10 + 9 + 8 + 7 + 6 + 5 + 4 + 3 + 2 + 1); diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/while-statement-with-pipe-in-condition/output.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/while-statement-with-pipe-in-condition/output.js new file mode 100644 index 0000000000..c249ee7673 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/while-statement-with-pipe-in-condition/output.js @@ -0,0 +1,10 @@ +let i = 0; +let sum = 0; + +while (_ref2 = (_ref = i, i = _ref + 1), _ref2 <= 10) { + var _ref, _ref2; + + sum += i; +} + +expect(sum).toBe(10 + 9 + 8 + 7 + 6 + 5 + 4 + 3 + 2 + 1); diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/within-assignment/exec.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/within-assignment/exec.js new file mode 100644 index 0000000000..17c2d772df --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/within-assignment/exec.js @@ -0,0 +1,3 @@ +const x = 0 |> % + 1; + +expect(x).toBe(1); diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/within-assignment/input.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/within-assignment/input.js new file mode 100644 index 0000000000..17c2d772df --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/within-assignment/input.js @@ -0,0 +1,3 @@ +const x = 0 |> % + 1; + +expect(x).toBe(1); diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/within-assignment/output.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/within-assignment/output.js new file mode 100644 index 0000000000..5ca2ce9e53 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/within-assignment/output.js @@ -0,0 +1,4 @@ +var _ref; + +const x = (_ref = 0, _ref + 1); +expect(x).toBe(1); diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/within-for-classic-statement-init/exec.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/within-for-classic-statement-init/exec.js new file mode 100644 index 0000000000..1f4c6486b5 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/within-for-classic-statement-init/exec.js @@ -0,0 +1,5 @@ +let sum = 0; +for (var i = 0 |> %; i <= 10; i++) + sum += i; + +expect(sum).toBe(10 + 9 + 8 + 7 + 6 + 5 + 4 + 3 + 2 + 1); diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/within-for-classic-statement-init/input.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/within-for-classic-statement-init/input.js new file mode 100644 index 0000000000..1f4c6486b5 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/within-for-classic-statement-init/input.js @@ -0,0 +1,5 @@ +let sum = 0; +for (var i = 0 |> %; i <= 10; i++) + sum += i; + +expect(sum).toBe(10 + 9 + 8 + 7 + 6 + 5 + 4 + 3 + 2 + 1); diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/within-for-classic-statement-init/output.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/within-for-classic-statement-init/output.js new file mode 100644 index 0000000000..dd399138c6 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/within-for-classic-statement-init/output.js @@ -0,0 +1,9 @@ +let sum = 0; + +for (var i = (_ref = 0, _ref); i <= 10; i++) { + var _ref; + + sum += i; +} + +expect(sum).toBe(10 + 9 + 8 + 7 + 6 + 5 + 4 + 3 + 2 + 1); diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/within-for-classic-statement-test/exec.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/within-for-classic-statement-test/exec.js new file mode 100644 index 0000000000..004b86f7c5 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/within-for-classic-statement-test/exec.js @@ -0,0 +1,5 @@ +let sum = 0; +for (var i = 0; i |> % <= 10; i++) + sum = sum + i; + +expect(sum).toBe(10 + 9 + 8 + 7 + 6 + 5 + 4 + 3 + 2 + 1) diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/within-for-classic-statement-test/input.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/within-for-classic-statement-test/input.js new file mode 100644 index 0000000000..004b86f7c5 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/within-for-classic-statement-test/input.js @@ -0,0 +1,5 @@ +let sum = 0; +for (var i = 0; i |> % <= 10; i++) + sum = sum + i; + +expect(sum).toBe(10 + 9 + 8 + 7 + 6 + 5 + 4 + 3 + 2 + 1) diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/within-for-classic-statement-test/output.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/within-for-classic-statement-test/output.js new file mode 100644 index 0000000000..14ae06d74a --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/within-for-classic-statement-test/output.js @@ -0,0 +1,9 @@ +let sum = 0; + +for (var i = 0; _ref = i, _ref <= 10; i++) { + var _ref; + + sum = sum + i; +} + +expect(sum).toBe(10 + 9 + 8 + 7 + 6 + 5 + 4 + 3 + 2 + 1); diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/within-for-classic-statement-update/exec.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/within-for-classic-statement-update/exec.js new file mode 100644 index 0000000000..f4e2d2d735 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/within-for-classic-statement-update/exec.js @@ -0,0 +1,6 @@ +let sum = 0; +for (var i = 0; i <= 10; i = i |> % + 1) { + sum = sum + i; +} + +expect(sum).toBe(10 + 9 + 8 + 7 + 6 + 5 + 4 + 3 + 2 + 1) diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/within-for-classic-statement-update/input.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/within-for-classic-statement-update/input.js new file mode 100644 index 0000000000..f4e2d2d735 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/within-for-classic-statement-update/input.js @@ -0,0 +1,6 @@ +let sum = 0; +for (var i = 0; i <= 10; i = i |> % + 1) { + sum = sum + i; +} + +expect(sum).toBe(10 + 9 + 8 + 7 + 6 + 5 + 4 + 3 + 2 + 1) diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/within-for-classic-statement-update/output.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/within-for-classic-statement-update/output.js new file mode 100644 index 0000000000..a741096b13 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/within-for-classic-statement-update/output.js @@ -0,0 +1,9 @@ +let sum = 0; + +for (var i = 0; i <= 10; i = (_ref = i, _ref + 1)) { + var _ref; + + sum = sum + i; +} + +expect(sum).toBe(10 + 9 + 8 + 7 + 6 + 5 + 4 + 3 + 2 + 1); diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/within-generator-with-yield/input.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/within-generator-with-yield/input.js new file mode 100644 index 0000000000..6c0af1e734 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/within-generator-with-yield/input.js @@ -0,0 +1,5 @@ +function * myGenerator(n) { + return n + |> (yield %) + |> Math.abs(%); +} diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/within-generator-with-yield/output.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/within-generator-with-yield/output.js new file mode 100644 index 0000000000..396c84ad9f --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/within-generator-with-yield/output.js @@ -0,0 +1,5 @@ +function* myGenerator(n) { + var _ref, _ref2; + + return _ref2 = (_ref = n, yield _ref), Math.abs(_ref2); +} diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/within-if-else-block/input.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/within-if-else-block/input.js new file mode 100644 index 0000000000..ea22b2858d --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/within-if-else-block/input.js @@ -0,0 +1,4 @@ +if (v |> e(%) |> f(%)) + g() |> h(%, % + 1) |> i(%); +else + j(); diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/within-if-else-block/output.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/within-if-else-block/output.js new file mode 100644 index 0000000000..6782b466ae --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/within-if-else-block/output.js @@ -0,0 +1,3 @@ +var _ref, _ref2, _ref3, _ref4; + +if (_ref2 = (_ref = v, e(_ref)), f(_ref2)) _ref4 = (_ref3 = g(), h(_ref3, _ref3 + 1)), i(_ref4);else j(); diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/within-var-statement/exec.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/within-var-statement/exec.js new file mode 100644 index 0000000000..26837dd515 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/within-var-statement/exec.js @@ -0,0 +1,3 @@ +var i = 0; + +expect(i).toBe(0); diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/within-var-statement/input.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/within-var-statement/input.js new file mode 100644 index 0000000000..26837dd515 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/within-var-statement/input.js @@ -0,0 +1,3 @@ +var i = 0; + +expect(i).toBe(0); diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/within-var-statement/output.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/within-var-statement/output.js new file mode 100644 index 0000000000..126fd40304 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/within-var-statement/output.js @@ -0,0 +1,2 @@ +var i = 0; +expect(i).toBe(0); diff --git a/packages/babel-plugin-syntax-pipeline-operator/src/index.js b/packages/babel-plugin-syntax-pipeline-operator/src/index.js index 5fe966e391..f81201bb2f 100644 --- a/packages/babel-plugin-syntax-pipeline-operator/src/index.js +++ b/packages/babel-plugin-syntax-pipeline-operator/src/index.js @@ -1,7 +1,7 @@ import { declare } from "@babel/helper-plugin-utils"; const PIPELINE_PROPOSALS = ["minimal", "fsharp", "hack", "smart"]; -const TOPIC_TOKENS = ["#"]; +const TOPIC_TOKENS = ["%", "#"]; const documentationURL = "https://babeljs.io/docs/en/babel-plugin-proposal-pipeline-operator";