From 12da3b9269ea56dc940c8196c87da5dc34d64df2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=2E=C2=A0S=2E=C2=A0Choi?= Date: Sun, 8 Jul 2018 15:57:43 -0400 Subject: [PATCH] Implement Smart Pipeline proposal in @babel/parser --- .../babel-parser/src/parser/expression.js | 312 ++++++++++- packages/babel-parser/src/parser/statement.js | 156 ++++-- packages/babel-parser/src/tokenizer/index.js | 60 ++- packages/babel-parser/src/tokenizer/state.js | 9 + packages/babel-parser/src/tokenizer/types.js | 15 + packages/babel-parser/src/types.js | 26 + .../with-pipeline/options.json | 6 +- .../options.json | 4 - .../arrow-requires-parens/options.json | 4 - .../await-requires-parens/options.json | 3 - .../pipeline-operator/base/options.json | 3 - .../pipeline-operator/chain/options.json | 3 - .../{base => invalid-proposal}/input.js | 0 .../invalid-proposal/options.json | 6 + .../pipeline-operator/multiline/options.json | 3 - .../pipeline-operator/precedence/options.json | 3 - .../input.js | 0 .../options.json | 6 + .../input.js | 0 .../options.json | 6 + .../input.js | 0 .../options.json | 5 + .../output.json | 0 .../input.js | 0 .../options.json | 4 +- .../input.js | 0 .../options.json | 4 +- .../proposal-minimal-base/input.js | 1 + .../proposal-minimal-base/options.json | 5 + .../output.json | 0 .../input.js | 0 .../proposal-minimal-chain/options.json | 5 + .../output.json | 0 .../input.js | 0 .../proposal-minimal-multiline/options.json | 5 + .../output.json | 0 .../input.js | 0 .../proposal-minimal-precedence/options.json | 5 + .../output.json | 0 .../input.js | 0 .../options.json | 5 + .../output.json | 0 .../input.js | 0 .../proposal-minimal-with-arrow/options.json | 5 + .../output.json | 0 .../input.js | 6 + .../options.json | 5 + .../output.json | 401 ++++++++++++++ .../input.js | 3 + .../options.json | 3 + .../output.json | 249 +++++++++ .../input.js | 3 + .../options.json | 3 + .../output.json | 234 +++++++++ .../input.js | 3 + .../options.json | 3 + .../output.json | 168 ++++++ .../input.js | 4 + .../options.json | 3 + .../output.json | 348 ++++++++++++ .../input.js | 1 + .../options.json | 3 + .../output.json | 233 +++++++++ .../input.js | 1 + .../options.json | 3 + .../output.json | 152 ++++++ .../input.js | 1 + .../options.json | 3 + .../output.json | 185 +++++++ .../input.js | 4 + .../options.json | 3 + .../output.json | 348 ++++++++++++ .../input.js | 1 + .../options.json | 3 + .../output.json | 233 +++++++++ .../input.js | 1 + .../options.json | 3 + .../output.json | 115 ++++ .../input.js | 1 + .../options.json | 3 + .../output.json | 214 ++++++++ .../input.js | 1 + .../options.json | 4 + .../input.js | 1 + .../options.json | 4 + .../input.js | 1 + .../options.json | 4 + .../input.js | 1 + .../options.json | 4 + .../input.js | 1 + .../options.json | 4 + .../input.js | 1 + .../options.json | 4 + .../input.js | 1 + .../options.json | 4 + .../input.js | 1 + .../options.json | 4 + .../input.js | 1 + .../options.json | 4 + .../input.js | 1 + .../options.json | 4 + .../input.js | 1 + .../options.json | 4 + .../input.js | 1 + .../options.json | 4 + .../input.js | 1 + .../options.json | 4 + .../input.js | 3 + .../options.json | 4 + .../input.js | 1 + .../options.json | 4 + .../input.js | 1 + .../options.json | 4 + .../input.js | 1 + .../options.json | 4 + .../input.js | 4 + .../options.json | 4 + .../input.js | 1 + .../options.json | 4 + .../input.js | 1 + .../options.json | 4 + .../input.js | 1 + .../options.json | 4 + .../input.js | 1 + .../options.json | 4 + .../input.js | 1 + .../options.json | 4 + .../input.js | 1 + .../options.json | 4 + .../input.js | 1 + .../options.json | 4 + .../input.js | 1 + .../options.json | 3 + .../output.json | 184 +++++++ .../input.js | 1 + .../options.json | 3 + .../output.json | 251 +++++++++ .../input.js | 1 + .../options.json | 3 + .../output.json | 165 ++++++ .../input.js | 1 + .../options.json | 3 + .../output.json | 214 ++++++++ .../input.js | 7 + .../options.json | 3 + .../output.json | 384 ++++++++++++++ .../input.js | 3 + .../options.json | 3 + .../output.json | 298 +++++++++++ .../input.js | 1 + .../options.json | 3 + .../output.json | 149 ++++++ .../input.js | 1 + .../options.json | 3 + .../output.json | 149 ++++++ .../input.js | 1 + .../options.json | 3 + .../output.json | 262 +++++++++ .../input.js | 3 + .../options.json | 3 + .../output.json | 298 +++++++++++ .../input.js | 1 + .../options.json | 3 + .../output.json | 357 +++++++++++++ .../input.js | 1 + .../options.json | 3 + .../output.json | 210 ++++++++ .../input.js | 1 + .../options.json | 3 + .../output.json | 211 ++++++++ .../input.js | 1 + .../options.json | 3 + .../output.json | 161 ++++++ .../input.js | 1 + .../options.json | 3 + .../output.json | 256 +++++++++ .../input.js | 1 + .../options.json | 3 + .../output.json | 223 ++++++++ .../input.js | 1 + .../options.json | 3 + .../output.json | 194 +++++++ .../input.js | 1 + .../options.json | 3 + .../output.json | 231 ++++++++ .../input.js | 7 + .../options.json | 3 + .../output.json | 419 +++++++++++++++ .../input.js | 7 + .../options.json | 3 + .../output.json | 360 +++++++++++++ .../input.js | 5 + .../options.json | 3 + .../output.json | 495 ++++++++++++++++++ .../input.js | 5 + .../options.json | 3 + .../output.json | 477 +++++++++++++++++ .../input.js | 4 + .../options.json | 3 + .../output.json | 412 +++++++++++++++ .../input.js | 1 + .../options.json | 3 + .../output.json | 262 +++++++++ .../input.js | 1 + .../options.json | 3 + .../output.json | 147 ++++++ .../input.js | 1 + .../options.json | 3 + .../output.json | 215 ++++++++ .../input.js | 1 + .../options.json | 3 + .../output.json | 117 +++++ .../input.js | 1 + .../options.json | 3 + .../output.json | 113 ++++ .../input.js | 1 + .../options.json | 3 + .../output.json | 113 ++++ .../input.js | 1 + .../options.json | 3 + .../output.json | 172 ++++++ .../with-arrow-parend-params/options.json | 3 - .../pipeline-operator/with-arrow/options.json | 3 - 223 files changed, 11297 insertions(+), 107 deletions(-) delete mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/arrow-requires-parens-with-parend-args/options.json delete mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/arrow-requires-parens/options.json delete mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/await-requires-parens/options.json delete mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/base/options.json delete mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/chain/options.json rename packages/babel-parser/test/fixtures/experimental/pipeline-operator/{base => invalid-proposal}/input.js (100%) create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/invalid-proposal/options.json delete mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/multiline/options.json delete mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/precedence/options.json rename packages/babel-parser/test/fixtures/experimental/pipeline-operator/{arrow-requires-parens-with-parend-args => proposal-minimal-arrow-requires-parens-with-parend-args}/input.js (100%) create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-minimal-arrow-requires-parens-with-parend-args/options.json rename packages/babel-parser/test/fixtures/experimental/pipeline-operator/{arrow-requires-parens => proposal-minimal-arrow-requires-parens}/input.js (100%) create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-minimal-arrow-requires-parens/options.json rename packages/babel-parser/test/fixtures/experimental/pipeline-operator/{await-requires-parens => proposal-minimal-await-requires-parens}/input.js (100%) create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-minimal-await-requires-parens/options.json rename packages/babel-parser/test/fixtures/experimental/pipeline-operator/{await-requires-parens => proposal-minimal-await-requires-parens}/output.json (100%) rename packages/babel-parser/test/fixtures/experimental/pipeline-operator/{ban-await-f => proposal-minimal-ban-await-f}/input.js (100%) rename packages/babel-parser/test/fixtures/experimental/pipeline-operator/{ban-await => proposal-minimal-ban-await-f}/options.json (61%) rename packages/babel-parser/test/fixtures/experimental/pipeline-operator/{ban-await => proposal-minimal-ban-await}/input.js (100%) rename packages/babel-parser/test/fixtures/experimental/pipeline-operator/{ban-await-f => proposal-minimal-ban-await}/options.json (61%) create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-minimal-base/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-minimal-base/options.json rename packages/babel-parser/test/fixtures/experimental/pipeline-operator/{base => proposal-minimal-base}/output.json (100%) rename packages/babel-parser/test/fixtures/experimental/pipeline-operator/{chain => proposal-minimal-chain}/input.js (100%) create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-minimal-chain/options.json rename packages/babel-parser/test/fixtures/experimental/pipeline-operator/{chain => proposal-minimal-chain}/output.json (100%) rename packages/babel-parser/test/fixtures/experimental/pipeline-operator/{multiline => proposal-minimal-multiline}/input.js (100%) create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-minimal-multiline/options.json rename packages/babel-parser/test/fixtures/experimental/pipeline-operator/{multiline => proposal-minimal-multiline}/output.json (100%) rename packages/babel-parser/test/fixtures/experimental/pipeline-operator/{precedence => proposal-minimal-precedence}/input.js (100%) create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-minimal-precedence/options.json rename packages/babel-parser/test/fixtures/experimental/pipeline-operator/{precedence => proposal-minimal-precedence}/output.json (100%) rename packages/babel-parser/test/fixtures/experimental/pipeline-operator/{with-arrow-parend-params => proposal-minimal-with-arrow-parend-params}/input.js (100%) create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-minimal-with-arrow-parend-params/options.json rename packages/babel-parser/test/fixtures/experimental/pipeline-operator/{with-arrow-parend-params => proposal-minimal-with-arrow-parend-params}/output.json (100%) rename packages/babel-parser/test/fixtures/experimental/pipeline-operator/{with-arrow => proposal-minimal-with-arrow}/input.js (100%) create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-minimal-with-arrow/options.json rename packages/babel-parser/test/fixtures/experimental/pipeline-operator/{with-arrow => proposal-minimal-with-arrow}/output.json (100%) create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-awaited-function-calls,-chained,-multiline/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-awaited-function-calls,-chained,-multiline/options.json create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-awaited-function-calls,-chained,-multiline/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-awaited-function-calls,-chained,-single-line/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-awaited-function-calls,-chained,-single-line/options.json create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-awaited-function-calls,-chained,-single-line/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-awaited-function-calls,-single,-nested-property/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-awaited-function-calls,-single,-nested-property/options.json create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-awaited-function-calls,-single,-nested-property/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-awaited-function-calls,-single,-single-identifier/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-awaited-function-calls,-single,-single-identifier/options.json create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-awaited-function-calls,-single,-single-identifier/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-constructor-calls,-chained,-multiline/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-constructor-calls,-chained,-multiline/options.json create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-constructor-calls,-chained,-multiline/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-constructor-calls,-chained,-single-line-arrow-function/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-constructor-calls,-chained,-single-line-arrow-function/options.json create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-constructor-calls,-chained,-single-line-arrow-function/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-constructor-calls,-single,-identifier/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-constructor-calls,-single,-identifier/options.json create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-constructor-calls,-single,-identifier/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-constructor-calls,-single,-property/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-constructor-calls,-single,-property/options.json create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-constructor-calls,-single,-property/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-function-calls,-chained,-multiline/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-function-calls,-chained,-multiline/options.json create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-function-calls,-chained,-multiline/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-function-calls,-chained,-single-line-arrow-function/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-function-calls,-chained,-single-line-arrow-function/options.json create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-function-calls,-chained,-single-line-arrow-function/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-function-calls,-single,-identifier/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-function-calls,-single,-identifier/options.json create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-function-calls,-single,-identifier/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-function-calls,-single,-property/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-function-calls,-single,-property/options.json create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-function-calls,-single,-property/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-bare-style,-head-with-topic-reference-pair/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-bare-style,-head-with-topic-reference-pair/options.json create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-invalid-hash-token,-followed-by-digit/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-invalid-hash-token,-followed-by-digit/options.json create mode 100644 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 create mode 100644 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 create mode 100644 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 create mode 100644 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 create mode 100644 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 create mode 100644 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 create mode 100644 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 create mode 100644 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 create mode 100644 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 create mode 100644 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 create mode 100644 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 create mode 100644 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 create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-sequence-style,-body-with-topic-reference-pair-then-end/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-sequence-style,-body-with-topic-reference-pair-then-end/options.json create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-no-topic-reference,-addition/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-no-topic-reference,-addition/options.json create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-no-topic-reference,-class-expression/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-no-topic-reference,-class-expression/options.json create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-no-topic-reference,-function-expression/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-no-topic-reference,-function-expression/options.json create mode 100644 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 create mode 100644 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 create mode 100644 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 create mode 100644 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 create mode 100644 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 create mode 100644 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 create mode 100644 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 create mode 100644 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 create mode 100644 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 create mode 100644 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 create mode 100644 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 create mode 100644 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 create mode 100644 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 create mode 100644 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 create mode 100644 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 create mode 100644 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 create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-unparenthesized-arrow-function-with-bare-parameter-and-bare-body/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-unparenthesized-arrow-function-with-bare-parameter-and-bare-body/options.json create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-unbound-topic,-inner-class-in-pipeline-body/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-unbound-topic,-inner-class-in-pipeline-body/options.json create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-unbound-topic,-inner-function-in-pipeline-body/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-unbound-topic,-inner-function-in-pipeline-body/options.json create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-unbound-topic,-pipeline-head-in-inner-function-in-pipeline-body/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-unbound-topic,-pipeline-head-in-inner-function-in-pipeline-body/options.json create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-unbound-topic,-simple/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-unbound-topic,-simple/options.json create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-nested-pipelines,-topic-style-with-arrow-function-with-bare-style/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-nested-pipelines,-topic-style-with-arrow-function-with-bare-style/options.json create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-nested-pipelines,-topic-style-with-arrow-function-with-bare-style/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-nested-pipelines,-topic-style-with-arrow-function-with-topic-style/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-nested-pipelines,-topic-style-with-arrow-function-with-topic-style/options.json create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-nested-pipelines,-topic-style-with-arrow-function-with-topic-style/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-nested-pipelines,-topic-style-with-inner-bare-style/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-nested-pipelines,-topic-style-with-inner-bare-style/options.json create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-nested-pipelines,-topic-style-with-inner-bare-style/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-nested-pipelines,-topic-style-with-inner-topic-style/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-nested-pipelines,-topic-style-with-inner-topic-style/options.json create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-nested-pipelines,-topic-style-with-inner-topic-style/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-style-mix,-multiline/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-style-mix,-multiline/options.json create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-style-mix,-multiline/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-style-mix,-single-line/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-style-mix,-single-line/options.json create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-style-mix,-single-line/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-addition,-single-line-arrow-function,-topic-reference-first/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-addition,-single-line-arrow-function,-topic-reference-first/options.json create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-addition,-single-line-arrow-function,-topic-reference-first/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-addition,-single-line-arrow-function,-topic-reference-last/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-addition,-single-line-arrow-function,-topic-reference-last/options.json create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-addition,-single-line-arrow-function,-topic-reference-last/output.json create mode 100644 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 create mode 100644 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 create mode 100644 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 create mode 100644 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 create mode 100644 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 create mode 100644 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 create mode 100644 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 create mode 100644 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 create mode 100644 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 create mode 100644 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 create mode 100644 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 create mode 100644 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 create mode 100644 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 create mode 100644 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 create mode 100644 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 create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-do-expression,-identity/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-do-expression,-identity/options.json create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-do-expression,-identity/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-do-expression,-if-statement,-outer-topic-reference-in-else-body/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-do-expression,-if-statement,-outer-topic-reference-in-else-body/options.json create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-do-expression,-if-statement,-outer-topic-reference-in-else-body/output.json create mode 100644 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 create mode 100644 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 create mode 100644 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 create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-do-expression,-if-statement,-outer-topic-reference-in-if-body/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-do-expression,-if-statement,-outer-topic-reference-in-if-body/options.json create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-do-expression,-if-statement,-outer-topic-reference-in-if-body/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-do-expression,-if-statement,-outer-topic-reference-in-if-head/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-do-expression,-if-statement,-outer-topic-reference-in-if-head/options.json create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-do-expression,-if-statement,-outer-topic-reference-in-if-head/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-do-expression,-switch-statement,-outer-topic-reference-in-switch-body/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-do-expression,-switch-statement,-outer-topic-reference-in-switch-body/options.json create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-do-expression,-switch-statement,-outer-topic-reference-in-switch-body/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-do-expression,-switch-statement,-outer-topic-reference-in-switch-head/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-do-expression,-switch-statement,-outer-topic-reference-in-switch-head/options.json create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-do-expression,-switch-statement,-outer-topic-reference-in-switch-head/output.json create mode 100644 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 create mode 100644 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 create mode 100644 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 create mode 100644 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 create mode 100644 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 create mode 100644 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 create mode 100644 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 create mode 100644 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 create mode 100644 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 create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-do-expression,-while-loop,-outer-topic-reference-in-loop-head/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-do-expression,-while-loop,-outer-topic-reference-in-loop-head/options.json create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-do-expression,-while-loop,-outer-topic-reference-in-loop-head/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-function-call,-identifier-with-topic-reference/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-function-call,-identifier-with-topic-reference/options.json create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-function-call,-identifier-with-topic-reference/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-function-definition,-outer-topic-reference-in-default-parameter-expression/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-function-definition,-outer-topic-reference-in-default-parameter-expression/options.json create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-function-definition,-outer-topic-reference-in-default-parameter-expression/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-identity,-parenthesized/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-identity,-parenthesized/options.json create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-identity,-parenthesized/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-identity,-unparenthesized/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-identity,-unparenthesized/options.json create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-identity,-unparenthesized/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-mixed-pipeline-plugins/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-mixed-pipeline-plugins/options.json create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-mixed-pipeline-plugins/output.json create mode 100644 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 create mode 100644 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 create mode 100644 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 delete mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/with-arrow-parend-params/options.json delete mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/with-arrow/options.json diff --git a/packages/babel-parser/src/parser/expression.js b/packages/babel-parser/src/parser/expression.js index 64868e7d591b..c87ce28a0e91 100644 --- a/packages/babel-parser/src/parser/expression.js +++ b/packages/babel-parser/src/parser/expression.js @@ -24,6 +24,8 @@ import LValParser from "./lval"; import { reservedWords } from "../util/identifier"; import type { Pos, Position } from "../util/location"; +const PIPELINE_PROPOSALS = ["minimal", "smart"]; + export default class ExpressionParser extends LValParser { // Forward-declaration: defined in statement.js +parseBlock: (allowDirectives?: boolean) => N.BlockStatement; @@ -296,18 +298,19 @@ export default class ExpressionParser extends LValParser { } const op = this.state.type; - if (op === tt.nullishCoalescing) { + + if (op === tt.pipeline) { + this.checkPipelineAtInfixOperator(left, leftStartPos); + } else if (op === tt.nullishCoalescing) { this.expectPlugin("nullishCoalescingOperator"); - } else if (op === tt.pipeline) { - this.expectPlugin("pipelineOperator"); } this.next(); - const startPos = this.state.start; - const startLoc = this.state.startLoc; - - if (op === tt.pipeline) { + if ( + op === tt.pipeline && + "minimal" === this.getPluginOption("pipelineOperator", "proposal") + ) { if ( this.match(tt.name) && this.state.value === "await" && @@ -320,13 +323,7 @@ export default class ExpressionParser extends LValParser { } } - node.right = this.parseExprOp( - this.parseMaybeUnary(), - startPos, - startLoc, - op.rightAssociative ? prec - 1 : prec, - noIn, - ); + node.right = this.parseExprOpRightExpr(op, prec, noIn); this.finishNode( node, @@ -336,6 +333,7 @@ export default class ExpressionParser extends LValParser { ? "LogicalExpression" : "BinaryExpression", ); + return this.parseExprOp( node, leftStartPos, @@ -348,6 +346,55 @@ export default class ExpressionParser extends LValParser { return left; } + // Helper function for `parseExprOp`. Parse the right-hand side of binary- + // operator expressions, then apply any operator-specific functions. + + parseExprOpRightExpr( + op: TokenType, + prec: number, + noIn: ?boolean, + ): N.Expression { + switch (op) { + case tt.pipeline: + if ("smart" === this.getPluginOption("pipelineOperator", "proposal")) { + const startPos = this.state.start; + const startLoc = this.state.startLoc; + return this.withTopicPermittingContext(() => { + return this.parseSmartPipelineBody( + this.parseExprOpBaseRightExpr(op, prec, noIn), + startPos, + startLoc, + ); + }); + } else { + return this.parseExprOpBaseRightExpr(op, prec, noIn); + } + + default: + return this.parseExprOpBaseRightExpr(op, prec, noIn); + } + } + + // Helper function for `parseExprOpRightExpr`. Parse the right-hand side of + // binary-operator expressions without applying any operator-specific functions. + + parseExprOpBaseRightExpr( + op: TokenType, + prec: number, + noIn: ?boolean, + ): N.Expression { + const startPos = this.state.start; + const startLoc = this.state.startLoc; + + return this.parseExprOp( + this.parseMaybeUnary(), + startPos, + startLoc, + op.rightAssociative ? prec - 1 : prec, + noIn, + ); + } + // Parse unary operators, both prefix and postfix. parseMaybeUnary(refShorthandDefaultPos: ?Pos): N.Expression { @@ -886,6 +933,29 @@ export default class ExpressionParser extends LValParser { } } + case tt.primaryTopicReference: { + this.expectPlugin("pipelineOperator"); + node = this.startNode(); + + if ("smart" !== this.getPluginOption("pipelineOperator", "proposal")) { + this.raise( + node.start, + "Primary Topic Reference found but pipelineOperator not passed 'smart' for 'proposal' option.", + ); + } + + this.next(); + if (this.primaryTopicReferenceIsAllowedInCurrentTopicContext()) { + this.registerTopicReference(); + return this.finishNode(node, "PrimaryTopicReference"); + } else { + throw this.raise( + node.start, + `Topic reference was used in a lexical context without topic binding`, + ); + } + } + default: throw this.unexpected(); } @@ -1921,4 +1991,218 @@ export default class ExpressionParser extends LValParser { } return this.finishNode(node, "YieldExpression"); } + + // Validates a pipeline (for any of the pipeline Babylon plugins) at the point + // of the infix operator `|>`. + + checkPipelineAtInfixOperator(left: N.Expression, leftStartPos: number) { + this.expectPlugin("pipelineOperator"); + + if ( + !PIPELINE_PROPOSALS.includes( + this.getPluginOption("pipelineOperator", "proposal"), + ) + ) { + this.raise( + leftStartPos, + "'pipelineOperator' requires 'proposal' option whose value should be one of: " + + PIPELINE_PROPOSALS.join(", "), + ); + } + + if ("smart" === this.getPluginOption("pipelineOperator", "proposal")) { + this.checkSmartPipelineHeadEarlyErrors(left, leftStartPos); + } + } + + checkSmartPipelineHeadEarlyErrors(left: N.Expression, leftStartPos: number) { + if (left.type === "SequenceExpression") { + // Ensure that the pipeline head is not a comma-delimited + // sequence expression. + throw this.raise( + leftStartPos, + `Pipeline head may not be a comma-separated sequence expression`, + ); + } + } + + parseSmartPipelineBody( + childExpression: N.Expression, + startPos: number, + startLoc: Position, + ): N.PipelineBody { + const pipelineStyle = this.checkSmartPipelineBodyStyle(childExpression); + + this.checkSmartPipelineBodyEarlyErrors( + childExpression, + pipelineStyle, + startPos, + ); + + return this.parseSmartPipelineBodyInStyle( + childExpression, + pipelineStyle, + startPos, + startLoc, + ); + } + + checkSmartPipelineBodyEarlyErrors( + childExpression: N.Expression, + pipelineStyle: PipelineStyle, + startPos: number, + ): N.PipelineBody { + 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, + `Unexpected arrow "=>" after pipeline body; arrow function in pipeline body must be parenthesized`, + ); + } else if ( + pipelineStyle === "PipelineTopicExpression" && + childExpression.type === "SequenceExpression" + ) { + throw this.raise( + startPos, + `Pipeline body may not be a comma-separated sequence expression`, + ); + } + } + + parseSmartPipelineBodyInStyle( + childExpression: N.Expression, + pipelineStyle: PipelineStyle, + startPos: number, + startLoc: Position, + ): N.PipelineBody { + const bodyNode = this.startNodeAt(startPos, startLoc); + switch (pipelineStyle) { + case "PipelineBareFunction": + bodyNode.callee = childExpression; + break; + case "PipelineBareConstructor": + bodyNode.callee = childExpression.callee; + break; + case "PipelineBareAwaitedFunction": + bodyNode.callee = childExpression.argument; + break; + case "PipelineTopicExpression": + if (!this.topicReferenceWasUsedInCurrentTopicContext()) { + throw this.raise( + startPos, + `Pipeline is in topic style but does not use topic reference`, + ); + } + bodyNode.expression = childExpression; + break; + default: + throw this.raise(startPos, `Unknown pipeline style ${pipelineStyle}`); + } + return this.finishNode(bodyNode, pipelineStyle); + } + + checkSmartPipelineBodyStyle( + expression: N.Expression, + ): + | "PipelineBareFunction" + | "PipelineBareConstructor" + | "PipelineBareAwaitedFunction" + | "PipelineTopicExpression" { + switch (expression.type) { + case "NewExpression": + return this.isSimpleReference(expression.callee) + ? "PipelineBareConstructor" + : "PipelineTopicExpression"; + case "AwaitExpression": + return this.isSimpleReference(expression.argument) + ? "PipelineBareAwaitedFunction" + : "PipelineTopicExpression"; + default: + return this.isSimpleReference(expression) + ? "PipelineBareFunction" + : "PipelineTopicExpression"; + } + } + + isSimpleReference(expression: N.Expression): boolean { + switch (expression.type) { + case "MemberExpression": + return this.isSimpleReference(expression.object); + case "Identifier": + return true; + default: + return false; + } + } + + // 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. + + withTopicPermittingContext(callback: () => T): T { + const outerContextTopicState = this.readTopicContextState(); + this.state.topicContextState = { + // Enable the use of the primary topic reference. + maxNumOfResolvableTopics: 1, + // Hide the use of any topic references from outer contexts. + maxTopicIndex: null, + }; + + const callbackResult = callback(); + + this.state.topicContextState = outerContextTopicState; + return callbackResult; + } + + // Disable 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.readTopicContextState(); + this.state.topicContextState = { + // Disable the use of the primary topic reference. + maxNumOfResolvableTopics: 0, + // Hide the use of any topic references from outer contexts. + maxTopicIndex: null, + }; + + const callbackResult = callback(); + + this.state.topicContextState = outerContextTopicState; + return callbackResult; + } + + readTopicContextState(): tt.TopicContextState { + return this.state.topicContextState; + } + + // Register the use of a primary topic reference (`#`) within the current + // topic context. + registerTopicReference(): void { + this.state.topicContextState.maxTopicIndex = 0; + } + + primaryTopicReferenceIsAllowedInCurrentTopicContext(): boolean { + return this.state.topicContextState.maxNumOfResolvableTopics >= 1; + } + + topicReferenceWasUsedInCurrentTopicContext(): boolean { + return ( + this.state.topicContextState.maxTopicIndex != null && + this.state.topicContextState.maxTopicIndex >= 0 + ); + } } + +type PipelineStyle = + | "PipelineBareFunction" + | "PipelineBareConstructor" + | "PipelineBareAwaitedFunction" + | "PipelineTopicExpression"; diff --git a/packages/babel-parser/src/parser/statement.js b/packages/babel-parser/src/parser/statement.js index 7bf7f55d07b5..041d8813e49d 100644 --- a/packages/babel-parser/src/parser/statement.js +++ b/packages/babel-parser/src/parser/statement.js @@ -364,8 +364,18 @@ export default class StatementParser extends ExpressionParser { parseDoStatement(node: N.DoWhileStatement): N.DoWhileStatement { this.next(); this.state.labels.push(loopLabel); - node.body = this.parseStatement(false); + + 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(() => + // Parse the loop body's body. + this.parseStatement(false), + ); + this.state.labels.pop(); + this.expect(tt._while); node.test = this.parseParenExpression(); this.eat(tt.semi); @@ -554,7 +564,17 @@ export default class StatementParser extends ExpressionParser { this.expectPlugin("optionalCatchBinding"); clause.param = null; } - clause.body = this.parseBlock(); + + clause.body = + // For the smartPipelines plugin: Disable topic references from outer + // contexts within the function body. They are permitted in function + // default-parameter expressions, which are part of the outer context, + // outside of the function body. + this.withTopicForbiddingContext(() => + // Parse the catch clause's body. + this.parseBlock(false), + ); + node.handler = this.finishNode(clause, "CatchClause"); } @@ -582,8 +602,18 @@ export default class StatementParser extends ExpressionParser { this.next(); node.test = this.parseParenExpression(); this.state.labels.push(loopLabel); - node.body = this.parseStatement(false); + + 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(() => + // Parse loop body. + this.parseStatement(false), + ); + this.state.labels.pop(); + return this.finishNode(node, "WhileStatement"); } @@ -593,7 +623,17 @@ export default class StatementParser extends ExpressionParser { } this.next(); node.object = this.parseParenExpression(); - node.body = this.parseStatement(false); + + node.body = + // For the smartPipelines plugin: + // Disable topic references from outer contexts within the function body. + // They are permitted in function default-parameter expressions, which are + // part of the outer context, outside of the function body. + this.withTopicForbiddingContext(() => + // Parse the statement body. + this.parseStatement(false), + ); + return this.finishNode(node, "WithStatement"); } @@ -750,8 +790,18 @@ export default class StatementParser extends ExpressionParser { this.expect(tt.semi); node.update = this.match(tt.parenR) ? null : this.parseExpression(); this.expect(tt.parenR); - node.body = this.parseStatement(false); + + 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(() => + // Parse the loop body. + this.parseStatement(false), + ); + this.state.labels.pop(); + return this.finishNode(node, "ForStatement"); } @@ -775,8 +825,18 @@ export default class StatementParser extends ExpressionParser { node.left = init; node.right = this.parseExpression(); this.expect(tt.parenR); - node.body = this.parseStatement(false); + + 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(() => + // Parse loop body. + this.parseStatement(false), + ); + this.state.labels.pop(); + return this.finishNode(node, type); } @@ -879,11 +939,18 @@ export default class StatementParser extends ExpressionParser { if (isStatement) this.state.inGenerator = node.generator; this.parseFunctionParams(node); - this.parseFunctionBodyAndFinish( - node, - isStatement ? "FunctionDeclaration" : "FunctionExpression", - allowExpressionBody, - ); + + // For the smartPipelines plugin: Disable topic references from outer + // contexts within the function body. They are permitted in test + // expressions, outside of the function body. + this.withTopicForbiddingContext(() => { + // Parse the function body. + this.parseFunctionBodyAndFinish( + node, + isStatement ? "FunctionDeclaration" : "FunctionExpression", + allowExpressionBody, + ); + }); this.state.inFunction = oldInFunc; this.state.inMethod = oldInMethod; @@ -957,44 +1024,49 @@ export default class StatementParser extends ExpressionParser { this.expect(tt.braceL); - while (!this.eat(tt.braceR)) { - if (this.eat(tt.semi)) { - if (decorators.length > 0) { - this.raise( - this.state.lastTokEnd, - "Decorators must not be followed by a semicolon", - ); + // For the smartPipelines plugin: Disable topic references from outer + // contexts within the class body. They are permitted in test expressions, + // outside of the class body. + this.withTopicForbiddingContext(() => { + while (!this.eat(tt.braceR)) { + if (this.eat(tt.semi)) { + if (decorators.length > 0) { + this.raise( + this.state.lastTokEnd, + "Decorators must not be followed by a semicolon", + ); + } + continue; } - continue; - } - if (this.match(tt.at)) { - decorators.push(this.parseDecorator()); - continue; - } + if (this.match(tt.at)) { + decorators.push(this.parseDecorator()); + continue; + } - const member = this.startNode(); + const member = this.startNode(); - // steal the decorators if there are any - if (decorators.length) { - member.decorators = decorators; - this.resetStartLocationFromNode(member, decorators[0]); - decorators = []; - } + // steal the decorators if there are any + if (decorators.length) { + member.decorators = decorators; + this.resetStartLocationFromNode(member, decorators[0]); + decorators = []; + } - this.parseClassMember(classBody, member, state); + this.parseClassMember(classBody, member, state); - if ( - member.kind === "constructor" && - member.decorators && - member.decorators.length > 0 - ) { - this.raise( - member.start, - "Decorators can't be used with a constructor. Did you mean '@dec class { ... }'?", - ); + if ( + member.kind === "constructor" && + member.decorators && + member.decorators.length > 0 + ) { + this.raise( + member.start, + "Decorators can't be used with a constructor. Did you mean '@dec class { ... }'?", + ); + } } - } + }); if (decorators.length) { this.raise( diff --git a/packages/babel-parser/src/tokenizer/index.js b/packages/babel-parser/src/tokenizer/index.js index a5655cadb465..658760c32e61 100644 --- a/packages/babel-parser/src/tokenizer/index.js +++ b/packages/babel-parser/src/tokenizer/index.js @@ -404,6 +404,43 @@ export default class Tokenizer extends LocationParser { // // All in the name of speed. // + readToken_numberSign(code: number): void { + if (this.state.pos === 0 && this.readToken_interpreter()) { + return; + } + + const nextPos = this.state.pos + 1; + const next = this.input.charCodeAt(nextPos); + // if (isIdentifierStart(next)) { + if ( + (this.hasPlugin("classPrivateProperties") || + this.hasPlugin("classPrivateMethods")) && + this.state.classLevel > 0 + ) { + ++this.state.pos; + this.finishToken(tt.hash); + return; + } else if ( + "smart" === this.getPluginOption("pipelineOperator", "proposal") + ) { + if (next >= charCodes.digit0 && next <= charCodes.digit9) { + this.raise( + this.state.pos, + `Unexpected digit after topic reference: '#${String.fromCodePoint( + next, + )}'`, + ); + } else { + this.finishOp(tt.primaryTopicReference, 1); + } + } else { + this.raise( + this.state.pos, + `Unexpected character '${codePointToString(code)}'`, + ); + } + } + readToken_dot(): void { const next = this.input.charCodeAt(this.state.pos + 1); if (next >= charCodes.digit0 && next <= charCodes.digit9) { @@ -651,25 +688,12 @@ export default class Tokenizer extends LocationParser { getTokenFromCode(code: number): void { switch (code) { - case charCodes.numberSign: - if (this.state.pos === 0 && this.readToken_interpreter()) { - return; - } + // The interpretation of a number sign "#" depends on whether it is + // followed by an identifier or not. - if ( - (this.hasPlugin("classPrivateProperties") || - this.hasPlugin("classPrivateMethods")) && - this.state.classLevel > 0 - ) { - ++this.state.pos; - this.finishToken(tt.hash); - return; - } else { - this.raise( - this.state.pos, - `Unexpected character '${codePointToString(code)}'`, - ); - } + case charCodes.numberSign: + this.readToken_numberSign(code); + return; // The interpretation of a dot depends on whether it is followed // by a digit or another two dots. diff --git a/packages/babel-parser/src/tokenizer/state.js b/packages/babel-parser/src/tokenizer/state.js index 364ceec96d32..536d81592434 100644 --- a/packages/babel-parser/src/tokenizer/state.js +++ b/packages/babel-parser/src/tokenizer/state.js @@ -33,6 +33,12 @@ export default class State { this.hasFlowComment = false; this.isIterator = false; + // Used by smartPipelines. + this.topicContextState = { + maxNumOfResolvableTopics: 0, + maxTopicIndex: undefined, + }; + this.classLevel = 0; this.labels = []; @@ -111,6 +117,9 @@ export default class State { hasFlowComment: boolean; isIterator: boolean; + // For the smartPipelines plugin: + topicContextState: tt.TopicContextState; + // Check whether we are in a (nested) class or not. classLevel: number; diff --git a/packages/babel-parser/src/tokenizer/types.js b/packages/babel-parser/src/tokenizer/types.js index 050ca6c82065..1142a47f2446 100644 --- a/packages/babel-parser/src/tokenizer/types.js +++ b/packages/babel-parser/src/tokenizer/types.js @@ -86,6 +86,7 @@ export const types: { [name: string]: TokenType } = { regexp: new TokenType("regexp", { startsExpr }), string: new TokenType("string", { startsExpr }), name: new TokenType("name", { startsExpr }), + primaryTopicReference: new TokenType("#", { startsExpr }), eof: new TokenType("eof"), // Punctuation token types. @@ -199,3 +200,17 @@ export const keywords = { Object.keys(keywords).forEach(name => { types["_" + name] = keywords[name]; }); + +// A type for the smartPipelines plugin. +export type TopicContextState = { + // When a topic binding has been currently established, + // then this is 1. Otherwise, it is 0. This is forwards compatible + // with a future plugin for multiple lexical topics. + maxNumOfResolvableTopics: number, + + // When a topic binding has been currently established, and if that binding + // has been used as a topic reference `#`, then this is 0. Otherwise, it is + // `null`. This is forwards compatible with a future plugin for multiple + // lexical topics. + maxTopicIndex: null | 0, +}; diff --git a/packages/babel-parser/src/types.js b/packages/babel-parser/src/types.js index 0a7d2d0f5271..7524c232b256 100644 --- a/packages/babel-parser/src/types.js +++ b/packages/babel-parser/src/types.js @@ -565,6 +565,32 @@ export type SequenceExpression = NodeBase & { expressions: $ReadOnlyArray, }; +// Pipelines + +export type PipelineBody = NodeBase & { + type: "PipelineBody", +}; + +export type PipelineBareFunctionBody = PipelineBody & { + type: "PipelineBareFunctionBody", + callee: Expression, +}; + +export type PipelineBareConstructorBody = PipelineBody & { + type: "PipelineBareConstructorBody", + callee: Expression, +}; + +export type PipelineBareAwaitedFunctionBody = PipelineBody & { + type: "PipelineBareAwaitedFunctionBody", + callee: Expression, +}; + +export type PipelineTopicBody = PipelineBody & { + type: "PipelineTopicBody", + expression: Expression, +}; + // Template Literals export type TemplateLiteral = NodeBase & { diff --git a/packages/babel-parser/test/fixtures/experimental/nullish-coalescing-operator/with-pipeline/options.json b/packages/babel-parser/test/fixtures/experimental/nullish-coalescing-operator/with-pipeline/options.json index 37fbfac05f2a..790c3f234b5c 100644 --- a/packages/babel-parser/test/fixtures/experimental/nullish-coalescing-operator/with-pipeline/options.json +++ b/packages/babel-parser/test/fixtures/experimental/nullish-coalescing-operator/with-pipeline/options.json @@ -1,4 +1,6 @@ { - "plugins": ["nullishCoalescingOperator", "pipelineOperator"] + "plugins": [ + "nullishCoalescingOperator", + ["pipelineOperator", { "proposal": "minimal" }] + ] } - \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/arrow-requires-parens-with-parend-args/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/arrow-requires-parens-with-parend-args/options.json deleted file mode 100644 index 120167aad9cf..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/arrow-requires-parens-with-parend-args/options.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "plugins": ["pipelineOperator"], - "throws": "Unexpected token, expected \";\" (1:10)" -} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/arrow-requires-parens/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/arrow-requires-parens/options.json deleted file mode 100644 index 6f196466a493..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/arrow-requires-parens/options.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "plugins": ["pipelineOperator"], - "throws": "Unexpected token, expected \";\" (1:8)" -} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/await-requires-parens/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/await-requires-parens/options.json deleted file mode 100644 index 599d48a46961..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/await-requires-parens/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "plugins": ["pipelineOperator"] -} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/base/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/base/options.json deleted file mode 100644 index 599d48a46961..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/base/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "plugins": ["pipelineOperator"] -} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/chain/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/chain/options.json deleted file mode 100644 index 599d48a46961..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/chain/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "plugins": ["pipelineOperator"] -} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/base/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/invalid-proposal/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/base/input.js rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/invalid-proposal/input.js 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 new file mode 100644 index 000000000000..9b75bedf3622 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/invalid-proposal/options.json @@ -0,0 +1,6 @@ +{ + "plugins": [ + ["pipelineOperator", { "proposal": "invalid" }] + ], + "throws": "'pipelineOperator' requires 'proposal' option whose value should be one of: minimal, smart (1:0)" +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/multiline/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/multiline/options.json deleted file mode 100644 index 599d48a46961..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/multiline/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "plugins": ["pipelineOperator"] -} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/precedence/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/precedence/options.json deleted file mode 100644 index 599d48a46961..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/precedence/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "plugins": ["pipelineOperator"] -} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/arrow-requires-parens-with-parend-args/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-minimal-arrow-requires-parens-with-parend-args/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/arrow-requires-parens-with-parend-args/input.js rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-minimal-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/proposal-minimal-arrow-requires-parens-with-parend-args/options.json new file mode 100644 index 000000000000..b4e236359dd1 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-minimal-arrow-requires-parens-with-parend-args/options.json @@ -0,0 +1,6 @@ +{ + "plugins": [ + ["pipelineOperator", { "proposal": "minimal" }] + ], + "throws": "Unexpected token, expected \";\" (1:10)" +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/arrow-requires-parens/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-minimal-arrow-requires-parens/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/arrow-requires-parens/input.js rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-minimal-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/proposal-minimal-arrow-requires-parens/options.json new file mode 100644 index 000000000000..551ef0ba6c76 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-minimal-arrow-requires-parens/options.json @@ -0,0 +1,6 @@ +{ + "plugins": [ + ["pipelineOperator", { "proposal": "minimal" }] + ], + "throws": "Unexpected token, expected \";\" (1:8)" +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/await-requires-parens/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-minimal-await-requires-parens/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/await-requires-parens/input.js rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-minimal-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/proposal-minimal-await-requires-parens/options.json new file mode 100644 index 000000000000..f96a57c74821 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-minimal-await-requires-parens/options.json @@ -0,0 +1,5 @@ +{ + "plugins": [ + ["pipelineOperator", { "proposal": "minimal" }] + ] +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/await-requires-parens/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-minimal-await-requires-parens/output.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/await-requires-parens/output.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-minimal-await-requires-parens/output.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/ban-await-f/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-minimal-ban-await-f/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/ban-await-f/input.js rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-minimal-ban-await-f/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/ban-await/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-minimal-ban-await-f/options.json similarity index 61% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/ban-await/options.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-minimal-ban-await-f/options.json index d964de6b4d2b..126164b9ee52 100644 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/ban-await/options.json +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-minimal-ban-await-f/options.json @@ -1,4 +1,6 @@ { - "plugins": ["pipelineOperator"], + "plugins": [ + ["pipelineOperator", { "proposal": "minimal" }] + ], "throws": "Unexpected \"await\" after pipeline body; await must have parentheses in minimal proposal (2:14)" } diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/ban-await/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-minimal-ban-await/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/ban-await/input.js rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-minimal-ban-await/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/ban-await-f/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-minimal-ban-await/options.json similarity index 61% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/ban-await-f/options.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-minimal-ban-await/options.json index d964de6b4d2b..126164b9ee52 100644 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/ban-await-f/options.json +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-minimal-ban-await/options.json @@ -1,4 +1,6 @@ { - "plugins": ["pipelineOperator"], + "plugins": [ + ["pipelineOperator", { "proposal": "minimal" }] + ], "throws": "Unexpected \"await\" after pipeline body; await must have parentheses in minimal proposal (2:14)" } 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/proposal-minimal-base/input.js new file mode 100644 index 000000000000..cf3443941ff0 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-minimal-base/input.js @@ -0,0 +1 @@ +a |> b 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/proposal-minimal-base/options.json new file mode 100644 index 000000000000..f96a57c74821 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-minimal-base/options.json @@ -0,0 +1,5 @@ +{ + "plugins": [ + ["pipelineOperator", { "proposal": "minimal" }] + ] +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/base/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-minimal-base/output.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/base/output.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-minimal-base/output.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/chain/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-minimal-chain/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/chain/input.js rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-minimal-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/proposal-minimal-chain/options.json new file mode 100644 index 000000000000..f96a57c74821 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-minimal-chain/options.json @@ -0,0 +1,5 @@ +{ + "plugins": [ + ["pipelineOperator", { "proposal": "minimal" }] + ] +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/chain/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-minimal-chain/output.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/chain/output.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-minimal-chain/output.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/multiline/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-minimal-multiline/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/multiline/input.js rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-minimal-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/proposal-minimal-multiline/options.json new file mode 100644 index 000000000000..f96a57c74821 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-minimal-multiline/options.json @@ -0,0 +1,5 @@ +{ + "plugins": [ + ["pipelineOperator", { "proposal": "minimal" }] + ] +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/multiline/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-minimal-multiline/output.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/multiline/output.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-minimal-multiline/output.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/precedence/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-minimal-precedence/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/precedence/input.js rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-minimal-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/proposal-minimal-precedence/options.json new file mode 100644 index 000000000000..f96a57c74821 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-minimal-precedence/options.json @@ -0,0 +1,5 @@ +{ + "plugins": [ + ["pipelineOperator", { "proposal": "minimal" }] + ] +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/precedence/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-minimal-precedence/output.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/precedence/output.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-minimal-precedence/output.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/with-arrow-parend-params/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-minimal-with-arrow-parend-params/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/with-arrow-parend-params/input.js rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-minimal-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/proposal-minimal-with-arrow-parend-params/options.json new file mode 100644 index 000000000000..f96a57c74821 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-minimal-with-arrow-parend-params/options.json @@ -0,0 +1,5 @@ +{ + "plugins": [ + ["pipelineOperator", { "proposal": "minimal" }] + ] +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/with-arrow-parend-params/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-minimal-with-arrow-parend-params/output.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/with-arrow-parend-params/output.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-minimal-with-arrow-parend-params/output.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/with-arrow/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-minimal-with-arrow/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/with-arrow/input.js rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-minimal-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/proposal-minimal-with-arrow/options.json new file mode 100644 index 000000000000..f96a57c74821 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-minimal-with-arrow/options.json @@ -0,0 +1,5 @@ +{ + "plugins": [ + ["pipelineOperator", { "proposal": "minimal" }] + ] +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/with-arrow/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-minimal-with-arrow/output.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/with-arrow/output.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-minimal-with-arrow/output.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-awaited-function-calls,-chained,-multiline/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-awaited-function-calls,-chained,-multiline/input.js new file mode 100644 index 000000000000..dfbeff94f212 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-awaited-function-calls,-chained,-multiline/input.js @@ -0,0 +1,6 @@ +async function af () { + let result = "hello" + |> await doubleSay + |> await text.capitalize + |> await a.b.exclaim; +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-awaited-function-calls,-chained,-multiline/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-awaited-function-calls,-chained,-multiline/options.json new file mode 100644 index 000000000000..8b9d7913160a --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-awaited-function-calls,-chained,-multiline/options.json @@ -0,0 +1,5 @@ +{ + "plugins": [ + ["pipelineOperator", { "proposal": "smart" }] + ] +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-awaited-function-calls,-chained,-multiline/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-awaited-function-calls,-chained,-multiline/output.json new file mode 100644 index 000000000000..fd6424d6361a --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-awaited-function-calls,-chained,-multiline/output.json @@ -0,0 +1,401 @@ +{ + "type": "File", + "start": 0, + "end": 119, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 6, + "column": 1 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 119, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 6, + "column": 1 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 119, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 6, + "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": 119, + "loc": { + "start": { + "line": 1, + "column": 21 + }, + "end": { + "line": 6, + "column": 1 + } + }, + "body": [ + { + "type": "VariableDeclaration", + "start": 25, + "end": 117, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 5, + "column": 23 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 29, + "end": 116, + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 5, + "column": 22 + } + }, + "id": { + "type": "Identifier", + "start": 29, + "end": 35, + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 12 + }, + "identifierName": "result" + }, + "name": "result" + }, + "init": { + "type": "BinaryExpression", + "start": 38, + "end": 116, + "loc": { + "start": { + "line": 2, + "column": 15 + }, + "end": { + "line": 5, + "column": 22 + } + }, + "left": { + "type": "BinaryExpression", + "start": 38, + "end": 93, + "loc": { + "start": { + "line": 2, + "column": 15 + }, + "end": { + "line": 4, + "column": 26 + } + }, + "left": { + "type": "BinaryExpression", + "start": 38, + "end": 66, + "loc": { + "start": { + "line": 2, + "column": 15 + }, + "end": { + "line": 3, + "column": 20 + } + }, + "left": { + "type": "StringLiteral", + "start": 38, + "end": 45, + "loc": { + "start": { + "line": 2, + "column": 15 + }, + "end": { + "line": 2, + "column": 22 + } + }, + "extra": { + "rawValue": "hello", + "raw": "\"hello\"" + }, + "value": "hello" + }, + "operator": "|>", + "right": { + "type": "PipelineBareAwaitedFunction", + "start": 51, + "end": 66, + "loc": { + "start": { + "line": 3, + "column": 5 + }, + "end": { + "line": 3, + "column": 20 + } + }, + "callee": { + "type": "Identifier", + "start": 57, + "end": 66, + "loc": { + "start": { + "line": 3, + "column": 11 + }, + "end": { + "line": 3, + "column": 20 + }, + "identifierName": "doubleSay" + }, + "name": "doubleSay" + } + } + }, + "operator": "|>", + "right": { + "type": "PipelineBareAwaitedFunction", + "start": 72, + "end": 93, + "loc": { + "start": { + "line": 4, + "column": 5 + }, + "end": { + "line": 4, + "column": 26 + } + }, + "callee": { + "type": "MemberExpression", + "start": 78, + "end": 93, + "loc": { + "start": { + "line": 4, + "column": 11 + }, + "end": { + "line": 4, + "column": 26 + } + }, + "object": { + "type": "Identifier", + "start": 78, + "end": 82, + "loc": { + "start": { + "line": 4, + "column": 11 + }, + "end": { + "line": 4, + "column": 15 + }, + "identifierName": "text" + }, + "name": "text" + }, + "property": { + "type": "Identifier", + "start": 83, + "end": 93, + "loc": { + "start": { + "line": 4, + "column": 16 + }, + "end": { + "line": 4, + "column": 26 + }, + "identifierName": "capitalize" + }, + "name": "capitalize" + }, + "computed": false + } + } + }, + "operator": "|>", + "right": { + "type": "PipelineBareAwaitedFunction", + "start": 99, + "end": 116, + "loc": { + "start": { + "line": 5, + "column": 5 + }, + "end": { + "line": 5, + "column": 22 + } + }, + "callee": { + "type": "MemberExpression", + "start": 105, + "end": 116, + "loc": { + "start": { + "line": 5, + "column": 11 + }, + "end": { + "line": 5, + "column": 22 + } + }, + "object": { + "type": "MemberExpression", + "start": 105, + "end": 108, + "loc": { + "start": { + "line": 5, + "column": 11 + }, + "end": { + "line": 5, + "column": 14 + } + }, + "object": { + "type": "Identifier", + "start": 105, + "end": 106, + "loc": { + "start": { + "line": 5, + "column": 11 + }, + "end": { + "line": 5, + "column": 12 + }, + "identifierName": "a" + }, + "name": "a" + }, + "property": { + "type": "Identifier", + "start": 107, + "end": 108, + "loc": { + "start": { + "line": 5, + "column": 13 + }, + "end": { + "line": 5, + "column": 14 + }, + "identifierName": "b" + }, + "name": "b" + }, + "computed": false + }, + "property": { + "type": "Identifier", + "start": 109, + "end": 116, + "loc": { + "start": { + "line": 5, + "column": 15 + }, + "end": { + "line": 5, + "column": 22 + }, + "identifierName": "exclaim" + }, + "name": "exclaim" + }, + "computed": false + } + } + } + } + ], + "kind": "let" + } + ], + "directives": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-awaited-function-calls,-chained,-single-line/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-awaited-function-calls,-chained,-single-line/input.js new file mode 100644 index 000000000000..a78a3ae84428 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-awaited-function-calls,-chained,-single-line/input.js @@ -0,0 +1,3 @@ +async function af () { + x |> await number.inc |> await double; +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-awaited-function-calls,-chained,-single-line/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-awaited-function-calls,-chained,-single-line/options.json new file mode 100644 index 000000000000..17e4e327bbad --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-awaited-function-calls,-chained,-single-line/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,-awaited-function-calls,-chained,-single-line/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-awaited-function-calls,-chained,-single-line/output.json new file mode 100644 index 000000000000..5e0aa503463d --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-awaited-function-calls,-chained,-single-line/output.json @@ -0,0 +1,249 @@ +{ + "type": "File", + "start": 0, + "end": 65, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 65, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 65, + "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": 65, + "loc": { + "start": { + "line": 1, + "column": 21 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 25, + "end": 63, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 40 + } + }, + "expression": { + "type": "BinaryExpression", + "start": 25, + "end": 62, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 39 + } + }, + "left": { + "type": "BinaryExpression", + "start": 25, + "end": 46, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 23 + } + }, + "left": { + "type": "Identifier", + "start": 25, + "end": 26, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 3 + }, + "identifierName": "x" + }, + "name": "x" + }, + "operator": "|>", + "right": { + "type": "PipelineBareAwaitedFunction", + "start": 30, + "end": 46, + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 2, + "column": 23 + } + }, + "callee": { + "type": "MemberExpression", + "start": 36, + "end": 46, + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 23 + } + }, + "object": { + "type": "Identifier", + "start": 36, + "end": 42, + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 19 + }, + "identifierName": "number" + }, + "name": "number" + }, + "property": { + "type": "Identifier", + "start": 43, + "end": 46, + "loc": { + "start": { + "line": 2, + "column": 20 + }, + "end": { + "line": 2, + "column": 23 + }, + "identifierName": "inc" + }, + "name": "inc" + }, + "computed": false + } + } + }, + "operator": "|>", + "right": { + "type": "PipelineBareAwaitedFunction", + "start": 50, + "end": 62, + "loc": { + "start": { + "line": 2, + "column": 27 + }, + "end": { + "line": 2, + "column": 39 + } + }, + "callee": { + "type": "Identifier", + "start": 56, + "end": 62, + "loc": { + "start": { + "line": 2, + "column": 33 + }, + "end": { + "line": 2, + "column": 39 + }, + "identifierName": "double" + }, + "name": "double" + } + } + } + } + ], + "directives": [] + } + } + ], + "directives": [] + } +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-awaited-function-calls,-single,-nested-property/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-awaited-function-calls,-single,-nested-property/input.js new file mode 100644 index 000000000000..c86dda49df36 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-awaited-function-calls,-single,-nested-property/input.js @@ -0,0 +1,3 @@ +async function af () { + value |> await a.b.f +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-awaited-function-calls,-single,-nested-property/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-awaited-function-calls,-single,-nested-property/options.json new file mode 100644 index 000000000000..17e4e327bbad --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-awaited-function-calls,-single,-nested-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,-awaited-function-calls,-single,-nested-property/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-awaited-function-calls,-single,-nested-property/output.json new file mode 100644 index 000000000000..aaf050332d53 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-awaited-function-calls,-single,-nested-property/output.json @@ -0,0 +1,234 @@ +{ + "type": "File", + "start": 0, + "end": 47, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 47, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 47, + "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": 47, + "loc": { + "start": { + "line": 1, + "column": 21 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 25, + "end": 45, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 22 + } + }, + "expression": { + "type": "BinaryExpression", + "start": 25, + "end": 45, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 22 + } + }, + "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": "PipelineBareAwaitedFunction", + "start": 34, + "end": 45, + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 22 + } + }, + "callee": { + "type": "MemberExpression", + "start": 40, + "end": 45, + "loc": { + "start": { + "line": 2, + "column": 17 + }, + "end": { + "line": 2, + "column": 22 + } + }, + "object": { + "type": "MemberExpression", + "start": 40, + "end": 43, + "loc": { + "start": { + "line": 2, + "column": 17 + }, + "end": { + "line": 2, + "column": 20 + } + }, + "object": { + "type": "Identifier", + "start": 40, + "end": 41, + "loc": { + "start": { + "line": 2, + "column": 17 + }, + "end": { + "line": 2, + "column": 18 + }, + "identifierName": "a" + }, + "name": "a" + }, + "property": { + "type": "Identifier", + "start": 42, + "end": 43, + "loc": { + "start": { + "line": 2, + "column": 19 + }, + "end": { + "line": 2, + "column": 20 + }, + "identifierName": "b" + }, + "name": "b" + }, + "computed": false + }, + "property": { + "type": "Identifier", + "start": 44, + "end": 45, + "loc": { + "start": { + "line": 2, + "column": 21 + }, + "end": { + "line": 2, + "column": 22 + }, + "identifierName": "f" + }, + "name": "f" + }, + "computed": false + } + } + } + } + ], + "directives": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-awaited-function-calls,-single,-single-identifier/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-awaited-function-calls,-single,-single-identifier/input.js new file mode 100644 index 000000000000..ff9045bd7262 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-awaited-function-calls,-single,-single-identifier/input.js @@ -0,0 +1,3 @@ +async function af () { + value |> await f +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-awaited-function-calls,-single,-single-identifier/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-awaited-function-calls,-single,-single-identifier/options.json new file mode 100644 index 000000000000..17e4e327bbad --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-awaited-function-calls,-single,-single-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,-awaited-function-calls,-single,-single-identifier/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-awaited-function-calls,-single,-single-identifier/output.json new file mode 100644 index 000000000000..50b19d2d745b --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-awaited-function-calls,-single,-single-identifier/output.json @@ -0,0 +1,168 @@ +{ + "type": "File", + "start": 0, + "end": 43, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 43, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 43, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 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": 43, + "loc": { + "start": { + "line": 1, + "column": 21 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 25, + "end": 41, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 18 + } + }, + "expression": { + "type": "BinaryExpression", + "start": 25, + "end": 41, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 18 + } + }, + "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": "PipelineBareAwaitedFunction", + "start": 34, + "end": 41, + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 18 + } + }, + "callee": { + "type": "Identifier", + "start": 40, + "end": 41, + "loc": { + "start": { + "line": 2, + "column": 17 + }, + "end": { + "line": 2, + "column": 18 + }, + "identifierName": "f" + }, + "name": "f" + } + } + } + } + ], + "directives": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-constructor-calls,-chained,-multiline/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-constructor-calls,-chained,-multiline/input.js new file mode 100644 index 000000000000..07827f96fbcd --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-constructor-calls,-chained,-multiline/input.js @@ -0,0 +1,4 @@ +let result = "hello" +|> new DoubleSay +|> new text.Capitalize +|> new a.b.Exclaim; diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-constructor-calls,-chained,-multiline/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-constructor-calls,-chained,-multiline/options.json new file mode 100644 index 000000000000..17e4e327bbad --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-constructor-calls,-chained,-multiline/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,-constructor-calls,-chained,-multiline/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-constructor-calls,-chained,-multiline/output.json new file mode 100644 index 000000000000..cdf86d3125da --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-constructor-calls,-chained,-multiline/output.json @@ -0,0 +1,348 @@ +{ + "type": "File", + "start": 0, + "end": 80, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 19 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 80, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 19 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "VariableDeclaration", + "start": 0, + "end": 80, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 19 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 4, + "end": 79, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 4, + "column": 18 + } + }, + "id": { + "type": "Identifier", + "start": 4, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 10 + }, + "identifierName": "result" + }, + "name": "result" + }, + "init": { + "type": "BinaryExpression", + "start": 13, + "end": 79, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 4, + "column": 18 + } + }, + "left": { + "type": "BinaryExpression", + "start": 13, + "end": 60, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 3, + "column": 22 + } + }, + "left": { + "type": "BinaryExpression", + "start": 13, + "end": 37, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 2, + "column": 16 + } + }, + "left": { + "type": "StringLiteral", + "start": 13, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "extra": { + "rawValue": "hello", + "raw": "\"hello\"" + }, + "value": "hello" + }, + "operator": "|>", + "right": { + "type": "PipelineBareConstructor", + "start": 24, + "end": 37, + "loc": { + "start": { + "line": 2, + "column": 3 + }, + "end": { + "line": 2, + "column": 16 + } + }, + "callee": { + "type": "Identifier", + "start": 28, + "end": 37, + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 2, + "column": 16 + }, + "identifierName": "DoubleSay" + }, + "name": "DoubleSay" + } + } + }, + "operator": "|>", + "right": { + "type": "PipelineBareConstructor", + "start": 41, + "end": 60, + "loc": { + "start": { + "line": 3, + "column": 3 + }, + "end": { + "line": 3, + "column": 22 + } + }, + "callee": { + "type": "MemberExpression", + "start": 45, + "end": 60, + "loc": { + "start": { + "line": 3, + "column": 7 + }, + "end": { + "line": 3, + "column": 22 + } + }, + "object": { + "type": "Identifier", + "start": 45, + "end": 49, + "loc": { + "start": { + "line": 3, + "column": 7 + }, + "end": { + "line": 3, + "column": 11 + }, + "identifierName": "text" + }, + "name": "text" + }, + "property": { + "type": "Identifier", + "start": 50, + "end": 60, + "loc": { + "start": { + "line": 3, + "column": 12 + }, + "end": { + "line": 3, + "column": 22 + }, + "identifierName": "Capitalize" + }, + "name": "Capitalize" + }, + "computed": false + } + } + }, + "operator": "|>", + "right": { + "type": "PipelineBareConstructor", + "start": 64, + "end": 79, + "loc": { + "start": { + "line": 4, + "column": 3 + }, + "end": { + "line": 4, + "column": 18 + } + }, + "callee": { + "type": "MemberExpression", + "start": 68, + "end": 79, + "loc": { + "start": { + "line": 4, + "column": 7 + }, + "end": { + "line": 4, + "column": 18 + } + }, + "object": { + "type": "MemberExpression", + "start": 68, + "end": 71, + "loc": { + "start": { + "line": 4, + "column": 7 + }, + "end": { + "line": 4, + "column": 10 + } + }, + "object": { + "type": "Identifier", + "start": 68, + "end": 69, + "loc": { + "start": { + "line": 4, + "column": 7 + }, + "end": { + "line": 4, + "column": 8 + }, + "identifierName": "a" + }, + "name": "a" + }, + "property": { + "type": "Identifier", + "start": 70, + "end": 71, + "loc": { + "start": { + "line": 4, + "column": 9 + }, + "end": { + "line": 4, + "column": 10 + }, + "identifierName": "b" + }, + "name": "b" + }, + "computed": false + }, + "property": { + "type": "Identifier", + "start": 72, + "end": 79, + "loc": { + "start": { + "line": 4, + "column": 11 + }, + "end": { + "line": 4, + "column": 18 + }, + "identifierName": "Exclaim" + }, + "name": "Exclaim" + }, + "computed": false + } + } + } + } + ], + "kind": "let" + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-constructor-calls,-chained,-single-line-arrow-function/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-constructor-calls,-chained,-single-line-arrow-function/input.js new file mode 100644 index 000000000000..39c48bad512f --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-constructor-calls,-chained,-single-line-arrow-function/input.js @@ -0,0 +1 @@ +x => x |> new number.Inc |> new Double diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-constructor-calls,-chained,-single-line-arrow-function/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-constructor-calls,-chained,-single-line-arrow-function/options.json new file mode 100644 index 000000000000..17e4e327bbad --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-constructor-calls,-chained,-single-line-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,-constructor-calls,-chained,-single-line-arrow-function/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-constructor-calls,-chained,-single-line-arrow-function/output.json new file mode 100644 index 000000000000..4b4a0fb6af89 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-constructor-calls,-chained,-single-line-arrow-function/output.json @@ -0,0 +1,233 @@ +{ + "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": "ArrowFunctionExpression", + "start": 0, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 38 + } + }, + "id": null, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "start": 0, + "end": 1, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 1 + }, + "identifierName": "x" + }, + "name": "x" + } + ], + "body": { + "type": "BinaryExpression", + "start": 5, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 38 + } + }, + "left": { + "type": "BinaryExpression", + "start": 5, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "left": { + "type": "Identifier", + "start": 5, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 6 + }, + "identifierName": "x" + }, + "name": "x" + }, + "operator": "|>", + "right": { + "type": "PipelineBareConstructor", + "start": 10, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "callee": { + "type": "MemberExpression", + "start": 14, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "object": { + "type": "Identifier", + "start": 14, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 20 + }, + "identifierName": "number" + }, + "name": "number" + }, + "property": { + "type": "Identifier", + "start": 21, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 21 + }, + "end": { + "line": 1, + "column": 24 + }, + "identifierName": "Inc" + }, + "name": "Inc" + }, + "computed": false + } + } + }, + "operator": "|>", + "right": { + "type": "PipelineBareConstructor", + "start": 28, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 28 + }, + "end": { + "line": 1, + "column": 38 + } + }, + "callee": { + "type": "Identifier", + "start": 32, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 38 + }, + "identifierName": "Double" + }, + "name": "Double" + } + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-constructor-calls,-single,-identifier/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-constructor-calls,-single,-identifier/input.js new file mode 100644 index 000000000000..4a4ec7bcd357 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-constructor-calls,-single,-identifier/input.js @@ -0,0 +1 @@ +x => x |> new F diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-constructor-calls,-single,-identifier/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-constructor-calls,-single,-identifier/options.json new file mode 100644 index 000000000000..17e4e327bbad --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-constructor-calls,-single,-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,-constructor-calls,-single,-identifier/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-constructor-calls,-single,-identifier/output.json new file mode 100644 index 000000000000..1f6e4945bd06 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-constructor-calls,-single,-identifier/output.json @@ -0,0 +1,152 @@ +{ + "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": "ArrowFunctionExpression", + "start": 0, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "id": null, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "start": 0, + "end": 1, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 1 + }, + "identifierName": "x" + }, + "name": "x" + } + ], + "body": { + "type": "BinaryExpression", + "start": 5, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "left": { + "type": "Identifier", + "start": 5, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 6 + }, + "identifierName": "x" + }, + "name": "x" + }, + "operator": "|>", + "right": { + "type": "PipelineBareConstructor", + "start": 10, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "callee": { + "type": "Identifier", + "start": 14, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 15 + }, + "identifierName": "F" + }, + "name": "F" + } + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-constructor-calls,-single,-property/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-constructor-calls,-single,-property/input.js new file mode 100644 index 000000000000..f6b0bd49964b --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-constructor-calls,-single,-property/input.js @@ -0,0 +1 @@ +x => x |> new a.F diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-constructor-calls,-single,-property/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-constructor-calls,-single,-property/options.json new file mode 100644 index 000000000000..17e4e327bbad --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-constructor-calls,-single,-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,-constructor-calls,-single,-property/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-constructor-calls,-single,-property/output.json new file mode 100644 index 000000000000..dc9bbf5eab44 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-constructor-calls,-single,-property/output.json @@ -0,0 +1,185 @@ +{ + "type": "File", + "start": 0, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "expression": { + "type": "ArrowFunctionExpression", + "start": 0, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "id": null, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "start": 0, + "end": 1, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 1 + }, + "identifierName": "x" + }, + "name": "x" + } + ], + "body": { + "type": "BinaryExpression", + "start": 5, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "left": { + "type": "Identifier", + "start": 5, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 6 + }, + "identifierName": "x" + }, + "name": "x" + }, + "operator": "|>", + "right": { + "type": "PipelineBareConstructor", + "start": 10, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "callee": { + "type": "MemberExpression", + "start": 14, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "object": { + "type": "Identifier", + "start": 14, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 15 + }, + "identifierName": "a" + }, + "name": "a" + }, + "property": { + "type": "Identifier", + "start": 16, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 17 + }, + "identifierName": "F" + }, + "name": "F" + }, + "computed": false + } + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file 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/proposal-smart-bare-style,-function-calls,-chained,-multiline/input.js new file mode 100644 index 000000000000..49a8129b058f --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-function-calls,-chained,-multiline/input.js @@ -0,0 +1,4 @@ +let result = "hello" +|> doubleSay +|> text.capitalize +|> a.b.exclaim; diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-function-calls,-chained,-multiline/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-function-calls,-chained,-multiline/options.json new file mode 100644 index 000000000000..17e4e327bbad --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-function-calls,-chained,-multiline/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/proposal-smart-bare-style,-function-calls,-chained,-multiline/output.json new file mode 100644 index 000000000000..889bb7a69b62 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-function-calls,-chained,-multiline/output.json @@ -0,0 +1,348 @@ +{ + "type": "File", + "start": 0, + "end": 68, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 15 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 68, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 15 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "VariableDeclaration", + "start": 0, + "end": 68, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 15 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 4, + "end": 67, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 4, + "column": 14 + } + }, + "id": { + "type": "Identifier", + "start": 4, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 10 + }, + "identifierName": "result" + }, + "name": "result" + }, + "init": { + "type": "BinaryExpression", + "start": 13, + "end": 67, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 4, + "column": 14 + } + }, + "left": { + "type": "BinaryExpression", + "start": 13, + "end": 52, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 3, + "column": 18 + } + }, + "left": { + "type": "BinaryExpression", + "start": 13, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 2, + "column": 12 + } + }, + "left": { + "type": "StringLiteral", + "start": 13, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "extra": { + "rawValue": "hello", + "raw": "\"hello\"" + }, + "value": "hello" + }, + "operator": "|>", + "right": { + "type": "PipelineBareFunction", + "start": 24, + "end": 33, + "loc": { + "start": { + "line": 2, + "column": 3 + }, + "end": { + "line": 2, + "column": 12 + } + }, + "callee": { + "type": "Identifier", + "start": 24, + "end": 33, + "loc": { + "start": { + "line": 2, + "column": 3 + }, + "end": { + "line": 2, + "column": 12 + }, + "identifierName": "doubleSay" + }, + "name": "doubleSay" + } + } + }, + "operator": "|>", + "right": { + "type": "PipelineBareFunction", + "start": 37, + "end": 52, + "loc": { + "start": { + "line": 3, + "column": 3 + }, + "end": { + "line": 3, + "column": 18 + } + }, + "callee": { + "type": "MemberExpression", + "start": 37, + "end": 52, + "loc": { + "start": { + "line": 3, + "column": 3 + }, + "end": { + "line": 3, + "column": 18 + } + }, + "object": { + "type": "Identifier", + "start": 37, + "end": 41, + "loc": { + "start": { + "line": 3, + "column": 3 + }, + "end": { + "line": 3, + "column": 7 + }, + "identifierName": "text" + }, + "name": "text" + }, + "property": { + "type": "Identifier", + "start": 42, + "end": 52, + "loc": { + "start": { + "line": 3, + "column": 8 + }, + "end": { + "line": 3, + "column": 18 + }, + "identifierName": "capitalize" + }, + "name": "capitalize" + }, + "computed": false + } + } + }, + "operator": "|>", + "right": { + "type": "PipelineBareFunction", + "start": 56, + "end": 67, + "loc": { + "start": { + "line": 4, + "column": 3 + }, + "end": { + "line": 4, + "column": 14 + } + }, + "callee": { + "type": "MemberExpression", + "start": 56, + "end": 67, + "loc": { + "start": { + "line": 4, + "column": 3 + }, + "end": { + "line": 4, + "column": 14 + } + }, + "object": { + "type": "MemberExpression", + "start": 56, + "end": 59, + "loc": { + "start": { + "line": 4, + "column": 3 + }, + "end": { + "line": 4, + "column": 6 + } + }, + "object": { + "type": "Identifier", + "start": 56, + "end": 57, + "loc": { + "start": { + "line": 4, + "column": 3 + }, + "end": { + "line": 4, + "column": 4 + }, + "identifierName": "a" + }, + "name": "a" + }, + "property": { + "type": "Identifier", + "start": 58, + "end": 59, + "loc": { + "start": { + "line": 4, + "column": 5 + }, + "end": { + "line": 4, + "column": 6 + }, + "identifierName": "b" + }, + "name": "b" + }, + "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 + } + } + } + } + ], + "kind": "let" + } + ], + "directives": [] + } +} \ No newline at end of file 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/proposal-smart-bare-style,-function-calls,-chained,-single-line-arrow-function/input.js new file mode 100644 index 000000000000..253a8fdfddf9 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-function-calls,-chained,-single-line-arrow-function/input.js @@ -0,0 +1 @@ +x => x |> number.inc |> double 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/proposal-smart-bare-style,-function-calls,-chained,-single-line-arrow-function/options.json new file mode 100644 index 000000000000..17e4e327bbad --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-function-calls,-chained,-single-line-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/proposal-smart-bare-style,-function-calls,-chained,-single-line-arrow-function/output.json new file mode 100644 index 000000000000..71953d9db9ce --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-function-calls,-chained,-single-line-arrow-function/output.json @@ -0,0 +1,233 @@ +{ + "type": "File", + "start": 0, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "expression": { + "type": "ArrowFunctionExpression", + "start": 0, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "id": null, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "start": 0, + "end": 1, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 1 + }, + "identifierName": "x" + }, + "name": "x" + } + ], + "body": { + "type": "BinaryExpression", + "start": 5, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "left": { + "type": "BinaryExpression", + "start": 5, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "left": { + "type": "Identifier", + "start": 5, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 6 + }, + "identifierName": "x" + }, + "name": "x" + }, + "operator": "|>", + "right": { + "type": "PipelineBareFunction", + "start": 10, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "callee": { + "type": "MemberExpression", + "start": 10, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "object": { + "type": "Identifier", + "start": 10, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 16 + }, + "identifierName": "number" + }, + "name": "number" + }, + "property": { + "type": "Identifier", + "start": 17, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 20 + }, + "identifierName": "inc" + }, + "name": "inc" + }, + "computed": false + } + } + }, + "operator": "|>", + "right": { + "type": "PipelineBareFunction", + "start": 24, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 24 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "callee": { + "type": "Identifier", + "start": 24, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 24 + }, + "end": { + "line": 1, + "column": 30 + }, + "identifierName": "double" + }, + "name": "double" + } + } + } + } + } + ], + "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/proposal-smart-bare-style,-function-calls,-single,-identifier/input.js new file mode 100644 index 000000000000..15a3d7657b9c --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-function-calls,-single,-identifier/input.js @@ -0,0 +1 @@ +value |> f 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/proposal-smart-bare-style,-function-calls,-single,-identifier/options.json new file mode 100644 index 000000000000..17e4e327bbad --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-function-calls,-single,-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/proposal-smart-bare-style,-function-calls,-single,-identifier/output.json new file mode 100644 index 000000000000..0aef90100fb5 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-function-calls,-single,-identifier/output.json @@ -0,0 +1,115 @@ +{ + "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": "PipelineBareFunction", + "start": 9, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "callee": { + "type": "Identifier", + "start": 9, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 10 + }, + "identifierName": "f" + }, + "name": "f" + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-function-calls,-single,-property/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-function-calls,-single,-property/input.js new file mode 100644 index 000000000000..9f9ac30d8f48 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-function-calls,-single,-property/input.js @@ -0,0 +1 @@ +value |> a.b.c.f 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/proposal-smart-bare-style,-function-calls,-single,-property/options.json new file mode 100644 index 000000000000..17e4e327bbad --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-function-calls,-single,-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/proposal-smart-bare-style,-function-calls,-single,-property/output.json new file mode 100644 index 000000000000..0fbd40308b71 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-function-calls,-single,-property/output.json @@ -0,0 +1,214 @@ +{ + "type": "File", + "start": 0, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "expression": { + "type": "BinaryExpression", + "start": 0, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "left": { + "type": "Identifier", + "start": 0, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + }, + "identifierName": "value" + }, + "name": "value" + }, + "operator": "|>", + "right": { + "type": "PipelineBareFunction", + "start": 9, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "callee": { + "type": "MemberExpression", + "start": 9, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "object": { + "type": "MemberExpression", + "start": 9, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "object": { + "type": "MemberExpression", + "start": 9, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "object": { + "type": "Identifier", + "start": 9, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 10 + }, + "identifierName": "a" + }, + "name": "a" + }, + "property": { + "type": "Identifier", + "start": 11, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 12 + }, + "identifierName": "b" + }, + "name": "b" + }, + "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 + }, + "property": { + "type": "Identifier", + "start": 15, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 16 + }, + "identifierName": "f" + }, + "name": "f" + }, + "computed": false + } + } + } + } + ], + "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/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-bare-style,-head-with-topic-reference-pair/input.js new file mode 100644 index 000000000000..a93aa77bbd74 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-bare-style,-head-with-topic-reference-pair/input.js @@ -0,0 +1 @@ +(1, 2) |> f; 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 new file mode 100644 index 000000000000..c785202f2a0c --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-bare-style,-head-with-topic-reference-pair/options.json @@ -0,0 +1,4 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "smart" }]], + "throws": "Pipeline head may not be a comma-separated sequence expression (1:0)" +} 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/proposal-smart-error,-invalid-hash-token,-followed-by-digit/input.js new file mode 100644 index 000000000000..b18a6404b537 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-invalid-hash-token,-followed-by-digit/input.js @@ -0,0 +1 @@ +x |> #42; 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/proposal-smart-error,-invalid-hash-token,-followed-by-digit/options.json new file mode 100644 index 000000000000..6d423c8c9d96 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-invalid-hash-token,-followed-by-digit/options.json @@ -0,0 +1,4 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "smart" }]], + "throws": "Unexpected digit after topic reference: '#4' (1: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/proposal-smart-error,-nested-pipelines,-topic-style-with-arrow-function-with-bare-style,-no-outer-topic-reference/input.js new file mode 100644 index 000000000000..194b4e64ed1f --- /dev/null +++ b/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 @@ -0,0 +1 @@ +x |> ($ => $ |> f) 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/proposal-smart-error,-nested-pipelines,-topic-style-with-arrow-function-with-bare-style,-no-outer-topic-reference/options.json new file mode 100644 index 000000000000..d2b32f77521a --- /dev/null +++ b/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 @@ -0,0 +1,4 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "smart" }]], + "throws": "Pipeline is in topic style but does not use topic reference (1:5)" +} 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/proposal-smart-error,-nested-pipelines,-topic-style-with-arrow-function-with-topic-style,-no-inner-topic-reference/input.js new file mode 100644 index 000000000000..98e99a4493f1 --- /dev/null +++ b/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 @@ -0,0 +1 @@ +x |> ($ => # |> $ + 1) 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/proposal-smart-error,-nested-pipelines,-topic-style-with-arrow-function-with-topic-style,-no-inner-topic-reference/options.json new file mode 100644 index 000000000000..e9eab6b46fe9 --- /dev/null +++ b/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 @@ -0,0 +1,4 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "smart" }]], + "throws": "Pipeline is in topic style but does not use topic reference (1:16)" +} 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/proposal-smart-error,-nested-pipelines,-topic-style-with-arrow-function-with-topic-style,-no-outer-topic-reference/input.js new file mode 100644 index 000000000000..a4723737f3b5 --- /dev/null +++ b/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 @@ -0,0 +1 @@ +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/proposal-smart-error,-nested-pipelines,-topic-style-with-arrow-function-with-topic-style,-no-outer-topic-reference/options.json new file mode 100644 index 000000000000..d2b32f77521a --- /dev/null +++ b/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 @@ -0,0 +1,4 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "smart" }]], + "throws": "Pipeline is in topic style but does not use topic reference (1:5)" +} 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/proposal-smart-error,-nested-pipelines,-topic-style-with-inner-topic-style,-no-inner-topic-reference/input.js new file mode 100644 index 000000000000..50b90bb9adf9 --- /dev/null +++ b/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 @@ -0,0 +1 @@ +x |> (# |> f()) 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/proposal-smart-error,-nested-pipelines,-topic-style-with-inner-topic-style,-no-inner-topic-reference/options.json new file mode 100644 index 000000000000..bdf0547df8f9 --- /dev/null +++ b/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 @@ -0,0 +1,4 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "smart" }]], + "throws": "Pipeline is in topic style but does not use topic reference (1:11)" +} 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/proposal-smart-error,-nested-pipelines,-topic-style-with-inner-topic-style,-no-outer-topic-reference/input.js new file mode 100644 index 000000000000..9d00837048ed --- /dev/null +++ b/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 @@ -0,0 +1 @@ +x |> ($ |> f) 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/proposal-smart-error,-nested-pipelines,-topic-style-with-inner-topic-style,-no-outer-topic-reference/options.json new file mode 100644 index 000000000000..d2b32f77521a --- /dev/null +++ b/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 @@ -0,0 +1,4 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "smart" }]], + "throws": "Pipeline is in topic style but does not use topic reference (1:5)" +} 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/proposal-smart-error,-sequence-style,-body-with-topic-reference-pair-followed-by-bare-style-pipeline-body/input.js new file mode 100644 index 000000000000..a6146afadab6 --- /dev/null +++ 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/input.js @@ -0,0 +1 @@ +10 |> (#, #) |> h; 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 new file mode 100644 index 000000000000..fe3873ecc67f --- /dev/null +++ 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 @@ -0,0 +1,4 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "smart" }]], + "throws": "Pipeline body may not be a comma-separated sequence expression (1:6)" +} 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/proposal-smart-error,-sequence-style,-body-with-topic-reference-pair-then-end/input.js new file mode 100644 index 000000000000..7da42e013c11 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-sequence-style,-body-with-topic-reference-pair-then-end/input.js @@ -0,0 +1 @@ +10 |> (#, #); 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 new file mode 100644 index 000000000000..fe3873ecc67f --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-sequence-style,-body-with-topic-reference-pair-then-end/options.json @@ -0,0 +1,4 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "smart" }]], + "throws": "Pipeline body may not be a comma-separated sequence expression (1:6)" +} 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/proposal-smart-error,-topic-style,-no-topic-reference,-addition/input.js new file mode 100644 index 000000000000..e952adac15fd --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-no-topic-reference,-addition/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/proposal-smart-error,-topic-style,-no-topic-reference,-addition/options.json new file mode 100644 index 000000000000..7a4451381c91 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-no-topic-reference,-addition/options.json @@ -0,0 +1,4 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "smart" }]], + "throws": "Pipeline is in topic style but does not use topic reference (1:9)" +} 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/proposal-smart-error,-topic-style,-no-topic-reference,-class-expression/input.js new file mode 100644 index 000000000000..6ccb6ca13351 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-no-topic-reference,-class-expression/input.js @@ -0,0 +1 @@ +value |> class { } 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/proposal-smart-error,-topic-style,-no-topic-reference,-class-expression/options.json new file mode 100644 index 000000000000..7a4451381c91 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-no-topic-reference,-class-expression/options.json @@ -0,0 +1,4 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "smart" }]], + "throws": "Pipeline is in topic style but does not use topic reference (1:9)" +} 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/proposal-smart-error,-topic-style,-no-topic-reference,-function-expression/input.js new file mode 100644 index 000000000000..faf09879d637 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-no-topic-reference,-function-expression/input.js @@ -0,0 +1 @@ +value |> function (x) { return; } 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/proposal-smart-error,-topic-style,-no-topic-reference,-function-expression/options.json new file mode 100644 index 000000000000..7a4451381c91 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-no-topic-reference,-function-expression/options.json @@ -0,0 +1,4 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "smart" }]], + "throws": "Pipeline is in topic style but does not use topic reference (1:9)" +} 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/proposal-smart-error,-topic-style,-unbound-topic,-do-expression,-do-while-loop,-outer-topic-reference-in-loop-body/input.js new file mode 100644 index 000000000000..c1005576b7d5 --- /dev/null +++ b/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 @@ -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/proposal-smart-error,-topic-style,-unbound-topic,-do-expression,-do-while-loop,-outer-topic-reference-in-loop-body/options.json new file mode 100644 index 000000000000..3b7a52d71cf7 --- /dev/null +++ b/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 @@ -0,0 +1,4 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "smart" }], "doExpressions"], + "throws": "Topic reference was used in a lexical context without topic binding (1:22)" +} 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/proposal-smart-error,-topic-style,-unbound-topic,-do-expression,-for-await-of-loop,-outer-topic-reference-in-loop-body/input.js new file mode 100644 index 000000000000..261f95e4c7d2 --- /dev/null +++ b/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 @@ -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/proposal-smart-error,-topic-style,-unbound-topic,-do-expression,-for-await-of-loop,-outer-topic-reference-in-loop-body/options.json new file mode 100644 index 000000000000..d4a1b64b4575 --- /dev/null +++ b/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 @@ -0,0 +1,4 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "smart" }], "doExpressions", "asyncGenerators"], + "throws": "Topic reference was used in a lexical context without topic binding (2:48)" +} 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/proposal-smart-error,-topic-style,-unbound-topic,-do-expression,-for-classic-loop,-outer-topic-reference-in-loop-body/input.js new file mode 100644 index 000000000000..e0eb815c73fb --- /dev/null +++ b/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 @@ -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-classic-loop,-outer-topic-reference-in-loop-body/options.json b/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 new file mode 100644 index 000000000000..35e8658a93da --- /dev/null +++ b/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 @@ -0,0 +1,4 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "smart" }], "doExpressions"], + "throws": "Topic reference was used in a lexical context without topic binding (1:45)" +} 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/proposal-smart-error,-topic-style,-unbound-topic,-do-expression,-for-in-loop,-outer-topic-reference-in-loop-body/input.js new file mode 100644 index 000000000000..f6ebfaf94818 --- /dev/null +++ b/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 @@ -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,-for-in-loop,-outer-topic-reference-in-loop-body/options.json b/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 new file mode 100644 index 000000000000..6e8b4a6f0d95 --- /dev/null +++ b/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 @@ -0,0 +1,4 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "smart" }], "doExpressions"], + "throws": "Topic reference was used in a lexical context without topic binding (1:32)" +} 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/proposal-smart-error,-topic-style,-unbound-topic,-do-expression,-for-of-loop,-outer-topic-reference-in-loop-body/input.js new file mode 100644 index 000000000000..b3350a5ad5e0 --- /dev/null +++ b/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 @@ -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,-for-of-loop,-outer-topic-reference-in-loop-body/options.json b/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 new file mode 100644 index 000000000000..a3707cc91710 --- /dev/null +++ b/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 @@ -0,0 +1,4 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "smart" }], "doExpressions"], + "throws": "Topic reference was used in a lexical context without topic binding (1:34)" +} 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/proposal-smart-error,-topic-style,-unbound-topic,-do-expression,-try-statement,-outer-topic-reference-in-catch-clause/input.js new file mode 100644 index 000000000000..bd64c4dd8768 --- /dev/null +++ b/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 @@ -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-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/proposal-smart-error,-topic-style,-unbound-topic,-do-expression,-try-statement,-outer-topic-reference-in-catch-clause/options.json new file mode 100644 index 000000000000..0f40a90d2204 --- /dev/null +++ b/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 @@ -0,0 +1,4 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "smart" }], "doExpressions"], + "throws": "Topic reference was used in a lexical context without topic binding (3:32)" +} 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/proposal-smart-error,-topic-style,-unbound-topic,-do-expression,-while-loop,-outer-topic-reference-in-loop-body/input.js new file mode 100644 index 000000000000..06cfc1f2bed0 --- /dev/null +++ b/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 @@ -0,0 +1 @@ +value |> do { while (x < 50) x += #; } 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/proposal-smart-error,-topic-style,-unbound-topic,-do-expression,-while-loop,-outer-topic-reference-in-loop-body/options.json new file mode 100644 index 000000000000..a3707cc91710 --- /dev/null +++ b/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 @@ -0,0 +1,4 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "smart" }], "doExpressions"], + "throws": "Topic reference was used in a lexical context without topic binding (1:34)" +} 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/proposal-smart-error,-topic-style,-unbound-topic,-do-expression,-with-statement,-outer-topic-reference-in-with-body/input.js new file mode 100644 index 000000000000..4872290c9926 --- /dev/null +++ b/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 @@ -0,0 +1 @@ +value |> do { with ({}) #; } 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/proposal-smart-error,-topic-style,-unbound-topic,-do-expression,-with-statement,-outer-topic-reference-in-with-body/options.json new file mode 100644 index 000000000000..fee1ffebc044 --- /dev/null +++ b/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 @@ -0,0 +1,4 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "smart" }], "doExpressions"], + "throws": "Topic reference was used in a lexical context without topic binding (1:24)" +} 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/proposal-smart-error,-topic-style,-unparenthesized-arrow-function-with-bare-parameter-and-bare-body/input.js new file mode 100644 index 000000000000..00d1c2320d2f --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-unparenthesized-arrow-function-with-bare-parameter-and-bare-body/input.js @@ -0,0 +1 @@ +10 |> x => x + #; 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 new file mode 100644 index 000000000000..a684795fbfb9 --- /dev/null +++ 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 @@ -0,0 +1,4 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "smart" }]], + "throws": "Unexpected arrow \"=>\" after pipeline body; arrow function in pipeline body must be parenthesized (1:8)" +} 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/proposal-smart-error,-unbound-topic,-inner-class-in-pipeline-body/input.js new file mode 100644 index 000000000000..a905d1b71159 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-unbound-topic,-inner-class-in-pipeline-body/input.js @@ -0,0 +1 @@ +x |> class { constructor () { this.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/proposal-smart-error,-unbound-topic,-inner-class-in-pipeline-body/options.json new file mode 100644 index 000000000000..6401af97db12 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-unbound-topic,-inner-class-in-pipeline-body/options.json @@ -0,0 +1,4 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "smart" }]], + "throws": "Topic reference was used in a lexical context without topic binding (1:39)" +} 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/proposal-smart-error,-unbound-topic,-inner-function-in-pipeline-body/input.js new file mode 100644 index 000000000000..8af92dbefe4a --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-unbound-topic,-inner-function-in-pipeline-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/proposal-smart-error,-unbound-topic,-inner-function-in-pipeline-body/options.json new file mode 100644 index 000000000000..e6731253189f --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-unbound-topic,-inner-function-in-pipeline-body/options.json @@ -0,0 +1,4 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "smart" }]], + "throws": "Topic reference was used in a lexical context without topic binding (1:19)" +} 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/proposal-smart-error,-unbound-topic,-pipeline-head-in-inner-function-in-pipeline-body/input.js new file mode 100644 index 000000000000..818748040ed7 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-unbound-topic,-pipeline-head-in-inner-function-in-pipeline-body/input.js @@ -0,0 +1 @@ +x |> function () { # |> # } 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/proposal-smart-error,-unbound-topic,-pipeline-head-in-inner-function-in-pipeline-body/options.json new file mode 100644 index 000000000000..e6731253189f --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-unbound-topic,-pipeline-head-in-inner-function-in-pipeline-body/options.json @@ -0,0 +1,4 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "smart" }]], + "throws": "Topic reference was used in a lexical context without topic binding (1:19)" +} 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/proposal-smart-error,-unbound-topic,-simple/input.js new file mode 100644 index 000000000000..2d07bd7883dc --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-unbound-topic,-simple/input.js @@ -0,0 +1 @@ +1 + # 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/proposal-smart-error,-unbound-topic,-simple/options.json new file mode 100644 index 000000000000..79a8e0a3852e --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-unbound-topic,-simple/options.json @@ -0,0 +1,4 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "smart" }]], + "throws": "Topic reference was used in a lexical context without topic binding (1:4)" +} 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/proposal-smart-nested-pipelines,-topic-style-with-arrow-function-with-bare-style/input.js new file mode 100644 index 000000000000..a5a21763a8eb --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-nested-pipelines,-topic-style-with-arrow-function-with-bare-style/input.js @@ -0,0 +1 @@ +x |> (() => # |> f) 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/proposal-smart-nested-pipelines,-topic-style-with-arrow-function-with-bare-style/options.json new file mode 100644 index 000000000000..17e4e327bbad --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-nested-pipelines,-topic-style-with-arrow-function-with-bare-style/options.json @@ -0,0 +1,3 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "smart" }]] +} 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/proposal-smart-nested-pipelines,-topic-style-with-arrow-function-with-bare-style/output.json new file mode 100644 index 000000000000..619f4e61b22b --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-nested-pipelines,-topic-style-with-arrow-function-with-bare-style/output.json @@ -0,0 +1,184 @@ +{ + "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": "PipelineTopicExpression", + "start": 5, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "expression": { + "type": "ArrowFunctionExpression", + "start": 6, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "id": null, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BinaryExpression", + "start": 12, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "left": { + "type": "PrimaryTopicReference", + "start": 12, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 13 + } + } + }, + "operator": "|>", + "right": { + "type": "PipelineBareFunction", + "start": 17, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "callee": { + "type": "Identifier", + "start": 17, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 18 + }, + "identifierName": "f" + }, + "name": "f" + } + } + }, + "extra": { + "parenthesized": true, + "parenStart": 5 + } + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-nested-pipelines,-topic-style-with-arrow-function-with-topic-style/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-nested-pipelines,-topic-style-with-arrow-function-with-topic-style/input.js new file mode 100644 index 000000000000..e8fc8e430b8e --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-nested-pipelines,-topic-style-with-arrow-function-with-topic-style/input.js @@ -0,0 +1 @@ +x |> ($ => # |> f(#, $)) 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/proposal-smart-nested-pipelines,-topic-style-with-arrow-function-with-topic-style/options.json new file mode 100644 index 000000000000..17e4e327bbad --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-nested-pipelines,-topic-style-with-arrow-function-with-topic-style/options.json @@ -0,0 +1,3 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "smart" }]] +} 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/proposal-smart-nested-pipelines,-topic-style-with-arrow-function-with-topic-style/output.json new file mode 100644 index 000000000000..b83895f5f4c3 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-nested-pipelines,-topic-style-with-arrow-function-with-topic-style/output.json @@ -0,0 +1,251 @@ +{ + "type": "File", + "start": 0, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "expression": { + "type": "BinaryExpression", + "start": 0, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "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": 24, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "expression": { + "type": "ArrowFunctionExpression", + "start": 6, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "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": 23, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "left": { + "type": "PrimaryTopicReference", + "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": "PrimaryTopicReference", + "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": "$" + } + ] + } + } + }, + "extra": { + "parenthesized": true, + "parenStart": 5 + } + } + } + } + } + ], + "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-bare-style/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-nested-pipelines,-topic-style-with-inner-bare-style/input.js new file mode 100644 index 000000000000..a462b80cbbd8 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-nested-pipelines,-topic-style-with-inner-bare-style/input.js @@ -0,0 +1 @@ +x |> (# |> f) 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/proposal-smart-nested-pipelines,-topic-style-with-inner-bare-style/options.json new file mode 100644 index 000000000000..17e4e327bbad --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-nested-pipelines,-topic-style-with-inner-bare-style/options.json @@ -0,0 +1,3 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "smart" }]] +} 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/proposal-smart-nested-pipelines,-topic-style-with-inner-bare-style/output.json new file mode 100644 index 000000000000..c2bc9ec1b75c --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-nested-pipelines,-topic-style-with-inner-bare-style/output.json @@ -0,0 +1,165 @@ +{ + "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": 1, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 1 + }, + "identifierName": "x" + }, + "name": "x" + }, + "operator": "|>", + "right": { + "type": "PipelineTopicExpression", + "start": 5, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "expression": { + "type": "BinaryExpression", + "start": 6, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "left": { + "type": "PrimaryTopicReference", + "start": 6, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + } + } + }, + "operator": "|>", + "right": { + "type": "PipelineBareFunction", + "start": 11, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "callee": { + "type": "Identifier", + "start": 11, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 12 + }, + "identifierName": "f" + }, + "name": "f" + } + }, + "extra": { + "parenthesized": true, + "parenStart": 5 + } + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-nested-pipelines,-topic-style-with-inner-topic-style/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-nested-pipelines,-topic-style-with-inner-topic-style/input.js new file mode 100644 index 000000000000..2668daa465d1 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-nested-pipelines,-topic-style-with-inner-topic-style/input.js @@ -0,0 +1 @@ +x |> (# |> f(#, x)) 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/proposal-smart-nested-pipelines,-topic-style-with-inner-topic-style/options.json new file mode 100644 index 000000000000..17e4e327bbad --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-nested-pipelines,-topic-style-with-inner-topic-style/options.json @@ -0,0 +1,3 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "smart" }]] +} 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/proposal-smart-nested-pipelines,-topic-style-with-inner-topic-style/output.json new file mode 100644 index 000000000000..683de81b9c6a --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-nested-pipelines,-topic-style-with-inner-topic-style/output.json @@ -0,0 +1,214 @@ +{ + "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": "PipelineTopicExpression", + "start": 5, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "expression": { + "type": "BinaryExpression", + "start": 6, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "left": { + "type": "PrimaryTopicReference", + "start": 6, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + } + } + }, + "operator": "|>", + "right": { + "type": "PipelineTopicExpression", + "start": 11, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "expression": { + "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": "PrimaryTopicReference", + "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" + } + ] + } + }, + "extra": { + "parenthesized": true, + "parenStart": 5 + } + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-style-mix,-multiline/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-style-mix,-multiline/input.js new file mode 100644 index 000000000000..0045c931d1e3 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-style-mix,-multiline/input.js @@ -0,0 +1,7 @@ +async function af () { + let result = "hello" + |> # + '' + |> new DoubleSay + |> capitalize + |> await exclaim; +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-style-mix,-multiline/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-style-mix,-multiline/options.json new file mode 100644 index 000000000000..17e4e327bbad --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-style-mix,-multiline/options.json @@ -0,0 +1,3 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "smart" }]] +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-style-mix,-multiline/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-style-mix,-multiline/output.json new file mode 100644 index 000000000000..8f5a0c112d2e --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-style-mix,-multiline/output.json @@ -0,0 +1,384 @@ +{ + "type": "File", + "start": 0, + "end": 114, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 7, + "column": 1 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 114, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 7, + "column": 1 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 114, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 7, + "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": 114, + "loc": { + "start": { + "line": 1, + "column": 21 + }, + "end": { + "line": 7, + "column": 1 + } + }, + "body": [ + { + "type": "VariableDeclaration", + "start": 25, + "end": 112, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 6, + "column": 19 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 29, + "end": 111, + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 6, + "column": 18 + } + }, + "id": { + "type": "Identifier", + "start": 29, + "end": 35, + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 12 + }, + "identifierName": "result" + }, + "name": "result" + }, + "init": { + "type": "BinaryExpression", + "start": 38, + "end": 111, + "loc": { + "start": { + "line": 2, + "column": 15 + }, + "end": { + "line": 6, + "column": 18 + } + }, + "left": { + "type": "BinaryExpression", + "start": 38, + "end": 92, + "loc": { + "start": { + "line": 2, + "column": 15 + }, + "end": { + "line": 5, + "column": 15 + } + }, + "left": { + "type": "BinaryExpression", + "start": 38, + "end": 76, + "loc": { + "start": { + "line": 2, + "column": 15 + }, + "end": { + "line": 4, + "column": 18 + } + }, + "left": { + "type": "BinaryExpression", + "start": 38, + "end": 57, + "loc": { + "start": { + "line": 2, + "column": 15 + }, + "end": { + "line": 3, + "column": 11 + } + }, + "left": { + "type": "StringLiteral", + "start": 38, + "end": 45, + "loc": { + "start": { + "line": 2, + "column": 15 + }, + "end": { + "line": 2, + "column": 22 + } + }, + "extra": { + "rawValue": "hello", + "raw": "\"hello\"" + }, + "value": "hello" + }, + "operator": "|>", + "right": { + "type": "PipelineTopicExpression", + "start": 51, + "end": 57, + "loc": { + "start": { + "line": 3, + "column": 5 + }, + "end": { + "line": 3, + "column": 11 + } + }, + "expression": { + "type": "BinaryExpression", + "start": 51, + "end": 57, + "loc": { + "start": { + "line": 3, + "column": 5 + }, + "end": { + "line": 3, + "column": 11 + } + }, + "left": { + "type": "PrimaryTopicReference", + "start": 51, + "end": 52, + "loc": { + "start": { + "line": 3, + "column": 5 + }, + "end": { + "line": 3, + "column": 6 + } + } + }, + "operator": "+", + "right": { + "type": "StringLiteral", + "start": 55, + "end": 57, + "loc": { + "start": { + "line": 3, + "column": 9 + }, + "end": { + "line": 3, + "column": 11 + } + }, + "extra": { + "rawValue": "", + "raw": "''" + }, + "value": "" + } + } + } + }, + "operator": "|>", + "right": { + "type": "PipelineBareConstructor", + "start": 63, + "end": 76, + "loc": { + "start": { + "line": 4, + "column": 5 + }, + "end": { + "line": 4, + "column": 18 + } + }, + "callee": { + "type": "Identifier", + "start": 67, + "end": 76, + "loc": { + "start": { + "line": 4, + "column": 9 + }, + "end": { + "line": 4, + "column": 18 + }, + "identifierName": "DoubleSay" + }, + "name": "DoubleSay" + } + } + }, + "operator": "|>", + "right": { + "type": "PipelineBareFunction", + "start": 82, + "end": 92, + "loc": { + "start": { + "line": 5, + "column": 5 + }, + "end": { + "line": 5, + "column": 15 + } + }, + "callee": { + "type": "Identifier", + "start": 82, + "end": 92, + "loc": { + "start": { + "line": 5, + "column": 5 + }, + "end": { + "line": 5, + "column": 15 + }, + "identifierName": "capitalize" + }, + "name": "capitalize" + } + } + }, + "operator": "|>", + "right": { + "type": "PipelineBareAwaitedFunction", + "start": 98, + "end": 111, + "loc": { + "start": { + "line": 6, + "column": 5 + }, + "end": { + "line": 6, + "column": 18 + } + }, + "callee": { + "type": "Identifier", + "start": 104, + "end": 111, + "loc": { + "start": { + "line": 6, + "column": 11 + }, + "end": { + "line": 6, + "column": 18 + }, + "identifierName": "exclaim" + }, + "name": "exclaim" + } + } + } + } + ], + "kind": "let" + } + ], + "directives": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-style-mix,-single-line/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-style-mix,-single-line/input.js new file mode 100644 index 000000000000..ed1cd16aad0f --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-style-mix,-single-line/input.js @@ -0,0 +1,3 @@ +async function af () { + x |> inc |> await double |> # + 1 +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-style-mix,-single-line/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-style-mix,-single-line/options.json new file mode 100644 index 000000000000..17e4e327bbad --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-style-mix,-single-line/options.json @@ -0,0 +1,3 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "smart" }]] +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-style-mix,-single-line/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-style-mix,-single-line/output.json new file mode 100644 index 000000000000..2fa260909358 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-style-mix,-single-line/output.json @@ -0,0 +1,298 @@ +{ + "type": "File", + "start": 0, + "end": 60, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 60, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 60, + "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": 60, + "loc": { + "start": { + "line": 1, + "column": 21 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 25, + "end": 58, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 35 + } + }, + "expression": { + "type": "BinaryExpression", + "start": 25, + "end": 58, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 35 + } + }, + "left": { + "type": "BinaryExpression", + "start": 25, + "end": 49, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 26 + } + }, + "left": { + "type": "BinaryExpression", + "start": 25, + "end": 33, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 10 + } + }, + "left": { + "type": "Identifier", + "start": 25, + "end": 26, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 3 + }, + "identifierName": "x" + }, + "name": "x" + }, + "operator": "|>", + "right": { + "type": "PipelineBareFunction", + "start": 30, + "end": 33, + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 2, + "column": 10 + } + }, + "callee": { + "type": "Identifier", + "start": 30, + "end": 33, + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 2, + "column": 10 + }, + "identifierName": "inc" + }, + "name": "inc" + } + } + }, + "operator": "|>", + "right": { + "type": "PipelineBareAwaitedFunction", + "start": 37, + "end": 49, + "loc": { + "start": { + "line": 2, + "column": 14 + }, + "end": { + "line": 2, + "column": 26 + } + }, + "callee": { + "type": "Identifier", + "start": 43, + "end": 49, + "loc": { + "start": { + "line": 2, + "column": 20 + }, + "end": { + "line": 2, + "column": 26 + }, + "identifierName": "double" + }, + "name": "double" + } + } + }, + "operator": "|>", + "right": { + "type": "PipelineTopicExpression", + "start": 53, + "end": 58, + "loc": { + "start": { + "line": 2, + "column": 30 + }, + "end": { + "line": 2, + "column": 35 + } + }, + "expression": { + "type": "BinaryExpression", + "start": 53, + "end": 58, + "loc": { + "start": { + "line": 2, + "column": 30 + }, + "end": { + "line": 2, + "column": 35 + } + }, + "left": { + "type": "PrimaryTopicReference", + "start": 53, + "end": 54, + "loc": { + "start": { + "line": 2, + "column": 30 + }, + "end": { + "line": 2, + "column": 31 + } + } + }, + "operator": "+", + "right": { + "type": "NumericLiteral", + "start": 57, + "end": 58, + "loc": { + "start": { + "line": 2, + "column": 34 + }, + "end": { + "line": 2, + "column": 35 + } + }, + "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-topic-style,-addition,-single-line-arrow-function,-topic-reference-first/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-addition,-single-line-arrow-function,-topic-reference-first/input.js new file mode 100644 index 000000000000..9d3fa9212120 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-addition,-single-line-arrow-function,-topic-reference-first/input.js @@ -0,0 +1 @@ +value |> # + 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/proposal-smart-topic-style,-addition,-single-line-arrow-function,-topic-reference-first/options.json new file mode 100644 index 000000000000..17e4e327bbad --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-addition,-single-line-arrow-function,-topic-reference-first/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,-addition,-single-line-arrow-function,-topic-reference-first/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-addition,-single-line-arrow-function,-topic-reference-first/output.json new file mode 100644 index 000000000000..8f9687369fc5 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-addition,-single-line-arrow-function,-topic-reference-first/output.json @@ -0,0 +1,149 @@ +{ + "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": "PrimaryTopicReference", + "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/proposal-smart-topic-style,-addition,-single-line-arrow-function,-topic-reference-last/input.js new file mode 100644 index 000000000000..64ea7f0bcd1e --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-addition,-single-line-arrow-function,-topic-reference-last/input.js @@ -0,0 +1 @@ +value |> 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/proposal-smart-topic-style,-addition,-single-line-arrow-function,-topic-reference-last/options.json new file mode 100644 index 000000000000..17e4e327bbad --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-addition,-single-line-arrow-function,-topic-reference-last/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,-addition,-single-line-arrow-function,-topic-reference-last/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-addition,-single-line-arrow-function,-topic-reference-last/output.json new file mode 100644 index 000000000000..844200b657a3 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-addition,-single-line-arrow-function,-topic-reference-last/output.json @@ -0,0 +1,149 @@ +{ + "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": "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": "PrimaryTopicReference", + "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-topic-style,-do-expression,-do-while-loop,-outer-topic-reference-in-loop-head/input.js b/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 new file mode 100644 index 000000000000..e5917937bc70 --- /dev/null +++ b/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 @@ -0,0 +1 @@ +value |> do { do x += 1; while (x < #); } 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/proposal-smart-topic-style,-do-expression,-do-while-loop,-outer-topic-reference-in-loop-head/options.json new file mode 100644 index 000000000000..edb7679c6a74 --- /dev/null +++ b/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 @@ -0,0 +1,3 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "smart" }], "doExpressions"] +} 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/proposal-smart-topic-style,-do-expression,-do-while-loop,-outer-topic-reference-in-loop-head/output.json new file mode 100644 index 000000000000..338ed0d21c54 --- /dev/null +++ b/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 @@ -0,0 +1,262 @@ +{ + "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": "PipelineTopicExpression", + "start": 9, + "end": 41, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 41 + } + }, + "expression": { + "type": "DoExpression", + "start": 9, + "end": 41, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 41 + } + }, + "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": "PrimaryTopicReference", + "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-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/proposal-smart-topic-style,-do-expression,-for-await-of-loop,-outer-topic-reference-in-loop-head/input.js new file mode 100644 index 000000000000..197761dcd742 --- /dev/null +++ b/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 @@ -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/proposal-smart-topic-style,-do-expression,-for-await-of-loop,-outer-topic-reference-in-loop-head/options.json new file mode 100644 index 000000000000..791fe8252d11 --- /dev/null +++ b/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 @@ -0,0 +1,3 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "smart" }], "doExpressions", "asyncGenerators"] +} 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/proposal-smart-topic-style,-do-expression,-for-await-of-loop,-outer-topic-reference-in-loop-head/output.json new file mode 100644 index 000000000000..727bcebb1146 --- /dev/null +++ b/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 @@ -0,0 +1,298 @@ +{ + "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": "PipelineTopicExpression", + "start": 34, + "end": 68, + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 45 + } + }, + "expression": { + "type": "DoExpression", + "start": 34, + "end": 68, + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 45 + } + }, + "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": "PrimaryTopicReference", + "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-topic-style,-do-expression,-for-classic-loop,-outer-topic-reference-in-loop-head/input.js b/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 new file mode 100644 index 000000000000..1e14a50cda84 --- /dev/null +++ b/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 @@ -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-topic-style,-do-expression,-for-classic-loop,-outer-topic-reference-in-loop-head/options.json b/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 new file mode 100644 index 000000000000..edb7679c6a74 --- /dev/null +++ b/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 @@ -0,0 +1,3 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "smart" }], "doExpressions"] +} 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/proposal-smart-topic-style,-do-expression,-for-classic-loop,-outer-topic-reference-in-loop-head/output.json new file mode 100644 index 000000000000..39abf98f7e6d --- /dev/null +++ b/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 @@ -0,0 +1,357 @@ +{ + "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": "PipelineTopicExpression", + "start": 9, + "end": 59, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 59 + } + }, + "expression": { + "type": "DoExpression", + "start": 9, + "end": 59, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 59 + } + }, + "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": "PrimaryTopicReference", + "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": "PrimaryTopicReference", + "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": "PrimaryTopicReference", + "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-topic-style,-do-expression,-for-in-loop,-outer-topic-reference-in-loop-head/input.js b/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 new file mode 100644 index 000000000000..096c359535e5 --- /dev/null +++ b/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 @@ -0,0 +1 @@ +value |> do { for (e in #) e; } 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/proposal-smart-topic-style,-do-expression,-for-in-loop,-outer-topic-reference-in-loop-head/options.json new file mode 100644 index 000000000000..edb7679c6a74 --- /dev/null +++ b/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 @@ -0,0 +1,3 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "smart" }], "doExpressions"] +} 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/proposal-smart-topic-style,-do-expression,-for-in-loop,-outer-topic-reference-in-loop-head/output.json new file mode 100644 index 000000000000..eddca7faa4b9 --- /dev/null +++ b/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 @@ -0,0 +1,210 @@ +{ + "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": "PipelineTopicExpression", + "start": 9, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "expression": { + "type": "DoExpression", + "start": 9, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "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": "PrimaryTopicReference", + "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,-for-of-loop,-outer-topic-reference-in-loop-head/input.js b/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 new file mode 100644 index 000000000000..b3e5f40ef7fd --- /dev/null +++ b/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 @@ -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,-for-of-loop,-outer-topic-reference-in-loop-head/options.json b/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 new file mode 100644 index 000000000000..edb7679c6a74 --- /dev/null +++ b/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 @@ -0,0 +1,3 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "smart" }], "doExpressions"] +} 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/proposal-smart-topic-style,-do-expression,-for-of-loop,-outer-topic-reference-in-loop-head/output.json new file mode 100644 index 000000000000..79f6c6b771be --- /dev/null +++ b/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 @@ -0,0 +1,211 @@ +{ + "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": "PipelineTopicExpression", + "start": 9, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "expression": { + "type": "DoExpression", + "start": 9, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "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": "PrimaryTopicReference", + "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,-identity/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-do-expression,-identity/input.js new file mode 100644 index 000000000000..f78ceb724f12 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-do-expression,-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,-identity/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-do-expression,-identity/options.json new file mode 100644 index 000000000000..edb7679c6a74 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-do-expression,-identity/options.json @@ -0,0 +1,3 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "smart" }], "doExpressions"] +} 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/proposal-smart-topic-style,-do-expression,-identity/output.json new file mode 100644 index 000000000000..c1394ed9d8f0 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-do-expression,-identity/output.json @@ -0,0 +1,161 @@ +{ + "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": "PipelineTopicExpression", + "start": 9, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "expression": { + "type": "DoExpression", + "start": 9, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "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": "PrimaryTopicReference", + "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-topic-style,-do-expression,-if-statement,-outer-topic-reference-in-else-body/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-do-expression,-if-statement,-outer-topic-reference-in-else-body/input.js new file mode 100644 index 000000000000..b4c8778046ed --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-do-expression,-if-statement,-outer-topic-reference-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,-if-statement,-outer-topic-reference-in-else-body/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-do-expression,-if-statement,-outer-topic-reference-in-else-body/options.json new file mode 100644 index 000000000000..edb7679c6a74 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-do-expression,-if-statement,-outer-topic-reference-in-else-body/options.json @@ -0,0 +1,3 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "smart" }], "doExpressions"] +} 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/proposal-smart-topic-style,-do-expression,-if-statement,-outer-topic-reference-in-else-body/output.json new file mode 100644 index 000000000000..7900de3f1399 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-do-expression,-if-statement,-outer-topic-reference-in-else-body/output.json @@ -0,0 +1,256 @@ +{ + "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": "PipelineTopicExpression", + "start": 9, + "end": 46, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 46 + } + }, + "expression": { + "type": "DoExpression", + "start": 9, + "end": 46, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 46 + } + }, + "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": "PrimaryTopicReference", + "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/proposal-smart-topic-style,-do-expression,-if-statement,-outer-topic-reference-in-else-if-body/input.js new file mode 100644 index 000000000000..0b1fd66aaa3c --- /dev/null +++ b/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 @@ -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,-if-statement,-outer-topic-reference-in-else-if-body/options.json b/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 new file mode 100644 index 000000000000..edb7679c6a74 --- /dev/null +++ b/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 @@ -0,0 +1,3 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "smart" }], "doExpressions"] +} 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/proposal-smart-topic-style,-do-expression,-if-statement,-outer-topic-reference-in-else-if-body/output.json new file mode 100644 index 000000000000..4bd2a955d177 --- /dev/null +++ b/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 @@ -0,0 +1,223 @@ +{ + "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": "PipelineTopicExpression", + "start": 9, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 38 + } + }, + "expression": { + "type": "DoExpression", + "start": 9, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 38 + } + }, + "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": "PrimaryTopicReference", + "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/proposal-smart-topic-style,-do-expression,-if-statement,-outer-topic-reference-in-if-body/input.js new file mode 100644 index 000000000000..bd64bfb5b763 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-do-expression,-if-statement,-outer-topic-reference-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,-if-statement,-outer-topic-reference-in-if-body/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-do-expression,-if-statement,-outer-topic-reference-in-if-body/options.json new file mode 100644 index 000000000000..edb7679c6a74 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-do-expression,-if-statement,-outer-topic-reference-in-if-body/options.json @@ -0,0 +1,3 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "smart" }], "doExpressions"] +} 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/proposal-smart-topic-style,-do-expression,-if-statement,-outer-topic-reference-in-if-body/output.json new file mode 100644 index 000000000000..11c2656ea035 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-do-expression,-if-statement,-outer-topic-reference-in-if-body/output.json @@ -0,0 +1,194 @@ +{ + "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": "PipelineTopicExpression", + "start": 9, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 27 + } + }, + "expression": { + "type": "DoExpression", + "start": 9, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 27 + } + }, + "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": "PrimaryTopicReference", + "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/proposal-smart-topic-style,-do-expression,-if-statement,-outer-topic-reference-in-if-head/input.js new file mode 100644 index 000000000000..8457c4e57f71 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-do-expression,-if-statement,-outer-topic-reference-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,-if-statement,-outer-topic-reference-in-if-head/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-do-expression,-if-statement,-outer-topic-reference-in-if-head/options.json new file mode 100644 index 000000000000..edb7679c6a74 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-do-expression,-if-statement,-outer-topic-reference-in-if-head/options.json @@ -0,0 +1,3 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "smart" }], "doExpressions"] +} 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/proposal-smart-topic-style,-do-expression,-if-statement,-outer-topic-reference-in-if-head/output.json new file mode 100644 index 000000000000..48d8f663f2cb --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-do-expression,-if-statement,-outer-topic-reference-in-if-head/output.json @@ -0,0 +1,231 @@ +{ + "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": "PipelineTopicExpression", + "start": 9, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 33 + } + }, + "expression": { + "type": "DoExpression", + "start": 9, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 33 + } + }, + "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": "PrimaryTopicReference", + "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/proposal-smart-topic-style,-do-expression,-switch-statement,-outer-topic-reference-in-switch-body/input.js new file mode 100644 index 000000000000..c9562d43181c --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-do-expression,-switch-statement,-outer-topic-reference-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,-switch-statement,-outer-topic-reference-in-switch-body/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-do-expression,-switch-statement,-outer-topic-reference-in-switch-body/options.json new file mode 100644 index 000000000000..edb7679c6a74 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-do-expression,-switch-statement,-outer-topic-reference-in-switch-body/options.json @@ -0,0 +1,3 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "smart" }], "doExpressions"] +} 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/proposal-smart-topic-style,-do-expression,-switch-statement,-outer-topic-reference-in-switch-body/output.json new file mode 100644 index 000000000000..f4e627647b9e --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-do-expression,-switch-statement,-outer-topic-reference-in-switch-body/output.json @@ -0,0 +1,419 @@ +{ + "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": "PipelineTopicExpression", + "start": 9, + "end": 94, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 7, + "column": 1 + } + }, + "expression": { + "type": "DoExpression", + "start": 9, + "end": 94, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 7, + "column": 1 + } + }, + "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": "PrimaryTopicReference", + "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": "PrimaryTopicReference", + "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": "PrimaryTopicReference", + "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/proposal-smart-topic-style,-do-expression,-switch-statement,-outer-topic-reference-in-switch-head/input.js new file mode 100644 index 000000000000..77e4a2ddcf2f --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-do-expression,-switch-statement,-outer-topic-reference-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,-switch-statement,-outer-topic-reference-in-switch-head/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-do-expression,-switch-statement,-outer-topic-reference-in-switch-head/options.json new file mode 100644 index 000000000000..edb7679c6a74 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-do-expression,-switch-statement,-outer-topic-reference-in-switch-head/options.json @@ -0,0 +1,3 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "smart" }], "doExpressions"] +} 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/proposal-smart-topic-style,-do-expression,-switch-statement,-outer-topic-reference-in-switch-head/output.json new file mode 100644 index 000000000000..c7c865a8e291 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-do-expression,-switch-statement,-outer-topic-reference-in-switch-head/output.json @@ -0,0 +1,360 @@ +{ + "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": "PipelineTopicExpression", + "start": 9, + "end": 83, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 7, + "column": 1 + } + }, + "expression": { + "type": "DoExpression", + "start": 9, + "end": 83, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 7, + "column": 1 + } + }, + "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": "PrimaryTopicReference", + "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,-try-statement,-outer-topic-reference-in-finally-clause-with-catch-and-finally/input.js b/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 new file mode 100644 index 000000000000..46ec28c2e777 --- /dev/null +++ b/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 @@ -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,-try-statement,-outer-topic-reference-in-finally-clause-with-catch-and-finally/options.json b/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 new file mode 100644 index 000000000000..edb7679c6a74 --- /dev/null +++ b/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 @@ -0,0 +1,3 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "smart" }], "doExpressions"] +} 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/proposal-smart-topic-style,-do-expression,-try-statement,-outer-topic-reference-in-finally-clause-with-catch-and-finally/output.json new file mode 100644 index 000000000000..07af94d070ab --- /dev/null +++ b/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 @@ -0,0 +1,495 @@ +{ + "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": "PipelineTopicExpression", + "start": 9, + "end": 117, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 5, + "column": 1 + } + }, + "expression": { + "type": "DoExpression", + "start": 9, + "end": 117, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 5, + "column": 1 + } + }, + "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" + }, + "property": { + "type": "Identifier", + "start": 27, + "end": 32, + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 18 + }, + "identifierName": "parse" + }, + "name": "parse" + }, + "computed": false + }, + "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" + }, + "property": { + "type": "Identifier", + "start": 72, + "end": 77, + "loc": { + "start": { + "line": 3, + "column": 26 + }, + "end": { + "line": 3, + "column": 31 + }, + "identifierName": "error" + }, + "name": "error" + }, + "computed": false + }, + "arguments": [ + { + "type": "Identifier", + "start": 78, + "end": 83, + "loc": { + "start": { + "line": 3, + "column": 32 + }, + "end": { + "line": 3, + "column": 37 + }, + "identifierName": "error" + }, + "name": "error" + } + ] + } + } + ], + "directives": [] + } + }, + "guardedHandlers": [], + "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": "PrimaryTopicReference", + "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/proposal-smart-topic-style,-do-expression,-try-statement,-outer-topic-reference-in-try-clause-with-catch-and-finally/input.js new file mode 100644 index 000000000000..dd034b608161 --- /dev/null +++ b/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 @@ -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,-try-statement,-outer-topic-reference-in-try-clause-with-catch-and-finally/options.json b/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 new file mode 100644 index 000000000000..edb7679c6a74 --- /dev/null +++ b/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 @@ -0,0 +1,3 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "smart" }], "doExpressions"] +} 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/proposal-smart-topic-style,-do-expression,-try-statement,-outer-topic-reference-in-try-clause-with-catch-and-finally/output.json new file mode 100644 index 000000000000..c9b09e909864 --- /dev/null +++ b/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 @@ -0,0 +1,477 @@ +{ + "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": "PipelineTopicExpression", + "start": 9, + "end": 109, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 5, + "column": 1 + } + }, + "expression": { + "type": "DoExpression", + "start": 9, + "end": 109, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 5, + "column": 1 + } + }, + "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" + }, + "property": { + "type": "Identifier", + "start": 27, + "end": 32, + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 18 + }, + "identifierName": "parse" + }, + "name": "parse" + }, + "computed": false + }, + "arguments": [ + { + "type": "PrimaryTopicReference", + "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" + }, + "property": { + "type": "Identifier", + "start": 65, + "end": 70, + "loc": { + "start": { + "line": 3, + "column": 26 + }, + "end": { + "line": 3, + "column": 31 + }, + "identifierName": "error" + }, + "name": "error" + }, + "computed": false + }, + "arguments": [ + { + "type": "Identifier", + "start": 71, + "end": 76, + "loc": { + "start": { + "line": 3, + "column": 32 + }, + "end": { + "line": 3, + "column": 37 + }, + "identifierName": "error" + }, + "name": "error" + } + ] + } + } + ], + "directives": [] + } + }, + "guardedHandlers": [], + "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/proposal-smart-topic-style,-do-expression,-try-statement,-outer-topic-reference-in-try-clause-with-catch/input.js new file mode 100644 index 000000000000..70eb5263f217 --- /dev/null +++ b/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 @@ -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-try-clause-with-catch/options.json b/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 new file mode 100644 index 000000000000..edb7679c6a74 --- /dev/null +++ b/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 @@ -0,0 +1,3 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "smart" }], "doExpressions"] +} 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/proposal-smart-topic-style,-do-expression,-try-statement,-outer-topic-reference-in-try-clause-with-catch/output.json new file mode 100644 index 000000000000..976398843dd9 --- /dev/null +++ b/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 @@ -0,0 +1,412 @@ +{ + "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": "PipelineTopicExpression", + "start": 9, + "end": 82, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "expression": { + "type": "DoExpression", + "start": 9, + "end": 82, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "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" + }, + "property": { + "type": "Identifier", + "start": 27, + "end": 32, + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 18 + }, + "identifierName": "parse" + }, + "name": "parse" + }, + "computed": false + }, + "arguments": [ + { + "type": "PrimaryTopicReference", + "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" + }, + "property": { + "type": "Identifier", + "start": 65, + "end": 70, + "loc": { + "start": { + "line": 3, + "column": 26 + }, + "end": { + "line": 3, + "column": 31 + }, + "identifierName": "error" + }, + "name": "error" + }, + "computed": false + }, + "arguments": [ + { + "type": "Identifier", + "start": 71, + "end": 76, + "loc": { + "start": { + "line": 3, + "column": 32 + }, + "end": { + "line": 3, + "column": 37 + }, + "identifierName": "error" + }, + "name": "error" + } + ] + } + } + ], + "directives": [] + } + }, + "guardedHandlers": [], + "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,-while-loop,-outer-topic-reference-in-loop-head/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-do-expression,-while-loop,-outer-topic-reference-in-loop-head/input.js new file mode 100644 index 000000000000..be802107159e --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-do-expression,-while-loop,-outer-topic-reference-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,-while-loop,-outer-topic-reference-in-loop-head/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-do-expression,-while-loop,-outer-topic-reference-in-loop-head/options.json new file mode 100644 index 000000000000..edb7679c6a74 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-do-expression,-while-loop,-outer-topic-reference-in-loop-head/options.json @@ -0,0 +1,3 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "smart" }], "doExpressions"] +} 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/proposal-smart-topic-style,-do-expression,-while-loop,-outer-topic-reference-in-loop-head/output.json new file mode 100644 index 000000000000..6c5dbb28a304 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-do-expression,-while-loop,-outer-topic-reference-in-loop-head/output.json @@ -0,0 +1,262 @@ +{ + "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": "PipelineTopicExpression", + "start": 9, + "end": 37, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 37 + } + }, + "expression": { + "type": "DoExpression", + "start": 9, + "end": 37, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 37 + } + }, + "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": "PrimaryTopicReference", + "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-topic-style,-function-call,-identifier-with-topic-reference/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-function-call,-identifier-with-topic-reference/input.js new file mode 100644 index 000000000000..e8678f6a2bb1 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-function-call,-identifier-with-topic-reference/input.js @@ -0,0 +1 @@ +value |> f(#) 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/proposal-smart-topic-style,-function-call,-identifier-with-topic-reference/options.json new file mode 100644 index 000000000000..17e4e327bbad --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-function-call,-identifier-with-topic-reference/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,-function-call,-identifier-with-topic-reference/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-function-call,-identifier-with-topic-reference/output.json new file mode 100644 index 000000000000..3c4b198f1d9c --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-function-call,-identifier-with-topic-reference/output.json @@ -0,0 +1,147 @@ +{ + "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": "PipelineTopicExpression", + "start": 9, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "expression": { + "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": "PrimaryTopicReference", + "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-topic-style,-function-definition,-outer-topic-reference-in-default-parameter-expression/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-function-definition,-outer-topic-reference-in-default-parameter-expression/input.js new file mode 100644 index 000000000000..432d1c9ed8c7 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-function-definition,-outer-topic-reference-in-default-parameter-expression/input.js @@ -0,0 +1 @@ +value |> function (x = #) { return x; } 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/proposal-smart-topic-style,-function-definition,-outer-topic-reference-in-default-parameter-expression/options.json new file mode 100644 index 000000000000..17e4e327bbad --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-function-definition,-outer-topic-reference-in-default-parameter-expression/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,-function-definition,-outer-topic-reference-in-default-parameter-expression/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-function-definition,-outer-topic-reference-in-default-parameter-expression/output.json new file mode 100644 index 000000000000..6aea657b9d0c --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-function-definition,-outer-topic-reference-in-default-parameter-expression/output.json @@ -0,0 +1,215 @@ +{ + "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": "PipelineTopicExpression", + "start": 9, + "end": 39, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 39 + } + }, + "expression": { + "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": "PrimaryTopicReference", + "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-topic-style,-identity,-parenthesized/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-identity,-parenthesized/input.js new file mode 100644 index 000000000000..a7abc2dc18f7 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-identity,-parenthesized/input.js @@ -0,0 +1 @@ +value |> (#) 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/proposal-smart-topic-style,-identity,-parenthesized/options.json new file mode 100644 index 000000000000..17e4e327bbad --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-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/proposal-smart-topic-style,-identity,-parenthesized/output.json new file mode 100644 index 000000000000..e3c00951e0ca --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-identity,-parenthesized/output.json @@ -0,0 +1,117 @@ +{ + "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": "PipelineTopicExpression", + "start": 9, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "expression": { + "type": "PrimaryTopicReference", + "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,-identity,-unparenthesized/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-identity,-unparenthesized/input.js new file mode 100644 index 000000000000..a18cbd0f1bb2 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-identity,-unparenthesized/input.js @@ -0,0 +1 @@ +value |> # 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/proposal-smart-topic-style,-identity,-unparenthesized/options.json new file mode 100644 index 000000000000..17e4e327bbad --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-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/proposal-smart-topic-style,-identity,-unparenthesized/output.json new file mode 100644 index 000000000000..24779f851b61 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-identity,-unparenthesized/output.json @@ -0,0 +1,113 @@ +{ + "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": "PipelineTopicExpression", + "start": 9, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "expression": { + "type": "PrimaryTopicReference", + "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/proposal-smart-topic-style,-mixed-pipeline-plugins/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-mixed-pipeline-plugins/input.js new file mode 100644 index 000000000000..a18cbd0f1bb2 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-mixed-pipeline-plugins/input.js @@ -0,0 +1 @@ +value |> # 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 new file mode 100644 index 000000000000..887155e27e68 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-mixed-pipeline-plugins/options.json @@ -0,0 +1,3 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "smart" }], "pipelineOperator"] +} 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/proposal-smart-topic-style,-mixed-pipeline-plugins/output.json new file mode 100644 index 000000000000..24779f851b61 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-mixed-pipeline-plugins/output.json @@ -0,0 +1,113 @@ +{ + "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": "PipelineTopicExpression", + "start": 9, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "expression": { + "type": "PrimaryTopicReference", + "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/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/proposal-smart-topic-style,-parenthesized-single-line-arrow-function,-with-empty-parameter-list-and-bare-addition-body/input.js new file mode 100644 index 000000000000..7f3f814efd71 --- /dev/null +++ b/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 @@ -0,0 +1 @@ +value |> (() => # + 1) 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/proposal-smart-topic-style,-parenthesized-single-line-arrow-function,-with-empty-parameter-list-and-bare-addition-body/options.json new file mode 100644 index 000000000000..17e4e327bbad --- /dev/null +++ b/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 @@ -0,0 +1,3 @@ +{ + "plugins": [["pipelineOperator", { "proposal": "smart" }]] +} 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/proposal-smart-topic-style,-parenthesized-single-line-arrow-function,-with-empty-parameter-list-and-bare-addition-body/output.json new file mode 100644 index 000000000000..6d82768d86bc --- /dev/null +++ b/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 @@ -0,0 +1,172 @@ +{ + "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": "PipelineTopicExpression", + "start": 9, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "expression": { + "type": "ArrowFunctionExpression", + "start": 10, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "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": "PrimaryTopicReference", + "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 + } + }, + "extra": { + "parenthesized": true, + "parenStart": 9 + } + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/with-arrow-parend-params/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/with-arrow-parend-params/options.json deleted file mode 100644 index 599d48a46961..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/with-arrow-parend-params/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "plugins": ["pipelineOperator"] -} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/with-arrow/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/with-arrow/options.json deleted file mode 100644 index 599d48a46961..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/with-arrow/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "plugins": ["pipelineOperator"] -}