diff --git a/packages/babel-generator/src/generators/types.ts b/packages/babel-generator/src/generators/types.ts index c248a31090..e8b501481a 100644 --- a/packages/babel-generator/src/generators/types.ts +++ b/packages/babel-generator/src/generators/types.ts @@ -237,6 +237,23 @@ export function DecimalLiteral(this: Printer, node: t.DecimalLiteral) { this.word(node.value + "m"); } +// Hack pipe operator +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); + } + } +} + +// Smart-mix pipe operator export function PipelineTopicExpression( this: Printer, node: t.PipelineTopicExpression, diff --git a/packages/babel-generator/src/index.ts b/packages/babel-generator/src/index.ts index 6c1a396c70..e16183ce0f 100644 --- a/packages/babel-generator/src/index.ts +++ b/packages/babel-generator/src/index.ts @@ -62,6 +62,7 @@ function normalizeOptions(code, opts): Format { ...opts.jsescOption, }, recordAndTupleSyntaxType: opts.recordAndTupleSyntaxType, + topicToken: opts.topicToken, }; if (!process.env.BABEL_8_BREAKING) { @@ -197,6 +198,12 @@ export interface GeneratorOptions { */ wrap?: boolean; }; + + /** + * For use with the Hack-style pipe operator. + * Changes what token is used for pipe bodies’ topic references. + */ + topicToken?: "#"; } export interface GeneratorResult { diff --git a/packages/babel-generator/src/printer.ts b/packages/babel-generator/src/printer.ts index 808f888478..a8dc34c0b7 100644 --- a/packages/babel-generator/src/printer.ts +++ b/packages/babel-generator/src/printer.ts @@ -33,6 +33,11 @@ export type Format = { recordAndTupleSyntaxType: "bar" | "hash"; jsescOption; jsonCompatibleStrings?; + /** + * For use with the Hack-style pipe operator. + * Changes what token is used for pipe bodies’ topic references. + */ + topicToken?: "#"; }; class Printer { diff --git a/packages/babel-generator/test/fixtures/types/PipelineBareFunction/options.json b/packages/babel-generator/test/fixtures/types/PipelineBareFunction/options.json index edb7679c6a..17e4e327bb 100644 --- a/packages/babel-generator/test/fixtures/types/PipelineBareFunction/options.json +++ b/packages/babel-generator/test/fixtures/types/PipelineBareFunction/options.json @@ -1,3 +1,3 @@ { - "plugins": [["pipelineOperator", { "proposal": "smart" }], "doExpressions"] + "plugins": [["pipelineOperator", { "proposal": "smart" }]] } diff --git a/packages/babel-generator/test/fixtures/types/PipelinePrimaryTopicReference/input.js b/packages/babel-generator/test/fixtures/types/PipelinePrimaryTopicReference/input.js new file mode 100644 index 0000000000..fe4d81876f --- /dev/null +++ b/packages/babel-generator/test/fixtures/types/PipelinePrimaryTopicReference/input.js @@ -0,0 +1 @@ +2 + 3 |> #.toString(16); diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-function-calls,-chained,-multiline/options.json b/packages/babel-generator/test/fixtures/types/PipelinePrimaryTopicReference/options.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-function-calls,-chained,-multiline/options.json rename to packages/babel-generator/test/fixtures/types/PipelinePrimaryTopicReference/options.json diff --git a/packages/babel-generator/test/fixtures/types/PipelinePrimaryTopicReference/output.js b/packages/babel-generator/test/fixtures/types/PipelinePrimaryTopicReference/output.js new file mode 100644 index 0000000000..8c25c56853 --- /dev/null +++ b/packages/babel-generator/test/fixtures/types/PipelinePrimaryTopicReference/output.js @@ -0,0 +1 @@ +2 + 3 |> #.toString(16); \ No newline at end of file diff --git a/packages/babel-generator/test/fixtures/types/TopicReference-with-hash-topicToken/input.js b/packages/babel-generator/test/fixtures/types/TopicReference-with-hash-topicToken/input.js new file mode 100644 index 0000000000..fe4d81876f --- /dev/null +++ b/packages/babel-generator/test/fixtures/types/TopicReference-with-hash-topicToken/input.js @@ -0,0 +1 @@ +2 + 3 |> #.toString(16); diff --git a/packages/babel-generator/test/fixtures/types/TopicReference-with-hash-topicToken/options.json b/packages/babel-generator/test/fixtures/types/TopicReference-with-hash-topicToken/options.json new file mode 100644 index 0000000000..63ab62c214 --- /dev/null +++ b/packages/babel-generator/test/fixtures/types/TopicReference-with-hash-topicToken/options.json @@ -0,0 +1,4 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "hack", "topicToken": "#" }]], + "topicToken": "#" +} diff --git a/packages/babel-generator/test/fixtures/types/TopicReference-with-hash-topicToken/output.js b/packages/babel-generator/test/fixtures/types/TopicReference-with-hash-topicToken/output.js new file mode 100644 index 0000000000..8c25c56853 --- /dev/null +++ b/packages/babel-generator/test/fixtures/types/TopicReference-with-hash-topicToken/output.js @@ -0,0 +1 @@ +2 + 3 |> #.toString(16); \ No newline at end of file diff --git a/packages/babel-generator/test/fixtures/types/TopicReference-with-invalid-topicToken/input.js b/packages/babel-generator/test/fixtures/types/TopicReference-with-invalid-topicToken/input.js new file mode 100644 index 0000000000..fe4d81876f --- /dev/null +++ b/packages/babel-generator/test/fixtures/types/TopicReference-with-invalid-topicToken/input.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 new file mode 100644 index 0000000000..4b1203dd72 --- /dev/null +++ b/packages/babel-generator/test/fixtures/types/TopicReference-with-invalid-topicToken/options.json @@ -0,0 +1,5 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "hack", "topicToken": "#" }]], + "topicToken": "invalid", + "throws": "The \"topicToken\" generator option must be \"#\" (\"invalid\" received instead)." +} diff --git a/packages/babel-generator/test/fixtures/types/TopicReference-with-missing-topicToken/input.js b/packages/babel-generator/test/fixtures/types/TopicReference-with-missing-topicToken/input.js new file mode 100644 index 0000000000..fe4d81876f --- /dev/null +++ b/packages/babel-generator/test/fixtures/types/TopicReference-with-missing-topicToken/input.js @@ -0,0 +1 @@ +2 + 3 |> #.toString(16); 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 new file mode 100644 index 0000000000..9e4d884dbf --- /dev/null +++ b/packages/babel-generator/test/fixtures/types/TopicReference-with-missing-topicToken/options.json @@ -0,0 +1,4 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "hack", "topicToken": "#" }]], + "throws": "The \"topicToken\" generator option must be \"#\" (undefined received instead)." +} diff --git a/packages/babel-parser/ast/spec.md b/packages/babel-parser/ast/spec.md index 0e005fd229..1c934c1ba1 100644 --- a/packages/babel-parser/ast/spec.md +++ b/packages/babel-parser/ast/spec.md @@ -960,54 +960,6 @@ interface BindExpression <: Expression { If `object` is `null`, then `callee` should be a `MemberExpression`. -### Pipeline - -These nodes are used by the Smart Pipeline to determine the type of the expression in a Pipeline Operator Expression. The F# Pipeline uses simple `BinaryExpression`s. - -#### PipelineBody - -```js -interface PipelineBody <: NodeBase { - type: "PipelineBody"; -} -``` - -#### PipelineBareFunctionBody - -```js -interface PipelineBody <: NodeBase { - type: "PipelineBareFunctionBody"; - callee: Expression; -} -``` - -#### PipelineBareConstructorBody - -```js -interface PipelineBareConstructorBody <: NodeBase { - type: "PipelineBareConstructorBody"; - callee: Expression; -} -``` - -#### PipelineBareAwaitedFunctionBody - -```js -interface PipelineBareConstructorBody <: NodeBase { - type: "PipelineTopicBody"; - expression: Expression; -} -``` - -#### PipelineTopicBody - -```js -interface PipelineBareConstructorBody <: NodeBase { - type: "PipelineBareAwaitedFunctionBody"; - callee: Expression; -} -``` - ## ConditionalExpression ```js @@ -1099,6 +1051,17 @@ interface ModuleExpression <: Expression { A inline module expression proposed in https://github.com/tc39/proposal-js-module-blocks. +## TopicReference + +```js +interface TopicReference <: Expression { + type: "TopicReference"; +} +``` + +A topic reference to be used inside the body of +a [Hack-style pipe expression](https://github.com/js-choi/proposal-hack-pipes). + # Template Literals ## TemplateLiteral @@ -1431,3 +1394,53 @@ interface ExportAllDeclaration <: ModuleDeclaration { ``` An export batch declaration, e.g., `export * from "mod";`. + +### Smart-mix pipelines + +These types are **deprecated**. +They are used by the deprecated smart-mix pipe operator to determine +the type of a pipe expression's the body expression. +The Hack and F# pipe operators use simple `BinaryExpression`s. + +#### PipelineBody + +```js +interface PipelineBody <: NodeBase { + type: "PipelineBody"; +} +``` + +#### PipelineBareFunctionBody + +```js +interface PipelineBody <: NodeBase { + type: "PipelineBareFunctionBody"; + callee: Expression; +} +``` + +#### PipelineBareConstructorBody + +```js +interface PipelineBareConstructorBody <: NodeBase { + type: "PipelineBareConstructorBody"; + callee: Expression; +} +``` + +#### PipelineBareAwaitedFunctionBody + +```js +interface PipelineBareConstructorBody <: NodeBase { + type: "PipelineTopicBody"; + expression: Expression; +} +``` + +#### PipelineTopicBody + +```js +interface PipelineBareConstructorBody <: NodeBase { + type: "PipelineBareAwaitedFunctionBody"; + callee: Expression; +} diff --git a/packages/babel-parser/src/parser/error-message.js b/packages/babel-parser/src/parser/error-message.js index 2efe2ba845..4953b5acd5 100644 --- a/packages/babel-parser/src/parser/error-message.js +++ b/packages/babel-parser/src/parser/error-message.js @@ -134,6 +134,19 @@ export const ErrorMessages = makeErrorTemplates( ParamDupe: "Argument name clash.", PatternHasAccessor: "Object pattern can't contain getter or setter.", PatternHasMethod: "Object pattern can't contain methods.", + PipeBodyIsTighter: + "Unexpected %0 after pipeline body; any %0 expression acting as Hack-style pipe body must be parenthesized due to its loose operator precedence.", + PipeTopicRequiresHackPipes: + 'Topic reference is used, but the pipelineOperator plugin was not passed a "proposal": "hack" or "smart" option.', + PipeTopicUnbound: + "Topic reference is unbound; it must be inside a pipe body.", + PipeTopicUnused: + "Hack-style pipe body does not contain a topic reference; Hack-style pipes must use topic at least once.", + + // Messages whose codes start with “Pipeline” or “PrimaryTopic” + // are retained for backwards compatibility + // with the deprecated smart-mix pipe operator proposal plugin. + // They are subject to removal in a future major version. PipelineBodyNoArrow: 'Unexpected arrow "=>" after pipeline body; arrow function in pipeline body must be parenthesized.', PipelineBodySequenceExpression: @@ -145,7 +158,8 @@ export const ErrorMessages = makeErrorTemplates( PrimaryTopicNotAllowed: "Topic reference was used in a lexical context without topic binding.", PrimaryTopicRequiresSmartPipeline: - "Primary Topic Reference found but pipelineOperator not passed 'smart' for 'proposal' option.", + 'Topic reference is used, but the pipelineOperator plugin was not passed a "proposal": "hack" or "smart" option.', + PrivateInExpectedIn: "Private names are only allowed in property accesses (`obj.#%0`) or in `in` expressions (`#%0 in obj`).", PrivateNameRedeclaration: "Duplicate private name #%0.", diff --git a/packages/babel-parser/src/parser/expression.js b/packages/babel-parser/src/parser/expression.js index 737b82439b..35e0178ef2 100644 --- a/packages/babel-parser/src/parser/expression.js +++ b/packages/babel-parser/src/parser/expression.js @@ -292,6 +292,28 @@ export default class ExpressionParser extends LValParser { const operator = this.state.value; node.operator = operator; + const leftIsHackPipeExpression = + left.type === "BinaryExpression" && + left.operator === "|>" && + this.getPluginOption("pipelineOperator", "proposal") === "hack"; + + if (leftIsHackPipeExpression) { + // If the pipelinePlugin is configured to use Hack pipes, + // and if an assignment expression’s LHS invalidly contains `|>`, + // then the user likely meant to parenthesize the assignment expression. + // Throw a human-friendly error + // instead of something like 'Invalid left-hand side'. + // For example, `x = x |> y = #` (assuming `#` is the topic reference) + // groups into `x = (x |> y) = #`, + // and `(x |> y)` is an invalid assignment LHS. + // This is because Hack-style `|>` has tighter precedence than `=>`. + // (Unparenthesized `yield` expressions are handled + // in `parseHackPipeBody`, + // and unparenthesized `=>` expressions are handled + // in `checkHackPipeBodyEarlyErrors`.) + throw this.raise(this.state.start, Errors.PipeBodyIsTighter, operator); + } + if (this.match(tt.eq)) { node.left = this.toAssignable(left, /* isLHS */ true); refExpressionErrors.doubleProto = -1; // reset because double __proto__ is valid in assignment expression @@ -386,7 +408,6 @@ export default class ExpressionParser extends LValParser { if (this.state.inFSharpPipelineDirectBody) { return left; } - this.state.inPipeline = true; this.checkPipelineAtInfixOperator(left, leftStartPos); } const node = this.startNodeAt(leftStartPos, leftStartLoc); @@ -453,21 +474,30 @@ export default class ExpressionParser extends LValParser { switch (op) { case tt.pipeline: switch (this.getPluginOption("pipelineOperator", "proposal")) { + case "hack": + return this.withTopicBindingContext(() => { + const bodyExpr = this.parseHackPipeBody(op, prec); + this.checkHackPipeBodyEarlyErrors(startPos); + return bodyExpr; + }); + case "smart": - return this.withTopicPermittingContext(() => { - return this.parseSmartPipelineBody( - this.parseExprOpBaseRightExpr(op, prec), + return this.withTopicBindingContext(() => { + const childExpr = this.parseHackPipeBody(op, prec); + return this.parseSmartPipelineBodyInStyle( + childExpr, startPos, startLoc, ); }); + case "fsharp": return this.withSoloAwaitPermittingContext(() => { return this.parseFSharpPipelineBody(prec); }); } - // falls through + // Falls through. default: return this.parseExprOpBaseRightExpr(op, prec); } @@ -488,6 +518,39 @@ export default class ExpressionParser extends LValParser { ); } + // Helper function for `parseExprOpRightExpr` for the Hack-pipe operator + // (and the Hack-style smart-mix pipe operator). + + parseHackPipeBody(op: TokenType, prec: number): N.Expression { + // If the following expression is invalidly a `yield` expression, + // then throw a human-friendly error. + // A `yield` expression in a generator context (i.e., a [Yield] production) + // starts a YieldExpression. + // Outside of a generator context, any `yield` as a pipe body + // is considered simply an identifier. + // This error is checked here, before actually parsing the body expression, + // because `yield`’s “not allowed as identifier in generator” error + // would otherwise have immediately + // occur before the pipe body is fully parsed. + // (Unparenthesized assignment expressions are handled + // in `parseMaybeAssign`, + // and unparenthesized `=>` expressions are handled + // in `checkHackPipeBodyEarlyErrors`.) + const bodyIsInGeneratorContext = this.prodParam.hasYield; + const bodyIsYieldExpression = + bodyIsInGeneratorContext && this.isContextual("yield"); + + if (bodyIsYieldExpression) { + throw this.raise( + this.state.start, + Errors.PipeBodyIsTighter, + this.state.value, + ); + } else { + return this.parseExprOpBaseRightExpr(op, prec); + } + } + checkExponentialAfterUnary(node: N.AwaitExpression | N.UnaryExpression) { if (this.match(tt.exponent)) { this.raise( @@ -1163,26 +1226,14 @@ export default class ExpressionParser extends LValParser { } return node; } + case tt.hash: { - if (this.state.inPipeline) { - node = this.startNode(); - - if ( - this.getPluginOption("pipelineOperator", "proposal") !== "smart" - ) { - this.raise(node.start, Errors.PrimaryTopicRequiresSmartPipeline); - } - - this.next(); - - if (!this.primaryTopicReferenceIsAllowedInCurrentTopicContext()) { - this.raise(node.start, Errors.PrimaryTopicNotAllowed); - } - - this.registerTopicReference(); - return this.finishNode(node, "PipelinePrimaryTopicReference"); + node = this.maybeParseTopicReference(); + if (node) { + return node; } } + // fall through case tt.relational: { if (this.state.value === "<") { @@ -1195,12 +1246,102 @@ export default class ExpressionParser extends LValParser { } } } + // fall through default: throw this.unexpected(); } } + // https://github.com/js-choi/proposal-hack-pipes + maybeParseTopicReference(): ?N.Expression { + const pipeProposal = this.getPluginOption("pipelineOperator", "proposal"); + + // `pipeProposal` is falsy when an input program + // contains a topic reference on its own, + // outside of a pipe expression, + // and without having turned on the pipelineOperator plugin. + if (pipeProposal) { + // A pipe-operator proposal is active. + + const tokenType = this.state.type; + + if (this.testTopicReferenceConfiguration(pipeProposal, tokenType)) { + // The token matches the plugin’s configuration. + // The token is therefore a topic reference. + + const node = this.startNode(); + + // Determine the node type for the topic reference + // that is appropriate for the active pipe-operator proposal. + let nodeType; + if (pipeProposal === "smart") { + nodeType = "PipelinePrimaryTopicReference"; + } else { + // The proposal must otherwise be "hack", + // as enforced by testTopicReferenceConfiguration. + nodeType = "TopicReference"; + } + + // Consume the token. + this.next(); + + // Register the topic reference so that its pipe body knows + // that its topic was used at least once. + this.registerTopicReference(); + + if (!this.topicReferenceIsAllowedInCurrentContext()) { + // The topic reference is not allowed in the current context: + // it is outside of a pipe body. + // Raise recoverable errors. + if (pipeProposal === "smart") { + this.raise(this.state.start, Errors.PrimaryTopicNotAllowed); + } else { + // In this case, `pipeProposal === "hack"` is true. + this.raise(this.state.start, Errors.PipeTopicUnbound); + } + } + + return this.finishNode(node, nodeType); + } else { + // The token does not match the plugin’s configuration. + throw this.raise( + this.state.start, + Errors.PipeTopicUnconfiguredToken, + tokenType.label, + ); + } + } + } + + // This helper method tests whether the given token type + // matches the pipelineOperator parser plugin’s configuration. + // If the active pipe proposal is Hack style, + // and if the given token is the same as the plugin configuration’s `topicToken`, + // then this is a valid topic reference. + // If the active pipe proposal is smart mix, + // then the topic token must always be `#`. + // If the active pipe proposal is neither (e.g., "minimal" or "fsharp"), + // then an error is thrown. + testTopicReferenceConfiguration( + pipeProposal: string, + tokenType: TokenType, + ): boolean { + switch (pipeProposal) { + case "hack": { + const pluginTopicToken = this.getPluginOption( + "pipelineOperator", + "topicToken", + ); + return tokenType.label === pluginTopicToken; + } + case "smart": + return tokenType === tt.hash; + default: + throw this.raise(this.state.start, Errors.PipeTopicRequiresHackPipes); + } + } + // async [no LineTerminator here] AsyncArrowBindingIdentifier[?Yield] [no LineTerminator here] => AsyncConciseBody[?In] parseAsyncArrowUnaryFunction(node: N.Node): N.ArrowFunctionExpression { // We don't need to push a new ParameterDeclarationScope here since we are sure @@ -2522,52 +2663,48 @@ export default class ExpressionParser extends LValParser { } } - parseSmartPipelineBody( - childExpression: N.Expression, - startPos: number, - startLoc: Position, - ): N.PipelineBody { - this.checkSmartPipelineBodyEarlyErrors(childExpression, startPos); + // This helper method is to be called immediately + // after a Hack-style pipe body is parsed. + // The `startPos` is the starting position of the pipe body. - return this.parseSmartPipelineBodyInStyle( - childExpression, - startPos, - startLoc, - ); - } - - checkSmartPipelineBodyEarlyErrors( - childExpression: N.Expression, - startPos: number, - ): void { + checkHackPipeBodyEarlyErrors(startPos: number): void { + // If the following token is invalidly `=>`, + // then throw a human-friendly error + // instead of something like 'Unexpected token, expected ";"'. + // For example, `x => x |> y => #` (assuming `#` is the topic reference) + // groups into `x => (x |> y) => #`, + // and `(x |> y) => #` is an invalid arrow function. + // This is because Hack-style `|>` has tighter precedence than `=>`. + // (Unparenthesized `yield` expressions are handled + // in `parseHackPipeBody`, + // and unparenthesized assignment expressions are handled + // in `parseMaybeAssign`.) if (this.match(tt.arrow)) { - // If the following token is invalidly `=>`, then throw a human-friendly error - // instead of something like 'Unexpected token, expected ";"'. - throw this.raise(this.state.start, Errors.PipelineBodyNoArrow); - } else if (childExpression.type === "SequenceExpression") { - this.raise(startPos, Errors.PipelineBodySequenceExpression); + throw this.raise( + this.state.start, + Errors.PipeBodyIsTighter, + tt.arrow.label, + ); + } else if (!this.topicReferenceWasUsedInCurrentContext()) { + // A Hack pipe body must use the topic reference at least once. + this.raise(startPos, Errors.PipeTopicUnused); } } parseSmartPipelineBodyInStyle( - childExpression: N.Expression, + childExpr: N.Expression, startPos: number, startLoc: Position, ): N.PipelineBody { const bodyNode = this.startNodeAt(startPos, startLoc); - const isSimpleReference = this.isSimpleReference(childExpression); - if (isSimpleReference) { - bodyNode.callee = childExpression; + if (this.isSimpleReference(childExpr)) { + bodyNode.callee = childExpr; + return this.finishNode(bodyNode, "PipelineBareFunction"); } else { - if (!this.topicReferenceWasUsedInCurrentTopicContext()) { - this.raise(startPos, Errors.PipelineTopicUnused); - } - bodyNode.expression = childExpression; + this.checkSmartPipeTopicBodyEarlyErrors(startPos); + bodyNode.expression = childExpr; + return this.finishNode(bodyNode, "PipelineTopicExpression"); } - return this.finishNode( - bodyNode, - isSimpleReference ? "PipelineBareFunction" : "PipelineTopicExpression", - ); } isSimpleReference(expression: N.Expression): boolean { @@ -2583,13 +2720,34 @@ export default class ExpressionParser extends LValParser { } } - // Enable topic references from outer contexts within smart pipeline bodies. - // The function modifies the parser's topic-context state to enable or disable - // the use of topic references with the smartPipelines plugin. They then run a - // callback, then they reset the parser to the old topic-context state that it - // had before the function was called. + // This helper method is to be called immediately + // after a topic-style smart-mix pipe body is parsed. + // The `startPos` is the starting position of the pipe body. - withTopicPermittingContext(callback: () => T): T { + checkSmartPipeTopicBodyEarlyErrors(startPos: number): void { + // If the following token is invalidly `=>`, then throw a human-friendly error + // instead of something like 'Unexpected token, expected ";"'. + // For example, `x => x |> y => #` (assuming `#` is the topic reference) + // groups into `x => (x |> y) => #`, + // and `(x |> y) => #` is an invalid arrow function. + // This is because smart-mix `|>` has tighter precedence than `=>`. + if (this.match(tt.arrow)) { + throw this.raise(this.state.start, Errors.PipelineBodyNoArrow); + } + + // A topic-style smart-mix pipe body must use the topic reference at least once. + else if (!this.topicReferenceWasUsedInCurrentContext()) { + this.raise(startPos, Errors.PipelineTopicUnused); + } + } + + // Enable topic references from outer contexts within Hack-style pipe bodies. + // The function modifies the parser's topic-context state to enable or disable + // the use of topic references. + // The function then calls a callback, then resets the parser + // to the old topic-context state that it had before the function was called. + + withTopicBindingContext(callback: () => T): T { const outerContextTopicState = this.state.topicContext; this.state.topicContext = { // Enable the use of the primary topic reference. @@ -2605,26 +2763,37 @@ export default class ExpressionParser extends LValParser { } } - // Disable topic references from outer contexts within syntax constructs + // This helper method is used only with the deprecated smart-mix pipe proposal. + // Disables topic references from outer contexts within syntax constructs // such as the bodies of iteration statements. // The function modifies the parser's topic-context state to enable or disable // the use of topic references with the smartPipelines plugin. They then run a // callback, then they reset the parser to the old topic-context state that it // had before the function was called. - withTopicForbiddingContext(callback: () => T): T { - const outerContextTopicState = this.state.topicContext; - this.state.topicContext = { - // Disable the use of the primary topic reference. - maxNumOfResolvableTopics: 0, - // Hide the use of any topic references from outer contexts. - maxTopicIndex: null, - }; + withSmartMixTopicForbiddingContext(callback: () => T): T { + const proposal = this.getPluginOption("pipelineOperator", "proposal"); + if (proposal === "smart") { + // Reset the parser’s topic context only if the smart-mix pipe proposal is active. + const outerContextTopicState = this.state.topicContext; + this.state.topicContext = { + // Disable the use of the primary topic reference. + maxNumOfResolvableTopics: 0, + // Hide the use of any topic references from outer contexts. + maxTopicIndex: null, + }; - try { + try { + return callback(); + } finally { + this.state.topicContext = outerContextTopicState; + } + } else { + // If the pipe proposal is "minimal", "fsharp", or "hack", + // or if no pipe proposal is active, + // then the callback result is returned + // without touching any extra parser state. return callback(); - } finally { - this.state.topicContext = outerContextTopicState; } } @@ -2667,17 +2836,17 @@ export default class ExpressionParser extends LValParser { return callback(); } - // Register the use of a primary topic reference (`#`) within the current - // topic context. + // Register the use of a topic reference within the current + // topic-binding context. registerTopicReference(): void { this.state.topicContext.maxTopicIndex = 0; } - primaryTopicReferenceIsAllowedInCurrentTopicContext(): boolean { + topicReferenceIsAllowedInCurrentContext(): boolean { return this.state.topicContext.maxNumOfResolvableTopics >= 1; } - topicReferenceWasUsedInCurrentTopicContext(): boolean { + topicReferenceWasUsedInCurrentContext(): boolean { return ( this.state.topicContext.maxTopicIndex != null && this.state.topicContext.maxTopicIndex >= 0 diff --git a/packages/babel-parser/src/parser/statement.js b/packages/babel-parser/src/parser/statement.js index 8634676ca4..5e72f7c094 100644 --- a/packages/babel-parser/src/parser/statement.js +++ b/packages/babel-parser/src/parser/statement.js @@ -528,11 +528,12 @@ export default class StatementParser extends ExpressionParser { this.next(); this.state.labels.push(loopLabel); + // Parse the loop body's body. node.body = // For the smartPipelines plugin: Disable topic references from outer // contexts within the loop body. They are permitted in test expressions, // outside of the loop body. - this.withTopicForbiddingContext(() => + this.withSmartMixTopicForbiddingContext(() => // Parse the loop body's body. this.parseStatement("do"), ); @@ -760,15 +761,16 @@ export default class StatementParser extends ExpressionParser { this.scope.enter(SCOPE_OTHER); } + // Parse the catch clause's body. clause.body = // For the smartPipelines plugin: Disable topic references from outer // contexts within the catch clause's body. - this.withTopicForbiddingContext(() => + this.withSmartMixTopicForbiddingContext(() => // Parse the catch clause's body. this.parseBlock(false, false), ); - this.scope.exit(); + this.scope.exit(); node.handler = this.finishNode(clause, "CatchClause"); } @@ -796,11 +798,12 @@ export default class StatementParser extends ExpressionParser { node.test = this.parseHeaderExpression(); this.state.labels.push(loopLabel); + // Parse the loop body. node.body = // For the smartPipelines plugin: // Disable topic references from outer contexts within the loop body. // They are permitted in test expressions, outside of the loop body. - this.withTopicForbiddingContext(() => + this.withSmartMixTopicForbiddingContext(() => // Parse loop body. this.parseStatement("while"), ); @@ -817,12 +820,13 @@ export default class StatementParser extends ExpressionParser { this.next(); node.object = this.parseHeaderExpression(); + // Parse the statement body. node.body = // For the smartPipelines plugin: // Disable topic references from outer contexts within the with statement's body. // They are permitted in function default-parameter expressions, which are // part of the outer context, outside of the with statement's body. - this.withTopicForbiddingContext(() => + this.withSmartMixTopicForbiddingContext(() => // Parse the statement body. this.parseStatement("with"), ); @@ -1010,11 +1014,12 @@ export default class StatementParser extends ExpressionParser { node.update = this.match(tt.parenR) ? null : this.parseExpression(); this.expect(tt.parenR); + // Parse the loop body. node.body = // For the smartPipelines plugin: Disable topic references from outer // contexts within the loop body. They are permitted in test expressions, // outside of the loop body. - this.withTopicForbiddingContext(() => + this.withSmartMixTopicForbiddingContext(() => // Parse the loop body. this.parseStatement("for"), ); @@ -1065,11 +1070,12 @@ export default class StatementParser extends ExpressionParser { : this.parseMaybeAssignAllowIn(); this.expect(tt.parenR); + // Parse the loop body. node.body = // For the smartPipelines plugin: // Disable topic references from outer contexts within the loop body. // They are permitted in test expressions, outside of the loop body. - this.withTopicForbiddingContext(() => + this.withSmartMixTopicForbiddingContext(() => // Parse loop body. this.parseStatement("for"), ); @@ -1177,7 +1183,7 @@ export default class StatementParser extends ExpressionParser { // For the smartPipelines plugin: Disable topic references from outer // contexts within the function body. They are permitted in function // default-parameter expressions, outside of the function body. - this.withTopicForbiddingContext(() => { + this.withSmartMixTopicForbiddingContext(() => { // Parse the function body. this.parseFunctionBodyAndFinish( node, @@ -1293,7 +1299,8 @@ export default class StatementParser extends ExpressionParser { // For the smartPipelines plugin: Disable topic references from outer // contexts within the class body. - this.withTopicForbiddingContext(() => { + this.withSmartMixTopicForbiddingContext(() => { + // Parse the contents within the braces. while (!this.match(tt.braceR)) { if (this.eat(tt.semi)) { if (decorators.length > 0) { diff --git a/packages/babel-parser/src/plugin-utils.js b/packages/babel-parser/src/plugin-utils.js index 69286d5f4d..73e2a63488 100644 --- a/packages/babel-parser/src/plugin-utils.js +++ b/packages/babel-parser/src/plugin-utils.js @@ -38,7 +38,8 @@ export function getPluginOption( return null; } -const PIPELINE_PROPOSALS = ["minimal", "smart", "fsharp"]; +const PIPELINE_PROPOSALS = ["minimal", "fsharp", "hack", "smart"]; +const TOPIC_TOKENS = ["%", "#"]; const RECORD_AND_TUPLE_SYNTAX_TYPES = ["hash", "bar"]; export function validatePlugins(plugins: PluginList) { @@ -74,16 +75,45 @@ export function validatePlugins(plugins: PluginList) { throw new Error("Cannot combine placeholders and v8intrinsic plugins."); } - if ( - hasPlugin(plugins, "pipelineOperator") && - !PIPELINE_PROPOSALS.includes( - getPluginOption(plugins, "pipelineOperator", "proposal"), - ) - ) { - throw new Error( - "'pipelineOperator' requires 'proposal' option whose value should be one of: " + - PIPELINE_PROPOSALS.map(p => `'${p}'`).join(", "), - ); + if (hasPlugin(plugins, "pipelineOperator")) { + const proposal = getPluginOption(plugins, "pipelineOperator", "proposal"); + + if (!PIPELINE_PROPOSALS.includes(proposal)) { + const proposalList = PIPELINE_PROPOSALS.map(p => `"${p}"`).join(", "); + throw new Error( + `"pipelineOperator" requires "proposal" option whose value must be one of: ${proposalList}.`, + ); + } + + const tupleSyntaxIsHash = + hasPlugin(plugins, "recordAndTuple") && + getPluginOption(plugins, "recordAndTuple", "syntaxType") === "hash"; + + if (proposal === "hack") { + const topicToken = getPluginOption( + plugins, + "pipelineOperator", + "topicToken", + ); + + if (!TOPIC_TOKENS.includes(topicToken)) { + const tokenList = TOPIC_TOKENS.map(t => `"${t}"`).join(", "); + + throw new Error( + `"pipelineOperator" in "proposal": "hack" mode also requires a "topicToken" option whose value must be one of: ${tokenList}.`, + ); + } + + if (topicToken === "#" && tupleSyntaxIsHash) { + throw new Error( + 'Plugin conflict between `["pipelineOperator", { proposal: "hack", topicToken: "#" }]` and `["recordAndtuple", { syntaxType: "hash"}]`.', + ); + } + } else if (proposal === "smart" && tupleSyntaxIsHash) { + throw new Error( + 'Plugin conflict between `["pipelineOperator", { proposal: "smart" }]` and `["recordAndtuple", { syntaxType: "hash"}]`.', + ); + } } if (hasPlugin(plugins, "moduleAttributes")) { diff --git a/packages/babel-parser/src/tokenizer/state.js b/packages/babel-parser/src/tokenizer/state.js index 35ddf50a8c..bae8e6d9b9 100644 --- a/packages/babel-parser/src/tokenizer/state.js +++ b/packages/babel-parser/src/tokenizer/state.js @@ -64,7 +64,6 @@ export default class State { // Flags to track maybeInArrowParameters: boolean = false; - inPipeline: boolean = false; inType: boolean = false; noAnonFunctionType: boolean = false; inPropertyName: boolean = false; @@ -72,13 +71,13 @@ export default class State { isAmbientContext: boolean = false; inAbstractClass: boolean = false; - // For the smartPipelines plugin: + // For the Hack-style pipelines plugin topicContext: TopicContextState = { maxNumOfResolvableTopics: 0, maxTopicIndex: null, }; - // For the F# plugin + // For the F#-style pipelines plugin soloAwait: boolean = false; inFSharpPipelineDirectBody: boolean = false; diff --git a/packages/babel-parser/src/types.js b/packages/babel-parser/src/types.js index 4cdee9d296..e747abc6b5 100644 --- a/packages/babel-parser/src/types.js +++ b/packages/babel-parser/src/types.js @@ -631,7 +631,13 @@ export type ParenthesizedExpression = NodeBase & { expression: Expression, }; -// Pipelines +// Hack pipe operator + +export type TopicReference = NodeBase & { + type: "TopicReference", +}; + +// Smart-mix pipe operator export type PipelineBody = NodeBase & { type: "PipelineBody", @@ -663,6 +669,10 @@ export type PipelineStyle = | "PipelineBareAwaitedFunction" | "PipelineTopicExpression"; +export type PipelinePrimaryTopicReference = NodeBase & { + type: "PipelinePrimaryTopicReference", +}; + // Template Literals export type TemplateLiteral = NodeBase & { diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-fsharp-arrow-and-array-in-body-with-operator/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/fsharp-proposal-arrow-and-array-in-body-with-operator/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-fsharp-arrow-and-array-in-body-with-operator/input.js rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/fsharp-proposal-arrow-and-array-in-body-with-operator/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-fsharp-arrow-and-array-in-body-with-operator/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/fsharp-proposal-arrow-and-array-in-body-with-operator/options.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-fsharp-arrow-and-array-in-body-with-operator/options.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/fsharp-proposal-arrow-and-array-in-body-with-operator/options.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-fsharp-arrow-and-array-in-body-with-operator/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/fsharp-proposal-arrow-and-array-in-body-with-operator/output.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-fsharp-arrow-and-array-in-body-with-operator/output.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/fsharp-proposal-arrow-and-array-in-body-with-operator/output.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-fsharp-arrow-and-array-in-body/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/fsharp-proposal-arrow-and-array-in-body/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-fsharp-arrow-and-array-in-body/input.js rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/fsharp-proposal-arrow-and-array-in-body/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-fsharp-arrow-and-array-in-body/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/fsharp-proposal-arrow-and-array-in-body/options.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-fsharp-arrow-and-array-in-body/options.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/fsharp-proposal-arrow-and-array-in-body/options.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-fsharp-arrow-and-array-in-body/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/fsharp-proposal-arrow-and-array-in-body/output.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-fsharp-arrow-and-array-in-body/output.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/fsharp-proposal-arrow-and-array-in-body/output.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-fsharp-arrow-and-assignment-in-body/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/fsharp-proposal-arrow-and-assignment-in-body/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-fsharp-arrow-and-assignment-in-body/input.js rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/fsharp-proposal-arrow-and-assignment-in-body/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-fsharp-arrow-and-assignment-in-body/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/fsharp-proposal-arrow-and-assignment-in-body/options.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-fsharp-arrow-and-assignment-in-body/options.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/fsharp-proposal-arrow-and-assignment-in-body/options.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-fsharp-arrow-and-assignment-in-body/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/fsharp-proposal-arrow-and-assignment-in-body/output.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-fsharp-arrow-and-assignment-in-body/output.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/fsharp-proposal-arrow-and-assignment-in-body/output.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-fsharp-arrow-and-object-in-body-with-operator/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/fsharp-proposal-arrow-and-object-in-body-with-operator/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-fsharp-arrow-and-object-in-body-with-operator/input.js rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/fsharp-proposal-arrow-and-object-in-body-with-operator/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-fsharp-arrow-and-object-in-body-with-operator/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/fsharp-proposal-arrow-and-object-in-body-with-operator/options.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-fsharp-arrow-and-object-in-body-with-operator/options.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/fsharp-proposal-arrow-and-object-in-body-with-operator/options.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-fsharp-arrow-and-object-in-body-with-operator/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/fsharp-proposal-arrow-and-object-in-body-with-operator/output.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-fsharp-arrow-and-object-in-body-with-operator/output.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/fsharp-proposal-arrow-and-object-in-body-with-operator/output.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-fsharp-arrow-and-object-in-body/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/fsharp-proposal-arrow-and-object-in-body/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-fsharp-arrow-and-object-in-body/input.js rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/fsharp-proposal-arrow-and-object-in-body/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-fsharp-arrow-and-object-in-body/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/fsharp-proposal-arrow-and-object-in-body/options.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-fsharp-arrow-and-object-in-body/options.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/fsharp-proposal-arrow-and-object-in-body/options.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-fsharp-arrow-and-object-in-body/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/fsharp-proposal-arrow-and-object-in-body/output.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-fsharp-arrow-and-object-in-body/output.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/fsharp-proposal-arrow-and-object-in-body/output.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-fsharp-arrow-at-head-indented/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/fsharp-proposal-arrow-at-head-indented/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-fsharp-arrow-at-head-indented/input.js rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/fsharp-proposal-arrow-at-head-indented/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-fsharp-arrow-at-head-indented/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/fsharp-proposal-arrow-at-head-indented/options.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-fsharp-arrow-at-head-indented/options.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/fsharp-proposal-arrow-at-head-indented/options.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-fsharp-arrow-at-head-indented/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/fsharp-proposal-arrow-at-head-indented/output.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-fsharp-arrow-at-head-indented/output.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/fsharp-proposal-arrow-at-head-indented/output.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-fsharp-arrow-at-head/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/fsharp-proposal-arrow-at-head/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-fsharp-arrow-at-head/input.js rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/fsharp-proposal-arrow-at-head/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-fsharp-arrow-at-head/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/fsharp-proposal-arrow-at-head/options.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-fsharp-arrow-at-head/options.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/fsharp-proposal-arrow-at-head/options.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-fsharp-arrow-at-head/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/fsharp-proposal-arrow-at-head/output.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-fsharp-arrow-at-head/output.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/fsharp-proposal-arrow-at-head/output.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-fsharp-arrow-in-body-alt-parens/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/fsharp-proposal-arrow-in-body-alt-parens/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-fsharp-arrow-in-body-alt-parens/input.js rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/fsharp-proposal-arrow-in-body-alt-parens/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-fsharp-arrow-in-body-alt-parens/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/fsharp-proposal-arrow-in-body-alt-parens/options.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-fsharp-arrow-in-body-alt-parens/options.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/fsharp-proposal-arrow-in-body-alt-parens/options.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-fsharp-arrow-in-body-alt-parens/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/fsharp-proposal-arrow-in-body-alt-parens/output.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-fsharp-arrow-in-body-alt-parens/output.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/fsharp-proposal-arrow-in-body-alt-parens/output.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-fsharp-arrow-in-body-no-parens-indented-with-arg-parens/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/fsharp-proposal-arrow-in-body-no-parens-indented-with-arg-parens/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-fsharp-arrow-in-body-no-parens-indented-with-arg-parens/input.js rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/fsharp-proposal-arrow-in-body-no-parens-indented-with-arg-parens/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-fsharp-arrow-in-body-no-parens-indented-with-arg-parens/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/fsharp-proposal-arrow-in-body-no-parens-indented-with-arg-parens/options.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-fsharp-arrow-in-body-no-parens-indented-with-arg-parens/options.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/fsharp-proposal-arrow-in-body-no-parens-indented-with-arg-parens/options.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-fsharp-arrow-in-body-no-parens-indented-with-arg-parens/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/fsharp-proposal-arrow-in-body-no-parens-indented-with-arg-parens/output.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-fsharp-arrow-in-body-no-parens-indented-with-arg-parens/output.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/fsharp-proposal-arrow-in-body-no-parens-indented-with-arg-parens/output.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-fsharp-arrow-in-body-no-parens-indented/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/fsharp-proposal-arrow-in-body-no-parens-indented/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-fsharp-arrow-in-body-no-parens-indented/input.js rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/fsharp-proposal-arrow-in-body-no-parens-indented/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-fsharp-arrow-in-body-no-parens-indented/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/fsharp-proposal-arrow-in-body-no-parens-indented/options.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-fsharp-arrow-in-body-no-parens-indented/options.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/fsharp-proposal-arrow-in-body-no-parens-indented/options.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-fsharp-arrow-in-body-no-parens-indented/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/fsharp-proposal-arrow-in-body-no-parens-indented/output.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-fsharp-arrow-in-body-no-parens-indented/output.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/fsharp-proposal-arrow-in-body-no-parens-indented/output.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-fsharp-arrow-in-body-no-parens-with-arg-parens/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/fsharp-proposal-arrow-in-body-no-parens-with-arg-parens/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-fsharp-arrow-in-body-no-parens-with-arg-parens/input.js rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/fsharp-proposal-arrow-in-body-no-parens-with-arg-parens/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-fsharp-arrow-in-body-no-parens-with-arg-parens/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/fsharp-proposal-arrow-in-body-no-parens-with-arg-parens/options.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-fsharp-arrow-in-body-no-parens-with-arg-parens/options.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/fsharp-proposal-arrow-in-body-no-parens-with-arg-parens/options.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-fsharp-arrow-in-body-no-parens-with-arg-parens/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/fsharp-proposal-arrow-in-body-no-parens-with-arg-parens/output.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-fsharp-arrow-in-body-no-parens-with-arg-parens/output.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/fsharp-proposal-arrow-in-body-no-parens-with-arg-parens/output.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-fsharp-arrow-in-body-no-parens/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/fsharp-proposal-arrow-in-body-no-parens/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-fsharp-arrow-in-body-no-parens/input.js rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/fsharp-proposal-arrow-in-body-no-parens/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-fsharp-arrow-in-body-no-parens/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/fsharp-proposal-arrow-in-body-no-parens/options.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-fsharp-arrow-in-body-no-parens/options.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/fsharp-proposal-arrow-in-body-no-parens/options.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-fsharp-arrow-in-body-no-parens/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/fsharp-proposal-arrow-in-body-no-parens/output.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-fsharp-arrow-in-body-no-parens/output.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/fsharp-proposal-arrow-in-body-no-parens/output.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-fsharp-await-end/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/fsharp-proposal-await-end/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-fsharp-await-end/input.js rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/fsharp-proposal-await-end/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-fsharp-await-end/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/fsharp-proposal-await-end/options.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-fsharp-await-end/options.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/fsharp-proposal-await-end/options.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-fsharp-await-end/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/fsharp-proposal-await-end/output.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-fsharp-await-end/output.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/fsharp-proposal-await-end/output.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-fsharp-await/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/fsharp-proposal-await/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-fsharp-await/input.js rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/fsharp-proposal-await/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-fsharp-await/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/fsharp-proposal-await/options.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-fsharp-await/options.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/fsharp-proposal-await/options.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-fsharp-await/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/fsharp-proposal-await/output.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-fsharp-await/output.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/fsharp-proposal-await/output.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-fsharp-ban-await-f/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/fsharp-proposal-ban-await-f/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-fsharp-ban-await-f/input.js rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/fsharp-proposal-ban-await-f/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-fsharp-ban-await-f/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/fsharp-proposal-ban-await-f/options.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-fsharp-ban-await-f/options.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/fsharp-proposal-ban-await-f/options.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-fsharp-ban-await-f/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/fsharp-proposal-ban-await-f/output.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-fsharp-ban-await-f/output.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/fsharp-proposal-ban-await-f/output.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/no-plugin/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/fsharp-proposal-base/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/no-plugin/input.js rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/fsharp-proposal-base/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-fsharp-base/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/fsharp-proposal-base/options.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-fsharp-base/options.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/fsharp-proposal-base/options.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-fsharp-base/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/fsharp-proposal-base/output.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-fsharp-base/output.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/fsharp-proposal-base/output.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-fsharp-chain/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/fsharp-proposal-chain/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-fsharp-chain/input.js rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/fsharp-proposal-chain/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-fsharp-chain/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/fsharp-proposal-chain/options.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-fsharp-chain/options.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/fsharp-proposal-chain/options.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-fsharp-chain/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/fsharp-proposal-chain/output.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-fsharp-chain/output.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/fsharp-proposal-chain/output.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-fsharp-invalid-primary-topic/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/fsharp-proposal-invalid-topic/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-fsharp-invalid-primary-topic/input.js rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/fsharp-proposal-invalid-topic/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/fsharp-proposal-invalid-topic/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/fsharp-proposal-invalid-topic/options.json new file mode 100644 index 0000000000..34afbcd4c3 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/fsharp-proposal-invalid-topic/options.json @@ -0,0 +1,4 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "fsharp" }]], + "throws": "Topic reference is used, but the pipelineOperator plugin was not passed a \"proposal\": \"hack\" or \"smart\" option. (1:5)" +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-addition,-single-line-arrow-function,-topic-reference-first/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-addition-with-topic-first/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-addition,-single-line-arrow-function,-topic-reference-first/input.js rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-addition-with-topic-first/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-addition-with-topic-first/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-addition-with-topic-first/options.json new file mode 100644 index 0000000000..be2b04c70d --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-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-hash-proposal-addition-with-topic-first/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-addition-with-topic-first/output.json new file mode 100644 index 0000000000..4af6702b93 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-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/proposal-smart-topic-style,-addition,-single-line-arrow-function,-topic-reference-last/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-addition-with-topic-last/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-addition,-single-line-arrow-function,-topic-reference-last/input.js rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-addition-with-topic-last/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-addition-with-topic-last/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-addition-with-topic-last/options.json new file mode 100644 index 0000000000..be2b04c70d --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-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-hash-proposal-addition-with-topic-last/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-addition-with-topic-last/output.json new file mode 100644 index 0000000000..09d48e0129 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-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/proposal-smart-error,-topic-style,-no-topic-reference,-addition/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-addition-without-topic/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-no-topic-reference,-addition/input.js rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-addition-without-topic/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-addition-without-topic/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-addition-without-topic/options.json new file mode 100644 index 0000000000..be2b04c70d --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-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-hash-proposal-addition-without-topic/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-addition-without-topic/output.json new file mode 100644 index 0000000000..6565ae6d9a --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-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/proposal-smart-topic-style,-parenthesized-single-line-arrow-function,-with-empty-parameter-list-and-bare-addition-body/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-arrow-function-parenthesized/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-parenthesized-single-line-arrow-function,-with-empty-parameter-list-and-bare-addition-body/input.js rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-arrow-function-parenthesized/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-arrow-function-parenthesized/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-arrow-function-parenthesized/options.json new file mode 100644 index 0000000000..be2b04c70d --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-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-hash-proposal-arrow-function-parenthesized/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-arrow-function-parenthesized/output.json new file mode 100644 index 0000000000..3bb77cf7bf --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-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/proposal-smart-error,-topic-style,-unparenthesized-arrow-function-with-bare-parameter-and-bare-body/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-arrow-function-unparenthesized/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-unparenthesized-arrow-function-with-bare-parameter-and-bare-body/input.js rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-arrow-function-unparenthesized/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-arrow-function-unparenthesized/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-arrow-function-unparenthesized/options.json new file mode 100644 index 0000000000..b58a56adfd --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-arrow-function-unparenthesized/options.json @@ -0,0 +1,12 @@ +{ + "plugins": [ + [ + "pipelineOperator", + { + "proposal": "hack", + "topicToken": "#" + } + ] + ], + "throws": "Unexpected => after pipeline body; any => expression acting as Hack-style pipe body must be parenthesized due to its loose operator precedence. (1:8)" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-assignment-logical-and/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-assignment-logical-and/input.js new file mode 100644 index 0000000000..d204179f2f --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-assignment-logical-and/input.js @@ -0,0 +1 @@ +value |> x &&= # diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-assignment-logical-and/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-assignment-logical-and/options.json new file mode 100644 index 0000000000..8b17059d1e --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-assignment-logical-and/options.json @@ -0,0 +1,12 @@ +{ + "plugins": [ + [ + "pipelineOperator", + { + "proposal": "hack", + "topicToken": "#" + } + ] + ], + "throws": "Unexpected &&= after pipeline body; any &&= expression acting as Hack-style pipe body must be parenthesized due to its loose operator precedence. (1:11)" +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-assignment-normal/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-assignment-normal/input.js new file mode 100644 index 0000000000..29d31a0704 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-assignment-normal/input.js @@ -0,0 +1 @@ +value |> [x, y] = # diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-assignment-normal/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-assignment-normal/options.json new file mode 100644 index 0000000000..44fc8ec437 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-assignment-normal/options.json @@ -0,0 +1,12 @@ +{ + "plugins": [ + [ + "pipelineOperator", + { + "proposal": "hack", + "topicToken": "#" + } + ] + ], + "throws": "Unexpected = after pipeline body; any = expression acting as Hack-style pipe body must be parenthesized due to its loose operator precedence. (1:16)" +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-assignment-plus/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-assignment-plus/input.js new file mode 100644 index 0000000000..c440a3031a --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-assignment-plus/input.js @@ -0,0 +1 @@ +value |> x += # diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-assignment-plus/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-assignment-plus/options.json new file mode 100644 index 0000000000..daec111d11 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-assignment-plus/options.json @@ -0,0 +1,12 @@ +{ + "plugins": [ + [ + "pipelineOperator", + { + "proposal": "hack", + "topicToken": "#" + } + ] + ], + "throws": "Unexpected += after pipeline body; any += expression acting as Hack-style pipe body must be parenthesized due to its loose operator precedence. (1:11)" +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-async-await/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-async-await/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-async-await/input.js rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-async-await/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-async-await/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-async-await/options.json new file mode 100644 index 0000000000..be2b04c70d --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-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-hash-proposal-async-await/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-async-await/output.json new file mode 100644 index 0000000000..ce3d60256e --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-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-hash-proposal-class-expression-with-decorators/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-class-expression-with-decorators/input.js new file mode 100644 index 0000000000..a7d86a1081 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-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-hash-proposal-class-expression-with-decorators/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-class-expression-with-decorators/options.json new file mode 100644 index 0000000000..1befdf56f0 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-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-hash-proposal-class-expression-with-decorators/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-class-expression-with-decorators/output.json new file mode 100644 index 0000000000..5f6fe6d44c --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-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-hash-proposal-class-expression-with-private-property/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-class-expression-with-private-property/input.js new file mode 100644 index 0000000000..12feae9c61 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-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-hash-proposal-class-expression-with-private-property/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-class-expression-with-private-property/options.json new file mode 100644 index 0000000000..ee4a6e09fb --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-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-hash-proposal-class-expression-with-private-property/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-class-expression-with-private-property/output.json new file mode 100644 index 0000000000..f6c7e7a65d --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-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/proposal-smart-error,-unbound-topic,-inner-class-in-pipeline-body/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-class-expression-without-private-property/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-unbound-topic,-inner-class-in-pipeline-body/input.js rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-class-expression-without-private-property/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-class-expression-without-private-property/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-class-expression-without-private-property/options.json new file mode 100644 index 0000000000..be2b04c70d --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-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-hash-proposal-class-expression-without-private-property/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-class-expression-without-private-property/output.json new file mode 100644 index 0000000000..201caee151 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-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/proposal-smart-error,-sequence-style,-body-with-topic-reference-pair-then-end/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-comma-topic-pair/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-sequence-style,-body-with-topic-reference-pair-then-end/input.js rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-comma-topic-pair/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-comma-topic-pair/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-comma-topic-pair/options.json new file mode 100644 index 0000000000..be2b04c70d --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-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-hash-proposal-comma-topic-pair/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-comma-topic-pair/output.json new file mode 100644 index 0000000000..12c0cb49ed --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-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/proposal-smart-error,-topic-style,-computed,-no-topic-reference/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-computed-no-topic/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-computed,-no-topic-reference/input.js rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-computed-no-topic/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-computed-no-topic/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-computed-no-topic/options.json new file mode 100644 index 0000000000..be2b04c70d --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-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-hash-proposal-computed-no-topic/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-computed-no-topic/output.json new file mode 100644 index 0000000000..3959a09863 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-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-hash-proposal-division/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-division/input.js new file mode 100644 index 0000000000..c75cfa54e7 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-division/input.js @@ -0,0 +1 @@ +value |> # / 2 diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-division/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-division/options.json new file mode 100644 index 0000000000..be2b04c70d --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-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-hash-proposal-division/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-division/output.json new file mode 100644 index 0000000000..0c5a673e7b --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-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/proposal-smart-error,-topic-style,-unbound-topic,-do-expression,-do-while-loop,-outer-topic-reference-in-loop-body/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-do-transform-do-while-loop-and-topic-in-loop-body/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-unbound-topic,-do-expression,-do-while-loop,-outer-topic-reference-in-loop-body/input.js rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-do-transform-do-while-loop-and-topic-in-loop-body/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-do-transform-do-while-loop-and-topic-in-loop-body/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-do-transform-do-while-loop-and-topic-in-loop-body/options.json new file mode 100644 index 0000000000..d567021d4b --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-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-hash-proposal-do-transform-do-while-loop-and-topic-in-loop-body/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-do-transform-do-while-loop-and-topic-in-loop-body/output.json new file mode 100644 index 0000000000..e14ccc735f --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-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/proposal-smart-topic-style,-do-expression,-do-while-loop,-outer-topic-reference-in-loop-head/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-do-transform-do-while-loop-and-topic-in-loop-head/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-do-expression,-do-while-loop,-outer-topic-reference-in-loop-head/input.js rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-do-transform-do-while-loop-and-topic-in-loop-head/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-do-transform-do-while-loop-and-topic-in-loop-head/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-do-transform-do-while-loop-and-topic-in-loop-head/options.json new file mode 100644 index 0000000000..d567021d4b --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-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-hash-proposal-do-transform-do-while-loop-and-topic-in-loop-head/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-do-transform-do-while-loop-and-topic-in-loop-head/output.json new file mode 100644 index 0000000000..48f0ec3c67 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-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/proposal-smart-error,-topic-style,-unbound-topic,-do-expression,-for-await-of-loop,-outer-topic-reference-in-loop-body/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-do-transform-for-await-of-loop-and-topic-in-loop-body/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-unbound-topic,-do-expression,-for-await-of-loop,-outer-topic-reference-in-loop-body/input.js rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-do-transform-for-await-of-loop-and-topic-in-loop-body/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-do-transform-for-await-of-loop-and-topic-in-loop-body/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-do-transform-for-await-of-loop-and-topic-in-loop-body/options.json new file mode 100644 index 0000000000..b74308c100 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-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-hash-proposal-do-transform-for-await-of-loop-and-topic-in-loop-body/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-do-transform-for-await-of-loop-and-topic-in-loop-body/output.json new file mode 100644 index 0000000000..8fbe9b326e --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-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/proposal-smart-topic-style,-do-expression,-for-await-of-loop,-outer-topic-reference-in-loop-head/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-do-transform-for-await-of-loop-and-topic-in-loop-head/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-do-expression,-for-await-of-loop,-outer-topic-reference-in-loop-head/input.js rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-do-transform-for-await-of-loop-and-topic-in-loop-head/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-do-transform-for-await-of-loop-and-topic-in-loop-head/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-do-transform-for-await-of-loop-and-topic-in-loop-head/options.json new file mode 100644 index 0000000000..b74308c100 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-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-hash-proposal-do-transform-for-await-of-loop-and-topic-in-loop-head/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-do-transform-for-await-of-loop-and-topic-in-loop-head/output.json new file mode 100644 index 0000000000..bdc716f071 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-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-hash-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-hash-proposal-do-transform-for-await-of-loop-transform-and-topic-in-loop-body/input.js new file mode 100644 index 0000000000..261f95e4c7 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-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-hash-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-hash-proposal-do-transform-for-await-of-loop-transform-and-topic-in-loop-body/options.json new file mode 100644 index 0000000000..5ee81853ee --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-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-hash-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-hash-proposal-do-transform-for-await-of-loop-transform-and-topic-in-loop-body/output.json new file mode 100644 index 0000000000..8fbe9b326e --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-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-hash-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-hash-proposal-do-transform-for-await-of-loop-transform-and-topic-in-loop-head/input.js new file mode 100644 index 0000000000..197761dcd7 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-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-hash-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-hash-proposal-do-transform-for-await-of-loop-transform-and-topic-in-loop-head/options.json new file mode 100644 index 0000000000..5ee81853ee --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-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-hash-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-hash-proposal-do-transform-for-await-of-loop-transform-and-topic-in-loop-head/output.json new file mode 100644 index 0000000000..bdc716f071 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-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/proposal-smart-error,-topic-style,-unbound-topic,-do-expression,-for-classic-loop,-outer-topic-reference-in-loop-body/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-do-transform-for-classic-loop-and-topic-in-loop-body/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-unbound-topic,-do-expression,-for-classic-loop,-outer-topic-reference-in-loop-body/input.js rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-do-transform-for-classic-loop-and-topic-in-loop-body/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-do-transform-for-classic-loop-and-topic-in-loop-body/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-do-transform-for-classic-loop-and-topic-in-loop-body/options.json new file mode 100644 index 0000000000..d567021d4b --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-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-hash-proposal-do-transform-for-classic-loop-and-topic-in-loop-body/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-do-transform-for-classic-loop-and-topic-in-loop-body/output.json new file mode 100644 index 0000000000..9a2cfce898 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-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/proposal-smart-topic-style,-do-expression,-for-classic-loop,-outer-topic-reference-in-loop-head/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-do-transform-for-classic-loop-and-topic-in-loop-head/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-do-expression,-for-classic-loop,-outer-topic-reference-in-loop-head/input.js rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-do-transform-for-classic-loop-and-topic-in-loop-head/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-do-transform-for-classic-loop-and-topic-in-loop-head/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-do-transform-for-classic-loop-and-topic-in-loop-head/options.json new file mode 100644 index 0000000000..d567021d4b --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-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-hash-proposal-do-transform-for-classic-loop-and-topic-in-loop-head/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-do-transform-for-classic-loop-and-topic-in-loop-head/output.json new file mode 100644 index 0000000000..7df2f583e2 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-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/proposal-smart-error,-topic-style,-unbound-topic,-do-expression,-for-in-loop,-outer-topic-reference-in-loop-body/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-do-transform-for-in-loop-and-topic-in-loop-body/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-unbound-topic,-do-expression,-for-in-loop,-outer-topic-reference-in-loop-body/input.js rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-do-transform-for-in-loop-and-topic-in-loop-body/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-do-transform-for-in-loop-and-topic-in-loop-body/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-do-transform-for-in-loop-and-topic-in-loop-body/options.json new file mode 100644 index 0000000000..d567021d4b --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-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-hash-proposal-do-transform-for-in-loop-and-topic-in-loop-body/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-do-transform-for-in-loop-and-topic-in-loop-body/output.json new file mode 100644 index 0000000000..3c3dc20a51 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-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/proposal-smart-topic-style,-do-expression,-for-in-loop,-outer-topic-reference-in-loop-head/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-do-transform-for-in-loop-and-topic-in-loop-head/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-do-expression,-for-in-loop,-outer-topic-reference-in-loop-head/input.js rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-do-transform-for-in-loop-and-topic-in-loop-head/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-do-transform-for-in-loop-and-topic-in-loop-head/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-do-transform-for-in-loop-and-topic-in-loop-head/options.json new file mode 100644 index 0000000000..d567021d4b --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-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-hash-proposal-do-transform-for-in-loop-and-topic-in-loop-head/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-do-transform-for-in-loop-and-topic-in-loop-head/output.json new file mode 100644 index 0000000000..230eafa0e7 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-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/proposal-smart-error,-topic-style,-unbound-topic,-do-expression,-for-of-loop,-outer-topic-reference-in-loop-body/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-do-transform-for-of-loop-and-topic-in-loop-body/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-unbound-topic,-do-expression,-for-of-loop,-outer-topic-reference-in-loop-body/input.js rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-do-transform-for-of-loop-and-topic-in-loop-body/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-do-transform-for-of-loop-and-topic-in-loop-body/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-do-transform-for-of-loop-and-topic-in-loop-body/options.json new file mode 100644 index 0000000000..d567021d4b --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-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-hash-proposal-do-transform-for-of-loop-and-topic-in-loop-body/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-do-transform-for-of-loop-and-topic-in-loop-body/output.json new file mode 100644 index 0000000000..33829839a9 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-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/proposal-smart-topic-style,-do-expression,-for-of-loop,-outer-topic-reference-in-loop-head/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-do-transform-for-of-loop-and-topic-in-loop-head/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-do-expression,-for-of-loop,-outer-topic-reference-in-loop-head/input.js rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-do-transform-for-of-loop-and-topic-in-loop-head/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-do-transform-for-of-loop-and-topic-in-loop-head/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-do-transform-for-of-loop-and-topic-in-loop-head/options.json new file mode 100644 index 0000000000..d567021d4b --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-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-hash-proposal-do-transform-for-of-loop-and-topic-in-loop-head/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-do-transform-for-of-loop-and-topic-in-loop-head/output.json new file mode 100644 index 0000000000..8edea4e4e6 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-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/proposal-smart-topic-style,-do-expression,-if-statement,-outer-topic-reference-in-else-body/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-do-transform-if-statement-and-topic-in-else-body/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-do-expression,-if-statement,-outer-topic-reference-in-else-body/input.js rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-do-transform-if-statement-and-topic-in-else-body/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-do-transform-if-statement-and-topic-in-else-body/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-do-transform-if-statement-and-topic-in-else-body/options.json new file mode 100644 index 0000000000..d567021d4b --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-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-hash-proposal-do-transform-if-statement-and-topic-in-else-body/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-do-transform-if-statement-and-topic-in-else-body/output.json new file mode 100644 index 0000000000..f1d076f6b5 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-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/proposal-smart-topic-style,-do-expression,-if-statement,-outer-topic-reference-in-else-if-body/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-do-transform-if-statement-and-topic-in-else-if-body/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-do-expression,-if-statement,-outer-topic-reference-in-else-if-body/input.js rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-do-transform-if-statement-and-topic-in-else-if-body/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-do-transform-if-statement-and-topic-in-else-if-body/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-do-transform-if-statement-and-topic-in-else-if-body/options.json new file mode 100644 index 0000000000..d567021d4b --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-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-hash-proposal-do-transform-if-statement-and-topic-in-else-if-body/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-do-transform-if-statement-and-topic-in-else-if-body/output.json new file mode 100644 index 0000000000..1543c9a557 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-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/proposal-smart-topic-style,-do-expression,-if-statement,-outer-topic-reference-in-if-body/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-do-transform-if-statement-and-topic-in-if-body/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-do-expression,-if-statement,-outer-topic-reference-in-if-body/input.js rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-do-transform-if-statement-and-topic-in-if-body/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-do-transform-if-statement-and-topic-in-if-body/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-do-transform-if-statement-and-topic-in-if-body/options.json new file mode 100644 index 0000000000..d567021d4b --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-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-hash-proposal-do-transform-if-statement-and-topic-in-if-body/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-do-transform-if-statement-and-topic-in-if-body/output.json new file mode 100644 index 0000000000..a98abe3fb6 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-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/proposal-smart-topic-style,-do-expression,-if-statement,-outer-topic-reference-in-if-head/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-do-transform-if-statement-and-topic-in-if-head/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-do-expression,-if-statement,-outer-topic-reference-in-if-head/input.js rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-do-transform-if-statement-and-topic-in-if-head/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-do-transform-if-statement-and-topic-in-if-head/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-do-transform-if-statement-and-topic-in-if-head/options.json new file mode 100644 index 0000000000..d567021d4b --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-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-hash-proposal-do-transform-if-statement-and-topic-in-if-head/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-do-transform-if-statement-and-topic-in-if-head/output.json new file mode 100644 index 0000000000..eb2faae4ae --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-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/proposal-smart-topic-style,-do-expression,-switch-statement,-outer-topic-reference-in-switch-body/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-do-transform-switch-statement-and-topic-in-switch-body/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-do-expression,-switch-statement,-outer-topic-reference-in-switch-body/input.js rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-do-transform-switch-statement-and-topic-in-switch-body/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-do-transform-switch-statement-and-topic-in-switch-body/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-do-transform-switch-statement-and-topic-in-switch-body/options.json new file mode 100644 index 0000000000..d567021d4b --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-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-hash-proposal-do-transform-switch-statement-and-topic-in-switch-body/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-do-transform-switch-statement-and-topic-in-switch-body/output.json new file mode 100644 index 0000000000..51c3d25a2e --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-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/proposal-smart-topic-style,-do-expression,-switch-statement,-outer-topic-reference-in-switch-head/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-do-transform-switch-statement-and-topic-in-switch-head/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-do-expression,-switch-statement,-outer-topic-reference-in-switch-head/input.js rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-do-transform-switch-statement-and-topic-in-switch-head/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-do-transform-switch-statement-and-topic-in-switch-head/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-do-transform-switch-statement-and-topic-in-switch-head/options.json new file mode 100644 index 0000000000..d567021d4b --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-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-hash-proposal-do-transform-switch-statement-and-topic-in-switch-head/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-do-transform-switch-statement-and-topic-in-switch-head/output.json new file mode 100644 index 0000000000..769f6ecb57 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-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/proposal-smart-topic-style,-do-expression,-identity/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-do-transform-topic-identity/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-do-expression,-identity/input.js rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-do-transform-topic-identity/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-do-transform-topic-identity/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-do-transform-topic-identity/options.json new file mode 100644 index 0000000000..d567021d4b --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-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-hash-proposal-do-transform-topic-identity/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-do-transform-topic-identity/output.json new file mode 100644 index 0000000000..46172d09d0 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-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/proposal-smart-error,-topic-style,-unbound-topic,-do-expression,-try-statement,-outer-topic-reference-in-catch-clause/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-do-transform-try-catch-finally-statements-and-topic-in-catch-clause/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-unbound-topic,-do-expression,-try-statement,-outer-topic-reference-in-catch-clause/input.js rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-do-transform-try-catch-finally-statements-and-topic-in-catch-clause/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-do-transform-try-catch-finally-statements-and-topic-in-catch-clause/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-do-transform-try-catch-finally-statements-and-topic-in-catch-clause/options.json new file mode 100644 index 0000000000..d567021d4b --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-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-hash-proposal-do-transform-try-catch-finally-statements-and-topic-in-catch-clause/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-do-transform-try-catch-finally-statements-and-topic-in-catch-clause/output.json new file mode 100644 index 0000000000..e9be28defe --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-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/proposal-smart-topic-style,-do-expression,-try-statement,-outer-topic-reference-in-finally-clause-with-catch-and-finally/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-do-transform-try-catch-finally-statements-and-topic-in-finally-clause/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-do-expression,-try-statement,-outer-topic-reference-in-finally-clause-with-catch-and-finally/input.js rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-do-transform-try-catch-finally-statements-and-topic-in-finally-clause/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-do-transform-try-catch-finally-statements-and-topic-in-finally-clause/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-do-transform-try-catch-finally-statements-and-topic-in-finally-clause/options.json new file mode 100644 index 0000000000..d567021d4b --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-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-hash-proposal-do-transform-try-catch-finally-statements-and-topic-in-finally-clause/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-do-transform-try-catch-finally-statements-and-topic-in-finally-clause/output.json new file mode 100644 index 0000000000..da5098b0f2 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-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/proposal-smart-topic-style,-do-expression,-try-statement,-outer-topic-reference-in-try-clause-with-catch-and-finally/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-do-transform-try-catch-finally-statements-and-topic-in-try-clause/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-do-expression,-try-statement,-outer-topic-reference-in-try-clause-with-catch-and-finally/input.js rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-do-transform-try-catch-finally-statements-and-topic-in-try-clause/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-do-transform-try-catch-finally-statements-and-topic-in-try-clause/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-do-transform-try-catch-finally-statements-and-topic-in-try-clause/options.json new file mode 100644 index 0000000000..d567021d4b --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-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-hash-proposal-do-transform-try-catch-finally-statements-and-topic-in-try-clause/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-do-transform-try-catch-finally-statements-and-topic-in-try-clause/output.json new file mode 100644 index 0000000000..06e9624daa --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-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/proposal-smart-topic-style,-do-expression,-try-statement,-outer-topic-reference-in-try-clause-with-catch/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-do-transform-try-catch-statements-topic-in-try-clause/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-do-expression,-try-statement,-outer-topic-reference-in-try-clause-with-catch/input.js rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-do-transform-try-catch-statements-topic-in-try-clause/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-do-transform-try-catch-statements-topic-in-try-clause/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-do-transform-try-catch-statements-topic-in-try-clause/options.json new file mode 100644 index 0000000000..d567021d4b --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-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-hash-proposal-do-transform-try-catch-statements-topic-in-try-clause/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-do-transform-try-catch-statements-topic-in-try-clause/output.json new file mode 100644 index 0000000000..7ce5dce3c2 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-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/proposal-smart-error,-topic-style,-unbound-topic,-do-expression,-while-loop,-outer-topic-reference-in-loop-body/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-do-transform-while-loop-topic-in-loop-body/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-unbound-topic,-do-expression,-while-loop,-outer-topic-reference-in-loop-body/input.js rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-do-transform-while-loop-topic-in-loop-body/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-do-transform-while-loop-topic-in-loop-body/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-do-transform-while-loop-topic-in-loop-body/options.json new file mode 100644 index 0000000000..d567021d4b --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-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-hash-proposal-do-transform-while-loop-topic-in-loop-body/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-do-transform-while-loop-topic-in-loop-body/output.json new file mode 100644 index 0000000000..39d0d923a8 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-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/proposal-smart-topic-style,-do-expression,-while-loop,-outer-topic-reference-in-loop-head/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-do-transform-while-loop-topic-in-loop-head/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-do-expression,-while-loop,-outer-topic-reference-in-loop-head/input.js rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-do-transform-while-loop-topic-in-loop-head/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-do-transform-while-loop-topic-in-loop-head/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-do-transform-while-loop-topic-in-loop-head/options.json new file mode 100644 index 0000000000..d567021d4b --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-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-hash-proposal-do-transform-while-loop-topic-in-loop-head/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-do-transform-while-loop-topic-in-loop-head/output.json new file mode 100644 index 0000000000..56f5af6523 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-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/proposal-smart-error,-topic-style,-unbound-topic,-do-expression,-with-statement,-outer-topic-reference-in-with-body/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-do-transform-with-block-topic-in-body/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-unbound-topic,-do-expression,-with-statement,-outer-topic-reference-in-with-body/input.js rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-do-transform-with-block-topic-in-body/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-do-transform-with-block-topic-in-body/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-do-transform-with-block-topic-in-body/options.json new file mode 100644 index 0000000000..d567021d4b --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-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-hash-proposal-do-transform-with-block-topic-in-body/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-do-transform-with-block-topic-in-body/output.json new file mode 100644 index 0000000000..9c21b42532 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-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/proposal-smart-topic-style,-function-call,-identifier-with-topic-reference/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-function-call-with-topic-in-argument/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-function-call,-identifier-with-topic-reference/input.js rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-function-call-with-topic-in-argument/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-function-call-with-topic-in-argument/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-function-call-with-topic-in-argument/options.json new file mode 100644 index 0000000000..be2b04c70d --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-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-hash-proposal-function-call-with-topic-in-argument/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-function-call-with-topic-in-argument/output.json new file mode 100644 index 0000000000..81ae12185c --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-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/proposal-smart-bare-style,-function-calls,-single,-identifier/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-function-call-without-topic/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-function-calls,-single,-identifier/input.js rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-function-call-without-topic/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-function-call-without-topic/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-function-call-without-topic/options.json new file mode 100644 index 0000000000..be2b04c70d --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-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/proposal-smart-topic-style,-mixed-pipeline-plugins/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-function-call-without-topic/output.json similarity index 78% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-mixed-pipeline-plugins/output.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-function-call-without-topic/output.json index cb533784bc..3917568d72 100644 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-mixed-pipeline-plugins/output.json +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-function-call-without-topic/output.json @@ -1,6 +1,9 @@ { "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}}, @@ -20,12 +23,9 @@ }, "operator": "|>", "right": { - "type": "PipelineTopicExpression", - "start":9,"end":10,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":10}}, - "expression": { - "type": "PipelinePrimaryTopicReference", - "start":9,"end":10,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":10}} - } + "type": "Identifier", + "start":9,"end":10,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":10},"identifierName":"f"}, + "name": "f" } } } diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-unbound-topic,-pipeline-head-in-inner-function-in-pipeline-body/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-function-definition-with-another-pipe-in-function-body/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-unbound-topic,-pipeline-head-in-inner-function-in-pipeline-body/input.js rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-function-definition-with-another-pipe-in-function-body/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-function-definition-with-another-pipe-in-function-body/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-function-definition-with-another-pipe-in-function-body/options.json new file mode 100644 index 0000000000..be2b04c70d --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-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-hash-proposal-function-definition-with-another-pipe-in-function-body/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-function-definition-with-another-pipe-in-function-body/output.json new file mode 100644 index 0000000000..78c6b8cd0a --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-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/proposal-smart-topic-style,-function-definition,-outer-topic-reference-in-default-parameter-expression/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-function-definition-with-topic-in-default-parameter/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-function-definition,-outer-topic-reference-in-default-parameter-expression/input.js rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-function-definition-with-topic-in-default-parameter/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-function-definition-with-topic-in-default-parameter/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-function-definition-with-topic-in-default-parameter/options.json new file mode 100644 index 0000000000..be2b04c70d --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-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-hash-proposal-function-definition-with-topic-in-default-parameter/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-function-definition-with-topic-in-default-parameter/output.json new file mode 100644 index 0000000000..3895abf6bf --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-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/proposal-smart-error,-unbound-topic,-inner-function-in-pipeline-body/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-function-definition-with-topic-in-function-body/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-unbound-topic,-inner-function-in-pipeline-body/input.js rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-function-definition-with-topic-in-function-body/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-function-definition-with-topic-in-function-body/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-function-definition-with-topic-in-function-body/options.json new file mode 100644 index 0000000000..be2b04c70d --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-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-hash-proposal-function-definition-with-topic-in-function-body/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-function-definition-with-topic-in-function-body/output.json new file mode 100644 index 0000000000..8dc59aef9a --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-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/proposal-smart-topic-style,-generator-yield/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-generator-yield-parenthesized/input.js similarity index 58% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-generator-yield/input.js rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-generator-yield-parenthesized/input.js index c35ae3c9db..1770468805 100644 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-generator-yield/input.js +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-generator-yield-parenthesized/input.js @@ -1,3 +1,3 @@ -function * f () { +function * f (x) { return x |> (yield #); } diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-generator-yield-parenthesized/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-generator-yield-parenthesized/options.json new file mode 100644 index 0000000000..be2b04c70d --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-generator-yield-parenthesized/options.json @@ -0,0 +1,3 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "hack", "topicToken": "#" }]] +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-generator-yield-parenthesized/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-generator-yield-parenthesized/output.json new file mode 100644 index 0000000000..e9e11c6eef --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-generator-yield-parenthesized/output.json @@ -0,0 +1,65 @@ +{ + "type": "File", + "start":0,"end":45,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}}, + "program": { + "type": "Program", + "start":0,"end":45,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}}, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start":0,"end":45,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}}, + "id": { + "type": "Identifier", + "start":11,"end":12,"loc":{"start":{"line":1,"column":11},"end":{"line":1,"column":12},"identifierName":"f"}, + "name": "f" + }, + "generator": true, + "async": false, + "params": [ + { + "type": "Identifier", + "start":14,"end":15,"loc":{"start":{"line":1,"column":14},"end":{"line":1,"column":15},"identifierName":"x"}, + "name": "x" + } + ], + "body": { + "type": "BlockStatement", + "start":17,"end":45,"loc":{"start":{"line":1,"column":17},"end":{"line":3,"column":1}}, + "body": [ + { + "type": "ReturnStatement", + "start":21,"end":43,"loc":{"start":{"line":2,"column":2},"end":{"line":2,"column":24}}, + "argument": { + "type": "BinaryExpression", + "start":28,"end":42,"loc":{"start":{"line":2,"column":9},"end":{"line":2,"column":23}}, + "left": { + "type": "Identifier", + "start":28,"end":29,"loc":{"start":{"line":2,"column":9},"end":{"line":2,"column":10},"identifierName":"x"}, + "name": "x" + }, + "operator": "|>", + "right": { + "type": "YieldExpression", + "start":34,"end":41,"loc":{"start":{"line":2,"column":15},"end":{"line":2,"column":22}}, + "extra": { + "parenthesized": true, + "parenStart": 33 + }, + "delegate": false, + "argument": { + "type": "TopicReference", + "start":40,"end":41,"loc":{"start":{"line":2,"column":21},"end":{"line":2,"column":22}} + } + } + } + } + ], + "directives": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-generator-yield-unparenthesized/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-generator-yield-unparenthesized/input.js new file mode 100644 index 0000000000..90672d043b --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-generator-yield-unparenthesized/input.js @@ -0,0 +1,3 @@ +function * f (x) { + return x |> yield #; +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-generator-yield-unparenthesized/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-generator-yield-unparenthesized/options.json new file mode 100644 index 0000000000..001ba9d365 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-generator-yield-unparenthesized/options.json @@ -0,0 +1,4 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "hack", "topicToken": "#" }]], + "throws": "Unexpected yield after pipeline body; any yield expression acting as Hack-style pipe body must be parenthesized due to its loose operator precedence. (2:14)" +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-hash-tuple/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-hash-tuple/input.js new file mode 100644 index 0000000000..eb22843797 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-hash-tuple/input.js @@ -0,0 +1,2 @@ +#[0]; +1 |> #[0]; diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-hash-tuple/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-hash-tuple/options.json new file mode 100644 index 0000000000..12e635d499 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-hash-tuple/options.json @@ -0,0 +1,7 @@ +{ + "plugins": [ + ["pipelineOperator", { "proposal": "hack", "topicToken": "#" }], + ["recordAndTuple", { "syntaxType": "hash" }] + ], + "throws": "Plugin conflict between `[\"pipelineOperator\", { proposal: \"hack\", topicToken: \"#\" }]` and `[\"recordAndtuple\", { syntaxType: \"hash\"}]`." +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-invalid-hash-token,-followed-by-digit/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-invalid-hash-then-digit/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-invalid-hash-token,-followed-by-digit/input.js rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-invalid-hash-then-digit/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-invalid-hash-token,-followed-by-digit/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-invalid-hash-then-digit/options.json similarity index 70% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-invalid-hash-token,-followed-by-digit/options.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-invalid-hash-then-digit/options.json index 71621d6348..c48dfc11c7 100644 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-invalid-hash-token,-followed-by-digit/options.json +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-invalid-hash-then-digit/options.json @@ -3,7 +3,8 @@ [ "pipelineOperator", { - "proposal": "smart" + "proposal": "hack", + "topicToken": "#" } ] ], diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-identity,-unparenthesized/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-mixed-pipeline-plugins/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-identity,-unparenthesized/input.js rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-mixed-pipeline-plugins/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-mixed-pipeline-plugins/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-mixed-pipeline-plugins/options.json new file mode 100644 index 0000000000..e346f539e9 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-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-hash-proposal-mixed-pipeline-plugins/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-mixed-pipeline-plugins/output.json new file mode 100644 index 0000000000..26d454dbfd --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-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-hash-proposal-modulo-with-topic/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-modulo-with-topic/input.js new file mode 100644 index 0000000000..7d8db91bd9 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-modulo-with-topic/input.js @@ -0,0 +1 @@ +value |> # % 2 diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-modulo-with-topic/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-modulo-with-topic/options.json new file mode 100644 index 0000000000..be2b04c70d --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-modulo-with-topic/options.json @@ -0,0 +1,3 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "hack", "topicToken": "#" }]] +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-modulo-with-topic/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-modulo-with-topic/output.json new file mode 100644 index 0000000000..b30346f770 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-modulo-with-topic/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-hash-proposal-nested-pipelines-with-arrow-function-with-required-topics/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-nested-pipelines-with-arrow-function-with-required-topics/input.js new file mode 100644 index 0000000000..a3cfa26e12 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-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-hash-proposal-nested-pipelines-with-arrow-function-with-required-topics/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-nested-pipelines-with-arrow-function-with-required-topics/options.json new file mode 100644 index 0000000000..be2b04c70d --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-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-hash-proposal-nested-pipelines-with-arrow-function-with-required-topics/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-nested-pipelines-with-arrow-function-with-required-topics/output.json new file mode 100644 index 0000000000..4fcf20826e --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-nested-pipelines-with-arrow-function-with-required-topics/output.json @@ -0,0 +1,97 @@ +{ + "type": "File", + "start":0,"end":33,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":33}}, + "program": { + "type": "Program", + "start":0,"end":33,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":33}}, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start":0,"end":33,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":33}}, + "expression": { + "type": "BinaryExpression", + "start":0,"end":33,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":33}}, + "left": { + "type": "Identifier", + "start":0,"end":1,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":1},"identifierName":"x"}, + "name": "x" + }, + "operator": "|>", + "right": { + "type": "ArrowFunctionExpression", + "start":6,"end":32,"loc":{"start":{"line":1,"column":6},"end":{"line":1,"column":32}}, + "extra": { + "parenthesized": true, + "parenStart": 5 + }, + "id": null, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "start":6,"end":7,"loc":{"start":{"line":1,"column":6},"end":{"line":1,"column":7},"identifierName":"$"}, + "name": "$" + } + ], + "body": { + "type": "BinaryExpression", + "start":11,"end":32,"loc":{"start":{"line":1,"column":11},"end":{"line":1,"column":32}}, + "left": { + "type": "BinaryExpression", + "start":11,"end":23,"loc":{"start":{"line":1,"column":11},"end":{"line":1,"column":23}}, + "left": { + "type": "TopicReference", + "start":11,"end":12,"loc":{"start":{"line":1,"column":11},"end":{"line":1,"column":12}} + }, + "operator": "|>", + "right": { + "type": "CallExpression", + "start":16,"end":23,"loc":{"start":{"line":1,"column":16},"end":{"line":1,"column":23}}, + "callee": { + "type": "Identifier", + "start":16,"end":17,"loc":{"start":{"line":1,"column":16},"end":{"line":1,"column":17},"identifierName":"f"}, + "name": "f" + }, + "arguments": [ + { + "type": "TopicReference", + "start":18,"end":19,"loc":{"start":{"line":1,"column":18},"end":{"line":1,"column":19}} + }, + { + "type": "Identifier", + "start":21,"end":22,"loc":{"start":{"line":1,"column":21},"end":{"line":1,"column":22},"identifierName":"$"}, + "name": "$" + } + ] + } + }, + "operator": "|>", + "right": { + "type": "BinaryExpression", + "start":27,"end":32,"loc":{"start":{"line":1,"column":27},"end":{"line":1,"column":32}}, + "left": { + "type": "TopicReference", + "start":27,"end":28,"loc":{"start":{"line":1,"column":27},"end":{"line":1,"column":28}} + }, + "operator": ">", + "right": { + "type": "NumericLiteral", + "start":31,"end":32,"loc":{"start":{"line":1,"column":31},"end":{"line":1,"column":32}}, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + } + } + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-nested-pipelines,-topic-style-with-arrow-function-with-topic-style,-no-inner-topic-reference/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-nested-pipelines-with-arrow-function-without-inner-topic/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-nested-pipelines,-topic-style-with-arrow-function-with-topic-style,-no-inner-topic-reference/input.js rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-nested-pipelines-with-arrow-function-without-inner-topic/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-nested-pipelines-with-arrow-function-without-inner-topic/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-nested-pipelines-with-arrow-function-without-inner-topic/options.json new file mode 100644 index 0000000000..be2b04c70d --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-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-hash-proposal-nested-pipelines-with-arrow-function-without-inner-topic/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-nested-pipelines-with-arrow-function-without-inner-topic/output.json new file mode 100644 index 0000000000..e04f68fe79 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-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/proposal-smart-error,-nested-pipelines,-topic-style-with-arrow-function-with-topic-style,-no-outer-topic-reference/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-nested-pipelines-with-arrow-function-without-outer-topic/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-nested-pipelines,-topic-style-with-arrow-function-with-topic-style,-no-outer-topic-reference/input.js rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-nested-pipelines-with-arrow-function-without-outer-topic/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-nested-pipelines-with-arrow-function-without-outer-topic/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-nested-pipelines-with-arrow-function-without-outer-topic/options.json new file mode 100644 index 0000000000..be2b04c70d --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-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-hash-proposal-nested-pipelines-with-arrow-function-without-outer-topic/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-nested-pipelines-with-arrow-function-without-outer-topic/output.json new file mode 100644 index 0000000000..2ec88e5332 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-nested-pipelines-with-arrow-function-without-outer-topic/output.json @@ -0,0 +1,62 @@ +{ + "type": "File", + "start":0,"end":18,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":18}}, + "errors": [ + "SyntaxError: Hack-style pipe body does not contain a topic reference; Hack-style pipes must use topic at least once. (1:5)" + ], + "program": { + "type": "Program", + "start":0,"end":18,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":18}}, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start":0,"end":18,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":18}}, + "expression": { + "type": "BinaryExpression", + "start":0,"end":18,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":18}}, + "left": { + "type": "Identifier", + "start":0,"end":1,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":1},"identifierName":"x"}, + "name": "x" + }, + "operator": "|>", + "right": { + "type": "ArrowFunctionExpression", + "start":6,"end":17,"loc":{"start":{"line":1,"column":6},"end":{"line":1,"column":17}}, + "extra": { + "parenthesized": true, + "parenStart": 5 + }, + "id": null, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "start":6,"end":7,"loc":{"start":{"line":1,"column":6},"end":{"line":1,"column":7},"identifierName":"$"}, + "name": "$" + } + ], + "body": { + "type": "BinaryExpression", + "start":11,"end":17,"loc":{"start":{"line":1,"column":11},"end":{"line":1,"column":17}}, + "left": { + "type": "Identifier", + "start":11,"end":12,"loc":{"start":{"line":1,"column":11},"end":{"line":1,"column":12},"identifierName":"$"}, + "name": "$" + }, + "operator": "|>", + "right": { + "type": "TopicReference", + "start":16,"end":17,"loc":{"start":{"line":1,"column":16},"end":{"line":1,"column":17}} + } + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-nested-pipelines,-topic-style-with-inner-topic-style/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-nested-pipelines-with-function-call/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-nested-pipelines,-topic-style-with-inner-topic-style/input.js rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-nested-pipelines-with-function-call/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-nested-pipelines-with-function-call/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-nested-pipelines-with-function-call/options.json new file mode 100644 index 0000000000..be2b04c70d --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-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-hash-proposal-nested-pipelines-with-function-call/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-nested-pipelines-with-function-call/output.json new file mode 100644 index 0000000000..12c2619c00 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-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/proposal-smart-error,-nested-pipelines,-topic-style-with-inner-topic-style,-no-inner-topic-reference/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-nested-pipelines-without-inner-topic/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-nested-pipelines,-topic-style-with-inner-topic-style,-no-inner-topic-reference/input.js rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-nested-pipelines-without-inner-topic/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-nested-pipelines-without-inner-topic/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-nested-pipelines-without-inner-topic/options.json new file mode 100644 index 0000000000..be2b04c70d --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-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-hash-proposal-nested-pipelines-without-inner-topic/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-nested-pipelines-without-inner-topic/output.json new file mode 100644 index 0000000000..fd53f606c9 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-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/proposal-smart-error,-nested-pipelines,-topic-style-with-inner-topic-style,-no-outer-topic-reference/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-nested-pipelines-without-outer-topic/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-nested-pipelines,-topic-style-with-inner-topic-style,-no-outer-topic-reference/input.js rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-nested-pipelines-without-outer-topic/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-nested-pipelines-without-outer-topic/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-nested-pipelines-without-outer-topic/options.json new file mode 100644 index 0000000000..be2b04c70d --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-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-hash-proposal-nested-pipelines-without-outer-topic/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-nested-pipelines-without-outer-topic/output.json new file mode 100644 index 0000000000..8223c338ae --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-nested-pipelines-without-outer-topic/output.json @@ -0,0 +1,50 @@ +{ + "type": "File", + "start":0,"end":13,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":13}}, + "errors": [ + "SyntaxError: Hack-style pipe body does not contain a topic reference; Hack-style pipes must use topic at least once. (1:11)", + "SyntaxError: Hack-style pipe body does not contain a topic reference; Hack-style pipes must use topic at least once. (1:5)" + ], + "program": { + "type": "Program", + "start":0,"end":13,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":13}}, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start":0,"end":13,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":13}}, + "expression": { + "type": "BinaryExpression", + "start":0,"end":13,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":13}}, + "left": { + "type": "Identifier", + "start":0,"end":1,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":1},"identifierName":"x"}, + "name": "x" + }, + "operator": "|>", + "right": { + "type": "BinaryExpression", + "start":6,"end":12,"loc":{"start":{"line":1,"column":6},"end":{"line":1,"column":12}}, + "extra": { + "parenthesized": true, + "parenStart": 5 + }, + "left": { + "type": "Identifier", + "start":6,"end":7,"loc":{"start":{"line":1,"column":6},"end":{"line":1,"column":7},"identifierName":"$"}, + "name": "$" + }, + "operator": "|>", + "right": { + "type": "Identifier", + "start":11,"end":12,"loc":{"start":{"line":1,"column":11},"end":{"line":1,"column":12},"identifierName":"f"}, + "name": "f" + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-no-topic-reference,-class-expression/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-no-topic-class-expression/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-no-topic-reference,-class-expression/input.js rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-no-topic-class-expression/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-no-topic-class-expression/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-no-topic-class-expression/options.json new file mode 100644 index 0000000000..be2b04c70d --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-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-hash-proposal-no-topic-class-expression/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-no-topic-class-expression/output.json new file mode 100644 index 0000000000..1e904fe3dd --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-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/proposal-smart-error,-topic-style,-no-topic-reference,-function-expression/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-no-topic-function-expression/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-no-topic-reference,-function-expression/input.js rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-no-topic-function-expression/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-no-topic-function-expression/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-no-topic-function-expression/options.json new file mode 100644 index 0000000000..be2b04c70d --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-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-hash-proposal-no-topic-function-expression/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-no-topic-function-expression/output.json new file mode 100644 index 0000000000..4a53253559 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-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-hash-proposal-non-generator-yield-identifier/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-non-generator-yield-identifier/input.js new file mode 100644 index 0000000000..3d85a40bae --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-non-generator-yield-identifier/input.js @@ -0,0 +1 @@ +x |> yield + #; diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-non-generator-yield-identifier/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-non-generator-yield-identifier/options.json new file mode 100644 index 0000000000..be2b04c70d --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-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-hash-proposal-non-generator-yield-identifier/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-non-generator-yield-identifier/output.json new file mode 100644 index 0000000000..cdd141011b --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-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-hash-proposal-private-property-in-private-method/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-private-property-in-private-method/input.js new file mode 100644 index 0000000000..b53ef573f7 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-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-hash-proposal-private-property-in-private-method/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-private-property-in-private-method/options.json new file mode 100644 index 0000000000..ee4a6e09fb --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-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-hash-proposal-private-property-in-private-method/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-private-property-in-private-method/output.json new file mode 100644 index 0000000000..0a1b91986a --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-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/proposal-smart-topic-style,-identity,-parenthesized/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-topic-identity-parenthesized/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-identity,-parenthesized/input.js rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-topic-identity-parenthesized/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-topic-identity-parenthesized/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-topic-identity-parenthesized/options.json new file mode 100644 index 0000000000..be2b04c70d --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-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-hash-proposal-topic-identity-parenthesized/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-topic-identity-parenthesized/output.json new file mode 100644 index 0000000000..90324568fe --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-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/proposal-smart-topic-style,-mixed-pipeline-plugins/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-topic-identity-unparenthesized/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-mixed-pipeline-plugins/input.js rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-topic-identity-unparenthesized/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-topic-identity-unparenthesized/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-topic-identity-unparenthesized/options.json new file mode 100644 index 0000000000..be2b04c70d --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-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-hash-proposal-topic-identity-unparenthesized/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-topic-identity-unparenthesized/output.json new file mode 100644 index 0000000000..26d454dbfd --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-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-hash-proposal-topic-with-optional-method-call/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-topic-with-optional-method-call/input.js new file mode 100644 index 0000000000..f9dcfac566 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-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-hash-proposal-topic-with-optional-method-call/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-topic-with-optional-method-call/options.json new file mode 100644 index 0000000000..be2b04c70d --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-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-hash-proposal-topic-with-optional-method-call/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-topic-with-optional-method-call/output.json new file mode 100644 index 0000000000..cfe7f18f72 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-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/proposal-smart-error,-unbound-topic,-simple/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-unbound-topic/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-unbound-topic,-simple/input.js rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-unbound-topic/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-unbound-topic/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-unbound-topic/options.json new file mode 100644 index 0000000000..be2b04c70d --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-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-hash-proposal-unbound-topic/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-unbound-topic/output.json new file mode 100644 index 0000000000..d4bd9e0955 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-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:5)" + ], + "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": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-within-assignment/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-within-assignment/input.js new file mode 100644 index 0000000000..e71753d479 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-within-assignment/input.js @@ -0,0 +1 @@ +x = 0 |> #; diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-within-assignment/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-within-assignment/options.json new file mode 100644 index 0000000000..be2b04c70d --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-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-hash-proposal-within-assignment/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-within-assignment/output.json new file mode 100644 index 0000000000..b6929c77f6 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-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-hash-proposal-within-classic-for-statement-init/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-within-classic-for-statement-init/input.js new file mode 100644 index 0000000000..c46759ff2f --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-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-hash-proposal-within-classic-for-statement-init/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-within-classic-for-statement-init/options.json new file mode 100644 index 0000000000..be2b04c70d --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-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-hash-proposal-within-classic-for-statement-init/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-within-classic-for-statement-init/output.json new file mode 100644 index 0000000000..a00ebbb4ba --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-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-hash-proposal-within-variable-declaration/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-within-variable-declaration/input.js new file mode 100644 index 0000000000..df93e754a9 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-within-variable-declaration/input.js @@ -0,0 +1 @@ +const x = 0 |> #; diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-within-variable-declaration/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-within-variable-declaration/options.json new file mode 100644 index 0000000000..be2b04c70d --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-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-hash-proposal-within-variable-declaration/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-within-variable-declaration/output.json new file mode 100644 index 0000000000..a1e01654c8 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-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/invalid-proposal/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/invalid-proposal/options.json index d8fca74323..a67350eff2 100644 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/invalid-proposal/options.json +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/invalid-proposal/options.json @@ -1,4 +1,12 @@ { - "plugins": [["pipelineOperator", { "proposal": "invalid" }]], - "throws": "'pipelineOperator' requires 'proposal' option whose value should be one of: 'minimal', 'smart', 'fsharp'" -} + "plugins": [ + [ + "pipelineOperator", + { + "proposal": "invalid" + } + ], + "estree" + ], + "throws": "\"pipelineOperator\" requires \"proposal\" option whose value must be one of: \"minimal\", \"fsharp\", \"hack\", \"smart\"." +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-minimal-arrow-requires-parens-with-parend-args/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/minimal-proposal-arrow-requires-parens-with-parend-args/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-minimal-arrow-requires-parens-with-parend-args/input.js rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/minimal-proposal-arrow-requires-parens-with-parend-args/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-minimal-arrow-requires-parens-with-parend-args/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/minimal-proposal-arrow-requires-parens-with-parend-args/options.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-minimal-arrow-requires-parens-with-parend-args/options.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/minimal-proposal-arrow-requires-parens-with-parend-args/options.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-minimal-arrow-requires-parens/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/minimal-proposal-arrow-requires-parens/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-minimal-arrow-requires-parens/input.js rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/minimal-proposal-arrow-requires-parens/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-minimal-arrow-requires-parens/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/minimal-proposal-arrow-requires-parens/options.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-minimal-arrow-requires-parens/options.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/minimal-proposal-arrow-requires-parens/options.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-minimal-await-requires-parens/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/minimal-proposal-await-requires-parens/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-minimal-await-requires-parens/input.js rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/minimal-proposal-await-requires-parens/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-minimal-await-requires-parens/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/minimal-proposal-await-requires-parens/options.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-minimal-await-requires-parens/options.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/minimal-proposal-await-requires-parens/options.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-minimal-await-requires-parens/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/minimal-proposal-await-requires-parens/output.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-minimal-await-requires-parens/output.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/minimal-proposal-await-requires-parens/output.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-minimal-ban-await-f/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/minimal-proposal-ban-await-f/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-minimal-ban-await-f/input.js rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/minimal-proposal-ban-await-f/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-minimal-ban-await-f/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/minimal-proposal-ban-await-f/options.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-minimal-ban-await-f/options.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/minimal-proposal-ban-await-f/options.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-minimal-ban-await/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/minimal-proposal-ban-await/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-minimal-ban-await/input.js rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/minimal-proposal-ban-await/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-minimal-ban-await/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/minimal-proposal-ban-await/options.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-minimal-ban-await/options.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/minimal-proposal-ban-await/options.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-fsharp-base/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/minimal-proposal-base/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-fsharp-base/input.js rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/minimal-proposal-base/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-minimal-base/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/minimal-proposal-base/options.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-minimal-base/options.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/minimal-proposal-base/options.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-minimal-base/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/minimal-proposal-base/output.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-minimal-base/output.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/minimal-proposal-base/output.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-minimal-chain/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/minimal-proposal-chain/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-minimal-chain/input.js rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/minimal-proposal-chain/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-minimal-chain/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/minimal-proposal-chain/options.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-minimal-chain/options.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/minimal-proposal-chain/options.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-minimal-chain/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/minimal-proposal-chain/output.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-minimal-chain/output.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/minimal-proposal-chain/output.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-minimal-multiline/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/minimal-proposal-multiline/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-minimal-multiline/input.js rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/minimal-proposal-multiline/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-minimal-multiline/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/minimal-proposal-multiline/options.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-minimal-multiline/options.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/minimal-proposal-multiline/options.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-minimal-multiline/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/minimal-proposal-multiline/output.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-minimal-multiline/output.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/minimal-proposal-multiline/output.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-minimal-precedence/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/minimal-proposal-precedence/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-minimal-precedence/input.js rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/minimal-proposal-precedence/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-minimal-precedence/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/minimal-proposal-precedence/options.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-minimal-precedence/options.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/minimal-proposal-precedence/options.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-minimal-precedence/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/minimal-proposal-precedence/output.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-minimal-precedence/output.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/minimal-proposal-precedence/output.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-minimal-with-arrow-parend-params/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/minimal-proposal-with-arrow-parend-params/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-minimal-with-arrow-parend-params/input.js rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/minimal-proposal-with-arrow-parend-params/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-minimal-with-arrow-parend-params/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/minimal-proposal-with-arrow-parend-params/options.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-minimal-with-arrow-parend-params/options.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/minimal-proposal-with-arrow-parend-params/options.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-minimal-with-arrow-parend-params/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/minimal-proposal-with-arrow-parend-params/output.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-minimal-with-arrow-parend-params/output.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/minimal-proposal-with-arrow-parend-params/output.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-minimal-with-arrow/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/minimal-proposal-with-arrow/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-minimal-with-arrow/input.js rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/minimal-proposal-with-arrow/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-minimal-with-arrow/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/minimal-proposal-with-arrow/options.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-minimal-with-arrow/options.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/minimal-proposal-with-arrow/options.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-minimal-with-arrow/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/minimal-proposal-with-arrow/output.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-minimal-with-arrow/output.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/minimal-proposal-with-arrow/output.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-minimal-base/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/no-plugin-pipe/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-minimal-base/input.js rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/no-plugin-pipe/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/no-plugin/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/no-plugin-pipe/options.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/no-plugin/options.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/no-plugin-pipe/options.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/no-plugin-topic-reference-hash/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/no-plugin-topic-reference-hash/input.js new file mode 100644 index 0000000000..3ce552b615 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/no-plugin-topic-reference-hash/input.js @@ -0,0 +1 @@ +# + 1; diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/no-plugin-topic-reference-hash/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/no-plugin-topic-reference-hash/options.json new file mode 100644 index 0000000000..919c05ec87 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/no-plugin-topic-reference-hash/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Unexpected token (1:0)" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-fsharp-invalid-primary-topic/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-fsharp-invalid-primary-topic/options.json deleted file mode 100644 index f95ecc7d6c..0000000000 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-fsharp-invalid-primary-topic/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "plugins": [["pipelineOperator", { "proposal": "fsharp" }]] -} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-fsharp-invalid-primary-topic/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-fsharp-invalid-primary-topic/output.json deleted file mode 100644 index 699e25b015..0000000000 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-fsharp-invalid-primary-topic/output.json +++ /dev/null @@ -1,49 +0,0 @@ -{ - "type": "File", - "start":0,"end":10,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":10}}, - "errors": [ - "SyntaxError: Primary Topic Reference found but pipelineOperator not passed 'smart' for 'proposal' option. (1:5)", - "SyntaxError: Topic reference was used in a lexical context without topic binding. (1:5)" - ], - "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":1,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":1},"identifierName":"x"}, - "name": "x" - }, - "operator": "|>", - "right": { - "type": "BinaryExpression", - "start":5,"end":10,"loc":{"start":{"line":1,"column":5},"end":{"line":1,"column":10}}, - "left": { - "type": "PipelinePrimaryTopicReference", - "start":5,"end":6,"loc":{"start":{"line":1,"column":5},"end":{"line":1,"column":6}} - }, - "operator": "+", - "right": { - "type": "NumericLiteral", - "start":9,"end":10,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":10}}, - "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/proposal-smart-error,-bare-style,-head-with-topic-reference-pair/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-bare-style,-head-with-topic-reference-pair/options.json deleted file mode 100644 index 279df0af85..0000000000 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-bare-style,-head-with-topic-reference-pair/options.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "plugins": [ - [ - "pipelineOperator", - { - "proposal": "smart" - } - ] - ] -} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-sequence-style,-body-with-topic-reference-pair-followed-by-bare-style-pipeline-body/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-sequence-style,-body-with-topic-reference-pair-followed-by-bare-style-pipeline-body/options.json deleted file mode 100644 index 279df0af85..0000000000 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-sequence-style,-body-with-topic-reference-pair-followed-by-bare-style-pipeline-body/options.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "plugins": [ - [ - "pipelineOperator", - { - "proposal": "smart" - } - ] - ] -} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-sequence-style,-body-with-topic-reference-pair-then-end/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-sequence-style,-body-with-topic-reference-pair-then-end/options.json deleted file mode 100644 index 279df0af85..0000000000 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-sequence-style,-body-with-topic-reference-pair-then-end/options.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "plugins": [ - [ - "pipelineOperator", - { - "proposal": "smart" - } - ] - ] -} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-unparenthesized-arrow-function-with-bare-parameter-and-bare-body/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-unparenthesized-arrow-function-with-bare-parameter-and-bare-body/options.json deleted file mode 100644 index c4d1cfc53f..0000000000 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-unparenthesized-arrow-function-with-bare-parameter-and-bare-body/options.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "plugins": [ - [ - "pipelineOperator", - { - "proposal": "smart" - } - ] - ], - "throws": "Unexpected arrow \"=>\" after pipeline body; arrow function in pipeline body must be parenthesized. (1:8)" -} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-mixed-pipeline-plugins/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-mixed-pipeline-plugins/options.json deleted file mode 100644 index 887155e27e..0000000000 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-mixed-pipeline-plugins/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "plugins": [["pipelineOperator", { "proposal": "smart" }], "pipelineOperator"] -} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-addition-with-topic-first/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-addition-with-topic-first/input.js new file mode 100644 index 0000000000..9d3fa92121 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-addition-with-topic-first/input.js @@ -0,0 +1 @@ +value |> # + 1 diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-function-calls,-chained,-single-line-arrow-function/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-addition-with-topic-first/options.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-function-calls,-chained,-single-line-arrow-function/options.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-addition-with-topic-first/options.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-addition,-single-line-arrow-function,-topic-reference-first/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-addition-with-topic-first/output.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-addition,-single-line-arrow-function,-topic-reference-first/output.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-addition-with-topic-first/output.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-addition-with-topic-last/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-addition-with-topic-last/input.js new file mode 100644 index 0000000000..64ea7f0bcd --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-addition-with-topic-last/input.js @@ -0,0 +1 @@ +value |> 1 + # diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-function-calls,-single,-identifier/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-addition-with-topic-last/options.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-function-calls,-single,-identifier/options.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-addition-with-topic-last/options.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-addition,-single-line-arrow-function,-topic-reference-last/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-addition-with-topic-last/output.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-addition,-single-line-arrow-function,-topic-reference-last/output.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-addition-with-topic-last/output.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-addition-without-topic/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-addition-without-topic/input.js new file mode 100644 index 0000000000..e952adac15 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-addition-without-topic/input.js @@ -0,0 +1 @@ +value |> a + b diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-function-calls,-single,-property/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-addition-without-topic/options.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-function-calls,-single,-property/options.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-addition-without-topic/options.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-no-topic-reference,-addition/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-addition-without-topic/output.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-no-topic-reference,-addition/output.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-addition-without-topic/output.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-arrow-function-parenthesized/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-arrow-function-parenthesized/input.js new file mode 100644 index 0000000000..7f3f814efd --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-arrow-function-parenthesized/input.js @@ -0,0 +1 @@ +value |> (() => # + 1) diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-nested-pipelines,-topic-style-with-arrow-function-with-bare-style,-no-outer-topic-reference/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-arrow-function-parenthesized/options.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-nested-pipelines,-topic-style-with-arrow-function-with-bare-style,-no-outer-topic-reference/options.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-arrow-function-parenthesized/options.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-parenthesized-single-line-arrow-function,-with-empty-parameter-list-and-bare-addition-body/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-arrow-function-parenthesized/output.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-parenthesized-single-line-arrow-function,-with-empty-parameter-list-and-bare-addition-body/output.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-arrow-function-parenthesized/output.json index c6606b33e1..c52d6a6960 100644 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-parenthesized-single-line-arrow-function,-with-empty-parameter-list-and-bare-addition-body/output.json +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-arrow-function-parenthesized/output.json @@ -25,6 +25,10 @@ "expression": { "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, @@ -46,10 +50,6 @@ }, "value": 1 } - }, - "extra": { - "parenthesized": true, - "parenStart": 9 } } } diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-arrow-function-unparenthesized/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-arrow-function-unparenthesized/input.js new file mode 100644 index 0000000000..00d1c2320d --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-arrow-function-unparenthesized/input.js @@ -0,0 +1 @@ +10 |> x => x + #; diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-unbound-topic,-simple/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-arrow-function-unparenthesized/options.json similarity index 73% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-unbound-topic,-simple/options.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-arrow-function-unparenthesized/options.json index 602ec88c93..d923169b6f 100644 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-unbound-topic,-simple/options.json +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-arrow-function-unparenthesized/options.json @@ -7,5 +7,5 @@ } ] ], - "throws": "Unexpected token (1:4)" + "throws": "Unexpected token (1:8)" } \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-async-await/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-async-await/input.js new file mode 100644 index 0000000000..ea421c59a0 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-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/proposal-smart-error,-nested-pipelines,-topic-style-with-arrow-function-with-topic-style,-no-inner-topic-reference/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-async-await/options.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-nested-pipelines,-topic-style-with-arrow-function-with-topic-style,-no-inner-topic-reference/options.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-async-await/options.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-async-await/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-async-await/output.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-async-await/output.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-async-await/output.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-class-expression-with-decorators/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-class-expression-with-decorators/input.js new file mode 100644 index 0000000000..a7d86a1081 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-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/smart-proposal-class-expression-with-decorators/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-class-expression-with-decorators/options.json new file mode 100644 index 0000000000..5e746c659b --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-class-expression-with-decorators/options.json @@ -0,0 +1,6 @@ +{ + "plugins": [ + ["pipelineOperator", { "proposal": "smart" }], + ["decorators", {"decoratorsBeforeExport": true}] + ] +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-class-expression-with-decorators/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-class-expression-with-decorators/output.json new file mode 100644 index 0000000000..df5fa7b209 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-class-expression-with-decorators/output.json @@ -0,0 +1,132 @@ +{ + "type": "File", + "start":0,"end":130,"loc":{"start":{"line":1,"column":0},"end":{"line":9,"column":2}}, + "errors": [ + "SyntaxError: Topic reference was used in a lexical context without topic binding. (6:15)", + "SyntaxError: Pipeline is in topic style but does not use topic reference. (1:9)" + ], + "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": "PipelineTopicExpression", + "start":9,"end":129,"loc":{"start":{"line":1,"column":9},"end":{"line":9,"column":1}}, + "expression": { + "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": "PipelinePrimaryTopicReference", + "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/smart-proposal-class-expression-with-private-property/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-class-expression-with-private-property/input.js new file mode 100644 index 0000000000..12feae9c61 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-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/smart-proposal-class-expression-with-private-property/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-class-expression-with-private-property/options.json new file mode 100644 index 0000000000..b790a145ef --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-class-expression-with-private-property/options.json @@ -0,0 +1,7 @@ +{ + "plugins": [ + ["pipelineOperator", { "proposal": "smart" }], + "classPrivateProperties", + "classPrivateMethods" + ] +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-class-expression-with-private-property/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-class-expression-with-private-property/output.json new file mode 100644 index 0000000000..c719c0f535 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-class-expression-with-private-property/output.json @@ -0,0 +1,129 @@ +{ + "type": "File", + "start":0,"end":94,"loc":{"start":{"line":1,"column":0},"end":{"line":7,"column":3}}, + "errors": [ + "SyntaxError: Topic reference was used in a lexical context without topic binding. (5:13)", + "SyntaxError: Pipeline is in topic style but does not use topic reference. (1:9)" + ], + "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": "PipelineTopicExpression", + "start":9,"end":93,"loc":{"start":{"line":1,"column":9},"end":{"line":7,"column":2}}, + "expression": { + "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": "PipelinePrimaryTopicReference", + "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/smart-proposal-class-expression-without-private-property/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-class-expression-without-private-property/input.js new file mode 100644 index 0000000000..a905d1b711 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-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/proposal-smart-error,-nested-pipelines,-topic-style-with-arrow-function-with-topic-style,-no-outer-topic-reference/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-class-expression-without-private-property/options.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-nested-pipelines,-topic-style-with-arrow-function-with-topic-style,-no-outer-topic-reference/options.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-class-expression-without-private-property/options.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-unbound-topic,-inner-class-in-pipeline-body/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-class-expression-without-private-property/output.json similarity index 99% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-unbound-topic,-inner-class-in-pipeline-body/output.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-class-expression-without-private-property/output.json index dcf7d7105d..f06bdd1a2d 100644 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-unbound-topic,-inner-class-in-pipeline-body/output.json +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-class-expression-without-private-property/output.json @@ -2,7 +2,7 @@ "type": "File", "start":0,"end":45,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":45}}, "errors": [ - "SyntaxError: Topic reference was used in a lexical context without topic binding. (1:39)", + "SyntaxError: Topic reference was used in a lexical context without topic binding. (1:40)", "SyntaxError: Pipeline is in topic style but does not use topic reference. (1:5)" ], "program": { diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-bare-style,-head-with-topic-reference-pair/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-comma-head-with-tacit-function-call/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-bare-style,-head-with-topic-reference-pair/input.js rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-comma-head-with-tacit-function-call/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-nested-pipelines,-topic-style-with-inner-topic-style,-no-inner-topic-reference/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-comma-head-with-tacit-function-call/options.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-nested-pipelines,-topic-style-with-inner-topic-style,-no-inner-topic-reference/options.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-comma-head-with-tacit-function-call/options.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-bare-style,-head-with-topic-reference-pair/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-comma-head-with-tacit-function-call/output.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-bare-style,-head-with-topic-reference-pair/output.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-comma-head-with-tacit-function-call/output.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-comma-topic-pair-then-end/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-comma-topic-pair-then-end/input.js new file mode 100644 index 0000000000..7da42e013c --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-comma-topic-pair-then-end/input.js @@ -0,0 +1 @@ +10 |> (#, #); diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-nested-pipelines,-topic-style-with-inner-topic-style,-no-outer-topic-reference/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-comma-topic-pair-then-end/options.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-nested-pipelines,-topic-style-with-inner-topic-style,-no-outer-topic-reference/options.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-comma-topic-pair-then-end/options.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-sequence-style,-body-with-topic-reference-pair-then-end/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-comma-topic-pair-then-end/output.json similarity index 94% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-sequence-style,-body-with-topic-reference-pair-then-end/output.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-comma-topic-pair-then-end/output.json index ae82401e52..dd794f84e9 100644 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-sequence-style,-body-with-topic-reference-pair-then-end/output.json +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-comma-topic-pair-then-end/output.json @@ -1,9 +1,6 @@ { "type": "File", "start":0,"end":13,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":13}}, - "errors": [ - "SyntaxError: Pipeline body may not be a comma-separated sequence expression. (1:6)" - ], "program": { "type": "Program", "start":0,"end":13,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":13}}, diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-sequence-style,-body-with-topic-reference-pair-followed-by-bare-style-pipeline-body/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-comma-topic-pair-then-tacit-function-call/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-sequence-style,-body-with-topic-reference-pair-followed-by-bare-style-pipeline-body/input.js rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-comma-topic-pair-then-tacit-function-call/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-computed,-no-topic-reference/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-comma-topic-pair-then-tacit-function-call/options.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-computed,-no-topic-reference/options.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-comma-topic-pair-then-tacit-function-call/options.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-sequence-style,-body-with-topic-reference-pair-followed-by-bare-style-pipeline-body/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-comma-topic-pair-then-tacit-function-call/output.json similarity index 95% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-sequence-style,-body-with-topic-reference-pair-followed-by-bare-style-pipeline-body/output.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-comma-topic-pair-then-tacit-function-call/output.json index c6eec8dc71..13532fa8ed 100644 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-sequence-style,-body-with-topic-reference-pair-followed-by-bare-style-pipeline-body/output.json +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-comma-topic-pair-then-tacit-function-call/output.json @@ -1,9 +1,6 @@ { "type": "File", "start":0,"end":18,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":18}}, - "errors": [ - "SyntaxError: Pipeline body may not be a comma-separated sequence expression. (1:6)" - ], "program": { "type": "Program", "start":0,"end":18,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":18}}, diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-computed-no-topic/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-computed-no-topic/input.js new file mode 100644 index 0000000000..5a02dee8ec --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-computed-no-topic/input.js @@ -0,0 +1 @@ +value |> a[b] diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-no-topic-reference,-addition/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-computed-no-topic/options.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-no-topic-reference,-addition/options.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-computed-no-topic/options.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-computed,-no-topic-reference/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-computed-no-topic/output.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-computed,-no-topic-reference/output.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-computed-no-topic/output.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-do-while-loop-and-topic-in-loop-body/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-do-while-loop-and-topic-in-loop-body/input.js new file mode 100644 index 0000000000..8b34c84f52 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-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/proposal-smart-error,-topic-style,-unbound-topic,-do-expression,-do-while-loop,-outer-topic-reference-in-loop-body/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-do-while-loop-and-topic-in-loop-body/options.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-unbound-topic,-do-expression,-do-while-loop,-outer-topic-reference-in-loop-body/options.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-do-while-loop-and-topic-in-loop-body/options.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-unbound-topic,-do-expression,-do-while-loop,-outer-topic-reference-in-loop-body/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-do-while-loop-and-topic-in-loop-body/output.json similarity index 99% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-unbound-topic,-do-expression,-do-while-loop,-outer-topic-reference-in-loop-body/output.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-do-while-loop-and-topic-in-loop-body/output.json index cce77f778a..e50f728649 100644 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-unbound-topic,-do-expression,-do-while-loop,-outer-topic-reference-in-loop-body/output.json +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-do-while-loop-and-topic-in-loop-body/output.json @@ -2,7 +2,7 @@ "type": "File", "start":0,"end":42,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":42}}, "errors": [ - "SyntaxError: Topic reference was used in a lexical context without topic binding. (1:22)", + "SyntaxError: Topic reference was used in a lexical context without topic binding. (1:23)", "SyntaxError: Pipeline is in topic style but does not use topic reference. (1:9)" ], "program": { diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-do-while-loop-and-topic-in-loop-head/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-do-while-loop-and-topic-in-loop-head/input.js new file mode 100644 index 0000000000..e5917937bc --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-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/proposal-smart-error,-topic-style,-unbound-topic,-do-expression,-for-classic-loop,-outer-topic-reference-in-loop-body/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-do-while-loop-and-topic-in-loop-head/options.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-unbound-topic,-do-expression,-for-classic-loop,-outer-topic-reference-in-loop-body/options.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-do-while-loop-and-topic-in-loop-head/options.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-do-expression,-do-while-loop,-outer-topic-reference-in-loop-head/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-do-while-loop-and-topic-in-loop-head/output.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-do-expression,-do-while-loop,-outer-topic-reference-in-loop-head/output.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-do-while-loop-and-topic-in-loop-head/output.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-for-await-of-loop-and-topic-in-loop-body/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-for-await-of-loop-and-topic-in-loop-body/input.js new file mode 100644 index 0000000000..261f95e4c7 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-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/proposal-smart-error,-topic-style,-unbound-topic,-do-expression,-for-await-of-loop,-outer-topic-reference-in-loop-body/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-for-await-of-loop-and-topic-in-loop-body/options.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-unbound-topic,-do-expression,-for-await-of-loop,-outer-topic-reference-in-loop-body/options.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-for-await-of-loop-and-topic-in-loop-body/options.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-unbound-topic,-do-expression,-for-await-of-loop,-outer-topic-reference-in-loop-body/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-for-await-of-loop-and-topic-in-loop-body/output.json similarity index 99% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-unbound-topic,-do-expression,-for-await-of-loop,-outer-topic-reference-in-loop-body/output.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-for-await-of-loop-and-topic-in-loop-body/output.json index cccbb6ee67..b5060f4103 100644 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-unbound-topic,-do-expression,-for-await-of-loop,-outer-topic-reference-in-loop-body/output.json +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-for-await-of-loop-and-topic-in-loop-body/output.json @@ -2,7 +2,7 @@ "type": "File", "start":0,"end":77,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}}, "errors": [ - "SyntaxError: Topic reference was used in a lexical context without topic binding. (2:48)", + "SyntaxError: Topic reference was used in a lexical context without topic binding. (2:49)", "SyntaxError: Pipeline is in topic style but does not use topic reference. (2:11)" ], "program": { diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-for-await-of-loop-and-topic-in-loop-head/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-for-await-of-loop-and-topic-in-loop-head/input.js new file mode 100644 index 0000000000..197761dcd7 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-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/proposal-smart-topic-style,-do-expression,-for-await-of-loop,-outer-topic-reference-in-loop-head/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-for-await-of-loop-and-topic-in-loop-head/options.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-do-expression,-for-await-of-loop,-outer-topic-reference-in-loop-head/options.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-for-await-of-loop-and-topic-in-loop-head/options.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-do-expression,-for-await-of-loop,-outer-topic-reference-in-loop-head/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-for-await-of-loop-and-topic-in-loop-head/output.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-do-expression,-for-await-of-loop,-outer-topic-reference-in-loop-head/output.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-for-await-of-loop-and-topic-in-loop-head/output.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-for-classic-loop-and-topic-in-loop-body/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-for-classic-loop-and-topic-in-loop-body/input.js new file mode 100644 index 0000000000..e0eb815c73 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-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/proposal-smart-error,-topic-style,-unbound-topic,-do-expression,-for-in-loop,-outer-topic-reference-in-loop-body/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-for-classic-loop-and-topic-in-loop-body/options.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-unbound-topic,-do-expression,-for-in-loop,-outer-topic-reference-in-loop-body/options.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-for-classic-loop-and-topic-in-loop-body/options.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-unbound-topic,-do-expression,-for-classic-loop,-outer-topic-reference-in-loop-body/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-for-classic-loop-and-topic-in-loop-body/output.json similarity index 99% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-unbound-topic,-do-expression,-for-classic-loop,-outer-topic-reference-in-loop-body/output.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-for-classic-loop-and-topic-in-loop-body/output.json index 30756decb9..dbab2d31d8 100644 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-unbound-topic,-do-expression,-for-classic-loop,-outer-topic-reference-in-loop-body/output.json +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-for-classic-loop-and-topic-in-loop-body/output.json @@ -2,7 +2,7 @@ "type": "File", "start":0,"end":49,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":49}}, "errors": [ - "SyntaxError: Topic reference was used in a lexical context without topic binding. (1:45)", + "SyntaxError: Topic reference was used in a lexical context without topic binding. (1:46)", "SyntaxError: Pipeline is in topic style but does not use topic reference. (1:9)" ], "program": { diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-for-classic-loop-and-topic-in-loop-head/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-for-classic-loop-and-topic-in-loop-head/input.js new file mode 100644 index 0000000000..1e14a50cda --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-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/proposal-smart-error,-topic-style,-unbound-topic,-do-expression,-for-of-loop,-outer-topic-reference-in-loop-body/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-for-classic-loop-and-topic-in-loop-head/options.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-unbound-topic,-do-expression,-for-of-loop,-outer-topic-reference-in-loop-body/options.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-for-classic-loop-and-topic-in-loop-head/options.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-do-expression,-for-classic-loop,-outer-topic-reference-in-loop-head/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-for-classic-loop-and-topic-in-loop-head/output.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-do-expression,-for-classic-loop,-outer-topic-reference-in-loop-head/output.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-for-classic-loop-and-topic-in-loop-head/output.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-for-in-loop-and-topic-in-loop-body/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-for-in-loop-and-topic-in-loop-body/input.js new file mode 100644 index 0000000000..f6ebfaf948 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-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/proposal-smart-error,-topic-style,-unbound-topic,-do-expression,-try-statement,-outer-topic-reference-in-catch-clause/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-for-in-loop-and-topic-in-loop-body/options.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-unbound-topic,-do-expression,-try-statement,-outer-topic-reference-in-catch-clause/options.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-for-in-loop-and-topic-in-loop-body/options.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-unbound-topic,-do-expression,-for-in-loop,-outer-topic-reference-in-loop-body/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-for-in-loop-and-topic-in-loop-body/output.json similarity index 98% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-unbound-topic,-do-expression,-for-in-loop,-outer-topic-reference-in-loop-body/output.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-for-in-loop-and-topic-in-loop-body/output.json index 9c483cd137..9d9eef3ec7 100644 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-unbound-topic,-do-expression,-for-in-loop,-outer-topic-reference-in-loop-body/output.json +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-for-in-loop-and-topic-in-loop-body/output.json @@ -2,7 +2,7 @@ "type": "File", "start":0,"end":36,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":36}}, "errors": [ - "SyntaxError: Topic reference was used in a lexical context without topic binding. (1:32)", + "SyntaxError: Topic reference was used in a lexical context without topic binding. (1:33)", "SyntaxError: Pipeline is in topic style but does not use topic reference. (1:9)" ], "program": { diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-for-in-loop-and-topic-in-loop-head/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-for-in-loop-and-topic-in-loop-head/input.js new file mode 100644 index 0000000000..096c359535 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-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/proposal-smart-error,-topic-style,-unbound-topic,-do-expression,-while-loop,-outer-topic-reference-in-loop-body/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-for-in-loop-and-topic-in-loop-head/options.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-unbound-topic,-do-expression,-while-loop,-outer-topic-reference-in-loop-body/options.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-for-in-loop-and-topic-in-loop-head/options.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-do-expression,-for-in-loop,-outer-topic-reference-in-loop-head/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-for-in-loop-and-topic-in-loop-head/output.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-do-expression,-for-in-loop,-outer-topic-reference-in-loop-head/output.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-for-in-loop-and-topic-in-loop-head/output.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-for-of-loop-and-topic-in-loop-body/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-for-of-loop-and-topic-in-loop-body/input.js new file mode 100644 index 0000000000..b3350a5ad5 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-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/proposal-smart-error,-topic-style,-unbound-topic,-do-expression,-with-statement,-outer-topic-reference-in-with-body/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-for-of-loop-and-topic-in-loop-body/options.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-unbound-topic,-do-expression,-with-statement,-outer-topic-reference-in-with-body/options.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-for-of-loop-and-topic-in-loop-body/options.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-unbound-topic,-do-expression,-for-of-loop,-outer-topic-reference-in-loop-body/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-for-of-loop-and-topic-in-loop-body/output.json similarity index 98% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-unbound-topic,-do-expression,-for-of-loop,-outer-topic-reference-in-loop-body/output.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-for-of-loop-and-topic-in-loop-body/output.json index 4241e8133c..fef8f1a252 100644 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-unbound-topic,-do-expression,-for-of-loop,-outer-topic-reference-in-loop-body/output.json +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-for-of-loop-and-topic-in-loop-body/output.json @@ -2,7 +2,7 @@ "type": "File", "start":0,"end":38,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":38}}, "errors": [ - "SyntaxError: Topic reference was used in a lexical context without topic binding. (1:34)", + "SyntaxError: Topic reference was used in a lexical context without topic binding. (1:35)", "SyntaxError: Pipeline is in topic style but does not use topic reference. (1:9)" ], "program": { diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-for-of-loop-and-topic-in-loop-head/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-for-of-loop-and-topic-in-loop-head/input.js new file mode 100644 index 0000000000..b3e5f40ef7 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-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/proposal-smart-topic-style,-do-expression,-do-while-loop,-outer-topic-reference-in-loop-head/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-for-of-loop-and-topic-in-loop-head/options.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-do-expression,-do-while-loop,-outer-topic-reference-in-loop-head/options.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-for-of-loop-and-topic-in-loop-head/options.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-do-expression,-for-of-loop,-outer-topic-reference-in-loop-head/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-for-of-loop-and-topic-in-loop-head/output.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-do-expression,-for-of-loop,-outer-topic-reference-in-loop-head/output.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-for-of-loop-and-topic-in-loop-head/output.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-if-statement-and-topic-in-else-body/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-if-statement-and-topic-in-else-body/input.js new file mode 100644 index 0000000000..b4c8778046 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-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/proposal-smart-topic-style,-do-expression,-for-classic-loop,-outer-topic-reference-in-loop-head/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-if-statement-and-topic-in-else-body/options.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-do-expression,-for-classic-loop,-outer-topic-reference-in-loop-head/options.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-if-statement-and-topic-in-else-body/options.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-do-expression,-if-statement,-outer-topic-reference-in-else-body/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-if-statement-and-topic-in-else-body/output.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-do-expression,-if-statement,-outer-topic-reference-in-else-body/output.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-if-statement-and-topic-in-else-body/output.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-if-statement-and-topic-in-else-if-body/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-if-statement-and-topic-in-else-if-body/input.js new file mode 100644 index 0000000000..0b1fd66aaa --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-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/proposal-smart-topic-style,-do-expression,-for-in-loop,-outer-topic-reference-in-loop-head/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-if-statement-and-topic-in-else-if-body/options.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-do-expression,-for-in-loop,-outer-topic-reference-in-loop-head/options.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-if-statement-and-topic-in-else-if-body/options.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-do-expression,-if-statement,-outer-topic-reference-in-else-if-body/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-if-statement-and-topic-in-else-if-body/output.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-do-expression,-if-statement,-outer-topic-reference-in-else-if-body/output.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-if-statement-and-topic-in-else-if-body/output.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-if-statement-and-topic-in-if-body/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-if-statement-and-topic-in-if-body/input.js new file mode 100644 index 0000000000..bd64bfb5b7 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-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/proposal-smart-topic-style,-do-expression,-for-of-loop,-outer-topic-reference-in-loop-head/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-if-statement-and-topic-in-if-body/options.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-do-expression,-for-of-loop,-outer-topic-reference-in-loop-head/options.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-if-statement-and-topic-in-if-body/options.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-do-expression,-if-statement,-outer-topic-reference-in-if-body/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-if-statement-and-topic-in-if-body/output.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-do-expression,-if-statement,-outer-topic-reference-in-if-body/output.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-if-statement-and-topic-in-if-body/output.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-if-statement-and-topic-in-if-head/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-if-statement-and-topic-in-if-head/input.js new file mode 100644 index 0000000000..8457c4e57f --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-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/proposal-smart-topic-style,-do-expression,-identity/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-if-statement-and-topic-in-if-head/options.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-do-expression,-identity/options.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-if-statement-and-topic-in-if-head/options.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-do-expression,-if-statement,-outer-topic-reference-in-if-head/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-if-statement-and-topic-in-if-head/output.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-do-expression,-if-statement,-outer-topic-reference-in-if-head/output.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-if-statement-and-topic-in-if-head/output.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-switch-statement-and-topic-in-switch-body/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-switch-statement-and-topic-in-switch-body/input.js new file mode 100644 index 0000000000..c9562d4318 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-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/proposal-smart-topic-style,-do-expression,-if-statement,-outer-topic-reference-in-else-body/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-switch-statement-and-topic-in-switch-body/options.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-do-expression,-if-statement,-outer-topic-reference-in-else-body/options.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-switch-statement-and-topic-in-switch-body/options.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-do-expression,-switch-statement,-outer-topic-reference-in-switch-body/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-switch-statement-and-topic-in-switch-body/output.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-do-expression,-switch-statement,-outer-topic-reference-in-switch-body/output.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-switch-statement-and-topic-in-switch-body/output.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-switch-statement-and-topic-in-switch-head/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-switch-statement-and-topic-in-switch-head/input.js new file mode 100644 index 0000000000..77e4a2ddcf --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-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/proposal-smart-topic-style,-do-expression,-if-statement,-outer-topic-reference-in-else-if-body/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-switch-statement-and-topic-in-switch-head/options.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-do-expression,-if-statement,-outer-topic-reference-in-else-if-body/options.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-switch-statement-and-topic-in-switch-head/options.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-do-expression,-switch-statement,-outer-topic-reference-in-switch-head/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-switch-statement-and-topic-in-switch-head/output.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-do-expression,-switch-statement,-outer-topic-reference-in-switch-head/output.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-switch-statement-and-topic-in-switch-head/output.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-topic-identity/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-topic-identity/input.js new file mode 100644 index 0000000000..f78ceb724f --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-topic-identity/input.js @@ -0,0 +1 @@ +value |> do { #; } diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-do-expression,-if-statement,-outer-topic-reference-in-if-body/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-topic-identity/options.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-do-expression,-if-statement,-outer-topic-reference-in-if-body/options.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-topic-identity/options.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-do-expression,-identity/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-topic-identity/output.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-do-expression,-identity/output.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-topic-identity/output.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-try-catch-finally-statements-and-topic-in-catch-clause/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-try-catch-finally-statements-and-topic-in-catch-clause/input.js new file mode 100644 index 0000000000..bd64c4dd87 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-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/proposal-smart-topic-style,-do-expression,-if-statement,-outer-topic-reference-in-if-head/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-try-catch-finally-statements-and-topic-in-catch-clause/options.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-do-expression,-if-statement,-outer-topic-reference-in-if-head/options.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-try-catch-finally-statements-and-topic-in-catch-clause/options.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-unbound-topic,-do-expression,-try-statement,-outer-topic-reference-in-catch-clause/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-try-catch-finally-statements-and-topic-in-catch-clause/output.json similarity index 99% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-unbound-topic,-do-expression,-try-statement,-outer-topic-reference-in-catch-clause/output.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-try-catch-finally-statements-and-topic-in-catch-clause/output.json index fe3ce80ecf..3d8a3d363d 100644 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-unbound-topic,-do-expression,-try-statement,-outer-topic-reference-in-catch-clause/output.json +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-try-catch-finally-statements-and-topic-in-catch-clause/output.json @@ -2,7 +2,7 @@ "type": "File", "start":0,"end":78,"loc":{"start":{"line":1,"column":0},"end":{"line":4,"column":1}}, "errors": [ - "SyntaxError: Topic reference was used in a lexical context without topic binding. (3:32)" + "SyntaxError: Topic reference was used in a lexical context without topic binding. (3:33)" ], "program": { "type": "Program", diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-try-catch-finally-statements-and-topic-in-finally-clause/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-try-catch-finally-statements-and-topic-in-finally-clause/input.js new file mode 100644 index 0000000000..46ec28c2e7 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-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/proposal-smart-topic-style,-do-expression,-switch-statement,-outer-topic-reference-in-switch-body/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-try-catch-finally-statements-and-topic-in-finally-clause/options.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-do-expression,-switch-statement,-outer-topic-reference-in-switch-body/options.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-try-catch-finally-statements-and-topic-in-finally-clause/options.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-do-expression,-try-statement,-outer-topic-reference-in-finally-clause-with-catch-and-finally/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-try-catch-finally-statements-and-topic-in-finally-clause/output.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-do-expression,-try-statement,-outer-topic-reference-in-finally-clause-with-catch-and-finally/output.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-try-catch-finally-statements-and-topic-in-finally-clause/output.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-try-catch-finally-statements-and-topic-in-try-clause/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-try-catch-finally-statements-and-topic-in-try-clause/input.js new file mode 100644 index 0000000000..dd034b6081 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-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/proposal-smart-topic-style,-do-expression,-switch-statement,-outer-topic-reference-in-switch-head/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-try-catch-finally-statements-and-topic-in-try-clause/options.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-do-expression,-switch-statement,-outer-topic-reference-in-switch-head/options.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-try-catch-finally-statements-and-topic-in-try-clause/options.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-do-expression,-try-statement,-outer-topic-reference-in-try-clause-with-catch-and-finally/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-try-catch-finally-statements-and-topic-in-try-clause/output.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-do-expression,-try-statement,-outer-topic-reference-in-try-clause-with-catch-and-finally/output.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-try-catch-finally-statements-and-topic-in-try-clause/output.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-try-catch-statements-topic-in-try-clause/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-try-catch-statements-topic-in-try-clause/input.js new file mode 100644 index 0000000000..70eb5263f2 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-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/proposal-smart-topic-style,-do-expression,-try-statement,-outer-topic-reference-in-finally-clause-with-catch-and-finally/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-try-catch-statements-topic-in-try-clause/options.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-do-expression,-try-statement,-outer-topic-reference-in-finally-clause-with-catch-and-finally/options.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-try-catch-statements-topic-in-try-clause/options.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-do-expression,-try-statement,-outer-topic-reference-in-try-clause-with-catch/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-try-catch-statements-topic-in-try-clause/output.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-do-expression,-try-statement,-outer-topic-reference-in-try-clause-with-catch/output.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-try-catch-statements-topic-in-try-clause/output.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-while-loop-topic-in-loop-body/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-while-loop-topic-in-loop-body/input.js new file mode 100644 index 0000000000..06cfc1f2be --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-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/proposal-smart-topic-style,-do-expression,-try-statement,-outer-topic-reference-in-try-clause-with-catch-and-finally/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-while-loop-topic-in-loop-body/options.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-do-expression,-try-statement,-outer-topic-reference-in-try-clause-with-catch-and-finally/options.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-while-loop-topic-in-loop-body/options.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-unbound-topic,-do-expression,-while-loop,-outer-topic-reference-in-loop-body/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-while-loop-topic-in-loop-body/output.json similarity index 99% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-unbound-topic,-do-expression,-while-loop,-outer-topic-reference-in-loop-body/output.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-while-loop-topic-in-loop-body/output.json index bf6ede1d56..ccd647133f 100644 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-unbound-topic,-do-expression,-while-loop,-outer-topic-reference-in-loop-body/output.json +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-while-loop-topic-in-loop-body/output.json @@ -2,7 +2,7 @@ "type": "File", "start":0,"end":38,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":38}}, "errors": [ - "SyntaxError: Topic reference was used in a lexical context without topic binding. (1:34)", + "SyntaxError: Topic reference was used in a lexical context without topic binding. (1:35)", "SyntaxError: Pipeline is in topic style but does not use topic reference. (1:9)" ], "program": { diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-while-loop-topic-in-loop-head/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-while-loop-topic-in-loop-head/input.js new file mode 100644 index 0000000000..be80210715 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-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/proposal-smart-topic-style,-do-expression,-try-statement,-outer-topic-reference-in-try-clause-with-catch/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-while-loop-topic-in-loop-head/options.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-do-expression,-try-statement,-outer-topic-reference-in-try-clause-with-catch/options.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-while-loop-topic-in-loop-head/options.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-do-expression,-while-loop,-outer-topic-reference-in-loop-head/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-while-loop-topic-in-loop-head/output.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-do-expression,-while-loop,-outer-topic-reference-in-loop-head/output.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-while-loop-topic-in-loop-head/output.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-with-block-topic-in-body/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-with-block-topic-in-body/input.js new file mode 100644 index 0000000000..4872290c99 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-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/proposal-smart-topic-style,-do-expression,-while-loop,-outer-topic-reference-in-loop-head/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-with-block-topic-in-body/options.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-do-expression,-while-loop,-outer-topic-reference-in-loop-head/options.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-with-block-topic-in-body/options.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-unbound-topic,-do-expression,-with-statement,-outer-topic-reference-in-with-body/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-with-block-topic-in-body/output.json similarity index 98% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-unbound-topic,-do-expression,-with-statement,-outer-topic-reference-in-with-body/output.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-with-block-topic-in-body/output.json index 7caf81f88f..17c7f5b6be 100644 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-unbound-topic,-do-expression,-with-statement,-outer-topic-reference-in-with-body/output.json +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-do-transform-with-block-topic-in-body/output.json @@ -2,7 +2,7 @@ "type": "File", "start":0,"end":28,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":28}}, "errors": [ - "SyntaxError: Topic reference was used in a lexical context without topic binding. (1:24)", + "SyntaxError: Topic reference was used in a lexical context without topic binding. (1:25)", "SyntaxError: Pipeline is in topic style but does not use topic reference. (1:9)" ], "program": { diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-function-call-with-topic-in-argument/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-function-call-with-topic-in-argument/input.js new file mode 100644 index 0000000000..e8678f6a2b --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-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/proposal-smart-error,-topic-style,-no-topic-reference,-class-expression/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-function-call-with-topic-in-argument/options.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-no-topic-reference,-class-expression/options.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-function-call-with-topic-in-argument/options.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-function-call,-identifier-with-topic-reference/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-function-call-with-topic-in-argument/output.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-function-call,-identifier-with-topic-reference/output.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-function-call-with-topic-in-argument/output.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-function-definition-with-another-pipe-in-function-body/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-function-definition-with-another-pipe-in-function-body/input.js new file mode 100644 index 0000000000..818748040e --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-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/proposal-smart-error,-topic-style,-no-topic-reference,-function-expression/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-function-definition-with-another-pipe-in-function-body/options.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-no-topic-reference,-function-expression/options.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-function-definition-with-another-pipe-in-function-body/options.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-unbound-topic,-pipeline-head-in-inner-function-in-pipeline-body/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-function-definition-with-another-pipe-in-function-body/output.json similarity index 98% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-unbound-topic,-pipeline-head-in-inner-function-in-pipeline-body/output.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-function-definition-with-another-pipe-in-function-body/output.json index 9e45ecfa0c..11a8ace33f 100644 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-unbound-topic,-pipeline-head-in-inner-function-in-pipeline-body/output.json +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-function-definition-with-another-pipe-in-function-body/output.json @@ -2,7 +2,7 @@ "type": "File", "start":0,"end":27,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":27}}, "errors": [ - "SyntaxError: Topic reference was used in a lexical context without topic binding. (1:19)", + "SyntaxError: Topic reference was used in a lexical context without topic binding. (1:21)", "SyntaxError: Pipeline is in topic style but does not use topic reference. (1:5)" ], "program": { diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-function-definition-with-topic-in-default-parameter/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-function-definition-with-topic-in-default-parameter/input.js new file mode 100644 index 0000000000..432d1c9ed8 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-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/proposal-smart-error,-unbound-topic,-inner-class-in-pipeline-body/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-function-definition-with-topic-in-default-parameter/options.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-unbound-topic,-inner-class-in-pipeline-body/options.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-function-definition-with-topic-in-default-parameter/options.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-function-definition,-outer-topic-reference-in-default-parameter-expression/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-function-definition-with-topic-in-default-parameter/output.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-function-definition,-outer-topic-reference-in-default-parameter-expression/output.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-function-definition-with-topic-in-default-parameter/output.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-function-definition-with-topic-in-function-body/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-function-definition-with-topic-in-function-body/input.js new file mode 100644 index 0000000000..8af92dbefe --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-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/proposal-smart-error,-unbound-topic,-inner-function-in-pipeline-body/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-function-definition-with-topic-in-function-body/options.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-unbound-topic,-inner-function-in-pipeline-body/options.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-function-definition-with-topic-in-function-body/options.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-unbound-topic,-inner-function-in-pipeline-body/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-function-definition-with-topic-in-function-body/output.json similarity index 98% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-unbound-topic,-inner-function-in-pipeline-body/output.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-function-definition-with-topic-in-function-body/output.json index 88eb526ee2..92ea7f23e1 100644 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-unbound-topic,-inner-function-in-pipeline-body/output.json +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-function-definition-with-topic-in-function-body/output.json @@ -2,7 +2,7 @@ "type": "File", "start":0,"end":22,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":22}}, "errors": [ - "SyntaxError: Topic reference was used in a lexical context without topic binding. (1:19)", + "SyntaxError: Topic reference was used in a lexical context without topic binding. (1:21)", "SyntaxError: Pipeline is in topic style but does not use topic reference. (1:5)" ], "program": { diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-generator-yield-parenthesized/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-generator-yield-parenthesized/input.js new file mode 100644 index 0000000000..1770468805 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-generator-yield-parenthesized/input.js @@ -0,0 +1,3 @@ +function * f (x) { + return x |> (yield #); +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-unbound-topic,-pipeline-head-in-inner-function-in-pipeline-body/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-generator-yield-parenthesized/options.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-unbound-topic,-pipeline-head-in-inner-function-in-pipeline-body/options.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-generator-yield-parenthesized/options.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-generator-yield/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-generator-yield-parenthesized/output.json similarity index 64% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-generator-yield/output.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-generator-yield-parenthesized/output.json index 3df77e4676..2350a5393f 100644 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-generator-yield/output.json +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-generator-yield-parenthesized/output.json @@ -1,15 +1,15 @@ { "type": "File", - "start":0,"end":44,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}}, + "start":0,"end":45,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}}, "program": { "type": "Program", - "start":0,"end":44,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}}, + "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":44,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}}, + "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"}, @@ -17,37 +17,43 @@ }, "generator": true, "async": false, - "params": [], + "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":16,"end":44,"loc":{"start":{"line":1,"column":16},"end":{"line":3,"column":1}}, + "start":17,"end":45,"loc":{"start":{"line":1,"column":17},"end":{"line":3,"column":1}}, "body": [ { "type": "ReturnStatement", - "start":20,"end":42,"loc":{"start":{"line":2,"column":2},"end":{"line":2,"column":24}}, + "start":21,"end":43,"loc":{"start":{"line":2,"column":2},"end":{"line":2,"column":24}}, "argument": { "type": "BinaryExpression", - "start":27,"end":41,"loc":{"start":{"line":2,"column":9},"end":{"line":2,"column":23}}, + "start":28,"end":42,"loc":{"start":{"line":2,"column":9},"end":{"line":2,"column":23}}, "left": { "type": "Identifier", - "start":27,"end":28,"loc":{"start":{"line":2,"column":9},"end":{"line":2,"column":10},"identifierName":"x"}, + "start":28,"end":29,"loc":{"start":{"line":2,"column":9},"end":{"line":2,"column":10},"identifierName":"x"}, "name": "x" }, "operator": "|>", "right": { "type": "PipelineTopicExpression", - "start":32,"end":41,"loc":{"start":{"line":2,"column":14},"end":{"line":2,"column":23}}, + "start":33,"end":42,"loc":{"start":{"line":2,"column":14},"end":{"line":2,"column":23}}, "expression": { "type": "YieldExpression", - "start":33,"end":40,"loc":{"start":{"line":2,"column":15},"end":{"line":2,"column":22}}, + "start":34,"end":41,"loc":{"start":{"line":2,"column":15},"end":{"line":2,"column":22}}, + "extra": { + "parenthesized": true, + "parenStart": 33 + }, "delegate": false, "argument": { "type": "PipelinePrimaryTopicReference", - "start":39,"end":40,"loc":{"start":{"line":2,"column":21},"end":{"line":2,"column":22}} - }, - "extra": { - "parenthesized": true, - "parenStart": 32 + "start":40,"end":41,"loc":{"start":{"line":2,"column":21},"end":{"line":2,"column":22}} } } } diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-generator-yield-unparenthesized/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-generator-yield-unparenthesized/input.js new file mode 100644 index 0000000000..90672d043b --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-generator-yield-unparenthesized/input.js @@ -0,0 +1,3 @@ +function * f (x) { + return x |> yield #; +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-generator-yield-unparenthesized/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-generator-yield-unparenthesized/options.json new file mode 100644 index 0000000000..1c31a8b939 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-generator-yield-unparenthesized/options.json @@ -0,0 +1,4 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "smart" }]], + "throws": "Unexpected yield after pipeline body; any yield expression acting as Hack-style pipe body must be parenthesized due to its loose operator precedence. (2:14)" +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-hash-tuple/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-hash-tuple/input.js new file mode 100644 index 0000000000..eb22843797 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-hash-tuple/input.js @@ -0,0 +1,2 @@ +#[0]; +1 |> #[0]; diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-hash-tuple/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-hash-tuple/options.json new file mode 100644 index 0000000000..bfad2e9eea --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-hash-tuple/options.json @@ -0,0 +1,7 @@ +{ + "plugins": [ + ["pipelineOperator", { "proposal": "smart" }], + ["recordAndTuple", { "syntaxType": "hash" }] + ], + "throws": "Plugin conflict between `[\"pipelineOperator\", { proposal: \"smart\" }]` and `[\"recordAndtuple\", { syntaxType: \"hash\"}]`." +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-invalid-hash-then-digit/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-invalid-hash-then-digit/input.js new file mode 100644 index 0000000000..b18a6404b5 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-invalid-hash-then-digit/input.js @@ -0,0 +1 @@ +x |> #42; diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-invalid-hash-then-digit/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-invalid-hash-then-digit/options.json new file mode 100644 index 0000000000..315056596f --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-invalid-hash-then-digit/options.json @@ -0,0 +1,12 @@ +{ + "plugins": [ + [ + "pipelineOperator", + { + "proposal": "smart", + "topicToken": "#" + } + ] + ], + "throws": "Unexpected digit after hash token. (1:5)" +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-modulo-with-topic/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-modulo-with-topic/input.js new file mode 100644 index 0000000000..7d8db91bd9 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-modulo-with-topic/input.js @@ -0,0 +1 @@ +value |> # % 2 diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-nested-pipelines,-topic-style-with-arrow-function-with-bare-style/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-modulo-with-topic/options.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-nested-pipelines,-topic-style-with-arrow-function-with-bare-style/options.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-modulo-with-topic/options.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-modulo-with-topic/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-modulo-with-topic/output.json new file mode 100644 index 0000000000..dd6ca8999c --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-modulo-with-topic/output.json @@ -0,0 +1,49 @@ +{ + "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": "PipelineTopicExpression", + "start":9,"end":14,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":14}}, + "expression": { + "type": "BinaryExpression", + "start":9,"end":14,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":14}}, + "left": { + "type": "PipelinePrimaryTopicReference", + "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/proposal-smart-nested-pipelines,-topic-style-with-arrow-function-with-topic-style/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-nested-pipelines-with-arrow-function-and-function-call/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-nested-pipelines,-topic-style-with-arrow-function-with-topic-style/input.js rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-nested-pipelines-with-arrow-function-and-function-call/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-nested-pipelines,-topic-style-with-arrow-function-with-topic-style/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-nested-pipelines-with-arrow-function-and-function-call/options.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-nested-pipelines,-topic-style-with-arrow-function-with-topic-style/options.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-nested-pipelines-with-arrow-function-and-function-call/options.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-nested-pipelines,-topic-style-with-arrow-function-with-topic-style/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-nested-pipelines-with-arrow-function-and-function-call/output.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-nested-pipelines,-topic-style-with-arrow-function-with-topic-style/output.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-nested-pipelines-with-arrow-function-and-function-call/output.json index c110c8d178..63b9f1f244 100644 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-nested-pipelines,-topic-style-with-arrow-function-with-topic-style/output.json +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-nested-pipelines-with-arrow-function-and-function-call/output.json @@ -25,6 +25,10 @@ "expression": { "type": "ArrowFunctionExpression", "start":6,"end":23,"loc":{"start":{"line":1,"column":6},"end":{"line":1,"column":23}}, + "extra": { + "parenthesized": true, + "parenStart": 5 + }, "id": null, "generator": false, "async": false, @@ -67,10 +71,6 @@ ] } } - }, - "extra": { - "parenthesized": true, - "parenStart": 5 } } } diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-nested-pipelines,-topic-style-with-arrow-function-with-bare-style/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-nested-pipelines-with-arrow-function-and-tacit-function-call-with-outer-topic/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-nested-pipelines,-topic-style-with-arrow-function-with-bare-style/input.js rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-nested-pipelines-with-arrow-function-and-tacit-function-call-with-outer-topic/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-nested-pipelines,-topic-style-with-inner-bare-style/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-nested-pipelines-with-arrow-function-and-tacit-function-call-with-outer-topic/options.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-nested-pipelines,-topic-style-with-inner-bare-style/options.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-nested-pipelines-with-arrow-function-and-tacit-function-call-with-outer-topic/options.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-nested-pipelines,-topic-style-with-arrow-function-with-bare-style/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-nested-pipelines-with-arrow-function-and-tacit-function-call-with-outer-topic/output.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-nested-pipelines,-topic-style-with-arrow-function-with-bare-style/output.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-nested-pipelines-with-arrow-function-and-tacit-function-call-with-outer-topic/output.json index 2aeb5206b5..2d6e9d4391 100644 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-nested-pipelines,-topic-style-with-arrow-function-with-bare-style/output.json +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-nested-pipelines-with-arrow-function-and-tacit-function-call-with-outer-topic/output.json @@ -25,6 +25,10 @@ "expression": { "type": "ArrowFunctionExpression", "start":6,"end":18,"loc":{"start":{"line":1,"column":6},"end":{"line":1,"column":18}}, + "extra": { + "parenthesized": true, + "parenStart": 5 + }, "id": null, "generator": false, "async": false, @@ -46,10 +50,6 @@ "name": "f" } } - }, - "extra": { - "parenthesized": true, - "parenStart": 5 } } } diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-nested-pipelines,-topic-style-with-arrow-function-with-bare-style,-no-outer-topic-reference/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-nested-pipelines-with-arrow-function-and-tacit-function-call-without-outer-topic/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-nested-pipelines,-topic-style-with-arrow-function-with-bare-style,-no-outer-topic-reference/input.js rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-nested-pipelines-with-arrow-function-and-tacit-function-call-without-outer-topic/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-nested-pipelines,-topic-style-with-inner-topic-style/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-nested-pipelines-with-arrow-function-and-tacit-function-call-without-outer-topic/options.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-nested-pipelines,-topic-style-with-inner-topic-style/options.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-nested-pipelines-with-arrow-function-and-tacit-function-call-without-outer-topic/options.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-nested-pipelines,-topic-style-with-arrow-function-with-bare-style,-no-outer-topic-reference/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-nested-pipelines-with-arrow-function-and-tacit-function-call-without-outer-topic/output.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-nested-pipelines,-topic-style-with-arrow-function-with-bare-style,-no-outer-topic-reference/output.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-nested-pipelines-with-arrow-function-and-tacit-function-call-without-outer-topic/output.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-nested-pipelines-with-arrow-function-with-required-topics/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-nested-pipelines-with-arrow-function-with-required-topics/input.js new file mode 100644 index 0000000000..a3cfa26e12 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-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/proposal-smart-topic-style,-addition,-single-line-arrow-function,-topic-reference-first/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-nested-pipelines-with-arrow-function-with-required-topics/options.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-addition,-single-line-arrow-function,-topic-reference-first/options.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-nested-pipelines-with-arrow-function-with-required-topics/options.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-nested-pipelines-with-arrow-function-with-required-topics/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-nested-pipelines-with-arrow-function-with-required-topics/output.json new file mode 100644 index 0000000000..094803f514 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-nested-pipelines-with-arrow-function-with-required-topics/output.json @@ -0,0 +1,109 @@ +{ + "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": "PipelineTopicExpression", + "start":5,"end":33,"loc":{"start":{"line":1,"column":5},"end":{"line":1,"column":33}}, + "expression": { + "type": "ArrowFunctionExpression", + "start":6,"end":32,"loc":{"start":{"line":1,"column":6},"end":{"line":1,"column":32}}, + "extra": { + "parenthesized": true, + "parenStart": 5 + }, + "id": null, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "start":6,"end":7,"loc":{"start":{"line":1,"column":6},"end":{"line":1,"column":7},"identifierName":"$"}, + "name": "$" + } + ], + "body": { + "type": "BinaryExpression", + "start":11,"end":32,"loc":{"start":{"line":1,"column":11},"end":{"line":1,"column":32}}, + "left": { + "type": "BinaryExpression", + "start":11,"end":23,"loc":{"start":{"line":1,"column":11},"end":{"line":1,"column":23}}, + "left": { + "type": "PipelinePrimaryTopicReference", + "start":11,"end":12,"loc":{"start":{"line":1,"column":11},"end":{"line":1,"column":12}} + }, + "operator": "|>", + "right": { + "type": "PipelineTopicExpression", + "start":16,"end":23,"loc":{"start":{"line":1,"column":16},"end":{"line":1,"column":23}}, + "expression": { + "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": "PipelinePrimaryTopicReference", + "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": "PipelineTopicExpression", + "start":27,"end":32,"loc":{"start":{"line":1,"column":27},"end":{"line":1,"column":32}}, + "expression": { + "type": "BinaryExpression", + "start":27,"end":32,"loc":{"start":{"line":1,"column":27},"end":{"line":1,"column":32}}, + "left": { + "type": "PipelinePrimaryTopicReference", + "start":27,"end":28,"loc":{"start":{"line":1,"column":27},"end":{"line":1,"column":28}} + }, + "operator": ">", + "right": { + "type": "NumericLiteral", + "start":31,"end":32,"loc":{"start":{"line":1,"column":31},"end":{"line":1,"column":32}}, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + } + } + } + } + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-nested-pipelines-with-arrow-function-without-inner-topic/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-nested-pipelines-with-arrow-function-without-inner-topic/input.js new file mode 100644 index 0000000000..98e99a4493 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-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/proposal-smart-topic-style,-addition,-single-line-arrow-function,-topic-reference-last/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-nested-pipelines-with-arrow-function-without-inner-topic/options.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-addition,-single-line-arrow-function,-topic-reference-last/options.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-nested-pipelines-with-arrow-function-without-inner-topic/options.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-nested-pipelines,-topic-style-with-arrow-function-with-topic-style,-no-inner-topic-reference/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-nested-pipelines-with-arrow-function-without-inner-topic/output.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-nested-pipelines,-topic-style-with-arrow-function-with-topic-style,-no-inner-topic-reference/output.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-nested-pipelines-with-arrow-function-without-inner-topic/output.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-nested-pipelines-with-arrow-function-without-outer-topic/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-nested-pipelines-with-arrow-function-without-outer-topic/input.js new file mode 100644 index 0000000000..a4723737f3 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-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/proposal-smart-topic-style,-async-await/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-nested-pipelines-with-arrow-function-without-outer-topic/options.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-async-await/options.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-nested-pipelines-with-arrow-function-without-outer-topic/options.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-nested-pipelines,-topic-style-with-arrow-function-with-topic-style,-no-outer-topic-reference/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-nested-pipelines-with-arrow-function-without-outer-topic/output.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-nested-pipelines,-topic-style-with-arrow-function-with-topic-style,-no-outer-topic-reference/output.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-nested-pipelines-with-arrow-function-without-outer-topic/output.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-nested-pipelines-with-function-call/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-nested-pipelines-with-function-call/input.js new file mode 100644 index 0000000000..2668daa465 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-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/proposal-smart-topic-style,-function-call,-identifier-with-topic-reference/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-nested-pipelines-with-function-call/options.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-function-call,-identifier-with-topic-reference/options.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-nested-pipelines-with-function-call/options.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-nested-pipelines,-topic-style-with-inner-topic-style/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-nested-pipelines-with-function-call/output.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-nested-pipelines,-topic-style-with-inner-topic-style/output.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-nested-pipelines-with-function-call/output.json index a2fd989f47..850c276d29 100644 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-nested-pipelines,-topic-style-with-inner-topic-style/output.json +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-nested-pipelines-with-function-call/output.json @@ -25,6 +25,10 @@ "expression": { "type": "BinaryExpression", "start":6,"end":18,"loc":{"start":{"line":1,"column":6},"end":{"line":1,"column":18}}, + "extra": { + "parenthesized": true, + "parenStart": 5 + }, "left": { "type": "PipelinePrimaryTopicReference", "start":6,"end":7,"loc":{"start":{"line":1,"column":6},"end":{"line":1,"column":7}} @@ -53,10 +57,6 @@ } ] } - }, - "extra": { - "parenthesized": true, - "parenStart": 5 } } } diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-nested-pipelines,-topic-style-with-inner-bare-style/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-nested-pipelines-with-tacit-function-call/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-nested-pipelines,-topic-style-with-inner-bare-style/input.js rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-nested-pipelines-with-tacit-function-call/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-function-definition,-outer-topic-reference-in-default-parameter-expression/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-nested-pipelines-with-tacit-function-call/options.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-function-definition,-outer-topic-reference-in-default-parameter-expression/options.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-nested-pipelines-with-tacit-function-call/options.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-nested-pipelines,-topic-style-with-inner-bare-style/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-nested-pipelines-with-tacit-function-call/output.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-nested-pipelines,-topic-style-with-inner-bare-style/output.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-nested-pipelines-with-tacit-function-call/output.json index 4259a597ed..9e827bd22c 100644 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-nested-pipelines,-topic-style-with-inner-bare-style/output.json +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-nested-pipelines-with-tacit-function-call/output.json @@ -25,6 +25,10 @@ "expression": { "type": "BinaryExpression", "start":6,"end":12,"loc":{"start":{"line":1,"column":6},"end":{"line":1,"column":12}}, + "extra": { + "parenthesized": true, + "parenStart": 5 + }, "left": { "type": "PipelinePrimaryTopicReference", "start":6,"end":7,"loc":{"start":{"line":1,"column":6},"end":{"line":1,"column":7}} @@ -38,10 +42,6 @@ "start":11,"end":12,"loc":{"start":{"line":1,"column":11},"end":{"line":1,"column":12},"identifierName":"f"}, "name": "f" } - }, - "extra": { - "parenthesized": true, - "parenStart": 5 } } } diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-nested-pipelines-without-inner-topic/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-nested-pipelines-without-inner-topic/input.js new file mode 100644 index 0000000000..50b90bb9ad --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-nested-pipelines-without-inner-topic/input.js @@ -0,0 +1 @@ +x |> (# |> f()) diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-generator-yield/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-nested-pipelines-without-inner-topic/options.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-generator-yield/options.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-nested-pipelines-without-inner-topic/options.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-nested-pipelines,-topic-style-with-inner-topic-style,-no-inner-topic-reference/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-nested-pipelines-without-inner-topic/output.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-nested-pipelines,-topic-style-with-inner-topic-style,-no-inner-topic-reference/output.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-nested-pipelines-without-inner-topic/output.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-nested-pipelines-without-outer-topic/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-nested-pipelines-without-outer-topic/input.js new file mode 100644 index 0000000000..9d00837048 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-nested-pipelines-without-outer-topic/input.js @@ -0,0 +1 @@ +x |> ($ |> f) diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-identity,-parenthesized/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-nested-pipelines-without-outer-topic/options.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-identity,-parenthesized/options.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-nested-pipelines-without-outer-topic/options.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-nested-pipelines,-topic-style-with-inner-topic-style,-no-outer-topic-reference/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-nested-pipelines-without-outer-topic/output.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-nested-pipelines,-topic-style-with-inner-topic-style,-no-outer-topic-reference/output.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-nested-pipelines-without-outer-topic/output.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-no-topic-class-expression/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-no-topic-class-expression/input.js new file mode 100644 index 0000000000..6ccb6ca133 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-no-topic-class-expression/input.js @@ -0,0 +1 @@ +value |> class { } diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-identity,-unparenthesized/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-no-topic-class-expression/options.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-identity,-unparenthesized/options.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-no-topic-class-expression/options.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-no-topic-reference,-class-expression/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-no-topic-class-expression/output.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-no-topic-reference,-class-expression/output.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-no-topic-class-expression/output.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-no-topic-function-expression/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-no-topic-function-expression/input.js new file mode 100644 index 0000000000..faf09879d6 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-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/proposal-smart-topic-style,-parenthesized-single-line-arrow-function,-with-empty-parameter-list-and-bare-addition-body/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-no-topic-function-expression/options.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-parenthesized-single-line-arrow-function,-with-empty-parameter-list-and-bare-addition-body/options.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-no-topic-function-expression/options.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-no-topic-reference,-function-expression/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-no-topic-function-expression/output.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-no-topic-reference,-function-expression/output.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-no-topic-function-expression/output.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-non-generator-yield-identifier/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-non-generator-yield-identifier/input.js new file mode 100644 index 0000000000..3d85a40bae --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-non-generator-yield-identifier/input.js @@ -0,0 +1 @@ +x |> yield + #; diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-non-generator-yield-identifier/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-non-generator-yield-identifier/options.json new file mode 100644 index 0000000000..17e4e327bb --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-non-generator-yield-identifier/options.json @@ -0,0 +1,3 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "smart" }]] +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-non-generator-yield-identifier/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-non-generator-yield-identifier/output.json new file mode 100644 index 0000000000..4a85028069 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-non-generator-yield-identifier/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":1,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":1},"identifierName":"x"}, + "name": "x" + }, + "operator": "|>", + "right": { + "type": "PipelineTopicExpression", + "start":5,"end":14,"loc":{"start":{"line":1,"column":5},"end":{"line":1,"column":14}}, + "expression": { + "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": "PipelinePrimaryTopicReference", + "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/smart-proposal-private-property-in-private-method/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-private-property-in-private-method/input.js new file mode 100644 index 0000000000..b53ef573f7 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-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/smart-proposal-private-property-in-private-method/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-private-property-in-private-method/options.json new file mode 100644 index 0000000000..b790a145ef --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-private-property-in-private-method/options.json @@ -0,0 +1,7 @@ +{ + "plugins": [ + ["pipelineOperator", { "proposal": "smart" }], + "classPrivateProperties", + "classPrivateMethods" + ] +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-private-property-in-private-method/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-private-property-in-private-method/output.json new file mode 100644 index 0000000000..ef9efd9c68 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-private-property-in-private-method/output.json @@ -0,0 +1,115 @@ +{ + "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": "PipelineTopicExpression", + "start":56,"end":74,"loc":{"start":{"line":5,"column":13},"end":{"line":5,"column":31}}, + "expression": { + "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": "PipelinePrimaryTopicReference", + "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/smart-proposal-tacit-function-call-on-identifier/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-tacit-function-call-on-identifier/input.js new file mode 100644 index 0000000000..15a3d7657b --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-tacit-function-call-on-identifier/input.js @@ -0,0 +1 @@ +value |> f diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-tacit-function-call-on-identifier/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-tacit-function-call-on-identifier/options.json new file mode 100644 index 0000000000..17e4e327bb --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-tacit-function-call-on-identifier/options.json @@ -0,0 +1,3 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "smart" }]] +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-function-calls,-single,-identifier/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-tacit-function-call-on-identifier/output.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-function-calls,-single,-identifier/output.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-tacit-function-call-on-identifier/output.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-function-calls,-single,-property/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-tacit-function-call-on-property/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-function-calls,-single,-property/input.js rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-tacit-function-call-on-property/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-tacit-function-call-on-property/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-tacit-function-call-on-property/options.json new file mode 100644 index 0000000000..17e4e327bb --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-tacit-function-call-on-property/options.json @@ -0,0 +1,3 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "smart" }]] +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-function-calls,-single,-property/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-tacit-function-call-on-property/output.json similarity index 94% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-function-calls,-single,-property/output.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-tacit-function-call-on-property/output.json index 8ae28448c0..aabee17cc1 100644 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-function-calls,-single,-property/output.json +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-tacit-function-call-on-property/output.json @@ -36,26 +36,26 @@ "start":9,"end":10,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":10},"identifierName":"a"}, "name": "a" }, + "computed": false, "property": { "type": "Identifier", "start":11,"end":12,"loc":{"start":{"line":1,"column":11},"end":{"line":1,"column":12},"identifierName":"b"}, "name": "b" - }, - "computed": false + } }, + "computed": false, "property": { "type": "Identifier", "start":13,"end":14,"loc":{"start":{"line":1,"column":13},"end":{"line":1,"column":14},"identifierName":"c"}, "name": "c" - }, - "computed": false + } }, + "computed": false, "property": { "type": "Identifier", "start":15,"end":16,"loc":{"start":{"line":1,"column":15},"end":{"line":1,"column":16},"identifierName":"f"}, "name": "f" - }, - "computed": false + } } } } diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-function-calls,-chained,-single-line-arrow-function/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-tacit-function-calls-chained-in-multiple-lines-inside-arrow-function/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-function-calls,-chained,-single-line-arrow-function/input.js rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-tacit-function-calls-chained-in-multiple-lines-inside-arrow-function/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-tacit-function-calls-chained-in-multiple-lines-inside-arrow-function/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-tacit-function-calls-chained-in-multiple-lines-inside-arrow-function/options.json new file mode 100644 index 0000000000..17e4e327bb --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-tacit-function-calls-chained-in-multiple-lines-inside-arrow-function/options.json @@ -0,0 +1,3 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "smart" }]] +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-function-calls,-chained,-single-line-arrow-function/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-tacit-function-calls-chained-in-multiple-lines-inside-arrow-function/output.json similarity index 98% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-function-calls,-chained,-single-line-arrow-function/output.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-tacit-function-calls-chained-in-multiple-lines-inside-arrow-function/output.json index 0827c20fe9..a19559d8fc 100644 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-function-calls,-chained,-single-line-arrow-function/output.json +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-tacit-function-calls-chained-in-multiple-lines-inside-arrow-function/output.json @@ -46,12 +46,12 @@ "start":10,"end":16,"loc":{"start":{"line":1,"column":10},"end":{"line":1,"column":16},"identifierName":"number"}, "name": "number" }, + "computed": false, "property": { "type": "Identifier", "start":17,"end":20,"loc":{"start":{"line":1,"column":17},"end":{"line":1,"column":20},"identifierName":"inc"}, "name": "inc" - }, - "computed": false + } } } }, diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-function-calls,-chained,-multiline/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-tacit-function-calls-chained-in-multiple-lines/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-function-calls,-chained,-multiline/input.js rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-tacit-function-calls-chained-in-multiple-lines/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-tacit-function-calls-chained-in-multiple-lines/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-tacit-function-calls-chained-in-multiple-lines/options.json new file mode 100644 index 0000000000..17e4e327bb --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-tacit-function-calls-chained-in-multiple-lines/options.json @@ -0,0 +1,3 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "smart" }]] +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-function-calls,-chained,-multiline/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-tacit-function-calls-chained-in-multiple-lines/output.json similarity index 96% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-function-calls,-chained,-multiline/output.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-tacit-function-calls-chained-in-multiple-lines/output.json index a5c71deace..507a7cfd36 100644 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-function-calls,-chained,-multiline/output.json +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-tacit-function-calls-chained-in-multiple-lines/output.json @@ -60,12 +60,12 @@ "start":37,"end":41,"loc":{"start":{"line":3,"column":3},"end":{"line":3,"column":7},"identifierName":"text"}, "name": "text" }, + "computed": false, "property": { "type": "Identifier", "start":42,"end":52,"loc":{"start":{"line":3,"column":8},"end":{"line":3,"column":18},"identifierName":"capitalize"}, "name": "capitalize" - }, - "computed": false + } } } }, @@ -84,19 +84,19 @@ "start":56,"end":57,"loc":{"start":{"line":4,"column":3},"end":{"line":4,"column":4},"identifierName":"a"}, "name": "a" }, + "computed": false, "property": { "type": "Identifier", "start":58,"end":59,"loc":{"start":{"line":4,"column":5},"end":{"line":4,"column":6},"identifierName":"b"}, "name": "b" - }, - "computed": false + } }, + "computed": false, "property": { "type": "Identifier", "start":60,"end":67,"loc":{"start":{"line":4,"column":7},"end":{"line":4,"column":14},"identifierName":"exclaim"}, "name": "exclaim" - }, - "computed": false + } } } } diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-topic-identity-parenthesized/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-topic-identity-parenthesized/input.js new file mode 100644 index 0000000000..a7abc2dc18 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-topic-identity-parenthesized/input.js @@ -0,0 +1 @@ +value |> (#) diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-topic-identity-parenthesized/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-topic-identity-parenthesized/options.json new file mode 100644 index 0000000000..17e4e327bb --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-topic-identity-parenthesized/options.json @@ -0,0 +1,3 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "smart" }]] +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-identity,-parenthesized/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-topic-identity-parenthesized/output.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-identity,-parenthesized/output.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-topic-identity-parenthesized/output.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-topic-identity-unparenthesized/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-topic-identity-unparenthesized/input.js new file mode 100644 index 0000000000..a18cbd0f1b --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-topic-identity-unparenthesized/input.js @@ -0,0 +1 @@ +value |> # diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-topic-identity-unparenthesized/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-topic-identity-unparenthesized/options.json new file mode 100644 index 0000000000..17e4e327bb --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-topic-identity-unparenthesized/options.json @@ -0,0 +1,3 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "smart" }]] +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-identity,-unparenthesized/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-topic-identity-unparenthesized/output.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-identity,-unparenthesized/output.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-topic-identity-unparenthesized/output.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-topic-with-optional-method-call/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-topic-with-optional-method-call/input.js new file mode 100644 index 0000000000..f9dcfac566 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-topic-with-optional-method-call/input.js @@ -0,0 +1 @@ +value |> #?.method() diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-topic-with-optional-method-call/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-topic-with-optional-method-call/options.json new file mode 100644 index 0000000000..17e4e327bb --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-topic-with-optional-method-call/options.json @@ -0,0 +1,3 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "smart" }]] +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-topic-with-optional-method-call/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-topic-with-optional-method-call/output.json new file mode 100644 index 0000000000..e852c58304 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-topic-with-optional-method-call/output.json @@ -0,0 +1,52 @@ +{ + "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": "PipelineTopicExpression", + "start":9,"end":20,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":20}}, + "expression": { + "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": "PipelinePrimaryTopicReference", + "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/smart-proposal-unbound-topic/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-unbound-topic/input.js new file mode 100644 index 0000000000..2d07bd7883 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-unbound-topic/input.js @@ -0,0 +1 @@ +1 + # diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-unbound-topic/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-unbound-topic/options.json new file mode 100644 index 0000000000..17e4e327bb --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-unbound-topic/options.json @@ -0,0 +1,3 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "smart" }]] +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-unbound-topic/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-unbound-topic/output.json new file mode 100644 index 0000000000..2f011bd014 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-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 was used in a lexical context without topic binding. (1:5)" + ], + "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": "PipelinePrimaryTopicReference", + "start":4,"end":5,"loc":{"start":{"line":1,"column":4},"end":{"line":1,"column":5}} + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/typings/babel-parser.d.ts b/packages/babel-parser/typings/babel-parser.d.ts index d4f4203a19..ead74592e0 100644 --- a/packages/babel-parser/typings/babel-parser.d.ts +++ b/packages/babel-parser/typings/babel-parser.d.ts @@ -160,7 +160,8 @@ export interface DecoratorsPluginOptions { } export interface PipelineOperatorPluginOptions { - proposal: "fsharp" | "minimal" | "smart"; + proposal: "minimal" | "fsharp" | "hack" | "smart"; + topicToken?: "#"; } export interface RecordAndTuplePluginOptions { diff --git a/packages/babel-plugin-proposal-pipeline-operator/src/hackVisitor.js b/packages/babel-plugin-proposal-pipeline-operator/src/hackVisitor.js new file mode 100644 index 0000000000..440b8df31f --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/src/hackVisitor.js @@ -0,0 +1,50 @@ +import { types as t } from "@babel/core"; + +const topicReferenceReplacementVisitor = { + TopicReference(path) { + path.replaceWith(t.cloneNode(this.topicVariable)); + }, +}; + +// This visitor traverses `BinaryExpression` +// and replaces any that use `|>` +// with sequence expressions containing assignment expressions +// with automatically generated variables, +// from inside to outside, from left to right. +export default { + BinaryExpression: { + exit(path) { + const { scope, node } = path; + + if (node.operator !== "|>") { + // The path node is a binary expression, + // but it is not a pipe expression. + return; + } + + const topicVariable = scope.generateUidIdentifierBasedOnNode(node); + const pipeBodyPath = path.get("right"); + + scope.push({ id: topicVariable }); + + if (pipeBodyPath.node.type === "TopicReference") { + // If the pipe body is itself a lone topic reference, + // then replace it with the topic variable. + pipeBodyPath.replaceWith(t.cloneNode(topicVariable)); + } else { + // Replace topic references with the topic variable. + pipeBodyPath.traverse(topicReferenceReplacementVisitor, { + topicVariable, + }); + } + + // Replace the pipe expression itself with an assignment expression. + path.replaceWith( + t.sequenceExpression([ + t.assignmentExpression("=", t.cloneNode(topicVariable), node.left), + node.right, + ]), + ); + }, + }, +}; diff --git a/packages/babel-plugin-proposal-pipeline-operator/src/index.js b/packages/babel-plugin-proposal-pipeline-operator/src/index.js index 241a99b878..6d895db28d 100644 --- a/packages/babel-plugin-proposal-pipeline-operator/src/index.js +++ b/packages/babel-plugin-proposal-pipeline-operator/src/index.js @@ -1,18 +1,28 @@ import { declare } from "@babel/helper-plugin-utils"; import syntaxPipelineOperator from "@babel/plugin-syntax-pipeline-operator"; import minimalVisitor from "./minimalVisitor"; -import smartVisitor from "./smartVisitor"; +import hackVisitor from "./hackVisitor"; import fsharpVisitor from "./fsharpVisitor"; +import smartVisitor from "./smartVisitor"; const visitorsPerProposal = { minimal: minimalVisitor, - smart: smartVisitor, + hack: hackVisitor, fsharp: fsharpVisitor, + smart: smartVisitor, }; export default declare((api, options) => { api.assertVersion(7); + const { proposal } = options; + + if (proposal === "smart") { + console.warn( + `The smart-mix pipe operator is deprecated. Use "proposal": "hack" instead.`, + ); + } + return { name: "proposal-pipeline-operator", inherits: syntaxPipelineOperator, diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/hash-tuple/input.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/hash-tuple/input.js new file mode 100644 index 0000000000..eb22843797 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/hash-tuple/input.js @@ -0,0 +1,2 @@ +#[0]; +1 |> #[0]; diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/hash-tuple/options.json b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/hash-tuple/options.json new file mode 100644 index 0000000000..ffa897bcca --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/hash-tuple/options.json @@ -0,0 +1,7 @@ +{ + "plugins": [ + ["proposal-pipeline-operator", { "proposal": "hack", "topicToken": "#" }], + ["proposal-record-and-tuple", { "syntaxType": "hash" }] + ], + "throws": "Plugin conflict between `[\"pipelineOperator\", { proposal: \"hack\", topicToken: \"#\" }]` and `[\"recordAndtuple\", { syntaxType: \"hash\"}]`." +} diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/options.json b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/options.json new file mode 100644 index 0000000000..a15caff94a --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/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-hash/pipe-body-identity/exec.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/pipe-body-identity/exec.js new file mode 100644 index 0000000000..eee45b7f19 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/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-hash/pipe-body-identity/input.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/pipe-body-identity/input.js new file mode 100644 index 0000000000..eee45b7f19 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/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-hash/pipe-body-identity/output.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/pipe-body-identity/output.js new file mode 100644 index 0000000000..ab1b473690 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/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-hash/pipe-body-with-addition/exec.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/pipe-body-with-addition/exec.js new file mode 100644 index 0000000000..8794728949 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/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-hash/pipe-body-with-addition/input.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/pipe-body-with-addition/input.js new file mode 100644 index 0000000000..8794728949 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/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-hash/pipe-body-with-addition/output.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/pipe-body-with-addition/output.js new file mode 100644 index 0000000000..73bb5a695b --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/pipe-body-with-addition/output.js @@ -0,0 +1,4 @@ +var _ref, _ref2; + +const result = (_ref2 = (_ref = 5, _ref + 1), _ref2 + _ref2); +expect(result).toBe(12); diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/pipe-body-with-arrow-function-and-nested-pipe/exec.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/pipe-body-with-arrow-function-and-nested-pipe/exec.js new file mode 100644 index 0000000000..2ac670cee1 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/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-hash/pipe-body-with-arrow-function-and-nested-pipe/input.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/pipe-body-with-arrow-function-and-nested-pipe/input.js new file mode 100644 index 0000000000..2ac670cee1 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/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-hash/pipe-body-with-arrow-function-and-nested-pipe/output.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/pipe-body-with-arrow-function-and-nested-pipe/output.js new file mode 100644 index 0000000000..01bf3aa32c --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/pipe-body-with-arrow-function-and-nested-pipe/output.js @@ -0,0 +1,8 @@ +var _ref, _ref5, _ref6; + +const result = (_ref6 = (_ref5 = (_ref = 5, Math.pow(_ref, 2)), [1, 2, 3].map(n => { + var _ref2, _ref3, _ref4; + + return _ref4 = (_ref3 = (_ref2 = n + _ref5, _ref2 * 2), `${_ref3} apples`), _ref4.toUpperCase(); +})), _ref6.join()); +expect(result).toEqual('52 APPLES,54 APPLES,56 APPLES'); diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/pipe-body-with-arrow-function/exec.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/pipe-body-with-arrow-function/exec.js new file mode 100644 index 0000000000..b9326ab317 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/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-hash/pipe-body-with-arrow-function/input.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/pipe-body-with-arrow-function/input.js new file mode 100644 index 0000000000..b9326ab317 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/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-hash/pipe-body-with-arrow-function/output.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/pipe-body-with-arrow-function/output.js new file mode 100644 index 0000000000..08ae200f6e --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/pipe-body-with-arrow-function/output.js @@ -0,0 +1,8 @@ +var _ref, _ref2, _ref3; + +const result = (_ref3 = (_ref2 = (_ref = -2.2 // -2.2 +, Math.floor(_ref) // -3 +), () => Math.pow(_ref2, 5) // () => -243 +), _ref3()); // -243 + +expect(result).toBe(-243); diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/pipe-body-with-await/exec.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/pipe-body-with-await/exec.js new file mode 100644 index 0000000000..ecd714784d --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/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-hash/pipe-body-with-await/input.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/pipe-body-with-await/input.js new file mode 100644 index 0000000000..ecd714784d --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/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/smart+arrow/await/options.json b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/pipe-body-with-await/options.json similarity index 100% rename from packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart+arrow/await/options.json rename to packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/pipe-body-with-await/options.json diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/pipe-body-with-await/output.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/pipe-body-with-await/output.js new file mode 100644 index 0000000000..133f8dbab2 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/pipe-body-with-await/output.js @@ -0,0 +1,13 @@ +function triple(x) { + return x * 3; +} + +async function asyncFunction(n) { + var _ref, _ref2, _ref3; + + return _ref3 = (_ref2 = (_ref = n, Math.abs(_ref)), await Promise.resolve(_ref2)), triple(_ref3); +} + +asyncFunction(-7).then(result => { + expect(result).toBe(21); +}); diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/pipe-body-with-class-expression-and-private-properties/exec.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/pipe-body-with-class-expression-and-private-properties/exec.js new file mode 100644 index 0000000000..3af60c246e --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/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-hash/pipe-body-with-class-expression-and-private-properties/input.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/pipe-body-with-class-expression-and-private-properties/input.js new file mode 100644 index 0000000000..3af60c246e --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/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-hash/pipe-body-with-class-expression-and-private-properties/options.json b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/pipe-body-with-class-expression-and-private-properties/options.json new file mode 100644 index 0000000000..a20aa8b560 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/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-hash/pipe-body-with-class-expression-and-private-properties/output.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/pipe-body-with-class-expression-and-private-properties/output.js new file mode 100644 index 0000000000..dcb947391c --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/pipe-body-with-class-expression-and-private-properties/output.js @@ -0,0 +1,19 @@ +var _ref, _ref2, _ref3; + +const result = (_ref3 = (_ref2 = (_ref = 1, class { + #baz; + + constructor() { + this.#baz = _ref; + } + + #bar() { + return this.#baz + 2; + } + + foo() { + return this.#bar() + 3; + } + +}), new _ref2()), _ref3.foo()); +expect(result).toBe(1 + 2 + 3); diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/pipe-body-with-eval/exec.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/pipe-body-with-eval/exec.js new file mode 100644 index 0000000000..0a1c0ce740 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/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-hash/pipe-body-with-eval/input.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/pipe-body-with-eval/input.js new file mode 100644 index 0000000000..0a1c0ce740 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/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-hash/pipe-body-with-eval/output.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/pipe-body-with-eval/output.js new file mode 100644 index 0000000000..c5dbd6107a --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/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-hash/pipe-body-with-nested-pipe/exec.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/pipe-body-with-nested-pipe/exec.js new file mode 100644 index 0000000000..8b7dd421d1 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/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-hash/pipe-body-with-nested-pipe/input.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/pipe-body-with-nested-pipe/input.js new file mode 100644 index 0000000000..8b7dd421d1 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/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-hash/pipe-body-with-nested-pipe/output.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/pipe-body-with-nested-pipe/output.js new file mode 100644 index 0000000000..482706ff44 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/pipe-body-with-nested-pipe/output.js @@ -0,0 +1,4 @@ +var _ref, _ref2, _ref3, _ref4; + +const result = (_ref4 = (_ref = 5, Math.pow(_ref, 2)), (_ref3 = (_ref2 = _ref4 + 1, `${_ref2} apples`), _ref3.toUpperCase())); +expect(result).toEqual('26 APPLES'); diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/pipe-body-with-object-literal/exec.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/pipe-body-with-object-literal/exec.js new file mode 100644 index 0000000000..06d0ad744e --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/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-hash/pipe-body-with-object-literal/input.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/pipe-body-with-object-literal/input.js new file mode 100644 index 0000000000..06d0ad744e --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/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-hash/pipe-body-with-object-literal/output.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/pipe-body-with-object-literal/output.js new file mode 100644 index 0000000000..397577ac5a --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/pipe-body-with-object-literal/output.js @@ -0,0 +1,11 @@ +var _ref, _ref2, _ref3; + +function area(rect) { + return rect.width * rect.height; +} + +const result = (_ref3 = (_ref2 = (_ref = -5, Math.abs(_ref)), { + width: _ref2, + height: _ref2 + 3 +}), area(_ref3)); +expect(result).toBe(40); diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/pipe-body-with-topic-method-call/exec.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/pipe-body-with-topic-method-call/exec.js new file mode 100644 index 0000000000..6d467f5e46 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/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-hash/pipe-body-with-topic-method-call/input.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/pipe-body-with-topic-method-call/input.js new file mode 100644 index 0000000000..6d467f5e46 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/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-hash/pipe-body-with-topic-method-call/output.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/pipe-body-with-topic-method-call/output.js new file mode 100644 index 0000000000..029efa5642 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/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/smart/yield/exec.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/pipe-body-with-yield/exec.js similarity index 93% rename from packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/yield/exec.js rename to packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/pipe-body-with-yield/exec.js index f998a1157e..f8abf7114a 100644 --- a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/yield/exec.js +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/pipe-body-with-yield/exec.js @@ -1,7 +1,7 @@ function *myGenerator(n) { return n |> (yield #) - |> Math.abs; + |> Math.abs(#); } const myIterator = myGenerator(15); diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/pipe-body-with-yield/input.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/pipe-body-with-yield/input.js new file mode 100644 index 0000000000..f8abf7114a --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/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-hash/pipe-body-with-yield/output.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/pipe-body-with-yield/output.js new file mode 100644 index 0000000000..6323364b3f --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/pipe-body-with-yield/output.js @@ -0,0 +1,11 @@ +function* myGenerator(n) { + var _ref, _ref2; + + return _ref2 = (_ref = n, yield _ref), Math.abs(_ref2); +} + +const myIterator = myGenerator(15); +const yieldedValue = myIterator.next().value; +const returnedValue = myIterator.next(-30).value; +expect(yieldedValue).toBe(15); +expect(returnedValue).toBe(30); diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/pipe-head-with-nested-pipe/exec.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/pipe-head-with-nested-pipe/exec.js new file mode 100644 index 0000000000..b3283d8f1c --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/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-hash/pipe-head-with-nested-pipe/input.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/pipe-head-with-nested-pipe/input.js new file mode 100644 index 0000000000..b3283d8f1c --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/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-hash/pipe-head-with-nested-pipe/output.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/pipe-head-with-nested-pipe/output.js new file mode 100644 index 0000000000..1adde65820 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/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-hash/pipe-in-arrow-function/exec.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/pipe-in-arrow-function/exec.js new file mode 100644 index 0000000000..51ccf9e82c --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/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-hash/pipe-in-arrow-function/input.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/pipe-in-arrow-function/input.js new file mode 100644 index 0000000000..51ccf9e82c --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/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-hash/pipe-in-arrow-function/output.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/pipe-in-arrow-function/output.js new file mode 100644 index 0000000000..573e312f0f --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/pipe-in-arrow-function/output.js @@ -0,0 +1,11 @@ +const result = () => { + var _ref, _ref2, _ref3; + + return _ref3 = (_ref2 = (_ref = -2.2 // -2.2 + , Math.floor(_ref) // -3 + ), () => Math.pow(_ref2, 5) // () => -243 + ), _ref3(); +}; // -243 + + +expect(result()).toBe(-243); diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/transform-arrow-functions/exec.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/transform-arrow-functions/exec.js new file mode 100644 index 0000000000..bad9628ca7 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/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-hash/transform-arrow-functions/input.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/transform-arrow-functions/input.js new file mode 100644 index 0000000000..bad9628ca7 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/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-hash/transform-arrow-functions/options.json b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/transform-arrow-functions/options.json new file mode 100644 index 0000000000..8cef5b5903 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/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-hash/transform-arrow-functions/output.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/transform-arrow-functions/output.js new file mode 100644 index 0000000000..556ae36b83 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/transform-arrow-functions/output.js @@ -0,0 +1,8 @@ +var _ref, _ref2; + +const triple = function (x) { + return x * 3; +}; + +const result = (_ref2 = (_ref = -7, Math.abs(_ref)), triple(_ref2)); +return expect(result).toBe(21); diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/transform-await-and-arrow-functions/exec.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/transform-await-and-arrow-functions/exec.js new file mode 100644 index 0000000000..1091424356 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/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-hash/transform-await-and-arrow-functions/input.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/transform-await-and-arrow-functions/input.js new file mode 100644 index 0000000000..1091424356 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/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-hash/transform-await-and-arrow-functions/options.json b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/transform-await-and-arrow-functions/options.json new file mode 100644 index 0000000000..3e3f41fd3d --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/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-hash/transform-await-and-arrow-functions/output.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/transform-await-and-arrow-functions/output.js new file mode 100644 index 0000000000..f7bf29a5fa --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/transform-await-and-arrow-functions/output.js @@ -0,0 +1,13 @@ +const triple = function (x) { + return x * 3; +}; + +async function myFunction(n) { + var _ref, _ref2, _ref3, _ref4; + + return _ref4 = (_ref3 = (_ref2 = (_ref = n, Math.abs(_ref)), Promise.resolve(_ref2)), await _ref3), triple(_ref4); +} + +return myFunction(-7).then(function (result) { + expect(result).toBe(21); +}); diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/while-statement-with-pipe-in-condition/exec.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/while-statement-with-pipe-in-condition/exec.js new file mode 100644 index 0000000000..b07c908a89 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/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-hash/while-statement-with-pipe-in-condition/input.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/while-statement-with-pipe-in-condition/input.js new file mode 100644 index 0000000000..b07c908a89 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/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-hash/while-statement-with-pipe-in-condition/output.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/while-statement-with-pipe-in-condition/output.js new file mode 100644 index 0000000000..c249ee7673 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/while-statement-with-pipe-in-condition/output.js @@ -0,0 +1,10 @@ +let i = 0; +let sum = 0; + +while (_ref2 = (_ref = i, i = _ref + 1), _ref2 <= 10) { + var _ref, _ref2; + + sum += i; +} + +expect(sum).toBe(10 + 9 + 8 + 7 + 6 + 5 + 4 + 3 + 2 + 1); diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/within-assignment/exec.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/within-assignment/exec.js new file mode 100644 index 0000000000..2b8b621b63 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/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-hash/within-assignment/input.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/within-assignment/input.js new file mode 100644 index 0000000000..2b8b621b63 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/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-hash/within-assignment/output.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/within-assignment/output.js new file mode 100644 index 0000000000..5ca2ce9e53 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/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-hash/within-for-classic-statement-init/exec.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/within-for-classic-statement-init/exec.js new file mode 100644 index 0000000000..dc3dd1f441 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/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-hash/within-for-classic-statement-init/input.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/within-for-classic-statement-init/input.js new file mode 100644 index 0000000000..dc3dd1f441 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/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-hash/within-for-classic-statement-init/output.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/within-for-classic-statement-init/output.js new file mode 100644 index 0000000000..dd399138c6 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/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/smart/for/exec.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/within-for-classic-statement-test/exec.js similarity index 70% rename from packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/for/exec.js rename to packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/within-for-classic-statement-test/exec.js index e1278cd25d..53db1fed69 100644 --- a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/for/exec.js +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/within-for-classic-statement-test/exec.js @@ -1,5 +1,5 @@ let sum = 0; -for (var i = 0; i |> # <= 10; i++) +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/smart/for-init/input.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/within-for-classic-statement-test/input.js similarity index 70% rename from packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/for-init/input.js rename to packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/within-for-classic-statement-test/input.js index 857fc6ce5b..53db1fed69 100644 --- a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/for-init/input.js +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/within-for-classic-statement-test/input.js @@ -1,5 +1,5 @@ let sum = 0; -for (var i = 0 |> #; i <= 10; i++) +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-hash/within-for-classic-statement-test/output.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/within-for-classic-statement-test/output.js new file mode 100644 index 0000000000..14ae06d74a --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/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/smart/for-update/exec.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/within-for-classic-statement-update/exec.js similarity index 100% rename from packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/for-update/exec.js rename to packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/within-for-classic-statement-update/exec.js diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/for-update/input.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/within-for-classic-statement-update/input.js similarity index 100% rename from packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/for-update/input.js rename to packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/within-for-classic-statement-update/input.js diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/within-for-classic-statement-update/output.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/within-for-classic-statement-update/output.js new file mode 100644 index 0000000000..a741096b13 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/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-hash/within-generator-with-yield/input.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/within-generator-with-yield/input.js new file mode 100644 index 0000000000..32cc2fda96 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/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-hash/within-generator-with-yield/output.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/within-generator-with-yield/output.js new file mode 100644 index 0000000000..396c84ad9f --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/within-generator-with-yield/output.js @@ -0,0 +1,5 @@ +function* myGenerator(n) { + var _ref, _ref2; + + return _ref2 = (_ref = n, yield _ref), Math.abs(_ref2); +} diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/within-if-else-block/input.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/within-if-else-block/input.js new file mode 100644 index 0000000000..7096f8cdfc --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/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-hash/within-if-else-block/output.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/within-if-else-block/output.js new file mode 100644 index 0000000000..6782b466ae --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/within-if-else-block/output.js @@ -0,0 +1,3 @@ +var _ref, _ref2, _ref3, _ref4; + +if (_ref2 = (_ref = v, e(_ref)), f(_ref2)) _ref4 = (_ref3 = g(), h(_ref3, _ref3 + 1)), i(_ref4);else j(); diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/within-var-statement/exec.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/within-var-statement/exec.js new file mode 100644 index 0000000000..26837dd515 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/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-hash/within-var-statement/input.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/within-var-statement/input.js new file mode 100644 index 0000000000..26837dd515 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/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-hash/within-var-statement/output.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/within-var-statement/output.js new file mode 100644 index 0000000000..126fd40304 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/within-var-statement/output.js @@ -0,0 +1,2 @@ +var i = 0; +expect(i).toBe(0); diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/no-proposal/input.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/no-proposal/input.js new file mode 100644 index 0000000000..18a01b67ee --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/no-proposal/input.js @@ -0,0 +1 @@ +x |> #; diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/no-proposal/options.json b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/no-proposal/options.json new file mode 100644 index 0000000000..038f64bc8d --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/no-proposal/options.json @@ -0,0 +1,4 @@ +{ + "plugins": ["proposal-pipeline-operator"], + "throws": "The pipeline plugin requires a \"proposal\" option. \"proposal\" must be one of: \"minimal\", \"fsharp\", \"hack\", \"smart\". See ." +} diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/await/input.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/await/input.js deleted file mode 100644 index 09ec849300..0000000000 --- a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/await/input.js +++ /dev/null @@ -1,6 +0,0 @@ -async function myFunction(n) { - return n - |> Math.abs - |> Promise.resolve(#) - |> await #; -} diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/await/options.json b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/await/options.json deleted file mode 100644 index df18488153..0000000000 --- a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/await/options.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "plugins": [["proposal-pipeline-operator", { "proposal": "smart" }]], - "parserOpts": { - "allowReturnOutsideFunction": true - }, - "minNodeVersion": "8.0.0" -} diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/await/output.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/await/output.js deleted file mode 100644 index bf78486967..0000000000 --- a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/await/output.js +++ /dev/null @@ -1,5 +0,0 @@ -async function myFunction(n) { - var _ref, _ref2, _n; - - return _ref = (_ref2 = (_n = n, Math.abs(_n)), Promise.resolve(_ref2)), await _ref; -} diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/basic/exec.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/basic/exec.js index 1a4868deae..8657c90a87 100644 --- a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/basic/exec.js +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/basic/exec.js @@ -1,6 +1,6 @@ var result = 5 - |> # + 1 - |> # + # - |> Math.pow(((x) => (x * 7))(#), 2) + |> # + 1 + |> # + # + |> Math.pow(((x) => (x * 7))(#), 2) expect(result).toBe(7056); diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/basic/input.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/basic/input.js index 839ae46a74..8657c90a87 100644 --- a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/basic/input.js +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/basic/input.js @@ -1,4 +1,6 @@ var result = 5 - |> # + 1 - |> # + # - |> Math.pow(((x) => (x * 7))(#), 2) + |> # + 1 + |> # + # + |> Math.pow(((x) => (x * 7))(#), 2) + +expect(result).toBe(7056); diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/basic/output.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/basic/output.js index 0f5af7ba95..0c88adebb0 100644 --- a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/basic/output.js +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/basic/output.js @@ -1,3 +1,4 @@ var _ref, _ref2, _; var result = (_ref = (_ref2 = (_ = 5, _ + 1), _ref2 + _ref2), Math.pow((x => x * 7)(_ref), 2)); +expect(result).toBe(7056); diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/for-init/exec.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/for-classic-statement-init-with-pipe-body/exec.js similarity index 70% rename from packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/for-init/exec.js rename to packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/for-classic-statement-init-with-pipe-body/exec.js index 857fc6ce5b..923ee82523 100644 --- a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/for-init/exec.js +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/for-classic-statement-init-with-pipe-body/exec.js @@ -1,5 +1,5 @@ let sum = 0; -for (var i = 0 |> #; i <= 10; i++) +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/smart/for/input.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/for-classic-statement-init-with-pipe-body/input.js similarity index 69% rename from packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/for/input.js rename to packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/for-classic-statement-init-with-pipe-body/input.js index 279b128e2d..923ee82523 100644 --- a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/for/input.js +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/for-classic-statement-init-with-pipe-body/input.js @@ -1,5 +1,5 @@ let sum = 0; -for (var i = 0; (i |> # <= 10); ++i) +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/smart/for-init/output.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/for-classic-statement-init-with-pipe-body/output.js similarity index 100% rename from packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/for-init/output.js rename to packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/for-classic-statement-init-with-pipe-body/output.js diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/for-classic-statement-predicate-with-pipe-body/exec.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/for-classic-statement-predicate-with-pipe-body/exec.js new file mode 100644 index 0000000000..53db1fed69 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/for-classic-statement-predicate-with-pipe-body/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/smart/for-classic-statement-predicate-with-pipe-body/input.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/for-classic-statement-predicate-with-pipe-body/input.js new file mode 100644 index 0000000000..53db1fed69 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/for-classic-statement-predicate-with-pipe-body/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/smart/for/output.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/for-classic-statement-predicate-with-pipe-body/output.js similarity index 71% rename from packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/for/output.js rename to packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/for-classic-statement-predicate-with-pipe-body/output.js index 09d8bc0562..a5e05dff2c 100644 --- a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/for/output.js +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/for-classic-statement-predicate-with-pipe-body/output.js @@ -1,6 +1,6 @@ let sum = 0; -for (var i = 0; _i = i, _i <= 10; ++i) { +for (var i = 0; _i = i, _i <= 10; i++) { var _i; sum = sum + i; diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/for-classic-statement-update-with-pipe-body/exec.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/for-classic-statement-update-with-pipe-body/exec.js new file mode 100644 index 0000000000..41d1e0584a --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/for-classic-statement-update-with-pipe-body/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/smart/for-classic-statement-update-with-pipe-body/input.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/for-classic-statement-update-with-pipe-body/input.js new file mode 100644 index 0000000000..41d1e0584a --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/for-classic-statement-update-with-pipe-body/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/smart/for-update/output.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/for-classic-statement-update-with-pipe-body/output.js similarity index 100% rename from packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/for-update/output.js rename to packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/for-classic-statement-update-with-pipe-body/output.js diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/yield/input.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/generator-yield/input.js similarity index 100% rename from packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/yield/input.js rename to packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/generator-yield/input.js diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/yield/output.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/generator-yield/output.js similarity index 100% rename from packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/yield/output.js rename to packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/generator-yield/output.js diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/hash-tuple/input.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/hash-tuple/input.js new file mode 100644 index 0000000000..eb22843797 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/hash-tuple/input.js @@ -0,0 +1,2 @@ +#[0]; +1 |> #[0]; diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/hash-tuple/options.json b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/hash-tuple/options.json new file mode 100644 index 0000000000..69cdcba741 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/hash-tuple/options.json @@ -0,0 +1,7 @@ +{ + "plugins": [ + ["proposal-pipeline-operator", { "proposal": "smart" }], + ["proposal-record-and-tuple", { "syntaxType": "hash" }] + ], + "throws": "Plugin conflict between `[\"pipelineOperator\", { proposal: \"smart\" }]` and `[\"recordAndtuple\", { syntaxType: \"hash\"}]`." +} diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/if/input.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/if-else-block/input.js similarity index 100% rename from packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/if/input.js rename to packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/if-else-block/input.js diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/if/output.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/if-else-block/output.js similarity index 100% rename from packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/if/output.js rename to packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/if-else-block/output.js diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/options.json b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/options.json index d8c03ffdf7..ffe4feed49 100644 --- a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/options.json +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/options.json @@ -1,6 +1,3 @@ { - "plugins": [["proposal-pipeline-operator", { "proposal": "smart" }]], - "parserOpts": { - "allowReturnOutsideFunction": true - } + "plugins": [["proposal-pipeline-operator", { "proposal": "smart" }]] } diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/pipe-body-identity/exec.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/pipe-body-identity/exec.js new file mode 100644 index 0000000000..eee45b7f19 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/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/smart/pipe-body-identity/input.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/pipe-body-identity/input.js new file mode 100644 index 0000000000..eee45b7f19 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/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/smart/pipe-body-identity/output.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/pipe-body-identity/output.js new file mode 100644 index 0000000000..d7b30d33e7 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/pipe-body-identity/output.js @@ -0,0 +1,4 @@ +var _; + +const result = (_ = 5, _); +expect(result).toBe(5); diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/nested/exec.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/pipe-body-with-arrow-function-containing-nested-pipe/exec.js similarity index 100% rename from packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/nested/exec.js rename to packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/pipe-body-with-arrow-function-containing-nested-pipe/exec.js diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/nested/input.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/pipe-body-with-arrow-function-containing-nested-pipe/input.js similarity index 74% rename from packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/nested/input.js rename to packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/pipe-body-with-arrow-function-containing-nested-pipe/input.js index 1903dbd95b..20c1c83d22 100644 --- a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/nested/input.js +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/pipe-body-with-arrow-function-containing-nested-pipe/input.js @@ -3,3 +3,5 @@ var result = 5 |> [ 10, 20, 30, 40, 50 ].filter(n => # |> n > # |> !#); + +expect(result).toEqual([10, 20]); diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/nested/output.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/pipe-body-with-arrow-function-containing-nested-pipe/output.js similarity index 83% rename from packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/nested/output.js rename to packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/pipe-body-with-arrow-function-containing-nested-pipe/output.js index d5266c6617..d203e3f28c 100644 --- a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/nested/output.js +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/pipe-body-with-arrow-function-containing-nested-pipe/output.js @@ -5,3 +5,4 @@ var result = (_ref = (_ = 5, Math.pow(_, 2)), [10, 20, 30, 40, 50].filter(n => { return _ref2 = (_ref3 = _ref, n > _ref3), !_ref2; })); +expect(result).toEqual([10, 20]); diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/topic-inside-arrow-function/exec.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/pipe-body-with-arrow-function-without-nested-pipe/exec.js similarity index 100% rename from packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/topic-inside-arrow-function/exec.js rename to packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/pipe-body-with-arrow-function-without-nested-pipe/exec.js diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/topic-inside-arrow-function/input.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/pipe-body-with-arrow-function-without-nested-pipe/input.js similarity index 86% rename from packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/topic-inside-arrow-function/input.js rename to packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/pipe-body-with-arrow-function-without-nested-pipe/input.js index 14a6f5b6c1..c5837e4a0b 100644 --- a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/topic-inside-arrow-function/input.js +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/pipe-body-with-arrow-function-without-nested-pipe/input.js @@ -3,3 +3,5 @@ const result = -2.2 // -2.2 |> (() => Math.pow(#, 5)) // () => -243 |> #() // -243 |> Math.sign; // -1 + +expect(result).toBe(-1); diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/topic-inside-arrow-function/output.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/pipe-body-with-arrow-function-without-nested-pipe/output.js similarity index 88% rename from packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/topic-inside-arrow-function/output.js rename to packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/pipe-body-with-arrow-function-without-nested-pipe/output.js index 35aee7ed2a..4df6228f3a 100644 --- a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/topic-inside-arrow-function/output.js +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/pipe-body-with-arrow-function-without-nested-pipe/output.js @@ -5,3 +5,5 @@ const result = (_ref = (_ref2 = (_ref3 = (_ = -2.2 // -2.2 ), () => Math.pow(_ref3, 5) // () => -243 ), _ref2() // -243 ), Math.sign(_ref)); // -1 + +expect(result).toBe(-1); diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart+arrow/await/exec.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/pipe-body-with-await/exec.js similarity index 100% rename from packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart+arrow/await/exec.js rename to packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/pipe-body-with-await/exec.js diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/await/exec.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/pipe-body-with-await/input.js similarity index 100% rename from packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/await/exec.js rename to packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/pipe-body-with-await/input.js diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/pipe-body-with-await/options.json b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/pipe-body-with-await/options.json new file mode 100644 index 0000000000..60d482269d --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/pipe-body-with-await/options.json @@ -0,0 +1,6 @@ +{ + "minNodeVersion": "8.0.0", + "parserOpts": { + "allowReturnOutsideFunction": true + } +} diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/pipe-body-with-await/output.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/pipe-body-with-await/output.js new file mode 100644 index 0000000000..f06a139d11 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/pipe-body-with-await/output.js @@ -0,0 +1,11 @@ +const triple = x => x * 3; + +async function myFunction(n) { + var _ref, _ref2, _ref3, _n; + + return _ref = (_ref2 = (_ref3 = (_n = n, Math.abs(_n)), Promise.resolve(_ref3)), await _ref2), triple(_ref); +} + +return myFunction(-7).then(result => { + expect(result).toBe(21); +}); diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/pipe-body-with-eval-on-topic/exec.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/pipe-body-with-eval-on-topic/exec.js new file mode 100644 index 0000000000..0a1c0ce740 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/pipe-body-with-eval-on-topic/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/smart/pipe-body-with-eval-on-topic/input.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/pipe-body-with-eval-on-topic/input.js new file mode 100644 index 0000000000..0a1c0ce740 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/pipe-body-with-eval-on-topic/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/smart/pipe-body-with-eval-on-topic/output.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/pipe-body-with-eval-on-topic/output.js new file mode 100644 index 0000000000..5387349e89 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/pipe-body-with-eval-on-topic/output.js @@ -0,0 +1,5 @@ +var _program; + +const program = '(function() { return this; })()'; +const result = (_program = program, eval(_program)); +expect(result).not.toBeUndefined(); diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/indirect-eval/exec.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/pipe-body-with-eval-tacit-call/exec.js similarity index 100% rename from packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/indirect-eval/exec.js rename to packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/pipe-body-with-eval-tacit-call/exec.js diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/indirect-eval/input.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/pipe-body-with-eval-tacit-call/input.js similarity index 100% rename from packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/indirect-eval/input.js rename to packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/pipe-body-with-eval-tacit-call/input.js diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/indirect-eval/output.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/pipe-body-with-eval-tacit-call/output.js similarity index 100% rename from packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/indirect-eval/output.js rename to packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/pipe-body-with-eval-tacit-call/output.js diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/pipe-body-with-nested-pipe/exec.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/pipe-body-with-nested-pipe/exec.js new file mode 100644 index 0000000000..8b7dd421d1 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/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/smart/pipe-body-with-nested-pipe/input.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/pipe-body-with-nested-pipe/input.js new file mode 100644 index 0000000000..8b7dd421d1 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/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/smart/pipe-body-with-nested-pipe/output.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/pipe-body-with-nested-pipe/output.js new file mode 100644 index 0000000000..3cb3841676 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/pipe-body-with-nested-pipe/output.js @@ -0,0 +1,4 @@ +var _ref, _, _ref2, _ref3; + +const result = (_ref = (_ = 5, Math.pow(_, 2)), (_ref2 = (_ref3 = _ref + 1, `${_ref3} apples`), _ref2.toUpperCase())); +expect(result).toEqual('26 APPLES'); diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/object-literal/exec.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/pipe-body-with-object-literal/exec.js similarity index 100% rename from packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/object-literal/exec.js rename to packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/pipe-body-with-object-literal/exec.js diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/object-literal/input.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/pipe-body-with-object-literal/input.js similarity index 100% rename from packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/object-literal/input.js rename to packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/pipe-body-with-object-literal/input.js diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/object-literal/output.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/pipe-body-with-object-literal/output.js similarity index 100% rename from packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/object-literal/output.js rename to packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/pipe-body-with-object-literal/output.js diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/bare-function/exec.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/pipe-body-with-tacit-function-call/exec.js similarity index 100% rename from packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/bare-function/exec.js rename to packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/pipe-body-with-tacit-function-call/exec.js diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/bare-function/input.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/pipe-body-with-tacit-function-call/input.js similarity index 72% rename from packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/bare-function/input.js rename to packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/pipe-body-with-tacit-function-call/input.js index be7fbdbd4c..93371d387a 100644 --- a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/bare-function/input.js +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/pipe-body-with-tacit-function-call/input.js @@ -3,3 +3,5 @@ const abs = Math.abs; const value = -5.9 |> abs |> Math.floor; + +expect(value).toBe(5); diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/bare-function/output.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/pipe-body-with-tacit-function-call/output.js similarity index 80% rename from packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/bare-function/output.js rename to packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/pipe-body-with-tacit-function-call/output.js index d89c931323..0e9f70897c 100644 --- a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/bare-function/output.js +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/pipe-body-with-tacit-function-call/output.js @@ -2,3 +2,4 @@ var _ref, _; const abs = Math.abs; const value = (_ref = (_ = -5.9, abs(_)), Math.floor(_ref)); +expect(value).toBe(5); diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/topic-as-callee/input.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/pipe-body-with-topic-method-call/input.js similarity index 100% rename from packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/topic-as-callee/input.js rename to packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/pipe-body-with-topic-method-call/input.js diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/topic-as-callee/output.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/pipe-body-with-topic-method-call/output.js similarity index 100% rename from packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/topic-as-callee/output.js rename to packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/pipe-body-with-topic-method-call/output.js diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/pipe-body-with-yield/exec.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/pipe-body-with-yield/exec.js new file mode 100644 index 0000000000..f8abf7114a --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/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/smart/pipe-body-with-yield/input.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/pipe-body-with-yield/input.js new file mode 100644 index 0000000000..f8abf7114a --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/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/smart/pipe-body-with-yield/output.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/pipe-body-with-yield/output.js new file mode 100644 index 0000000000..86760689e5 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/pipe-body-with-yield/output.js @@ -0,0 +1,11 @@ +function* myGenerator(n) { + var _ref, _n; + + return _ref = (_n = n, yield _n), 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/smart/pipe-head-with-nested-pipe/exec.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/pipe-head-with-nested-pipe/exec.js new file mode 100644 index 0000000000..b3283d8f1c --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/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/smart/pipe-head-with-nested-pipe/input.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/pipe-head-with-nested-pipe/input.js new file mode 100644 index 0000000000..b3283d8f1c --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/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/smart/pipe-head-with-nested-pipe/output.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/pipe-head-with-nested-pipe/output.js new file mode 100644 index 0000000000..dc1b18d389 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/pipe-head-with-nested-pipe/output.js @@ -0,0 +1,4 @@ +var _ref, _; + +const result = (_ref = (_ = 5, Math.pow(_, 2)), _ref + 1); +expect(result).toEqual(26); diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/pipe-in-arrow-function/exec.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/pipe-in-arrow-function/exec.js new file mode 100644 index 0000000000..51ccf9e82c --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/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/smart/pipe-in-arrow-function/input.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/pipe-in-arrow-function/input.js new file mode 100644 index 0000000000..51ccf9e82c --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/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/smart/pipe-in-arrow-function/output.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/pipe-in-arrow-function/output.js new file mode 100644 index 0000000000..7b2ef09bb7 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/pipe-in-arrow-function/output.js @@ -0,0 +1,11 @@ +const result = () => { + var _ref, _ref2, _; + + return _ref = (_ref2 = (_ = -2.2 // -2.2 + , Math.floor(_) // -3 + ), () => Math.pow(_ref2, 5) // () => -243 + ), _ref(); +}; // -243 + + +expect(result()).toBe(-243); diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/transform-arrow-functions/exec.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/transform-arrow-functions/exec.js new file mode 100644 index 0000000000..bad9628ca7 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/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/smart/transform-arrow-functions/input.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/transform-arrow-functions/input.js new file mode 100644 index 0000000000..bad9628ca7 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/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/smart+arrow/options.json b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/transform-arrow-functions/options.json similarity index 100% rename from packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart+arrow/options.json rename to packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/transform-arrow-functions/options.json diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/transform-arrow-functions/output.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/transform-arrow-functions/output.js new file mode 100644 index 0000000000..738ed47905 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/transform-arrow-functions/output.js @@ -0,0 +1,8 @@ +var _ref, _; + +const triple = function (x) { + return x * 3; +}; + +const result = (_ref = (_ = -7, Math.abs(_)), triple(_ref)); +return expect(result).toBe(21); diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/transform-await-and-arrow-functions/exec.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/transform-await-and-arrow-functions/exec.js new file mode 100644 index 0000000000..7e7ea94bd4 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/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/smart/transform-await-and-arrow-functions/input.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/transform-await-and-arrow-functions/input.js new file mode 100644 index 0000000000..7e7ea94bd4 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/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/smart/transform-await-and-arrow-functions/options.json b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/transform-await-and-arrow-functions/options.json new file mode 100644 index 0000000000..6a7e42fdd0 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/transform-await-and-arrow-functions/options.json @@ -0,0 +1,10 @@ +{ + "plugins": [ + ["proposal-pipeline-operator", { "proposal": "smart" }], + "transform-arrow-functions" + ], + "parserOpts": { + "allowReturnOutsideFunction": true + }, + "minNodeVersion": "8.0.0" +} diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/transform-await-and-arrow-functions/output.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/transform-await-and-arrow-functions/output.js new file mode 100644 index 0000000000..24241257e9 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/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, _n; + + return _ref = (_ref2 = (_ref3 = (_n = n, Math.abs(_n)), Promise.resolve(_ref3)), 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/smart/while/exec.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/while-statement-with-pipe-in-condition/exec.js similarity index 100% rename from packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/while/exec.js rename to packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/while-statement-with-pipe-in-condition/exec.js diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/while/input.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/while-statement-with-pipe-in-condition/input.js similarity index 100% rename from packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/while/input.js rename to packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/while-statement-with-pipe-in-condition/input.js diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/while/output.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/while-statement-with-pipe-in-condition/output.js similarity index 100% rename from packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/while/output.js rename to packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/while-statement-with-pipe-in-condition/output.js diff --git a/packages/babel-plugin-syntax-pipeline-operator/src/index.js b/packages/babel-plugin-syntax-pipeline-operator/src/index.js index df904e7764..5fe966e391 100644 --- a/packages/babel-plugin-syntax-pipeline-operator/src/index.js +++ b/packages/babel-plugin-syntax-pipeline-operator/src/index.js @@ -1,16 +1,24 @@ import { declare } from "@babel/helper-plugin-utils"; -export const proposals = ["minimal", "smart", "fsharp"]; +const PIPELINE_PROPOSALS = ["minimal", "fsharp", "hack", "smart"]; +const TOPIC_TOKENS = ["#"]; +const documentationURL = + "https://babeljs.io/docs/en/babel-plugin-proposal-pipeline-operator"; -export default declare((api, { proposal }) => { +export default declare((api, { proposal, topicToken }) => { api.assertVersion(7); - if (typeof proposal !== "string" || !proposals.includes(proposal)) { + if (typeof proposal !== "string" || !PIPELINE_PROPOSALS.includes(proposal)) { + const proposalList = PIPELINE_PROPOSALS.map(p => `"${p}"`).join(", "); throw new Error( - "The pipeline operator plugin requires a 'proposal' option." + - "'proposal' must be one of: " + - proposals.join(", ") + - ". More details: https://babeljs.io/docs/en/next/babel-plugin-proposal-pipeline-operator", + `The pipeline plugin requires a "proposal" option. "proposal" must be one of: ${proposalList}. See <${documentationURL}>.`, + ); + } + + if (proposal === "hack" && !TOPIC_TOKENS.includes(topicToken)) { + const topicTokenList = TOPIC_TOKENS.map(t => `"${t}"`).join(", "); + throw new Error( + `The pipeline plugin in "proposal": "hack" mode also requires a "topicToken" option. "topicToken" must be one of: ${topicTokenList}. See <${documentationURL}>.`, ); } @@ -18,7 +26,11 @@ export default declare((api, { proposal }) => { name: "syntax-pipeline-operator", manipulateOptions(opts, parserOpts) { - parserOpts.plugins.push(["pipelineOperator", { proposal }]); + // Add parser options. + parserOpts.plugins.push(["pipelineOperator", { proposal, topicToken }]); + + // Add generator options. + opts.generatorOpts.topicToken = topicToken; }, }; }); diff --git a/packages/babel-traverse/src/path/generated/asserts.ts b/packages/babel-traverse/src/path/generated/asserts.ts index bd66907898..3acc28f3fb 100755 --- a/packages/babel-traverse/src/path/generated/asserts.ts +++ b/packages/babel-traverse/src/path/generated/asserts.ts @@ -636,6 +636,9 @@ export interface NodePathAssetions { assertThrowStatement( opts?: object, ): asserts this is NodePath; + assertTopicReference( + opts?: object, + ): asserts this is NodePath; assertTryStatement(opts?: object): asserts this is NodePath; assertTupleExpression( opts?: object, diff --git a/packages/babel-traverse/src/path/generated/validators.ts b/packages/babel-traverse/src/path/generated/validators.ts index 7dbf7d828d..6f6c457e37 100755 --- a/packages/babel-traverse/src/path/generated/validators.ts +++ b/packages/babel-traverse/src/path/generated/validators.ts @@ -385,6 +385,7 @@ export interface NodePathValidators { isThisExpression(opts?: object): this is NodePath; isThisTypeAnnotation(opts?: object): this is NodePath; isThrowStatement(opts?: object): this is NodePath; + isTopicReference(opts?: object): this is NodePath; isTryStatement(opts?: object): this is NodePath; isTupleExpression(opts?: object): this is NodePath; isTupleTypeAnnotation(opts?: object): this is NodePath; diff --git a/packages/babel-types/src/asserts/generated/index.ts b/packages/babel-types/src/asserts/generated/index.ts index bbc1a80e42..c171b27816 100755 --- a/packages/babel-types/src/asserts/generated/index.ts +++ b/packages/babel-types/src/asserts/generated/index.ts @@ -1034,24 +1034,6 @@ export function assertBindExpression( ): asserts node is t.BindExpression { assert("BindExpression", node, opts); } -export function assertPipelineTopicExpression( - node: object | null | undefined, - opts?: object | null, -): asserts node is t.PipelineTopicExpression { - assert("PipelineTopicExpression", node, opts); -} -export function assertPipelineBareFunction( - node: object | null | undefined, - opts?: object | null, -): asserts node is t.PipelineBareFunction { - assert("PipelineBareFunction", node, opts); -} -export function assertPipelinePrimaryTopicReference( - node: object | null | undefined, - opts?: object | null, -): asserts node is t.PipelinePrimaryTopicReference { - assert("PipelinePrimaryTopicReference", node, opts); -} export function assertImportAttribute( node: object | null | undefined, opts?: object | null, @@ -1106,6 +1088,30 @@ export function assertModuleExpression( ): asserts node is t.ModuleExpression { assert("ModuleExpression", node, opts); } +export function assertTopicReference( + node: object | null | undefined, + opts?: object | null, +): asserts node is t.TopicReference { + assert("TopicReference", node, opts); +} +export function assertPipelineTopicExpression( + node: object | null | undefined, + opts?: object | null, +): asserts node is t.PipelineTopicExpression { + assert("PipelineTopicExpression", node, opts); +} +export function assertPipelineBareFunction( + node: object | null | undefined, + opts?: object | null, +): asserts node is t.PipelineBareFunction { + assert("PipelineBareFunction", node, opts); +} +export function assertPipelinePrimaryTopicReference( + node: object | null | undefined, + opts?: object | null, +): asserts node is t.PipelinePrimaryTopicReference { + assert("PipelinePrimaryTopicReference", node, opts); +} export function assertTSParameterProperty( node: object | null | undefined, opts?: object | null, diff --git a/packages/babel-types/src/ast-types/generated/index.ts b/packages/babel-types/src/ast-types/generated/index.ts index 5375ac186e..f4def136c3 100755 --- a/packages/babel-types/src/ast-types/generated/index.ts +++ b/packages/babel-types/src/ast-types/generated/index.ts @@ -316,6 +316,7 @@ export type Node = | ThisExpression | ThisTypeAnnotation | ThrowStatement + | TopicReference | TryStatement | TupleExpression | TupleTypeAnnotation @@ -1595,20 +1596,6 @@ export interface BindExpression extends BaseNode { callee: Expression; } -export interface PipelineTopicExpression extends BaseNode { - type: "PipelineTopicExpression"; - expression: Expression; -} - -export interface PipelineBareFunction extends BaseNode { - type: "PipelineBareFunction"; - callee: Expression; -} - -export interface PipelinePrimaryTopicReference extends BaseNode { - type: "PipelinePrimaryTopicReference"; -} - export interface ImportAttribute extends BaseNode { type: "ImportAttribute"; key: Identifier | StringLiteral; @@ -1656,6 +1643,24 @@ export interface ModuleExpression extends BaseNode { body: Program; } +export interface TopicReference extends BaseNode { + type: "TopicReference"; +} + +export interface PipelineTopicExpression extends BaseNode { + type: "PipelineTopicExpression"; + expression: Expression; +} + +export interface PipelineBareFunction extends BaseNode { + type: "PipelineBareFunction"; + callee: Expression; +} + +export interface PipelinePrimaryTopicReference extends BaseNode { + type: "PipelinePrimaryTopicReference"; +} + export interface TSParameterProperty extends BaseNode { type: "TSParameterProperty"; parameter: Identifier | AssignmentPattern; @@ -2088,12 +2093,15 @@ export type Expression = | JSXElement | JSXFragment | BindExpression - | PipelinePrimaryTopicReference | DoExpression | RecordExpression | TupleExpression | DecimalLiteral | ModuleExpression + | TopicReference + | PipelineTopicExpression + | PipelineBareFunction + | PipelinePrimaryTopicReference | TSAsExpression | TSTypeAssertion | TSNonNullExpression; diff --git a/packages/babel-types/src/builders/generated/index.ts b/packages/babel-types/src/builders/generated/index.ts index 658a503298..aa5591c88b 100755 --- a/packages/babel-types/src/builders/generated/index.ts +++ b/packages/babel-types/src/builders/generated/index.ts @@ -1024,19 +1024,6 @@ export function bindExpression( ): t.BindExpression { return builder("BindExpression", ...arguments); } -export function pipelineTopicExpression( - expression: t.Expression, -): t.PipelineTopicExpression { - return builder("PipelineTopicExpression", ...arguments); -} -export function pipelineBareFunction( - callee: t.Expression, -): t.PipelineBareFunction { - return builder("PipelineBareFunction", ...arguments); -} -export function pipelinePrimaryTopicReference(): t.PipelinePrimaryTopicReference { - return builder("PipelinePrimaryTopicReference", ...arguments); -} export function importAttribute( key: t.Identifier | t.StringLiteral, value: t.StringLiteral, @@ -1076,6 +1063,22 @@ export function staticBlock(body: Array): t.StaticBlock { export function moduleExpression(body: t.Program): t.ModuleExpression { return builder("ModuleExpression", ...arguments); } +export function topicReference(): t.TopicReference { + return builder("TopicReference", ...arguments); +} +export function pipelineTopicExpression( + expression: t.Expression, +): t.PipelineTopicExpression { + return builder("PipelineTopicExpression", ...arguments); +} +export function pipelineBareFunction( + callee: t.Expression, +): t.PipelineBareFunction { + return builder("PipelineBareFunction", ...arguments); +} +export function pipelinePrimaryTopicReference(): t.PipelinePrimaryTopicReference { + return builder("PipelinePrimaryTopicReference", ...arguments); +} export function tsParameterProperty( parameter: t.Identifier | t.AssignmentPattern, ): t.TSParameterProperty { diff --git a/packages/babel-types/src/builders/generated/uppercase.js b/packages/babel-types/src/builders/generated/uppercase.js index c56295e657..73d60dbb6f 100755 --- a/packages/babel-types/src/builders/generated/uppercase.js +++ b/packages/babel-types/src/builders/generated/uppercase.js @@ -179,9 +179,6 @@ export { v8IntrinsicIdentifier as V8IntrinsicIdentifier, argumentPlaceholder as ArgumentPlaceholder, bindExpression as BindExpression, - pipelineTopicExpression as PipelineTopicExpression, - pipelineBareFunction as PipelineBareFunction, - pipelinePrimaryTopicReference as PipelinePrimaryTopicReference, importAttribute as ImportAttribute, decorator as Decorator, doExpression as DoExpression, @@ -191,6 +188,10 @@ export { decimalLiteral as DecimalLiteral, staticBlock as StaticBlock, moduleExpression as ModuleExpression, + topicReference as TopicReference, + pipelineTopicExpression as PipelineTopicExpression, + pipelineBareFunction as PipelineBareFunction, + pipelinePrimaryTopicReference as PipelinePrimaryTopicReference, tsParameterProperty as TSParameterProperty, tsDeclareFunction as TSDeclareFunction, tsDeclareMethod as TSDeclareMethod, diff --git a/packages/babel-types/src/definitions/experimental.ts b/packages/babel-types/src/definitions/experimental.ts index afc33d5417..064f25e47f 100644 --- a/packages/babel-types/src/definitions/experimental.ts +++ b/packages/babel-types/src/definitions/experimental.ts @@ -33,30 +33,6 @@ defineType("BindExpression", { }, }); -defineType("PipelineTopicExpression", { - builder: ["expression"], - visitor: ["expression"], - fields: { - expression: { - validate: assertNodeType("Expression"), - }, - }, -}); - -defineType("PipelineBareFunction", { - builder: ["callee"], - visitor: ["callee"], - fields: { - callee: { - validate: assertNodeType("Expression"), - }, - }, -}); - -defineType("PipelinePrimaryTopicReference", { - aliases: ["Expression"], -}); - defineType("ImportAttribute", { visitor: ["key", "value"], fields: { @@ -164,3 +140,37 @@ defineType("ModuleExpression", { }, aliases: ["Expression"], }); + +// https://github.com/tc39/proposal-pipeline-operator +// https://github.com/js-choi/proposal-hack-pipes +defineType("TopicReference", { + aliases: ["Expression"], +}); + +// https://github.com/tc39/proposal-pipeline-operator +// https://github.com/js-choi/proposal-smart-pipes +defineType("PipelineTopicExpression", { + builder: ["expression"], + visitor: ["expression"], + fields: { + expression: { + validate: assertNodeType("Expression"), + }, + }, + aliases: ["Expression"], +}); + +defineType("PipelineBareFunction", { + builder: ["callee"], + visitor: ["callee"], + fields: { + callee: { + validate: assertNodeType("Expression"), + }, + }, + aliases: ["Expression"], +}); + +defineType("PipelinePrimaryTopicReference", { + aliases: ["Expression"], +}); diff --git a/packages/babel-types/src/validators/generated/index.ts b/packages/babel-types/src/validators/generated/index.ts index 02cbdf1398..7a2509842d 100755 --- a/packages/babel-types/src/validators/generated/index.ts +++ b/packages/babel-types/src/validators/generated/index.ts @@ -2895,57 +2895,6 @@ export function isBindExpression( return false; } -export function isPipelineTopicExpression( - node: object | null | undefined, - opts?: object | null, -): node is t.PipelineTopicExpression { - if (!node) return false; - - const nodeType = (node as t.Node).type; - if (nodeType === "PipelineTopicExpression") { - if (typeof opts === "undefined") { - return true; - } else { - return shallowEqual(node, opts); - } - } - - return false; -} -export function isPipelineBareFunction( - node: object | null | undefined, - opts?: object | null, -): node is t.PipelineBareFunction { - if (!node) return false; - - const nodeType = (node as t.Node).type; - if (nodeType === "PipelineBareFunction") { - if (typeof opts === "undefined") { - return true; - } else { - return shallowEqual(node, opts); - } - } - - return false; -} -export function isPipelinePrimaryTopicReference( - node: object | null | undefined, - opts?: object | null, -): node is t.PipelinePrimaryTopicReference { - if (!node) return false; - - const nodeType = (node as t.Node).type; - if (nodeType === "PipelinePrimaryTopicReference") { - if (typeof opts === "undefined") { - return true; - } else { - return shallowEqual(node, opts); - } - } - - return false; -} export function isImportAttribute( node: object | null | undefined, opts?: object | null, @@ -3099,6 +3048,74 @@ export function isModuleExpression( return false; } +export function isTopicReference( + node: object | null | undefined, + opts?: object | null, +): node is t.TopicReference { + if (!node) return false; + + const nodeType = (node as t.Node).type; + if (nodeType === "TopicReference") { + if (typeof opts === "undefined") { + return true; + } else { + return shallowEqual(node, opts); + } + } + + return false; +} +export function isPipelineTopicExpression( + node: object | null | undefined, + opts?: object | null, +): node is t.PipelineTopicExpression { + if (!node) return false; + + const nodeType = (node as t.Node).type; + if (nodeType === "PipelineTopicExpression") { + if (typeof opts === "undefined") { + return true; + } else { + return shallowEqual(node, opts); + } + } + + return false; +} +export function isPipelineBareFunction( + node: object | null | undefined, + opts?: object | null, +): node is t.PipelineBareFunction { + if (!node) return false; + + const nodeType = (node as t.Node).type; + if (nodeType === "PipelineBareFunction") { + if (typeof opts === "undefined") { + return true; + } else { + return shallowEqual(node, opts); + } + } + + return false; +} +export function isPipelinePrimaryTopicReference( + node: object | null | undefined, + opts?: object | null, +): node is t.PipelinePrimaryTopicReference { + if (!node) return false; + + const nodeType = (node as t.Node).type; + if (nodeType === "PipelinePrimaryTopicReference") { + if (typeof opts === "undefined") { + return true; + } else { + return shallowEqual(node, opts); + } + } + + return false; +} export function isTSParameterProperty( node: object | null | undefined, opts?: object | null, @@ -4215,12 +4232,15 @@ export function isExpression( "JSXElement" === nodeType || "JSXFragment" === nodeType || "BindExpression" === nodeType || - "PipelinePrimaryTopicReference" === nodeType || "DoExpression" === nodeType || "RecordExpression" === nodeType || "TupleExpression" === nodeType || "DecimalLiteral" === nodeType || "ModuleExpression" === nodeType || + "TopicReference" === nodeType || + "PipelineTopicExpression" === nodeType || + "PipelineBareFunction" === nodeType || + "PipelinePrimaryTopicReference" === nodeType || "TSAsExpression" === nodeType || "TSTypeAssertion" === nodeType || "TSNonNullExpression" === nodeType ||