diff --git a/packages/babel-generator/src/generators/types.ts b/packages/babel-generator/src/generators/types.ts index 48ab4c3806e5..b75f5cba5916 100644 --- a/packages/babel-generator/src/generators/types.ts +++ b/packages/babel-generator/src/generators/types.ts @@ -238,18 +238,19 @@ export function DecimalLiteral(this: Printer, node: t.DecimalLiteral) { } // Hack pipe operator +const validTopicTokenSet = new Set(["^", "%", "#"]); export function TopicReference(this: Printer) { const { topicToken } = this.format; - switch (topicToken) { - case "#": - this.token("#"); - break; - - default: { - const givenTopicTokenJSON = JSON.stringify(topicToken); - const message = `The "topicToken" generator option must be "#" (${givenTopicTokenJSON} received instead).`; - throw new Error(message); - } + + if (validTopicTokenSet.has(topicToken)) { + this.token(topicToken); + } else { + const givenTopicTokenJSON = JSON.stringify(topicToken); + const validTopics = Array.from(validTopicTokenSet, v => JSON.stringify(v)); + throw new Error( + `The "topicToken" generator option must be one of ` + + `${validTopics.join(", ")} (${givenTopicTokenJSON} received instead).`, + ); } } diff --git a/packages/babel-generator/src/index.ts b/packages/babel-generator/src/index.ts index e16183ce0f3d..5346c24460b3 100644 --- a/packages/babel-generator/src/index.ts +++ b/packages/babel-generator/src/index.ts @@ -203,7 +203,7 @@ export interface GeneratorOptions { * For use with the Hack-style pipe operator. * Changes what token is used for pipe bodies’ topic references. */ - topicToken?: "#"; + topicToken?: "^" | "%" | "#"; } export interface GeneratorResult { diff --git a/packages/babel-generator/test/fixtures/types/TopicReference-with-caret-topicToken/input.js b/packages/babel-generator/test/fixtures/types/TopicReference-with-caret-topicToken/input.js new file mode 100644 index 000000000000..476589e6a831 --- /dev/null +++ b/packages/babel-generator/test/fixtures/types/TopicReference-with-caret-topicToken/input.js @@ -0,0 +1 @@ +2 + 3 |> ^.toString(16); diff --git a/packages/babel-generator/test/fixtures/types/TopicReference-with-caret-topicToken/options.json b/packages/babel-generator/test/fixtures/types/TopicReference-with-caret-topicToken/options.json new file mode 100644 index 000000000000..9f1d6c0c1ca6 --- /dev/null +++ b/packages/babel-generator/test/fixtures/types/TopicReference-with-caret-topicToken/options.json @@ -0,0 +1,4 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "hack", "topicToken": "^" }]], + "topicToken": "^" +} diff --git a/packages/babel-generator/test/fixtures/types/TopicReference-with-caret-topicToken/output.js b/packages/babel-generator/test/fixtures/types/TopicReference-with-caret-topicToken/output.js new file mode 100644 index 000000000000..476589e6a831 --- /dev/null +++ b/packages/babel-generator/test/fixtures/types/TopicReference-with-caret-topicToken/output.js @@ -0,0 +1 @@ +2 + 3 |> ^.toString(16); diff --git a/packages/babel-generator/test/fixtures/types/TopicReference-with-invalid-topicToken/options.json b/packages/babel-generator/test/fixtures/types/TopicReference-with-invalid-topicToken/options.json index 4b1203dd72d8..3ef07c59571f 100644 --- a/packages/babel-generator/test/fixtures/types/TopicReference-with-invalid-topicToken/options.json +++ b/packages/babel-generator/test/fixtures/types/TopicReference-with-invalid-topicToken/options.json @@ -1,5 +1,5 @@ { "plugins": [["pipelineOperator", { "proposal": "hack", "topicToken": "#" }]], "topicToken": "invalid", - "throws": "The \"topicToken\" generator option must be \"#\" (\"invalid\" received instead)." + "throws": "The \"topicToken\" generator option must be one of \"^\", \"%\", \"#\" (\"invalid\" received instead)." } diff --git a/packages/babel-generator/test/fixtures/types/TopicReference-with-missing-topicToken/options.json b/packages/babel-generator/test/fixtures/types/TopicReference-with-missing-topicToken/options.json index 9e4d884dbf7f..1911353dc052 100644 --- a/packages/babel-generator/test/fixtures/types/TopicReference-with-missing-topicToken/options.json +++ b/packages/babel-generator/test/fixtures/types/TopicReference-with-missing-topicToken/options.json @@ -1,4 +1,4 @@ { "plugins": [["pipelineOperator", { "proposal": "hack", "topicToken": "#" }]], - "throws": "The \"topicToken\" generator option must be \"#\" (undefined received instead)." + "throws": "The \"topicToken\" generator option must be one of \"^\", \"%\", \"#\" (undefined received instead)." } diff --git a/packages/babel-generator/test/fixtures/types/TopicReference-with-percent-topicToken/input.js b/packages/babel-generator/test/fixtures/types/TopicReference-with-percent-topicToken/input.js new file mode 100644 index 000000000000..1eb3ce0874c7 --- /dev/null +++ b/packages/babel-generator/test/fixtures/types/TopicReference-with-percent-topicToken/input.js @@ -0,0 +1 @@ +2 + 3 |> %.toString(16); diff --git a/packages/babel-generator/test/fixtures/types/TopicReference-with-percent-topicToken/options.json b/packages/babel-generator/test/fixtures/types/TopicReference-with-percent-topicToken/options.json new file mode 100644 index 000000000000..33f7b6396252 --- /dev/null +++ b/packages/babel-generator/test/fixtures/types/TopicReference-with-percent-topicToken/options.json @@ -0,0 +1,4 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "hack", "topicToken": "%" }]], + "topicToken": "%" +} diff --git a/packages/babel-generator/test/fixtures/types/TopicReference-with-percent-topicToken/output.js b/packages/babel-generator/test/fixtures/types/TopicReference-with-percent-topicToken/output.js new file mode 100644 index 000000000000..1eb3ce0874c7 --- /dev/null +++ b/packages/babel-generator/test/fixtures/types/TopicReference-with-percent-topicToken/output.js @@ -0,0 +1 @@ +2 + 3 |> %.toString(16); diff --git a/packages/babel-parser/src/parser/expression.js b/packages/babel-parser/src/parser/expression.js index 4dcd64a5d6e7..eae9a7242d7f 100644 --- a/packages/babel-parser/src/parser/expression.js +++ b/packages/babel-parser/src/parser/expression.js @@ -1193,26 +1193,15 @@ export default class ExpressionParser extends LValParser { return this.parsePrivateName(); } - case tt.moduloAssign: - if ( - this.getPluginOption("pipelineOperator", "proposal") === "hack" && - this.getPluginOption("pipelineOperator", "topicToken") === "%" - ) { - // If we find %= in an expression position, and the Hack-pipes proposal is active, - // then the % could be the topic token (e.g., in x |> %==y or x |> %===y), and so we - // reparse it as %. - // The next readToken() call will start parsing from =. - - this.state.value = "%"; - this.state.type = tt.modulo; - this.state.pos--; - this.state.end--; - this.state.endLoc.column--; - } else { - throw this.unexpected(); - } + case tt.moduloAssign: { + return this.parseTopicReferenceThenEqualsSign(tt.modulo, "%"); + } + + case tt.xorAssign: { + return this.parseTopicReferenceThenEqualsSign(tt.bitwiseXOR, "^"); + } - // falls through + case tt.bitwiseXOR: case tt.modulo: case tt.hash: { const pipeProposal = this.getPluginOption( @@ -1221,24 +1210,7 @@ export default class ExpressionParser extends LValParser { ); 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, - ); + return this.parseTopicReference(pipeProposal); } } @@ -1325,6 +1297,61 @@ export default class ExpressionParser extends LValParser { } } + // This helper method should only be called + // when the parser has reached a potential Hack pipe topic token + // that is followed by an equals sign. + // See . + // If we find ^= or %= in an expression position + // (i.e., the tt.moduloAssign or tt.xorAssign token types), + // and if the Hack-pipes proposal is active with ^ or % as its topicToken, + // then the ^ or % could be the topic token (e.g., in x |> ^==y or x |> ^===y), + // and so we reparse the current token as ^ or %. + // Otherwise, this throws an unexpected-token error. + parseTopicReferenceThenEqualsSign( + topicTokenType: TokenType, + topicTokenValue: string, + ): N.Expression { + const pipeProposal = this.getPluginOption("pipelineOperator", "proposal"); + + if (pipeProposal) { + // Set the most-recent token to be a topic token + // given by the tokenType and tokenValue. + // Now the next readToken() call (in parseTopicReference) + // will consume that “topic token”. + this.state.type = topicTokenType; + this.state.value = topicTokenValue; + // Rewind the tokenizer to the end of the “topic token”, + // so that the following token starts at the equals sign after that topic token. + this.state.pos--; + this.state.end--; + this.state.endLoc.column--; + // Now actually consume the topic token. + return this.parseTopicReference(pipeProposal); + } else { + throw this.unexpected(); + } + } + + // This helper method should only be called + // when the proposal-pipeline-operator plugin is active, + // and when the parser has reached a potential Hack pipe topic token. + // Although a pipe-operator proposal is assumed to be active, + // its configuration might not match the current token’s type. + // See . + parseTopicReference(pipeProposal: string): N.Expression { + const 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); + } + // This helper method attempts to finish the given `node` // into a topic-reference node for the given `pipeProposal`. // See . diff --git a/packages/babel-parser/src/plugin-utils.js b/packages/babel-parser/src/plugin-utils.js index 017d158bfcb7..0e2d64c26e6f 100644 --- a/packages/babel-parser/src/plugin-utils.js +++ b/packages/babel-parser/src/plugin-utils.js @@ -39,7 +39,7 @@ export function getPluginOption( } const PIPELINE_PROPOSALS = ["minimal", "fsharp", "hack", "smart"]; -const TOPIC_TOKENS = ["%", "#"]; +const TOPIC_TOKENS = ["^", "%", "#"]; const RECORD_AND_TUPLE_SYNTAX_TYPES = ["hash", "bar"]; export function validatePlugins(plugins: PluginList) { diff --git a/packages/babel-parser/src/tokenizer/index.js b/packages/babel-parser/src/tokenizer/index.js index f8092cf585a0..93d19926876f 100644 --- a/packages/babel-parser/src/tokenizer/index.js +++ b/packages/babel-parser/src/tokenizer/index.js @@ -605,20 +605,24 @@ export default class Tokenizer extends ParserErrors { } readToken_mult_modulo(code: number): void { - // '%*' + // '%' or '*' let type = code === charCodes.asterisk ? tt.star : tt.modulo; let width = 1; let next = this.input.charCodeAt(this.state.pos + 1); - // Exponentiation operator ** + // Exponentiation operator '**' if (code === charCodes.asterisk && next === charCodes.asterisk) { width++; next = this.input.charCodeAt(this.state.pos + 2); type = tt.exponent; } + // '%=' or '*=' if (next === charCodes.equalsTo && !this.state.inType) { width++; + // `tt.moduloAssign` is only needed to support % as a Hack-pipe topic token. + // If the proposal ends up choosing a different token, + // it can be merged with tt.assign. type = code === charCodes.percentSign ? tt.moduloAssign : tt.assign; } @@ -692,11 +696,17 @@ export default class Tokenizer extends ParserErrors { } readToken_caret(): void { - // '^' const next = this.input.charCodeAt(this.state.pos + 1); - if (next === charCodes.equalsTo) { - this.finishOp(tt.assign, 2); - } else { + + // '^=' + if (next === charCodes.equalsTo && !this.state.inType) { + // `tt.xorAssign` is only needed to support ^ as a Hack-pipe topic token. + // If the proposal ends up choosing a different token, + // it can be merged with tt.assign. + this.finishOp(tt.xorAssign, 2); + } + // '^' + else { this.finishOp(tt.bitwiseXOR, 1); } } diff --git a/packages/babel-parser/src/tokenizer/types.js b/packages/babel-parser/src/tokenizer/types.js index 8f0efc4969d9..c9e8f2628c8e 100644 --- a/packages/babel-parser/src/tokenizer/types.js +++ b/packages/babel-parser/src/tokenizer/types.js @@ -182,8 +182,9 @@ export const tt: { [name: string]: TokenType } = { eq: createToken("=", { beforeExpr, isAssign }), assign: createToken("_=", { beforeExpr, isAssign }), slashAssign: createToken("_=", { beforeExpr, isAssign }), - // This is only needed to support % as a Hack-pipe topic token. If the proposal - // ends up choosing a different token, it can be merged with tt.assign. + // These are only needed to support % and ^ as a Hack-pipe topic token. When the + // proposal settles on a token, the others can be merged with tt.assign. + xorAssign: createToken("_=", { beforeExpr, isAssign }), moduloAssign: createToken("_=", { beforeExpr, isAssign }), // end: isAssign diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-addition-with-topic-first/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-addition-with-topic-first/input.js new file mode 100644 index 000000000000..007ae280e2fc --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-addition-with-topic-first/input.js @@ -0,0 +1 @@ +value |> ^ + 1 diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-addition-with-topic-first/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-addition-with-topic-first/options.json new file mode 100644 index 000000000000..ae9c48b29706 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-addition-with-topic-first/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-addition-with-topic-first/output.json new file mode 100644 index 000000000000..4af6702b93c0 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-addition-with-topic-last/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-addition-with-topic-last/input.js new file mode 100644 index 000000000000..af8f40c56272 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-addition-with-topic-last/input.js @@ -0,0 +1 @@ +value |> 1 + ^ diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-addition-with-topic-last/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-addition-with-topic-last/options.json new file mode 100644 index 000000000000..ae9c48b29706 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-addition-with-topic-last/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-addition-with-topic-last/output.json new file mode 100644 index 000000000000..09d48e0129f5 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-addition-without-topic/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-addition-without-topic/input.js new file mode 100644 index 000000000000..e952adac15fd --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-addition-without-topic/input.js @@ -0,0 +1 @@ +value |> a + b diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-addition-without-topic/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-addition-without-topic/options.json new file mode 100644 index 000000000000..ae9c48b29706 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-addition-without-topic/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-addition-without-topic/output.json new file mode 100644 index 000000000000..6565ae6d9aa2 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-arrow-function-parenthesized/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-arrow-function-parenthesized/input.js new file mode 100644 index 000000000000..455d5c69132f --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-arrow-function-parenthesized/input.js @@ -0,0 +1 @@ +value |> (() => ^ + 1) diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-arrow-function-parenthesized/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-arrow-function-parenthesized/options.json new file mode 100644 index 000000000000..ae9c48b29706 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-arrow-function-parenthesized/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-arrow-function-parenthesized/output.json new file mode 100644 index 000000000000..3bb77cf7bf46 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-arrow-function-unparenthesized/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-arrow-function-unparenthesized/input.js new file mode 100644 index 000000000000..beddad738923 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-arrow-function-unparenthesized/input.js @@ -0,0 +1 @@ +10 |> x => x + ^; diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-arrow-function-unparenthesized/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-arrow-function-unparenthesized/options.json new file mode 100644 index 000000000000..996491c1f81c --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-arrow-function-unparenthesized/options.json @@ -0,0 +1,11 @@ +{ + "plugins": [ + [ + "pipelineOperator", + { + "proposal": "hack", + "topicToken": "^" + } + ] + ] +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-arrow-function-unparenthesized/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-arrow-function-unparenthesized/output.json new file mode 100644 index 000000000000..4078ecbe0a00 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-arrow-function-unparenthesized/output.json @@ -0,0 +1,62 @@ +{ + "type": "File", + "start":0,"end":17,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":17}}, + "errors": [ + "SyntaxError: Hack-style pipe body cannot be an unparenthesized arrow function expression; please wrap it in parentheses. (1:6)" + ], + "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": "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": "ArrowFunctionExpression", + "start":6,"end":16,"loc":{"start":{"line":1,"column":6},"end":{"line":1,"column":16}}, + "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":"x"}, + "name": "x" + } + ], + "body": { + "type": "BinaryExpression", + "start":11,"end":16,"loc":{"start":{"line":1,"column":11},"end":{"line":1,"column":16}}, + "left": { + "type": "Identifier", + "start":11,"end":12,"loc":{"start":{"line":1,"column":11},"end":{"line":1,"column":12},"identifierName":"x"}, + "name": "x" + }, + "operator": "+", + "right": { + "type": "TopicReference", + "start":15,"end":16,"loc":{"start":{"line":1,"column":15},"end":{"line":1,"column":16}} + } + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-assignment-bitwise-xor-with-spaces/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-assignment-bitwise-xor-with-spaces/input.js new file mode 100644 index 000000000000..846e106548a4 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-assignment-bitwise-xor-with-spaces/input.js @@ -0,0 +1 @@ +value |> (variable ^= ^); diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-assignment-bitwise-xor-with-spaces/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-assignment-bitwise-xor-with-spaces/options.json new file mode 100644 index 000000000000..ae9c48b29706 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-assignment-bitwise-xor-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-caret-proposal-assignment-bitwise-xor-with-spaces/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-assignment-bitwise-xor-with-spaces/output.json new file mode 100644 index 000000000000..d8d0c3a26682 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-assignment-bitwise-xor-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": [] + } +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-assignment-bitwise-xor-without-spaces/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-assignment-bitwise-xor-without-spaces/input.js new file mode 100644 index 000000000000..5ba9aa50f84a --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-assignment-bitwise-xor-without-spaces/input.js @@ -0,0 +1 @@ +value |> (variable^=^); diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-assignment-bitwise-xor-without-spaces/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-assignment-bitwise-xor-without-spaces/options.json new file mode 100644 index 000000000000..ae9c48b29706 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-assignment-bitwise-xor-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-caret-proposal-assignment-bitwise-xor-without-spaces/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-assignment-bitwise-xor-without-spaces/output.json new file mode 100644 index 000000000000..cb0d87ebbbd3 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-assignment-bitwise-xor-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-caret-proposal-assignment-logical-and/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-assignment-logical-and/input.js new file mode 100644 index 000000000000..aad7084e6969 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-assignment-logical-and/input.js @@ -0,0 +1 @@ +value |> (x &&= ^) diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-assignment-logical-and/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-assignment-logical-and/options.json new file mode 100644 index 000000000000..996491c1f81c --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-assignment-logical-and/options.json @@ -0,0 +1,11 @@ +{ + "plugins": [ + [ + "pipelineOperator", + { + "proposal": "hack", + "topicToken": "^" + } + ] + ] +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-assignment-logical-and/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-assignment-logical-and/output.json new file mode 100644 index 000000000000..3c15e48a4789 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-assignment-logical-and/output.json @@ -0,0 +1,45 @@ +{ + "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": "AssignmentExpression", + "start":10,"end":17,"loc":{"start":{"line":1,"column":10},"end":{"line":1,"column":17}}, + "operator": "&&=", + "left": { + "type": "Identifier", + "start":10,"end":11,"loc":{"start":{"line":1,"column":10},"end":{"line":1,"column":11},"identifierName":"x"}, + "name": "x" + }, + "right": { + "type": "TopicReference", + "start":16,"end":17,"loc":{"start":{"line":1,"column":16},"end":{"line":1,"column":17}} + }, + "extra": { + "parenthesized": true, + "parenStart": 9 + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-assignment-modulo-with-spaces/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-assignment-modulo-with-spaces/input.js new file mode 100644 index 000000000000..a6d9954a2305 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-assignment-modulo-with-spaces/input.js @@ -0,0 +1 @@ +value |> (variable %= ^); diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-assignment-modulo-with-spaces/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-assignment-modulo-with-spaces/options.json new file mode 100644 index 000000000000..ae9c48b29706 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-assignment-modulo-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-caret-proposal-assignment-modulo-with-spaces/output.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-modulo-assignment-with-spaces/output.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-assignment-modulo-with-spaces/output.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-assignment-modulo-without-spaces/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-assignment-modulo-without-spaces/input.js new file mode 100644 index 000000000000..965cce073bef --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-assignment-modulo-without-spaces/input.js @@ -0,0 +1 @@ +value |> (variable%=^); diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-assignment-modulo-without-spaces/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-assignment-modulo-without-spaces/options.json new file mode 100644 index 000000000000..ae9c48b29706 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-assignment-modulo-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-caret-proposal-assignment-modulo-without-spaces/output.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-modulo-assignment-without-spaces/output.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-assignment-modulo-without-spaces/output.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-assignment-normal/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-assignment-normal/input.js new file mode 100644 index 000000000000..09be12e0d8b0 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-assignment-normal/input.js @@ -0,0 +1 @@ +value |> ([x, y] = ^) diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-assignment-normal/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-assignment-normal/options.json new file mode 100644 index 000000000000..996491c1f81c --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-assignment-normal/options.json @@ -0,0 +1,11 @@ +{ + "plugins": [ + [ + "pipelineOperator", + { + "proposal": "hack", + "topicToken": "^" + } + ] + ] +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-assignment-normal/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-assignment-normal/output.json new file mode 100644 index 000000000000..0fcd28072cc8 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-assignment-normal/output.json @@ -0,0 +1,56 @@ +{ + "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": "BinaryExpression", + "start":0,"end":21,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":21}}, + "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":20,"loc":{"start":{"line":1,"column":10},"end":{"line":1,"column":20}}, + "operator": "=", + "left": { + "type": "ArrayPattern", + "start":10,"end":16,"loc":{"start":{"line":1,"column":10},"end":{"line":1,"column":16}}, + "elements": [ + { + "type": "Identifier", + "start":11,"end":12,"loc":{"start":{"line":1,"column":11},"end":{"line":1,"column":12},"identifierName":"x"}, + "name": "x" + }, + { + "type": "Identifier", + "start":14,"end":15,"loc":{"start":{"line":1,"column":14},"end":{"line":1,"column":15},"identifierName":"y"}, + "name": "y" + } + ] + }, + "right": { + "type": "TopicReference", + "start":19,"end":20,"loc":{"start":{"line":1,"column":19},"end":{"line":1,"column":20}} + }, + "extra": { + "parenthesized": true, + "parenStart": 9 + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-assignment-plus/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-assignment-plus/input.js new file mode 100644 index 000000000000..50edeae785a5 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-assignment-plus/input.js @@ -0,0 +1 @@ +value |> (x += ^) diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-assignment-plus/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-assignment-plus/options.json new file mode 100644 index 000000000000..996491c1f81c --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-assignment-plus/options.json @@ -0,0 +1,11 @@ +{ + "plugins": [ + [ + "pipelineOperator", + { + "proposal": "hack", + "topicToken": "^" + } + ] + ] +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-assignment-plus/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-assignment-plus/output.json new file mode 100644 index 000000000000..7286fc1ca3c6 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-assignment-plus/output.json @@ -0,0 +1,45 @@ +{ + "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": "ExpressionStatement", + "start":0,"end":17,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":17}}, + "expression": { + "type": "BinaryExpression", + "start":0,"end":17,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":17}}, + "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":16,"loc":{"start":{"line":1,"column":10},"end":{"line":1,"column":16}}, + "operator": "+=", + "left": { + "type": "Identifier", + "start":10,"end":11,"loc":{"start":{"line":1,"column":10},"end":{"line":1,"column":11},"identifierName":"x"}, + "name": "x" + }, + "right": { + "type": "TopicReference", + "start":15,"end":16,"loc":{"start":{"line":1,"column":15},"end":{"line":1,"column":16}} + }, + "extra": { + "parenthesized": true, + "parenStart": 9 + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-assignment-to-topic/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-assignment-to-topic/input.js new file mode 100644 index 000000000000..c935c8f583ec --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-assignment-to-topic/input.js @@ -0,0 +1 @@ +value |> (^ = 1); diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-assignment-to-topic/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-assignment-to-topic/options.json new file mode 100644 index 000000000000..ae9c48b29706 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-assignment-to-topic/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-assignment-to-topic/output.json new file mode 100644 index 000000000000..34b61d929f4d --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-assignment-unparenthesized/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-assignment-unparenthesized/input.js new file mode 100644 index 000000000000..32bfbb9dbc1f --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-assignment-unparenthesized/input.js @@ -0,0 +1 @@ +value |> [x, y] = ^ diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-assignment-unparenthesized/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-assignment-unparenthesized/options.json new file mode 100644 index 000000000000..996491c1f81c --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-assignment-unparenthesized/options.json @@ -0,0 +1,11 @@ +{ + "plugins": [ + [ + "pipelineOperator", + { + "proposal": "hack", + "topicToken": "^" + } + ] + ] +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-assignment-unparenthesized/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-assignment-unparenthesized/output.json new file mode 100644 index 000000000000..2d377919e7b2 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-assignment-unparenthesized/output.json @@ -0,0 +1,55 @@ +{ + "type": "File", + "start":0,"end":19,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":19}}, + "errors": [ + "SyntaxError: Hack-style pipe body cannot be an unparenthesized assignment expression; please wrap it in parentheses. (1:9)" + ], + "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":5,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":5},"identifierName":"value"}, + "name": "value" + }, + "operator": "|>", + "right": { + "type": "AssignmentExpression", + "start":9,"end":19,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":19}}, + "operator": "=", + "left": { + "type": "ArrayPattern", + "start":9,"end":15,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":15}}, + "elements": [ + { + "type": "Identifier", + "start":10,"end":11,"loc":{"start":{"line":1,"column":10},"end":{"line":1,"column":11},"identifierName":"x"}, + "name": "x" + }, + { + "type": "Identifier", + "start":13,"end":14,"loc":{"start":{"line":1,"column":13},"end":{"line":1,"column":14},"identifierName":"y"}, + "name": "y" + } + ] + }, + "right": { + "type": "TopicReference", + "start":18,"end":19,"loc":{"start":{"line":1,"column":18},"end":{"line":1,"column":19}} + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-associativity/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-associativity/input.js new file mode 100644 index 000000000000..d642ed353c69 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-associativity/input.js @@ -0,0 +1 @@ +1 |> f(^) |> g(^); diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-associativity/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-associativity/options.json new file mode 100644 index 000000000000..ae9c48b29706 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-associativity/options.json @@ -0,0 +1,3 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "hack", "topicToken": "^" }]] +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-associativity/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-associativity/output.json new file mode 100644 index 000000000000..288c04e15ec5 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-associativity/output.json @@ -0,0 +1,66 @@ +{ + "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":17,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":17}}, + "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": "BinaryExpression", + "start":5,"end":17,"loc":{"start":{"line":1,"column":5},"end":{"line":1,"column":17}}, + "left": { + "type": "CallExpression", + "start":5,"end":9,"loc":{"start":{"line":1,"column":5},"end":{"line":1,"column":9}}, + "callee": { + "type": "Identifier", + "start":5,"end":6,"loc":{"start":{"line":1,"column":5},"end":{"line":1,"column":6},"identifierName":"f"}, + "name": "f" + }, + "arguments": [ + { + "type": "TopicReference", + "start":7,"end":8,"loc":{"start":{"line":1,"column":7},"end":{"line":1,"column":8}} + } + ] + }, + "operator": "|>", + "right": { + "type": "CallExpression", + "start":13,"end":17,"loc":{"start":{"line":1,"column":13},"end":{"line":1,"column":17}}, + "callee": { + "type": "Identifier", + "start":13,"end":14,"loc":{"start":{"line":1,"column":13},"end":{"line":1,"column":14},"identifierName":"g"}, + "name": "g" + }, + "arguments": [ + { + "type": "TopicReference", + "start":15,"end":16,"loc":{"start":{"line":1,"column":15},"end":{"line":1,"column":16}} + } + ] + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-async-await/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-async-await/input.js new file mode 100644 index 000000000000..fe21dec62830 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-async-await/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-async-await/options.json new file mode 100644 index 000000000000..ae9c48b29706 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-async-await/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-async-await/output.json new file mode 100644 index 000000000000..ce3d60256e05 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-bitwise-xor-inside-pipe-then-newline-then-function/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-bitwise-xor-inside-pipe-then-newline-then-function/input.js new file mode 100644 index 000000000000..a8f2d578f2df --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-bitwise-xor-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-caret-proposal-bitwise-xor-inside-pipe-then-newline-then-function/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-bitwise-xor-inside-pipe-then-newline-then-function/options.json new file mode 100644 index 000000000000..ae9c48b29706 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-bitwise-xor-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-caret-proposal-bitwise-xor-inside-pipe-then-newline-then-function/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-bitwise-xor-inside-pipe-then-newline-then-function/output.json new file mode 100644 index 000000000000..a2a036276d6b --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-bitwise-xor-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-caret-proposal-bitwise-xor-outside-pipe-then-newline-then-function/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-bitwise-xor-outside-pipe-then-newline-then-function/input.js new file mode 100644 index 000000000000..c78a077c6a36 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-bitwise-xor-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-caret-proposal-bitwise-xor-outside-pipe-then-newline-then-function/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-bitwise-xor-outside-pipe-then-newline-then-function/options.json new file mode 100644 index 000000000000..ae9c48b29706 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-bitwise-xor-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-caret-proposal-bitwise-xor-outside-pipe-then-newline-then-function/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-bitwise-xor-outside-pipe-then-newline-then-function/output.json new file mode 100644 index 000000000000..4d498cec2671 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-bitwise-xor-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-caret-proposal-bitwise-xor-regex-outside-pipe/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-bitwise-xor-regex-outside-pipe/input.js new file mode 100644 index 000000000000..036d7337789d --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-bitwise-xor-regex-outside-pipe/input.js @@ -0,0 +1 @@ +5 ^ /3/g; diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-bitwise-xor-regex-outside-pipe/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-bitwise-xor-regex-outside-pipe/options.json new file mode 100644 index 000000000000..ae9c48b29706 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-bitwise-xor-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-caret-proposal-bitwise-xor-regex-outside-pipe/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-bitwise-xor-regex-outside-pipe/output.json new file mode 100644 index 000000000000..e2fb7b8dd7e3 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-bitwise-xor-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-caret-proposal-bitwise-xor-topic-first-with-spaces/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-bitwise-xor-topic-first-with-spaces/input.js new file mode 100644 index 000000000000..447cd8450ab1 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-bitwise-xor-topic-first-with-spaces/input.js @@ -0,0 +1 @@ +value |> ^ ^ 2; diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-bitwise-xor-topic-first-with-spaces/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-bitwise-xor-topic-first-with-spaces/options.json new file mode 100644 index 000000000000..ae9c48b29706 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-bitwise-xor-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-caret-proposal-bitwise-xor-topic-first-with-spaces/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-bitwise-xor-topic-first-with-spaces/output.json new file mode 100644 index 000000000000..b0d2d6895330 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-bitwise-xor-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-caret-proposal-bitwise-xor-topic-first-without-spaces/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-bitwise-xor-topic-first-without-spaces/input.js new file mode 100644 index 000000000000..94d104f93843 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-bitwise-xor-topic-first-without-spaces/input.js @@ -0,0 +1 @@ +value |> ^^2; diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-bitwise-xor-topic-first-without-spaces/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-bitwise-xor-topic-first-without-spaces/options.json new file mode 100644 index 000000000000..ae9c48b29706 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-bitwise-xor-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-caret-proposal-bitwise-xor-topic-first-without-spaces/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-bitwise-xor-topic-first-without-spaces/output.json new file mode 100644 index 000000000000..be5a1ae193fd --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-bitwise-xor-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-caret-proposal-bitwise-xor-topic-last-with-spaces/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-bitwise-xor-topic-last-with-spaces/input.js new file mode 100644 index 000000000000..45aff06c964f --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-bitwise-xor-topic-last-with-spaces/input.js @@ -0,0 +1 @@ +value |> 2 ^ ^; diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-bitwise-xor-topic-last-with-spaces/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-bitwise-xor-topic-last-with-spaces/options.json new file mode 100644 index 000000000000..ae9c48b29706 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-bitwise-xor-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-caret-proposal-bitwise-xor-topic-last-with-spaces/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-bitwise-xor-topic-last-with-spaces/output.json new file mode 100644 index 000000000000..87aef13d06c4 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-bitwise-xor-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-caret-proposal-bitwise-xor-topic-last-without-spaces/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-bitwise-xor-topic-last-without-spaces/input.js new file mode 100644 index 000000000000..3bb68f06b5e9 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-bitwise-xor-topic-last-without-spaces/input.js @@ -0,0 +1 @@ +value |> 2^^; diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-bitwise-xor-topic-last-without-spaces/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-bitwise-xor-topic-last-without-spaces/options.json new file mode 100644 index 000000000000..ae9c48b29706 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-bitwise-xor-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-caret-proposal-bitwise-xor-topic-last-without-spaces/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-bitwise-xor-topic-last-without-spaces/output.json new file mode 100644 index 000000000000..798bfd19e183 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-bitwise-xor-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-caret-proposal-class-expression-with-decorators/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-class-expression-with-decorators/input.js new file mode 100644 index 000000000000..819f9ac5990b --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-class-expression-with-decorators/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-class-expression-with-decorators/options.json new file mode 100644 index 000000000000..4a0ee54918c6 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-class-expression-with-decorators/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-class-expression-with-decorators/output.json new file mode 100644 index 000000000000..5f6fe6d44c55 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-class-expression-with-private-property/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-class-expression-with-private-property/input.js new file mode 100644 index 000000000000..8c46164c7e73 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-class-expression-with-private-property/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-class-expression-with-private-property/options.json new file mode 100644 index 000000000000..06dc513278ab --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-class-expression-with-private-property/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-class-expression-with-private-property/output.json new file mode 100644 index 000000000000..f6c7e7a65d81 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-class-expression-without-private-property/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-class-expression-without-private-property/input.js new file mode 100644 index 000000000000..e46a26f12131 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-class-expression-without-private-property/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-class-expression-without-private-property/options.json new file mode 100644 index 000000000000..ae9c48b29706 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-class-expression-without-private-property/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-class-expression-without-private-property/output.json new file mode 100644 index 000000000000..201caee15156 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-comma-topic-pair/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-comma-topic-pair/input.js new file mode 100644 index 000000000000..c2c7e966c2e3 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-comma-topic-pair/input.js @@ -0,0 +1 @@ +10 |> (^, ^); diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-comma-topic-pair/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-comma-topic-pair/options.json new file mode 100644 index 000000000000..ae9c48b29706 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-comma-topic-pair/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-comma-topic-pair/output.json new file mode 100644 index 000000000000..12c0cb49edb8 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-computed-no-topic/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-computed-no-topic/input.js new file mode 100644 index 000000000000..5a02dee8ec60 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-computed-no-topic/input.js @@ -0,0 +1 @@ +value |> a[b] diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-computed-no-topic/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-computed-no-topic/options.json new file mode 100644 index 000000000000..ae9c48b29706 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-computed-no-topic/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-computed-no-topic/output.json new file mode 100644 index 000000000000..3959a09863b0 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-division/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-division/input.js new file mode 100644 index 000000000000..42e05558d9d1 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-division/input.js @@ -0,0 +1 @@ +value |> ^ / 2 diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-division/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-division/options.json new file mode 100644 index 000000000000..ae9c48b29706 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-division/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-division/output.json new file mode 100644 index 000000000000..0c5a673e7b83 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-do-transform-do-while-loop-and-topic-in-loop-body/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-do-transform-do-while-loop-and-topic-in-loop-body/input.js new file mode 100644 index 000000000000..7230431f15f1 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-do-transform-do-while-loop-and-topic-in-loop-body/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-do-transform-do-while-loop-and-topic-in-loop-body/options.json new file mode 100644 index 000000000000..e60a49a3032b --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-do-transform-do-while-loop-and-topic-in-loop-body/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-do-transform-do-while-loop-and-topic-in-loop-body/output.json new file mode 100644 index 000000000000..e14ccc735fac --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-do-transform-do-while-loop-and-topic-in-loop-head/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-do-transform-do-while-loop-and-topic-in-loop-head/input.js new file mode 100644 index 000000000000..3cd5ecd6b057 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-do-transform-do-while-loop-and-topic-in-loop-head/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-do-transform-do-while-loop-and-topic-in-loop-head/options.json new file mode 100644 index 000000000000..e60a49a3032b --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-do-transform-do-while-loop-and-topic-in-loop-head/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-do-transform-do-while-loop-and-topic-in-loop-head/output.json new file mode 100644 index 000000000000..48f0ec3c67ab --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-do-transform-for-await-of-loop-and-topic-in-loop-body/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-do-transform-for-await-of-loop-and-topic-in-loop-body/input.js new file mode 100644 index 000000000000..1dcb062a7b81 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-do-transform-for-await-of-loop-and-topic-in-loop-body/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-do-transform-for-await-of-loop-and-topic-in-loop-body/options.json new file mode 100644 index 000000000000..d77cc08fb007 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-do-transform-for-await-of-loop-and-topic-in-loop-body/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-do-transform-for-await-of-loop-and-topic-in-loop-body/output.json new file mode 100644 index 000000000000..8fbe9b326ed2 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-do-transform-for-await-of-loop-and-topic-in-loop-head/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-do-transform-for-await-of-loop-and-topic-in-loop-head/input.js new file mode 100644 index 000000000000..4fd5609bebbe --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-do-transform-for-await-of-loop-and-topic-in-loop-head/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-do-transform-for-await-of-loop-and-topic-in-loop-head/options.json new file mode 100644 index 000000000000..d77cc08fb007 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-do-transform-for-await-of-loop-and-topic-in-loop-head/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-do-transform-for-await-of-loop-and-topic-in-loop-head/output.json new file mode 100644 index 000000000000..bdc716f07157 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-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-caret-proposal-do-transform-for-await-of-loop-transform-and-topic-in-loop-body/input.js new file mode 100644 index 000000000000..1dcb062a7b81 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-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-caret-proposal-do-transform-for-await-of-loop-transform-and-topic-in-loop-body/options.json new file mode 100644 index 000000000000..3ef7c31718fc --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-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-caret-proposal-do-transform-for-await-of-loop-transform-and-topic-in-loop-body/output.json new file mode 100644 index 000000000000..8fbe9b326ed2 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-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-caret-proposal-do-transform-for-await-of-loop-transform-and-topic-in-loop-head/input.js new file mode 100644 index 000000000000..4fd5609bebbe --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-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-caret-proposal-do-transform-for-await-of-loop-transform-and-topic-in-loop-head/options.json new file mode 100644 index 000000000000..3ef7c31718fc --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-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-caret-proposal-do-transform-for-await-of-loop-transform-and-topic-in-loop-head/output.json new file mode 100644 index 000000000000..bdc716f07157 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-do-transform-for-classic-loop-and-topic-in-loop-body/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-do-transform-for-classic-loop-and-topic-in-loop-body/input.js new file mode 100644 index 000000000000..9ec8fb2d0f64 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-do-transform-for-classic-loop-and-topic-in-loop-body/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-do-transform-for-classic-loop-and-topic-in-loop-body/options.json new file mode 100644 index 000000000000..e60a49a3032b --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-do-transform-for-classic-loop-and-topic-in-loop-body/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-do-transform-for-classic-loop-and-topic-in-loop-body/output.json new file mode 100644 index 000000000000..9a2cfce89805 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-do-transform-for-classic-loop-and-topic-in-loop-head/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-do-transform-for-classic-loop-and-topic-in-loop-head/input.js new file mode 100644 index 000000000000..df1f1874d239 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-do-transform-for-classic-loop-and-topic-in-loop-head/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-do-transform-for-classic-loop-and-topic-in-loop-head/options.json new file mode 100644 index 000000000000..e60a49a3032b --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-do-transform-for-classic-loop-and-topic-in-loop-head/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-do-transform-for-classic-loop-and-topic-in-loop-head/output.json new file mode 100644 index 000000000000..7df2f583e2fc --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-do-transform-for-in-loop-and-topic-in-loop-body/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-do-transform-for-in-loop-and-topic-in-loop-body/input.js new file mode 100644 index 000000000000..a1e29ab37e6a --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-do-transform-for-in-loop-and-topic-in-loop-body/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-do-transform-for-in-loop-and-topic-in-loop-body/options.json new file mode 100644 index 000000000000..e60a49a3032b --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-do-transform-for-in-loop-and-topic-in-loop-body/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-do-transform-for-in-loop-and-topic-in-loop-body/output.json new file mode 100644 index 000000000000..3c3dc20a51af --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-do-transform-for-in-loop-and-topic-in-loop-head/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-do-transform-for-in-loop-and-topic-in-loop-head/input.js new file mode 100644 index 000000000000..1825b2f2ea55 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-do-transform-for-in-loop-and-topic-in-loop-head/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-do-transform-for-in-loop-and-topic-in-loop-head/options.json new file mode 100644 index 000000000000..e60a49a3032b --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-do-transform-for-in-loop-and-topic-in-loop-head/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-do-transform-for-in-loop-and-topic-in-loop-head/output.json new file mode 100644 index 000000000000..230eafa0e7ab --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-do-transform-for-of-loop-and-topic-in-loop-body/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-do-transform-for-of-loop-and-topic-in-loop-body/input.js new file mode 100644 index 000000000000..8eccb3d034d1 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-do-transform-for-of-loop-and-topic-in-loop-body/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-do-transform-for-of-loop-and-topic-in-loop-body/options.json new file mode 100644 index 000000000000..e60a49a3032b --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-do-transform-for-of-loop-and-topic-in-loop-body/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-do-transform-for-of-loop-and-topic-in-loop-body/output.json new file mode 100644 index 000000000000..33829839a946 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-do-transform-for-of-loop-and-topic-in-loop-head/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-do-transform-for-of-loop-and-topic-in-loop-head/input.js new file mode 100644 index 000000000000..7daa4b512ead --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-do-transform-for-of-loop-and-topic-in-loop-head/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-do-transform-for-of-loop-and-topic-in-loop-head/options.json new file mode 100644 index 000000000000..e60a49a3032b --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-do-transform-for-of-loop-and-topic-in-loop-head/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-do-transform-for-of-loop-and-topic-in-loop-head/output.json new file mode 100644 index 000000000000..8edea4e4e609 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-do-transform-if-statement-and-topic-in-else-body/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-do-transform-if-statement-and-topic-in-else-body/input.js new file mode 100644 index 000000000000..b9d55e7e2550 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-do-transform-if-statement-and-topic-in-else-body/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-do-transform-if-statement-and-topic-in-else-body/options.json new file mode 100644 index 000000000000..e60a49a3032b --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-do-transform-if-statement-and-topic-in-else-body/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-do-transform-if-statement-and-topic-in-else-body/output.json new file mode 100644 index 000000000000..f1d076f6b582 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-do-transform-if-statement-and-topic-in-else-if-body/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-do-transform-if-statement-and-topic-in-else-if-body/input.js new file mode 100644 index 000000000000..92220bd1c260 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-do-transform-if-statement-and-topic-in-else-if-body/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-do-transform-if-statement-and-topic-in-else-if-body/options.json new file mode 100644 index 000000000000..e60a49a3032b --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-do-transform-if-statement-and-topic-in-else-if-body/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-do-transform-if-statement-and-topic-in-else-if-body/output.json new file mode 100644 index 000000000000..1543c9a55711 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-do-transform-if-statement-and-topic-in-if-body/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-do-transform-if-statement-and-topic-in-if-body/input.js new file mode 100644 index 000000000000..b659cafb089f --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-do-transform-if-statement-and-topic-in-if-body/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-do-transform-if-statement-and-topic-in-if-body/options.json new file mode 100644 index 000000000000..e60a49a3032b --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-do-transform-if-statement-and-topic-in-if-body/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-do-transform-if-statement-and-topic-in-if-body/output.json new file mode 100644 index 000000000000..a98abe3fb66d --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-do-transform-if-statement-and-topic-in-if-head/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-do-transform-if-statement-and-topic-in-if-head/input.js new file mode 100644 index 000000000000..00a5095947a5 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-do-transform-if-statement-and-topic-in-if-head/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-do-transform-if-statement-and-topic-in-if-head/options.json new file mode 100644 index 000000000000..e60a49a3032b --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-do-transform-if-statement-and-topic-in-if-head/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-do-transform-if-statement-and-topic-in-if-head/output.json new file mode 100644 index 000000000000..eb2faae4aef9 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-do-transform-switch-statement-and-topic-in-switch-body/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-do-transform-switch-statement-and-topic-in-switch-body/input.js new file mode 100644 index 000000000000..dff94e8bd668 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-do-transform-switch-statement-and-topic-in-switch-body/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-do-transform-switch-statement-and-topic-in-switch-body/options.json new file mode 100644 index 000000000000..e60a49a3032b --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-do-transform-switch-statement-and-topic-in-switch-body/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-do-transform-switch-statement-and-topic-in-switch-body/output.json new file mode 100644 index 000000000000..51c3d25a2e0c --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-do-transform-switch-statement-and-topic-in-switch-head/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-do-transform-switch-statement-and-topic-in-switch-head/input.js new file mode 100644 index 000000000000..18458d9bfefd --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-do-transform-switch-statement-and-topic-in-switch-head/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-do-transform-switch-statement-and-topic-in-switch-head/options.json new file mode 100644 index 000000000000..e60a49a3032b --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-do-transform-switch-statement-and-topic-in-switch-head/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-do-transform-switch-statement-and-topic-in-switch-head/output.json new file mode 100644 index 000000000000..769f6ecb5703 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-do-transform-topic-identity/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-do-transform-topic-identity/input.js new file mode 100644 index 000000000000..6cf4787adfe5 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-do-transform-topic-identity/input.js @@ -0,0 +1 @@ +value |> do { ^; } diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-do-transform-topic-identity/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-do-transform-topic-identity/options.json new file mode 100644 index 000000000000..e60a49a3032b --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-do-transform-topic-identity/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-do-transform-topic-identity/output.json new file mode 100644 index 000000000000..46172d09d0ca --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-do-transform-try-catch-finally-statements-and-topic-in-catch-clause/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-do-transform-try-catch-finally-statements-and-topic-in-catch-clause/input.js new file mode 100644 index 000000000000..eccf8c8601f3 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-do-transform-try-catch-finally-statements-and-topic-in-catch-clause/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-do-transform-try-catch-finally-statements-and-topic-in-catch-clause/options.json new file mode 100644 index 000000000000..e60a49a3032b --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-do-transform-try-catch-finally-statements-and-topic-in-catch-clause/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-do-transform-try-catch-finally-statements-and-topic-in-catch-clause/output.json new file mode 100644 index 000000000000..e9be28defeb2 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-do-transform-try-catch-finally-statements-and-topic-in-finally-clause/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-do-transform-try-catch-finally-statements-and-topic-in-finally-clause/input.js new file mode 100644 index 000000000000..6e305d0e3fe4 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-do-transform-try-catch-finally-statements-and-topic-in-finally-clause/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-do-transform-try-catch-finally-statements-and-topic-in-finally-clause/options.json new file mode 100644 index 000000000000..e60a49a3032b --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-do-transform-try-catch-finally-statements-and-topic-in-finally-clause/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-do-transform-try-catch-finally-statements-and-topic-in-finally-clause/output.json new file mode 100644 index 000000000000..da5098b0f274 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-do-transform-try-catch-finally-statements-and-topic-in-try-clause/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-do-transform-try-catch-finally-statements-and-topic-in-try-clause/input.js new file mode 100644 index 000000000000..cf548b04df97 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-do-transform-try-catch-finally-statements-and-topic-in-try-clause/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-do-transform-try-catch-finally-statements-and-topic-in-try-clause/options.json new file mode 100644 index 000000000000..e60a49a3032b --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-do-transform-try-catch-finally-statements-and-topic-in-try-clause/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-do-transform-try-catch-finally-statements-and-topic-in-try-clause/output.json new file mode 100644 index 000000000000..06e9624daa1f --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-do-transform-try-catch-statements-topic-in-try-clause/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-do-transform-try-catch-statements-topic-in-try-clause/input.js new file mode 100644 index 000000000000..2c5f676874a7 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-do-transform-try-catch-statements-topic-in-try-clause/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-do-transform-try-catch-statements-topic-in-try-clause/options.json new file mode 100644 index 000000000000..e60a49a3032b --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-do-transform-try-catch-statements-topic-in-try-clause/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-do-transform-try-catch-statements-topic-in-try-clause/output.json new file mode 100644 index 000000000000..7ce5dce3c2a1 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-do-transform-while-loop-topic-in-loop-body/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-do-transform-while-loop-topic-in-loop-body/input.js new file mode 100644 index 000000000000..7ae16ca1f837 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-do-transform-while-loop-topic-in-loop-body/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-do-transform-while-loop-topic-in-loop-body/options.json new file mode 100644 index 000000000000..e60a49a3032b --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-do-transform-while-loop-topic-in-loop-body/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-do-transform-while-loop-topic-in-loop-body/output.json new file mode 100644 index 000000000000..39d0d923a86e --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-do-transform-while-loop-topic-in-loop-head/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-do-transform-while-loop-topic-in-loop-head/input.js new file mode 100644 index 000000000000..c8ff1c3e8a8f --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-do-transform-while-loop-topic-in-loop-head/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-do-transform-while-loop-topic-in-loop-head/options.json new file mode 100644 index 000000000000..e60a49a3032b --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-do-transform-while-loop-topic-in-loop-head/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-do-transform-while-loop-topic-in-loop-head/output.json new file mode 100644 index 000000000000..56f5af6523c1 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-do-transform-with-block-topic-in-body/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-do-transform-with-block-topic-in-body/input.js new file mode 100644 index 000000000000..56714a530d27 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-do-transform-with-block-topic-in-body/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-do-transform-with-block-topic-in-body/options.json new file mode 100644 index 000000000000..e60a49a3032b --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-do-transform-with-block-topic-in-body/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-do-transform-with-block-topic-in-body/output.json new file mode 100644 index 000000000000..9c21b42532c9 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-equality-loose-with-topic-first-without-spaces/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-equality-loose-with-topic-first-without-spaces/input.js new file mode 100644 index 000000000000..fa41c400fb2c --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-equality-loose-with-topic-first-without-spaces/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-equality-loose-with-topic-first-without-spaces/options.json new file mode 100644 index 000000000000..ae9c48b29706 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-equality-loose-with-topic-first-without-spaces/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-equality-loose-with-topic-first-without-spaces/output.json new file mode 100644 index 000000000000..7ade0b76cff5 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-equality-strict-with-topic-first-without-spaces/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-equality-strict-with-topic-first-without-spaces/input.js new file mode 100644 index 000000000000..59803bc2b79f --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-equality-strict-with-topic-first-without-spaces/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-equality-strict-with-topic-first-without-spaces/options.json new file mode 100644 index 000000000000..ae9c48b29706 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-equality-strict-with-topic-first-without-spaces/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-equality-strict-with-topic-first-without-spaces/output.json new file mode 100644 index 000000000000..229fcca78336 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-function-call-with-topic-in-argument/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-function-call-with-topic-in-argument/input.js new file mode 100644 index 000000000000..76c07b7405ba --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-function-call-with-topic-in-argument/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-function-call-with-topic-in-argument/options.json new file mode 100644 index 000000000000..ae9c48b29706 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-function-call-with-topic-in-argument/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-function-call-with-topic-in-argument/output.json new file mode 100644 index 000000000000..81ae12185c6c --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-function-call-without-topic/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-function-call-without-topic/input.js new file mode 100644 index 000000000000..15a3d7657b9c --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-function-call-without-topic/input.js @@ -0,0 +1 @@ +value |> f diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-function-call-without-topic/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-function-call-without-topic/options.json new file mode 100644 index 000000000000..ae9c48b29706 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-function-call-without-topic/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-function-call-without-topic/output.json new file mode 100644 index 000000000000..3917568d724f --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-function-definition-with-another-pipe-in-function-body/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-function-definition-with-another-pipe-in-function-body/input.js new file mode 100644 index 000000000000..2720a7aa6d2e --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-function-definition-with-another-pipe-in-function-body/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-function-definition-with-another-pipe-in-function-body/options.json new file mode 100644 index 000000000000..ae9c48b29706 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-function-definition-with-another-pipe-in-function-body/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-function-definition-with-another-pipe-in-function-body/output.json new file mode 100644 index 000000000000..78c6b8cd0a9b --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-function-definition-with-topic-in-default-parameter/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-function-definition-with-topic-in-default-parameter/input.js new file mode 100644 index 000000000000..e04cf990cc33 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-function-definition-with-topic-in-default-parameter/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-function-definition-with-topic-in-default-parameter/options.json new file mode 100644 index 000000000000..ae9c48b29706 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-function-definition-with-topic-in-default-parameter/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-function-definition-with-topic-in-default-parameter/output.json new file mode 100644 index 000000000000..3895abf6bf98 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-function-definition-with-topic-in-function-body/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-function-definition-with-topic-in-function-body/input.js new file mode 100644 index 000000000000..55c2c967f430 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-function-definition-with-topic-in-function-body/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-function-definition-with-topic-in-function-body/options.json new file mode 100644 index 000000000000..ae9c48b29706 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-function-definition-with-topic-in-function-body/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-function-definition-with-topic-in-function-body/output.json new file mode 100644 index 000000000000..8dc59aef9a13 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-hash-topic/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-hash-topic/input.js new file mode 100644 index 000000000000..a18cbd0f1bb2 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-hash-topic/input.js @@ -0,0 +1 @@ +value |> # diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-hash-topic/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-hash-topic/options.json new file mode 100644 index 000000000000..937e5c799ea4 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-hash-tuple/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-hash-tuple/input.js new file mode 100644 index 000000000000..c9cafc96318d --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-hash-tuple/input.js @@ -0,0 +1,2 @@ +#[0]; +1 |> #[0, ^]; diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-hash-tuple/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-hash-tuple/options.json new file mode 100644 index 000000000000..e36d4a74acbc --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-hash-tuple/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-hash-tuple/output.json new file mode 100644 index 000000000000..cb9f00888851 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-mixed-pipeline-plugins/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-mixed-pipeline-plugins/input.js new file mode 100644 index 000000000000..3e255cba749b --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-mixed-pipeline-plugins/input.js @@ -0,0 +1 @@ +value |> ^ diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-mixed-pipeline-plugins/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-mixed-pipeline-plugins/options.json new file mode 100644 index 000000000000..eda8b7e5a987 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-mixed-pipeline-plugins/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-mixed-pipeline-plugins/output.json new file mode 100644 index 000000000000..26d454dbfd87 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-nested-pipelines-with-arrow-function-with-required-topics/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-nested-pipelines-with-arrow-function-with-required-topics/input.js new file mode 100644 index 000000000000..4449313fde27 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-nested-pipelines-with-arrow-function-with-required-topics/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-nested-pipelines-with-arrow-function-with-required-topics/options.json new file mode 100644 index 000000000000..ae9c48b29706 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-nested-pipelines-with-arrow-function-with-required-topics/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-nested-pipelines-with-arrow-function-with-required-topics/output.json new file mode 100644 index 000000000000..ab141137b42f --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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}}, + "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": "TopicReference", + "start":11,"end":12,"loc":{"start":{"line":1,"column":11},"end":{"line":1,"column":12}} + }, + "operator": "|>", + "right": { + "type": "BinaryExpression", + "start":16,"end":32,"loc":{"start":{"line":1,"column":16},"end":{"line":1,"column":32}}, + "left": { + "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 + } + } + } + }, + "extra": { + "parenthesized": true, + "parenStart": 5 + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-nested-pipelines-with-arrow-function-without-inner-topic/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-nested-pipelines-with-arrow-function-without-inner-topic/input.js new file mode 100644 index 000000000000..9a79c58c2f21 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-nested-pipelines-with-arrow-function-without-inner-topic/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-nested-pipelines-with-arrow-function-without-inner-topic/options.json new file mode 100644 index 000000000000..ae9c48b29706 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-nested-pipelines-with-arrow-function-without-inner-topic/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-nested-pipelines-with-arrow-function-without-inner-topic/output.json new file mode 100644 index 000000000000..e04f68fe79b1 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-nested-pipelines-with-arrow-function-without-outer-topic/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-nested-pipelines-with-arrow-function-without-outer-topic/input.js new file mode 100644 index 000000000000..3613703048f3 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-nested-pipelines-with-arrow-function-without-outer-topic/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-nested-pipelines-with-arrow-function-without-outer-topic/options.json new file mode 100644 index 000000000000..ae9c48b29706 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-nested-pipelines-with-arrow-function-without-outer-topic/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-nested-pipelines-with-arrow-function-without-outer-topic/output.json new file mode 100644 index 000000000000..9d7a5f58fb36 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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}}, + "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}} + } + }, + "extra": { + "parenthesized": true, + "parenStart": 5 + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-nested-pipelines-with-function-call/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-nested-pipelines-with-function-call/input.js new file mode 100644 index 000000000000..2b5e6aaf1382 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-nested-pipelines-with-function-call/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-nested-pipelines-with-function-call/options.json new file mode 100644 index 000000000000..ae9c48b29706 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-nested-pipelines-with-function-call/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-nested-pipelines-with-function-call/output.json new file mode 100644 index 000000000000..12c2619c004c --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-nested-pipelines-without-inner-topic/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-nested-pipelines-without-inner-topic/input.js new file mode 100644 index 000000000000..655a497ad290 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-nested-pipelines-without-inner-topic/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-nested-pipelines-without-inner-topic/options.json new file mode 100644 index 000000000000..ae9c48b29706 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-nested-pipelines-without-inner-topic/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-nested-pipelines-without-inner-topic/output.json new file mode 100644 index 000000000000..fd53f606c943 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-nested-pipelines-without-outer-topic/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-nested-pipelines-without-outer-topic/input.js new file mode 100644 index 000000000000..9d00837048ed --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-nested-pipelines-without-outer-topic/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-nested-pipelines-without-outer-topic/options.json new file mode 100644 index 000000000000..ae9c48b29706 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-nested-pipelines-without-outer-topic/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-nested-pipelines-without-outer-topic/output.json new file mode 100644 index 000000000000..cfab816d1276 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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}}, + "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" + }, + "extra": { + "parenthesized": true, + "parenStart": 5 + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-no-topic-class-expression/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-no-topic-class-expression/input.js new file mode 100644 index 000000000000..6ccb6ca13351 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-no-topic-class-expression/input.js @@ -0,0 +1 @@ +value |> class { } diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-no-topic-class-expression/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-no-topic-class-expression/options.json new file mode 100644 index 000000000000..ae9c48b29706 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-no-topic-class-expression/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-no-topic-class-expression/output.json new file mode 100644 index 000000000000..1e904fe3ddea --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-no-topic-function-expression/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-no-topic-function-expression/input.js new file mode 100644 index 000000000000..faf09879d637 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-no-topic-function-expression/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-no-topic-function-expression/options.json new file mode 100644 index 000000000000..ae9c48b29706 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-no-topic-function-expression/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-no-topic-function-expression/output.json new file mode 100644 index 000000000000..4a5325355978 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-non-generator-yield-identifier/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-non-generator-yield-identifier/input.js new file mode 100644 index 000000000000..9e41e19db543 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-non-generator-yield-identifier/input.js @@ -0,0 +1 @@ +x |> yield + ^; diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-non-generator-yield-identifier/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-non-generator-yield-identifier/options.json new file mode 100644 index 000000000000..ae9c48b29706 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-non-generator-yield-identifier/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-non-generator-yield-identifier/output.json new file mode 100644 index 000000000000..cdd141011b5e --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-private-property-in-private-method/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-private-property-in-private-method/input.js new file mode 100644 index 000000000000..72c6bda8f83d --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-private-property-in-private-method/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-private-property-in-private-method/options.json new file mode 100644 index 000000000000..06dc513278ab --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-private-property-in-private-method/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-private-property-in-private-method/output.json new file mode 100644 index 000000000000..0a1b91986a6b --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-topic-identity-parenthesized/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-topic-identity-parenthesized/input.js new file mode 100644 index 000000000000..f5f666764bbb --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-topic-identity-parenthesized/input.js @@ -0,0 +1 @@ +value |> (^) diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-topic-identity-parenthesized/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-topic-identity-parenthesized/options.json new file mode 100644 index 000000000000..ae9c48b29706 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-topic-identity-parenthesized/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-topic-identity-parenthesized/output.json new file mode 100644 index 000000000000..90324568fe54 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-topic-identity-unparenthesized/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-topic-identity-unparenthesized/input.js new file mode 100644 index 000000000000..3e255cba749b --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-topic-identity-unparenthesized/input.js @@ -0,0 +1 @@ +value |> ^ diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-topic-identity-unparenthesized/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-topic-identity-unparenthesized/options.json new file mode 100644 index 000000000000..ae9c48b29706 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-topic-identity-unparenthesized/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-topic-identity-unparenthesized/output.json new file mode 100644 index 000000000000..26d454dbfd87 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-topic-then-digit/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-topic-then-digit/input.js new file mode 100644 index 000000000000..4d67615b5703 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-topic-then-digit/input.js @@ -0,0 +1 @@ +x |> ^42; diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-topic-then-digit/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-topic-then-digit/options.json new file mode 100644 index 000000000000..7620f98fe61a --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-topic-then-digit/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-topic-then-digit/output.json new file mode 100644 index 000000000000..5326190e1700 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-topic-with-optional-method-call/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-topic-with-optional-method-call/input.js new file mode 100644 index 000000000000..d2f00e9b215f --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-topic-with-optional-method-call/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-topic-with-optional-method-call/options.json new file mode 100644 index 000000000000..ae9c48b29706 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-topic-with-optional-method-call/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-topic-with-optional-method-call/output.json new file mode 100644 index 000000000000..cfe7f18f7295 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-unbound-topic/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-unbound-topic/input.js new file mode 100644 index 000000000000..e532989d3f65 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-unbound-topic/input.js @@ -0,0 +1 @@ +1 + ^ diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-unbound-topic/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-unbound-topic/options.json new file mode 100644 index 000000000000..ae9c48b29706 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-unbound-topic/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-unbound-topic/output.json new file mode 100644 index 000000000000..9b2253f1b116 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-v8intrinsic/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-v8intrinsic/input.js new file mode 100644 index 000000000000..89fbe805c659 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-v8intrinsic/input.js @@ -0,0 +1 @@ +^GetOptimizationStatus(f); diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-v8intrinsic/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-v8intrinsic/options.json new file mode 100644 index 000000000000..1e044fd99050 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-within-assignment-bitwise-xor-with-spaces/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-within-assignment-bitwise-xor-with-spaces/input.js new file mode 100644 index 000000000000..2b16ad67f6d7 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-within-assignment-bitwise-xor-with-spaces/input.js @@ -0,0 +1 @@ +variable ^= value |> ^; diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-within-assignment-bitwise-xor-with-spaces/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-within-assignment-bitwise-xor-with-spaces/options.json new file mode 100644 index 000000000000..ae9c48b29706 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-within-assignment-bitwise-xor-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-caret-proposal-within-assignment-bitwise-xor-with-spaces/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-within-assignment-bitwise-xor-with-spaces/output.json new file mode 100644 index 000000000000..99c899615fee --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-within-assignment-bitwise-xor-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-caret-proposal-within-assignment-bitwise-xor-without-spaces/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-within-assignment-bitwise-xor-without-spaces/input.js new file mode 100644 index 000000000000..e5d13445358e --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-within-assignment-bitwise-xor-without-spaces/input.js @@ -0,0 +1 @@ +variable^=value |> ^; diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-within-assignment-bitwise-xor-without-spaces/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-within-assignment-bitwise-xor-without-spaces/options.json new file mode 100644 index 000000000000..ae9c48b29706 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-within-assignment-bitwise-xor-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-caret-proposal-within-assignment-bitwise-xor-without-spaces/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-within-assignment-bitwise-xor-without-spaces/output.json new file mode 100644 index 000000000000..6b2d7e59abdb --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-within-assignment-bitwise-xor-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-caret-proposal-within-assignment/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-within-assignment/input.js new file mode 100644 index 000000000000..7fa5ed10dbb7 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-within-assignment/input.js @@ -0,0 +1 @@ +x = 0 |> ^; diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-within-assignment/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-within-assignment/options.json new file mode 100644 index 000000000000..ae9c48b29706 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-within-assignment/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-within-assignment/output.json new file mode 100644 index 000000000000..b6929c77f6bc --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-within-classic-for-statement-init/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-within-classic-for-statement-init/input.js new file mode 100644 index 000000000000..f7dff61629d4 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-within-classic-for-statement-init/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-within-classic-for-statement-init/options.json new file mode 100644 index 000000000000..ae9c48b29706 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-within-classic-for-statement-init/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-within-classic-for-statement-init/output.json new file mode 100644 index 000000000000..a00ebbb4ba22 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-within-variable-declaration/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-within-variable-declaration/input.js new file mode 100644 index 000000000000..437a413a1e8f --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-within-variable-declaration/input.js @@ -0,0 +1 @@ +const x = 0 |> ^; diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-within-variable-declaration/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-within-variable-declaration/options.json new file mode 100644 index 000000000000..ae9c48b29706 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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-caret-proposal-within-variable-declaration/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-within-variable-declaration/output.json new file mode 100644 index 000000000000..a1e01654c880 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-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/hack-caret-proposal-yield-generator-parenthesized/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-yield-generator-parenthesized/input.js new file mode 100644 index 000000000000..fd2971c4e684 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-yield-generator-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-caret-proposal-yield-generator-parenthesized/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-yield-generator-parenthesized/options.json new file mode 100644 index 000000000000..ae9c48b29706 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-yield-generator-parenthesized/options.json @@ -0,0 +1,3 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "hack", "topicToken": "^" }]] +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-yield-generator-parenthesized/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-yield-generator-parenthesized/output.json new file mode 100644 index 000000000000..e9e11c6eef44 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-yield-generator-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-caret-proposal-yield-generator-unparenthesized/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-yield-generator-unparenthesized/input.js new file mode 100644 index 000000000000..f225faf37e4a --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-yield-generator-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-caret-proposal-yield-generator-unparenthesized/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-yield-generator-unparenthesized/options.json new file mode 100644 index 000000000000..996491c1f81c --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-yield-generator-unparenthesized/options.json @@ -0,0 +1,11 @@ +{ + "plugins": [ + [ + "pipelineOperator", + { + "proposal": "hack", + "topicToken": "^" + } + ] + ] +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-yield-generator-unparenthesized/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-yield-generator-unparenthesized/output.json new file mode 100644 index 000000000000..3bcb52365757 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-yield-generator-unparenthesized/output.json @@ -0,0 +1,64 @@ +{ + "type": "File", + "start":0,"end":43,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}}, + "errors": [ + "SyntaxError: Hack-style pipe body cannot be an unparenthesized yield expression; please wrap it in parentheses. (2:14)" + ], + "program": { + "type": "Program", + "start":0,"end":43,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}}, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start":0,"end":43,"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":43,"loc":{"start":{"line":1,"column":17},"end":{"line":3,"column":1}}, + "body": [ + { + "type": "ReturnStatement", + "start":21,"end":41,"loc":{"start":{"line":2,"column":2},"end":{"line":2,"column":22}}, + "argument": { + "type": "BinaryExpression", + "start":28,"end":40,"loc":{"start":{"line":2,"column":9},"end":{"line":2,"column":21}}, + "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":33,"end":40,"loc":{"start":{"line":2,"column":14},"end":{"line":2,"column":21}}, + "delegate": false, + "argument": { + "type": "TopicReference", + "start":39,"end":40,"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-caret-proposal-yield-identifier-unparenthesized/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-yield-identifier-unparenthesized/input.js new file mode 100644 index 000000000000..9e41e19db543 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-yield-identifier-unparenthesized/input.js @@ -0,0 +1 @@ +x |> yield + ^; diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-yield-identifier-unparenthesized/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-yield-identifier-unparenthesized/options.json new file mode 100644 index 000000000000..7620f98fe61a --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-yield-identifier-unparenthesized/options.json @@ -0,0 +1,11 @@ +{ + "plugins": [ + [ + "pipelineOperator", + { + "proposal": "hack", + "topicToken": "^" + } + ] + ] +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-yield-identifier-unparenthesized/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-yield-identifier-unparenthesized/output.json new file mode 100644 index 000000000000..cdd141011b5e --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-yield-identifier-unparenthesized/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-hash-proposal-assignment-logical-and/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-assignment-logical-and/input.js index d204179f2f4d..29e790c825e5 100644 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-assignment-logical-and/input.js +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-assignment-logical-and/input.js @@ -1 +1 @@ -value |> x &&= # +value |> (x &&= #) diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-assignment-logical-and/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-assignment-logical-and/output.json index 41d7cc567fe5..3c15e48a4789 100644 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-assignment-logical-and/output.json +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-assignment-logical-and/output.json @@ -1,21 +1,18 @@ { "type": "File", - "start":0,"end":16,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":16}}, - "errors": [ - "SyntaxError: Hack-style pipe body cannot be an unparenthesized assignment expression; please wrap it in parentheses. (1:9)" - ], + "start":0,"end":18,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":18}}, "program": { "type": "Program", - "start":0,"end":16,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":16}}, + "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":16,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":16}}, + "start":0,"end":18,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":18}}, "expression": { "type": "BinaryExpression", - "start":0,"end":16,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":16}}, + "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"}, @@ -24,16 +21,20 @@ "operator": "|>", "right": { "type": "AssignmentExpression", - "start":9,"end":16,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":16}}, + "start":10,"end":17,"loc":{"start":{"line":1,"column":10},"end":{"line":1,"column":17}}, "operator": "&&=", "left": { "type": "Identifier", - "start":9,"end":10,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":10},"identifierName":"x"}, + "start":10,"end":11,"loc":{"start":{"line":1,"column":10},"end":{"line":1,"column":11},"identifierName":"x"}, "name": "x" }, "right": { "type": "TopicReference", - "start":15,"end":16,"loc":{"start":{"line":1,"column":15},"end":{"line":1,"column":16}} + "start":16,"end":17,"loc":{"start":{"line":1,"column":16},"end":{"line":1,"column":17}} + }, + "extra": { + "parenthesized": true, + "parenStart": 9 } } } diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-assignment-modulo/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-assignment-modulo/input.js new file mode 100644 index 000000000000..87a0b9689b97 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-assignment-modulo/input.js @@ -0,0 +1 @@ +value |> (v %= #) diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-assignment-modulo/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-assignment-modulo/options.json new file mode 100644 index 000000000000..be2b04c70d33 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-assignment-modulo/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-modulo/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-assignment-modulo/output.json new file mode 100644 index 000000000000..d496b360488f --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-assignment-modulo/output.json @@ -0,0 +1,45 @@ +{ + "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": "ExpressionStatement", + "start":0,"end":17,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":17}}, + "expression": { + "type": "BinaryExpression", + "start":0,"end":17,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":17}}, + "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":16,"loc":{"start":{"line":1,"column":10},"end":{"line":1,"column":16}}, + "operator": "%=", + "left": { + "type": "Identifier", + "start":10,"end":11,"loc":{"start":{"line":1,"column":10},"end":{"line":1,"column":11},"identifierName":"v"}, + "name": "v" + }, + "right": { + "type": "TopicReference", + "start":15,"end":16,"loc":{"start":{"line":1,"column":15},"end":{"line":1,"column":16}} + }, + "extra": { + "parenthesized": true, + "parenStart": 9 + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-assignment-normal/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-assignment-normal/input.js index 29d31a070454..1e5ae4e883f8 100644 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-assignment-normal/input.js +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-assignment-normal/input.js @@ -1 +1 @@ -value |> [x, y] = # +value |> ([x, y] = #) diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-assignment-normal/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-assignment-normal/output.json index 2d377919e7b2..0fcd28072cc8 100644 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-assignment-normal/output.json +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-assignment-normal/output.json @@ -1,21 +1,18 @@ { "type": "File", - "start":0,"end":19,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":19}}, - "errors": [ - "SyntaxError: Hack-style pipe body cannot be an unparenthesized assignment expression; please wrap it in parentheses. (1:9)" - ], + "start":0,"end":21,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":21}}, "program": { "type": "Program", - "start":0,"end":19,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":19}}, + "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":19,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":19}}, + "start":0,"end":21,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":21}}, "expression": { "type": "BinaryExpression", - "start":0,"end":19,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":19}}, + "start":0,"end":21,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":21}}, "left": { "type": "Identifier", "start":0,"end":5,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":5},"identifierName":"value"}, @@ -24,27 +21,31 @@ "operator": "|>", "right": { "type": "AssignmentExpression", - "start":9,"end":19,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":19}}, + "start":10,"end":20,"loc":{"start":{"line":1,"column":10},"end":{"line":1,"column":20}}, "operator": "=", "left": { "type": "ArrayPattern", - "start":9,"end":15,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":15}}, + "start":10,"end":16,"loc":{"start":{"line":1,"column":10},"end":{"line":1,"column":16}}, "elements": [ { "type": "Identifier", - "start":10,"end":11,"loc":{"start":{"line":1,"column":10},"end":{"line":1,"column":11},"identifierName":"x"}, + "start":11,"end":12,"loc":{"start":{"line":1,"column":11},"end":{"line":1,"column":12},"identifierName":"x"}, "name": "x" }, { "type": "Identifier", - "start":13,"end":14,"loc":{"start":{"line":1,"column":13},"end":{"line":1,"column":14},"identifierName":"y"}, + "start":14,"end":15,"loc":{"start":{"line":1,"column":14},"end":{"line":1,"column":15},"identifierName":"y"}, "name": "y" } ] }, "right": { "type": "TopicReference", - "start":18,"end":19,"loc":{"start":{"line":1,"column":18},"end":{"line":1,"column":19}} + "start":19,"end":20,"loc":{"start":{"line":1,"column":19},"end":{"line":1,"column":20}} + }, + "extra": { + "parenthesized": true, + "parenStart": 9 } } } diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-assignment-plus/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-assignment-plus/input.js index c440a3031a8e..c8bf29a7878e 100644 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-assignment-plus/input.js +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-assignment-plus/input.js @@ -1 +1 @@ -value |> x += # +value |> (x += #) diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-assignment-plus/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-assignment-plus/output.json index daf345f63a28..7286fc1ca3c6 100644 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-assignment-plus/output.json +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-assignment-plus/output.json @@ -1,21 +1,18 @@ { "type": "File", - "start":0,"end":15,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":15}}, - "errors": [ - "SyntaxError: Hack-style pipe body cannot be an unparenthesized assignment expression; please wrap it in parentheses. (1:9)" - ], + "start":0,"end":17,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":17}}, "program": { "type": "Program", - "start":0,"end":15,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":15}}, + "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":15,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":15}}, + "start":0,"end":17,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":17}}, "expression": { "type": "BinaryExpression", - "start":0,"end":15,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":15}}, + "start":0,"end":17,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":17}}, "left": { "type": "Identifier", "start":0,"end":5,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":5},"identifierName":"value"}, @@ -24,16 +21,20 @@ "operator": "|>", "right": { "type": "AssignmentExpression", - "start":9,"end":15,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":15}}, + "start":10,"end":16,"loc":{"start":{"line":1,"column":10},"end":{"line":1,"column":16}}, "operator": "+=", "left": { "type": "Identifier", - "start":9,"end":10,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":10},"identifierName":"x"}, + "start":10,"end":11,"loc":{"start":{"line":1,"column":10},"end":{"line":1,"column":11},"identifierName":"x"}, "name": "x" }, "right": { "type": "TopicReference", - "start":14,"end":15,"loc":{"start":{"line":1,"column":14},"end":{"line":1,"column":15}} + "start":15,"end":16,"loc":{"start":{"line":1,"column":15},"end":{"line":1,"column":16}} + }, + "extra": { + "parenthesized": true, + "parenStart": 9 } } } diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-assignment-unparenthesized/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-assignment-unparenthesized/input.js new file mode 100644 index 000000000000..29d31a070454 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-assignment-unparenthesized/input.js @@ -0,0 +1 @@ +value |> [x, y] = # diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-assignment-unparenthesized/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-assignment-unparenthesized/options.json new file mode 100644 index 000000000000..5d133a4e1801 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-assignment-unparenthesized/options.json @@ -0,0 +1,11 @@ +{ + "plugins": [ + [ + "pipelineOperator", + { + "proposal": "hack", + "topicToken": "#" + } + ] + ] +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-assignment-unparenthesized/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-assignment-unparenthesized/output.json new file mode 100644 index 000000000000..2d377919e7b2 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-assignment-unparenthesized/output.json @@ -0,0 +1,55 @@ +{ + "type": "File", + "start":0,"end":19,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":19}}, + "errors": [ + "SyntaxError: Hack-style pipe body cannot be an unparenthesized assignment expression; please wrap it in parentheses. (1:9)" + ], + "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":5,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":5},"identifierName":"value"}, + "name": "value" + }, + "operator": "|>", + "right": { + "type": "AssignmentExpression", + "start":9,"end":19,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":19}}, + "operator": "=", + "left": { + "type": "ArrayPattern", + "start":9,"end":15,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":15}}, + "elements": [ + { + "type": "Identifier", + "start":10,"end":11,"loc":{"start":{"line":1,"column":10},"end":{"line":1,"column":11},"identifierName":"x"}, + "name": "x" + }, + { + "type": "Identifier", + "start":13,"end":14,"loc":{"start":{"line":1,"column":13},"end":{"line":1,"column":14},"identifierName":"y"}, + "name": "y" + } + ] + }, + "right": { + "type": "TopicReference", + "start":18,"end":19,"loc":{"start":{"line":1,"column":18},"end":{"line":1,"column":19}} + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-caret-topic-outside-of-equality/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-caret-topic-outside-of-equality/input.js new file mode 100644 index 000000000000..3e255cba749b --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-caret-topic-outside-of-equality/input.js @@ -0,0 +1 @@ +value |> ^ diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-caret-topic-outside-of-equality/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-caret-topic-outside-of-equality/options.json new file mode 100644 index 000000000000..612aad486f2a --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-caret-topic-outside-of-equality/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-caret-topic-then-equality/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-caret-topic-then-equality/input.js new file mode 100644 index 000000000000..fa41c400fb2c --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-caret-topic-then-equality/input.js @@ -0,0 +1 @@ +value |> ^==1 diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-caret-topic-then-equality/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-caret-topic-then-equality/options.json new file mode 100644 index 000000000000..612aad486f2a --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-caret-topic-then-equality/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-percent-topic/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-percent-topic-outside-of-equality/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-percent-topic/input.js rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-percent-topic-outside-of-equality/input.js 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-outside-of-equality/options.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-percent-topic/options.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-percent-topic-outside-of-equality/options.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-percent-topic-then-equality/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-percent-topic-then-equality/input.js new file mode 100644 index 000000000000..ba8145cdfb74 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-percent-topic-then-equality/input.js @@ -0,0 +1 @@ +value |> %==1 diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-percent-topic-then-equality/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-percent-topic-then-equality/options.json new file mode 100644 index 000000000000..2b8981cde576 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-percent-topic-then-equality/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-assignment-bitwise-xor-with-spaces/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-assignment-bitwise-xor-with-spaces/input.js new file mode 100644 index 000000000000..993cdbcfc41a --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-assignment-bitwise-xor-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-assignment-bitwise-xor-with-spaces/options.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-modulo-assignment-with-spaces/options.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-assignment-bitwise-xor-with-spaces/options.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-assignment-bitwise-xor-with-spaces/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-assignment-bitwise-xor-with-spaces/output.json new file mode 100644 index 000000000000..124c70876804 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-assignment-bitwise-xor-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}}, + "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}} + }, + "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-assignment-bitwise-xor-without-spaces/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-assignment-bitwise-xor-without-spaces/input.js new file mode 100644 index 000000000000..7a0ddfbb566b --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-assignment-bitwise-xor-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-assignment-bitwise-xor-without-spaces/options.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-modulo-assignment-without-spaces/options.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-assignment-bitwise-xor-without-spaces/options.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-assignment-bitwise-xor-without-spaces/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-assignment-bitwise-xor-without-spaces/output.json new file mode 100644 index 000000000000..7211694b601d --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-assignment-bitwise-xor-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}}, + "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}} + }, + "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-assignment-logical-and/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-assignment-logical-and/input.js index 6eed41b3b19f..2449170d1b2a 100644 --- 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 @@ -1 +1 @@ -value |> x &&= % +value |> (x &&= %) diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-assignment-logical-and/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-assignment-logical-and/output.json index 41d7cc567fe5..3c15e48a4789 100644 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-assignment-logical-and/output.json +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-assignment-logical-and/output.json @@ -1,21 +1,18 @@ { "type": "File", - "start":0,"end":16,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":16}}, - "errors": [ - "SyntaxError: Hack-style pipe body cannot be an unparenthesized assignment expression; please wrap it in parentheses. (1:9)" - ], + "start":0,"end":18,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":18}}, "program": { "type": "Program", - "start":0,"end":16,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":16}}, + "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":16,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":16}}, + "start":0,"end":18,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":18}}, "expression": { "type": "BinaryExpression", - "start":0,"end":16,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":16}}, + "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"}, @@ -24,16 +21,20 @@ "operator": "|>", "right": { "type": "AssignmentExpression", - "start":9,"end":16,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":16}}, + "start":10,"end":17,"loc":{"start":{"line":1,"column":10},"end":{"line":1,"column":17}}, "operator": "&&=", "left": { "type": "Identifier", - "start":9,"end":10,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":10},"identifierName":"x"}, + "start":10,"end":11,"loc":{"start":{"line":1,"column":10},"end":{"line":1,"column":11},"identifierName":"x"}, "name": "x" }, "right": { "type": "TopicReference", - "start":15,"end":16,"loc":{"start":{"line":1,"column":15},"end":{"line":1,"column":16}} + "start":16,"end":17,"loc":{"start":{"line":1,"column":16},"end":{"line":1,"column":17}} + }, + "extra": { + "parenthesized": true, + "parenStart": 9 } } } 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-assignment-modulo-with-spaces/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-modulo-assignment-with-spaces/input.js rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-assignment-modulo-with-spaces/input.js 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-assignment-modulo-with-spaces/options.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-within-modulo-assignment-with-spaces/options.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-assignment-modulo-with-spaces/options.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-assignment-modulo-with-spaces/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-assignment-modulo-with-spaces/output.json new file mode 100644 index 000000000000..8cd63cbc9b01 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-assignment-modulo-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}}, + "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}} + }, + "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-modulo-assignment-without-spaces/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-assignment-modulo-without-spaces/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-modulo-assignment-without-spaces/input.js rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-assignment-modulo-without-spaces/input.js 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-assignment-modulo-without-spaces/options.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-within-modulo-assignment-without-spaces/options.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-assignment-modulo-without-spaces/options.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-assignment-modulo-without-spaces/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-assignment-modulo-without-spaces/output.json new file mode 100644 index 000000000000..268e1c5dcf41 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-assignment-modulo-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}}, + "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}} + }, + "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-assignment-normal/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-assignment-normal/input.js index 45f41c1eb927..e395996b6cb0 100644 --- 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 @@ -1 +1 @@ -value |> [x, y] = % +value |> ([x, y] = %) diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-assignment-normal/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-assignment-normal/output.json index 2d377919e7b2..0fcd28072cc8 100644 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-assignment-normal/output.json +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-assignment-normal/output.json @@ -1,21 +1,18 @@ { "type": "File", - "start":0,"end":19,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":19}}, - "errors": [ - "SyntaxError: Hack-style pipe body cannot be an unparenthesized assignment expression; please wrap it in parentheses. (1:9)" - ], + "start":0,"end":21,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":21}}, "program": { "type": "Program", - "start":0,"end":19,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":19}}, + "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":19,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":19}}, + "start":0,"end":21,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":21}}, "expression": { "type": "BinaryExpression", - "start":0,"end":19,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":19}}, + "start":0,"end":21,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":21}}, "left": { "type": "Identifier", "start":0,"end":5,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":5},"identifierName":"value"}, @@ -24,27 +21,31 @@ "operator": "|>", "right": { "type": "AssignmentExpression", - "start":9,"end":19,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":19}}, + "start":10,"end":20,"loc":{"start":{"line":1,"column":10},"end":{"line":1,"column":20}}, "operator": "=", "left": { "type": "ArrayPattern", - "start":9,"end":15,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":15}}, + "start":10,"end":16,"loc":{"start":{"line":1,"column":10},"end":{"line":1,"column":16}}, "elements": [ { "type": "Identifier", - "start":10,"end":11,"loc":{"start":{"line":1,"column":10},"end":{"line":1,"column":11},"identifierName":"x"}, + "start":11,"end":12,"loc":{"start":{"line":1,"column":11},"end":{"line":1,"column":12},"identifierName":"x"}, "name": "x" }, { "type": "Identifier", - "start":13,"end":14,"loc":{"start":{"line":1,"column":13},"end":{"line":1,"column":14},"identifierName":"y"}, + "start":14,"end":15,"loc":{"start":{"line":1,"column":14},"end":{"line":1,"column":15},"identifierName":"y"}, "name": "y" } ] }, "right": { "type": "TopicReference", - "start":18,"end":19,"loc":{"start":{"line":1,"column":18},"end":{"line":1,"column":19}} + "start":19,"end":20,"loc":{"start":{"line":1,"column":19},"end":{"line":1,"column":20}} + }, + "extra": { + "parenthesized": true, + "parenStart": 9 } } } 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 index d7d3ae4de1f1..5fa6b2a6b5cf 100644 --- 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 @@ -1 +1 @@ -value |> x += % +value |> (x += %) diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-assignment-plus/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-assignment-plus/output.json index daf345f63a28..7286fc1ca3c6 100644 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-assignment-plus/output.json +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-assignment-plus/output.json @@ -1,21 +1,18 @@ { "type": "File", - "start":0,"end":15,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":15}}, - "errors": [ - "SyntaxError: Hack-style pipe body cannot be an unparenthesized assignment expression; please wrap it in parentheses. (1:9)" - ], + "start":0,"end":17,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":17}}, "program": { "type": "Program", - "start":0,"end":15,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":15}}, + "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":15,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":15}}, + "start":0,"end":17,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":17}}, "expression": { "type": "BinaryExpression", - "start":0,"end":15,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":15}}, + "start":0,"end":17,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":17}}, "left": { "type": "Identifier", "start":0,"end":5,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":5},"identifierName":"value"}, @@ -24,16 +21,20 @@ "operator": "|>", "right": { "type": "AssignmentExpression", - "start":9,"end":15,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":15}}, + "start":10,"end":16,"loc":{"start":{"line":1,"column":10},"end":{"line":1,"column":16}}, "operator": "+=", "left": { "type": "Identifier", - "start":9,"end":10,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":10},"identifierName":"x"}, + "start":10,"end":11,"loc":{"start":{"line":1,"column":10},"end":{"line":1,"column":11},"identifierName":"x"}, "name": "x" }, "right": { "type": "TopicReference", - "start":14,"end":15,"loc":{"start":{"line":1,"column":14},"end":{"line":1,"column":15}} + "start":15,"end":16,"loc":{"start":{"line":1,"column":15},"end":{"line":1,"column":16}} + }, + "extra": { + "parenthesized": true, + "parenStart": 9 } } } diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-assignment-unparenthesized/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-assignment-unparenthesized/input.js new file mode 100644 index 000000000000..45f41c1eb927 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-assignment-unparenthesized/input.js @@ -0,0 +1 @@ +value |> [x, y] = % diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-assignment-unparenthesized/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-assignment-unparenthesized/options.json new file mode 100644 index 000000000000..bec5b124a302 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-assignment-unparenthesized/options.json @@ -0,0 +1,11 @@ +{ + "plugins": [ + [ + "pipelineOperator", + { + "proposal": "hack", + "topicToken": "%" + } + ] + ] +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-assignment-unparenthesized/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-assignment-unparenthesized/output.json new file mode 100644 index 000000000000..2d377919e7b2 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-assignment-unparenthesized/output.json @@ -0,0 +1,55 @@ +{ + "type": "File", + "start":0,"end":19,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":19}}, + "errors": [ + "SyntaxError: Hack-style pipe body cannot be an unparenthesized assignment expression; please wrap it in parentheses. (1:9)" + ], + "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":5,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":5},"identifierName":"value"}, + "name": "value" + }, + "operator": "|>", + "right": { + "type": "AssignmentExpression", + "start":9,"end":19,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":19}}, + "operator": "=", + "left": { + "type": "ArrayPattern", + "start":9,"end":15,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":15}}, + "elements": [ + { + "type": "Identifier", + "start":10,"end":11,"loc":{"start":{"line":1,"column":10},"end":{"line":1,"column":11},"identifierName":"x"}, + "name": "x" + }, + { + "type": "Identifier", + "start":13,"end":14,"loc":{"start":{"line":1,"column":13},"end":{"line":1,"column":14},"identifierName":"y"}, + "name": "y" + } + ] + }, + "right": { + "type": "TopicReference", + "start":18,"end":19,"loc":{"start":{"line":1,"column":18},"end":{"line":1,"column":19}} + } + } + } + } + ], + "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-assignment-modulo-with-spaces/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-within-modulo-assignment-with-spaces/input.js rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-within-assignment-modulo-with-spaces/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-within-assignment-modulo-with-spaces/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-within-assignment-modulo-with-spaces/options.json new file mode 100644 index 000000000000..cfbb79338626 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-within-assignment-modulo-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-assignment-modulo-with-spaces/output.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-within-modulo-assignment-with-spaces/output.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-within-assignment-modulo-with-spaces/output.json 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-assignment-modulo-without-spaces/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-within-modulo-assignment-without-spaces/input.js rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-within-assignment-modulo-without-spaces/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-within-assignment-modulo-without-spaces/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-within-assignment-modulo-without-spaces/options.json new file mode 100644 index 000000000000..cfbb79338626 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-within-assignment-modulo-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-assignment-modulo-without-spaces/output.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-within-modulo-assignment-without-spaces/output.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-within-assignment-modulo-without-spaces/output.json diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/hash-tuple/input.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/hash-tuple/input.js new file mode 100644 index 000000000000..c9cafc96318d --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/hash-tuple/input.js @@ -0,0 +1,2 @@ +#[0]; +1 |> #[0, ^]; diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/hash-tuple/options.json b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/hash-tuple/options.json new file mode 100644 index 000000000000..6084a8087a59 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/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-caret/hash-tuple/output.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/hash-tuple/output.js new file mode 100644 index 000000000000..877d41141fbe --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/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-caret/options.json b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/options.json new file mode 100644 index 000000000000..210c585582be --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/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-caret/pipe-body-identity/exec.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/pipe-body-identity/exec.js new file mode 100644 index 000000000000..c1beaa7cf65f --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/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-caret/pipe-body-identity/input.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/pipe-body-identity/input.js new file mode 100644 index 000000000000..c1beaa7cf65f --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/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-caret/pipe-body-identity/output.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/pipe-body-identity/output.js new file mode 100644 index 000000000000..ab1b47369050 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/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-caret/pipe-body-with-addition/exec.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/pipe-body-with-addition/exec.js new file mode 100644 index 000000000000..74b9e61a826f --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/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-caret/pipe-body-with-addition/input.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/pipe-body-with-addition/input.js new file mode 100644 index 000000000000..74b9e61a826f --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/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-caret/pipe-body-with-addition/output.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/pipe-body-with-addition/output.js new file mode 100644 index 000000000000..62a22e6b7067 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/pipe-body-with-addition/output.js @@ -0,0 +1,4 @@ +var _ref, _ref2; + +const result = (_ref2 = 5, (_ref = _ref2 + 1, _ref + _ref)); +expect(result).toBe(12); diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/pipe-body-with-arrow-function-and-nested-pipe/exec.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/pipe-body-with-arrow-function-and-nested-pipe/exec.js new file mode 100644 index 000000000000..43ee990e5f98 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/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-caret/pipe-body-with-arrow-function-and-nested-pipe/input.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/pipe-body-with-arrow-function-and-nested-pipe/input.js new file mode 100644 index 000000000000..43ee990e5f98 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/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-caret/pipe-body-with-arrow-function-and-nested-pipe/output.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/pipe-body-with-arrow-function-and-nested-pipe/output.js new file mode 100644 index 000000000000..bf1fcd321aef --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/pipe-body-with-arrow-function-and-nested-pipe/output.js @@ -0,0 +1,8 @@ +var _ref4, _ref5, _ref6; + +const result = (_ref6 = 5, (_ref5 = Math.pow(_ref6, 2), (_ref4 = [1, 2, 3].map(n => { + var _ref, _ref2, _ref3; + + return _ref3 = n + _ref5, (_ref2 = _ref3 * 2, (_ref = `${_ref2} apples`, _ref.toUpperCase())); +}), _ref4.join()))); +expect(result).toEqual('52 APPLES,54 APPLES,56 APPLES'); diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/pipe-body-with-arrow-function/exec.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/pipe-body-with-arrow-function/exec.js new file mode 100644 index 000000000000..3a54518ad970 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/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-caret/pipe-body-with-arrow-function/input.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/pipe-body-with-arrow-function/input.js new file mode 100644 index 000000000000..3a54518ad970 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/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-caret/pipe-body-with-arrow-function/output.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/pipe-body-with-arrow-function/output.js new file mode 100644 index 000000000000..5def3730d465 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/pipe-body-with-arrow-function/output.js @@ -0,0 +1,8 @@ +var _ref, _ref2, _ref3; + +const result = (_ref3 = -2.2 // -2.2 +, (_ref2 = Math.floor(_ref3) // -3 +, (_ref = () => Math.pow(_ref2, 5) // () => -243 +, _ref()))); // -243 + +expect(result).toBe(-243); diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/pipe-body-with-await/exec.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/pipe-body-with-await/exec.js new file mode 100644 index 000000000000..963ae8e6059d --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/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-caret/pipe-body-with-await/input.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/pipe-body-with-await/input.js new file mode 100644 index 000000000000..963ae8e6059d --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/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-caret/pipe-body-with-await/options.json b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/pipe-body-with-await/options.json new file mode 100644 index 000000000000..f19c36b8eef1 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/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-caret/pipe-body-with-await/output.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/pipe-body-with-await/output.js new file mode 100644 index 000000000000..aa3d4e62d419 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/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 = n, (_ref2 = Math.abs(_ref3), (_ref = await Promise.resolve(_ref2), triple(_ref))); +} + +asyncFunction(-7).then(result => { + expect(result).toBe(21); +}); diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/pipe-body-with-class-expression-and-private-properties/exec.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/pipe-body-with-class-expression-and-private-properties/exec.js new file mode 100644 index 000000000000..07388ac895d2 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/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-caret/pipe-body-with-class-expression-and-private-properties/input.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/pipe-body-with-class-expression-and-private-properties/input.js new file mode 100644 index 000000000000..07388ac895d2 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/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-caret/pipe-body-with-class-expression-and-private-properties/options.json b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/pipe-body-with-class-expression-and-private-properties/options.json new file mode 100644 index 000000000000..017e3038fff7 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/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-caret/pipe-body-with-class-expression-and-private-properties/output.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/pipe-body-with-class-expression-and-private-properties/output.js new file mode 100644 index 000000000000..638f9cda750f --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/pipe-body-with-class-expression-and-private-properties/output.js @@ -0,0 +1,19 @@ +var _ref, _ref2, _ref3; + +const result = (_ref3 = 1, (_ref2 = class { + #baz; + + constructor() { + this.#baz = _ref3; + } + + #bar() { + return this.#baz + 2; + } + + foo() { + return this.#bar() + 3; + } + +}, (_ref = new _ref2(), _ref.foo()))); +expect(result).toBe(1 + 2 + 3); diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/pipe-body-with-eval/exec.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/pipe-body-with-eval/exec.js new file mode 100644 index 000000000000..1d0f4a5297e5 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/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-caret/pipe-body-with-eval/input.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/pipe-body-with-eval/input.js new file mode 100644 index 000000000000..1d0f4a5297e5 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/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-caret/pipe-body-with-eval/output.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/pipe-body-with-eval/output.js new file mode 100644 index 000000000000..c5dbd6107a44 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/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-caret/pipe-body-with-nested-pipe/exec.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/pipe-body-with-nested-pipe/exec.js new file mode 100644 index 000000000000..9a9f693d9a3c --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/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-caret/pipe-body-with-nested-pipe/input.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/pipe-body-with-nested-pipe/input.js new file mode 100644 index 000000000000..9a9f693d9a3c --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/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-caret/pipe-body-with-nested-pipe/output.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/pipe-body-with-nested-pipe/output.js new file mode 100644 index 000000000000..8ee6b4bbf42f --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/pipe-body-with-nested-pipe/output.js @@ -0,0 +1,4 @@ +var _ref, _ref2, _ref3, _ref4; + +const result = (_ref4 = 5, (_ref3 = Math.pow(_ref4, 2), (_ref2 = _ref3 + 1, (_ref = `${_ref2} apples`, _ref.toUpperCase())))); +expect(result).toEqual('26 APPLES'); diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/pipe-body-with-object-literal/exec.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/pipe-body-with-object-literal/exec.js new file mode 100644 index 000000000000..0aed0bf1524f --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/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-caret/pipe-body-with-object-literal/input.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/pipe-body-with-object-literal/input.js new file mode 100644 index 000000000000..0aed0bf1524f --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/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-caret/pipe-body-with-object-literal/output.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/pipe-body-with-object-literal/output.js new file mode 100644 index 000000000000..cd74f2422e0a --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/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 = -5, (_ref2 = Math.abs(_ref3), (_ref = { + width: _ref2, + height: _ref2 + 3 +}, area(_ref)))); +expect(result).toBe(40); diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/pipe-body-with-topic-method-call/exec.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/pipe-body-with-topic-method-call/exec.js new file mode 100644 index 000000000000..f5cc47e555c5 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/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-caret/pipe-body-with-topic-method-call/input.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/pipe-body-with-topic-method-call/input.js new file mode 100644 index 000000000000..f5cc47e555c5 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/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-caret/pipe-body-with-topic-method-call/output.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/pipe-body-with-topic-method-call/output.js new file mode 100644 index 000000000000..029efa564267 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/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-caret/pipe-body-with-yield/exec.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/pipe-body-with-yield/exec.js new file mode 100644 index 000000000000..6cebabd828f7 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/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-caret/pipe-body-with-yield/input.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/pipe-body-with-yield/input.js new file mode 100644 index 000000000000..6cebabd828f7 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/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-caret/pipe-body-with-yield/output.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/pipe-body-with-yield/output.js new file mode 100644 index 000000000000..40f127c27ae2 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/pipe-body-with-yield/output.js @@ -0,0 +1,11 @@ +function* myGenerator(n) { + var _ref, _ref2; + + return _ref2 = n, (_ref = yield _ref2, Math.abs(_ref)); +} + +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-caret/pipe-head-with-nested-pipe/exec.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/pipe-head-with-nested-pipe/exec.js new file mode 100644 index 000000000000..b2de7435479a --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/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-caret/pipe-head-with-nested-pipe/input.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/pipe-head-with-nested-pipe/input.js new file mode 100644 index 000000000000..b2de7435479a --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/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-caret/pipe-head-with-nested-pipe/output.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/pipe-head-with-nested-pipe/output.js new file mode 100644 index 000000000000..1adde6582021 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/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-caret/pipe-in-arrow-function/exec.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/pipe-in-arrow-function/exec.js new file mode 100644 index 000000000000..c0b427a4e742 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/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-caret/pipe-in-arrow-function/input.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/pipe-in-arrow-function/input.js new file mode 100644 index 000000000000..c0b427a4e742 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/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-caret/pipe-in-arrow-function/output.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/pipe-in-arrow-function/output.js new file mode 100644 index 000000000000..66106a985d16 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/pipe-in-arrow-function/output.js @@ -0,0 +1,11 @@ +const result = () => { + var _ref, _ref2, _ref3; + + return _ref3 = -2.2 // -2.2 + , (_ref2 = Math.floor(_ref3) // -3 + , (_ref = () => Math.pow(_ref2, 5) // () => -243 + , _ref())); +}; // -243 + + +expect(result()).toBe(-243); diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/transform-arrow-functions/exec.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/transform-arrow-functions/exec.js new file mode 100644 index 000000000000..677d889ebe61 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/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-caret/transform-arrow-functions/input.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/transform-arrow-functions/input.js new file mode 100644 index 000000000000..677d889ebe61 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/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-caret/transform-arrow-functions/options.json b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/transform-arrow-functions/options.json new file mode 100644 index 000000000000..300f5616597c --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/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-caret/transform-arrow-functions/output.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/transform-arrow-functions/output.js new file mode 100644 index 000000000000..23cdd3fe2a2b --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/transform-arrow-functions/output.js @@ -0,0 +1,8 @@ +var _ref, _ref2; + +const triple = function (x) { + return x * 3; +}; + +const result = (_ref2 = -7, (_ref = Math.abs(_ref2), triple(_ref))); +return expect(result).toBe(21); diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/transform-await-and-arrow-functions/exec.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/transform-await-and-arrow-functions/exec.js new file mode 100644 index 000000000000..e29f5c8197a3 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/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-caret/transform-await-and-arrow-functions/input.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/transform-await-and-arrow-functions/input.js new file mode 100644 index 000000000000..e29f5c8197a3 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/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-caret/transform-await-and-arrow-functions/options.json b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/transform-await-and-arrow-functions/options.json new file mode 100644 index 000000000000..81c5421cd5a3 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/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-caret/transform-await-and-arrow-functions/output.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/transform-await-and-arrow-functions/output.js new file mode 100644 index 000000000000..3a32f6e23831 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/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 = n, (_ref3 = Math.abs(_ref4), (_ref2 = Promise.resolve(_ref3), (_ref = await _ref2, triple(_ref)))); +} + +return myFunction(-7).then(function (result) { + expect(result).toBe(21); +}); diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/while-statement-with-pipe-in-condition/exec.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/while-statement-with-pipe-in-condition/exec.js new file mode 100644 index 000000000000..5d893fe9e1ed --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/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-caret/while-statement-with-pipe-in-condition/input.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/while-statement-with-pipe-in-condition/input.js new file mode 100644 index 000000000000..5d893fe9e1ed --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/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-caret/while-statement-with-pipe-in-condition/output.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/while-statement-with-pipe-in-condition/output.js new file mode 100644 index 000000000000..0622dfee4902 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/while-statement-with-pipe-in-condition/output.js @@ -0,0 +1,10 @@ +let i = 0; +let sum = 0; + +while (_ref2 = i, (_ref = i = _ref2 + 1, _ref <= 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-caret/within-assignment/exec.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/within-assignment/exec.js new file mode 100644 index 000000000000..7e32eaaaf2a2 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/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-caret/within-assignment/input.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/within-assignment/input.js new file mode 100644 index 000000000000..7e32eaaaf2a2 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/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-caret/within-assignment/output.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/within-assignment/output.js new file mode 100644 index 000000000000..5ca2ce9e5390 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/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-caret/within-for-classic-statement-init/exec.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/within-for-classic-statement-init/exec.js new file mode 100644 index 000000000000..444eb6750af8 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/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-caret/within-for-classic-statement-init/input.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/within-for-classic-statement-init/input.js new file mode 100644 index 000000000000..444eb6750af8 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/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-caret/within-for-classic-statement-init/output.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/within-for-classic-statement-init/output.js new file mode 100644 index 000000000000..dd399138c6fb --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/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-caret/within-for-classic-statement-test/exec.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/within-for-classic-statement-test/exec.js new file mode 100644 index 000000000000..5abd941fbefb --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/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-caret/within-for-classic-statement-test/input.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/within-for-classic-statement-test/input.js new file mode 100644 index 000000000000..5abd941fbefb --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/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-caret/within-for-classic-statement-test/output.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/within-for-classic-statement-test/output.js new file mode 100644 index 000000000000..14ae06d74abf --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/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-caret/within-for-classic-statement-update/exec.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/within-for-classic-statement-update/exec.js new file mode 100644 index 000000000000..2f13cb0e7e08 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/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-caret/within-for-classic-statement-update/input.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/within-for-classic-statement-update/input.js new file mode 100644 index 000000000000..2f13cb0e7e08 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/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-caret/within-for-classic-statement-update/output.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/within-for-classic-statement-update/output.js new file mode 100644 index 000000000000..a741096b130d --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/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-caret/within-generator-with-yield/input.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/within-generator-with-yield/input.js new file mode 100644 index 000000000000..fb0a441f45c3 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/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-caret/within-generator-with-yield/output.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/within-generator-with-yield/output.js new file mode 100644 index 000000000000..4e9cfe3a1240 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/within-generator-with-yield/output.js @@ -0,0 +1,5 @@ +function* myGenerator(n) { + var _ref, _ref2; + + return _ref2 = n, (_ref = yield _ref2, Math.abs(_ref)); +} diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/within-if-else-block/input.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/within-if-else-block/input.js new file mode 100644 index 000000000000..9ca55ff4cfb0 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/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-caret/within-if-else-block/output.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/within-if-else-block/output.js new file mode 100644 index 000000000000..5d542dc97ffc --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/within-if-else-block/output.js @@ -0,0 +1,3 @@ +var _ref, _ref2, _ref3, _ref4; + +if (_ref2 = v, (_ref = e(_ref2), f(_ref))) _ref4 = g(), (_ref3 = h(_ref4, _ref4 + 1), i(_ref3));else j(); diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/within-var-statement/exec.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/within-var-statement/exec.js new file mode 100644 index 000000000000..26837dd5150f --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/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-caret/within-var-statement/input.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/within-var-statement/input.js new file mode 100644 index 000000000000..26837dd5150f --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/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-caret/within-var-statement/output.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/within-var-statement/output.js new file mode 100644 index 000000000000..126fd403042b --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/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 f81201bb2fc9..6ee8d1fbb638 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";