From fbf62b4830b35af2c906e092e91635a33d919fad 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 01/26] Implement Smart Pipeline proposal in @babel/parser --- .../babel-parser/src/parser/expression.js | 298 ++++++++++- packages/babel-parser/src/parser/statement.js | 156 ++++-- packages/babel-parser/src/plugin-utils.js | 2 +- 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 + .../invalid-proposal/options.json | 2 +- .../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 ++++++ 184 files changed, 11221 insertions(+), 76 deletions(-) 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 diff --git a/packages/babel-parser/src/parser/expression.js b/packages/babel-parser/src/parser/expression.js index ab51bd0c90c1..ca2e6d8c2ffe 100644 --- a/packages/babel-parser/src/parser/expression.js +++ b/packages/babel-parser/src/parser/expression.js @@ -296,18 +296,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 +321,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 +331,7 @@ export default class ExpressionParser extends LValParser { ? "LogicalExpression" : "BinaryExpression", ); + return this.parseExprOp( node, leftStartPos, @@ -348,6 +344,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 +931,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(); } @@ -1920,4 +1988,206 @@ 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 ("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, + ): void { + 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/plugin-utils.js b/packages/babel-parser/src/plugin-utils.js index 69cc39f7acb2..000507c8d715 100644 --- a/packages/babel-parser/src/plugin-utils.js +++ b/packages/babel-parser/src/plugin-utils.js @@ -38,7 +38,7 @@ export function getPluginOption( return null; } -const PIPELINE_PROPOSALS = ["minimal"]; +const PIPELINE_PROPOSALS = ["minimal", "smart"]; export function validatePlugins(plugins: PluginList) { if ( 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/pipeline-operator/invalid-proposal/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/invalid-proposal/options.json index 188385c5ab0d..1697b4bdb73b 100644 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/invalid-proposal/options.json +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/invalid-proposal/options.json @@ -2,5 +2,5 @@ "plugins": [ ["pipelineOperator", { "proposal": "invalid" }] ], - "throws": "'pipelineOperator' requires 'proposal' option whose value should be one of: minimal" + "throws": "'pipelineOperator' requires 'proposal' option whose value should be one of: minimal, smart" } 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 From ef0f723fc53285ef87699f7a74999055e8e1ff45 Mon Sep 17 00:00:00 2001 From: James DiGioia Date: Thu, 12 Jul 2018 22:46:34 -0400 Subject: [PATCH 02/26] Reverse yoda conditions If "smart" proposal is, we'll no longer say. --- packages/babel-parser/src/parser/expression.js | 6 +++--- packages/babel-parser/src/tokenizer/index.js | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/babel-parser/src/parser/expression.js b/packages/babel-parser/src/parser/expression.js index ca2e6d8c2ffe..33cc0b8eabd6 100644 --- a/packages/babel-parser/src/parser/expression.js +++ b/packages/babel-parser/src/parser/expression.js @@ -307,7 +307,7 @@ export default class ExpressionParser extends LValParser { if ( op === tt.pipeline && - "minimal" === this.getPluginOption("pipelineOperator", "proposal") + this.getPluginOption("pipelineOperator", "proposal") === "minimal" ) { if ( this.match(tt.name) && @@ -354,7 +354,7 @@ export default class ExpressionParser extends LValParser { ): N.Expression { switch (op) { case tt.pipeline: - if ("smart" === this.getPluginOption("pipelineOperator", "proposal")) { + if (this.getPluginOption("pipelineOperator", "proposal") === "smart") { const startPos = this.state.start; const startLoc = this.state.startLoc; return this.withTopicPermittingContext(() => { @@ -1995,7 +1995,7 @@ export default class ExpressionParser extends LValParser { checkPipelineAtInfixOperator(left: N.Expression, leftStartPos: number) { this.expectPlugin("pipelineOperator"); - if ("smart" === this.getPluginOption("pipelineOperator", "proposal")) { + if (this.getPluginOption("pipelineOperator", "proposal") === "smart") { this.checkSmartPipelineHeadEarlyErrors(left, leftStartPos); } } diff --git a/packages/babel-parser/src/tokenizer/index.js b/packages/babel-parser/src/tokenizer/index.js index 658760c32e61..6464167ef849 100644 --- a/packages/babel-parser/src/tokenizer/index.js +++ b/packages/babel-parser/src/tokenizer/index.js @@ -421,7 +421,7 @@ export default class Tokenizer extends LocationParser { this.finishToken(tt.hash); return; } else if ( - "smart" === this.getPluginOption("pipelineOperator", "proposal") + this.getPluginOption("pipelineOperator", "proposal") === "smart" ) { if (next >= charCodes.digit0 && next <= charCodes.digit9) { this.raise( From b50fdc191e745169666286a4bf8cc6b074e31424 Mon Sep 17 00:00:00 2001 From: James DiGioia Date: Thu, 12 Jul 2018 22:47:45 -0400 Subject: [PATCH 03/26] Inline function checkSmartPipelineHeadEarlyErrors It's only used once. --- .../babel-parser/src/parser/expression.js | 20 ++++++++----------- 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/packages/babel-parser/src/parser/expression.js b/packages/babel-parser/src/parser/expression.js index 33cc0b8eabd6..e26f77f1ab78 100644 --- a/packages/babel-parser/src/parser/expression.js +++ b/packages/babel-parser/src/parser/expression.js @@ -1996,18 +1996,14 @@ export default class ExpressionParser extends LValParser { this.expectPlugin("pipelineOperator"); if (this.getPluginOption("pipelineOperator", "proposal") === "smart") { - 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`, - ); + 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`, + ); + } } } From 00845709ce28c931603e93463fd14bb1162c0705 Mon Sep 17 00:00:00 2001 From: James DiGioia Date: Thu, 12 Jul 2018 22:48:53 -0400 Subject: [PATCH 04/26] Add comment for number sign --- packages/babel-parser/src/tokenizer/index.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/babel-parser/src/tokenizer/index.js b/packages/babel-parser/src/tokenizer/index.js index 6464167ef849..f0cfb9e12ba3 100644 --- a/packages/babel-parser/src/tokenizer/index.js +++ b/packages/babel-parser/src/tokenizer/index.js @@ -403,7 +403,8 @@ export default class Tokenizer extends LocationParser { // into it. // // All in the name of speed. - // + + // number sign is "#" readToken_numberSign(code: number): void { if (this.state.pos === 0 && this.readToken_interpreter()) { return; From 718882015143b990c109b310e24ab2f87a66b48d Mon Sep 17 00:00:00 2001 From: James DiGioia Date: Thu, 12 Jul 2018 22:55:01 -0400 Subject: [PATCH 05/26] Delete commented code --- packages/babel-parser/src/tokenizer/index.js | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/babel-parser/src/tokenizer/index.js b/packages/babel-parser/src/tokenizer/index.js index f0cfb9e12ba3..67346a8bce6b 100644 --- a/packages/babel-parser/src/tokenizer/index.js +++ b/packages/babel-parser/src/tokenizer/index.js @@ -412,7 +412,6 @@ export default class Tokenizer extends LocationParser { const nextPos = this.state.pos + 1; const next = this.input.charCodeAt(nextPos); - // if (isIdentifierStart(next)) { if ( (this.hasPlugin("classPrivateProperties") || this.hasPlugin("classPrivateMethods")) && From cc526940eec42616991b21baba9fee553b639232 Mon Sep 17 00:00:00 2001 From: James DiGioia Date: Thu, 12 Jul 2018 23:07:09 -0400 Subject: [PATCH 06/26] Quote proposals in error message --- packages/babel-parser/src/plugin-utils.js | 2 +- .../pipeline-operator/invalid-proposal/options.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/babel-parser/src/plugin-utils.js b/packages/babel-parser/src/plugin-utils.js index 000507c8d715..d8ed23d86df9 100644 --- a/packages/babel-parser/src/plugin-utils.js +++ b/packages/babel-parser/src/plugin-utils.js @@ -62,7 +62,7 @@ export function validatePlugins(plugins: PluginList) { ) { throw new Error( "'pipelineOperator' requires 'proposal' option whose value should be one of: " + - PIPELINE_PROPOSALS.join(", "), + PIPELINE_PROPOSALS.map(p => `'${p}'`).join(", "), ); } } diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/invalid-proposal/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/invalid-proposal/options.json index 1697b4bdb73b..109111d73a1a 100644 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/invalid-proposal/options.json +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/invalid-proposal/options.json @@ -2,5 +2,5 @@ "plugins": [ ["pipelineOperator", { "proposal": "invalid" }] ], - "throws": "'pipelineOperator' requires 'proposal' option whose value should be one of: minimal, smart" + "throws": "'pipelineOperator' requires 'proposal' option whose value should be one of: 'minimal', 'smart'" } From e91a02cc49f80423ee7c931e7711c49c04540f6b Mon Sep 17 00:00:00 2001 From: James DiGioia Date: Thu, 12 Jul 2018 23:08:11 -0400 Subject: [PATCH 07/26] Reuse declared type in function return value --- packages/babel-parser/src/parser/expression.js | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/packages/babel-parser/src/parser/expression.js b/packages/babel-parser/src/parser/expression.js index e26f77f1ab78..285787f12bbf 100644 --- a/packages/babel-parser/src/parser/expression.js +++ b/packages/babel-parser/src/parser/expression.js @@ -2083,13 +2083,7 @@ export default class ExpressionParser extends LValParser { return this.finishNode(bodyNode, pipelineStyle); } - checkSmartPipelineBodyStyle( - expression: N.Expression, - ): - | "PipelineBareFunction" - | "PipelineBareConstructor" - | "PipelineBareAwaitedFunction" - | "PipelineTopicExpression" { + checkSmartPipelineBodyStyle(expression: N.Expression): PipelineStyle { switch (expression.type) { case "NewExpression": return this.isSimpleReference(expression.callee) From b847d40842ebbdcdfc0c206f943d9af0740eea64 Mon Sep 17 00:00:00 2001 From: James DiGioia Date: Thu, 12 Jul 2018 23:10:07 -0400 Subject: [PATCH 08/26] Inline readTopicContextState method --- packages/babel-parser/src/parser/expression.js | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/packages/babel-parser/src/parser/expression.js b/packages/babel-parser/src/parser/expression.js index 285787f12bbf..49cd37faf36c 100644 --- a/packages/babel-parser/src/parser/expression.js +++ b/packages/babel-parser/src/parser/expression.js @@ -2118,7 +2118,7 @@ export default class ExpressionParser extends LValParser { // had before the function was called. withTopicPermittingContext(callback: () => T): T { - const outerContextTopicState = this.readTopicContextState(); + const outerContextTopicState = this.state.topicContextState; this.state.topicContextState = { // Enable the use of the primary topic reference. maxNumOfResolvableTopics: 1, @@ -2140,7 +2140,7 @@ export default class ExpressionParser extends LValParser { // had before the function was called. withTopicForbiddingContext(callback: () => T): T { - const outerContextTopicState = this.readTopicContextState(); + const outerContextTopicState = this.state.topicContextState; this.state.topicContextState = { // Disable the use of the primary topic reference. maxNumOfResolvableTopics: 0, @@ -2154,10 +2154,6 @@ export default class ExpressionParser extends LValParser { return callbackResult; } - readTopicContextState(): tt.TopicContextState { - return this.state.topicContextState; - } - // Register the use of a primary topic reference (`#`) within the current // topic context. registerTopicReference(): void { From 7931f4c241fbde60b38ba589f879f42dc83d9543 Mon Sep 17 00:00:00 2001 From: James DiGioia Date: Thu, 12 Jul 2018 23:11:55 -0400 Subject: [PATCH 09/26] Rename topicContextState -> .topicContext --- .../babel-parser/src/parser/expression.js | 20 +++++++++---------- packages/babel-parser/src/tokenizer/state.js | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/packages/babel-parser/src/parser/expression.js b/packages/babel-parser/src/parser/expression.js index 49cd37faf36c..c71b952ad1c3 100644 --- a/packages/babel-parser/src/parser/expression.js +++ b/packages/babel-parser/src/parser/expression.js @@ -2118,8 +2118,8 @@ export default class ExpressionParser extends LValParser { // had before the function was called. withTopicPermittingContext(callback: () => T): T { - const outerContextTopicState = this.state.topicContextState; - this.state.topicContextState = { + const outerContextTopicState = this.state.topicContext; + this.state.topicContext = { // Enable the use of the primary topic reference. maxNumOfResolvableTopics: 1, // Hide the use of any topic references from outer contexts. @@ -2128,7 +2128,7 @@ export default class ExpressionParser extends LValParser { const callbackResult = callback(); - this.state.topicContextState = outerContextTopicState; + this.state.topicContext = outerContextTopicState; return callbackResult; } @@ -2140,8 +2140,8 @@ export default class ExpressionParser extends LValParser { // had before the function was called. withTopicForbiddingContext(callback: () => T): T { - const outerContextTopicState = this.state.topicContextState; - this.state.topicContextState = { + const outerContextTopicState = this.state.topicContext; + this.state.topicContext = { // Disable the use of the primary topic reference. maxNumOfResolvableTopics: 0, // Hide the use of any topic references from outer contexts. @@ -2150,24 +2150,24 @@ export default class ExpressionParser extends LValParser { const callbackResult = callback(); - this.state.topicContextState = outerContextTopicState; + this.state.topicContext = outerContextTopicState; return callbackResult; } // Register the use of a primary topic reference (`#`) within the current // topic context. registerTopicReference(): void { - this.state.topicContextState.maxTopicIndex = 0; + this.state.topicContext.maxTopicIndex = 0; } primaryTopicReferenceIsAllowedInCurrentTopicContext(): boolean { - return this.state.topicContextState.maxNumOfResolvableTopics >= 1; + return this.state.topicContext.maxNumOfResolvableTopics >= 1; } topicReferenceWasUsedInCurrentTopicContext(): boolean { return ( - this.state.topicContextState.maxTopicIndex != null && - this.state.topicContextState.maxTopicIndex >= 0 + this.state.topicContext.maxTopicIndex != null && + this.state.topicContext.maxTopicIndex >= 0 ); } } diff --git a/packages/babel-parser/src/tokenizer/state.js b/packages/babel-parser/src/tokenizer/state.js index 536d81592434..c520f4388322 100644 --- a/packages/babel-parser/src/tokenizer/state.js +++ b/packages/babel-parser/src/tokenizer/state.js @@ -34,7 +34,7 @@ export default class State { this.isIterator = false; // Used by smartPipelines. - this.topicContextState = { + this.topicContext = { maxNumOfResolvableTopics: 0, maxTopicIndex: undefined, }; From 6e41edb90f1b831d474fa53cae14dbd6f194c33f Mon Sep 17 00:00:00 2001 From: James DiGioia Date: Sun, 22 Jul 2018 17:58:51 -0400 Subject: [PATCH 10/26] Fix TopicContextState type in Flow --- packages/babel-parser/src/tokenizer/state.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/babel-parser/src/tokenizer/state.js b/packages/babel-parser/src/tokenizer/state.js index c520f4388322..936d3a5dc2e2 100644 --- a/packages/babel-parser/src/tokenizer/state.js +++ b/packages/babel-parser/src/tokenizer/state.js @@ -6,7 +6,7 @@ import { Position } from "../util/location"; import { types as ct, type TokContext } from "./context"; import type { Token } from "./index"; -import { types as tt, type TokenType } from "./types"; +import { types as tt, type TokenType, type TopicContextState } from "./types"; export default class State { init(options: Options, input: string): void { @@ -36,7 +36,7 @@ export default class State { // Used by smartPipelines. this.topicContext = { maxNumOfResolvableTopics: 0, - maxTopicIndex: undefined, + maxTopicIndex: null, }; this.classLevel = 0; @@ -118,7 +118,7 @@ export default class State { isIterator: boolean; // For the smartPipelines plugin: - topicContextState: tt.TopicContextState; + topicContext: TopicContextState; // Check whether we are in a (nested) class or not. classLevel: number; From afd0638b741602635adcc244aad6668b5e8a7526 Mon Sep 17 00:00:00 2001 From: James DiGioia Date: Sun, 22 Jul 2018 18:46:31 -0400 Subject: [PATCH 11/26] Reuse hash token instead of new primaryTopicToken Set whether we're in a pipeline in order to determine how to parse the hash. The error message changes as a result, since the `hash` never enters the block. --- .../babel-parser/src/parser/expression.js | 41 +++++++++++-------- packages/babel-parser/src/tokenizer/index.js | 2 +- packages/babel-parser/src/tokenizer/state.js | 2 + packages/babel-parser/src/tokenizer/types.js | 1 - .../options.json | 2 +- 5 files changed, 27 insertions(+), 21 deletions(-) diff --git a/packages/babel-parser/src/parser/expression.js b/packages/babel-parser/src/parser/expression.js index c71b952ad1c3..b04e26bac37c 100644 --- a/packages/babel-parser/src/parser/expression.js +++ b/packages/babel-parser/src/parser/expression.js @@ -298,6 +298,7 @@ export default class ExpressionParser extends LValParser { const op = this.state.type; if (op === tt.pipeline) { + this.state.inPipeline = true; this.checkPipelineAtInfixOperator(left, leftStartPos); } else if (op === tt.nullishCoalescing) { this.expectPlugin("nullishCoalescingOperator"); @@ -931,26 +932,30 @@ export default class ExpressionParser extends LValParser { } } - case tt.primaryTopicReference: { - this.expectPlugin("pipelineOperator"); - node = this.startNode(); + case tt.hash: { + if (this.state.inPipeline) { + 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.", - ); - } + 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`, - ); + 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`, + ); + } } } diff --git a/packages/babel-parser/src/tokenizer/index.js b/packages/babel-parser/src/tokenizer/index.js index 67346a8bce6b..69a845b52533 100644 --- a/packages/babel-parser/src/tokenizer/index.js +++ b/packages/babel-parser/src/tokenizer/index.js @@ -431,7 +431,7 @@ export default class Tokenizer extends LocationParser { )}'`, ); } else { - this.finishOp(tt.primaryTopicReference, 1); + this.finishOp(tt.hash, 1); } } else { this.raise( diff --git a/packages/babel-parser/src/tokenizer/state.js b/packages/babel-parser/src/tokenizer/state.js index 936d3a5dc2e2..1c71ada99def 100644 --- a/packages/babel-parser/src/tokenizer/state.js +++ b/packages/babel-parser/src/tokenizer/state.js @@ -26,6 +26,7 @@ export default class State { this.maybeInArrowParameters = false; this.inGenerator = false; this.inAsync = false; + this.inPipeline = false; this.inPropertyName = false; this.inType = false; this.inClassProperty = false; @@ -110,6 +111,7 @@ export default class State { inGenerator: boolean; inMethod: boolean | N.MethodKind; inAsync: boolean; + inPipeline: boolean; inType: boolean; noAnonFunctionType: boolean; inPropertyName: boolean; diff --git a/packages/babel-parser/src/tokenizer/types.js b/packages/babel-parser/src/tokenizer/types.js index 1142a47f2446..3c401f163f87 100644 --- a/packages/babel-parser/src/tokenizer/types.js +++ b/packages/babel-parser/src/tokenizer/types.js @@ -86,7 +86,6 @@ 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. 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 index 79a8e0a3852e..736cde0e101d 100644 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-unbound-topic,-simple/options.json +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-unbound-topic,-simple/options.json @@ -1,4 +1,4 @@ { "plugins": [["pipelineOperator", { "proposal": "smart" }]], - "throws": "Topic reference was used in a lexical context without topic binding (1:4)" + "throws": "Unexpected token (1:4)" } From 094ef31c01f7f65a3f44d608a87671fa90eff199 Mon Sep 17 00:00:00 2001 From: James DiGioia Date: Sun, 22 Jul 2018 18:50:29 -0400 Subject: [PATCH 12/26] Wrap callback in try/finally This ensures we clean up always if the callback throws. --- packages/babel-parser/src/parser/expression.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/packages/babel-parser/src/parser/expression.js b/packages/babel-parser/src/parser/expression.js index b04e26bac37c..47a34a18eab7 100644 --- a/packages/babel-parser/src/parser/expression.js +++ b/packages/babel-parser/src/parser/expression.js @@ -2131,10 +2131,11 @@ export default class ExpressionParser extends LValParser { maxTopicIndex: null, }; - const callbackResult = callback(); - - this.state.topicContext = outerContextTopicState; - return callbackResult; + try { + return callback(); + } finally { + this.state.topicContext = outerContextTopicState; + } } // Disable topic references from outer contexts within syntax constructs @@ -2153,10 +2154,11 @@ export default class ExpressionParser extends LValParser { maxTopicIndex: null, }; - const callbackResult = callback(); - - this.state.topicContext = outerContextTopicState; - return callbackResult; + try { + return callback(); + } finally { + this.state.topicContext = outerContextTopicState; + } } // Register the use of a primary topic reference (`#`) within the current From 39e7ee6e651c73dba1eb68fea52a8a14e7814cc0 Mon Sep 17 00:00:00 2001 From: James DiGioia Date: Sun, 22 Jul 2018 18:55:12 -0400 Subject: [PATCH 13/26] Switch Pipeline types to extend NodeBase This doesn't work because the `type` values are not compatible. --- packages/babel-parser/src/types.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/babel-parser/src/types.js b/packages/babel-parser/src/types.js index 7524c232b256..b658f7b0d715 100644 --- a/packages/babel-parser/src/types.js +++ b/packages/babel-parser/src/types.js @@ -571,22 +571,22 @@ export type PipelineBody = NodeBase & { type: "PipelineBody", }; -export type PipelineBareFunctionBody = PipelineBody & { +export type PipelineBareFunctionBody = NodeBase & { type: "PipelineBareFunctionBody", callee: Expression, }; -export type PipelineBareConstructorBody = PipelineBody & { +export type PipelineBareConstructorBody = NodeBase & { type: "PipelineBareConstructorBody", callee: Expression, }; -export type PipelineBareAwaitedFunctionBody = PipelineBody & { +export type PipelineBareAwaitedFunctionBody = NodeBase & { type: "PipelineBareAwaitedFunctionBody", callee: Expression, }; -export type PipelineTopicBody = PipelineBody & { +export type PipelineTopicBody = NodeBase & { type: "PipelineTopicBody", expression: Expression, }; From 11aee13ff2c3282034807e25ddb93cd98ae37217 Mon Sep 17 00:00:00 2001 From: James DiGioia Date: Thu, 9 Aug 2018 21:04:47 -0400 Subject: [PATCH 14/26] Swap Yoda condition --- packages/babel-parser/src/parser/expression.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/babel-parser/src/parser/expression.js b/packages/babel-parser/src/parser/expression.js index 47a34a18eab7..135aa2bd330b 100644 --- a/packages/babel-parser/src/parser/expression.js +++ b/packages/babel-parser/src/parser/expression.js @@ -938,7 +938,7 @@ export default class ExpressionParser extends LValParser { node = this.startNode(); if ( - "smart" !== this.getPluginOption("pipelineOperator", "proposal") + this.getPluginOption("pipelineOperator", "proposal") !== "smart" ) { this.raise( node.start, From d1cae2dec292248b4f447c14ad15909b90653d04 Mon Sep 17 00:00:00 2001 From: James DiGioia Date: Thu, 9 Aug 2018 21:10:43 -0400 Subject: [PATCH 15/26] Remove unneeded comment This is no longer true, now that we return `tt.hash`. --- packages/babel-parser/src/tokenizer/index.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/packages/babel-parser/src/tokenizer/index.js b/packages/babel-parser/src/tokenizer/index.js index 69a845b52533..138e79d9c2c5 100644 --- a/packages/babel-parser/src/tokenizer/index.js +++ b/packages/babel-parser/src/tokenizer/index.js @@ -688,9 +688,6 @@ export default class Tokenizer extends LocationParser { getTokenFromCode(code: number): void { switch (code) { - // The interpretation of a number sign "#" depends on whether it is - // followed by an identifier or not. - case charCodes.numberSign: this.readToken_numberSign(code); return; From 15e6d844ae14b3312624e9ff49aa8d1b816db78e Mon Sep 17 00:00:00 2001 From: James DiGioia Date: Thu, 9 Aug 2018 22:08:23 -0400 Subject: [PATCH 16/26] Remove additional parser logic These are parsable only in follow-on proposals, not in the base proposal, so we'll introduce that in a separate PR. --- .../babel-parser/src/parser/expression.js | 8 - .../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 | 7 - .../options.json | 3 - .../output.json | 384 ----------------- .../input.js | 3 - .../options.json | 3 - .../output.json | 298 ------------- 31 files changed, 2724 deletions(-) delete mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-awaited-function-calls,-chained,-multiline/input.js delete mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-awaited-function-calls,-chained,-multiline/options.json delete mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-awaited-function-calls,-chained,-multiline/output.json delete mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-awaited-function-calls,-chained,-single-line/input.js delete mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-awaited-function-calls,-chained,-single-line/options.json delete mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-awaited-function-calls,-chained,-single-line/output.json delete mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-awaited-function-calls,-single,-nested-property/input.js delete mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-awaited-function-calls,-single,-nested-property/options.json delete mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-awaited-function-calls,-single,-nested-property/output.json delete mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-awaited-function-calls,-single,-single-identifier/input.js delete mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-awaited-function-calls,-single,-single-identifier/options.json delete mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-awaited-function-calls,-single,-single-identifier/output.json delete mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-constructor-calls,-chained,-multiline/input.js delete mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-constructor-calls,-chained,-multiline/options.json delete mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-constructor-calls,-chained,-multiline/output.json delete mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-constructor-calls,-chained,-single-line-arrow-function/input.js delete mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-constructor-calls,-chained,-single-line-arrow-function/options.json delete mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-constructor-calls,-chained,-single-line-arrow-function/output.json delete mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-constructor-calls,-single,-identifier/input.js delete mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-constructor-calls,-single,-identifier/options.json delete mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-constructor-calls,-single,-identifier/output.json delete mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-constructor-calls,-single,-property/input.js delete mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-constructor-calls,-single,-property/options.json delete mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-constructor-calls,-single,-property/output.json delete mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-style-mix,-multiline/input.js delete mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-style-mix,-multiline/options.json delete mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-style-mix,-multiline/output.json delete mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-style-mix,-single-line/input.js delete mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-style-mix,-single-line/options.json delete mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-style-mix,-single-line/output.json diff --git a/packages/babel-parser/src/parser/expression.js b/packages/babel-parser/src/parser/expression.js index 135aa2bd330b..2e50be642368 100644 --- a/packages/babel-parser/src/parser/expression.js +++ b/packages/babel-parser/src/parser/expression.js @@ -2090,14 +2090,6 @@ export default class ExpressionParser extends LValParser { checkSmartPipelineBodyStyle(expression: N.Expression): PipelineStyle { 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" 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 deleted file mode 100644 index dfbeff94f212..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-awaited-function-calls,-chained,-multiline/input.js +++ /dev/null @@ -1,6 +0,0 @@ -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 deleted file mode 100644 index 8b9d7913160a..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-awaited-function-calls,-chained,-multiline/options.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "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 deleted file mode 100644 index fd6424d6361a..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-awaited-function-calls,-chained,-multiline/output.json +++ /dev/null @@ -1,401 +0,0 @@ -{ - "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 deleted file mode 100644 index a78a3ae84428..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-awaited-function-calls,-chained,-single-line/input.js +++ /dev/null @@ -1,3 +0,0 @@ -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 deleted file mode 100644 index 17e4e327bbad..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-awaited-function-calls,-chained,-single-line/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "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 deleted file mode 100644 index 5e0aa503463d..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-awaited-function-calls,-chained,-single-line/output.json +++ /dev/null @@ -1,249 +0,0 @@ -{ - "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 deleted file mode 100644 index c86dda49df36..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-awaited-function-calls,-single,-nested-property/input.js +++ /dev/null @@ -1,3 +0,0 @@ -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 deleted file mode 100644 index 17e4e327bbad..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-awaited-function-calls,-single,-nested-property/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "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 deleted file mode 100644 index aaf050332d53..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-awaited-function-calls,-single,-nested-property/output.json +++ /dev/null @@ -1,234 +0,0 @@ -{ - "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 deleted file mode 100644 index ff9045bd7262..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-awaited-function-calls,-single,-single-identifier/input.js +++ /dev/null @@ -1,3 +0,0 @@ -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 deleted file mode 100644 index 17e4e327bbad..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-awaited-function-calls,-single,-single-identifier/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "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 deleted file mode 100644 index 50b19d2d745b..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-awaited-function-calls,-single,-single-identifier/output.json +++ /dev/null @@ -1,168 +0,0 @@ -{ - "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 deleted file mode 100644 index 07827f96fbcd..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-constructor-calls,-chained,-multiline/input.js +++ /dev/null @@ -1,4 +0,0 @@ -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 deleted file mode 100644 index 17e4e327bbad..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-constructor-calls,-chained,-multiline/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "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 deleted file mode 100644 index cdf86d3125da..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-constructor-calls,-chained,-multiline/output.json +++ /dev/null @@ -1,348 +0,0 @@ -{ - "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 deleted file mode 100644 index 39c48bad512f..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-constructor-calls,-chained,-single-line-arrow-function/input.js +++ /dev/null @@ -1 +0,0 @@ -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 deleted file mode 100644 index 17e4e327bbad..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-constructor-calls,-chained,-single-line-arrow-function/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "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 deleted file mode 100644 index 4b4a0fb6af89..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-constructor-calls,-chained,-single-line-arrow-function/output.json +++ /dev/null @@ -1,233 +0,0 @@ -{ - "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 deleted file mode 100644 index 4a4ec7bcd357..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-constructor-calls,-single,-identifier/input.js +++ /dev/null @@ -1 +0,0 @@ -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 deleted file mode 100644 index 17e4e327bbad..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-constructor-calls,-single,-identifier/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "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 deleted file mode 100644 index 1f6e4945bd06..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-constructor-calls,-single,-identifier/output.json +++ /dev/null @@ -1,152 +0,0 @@ -{ - "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 deleted file mode 100644 index f6b0bd49964b..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-constructor-calls,-single,-property/input.js +++ /dev/null @@ -1 +0,0 @@ -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 deleted file mode 100644 index 17e4e327bbad..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-constructor-calls,-single,-property/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "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 deleted file mode 100644 index dc9bbf5eab44..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-constructor-calls,-single,-property/output.json +++ /dev/null @@ -1,185 +0,0 @@ -{ - "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-style-mix,-multiline/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-style-mix,-multiline/input.js deleted file mode 100644 index 0045c931d1e3..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-style-mix,-multiline/input.js +++ /dev/null @@ -1,7 +0,0 @@ -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 deleted file mode 100644 index 17e4e327bbad..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-style-mix,-multiline/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "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 deleted file mode 100644 index 8f5a0c112d2e..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-style-mix,-multiline/output.json +++ /dev/null @@ -1,384 +0,0 @@ -{ - "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 deleted file mode 100644 index ed1cd16aad0f..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-style-mix,-single-line/input.js +++ /dev/null @@ -1,3 +0,0 @@ -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 deleted file mode 100644 index 17e4e327bbad..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-style-mix,-single-line/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "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 deleted file mode 100644 index 2fa260909358..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-style-mix,-single-line/output.json +++ /dev/null @@ -1,298 +0,0 @@ -{ - "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 From ba5642d4ee33dad7c66051613a85884bbc639736 Mon Sep 17 00:00:00 2001 From: James DiGioia Date: Thu, 9 Aug 2018 22:08:39 -0400 Subject: [PATCH 17/26] Add test for computer properties This seems to parse fine. Should it? --- .../input.js | 1 + .../options.json | 3 + .../output.json | 148 ++++++++++++++++++ 3 files changed, 152 insertions(+) create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-function-calls,-single,-computed/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-function-calls,-single,-computed/options.json create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-function-calls,-single,-computed/output.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-function-calls,-single,-computed/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-function-calls,-single,-computed/input.js new file mode 100644 index 000000000000..5a02dee8ec60 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-function-calls,-single,-computed/input.js @@ -0,0 +1 @@ +value |> a[b] diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-function-calls,-single,-computed/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-function-calls,-single,-computed/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,-computed/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,-computed/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-function-calls,-single,-computed/output.json new file mode 100644 index 000000000000..540ce0ba4002 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-function-calls,-single,-computed/output.json @@ -0,0 +1,148 @@ +{ + "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": "PipelineBareFunction", + "start": 9, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "callee": { + "type": "MemberExpression", + "start": 9, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "object": { + "type": "Identifier", + "start": 9, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 10 + }, + "identifierName": "a" + }, + "name": "a" + }, + "property": { + "type": "Identifier", + "start": 11, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 12 + }, + "identifierName": "b" + }, + "name": "b" + }, + "computed": true + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file From 25d01460fdb017fee6ec1b812449f62a432759fb Mon Sep 17 00:00:00 2001 From: James DiGioia Date: Fri, 10 Aug 2018 07:52:55 -0400 Subject: [PATCH 18/26] Fix error message for #4 case This impact private fields as well as smart pipeline, providing a clearer error message for both. --- packages/babel-parser/src/tokenizer/index.js | 15 +++++---------- .../failure-numeric-literal/options.json | 2 +- .../failure-numeric-start-identifier/options.json | 2 +- .../options.json | 2 +- 4 files changed, 8 insertions(+), 13 deletions(-) diff --git a/packages/babel-parser/src/tokenizer/index.js b/packages/babel-parser/src/tokenizer/index.js index 138e79d9c2c5..2c362e0c2467 100644 --- a/packages/babel-parser/src/tokenizer/index.js +++ b/packages/babel-parser/src/tokenizer/index.js @@ -412,6 +412,10 @@ export default class Tokenizer extends LocationParser { const nextPos = this.state.pos + 1; const next = this.input.charCodeAt(nextPos); + if (next >= charCodes.digit0 && next <= charCodes.digit9) { + this.raise(this.state.pos, "Unexpected digit after hash token"); + } + if ( (this.hasPlugin("classPrivateProperties") || this.hasPlugin("classPrivateMethods")) && @@ -423,16 +427,7 @@ export default class Tokenizer extends LocationParser { } else if ( this.getPluginOption("pipelineOperator", "proposal") === "smart" ) { - if (next >= charCodes.digit0 && next <= charCodes.digit9) { - this.raise( - this.state.pos, - `Unexpected digit after topic reference: '#${String.fromCodePoint( - next, - )}'`, - ); - } else { - this.finishOp(tt.hash, 1); - } + this.finishOp(tt.hash, 1); } else { this.raise( this.state.pos, diff --git a/packages/babel-parser/test/fixtures/experimental/class-private-properties/failure-numeric-literal/options.json b/packages/babel-parser/test/fixtures/experimental/class-private-properties/failure-numeric-literal/options.json index dfd75111a543..03592e655ab9 100644 --- a/packages/babel-parser/test/fixtures/experimental/class-private-properties/failure-numeric-literal/options.json +++ b/packages/babel-parser/test/fixtures/experimental/class-private-properties/failure-numeric-literal/options.json @@ -1,4 +1,4 @@ { - "throws": "Unexpected token (2:3)", + "throws": "Unexpected digit after hash token (2:2)", "plugins": [ "classPrivateProperties" ] } diff --git a/packages/babel-parser/test/fixtures/experimental/class-private-properties/failure-numeric-start-identifier/options.json b/packages/babel-parser/test/fixtures/experimental/class-private-properties/failure-numeric-start-identifier/options.json index c1de1d488c13..2ba960820f02 100644 --- a/packages/babel-parser/test/fixtures/experimental/class-private-properties/failure-numeric-start-identifier/options.json +++ b/packages/babel-parser/test/fixtures/experimental/class-private-properties/failure-numeric-start-identifier/options.json @@ -1,4 +1,4 @@ { - "throws": "Identifier directly after number (2:4)", + "throws": "Unexpected digit after hash token (2:2)", "plugins": ["classPrivateProperties"] } 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 index 6d423c8c9d96..a2f6f625f90c 100644 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-invalid-hash-token,-followed-by-digit/options.json +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-invalid-hash-token,-followed-by-digit/options.json @@ -1,4 +1,4 @@ { "plugins": [["pipelineOperator", { "proposal": "smart" }]], - "throws": "Unexpected digit after topic reference: '#4' (1:5)" + "throws": "Unexpected digit after hash token (1:5)" } From 122906d5255dfef9075284f5e505dd84b1951535 Mon Sep 17 00:00:00 2001 From: James DiGioia Date: Fri, 10 Aug 2018 08:06:38 -0400 Subject: [PATCH 19/26] Verify if MemberExpression is computed If a property access is computed, e.g. a[b], then it's in topic style. Currently, this isn't accounted for. Test & change ensures this doesn't parse. --- .../babel-parser/src/parser/expression.js | 4 +- .../options.json | 3 - .../output.json | 148 ------------------ .../input.js | 0 .../options.json | 4 + 5 files changed, 7 insertions(+), 152 deletions(-) delete mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-function-calls,-single,-computed/options.json delete mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-function-calls,-single,-computed/output.json rename packages/babel-parser/test/fixtures/experimental/pipeline-operator/{proposal-smart-bare-style,-function-calls,-single,-computed => proposal-smart-error,-topic-style,-computed,-no-topic-reference}/input.js (100%) create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-computed,-no-topic-reference/options.json diff --git a/packages/babel-parser/src/parser/expression.js b/packages/babel-parser/src/parser/expression.js index 2e50be642368..dd7641990a06 100644 --- a/packages/babel-parser/src/parser/expression.js +++ b/packages/babel-parser/src/parser/expression.js @@ -2100,7 +2100,9 @@ export default class ExpressionParser extends LValParser { isSimpleReference(expression: N.Expression): boolean { switch (expression.type) { case "MemberExpression": - return this.isSimpleReference(expression.object); + return ( + !expression.computed && this.isSimpleReference(expression.object) + ); case "Identifier": return true; default: diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-function-calls,-single,-computed/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-function-calls,-single,-computed/options.json deleted file mode 100644 index 17e4e327bbad..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-function-calls,-single,-computed/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "plugins": [["pipelineOperator", { "proposal": "smart" }]] -} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-function-calls,-single,-computed/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-function-calls,-single,-computed/output.json deleted file mode 100644 index 540ce0ba4002..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-function-calls,-single,-computed/output.json +++ /dev/null @@ -1,148 +0,0 @@ -{ - "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": "PipelineBareFunction", - "start": 9, - "end": 13, - "loc": { - "start": { - "line": 1, - "column": 9 - }, - "end": { - "line": 1, - "column": 13 - } - }, - "callee": { - "type": "MemberExpression", - "start": 9, - "end": 13, - "loc": { - "start": { - "line": 1, - "column": 9 - }, - "end": { - "line": 1, - "column": 13 - } - }, - "object": { - "type": "Identifier", - "start": 9, - "end": 10, - "loc": { - "start": { - "line": 1, - "column": 9 - }, - "end": { - "line": 1, - "column": 10 - }, - "identifierName": "a" - }, - "name": "a" - }, - "property": { - "type": "Identifier", - "start": 11, - "end": 12, - "loc": { - "start": { - "line": 1, - "column": 11 - }, - "end": { - "line": 1, - "column": 12 - }, - "identifierName": "b" - }, - "name": "b" - }, - "computed": true - } - } - } - } - ], - "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,-computed/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-computed,-no-topic-reference/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-bare-style,-function-calls,-single,-computed/input.js rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-computed,-no-topic-reference/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-computed,-no-topic-reference/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-computed,-no-topic-reference/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,-computed,-no-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:9)" +} From b593af17a9a96a8acd0c966f274ce6d6decfb393 Mon Sep 17 00:00:00 2001 From: mAAdhaTTah Date: Sat, 3 Nov 2018 14:00:42 -0400 Subject: [PATCH 20/26] Replace codePointToString with ES6 method --- packages/babel-parser/src/tokenizer/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/babel-parser/src/tokenizer/index.js b/packages/babel-parser/src/tokenizer/index.js index 871c3199603c..20dd2860c492 100644 --- a/packages/babel-parser/src/tokenizer/index.js +++ b/packages/babel-parser/src/tokenizer/index.js @@ -402,7 +402,7 @@ export default class Tokenizer extends LocationParser { } else { this.raise( this.state.pos, - `Unexpected character '${codePointToString(code)}'`, + `Unexpected character '${String.fromCodePoint(code)}'`, ); } } From a0e94ec24d2d46b3cc43ed0f6964fb3215bc7982 Mon Sep 17 00:00:00 2001 From: mAAdhaTTah Date: Sat, 3 Nov 2018 14:03:17 -0400 Subject: [PATCH 21/26] Move PipelineStyle to types.js file --- packages/babel-parser/src/parser/expression.js | 12 +++--------- packages/babel-parser/src/types.js | 6 ++++++ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/packages/babel-parser/src/parser/expression.js b/packages/babel-parser/src/parser/expression.js index a02e409ec9e9..e94dc10805bf 100644 --- a/packages/babel-parser/src/parser/expression.js +++ b/packages/babel-parser/src/parser/expression.js @@ -2071,7 +2071,7 @@ export default class ExpressionParser extends LValParser { checkSmartPipelineBodyEarlyErrors( childExpression: N.Expression, - pipelineStyle: PipelineStyle, + pipelineStyle: N.PipelineStyle, startPos: number, ): void { if (this.match(tt.arrow)) { @@ -2094,7 +2094,7 @@ export default class ExpressionParser extends LValParser { parseSmartPipelineBodyInStyle( childExpression: N.Expression, - pipelineStyle: PipelineStyle, + pipelineStyle: N.PipelineStyle, startPos: number, startLoc: Position, ): N.PipelineBody { @@ -2124,7 +2124,7 @@ export default class ExpressionParser extends LValParser { return this.finishNode(bodyNode, pipelineStyle); } - checkSmartPipelineBodyStyle(expression: N.Expression): PipelineStyle { + checkSmartPipelineBodyStyle(expression: N.Expression): N.PipelineStyle { switch (expression.type) { default: return this.isSimpleReference(expression) @@ -2208,9 +2208,3 @@ export default class ExpressionParser extends LValParser { ); } } - -type PipelineStyle = - | "PipelineBareFunction" - | "PipelineBareConstructor" - | "PipelineBareAwaitedFunction" - | "PipelineTopicExpression"; diff --git a/packages/babel-parser/src/types.js b/packages/babel-parser/src/types.js index c06f1e66b88b..254372aa7a0a 100644 --- a/packages/babel-parser/src/types.js +++ b/packages/babel-parser/src/types.js @@ -592,6 +592,12 @@ export type PipelineTopicBody = NodeBase & { expression: Expression, }; +export type PipelineStyle = + | "PipelineBareFunction" + | "PipelineBareConstructor" + | "PipelineBareAwaitedFunction" + | "PipelineTopicExpression"; + // Template Literals export type TemplateLiteral = NodeBase & { From 0eb9b2463db3d2b9515a50d5a44a4adfdb2a7f23 Mon Sep 17 00:00:00 2001 From: mAAdhaTTah Date: Wed, 21 Nov 2018 15:54:26 -0500 Subject: [PATCH 22/26] Move plugin check to pipeline op appearance No need to recheck it throughout then. --- packages/babel-parser/src/parser/expression.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/packages/babel-parser/src/parser/expression.js b/packages/babel-parser/src/parser/expression.js index e94dc10805bf..cd7f402561cb 100644 --- a/packages/babel-parser/src/parser/expression.js +++ b/packages/babel-parser/src/parser/expression.js @@ -298,6 +298,7 @@ export default class ExpressionParser extends LValParser { const op = this.state.type; if (op === tt.pipeline) { + this.expectPlugin("pipelineOperator"); this.state.inPipeline = true; this.checkPipelineAtInfixOperator(left, leftStartPos); } else if (op === tt.nullishCoalescing) { @@ -958,7 +959,6 @@ export default class ExpressionParser extends LValParser { case tt.hash: { if (this.state.inPipeline) { - this.expectPlugin("pipelineOperator"); node = this.startNode(); if ( @@ -2034,8 +2034,6 @@ export default class ExpressionParser extends LValParser { // of the infix operator `|>`. checkPipelineAtInfixOperator(left: N.Expression, leftStartPos: number) { - this.expectPlugin("pipelineOperator"); - if (this.getPluginOption("pipelineOperator", "proposal") === "smart") { if (left.type === "SequenceExpression") { // Ensure that the pipeline head is not a comma-delimited From 6e84352b5157a66e4fcd3d967120181e05feb339 Mon Sep 17 00:00:00 2001 From: mAAdhaTTah Date: Wed, 21 Nov 2018 15:54:56 -0500 Subject: [PATCH 23/26] PrimaryTopicReference -> PipelinePrimaryTopicReference --- packages/babel-parser/src/parser/expression.js | 2 +- .../output.json | 2 +- .../output.json | 4 ++-- .../output.json | 2 +- .../output.json | 4 ++-- .../output.json | 2 +- .../output.json | 2 +- .../output.json | 2 +- .../output.json | 2 +- .../output.json | 6 +++--- .../output.json | 2 +- .../output.json | 2 +- .../output.json | 2 +- .../output.json | 2 +- .../output.json | 2 +- .../output.json | 2 +- .../output.json | 2 +- .../output.json | 6 +++--- .../output.json | 2 +- .../output.json | 2 +- .../output.json | 2 +- .../output.json | 2 +- .../output.json | 2 +- .../output.json | 2 +- .../output.json | 2 +- .../output.json | 2 +- .../output.json | 2 +- .../output.json | 2 +- .../output.json | 2 +- 29 files changed, 35 insertions(+), 35 deletions(-) diff --git a/packages/babel-parser/src/parser/expression.js b/packages/babel-parser/src/parser/expression.js index cd7f402561cb..eced2772f032 100644 --- a/packages/babel-parser/src/parser/expression.js +++ b/packages/babel-parser/src/parser/expression.js @@ -973,7 +973,7 @@ export default class ExpressionParser extends LValParser { this.next(); if (this.primaryTopicReferenceIsAllowedInCurrentTopicContext()) { this.registerTopicReference(); - return this.finishNode(node, "PrimaryTopicReference"); + return this.finishNode(node, "PipelinePrimaryTopicReference"); } else { throw this.raise( node.start, 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 index 619f4e61b22b..20fef485fd61 100644 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-nested-pipelines,-topic-style-with-arrow-function-with-bare-style/output.json +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-nested-pipelines,-topic-style-with-arrow-function-with-bare-style/output.json @@ -122,7 +122,7 @@ } }, "left": { - "type": "PrimaryTopicReference", + "type": "PipelinePrimaryTopicReference", "start": 12, "end": 13, "loc": { 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 index b83895f5f4c3..ae7bef130c84 100644 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-nested-pipelines,-topic-style-with-arrow-function-with-topic-style/output.json +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-nested-pipelines,-topic-style-with-arrow-function-with-topic-style/output.json @@ -140,7 +140,7 @@ } }, "left": { - "type": "PrimaryTopicReference", + "type": "PipelinePrimaryTopicReference", "start": 11, "end": 12, "loc": { @@ -202,7 +202,7 @@ }, "arguments": [ { - "type": "PrimaryTopicReference", + "type": "PipelinePrimaryTopicReference", "start": 18, "end": 19, "loc": { 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 index c2bc9ec1b75c..51d79d3318da 100644 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-nested-pipelines,-topic-style-with-inner-bare-style/output.json +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-nested-pipelines,-topic-style-with-inner-bare-style/output.json @@ -104,7 +104,7 @@ } }, "left": { - "type": "PrimaryTopicReference", + "type": "PipelinePrimaryTopicReference", "start": 6, "end": 7, "loc": { 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 index 683de81b9c6a..7b38baf9008c 100644 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-nested-pipelines,-topic-style-with-inner-topic-style/output.json +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-nested-pipelines,-topic-style-with-inner-topic-style/output.json @@ -104,7 +104,7 @@ } }, "left": { - "type": "PrimaryTopicReference", + "type": "PipelinePrimaryTopicReference", "start": 6, "end": 7, "loc": { @@ -166,7 +166,7 @@ }, "arguments": [ { - "type": "PrimaryTopicReference", + "type": "PipelinePrimaryTopicReference", "start": 13, "end": 14, "loc": { 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 index 8f9687369fc5..195e3bb795f5 100644 --- 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 @@ -104,7 +104,7 @@ } }, "left": { - "type": "PrimaryTopicReference", + "type": "PipelinePrimaryTopicReference", "start": 9, "end": 10, "loc": { 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 index 844200b657a3..3a206964c2bd 100644 --- 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 @@ -125,7 +125,7 @@ }, "operator": "+", "right": { - "type": "PrimaryTopicReference", + "type": "PipelinePrimaryTopicReference", "start": 13, "end": 14, "loc": { 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 index 338ed0d21c54..18b3068859d9 100644 --- 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 @@ -233,7 +233,7 @@ }, "operator": "<", "right": { - "type": "PrimaryTopicReference", + "type": "PipelinePrimaryTopicReference", "start": 36, "end": 37, "loc": { 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 index 727bcebb1146..15b7a61ce7ba 100644 --- 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 @@ -234,7 +234,7 @@ "kind": "const" }, "right": { - "type": "PrimaryTopicReference", + "type": "PipelinePrimaryTopicReference", "start": 61, "end": 62, "loc": { 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 index 39abf98f7e6d..2fb6945eeb76 100644 --- 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 @@ -179,7 +179,7 @@ "name": "i" }, "init": { - "type": "PrimaryTopicReference", + "type": "PipelinePrimaryTopicReference", "start": 27, "end": 28, "loc": { @@ -247,7 +247,7 @@ "name": "i" }, { - "type": "PrimaryTopicReference", + "type": "PipelinePrimaryTopicReference", "start": 43, "end": 44, "loc": { @@ -296,7 +296,7 @@ "name": "i" }, "right": { - "type": "PrimaryTopicReference", + "type": "PipelinePrimaryTopicReference", "start": 52, "end": 53, "loc": { 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 index eddca7faa4b9..4571a8f3b91e 100644 --- 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 @@ -150,7 +150,7 @@ "name": "e" }, "right": { - "type": "PrimaryTopicReference", + "type": "PipelinePrimaryTopicReference", "start": 24, "end": 25, "loc": { 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 index 79f6c6b771be..25757328ebef 100644 --- 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 @@ -151,7 +151,7 @@ "name": "e" }, "right": { - "type": "PrimaryTopicReference", + "type": "PipelinePrimaryTopicReference", "start": 24, "end": 25, "loc": { 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 index c1394ed9d8f0..d0c29a3cc724 100644 --- 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 @@ -133,7 +133,7 @@ } }, "expression": { - "type": "PrimaryTopicReference", + "type": "PipelinePrimaryTopicReference", "start": 14, "end": 15, "loc": { 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 index 7900de3f1399..be74d493c27c 100644 --- 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 @@ -225,7 +225,7 @@ } }, "expression": { - "type": "PrimaryTopicReference", + "type": "PipelinePrimaryTopicReference", "start": 42, "end": 43, "loc": { 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 index 4bd2a955d177..eb53ce59a775 100644 --- 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 @@ -194,7 +194,7 @@ } }, "expression": { - "type": "PrimaryTopicReference", + "type": "PipelinePrimaryTopicReference", "start": 34, "end": 35, "loc": { 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 index 11c2656ea035..501bbac6fa08 100644 --- 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 @@ -164,7 +164,7 @@ } }, "expression": { - "type": "PrimaryTopicReference", + "type": "PipelinePrimaryTopicReference", "start": 23, "end": 24, "loc": { 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 index 48d8f663f2cb..e2fb435ec82b 100644 --- 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 @@ -133,7 +133,7 @@ } }, "test": { - "type": "PrimaryTopicReference", + "type": "PipelinePrimaryTopicReference", "start": 18, "end": 19, "loc": { 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 index f4e627647b9e..7ab18f8fbcfc 100644 --- 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 @@ -180,7 +180,7 @@ } }, "expression": { - "type": "PrimaryTopicReference", + "type": "PipelinePrimaryTopicReference", "start": 46, "end": 47, "loc": { @@ -261,7 +261,7 @@ } }, "left": { - "type": "PrimaryTopicReference", + "type": "PipelinePrimaryTopicReference", "start": 61, "end": 62, "loc": { @@ -364,7 +364,7 @@ } }, "left": { - "type": "PrimaryTopicReference", + "type": "PipelinePrimaryTopicReference", "start": 81, "end": 82, "loc": { 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 index c7c865a8e291..75c247866713 100644 --- 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 @@ -133,7 +133,7 @@ } }, "discriminant": { - "type": "PrimaryTopicReference", + "type": "PipelinePrimaryTopicReference", "start": 24, "end": 25, "loc": { 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 index 07af94d070ab..919b7780300e 100644 --- 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 @@ -461,7 +461,7 @@ }, "arguments": [ { - "type": "PrimaryTopicReference", + "type": "PipelinePrimaryTopicReference", "start": 110, "end": 111, "loc": { 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 index c9b09e909864..56532830c7a7 100644 --- 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 @@ -227,7 +227,7 @@ }, "arguments": [ { - "type": "PrimaryTopicReference", + "type": "PipelinePrimaryTopicReference", "start": 33, "end": 34, "loc": { 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 index 976398843dd9..1eaf75551753 100644 --- 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 @@ -227,7 +227,7 @@ }, "arguments": [ { - "type": "PrimaryTopicReference", + "type": "PipelinePrimaryTopicReference", "start": 33, "end": 34, "loc": { 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 index 6c5dbb28a304..e3714c89c3b5 100644 --- 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 @@ -165,7 +165,7 @@ }, "operator": "<", "right": { - "type": "PrimaryTopicReference", + "type": "PipelinePrimaryTopicReference", "start": 25, "end": 26, "loc": { 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 index 3c4b198f1d9c..3ee59b9da5c3 100644 --- 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 @@ -122,7 +122,7 @@ }, "arguments": [ { - "type": "PrimaryTopicReference", + "type": "PipelinePrimaryTopicReference", "start": 11, "end": 12, "loc": { 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 index 6aea657b9d0c..c5ba3fb13a9c 100644 --- 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 @@ -139,7 +139,7 @@ "name": "x" }, "right": { - "type": "PrimaryTopicReference", + "type": "PipelinePrimaryTopicReference", "start": 23, "end": 24, "loc": { 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 index e3c00951e0ca..3d951c7dcb90 100644 --- 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 @@ -90,7 +90,7 @@ } }, "expression": { - "type": "PrimaryTopicReference", + "type": "PipelinePrimaryTopicReference", "start": 10, "end": 11, "loc": { 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 index 24779f851b61..147e066345a3 100644 --- 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 @@ -90,7 +90,7 @@ } }, "expression": { - "type": "PrimaryTopicReference", + "type": "PipelinePrimaryTopicReference", "start": 9, "end": 10, "loc": { 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 index 24779f851b61..147e066345a3 100644 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-mixed-pipeline-plugins/output.json +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-mixed-pipeline-plugins/output.json @@ -90,7 +90,7 @@ } }, "expression": { - "type": "PrimaryTopicReference", + "type": "PipelinePrimaryTopicReference", "start": 9, "end": 10, "loc": { 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 index 6d82768d86bc..23ba6b6a9dd4 100644 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-parenthesized-single-line-arrow-function,-with-empty-parameter-list-and-bare-addition-body/output.json +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-parenthesized-single-line-arrow-function,-with-empty-parameter-list-and-bare-addition-body/output.json @@ -122,7 +122,7 @@ } }, "left": { - "type": "PrimaryTopicReference", + "type": "PipelinePrimaryTopicReference", "start": 16, "end": 17, "loc": { From 70318c941360f30466912890488886b19a8b27af Mon Sep 17 00:00:00 2001 From: mAAdhaTTah Date: Wed, 21 Nov 2018 15:55:24 -0500 Subject: [PATCH 24/26] s/may/should --- packages/babel-parser/src/parser/expression.js | 2 +- .../options.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/babel-parser/src/parser/expression.js b/packages/babel-parser/src/parser/expression.js index eced2772f032..89913e07e517 100644 --- a/packages/babel-parser/src/parser/expression.js +++ b/packages/babel-parser/src/parser/expression.js @@ -2040,7 +2040,7 @@ export default class ExpressionParser extends LValParser { // sequence expression. throw this.raise( leftStartPos, - `Pipeline head may not be a comma-separated sequence expression`, + `Pipeline head should not be a comma-separated sequence expression`, ); } } 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 index c785202f2a0c..cc2c16a778e7 100644 --- 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 @@ -1,4 +1,4 @@ { "plugins": [["pipelineOperator", { "proposal": "smart" }]], - "throws": "Pipeline head may not be a comma-separated sequence expression (1:0)" + "throws": "Pipeline head should not be a comma-separated sequence expression (1:0)" } From 4cbd22a15f1a1898bb9ffdf2be5f774d7dbd3634 Mon Sep 17 00:00:00 2001 From: mAAdhaTTah Date: Wed, 21 Nov 2018 21:05:51 -0500 Subject: [PATCH 25/26] Hardcode "#" in error message It's not going to be anything else... --- packages/babel-parser/src/tokenizer/index.js | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/packages/babel-parser/src/tokenizer/index.js b/packages/babel-parser/src/tokenizer/index.js index 20dd2860c492..b17de1af2edb 100644 --- a/packages/babel-parser/src/tokenizer/index.js +++ b/packages/babel-parser/src/tokenizer/index.js @@ -376,7 +376,7 @@ export default class Tokenizer extends LocationParser { // All in the name of speed. // number sign is "#" - readToken_numberSign(code: number): void { + readToken_numberSign(): void { if (this.state.pos === 0 && this.readToken_interpreter()) { return; } @@ -400,10 +400,7 @@ export default class Tokenizer extends LocationParser { ) { this.finishOp(tt.hash, 1); } else { - this.raise( - this.state.pos, - `Unexpected character '${String.fromCodePoint(code)}'`, - ); + this.raise(this.state.pos, "Unexpected character '#'"); } } @@ -655,7 +652,7 @@ export default class Tokenizer extends LocationParser { getTokenFromCode(code: number): void { switch (code) { case charCodes.numberSign: - this.readToken_numberSign(code); + this.readToken_numberSign(); return; // The interpretation of a dot depends on whether it is followed From 100b38784d4a6c78748386f45d61cb69e2867abc Mon Sep 17 00:00:00 2001 From: mAAdhaTTah Date: Wed, 21 Nov 2018 21:07:03 -0500 Subject: [PATCH 26/26] Replace else with fall through --- packages/babel-parser/src/parser/expression.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/babel-parser/src/parser/expression.js b/packages/babel-parser/src/parser/expression.js index 89913e07e517..089efdf6986b 100644 --- a/packages/babel-parser/src/parser/expression.js +++ b/packages/babel-parser/src/parser/expression.js @@ -366,9 +366,8 @@ export default class ExpressionParser extends LValParser { startLoc, ); }); - } else { - return this.parseExprOpBaseRightExpr(op, prec, noIn); } + // falls through default: return this.parseExprOpBaseRightExpr(op, prec, noIn);