From 97c3eb173444d5062e850c81805339ce5c625851 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hu=C3=A1ng=20J=C3=B9nli=C3=A0ng?= Date: Thu, 2 May 2024 09:53:17 -0400 Subject: [PATCH] Remove `syntaxType` option for record-and-tuple (parser&plugin) (#16458) --- eslint/babel-eslint-parser/test/index.js | 10 ++- .../babel-generator/src/generators/types.ts | 50 ++++++----- packages/babel-generator/src/index.ts | 3 +- packages/babel-generator/src/printer.ts | 5 +- .../fixtures/recordAndTuple/default/input.js | 1 + .../recordAndTuple/default/options.json | 3 + .../fixtures/recordAndTuple/default/output.js | 1 + .../test/fixtures/recordAndTuple/options.json | 3 + .../bar-record/input.js | 0 .../bar-record/options.json | 0 .../bar-record/output.js | 0 .../bar-tuple/input.js | 0 .../bar-tuple/options.json | 0 .../bar-tuple/output.js | 0 .../default/input.js | 0 .../default/options.json | 0 .../default/output.js | 0 .../hash-record/input.js | 0 .../hash-record/options.json | 0 .../hash-record/output.js | 0 .../hash-tuple/input.js | 0 .../hash-tuple/options.json | 0 .../hash-tuple/output.js | 0 .../invalid-option/input.js | 0 .../invalid-option/options.json | 0 .../missing-option/input.js | 0 .../missing-option/options.json | 0 .../missing-option/output.js | 0 .../options.json | 3 + .../input.js | 0 .../options.json | 1 + .../output.js | 0 .../source-map.json | 2 +- .../hash-record-tuple-babel-7/input.js | 2 + .../hash-record-tuple-babel-7/options.json | 6 ++ .../hash-record-tuple-babel-7/output.js | 6 ++ .../hash-record-tuple-babel-7/source-map.json | 16 ++++ .../sourcemaps/hash-record-tuple/options.json | 3 +- packages/babel-parser/src/plugin-utils.ts | 50 +++++++---- packages/babel-parser/src/tokenizer/index.ts | 9 +- .../input.js | 0 .../options.json | 1 + .../input.js | 2 + .../options.json | 18 ++++ .../output.json | 0 .../options.json | 13 ++- .../input.js | 2 + .../options.json | 18 ++++ .../output.json | 69 ++++++++++++++ .../options.json | 13 ++- .../input.js | 2 + .../options.json | 18 ++++ .../output.json | 69 ++++++++++++++ .../options.json | 13 ++- .../input.js | 2 + .../options.json | 19 ++++ .../options.json | 15 +++- .../input.js | 2 + .../options.json | 18 ++++ .../output.json | 69 ++++++++++++++ .../options.json | 19 +++- .../input.js | 2 + .../options.json | 18 ++++ .../smart-proposal-hash-tuple/options.json | 12 ++- .../as-jsx-attribute-value-bar/input.js | 0 .../as-jsx-attribute-value-bar/options.json | 12 +++ .../as-jsx-attribute-value-bar/output.json | 0 .../as-jsx-attribute-value-hash/input.js | 1 + .../as-jsx-attribute-value-hash/options.json | 12 +++ .../as-jsx-attribute-value-hash/output.json | 0 .../bar-flow/input.js | 1 + .../bar-flow/options.json | 3 + .../bar-yield-without-argument/input.js | 3 + .../bar-yield-without-argument/options.json | 10 +++ .../bar-yield-without-argument/output.json | 0 .../record-and-tuple-babel-7/bar/input.js | 16 ++++ .../record-and-tuple-babel-7/bar/options.json | 10 +++ .../bar/output.json | 0 .../default-hash/input.js | 1 + .../default-hash/options.json | 3 + .../default-hash/output.json | 44 +++++++++ .../disambiguate-regex-hash/input.js | 1 + .../disambiguate-regex-hash/options.json | 12 +++ .../disambiguate-regex-hash/output.json | 0 .../record-and-tuple-babel-7/hash/input.js | 16 ++++ .../hash/options.json | 10 +++ .../hash/output.json | 0 .../incorrect-type-record-end-bar/input.js | 0 .../options.json | 2 +- .../incorrect-type-record-start-bar/input.js | 0 .../options.json | 2 +- .../incorrect-type-record-start-hash/input.js | 1 + .../options.json | 11 +++ .../incorrect-type-tuple-end-bar/input.js | 0 .../incorrect-type-tuple-end-bar/options.json | 2 +- .../incorrect-type-tuple-start-bar/input.js | 0 .../options.json | 2 +- .../incorrect-type-tuple-start-hash/input.js | 1 + .../options.json | 11 +++ .../invalid-private-key/input.js | 1 + .../invalid-private-key/options.json | 3 + .../invalid-property-initializer/input.js | 1 + .../invalid-property-initializer/options.json | 10 +++ .../invalid-property-initializer/output.json | 0 .../invalid-record-method/input.js | 7 ++ .../invalid-record-method/options.json | 10 +++ .../invalid-record-method/output.json | 0 .../invalid-record-proto/input.js | 1 + .../invalid-record-proto/options.json | 10 +++ .../invalid-record-proto/output.json | 0 .../invalid-tuple-holes/input.js | 1 + .../invalid-tuple-holes/options.json | 10 +++ .../invalid-tuple-holes/output.json | 0 .../invalid-type-bar-record/input.js | 0 .../invalid-type-bar-record/options.json | 11 +++ .../invalid-type-bar-tuple/input.js | 0 .../invalid-type-bar-tuple/options.json | 11 +++ .../invalid-type-hash-record/input.js | 1 + .../invalid-type-hash-record/options.json | 11 +++ .../invalid-type-hash-tuple/input.js | 1 + .../invalid-type-hash-tuple/options.json | 3 + .../not-enabled-bar}/input.js | 0 .../not-enabled-bar/options.json | 4 + .../not-enabled-hash/input.js | 1 + .../not-enabled-hash/options.json | 3 + .../record-and-tuple-babel-7/options.json | 3 + .../trailing-comma-comments/input.js | 2 + .../trailing-comma-comments/options.json | 10 +++ .../trailing-comma-comments/output.json | 0 .../tuple-trailing-comma/input.js | 1 + .../tuple-trailing-comma/options.json | 10 +++ .../tuple-trailing-comma/output.json | 0 .../as-jsx-attribute-value-bar/options.json | 3 - .../as-jsx-attribute-value-hash/options.json | 12 ++- .../record-and-tuple/bar-flow/options.json | 5 +- .../record-and-tuple/bar-flow/output.json | 90 ------------------- .../bar-yield-without-argument/options.json | 10 ++- .../record-and-tuple/bar/options.json | 10 ++- .../disambiguate-regex-hash/options.json | 12 ++- .../record-and-tuple/hash/options.json | 10 ++- .../options.json | 4 +- .../options.json | 4 +- .../invalid-private-key/options.json | 5 +- .../invalid-private-key/output.json | 46 ---------- .../invalid-property-initializer/options.json | 10 ++- .../invalid-record-method/options.json | 10 ++- .../invalid-record-proto/options.json | 10 ++- .../invalid-tuple-holes/options.json | 5 +- .../invalid-type-bar-record/options.json | 4 - .../invalid-type-bar-tuple/options.json | 4 - .../invalid-type-hash-record/options.json | 11 ++- .../invalid-type-hash-tuple/options.json | 3 +- .../record-and-tuple/options.json | 3 + .../trailing-comma-comments/options.json | 10 ++- .../tuple-trailing-comma/options.json | 10 ++- .../record-and-tuple/brace-bar/options.json | 4 - .../record-and-tuple/brace-bar/output.json | 66 -------------- .../record-and-tuple/brace-hash/options.json | 6 +- .../record-and-tuple/bracket-bar/input.js | 1 - .../record-and-tuple/bracket-bar/options.json | 4 - .../record-and-tuple/bracket-bar/output.json | 66 -------------- .../bracket-hash/options.json | 6 +- .../array-pattern-with-es-tuple/options.json | 5 +- .../options.json | 7 +- .../hack-caret/hash-tuple-babel-7/input.js | 2 + .../hash-tuple-babel-7/options.json | 7 ++ .../hack-caret/hash-tuple-babel-7/output.js | 2 + .../hack-caret/hash-tuple/options.json | 3 +- .../hash-tuple-babel-7/input.js | 2 + .../hash-tuple-babel-7/options.json | 7 ++ .../hash-tuple-babel-7/output.js | 2 + .../hack-double-at/hash-tuple/options.json | 3 +- .../hash-tuple-babel-7/input.js | 2 + .../hash-tuple-babel-7/options.json | 7 ++ .../hash-tuple-babel-7/output.js | 2 + .../hack-double-caret/hash-tuple/options.json | 3 +- .../hack-hash/hash-tuple-babel-7/input.js | 2 + .../hack-hash/hash-tuple-babel-7/options.json | 8 ++ .../hack-hash/hash-tuple/options.json | 5 +- .../hack-percent/hash-tuple-babel-7/input.js | 2 + .../hash-tuple-babel-7/options.json | 7 ++ .../hack-percent/hash-tuple-babel-7/output.js | 2 + .../hack-percent/hash-tuple/options.json | 3 +- .../smart/hash-tuple-babel-7/input.js | 2 + .../smart/hash-tuple-babel-7/options.json | 8 ++ .../fixtures/smart/hash-tuple/options.json | 5 +- .../import-polyfill-babel-7/commonjs/input.js | 8 ++ .../commonjs/options.json | 6 ++ .../commonjs/output.js | 9 ++ .../input.mjs | 8 ++ .../options.json | 6 ++ .../output.mjs | 8 ++ .../custom-name/input.mjs | 8 ++ .../custom-name/options.json | 7 ++ .../custom-name/output.mjs | 8 ++ .../default-name/input.mjs | 8 ++ .../default-name/options.json | 6 ++ .../default-name/output.mjs | 8 ++ .../import-polyfill-babel-7/options.json | 3 + .../import-polyfill/commonjs/options.json | 12 ++- .../options.json | 12 ++- .../import-polyfill/custom-name/options.json | 14 +-- .../import-polyfill/default-name/options.json | 12 ++- .../fixtures/import-polyfill/options.json | 3 + .../test/fixtures/syntax-babel-7/bar/input.js | 23 +++++ .../fixtures/syntax-babel-7/bar/options.json | 3 + .../{syntax => syntax-babel-7}/bar/output.js | 0 .../fixtures/syntax-babel-7/hash/input.js | 21 +++++ .../fixtures/syntax-babel-7/hash/options.json | 3 + .../{syntax => syntax-babel-7}/hash/output.js | 0 .../test/fixtures/syntax-babel-7/options.json | 3 + .../test/fixtures/syntax/bar/options.json | 3 +- .../test/fixtures/syntax/default/input.js | 21 +++++ .../test/fixtures/syntax/default/options.json | 3 + .../test/fixtures/syntax/default/output.js | 18 ++++ .../test/fixtures/syntax/hash/options.json | 3 +- .../test/fixtures/syntax/options.json | 3 + .../src/index.ts | 25 ++++-- .../babel-standalone/src/preset-stage-1.ts | 31 ++++--- .../babel-standalone/src/preset-stage-2.ts | 16 ++-- .../test/preset-stage-1.test.js | 3 +- packages/babel-traverse/test/path/isPure.js | 7 +- scripts/integration-tests/e2e-prettier.sh | 2 + 223 files changed, 1332 insertions(+), 445 deletions(-) create mode 100644 packages/babel-generator/test/fixtures/recordAndTuple/default/input.js create mode 100644 packages/babel-generator/test/fixtures/recordAndTuple/default/options.json create mode 100644 packages/babel-generator/test/fixtures/recordAndTuple/default/output.js create mode 100644 packages/babel-generator/test/fixtures/recordAndTuple/options.json rename packages/babel-generator/test/fixtures/{recordAndTupleSyntaxType => recordAndTupleSyntaxType-babel-7}/bar-record/input.js (100%) rename packages/babel-generator/test/fixtures/{recordAndTupleSyntaxType => recordAndTupleSyntaxType-babel-7}/bar-record/options.json (100%) rename packages/babel-generator/test/fixtures/{recordAndTupleSyntaxType => recordAndTupleSyntaxType-babel-7}/bar-record/output.js (100%) rename packages/babel-generator/test/fixtures/{recordAndTupleSyntaxType => recordAndTupleSyntaxType-babel-7}/bar-tuple/input.js (100%) rename packages/babel-generator/test/fixtures/{recordAndTupleSyntaxType => recordAndTupleSyntaxType-babel-7}/bar-tuple/options.json (100%) rename packages/babel-generator/test/fixtures/{recordAndTupleSyntaxType => recordAndTupleSyntaxType-babel-7}/bar-tuple/output.js (100%) rename packages/babel-generator/test/fixtures/{recordAndTupleSyntaxType => recordAndTupleSyntaxType-babel-7}/default/input.js (100%) rename packages/babel-generator/test/fixtures/{recordAndTupleSyntaxType => recordAndTupleSyntaxType-babel-7}/default/options.json (100%) rename packages/babel-generator/test/fixtures/{recordAndTupleSyntaxType => recordAndTupleSyntaxType-babel-7}/default/output.js (100%) rename packages/babel-generator/test/fixtures/{recordAndTupleSyntaxType => recordAndTupleSyntaxType-babel-7}/hash-record/input.js (100%) rename packages/babel-generator/test/fixtures/{recordAndTupleSyntaxType => recordAndTupleSyntaxType-babel-7}/hash-record/options.json (100%) rename packages/babel-generator/test/fixtures/{recordAndTupleSyntaxType => recordAndTupleSyntaxType-babel-7}/hash-record/output.js (100%) rename packages/babel-generator/test/fixtures/{recordAndTupleSyntaxType => recordAndTupleSyntaxType-babel-7}/hash-tuple/input.js (100%) rename packages/babel-generator/test/fixtures/{recordAndTupleSyntaxType => recordAndTupleSyntaxType-babel-7}/hash-tuple/options.json (100%) rename packages/babel-generator/test/fixtures/{recordAndTupleSyntaxType => recordAndTupleSyntaxType-babel-7}/hash-tuple/output.js (100%) rename packages/babel-generator/test/fixtures/{recordAndTupleSyntaxType => recordAndTupleSyntaxType-babel-7}/invalid-option/input.js (100%) rename packages/babel-generator/test/fixtures/{recordAndTupleSyntaxType => recordAndTupleSyntaxType-babel-7}/invalid-option/options.json (100%) rename packages/babel-generator/test/fixtures/{recordAndTupleSyntaxType => recordAndTupleSyntaxType-babel-7}/missing-option/input.js (100%) rename packages/babel-generator/test/fixtures/{recordAndTupleSyntaxType => recordAndTupleSyntaxType-babel-7}/missing-option/options.json (100%) rename packages/babel-generator/test/fixtures/{recordAndTupleSyntaxType => recordAndTupleSyntaxType-babel-7}/missing-option/output.js (100%) create mode 100644 packages/babel-generator/test/fixtures/recordAndTupleSyntaxType-babel-7/options.json rename packages/babel-generator/test/fixtures/sourcemaps/{bar-record-tuple => bar-record-tuple-babel-7}/input.js (100%) rename packages/babel-generator/test/fixtures/sourcemaps/{bar-record-tuple => bar-record-tuple-babel-7}/options.json (80%) rename packages/babel-generator/test/fixtures/sourcemaps/{bar-record-tuple => bar-record-tuple-babel-7}/output.js (100%) rename packages/babel-generator/test/fixtures/sourcemaps/{bar-record-tuple => bar-record-tuple-babel-7}/source-map.json (81%) create mode 100644 packages/babel-generator/test/fixtures/sourcemaps/hash-record-tuple-babel-7/input.js create mode 100644 packages/babel-generator/test/fixtures/sourcemaps/hash-record-tuple-babel-7/options.json create mode 100644 packages/babel-generator/test/fixtures/sourcemaps/hash-record-tuple-babel-7/output.js create mode 100644 packages/babel-generator/test/fixtures/sourcemaps/hash-record-tuple-babel-7/source-map.json rename packages/babel-parser/test/fixtures/experimental/module-blocks/{invalid-module-bracketBarL => invalid-module-bracketBarL-babel-7}/input.js (100%) rename packages/babel-parser/test/fixtures/experimental/module-blocks/{invalid-module-bracketBarL => invalid-module-bracketBarL-babel-7}/options.json (85%) create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-hash-tuple-babel-7/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-hash-tuple-babel-7/options.json rename packages/babel-parser/test/fixtures/experimental/pipeline-operator/{hack-percent-proposal-hash-tuple => hack-caret-proposal-hash-tuple-babel-7}/output.json (100%) create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-double-at-proposal-hash-tuple-babel-7/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-double-at-proposal-hash-tuple-babel-7/options.json create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-double-at-proposal-hash-tuple-babel-7/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-double-caret-proposal-hash-tuple-babel-7/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-double-caret-proposal-hash-tuple-babel-7/options.json create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-double-caret-proposal-hash-tuple-babel-7/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-hash-tuple-babel-7/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-hash-tuple-babel-7/options.json create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-hash-tuple-babel-7/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-hash-tuple-babel-7/options.json create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-hash-tuple-babel-7/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-hash-tuple-babel-7/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-hash-tuple-babel-7/options.json rename packages/babel-parser/test/fixtures/experimental/{record-and-tuple => record-and-tuple-babel-7}/as-jsx-attribute-value-bar/input.js (100%) create mode 100644 packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/as-jsx-attribute-value-bar/options.json rename packages/babel-parser/test/fixtures/experimental/{record-and-tuple => record-and-tuple-babel-7}/as-jsx-attribute-value-bar/output.json (100%) create mode 100644 packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/as-jsx-attribute-value-hash/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/as-jsx-attribute-value-hash/options.json rename packages/babel-parser/test/fixtures/experimental/{record-and-tuple => record-and-tuple-babel-7}/as-jsx-attribute-value-hash/output.json (100%) create mode 100644 packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/bar-flow/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/bar-flow/options.json create mode 100644 packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/bar-yield-without-argument/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/bar-yield-without-argument/options.json rename packages/babel-parser/test/fixtures/experimental/{record-and-tuple => record-and-tuple-babel-7}/bar-yield-without-argument/output.json (100%) create mode 100644 packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/bar/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/bar/options.json rename packages/babel-parser/test/fixtures/experimental/{record-and-tuple => record-and-tuple-babel-7}/bar/output.json (100%) create mode 100644 packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/default-hash/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/default-hash/options.json create mode 100644 packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/default-hash/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/disambiguate-regex-hash/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/disambiguate-regex-hash/options.json rename packages/babel-parser/test/fixtures/experimental/{record-and-tuple => record-and-tuple-babel-7}/disambiguate-regex-hash/output.json (100%) create mode 100644 packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/hash/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/hash/options.json rename packages/babel-parser/test/fixtures/experimental/{record-and-tuple => record-and-tuple-babel-7}/hash/output.json (100%) rename packages/babel-parser/test/fixtures/experimental/{record-and-tuple => record-and-tuple-babel-7}/incorrect-type-record-end-bar/input.js (100%) rename packages/babel-parser/test/fixtures/experimental/{record-and-tuple => record-and-tuple-babel-7}/incorrect-type-record-end-bar/options.json (99%) rename packages/babel-parser/test/fixtures/experimental/{record-and-tuple => record-and-tuple-babel-7}/incorrect-type-record-start-bar/input.js (100%) rename packages/babel-parser/test/fixtures/experimental/{record-and-tuple => record-and-tuple-babel-7}/incorrect-type-record-start-bar/options.json (99%) create mode 100644 packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/incorrect-type-record-start-hash/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/incorrect-type-record-start-hash/options.json rename packages/babel-parser/test/fixtures/experimental/{record-and-tuple => record-and-tuple-babel-7}/incorrect-type-tuple-end-bar/input.js (100%) rename packages/babel-parser/test/fixtures/experimental/{record-and-tuple => record-and-tuple-babel-7}/incorrect-type-tuple-end-bar/options.json (99%) rename packages/babel-parser/test/fixtures/experimental/{record-and-tuple => record-and-tuple-babel-7}/incorrect-type-tuple-start-bar/input.js (100%) rename packages/babel-parser/test/fixtures/experimental/{record-and-tuple => record-and-tuple-babel-7}/incorrect-type-tuple-start-bar/options.json (99%) create mode 100644 packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/incorrect-type-tuple-start-hash/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/incorrect-type-tuple-start-hash/options.json create mode 100644 packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/invalid-private-key/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/invalid-private-key/options.json create mode 100644 packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/invalid-property-initializer/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/invalid-property-initializer/options.json rename packages/babel-parser/test/fixtures/experimental/{record-and-tuple => record-and-tuple-babel-7}/invalid-property-initializer/output.json (100%) create mode 100644 packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/invalid-record-method/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/invalid-record-method/options.json rename packages/babel-parser/test/fixtures/experimental/{record-and-tuple => record-and-tuple-babel-7}/invalid-record-method/output.json (100%) create mode 100644 packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/invalid-record-proto/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/invalid-record-proto/options.json rename packages/babel-parser/test/fixtures/experimental/{record-and-tuple => record-and-tuple-babel-7}/invalid-record-proto/output.json (100%) create mode 100644 packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/invalid-tuple-holes/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/invalid-tuple-holes/options.json rename packages/babel-parser/test/fixtures/experimental/{record-and-tuple => record-and-tuple-babel-7}/invalid-tuple-holes/output.json (100%) rename packages/babel-parser/test/fixtures/experimental/{record-and-tuple => record-and-tuple-babel-7}/invalid-type-bar-record/input.js (100%) create mode 100644 packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/invalid-type-bar-record/options.json rename packages/babel-parser/test/fixtures/experimental/{record-and-tuple => record-and-tuple-babel-7}/invalid-type-bar-tuple/input.js (100%) create mode 100644 packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/invalid-type-bar-tuple/options.json create mode 100644 packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/invalid-type-hash-record/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/invalid-type-hash-record/options.json create mode 100644 packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/invalid-type-hash-tuple/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/invalid-type-hash-tuple/options.json rename packages/babel-parser/test/fixtures/{tokens/record-and-tuple/brace-bar => experimental/record-and-tuple-babel-7/not-enabled-bar}/input.js (100%) create mode 100644 packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/not-enabled-bar/options.json create mode 100644 packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/not-enabled-hash/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/not-enabled-hash/options.json create mode 100644 packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/options.json create mode 100644 packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/trailing-comma-comments/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/trailing-comma-comments/options.json rename packages/babel-parser/test/fixtures/experimental/{record-and-tuple => record-and-tuple-babel-7}/trailing-comma-comments/output.json (100%) create mode 100644 packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/tuple-trailing-comma/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/tuple-trailing-comma/options.json rename packages/babel-parser/test/fixtures/experimental/{record-and-tuple => record-and-tuple-babel-7}/tuple-trailing-comma/output.json (100%) delete mode 100644 packages/babel-parser/test/fixtures/experimental/record-and-tuple/as-jsx-attribute-value-bar/options.json delete mode 100644 packages/babel-parser/test/fixtures/experimental/record-and-tuple/bar-flow/output.json delete mode 100644 packages/babel-parser/test/fixtures/experimental/record-and-tuple/invalid-private-key/output.json delete mode 100644 packages/babel-parser/test/fixtures/experimental/record-and-tuple/invalid-type-bar-record/options.json delete mode 100644 packages/babel-parser/test/fixtures/experimental/record-and-tuple/invalid-type-bar-tuple/options.json create mode 100644 packages/babel-parser/test/fixtures/experimental/record-and-tuple/options.json delete mode 100644 packages/babel-parser/test/fixtures/tokens/record-and-tuple/brace-bar/options.json delete mode 100644 packages/babel-parser/test/fixtures/tokens/record-and-tuple/brace-bar/output.json delete mode 100644 packages/babel-parser/test/fixtures/tokens/record-and-tuple/bracket-bar/input.js delete mode 100644 packages/babel-parser/test/fixtures/tokens/record-and-tuple/bracket-bar/options.json delete mode 100644 packages/babel-parser/test/fixtures/tokens/record-and-tuple/bracket-bar/output.json create mode 100644 packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/hash-tuple-babel-7/input.js create mode 100644 packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/hash-tuple-babel-7/options.json create mode 100644 packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/hash-tuple-babel-7/output.js create mode 100644 packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-double-at/hash-tuple-babel-7/input.js create mode 100644 packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-double-at/hash-tuple-babel-7/options.json create mode 100644 packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-double-at/hash-tuple-babel-7/output.js create mode 100644 packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-double-caret/hash-tuple-babel-7/input.js create mode 100644 packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-double-caret/hash-tuple-babel-7/options.json create mode 100644 packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-double-caret/hash-tuple-babel-7/output.js create mode 100644 packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/hash-tuple-babel-7/input.js create mode 100644 packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/hash-tuple-babel-7/options.json create mode 100644 packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/hash-tuple-babel-7/input.js create mode 100644 packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/hash-tuple-babel-7/options.json create mode 100644 packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/hash-tuple-babel-7/output.js create mode 100644 packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/hash-tuple-babel-7/input.js create mode 100644 packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/hash-tuple-babel-7/options.json create mode 100644 packages/babel-plugin-proposal-record-and-tuple/test/fixtures/import-polyfill-babel-7/commonjs/input.js create mode 100644 packages/babel-plugin-proposal-record-and-tuple/test/fixtures/import-polyfill-babel-7/commonjs/options.json create mode 100644 packages/babel-plugin-proposal-record-and-tuple/test/fixtures/import-polyfill-babel-7/commonjs/output.js create mode 100644 packages/babel-plugin-proposal-record-and-tuple/test/fixtures/import-polyfill-babel-7/custom-name-implies-should-import/input.mjs create mode 100644 packages/babel-plugin-proposal-record-and-tuple/test/fixtures/import-polyfill-babel-7/custom-name-implies-should-import/options.json create mode 100644 packages/babel-plugin-proposal-record-and-tuple/test/fixtures/import-polyfill-babel-7/custom-name-implies-should-import/output.mjs create mode 100644 packages/babel-plugin-proposal-record-and-tuple/test/fixtures/import-polyfill-babel-7/custom-name/input.mjs create mode 100644 packages/babel-plugin-proposal-record-and-tuple/test/fixtures/import-polyfill-babel-7/custom-name/options.json create mode 100644 packages/babel-plugin-proposal-record-and-tuple/test/fixtures/import-polyfill-babel-7/custom-name/output.mjs create mode 100644 packages/babel-plugin-proposal-record-and-tuple/test/fixtures/import-polyfill-babel-7/default-name/input.mjs create mode 100644 packages/babel-plugin-proposal-record-and-tuple/test/fixtures/import-polyfill-babel-7/default-name/options.json create mode 100644 packages/babel-plugin-proposal-record-and-tuple/test/fixtures/import-polyfill-babel-7/default-name/output.mjs create mode 100644 packages/babel-plugin-proposal-record-and-tuple/test/fixtures/import-polyfill-babel-7/options.json create mode 100644 packages/babel-plugin-proposal-record-and-tuple/test/fixtures/import-polyfill/options.json create mode 100644 packages/babel-plugin-proposal-record-and-tuple/test/fixtures/syntax-babel-7/bar/input.js create mode 100644 packages/babel-plugin-proposal-record-and-tuple/test/fixtures/syntax-babel-7/bar/options.json rename packages/babel-plugin-proposal-record-and-tuple/test/fixtures/{syntax => syntax-babel-7}/bar/output.js (100%) create mode 100644 packages/babel-plugin-proposal-record-and-tuple/test/fixtures/syntax-babel-7/hash/input.js create mode 100644 packages/babel-plugin-proposal-record-and-tuple/test/fixtures/syntax-babel-7/hash/options.json rename packages/babel-plugin-proposal-record-and-tuple/test/fixtures/{syntax => syntax-babel-7}/hash/output.js (100%) create mode 100644 packages/babel-plugin-proposal-record-and-tuple/test/fixtures/syntax-babel-7/options.json create mode 100644 packages/babel-plugin-proposal-record-and-tuple/test/fixtures/syntax/default/input.js create mode 100644 packages/babel-plugin-proposal-record-and-tuple/test/fixtures/syntax/default/options.json create mode 100644 packages/babel-plugin-proposal-record-and-tuple/test/fixtures/syntax/default/output.js create mode 100644 packages/babel-plugin-proposal-record-and-tuple/test/fixtures/syntax/options.json diff --git a/eslint/babel-eslint-parser/test/index.js b/eslint/babel-eslint-parser/test/index.js index 7ed5ed9ee3cf..6c16e4f62b1a 100644 --- a/eslint/babel-eslint-parser/test/index.js +++ b/eslint/babel-eslint-parser/test/index.js @@ -3,7 +3,7 @@ import escope from "eslint-scope"; import unpad from "dedent"; import { parseForESLint as parseForESLintOriginal } from "../lib/index.cjs"; import { ESLint } from "eslint"; -import { itDummy, commonJS } from "$repo-utils"; +import { itDummy, commonJS, IS_BABEL_8, itBabel7 } from "$repo-utils"; function parseForESLint(code, options) { return parseForESLintOriginal(code, { @@ -382,7 +382,11 @@ describe("Babel and Espree", () => { babelOptions: { filename: "test.js", parserOpts: { - plugins: [["recordAndTuple", { syntaxType: "hash" }]], + plugins: [ + IS_BABEL_8() + ? "recordAndTuple" + : ["recordAndTuple", { syntaxType: "hash" }], + ], tokens: true, }, }, @@ -395,7 +399,7 @@ describe("Babel and Espree", () => { ); }); - it("brace and bracket bar operator (token)", () => { + itBabel7("brace and bracket bar operator (token)", () => { const code = "{||}; [||]"; const babylonAST = parseForESLint(code, { eslintVisitorKeys: true, diff --git a/packages/babel-generator/src/generators/types.ts b/packages/babel-generator/src/generators/types.ts index adc3355fe672..b92e49b5c25e 100644 --- a/packages/babel-generator/src/generators/types.ts +++ b/packages/babel-generator/src/generators/types.ts @@ -113,21 +113,26 @@ export function RecordExpression(this: Printer, node: t.RecordExpression) { let startToken; let endToken; - if (this.format.recordAndTupleSyntaxType === "bar") { - startToken = "{|"; - endToken = "|}"; - } else if ( - this.format.recordAndTupleSyntaxType !== "hash" && - this.format.recordAndTupleSyntaxType != null - ) { - throw new Error( - `The "recordAndTupleSyntaxType" generator option must be "bar" or "hash" (${JSON.stringify( - this.format.recordAndTupleSyntaxType, - )} received).`, - ); - } else { + if (process.env.BABEL_8_BREAKING) { startToken = "#{"; endToken = "}"; + } else { + if (this.format.recordAndTupleSyntaxType === "bar") { + startToken = "{|"; + endToken = "|}"; + } else if ( + this.format.recordAndTupleSyntaxType !== "hash" && + this.format.recordAndTupleSyntaxType != null + ) { + throw new Error( + `The "recordAndTupleSyntaxType" generator option must be "bar" or "hash" (${JSON.stringify( + this.format.recordAndTupleSyntaxType, + )} received).`, + ); + } else { + startToken = "#{"; + endToken = "}"; + } } this.token(startToken); @@ -146,16 +151,21 @@ export function TupleExpression(this: Printer, node: t.TupleExpression) { let startToken; let endToken; - if (this.format.recordAndTupleSyntaxType === "bar") { - startToken = "[|"; - endToken = "|]"; - } else if (this.format.recordAndTupleSyntaxType === "hash") { + if (process.env.BABEL_8_BREAKING) { startToken = "#["; endToken = "]"; } else { - throw new Error( - `${this.format.recordAndTupleSyntaxType} is not a valid recordAndTuple syntax type`, - ); + if (this.format.recordAndTupleSyntaxType === "bar") { + startToken = "[|"; + endToken = "|]"; + } else if (this.format.recordAndTupleSyntaxType === "hash") { + startToken = "#["; + endToken = "]"; + } else { + throw new Error( + `${this.format.recordAndTupleSyntaxType} is not a valid recordAndTuple syntax type`, + ); + } } this.token(startToken); diff --git a/packages/babel-generator/src/index.ts b/packages/babel-generator/src/index.ts index f76e553d4ae7..f9983cf9992e 100644 --- a/packages/babel-generator/src/index.ts +++ b/packages/babel-generator/src/index.ts @@ -44,7 +44,6 @@ function normalizeOptions( minimal: process.env.BABEL_8_BREAKING ? true : false, ...opts.jsescOption, }, - recordAndTupleSyntaxType: opts.recordAndTupleSyntaxType ?? "hash", topicToken: opts.topicToken, importAttributesKeyword: opts.importAttributesKeyword, }; @@ -52,6 +51,7 @@ function normalizeOptions( if (!process.env.BABEL_8_BREAKING) { format.decoratorsBeforeExport = opts.decoratorsBeforeExport; format.jsescOption.json = opts.jsonCompatibleStrings; + format.recordAndTupleSyntaxType = opts.recordAndTupleSyntaxType ?? "hash"; } if (format.minified) { @@ -190,6 +190,7 @@ export interface GeneratorOptions { /** * For use with the recordAndTuple token. + * @deprecated It will be removed in Babel 8. */ recordAndTupleSyntaxType?: RecordAndTuplePluginOptions["syntaxType"]; diff --git a/packages/babel-generator/src/printer.ts b/packages/babel-generator/src/printer.ts index e2d21741d8db..696a146a7ea4 100644 --- a/packages/babel-generator/src/printer.ts +++ b/packages/babel-generator/src/printer.ts @@ -60,7 +60,10 @@ export type Format = { adjustMultilineComment: boolean; style: string; }; - recordAndTupleSyntaxType: RecordAndTuplePluginOptions["syntaxType"]; + /** + * @deprecated Removed in Babel 8, syntax type is always 'hash' + */ + recordAndTupleSyntaxType?: RecordAndTuplePluginOptions["syntaxType"]; jsescOption: jsescOptions; /** * @deprecated Removed in Babel 8, use `jsescOption` instead diff --git a/packages/babel-generator/test/fixtures/recordAndTuple/default/input.js b/packages/babel-generator/test/fixtures/recordAndTuple/default/input.js new file mode 100644 index 000000000000..062cbf54bd7c --- /dev/null +++ b/packages/babel-generator/test/fixtures/recordAndTuple/default/input.js @@ -0,0 +1 @@ +#[#{}] \ No newline at end of file diff --git a/packages/babel-generator/test/fixtures/recordAndTuple/default/options.json b/packages/babel-generator/test/fixtures/recordAndTuple/default/options.json new file mode 100644 index 000000000000..4064c498b9bd --- /dev/null +++ b/packages/babel-generator/test/fixtures/recordAndTuple/default/options.json @@ -0,0 +1,3 @@ +{ + "plugins": [["recordAndTuple"]] +} diff --git a/packages/babel-generator/test/fixtures/recordAndTuple/default/output.js b/packages/babel-generator/test/fixtures/recordAndTuple/default/output.js new file mode 100644 index 000000000000..71d2c6b170bb --- /dev/null +++ b/packages/babel-generator/test/fixtures/recordAndTuple/default/output.js @@ -0,0 +1 @@ +#[#{}]; \ No newline at end of file diff --git a/packages/babel-generator/test/fixtures/recordAndTuple/options.json b/packages/babel-generator/test/fixtures/recordAndTuple/options.json new file mode 100644 index 000000000000..cbf6d1595427 --- /dev/null +++ b/packages/babel-generator/test/fixtures/recordAndTuple/options.json @@ -0,0 +1,3 @@ +{ + "BABEL_8_BREAKING": true +} diff --git a/packages/babel-generator/test/fixtures/recordAndTupleSyntaxType/bar-record/input.js b/packages/babel-generator/test/fixtures/recordAndTupleSyntaxType-babel-7/bar-record/input.js similarity index 100% rename from packages/babel-generator/test/fixtures/recordAndTupleSyntaxType/bar-record/input.js rename to packages/babel-generator/test/fixtures/recordAndTupleSyntaxType-babel-7/bar-record/input.js diff --git a/packages/babel-generator/test/fixtures/recordAndTupleSyntaxType/bar-record/options.json b/packages/babel-generator/test/fixtures/recordAndTupleSyntaxType-babel-7/bar-record/options.json similarity index 100% rename from packages/babel-generator/test/fixtures/recordAndTupleSyntaxType/bar-record/options.json rename to packages/babel-generator/test/fixtures/recordAndTupleSyntaxType-babel-7/bar-record/options.json diff --git a/packages/babel-generator/test/fixtures/recordAndTupleSyntaxType/bar-record/output.js b/packages/babel-generator/test/fixtures/recordAndTupleSyntaxType-babel-7/bar-record/output.js similarity index 100% rename from packages/babel-generator/test/fixtures/recordAndTupleSyntaxType/bar-record/output.js rename to packages/babel-generator/test/fixtures/recordAndTupleSyntaxType-babel-7/bar-record/output.js diff --git a/packages/babel-generator/test/fixtures/recordAndTupleSyntaxType/bar-tuple/input.js b/packages/babel-generator/test/fixtures/recordAndTupleSyntaxType-babel-7/bar-tuple/input.js similarity index 100% rename from packages/babel-generator/test/fixtures/recordAndTupleSyntaxType/bar-tuple/input.js rename to packages/babel-generator/test/fixtures/recordAndTupleSyntaxType-babel-7/bar-tuple/input.js diff --git a/packages/babel-generator/test/fixtures/recordAndTupleSyntaxType/bar-tuple/options.json b/packages/babel-generator/test/fixtures/recordAndTupleSyntaxType-babel-7/bar-tuple/options.json similarity index 100% rename from packages/babel-generator/test/fixtures/recordAndTupleSyntaxType/bar-tuple/options.json rename to packages/babel-generator/test/fixtures/recordAndTupleSyntaxType-babel-7/bar-tuple/options.json diff --git a/packages/babel-generator/test/fixtures/recordAndTupleSyntaxType/bar-tuple/output.js b/packages/babel-generator/test/fixtures/recordAndTupleSyntaxType-babel-7/bar-tuple/output.js similarity index 100% rename from packages/babel-generator/test/fixtures/recordAndTupleSyntaxType/bar-tuple/output.js rename to packages/babel-generator/test/fixtures/recordAndTupleSyntaxType-babel-7/bar-tuple/output.js diff --git a/packages/babel-generator/test/fixtures/recordAndTupleSyntaxType/default/input.js b/packages/babel-generator/test/fixtures/recordAndTupleSyntaxType-babel-7/default/input.js similarity index 100% rename from packages/babel-generator/test/fixtures/recordAndTupleSyntaxType/default/input.js rename to packages/babel-generator/test/fixtures/recordAndTupleSyntaxType-babel-7/default/input.js diff --git a/packages/babel-generator/test/fixtures/recordAndTupleSyntaxType/default/options.json b/packages/babel-generator/test/fixtures/recordAndTupleSyntaxType-babel-7/default/options.json similarity index 100% rename from packages/babel-generator/test/fixtures/recordAndTupleSyntaxType/default/options.json rename to packages/babel-generator/test/fixtures/recordAndTupleSyntaxType-babel-7/default/options.json diff --git a/packages/babel-generator/test/fixtures/recordAndTupleSyntaxType/default/output.js b/packages/babel-generator/test/fixtures/recordAndTupleSyntaxType-babel-7/default/output.js similarity index 100% rename from packages/babel-generator/test/fixtures/recordAndTupleSyntaxType/default/output.js rename to packages/babel-generator/test/fixtures/recordAndTupleSyntaxType-babel-7/default/output.js diff --git a/packages/babel-generator/test/fixtures/recordAndTupleSyntaxType/hash-record/input.js b/packages/babel-generator/test/fixtures/recordAndTupleSyntaxType-babel-7/hash-record/input.js similarity index 100% rename from packages/babel-generator/test/fixtures/recordAndTupleSyntaxType/hash-record/input.js rename to packages/babel-generator/test/fixtures/recordAndTupleSyntaxType-babel-7/hash-record/input.js diff --git a/packages/babel-generator/test/fixtures/recordAndTupleSyntaxType/hash-record/options.json b/packages/babel-generator/test/fixtures/recordAndTupleSyntaxType-babel-7/hash-record/options.json similarity index 100% rename from packages/babel-generator/test/fixtures/recordAndTupleSyntaxType/hash-record/options.json rename to packages/babel-generator/test/fixtures/recordAndTupleSyntaxType-babel-7/hash-record/options.json diff --git a/packages/babel-generator/test/fixtures/recordAndTupleSyntaxType/hash-record/output.js b/packages/babel-generator/test/fixtures/recordAndTupleSyntaxType-babel-7/hash-record/output.js similarity index 100% rename from packages/babel-generator/test/fixtures/recordAndTupleSyntaxType/hash-record/output.js rename to packages/babel-generator/test/fixtures/recordAndTupleSyntaxType-babel-7/hash-record/output.js diff --git a/packages/babel-generator/test/fixtures/recordAndTupleSyntaxType/hash-tuple/input.js b/packages/babel-generator/test/fixtures/recordAndTupleSyntaxType-babel-7/hash-tuple/input.js similarity index 100% rename from packages/babel-generator/test/fixtures/recordAndTupleSyntaxType/hash-tuple/input.js rename to packages/babel-generator/test/fixtures/recordAndTupleSyntaxType-babel-7/hash-tuple/input.js diff --git a/packages/babel-generator/test/fixtures/recordAndTupleSyntaxType/hash-tuple/options.json b/packages/babel-generator/test/fixtures/recordAndTupleSyntaxType-babel-7/hash-tuple/options.json similarity index 100% rename from packages/babel-generator/test/fixtures/recordAndTupleSyntaxType/hash-tuple/options.json rename to packages/babel-generator/test/fixtures/recordAndTupleSyntaxType-babel-7/hash-tuple/options.json diff --git a/packages/babel-generator/test/fixtures/recordAndTupleSyntaxType/hash-tuple/output.js b/packages/babel-generator/test/fixtures/recordAndTupleSyntaxType-babel-7/hash-tuple/output.js similarity index 100% rename from packages/babel-generator/test/fixtures/recordAndTupleSyntaxType/hash-tuple/output.js rename to packages/babel-generator/test/fixtures/recordAndTupleSyntaxType-babel-7/hash-tuple/output.js diff --git a/packages/babel-generator/test/fixtures/recordAndTupleSyntaxType/invalid-option/input.js b/packages/babel-generator/test/fixtures/recordAndTupleSyntaxType-babel-7/invalid-option/input.js similarity index 100% rename from packages/babel-generator/test/fixtures/recordAndTupleSyntaxType/invalid-option/input.js rename to packages/babel-generator/test/fixtures/recordAndTupleSyntaxType-babel-7/invalid-option/input.js diff --git a/packages/babel-generator/test/fixtures/recordAndTupleSyntaxType/invalid-option/options.json b/packages/babel-generator/test/fixtures/recordAndTupleSyntaxType-babel-7/invalid-option/options.json similarity index 100% rename from packages/babel-generator/test/fixtures/recordAndTupleSyntaxType/invalid-option/options.json rename to packages/babel-generator/test/fixtures/recordAndTupleSyntaxType-babel-7/invalid-option/options.json diff --git a/packages/babel-generator/test/fixtures/recordAndTupleSyntaxType/missing-option/input.js b/packages/babel-generator/test/fixtures/recordAndTupleSyntaxType-babel-7/missing-option/input.js similarity index 100% rename from packages/babel-generator/test/fixtures/recordAndTupleSyntaxType/missing-option/input.js rename to packages/babel-generator/test/fixtures/recordAndTupleSyntaxType-babel-7/missing-option/input.js diff --git a/packages/babel-generator/test/fixtures/recordAndTupleSyntaxType/missing-option/options.json b/packages/babel-generator/test/fixtures/recordAndTupleSyntaxType-babel-7/missing-option/options.json similarity index 100% rename from packages/babel-generator/test/fixtures/recordAndTupleSyntaxType/missing-option/options.json rename to packages/babel-generator/test/fixtures/recordAndTupleSyntaxType-babel-7/missing-option/options.json diff --git a/packages/babel-generator/test/fixtures/recordAndTupleSyntaxType/missing-option/output.js b/packages/babel-generator/test/fixtures/recordAndTupleSyntaxType-babel-7/missing-option/output.js similarity index 100% rename from packages/babel-generator/test/fixtures/recordAndTupleSyntaxType/missing-option/output.js rename to packages/babel-generator/test/fixtures/recordAndTupleSyntaxType-babel-7/missing-option/output.js diff --git a/packages/babel-generator/test/fixtures/recordAndTupleSyntaxType-babel-7/options.json b/packages/babel-generator/test/fixtures/recordAndTupleSyntaxType-babel-7/options.json new file mode 100644 index 000000000000..29a3f0e84167 --- /dev/null +++ b/packages/babel-generator/test/fixtures/recordAndTupleSyntaxType-babel-7/options.json @@ -0,0 +1,3 @@ +{ + "BABEL_8_BREAKING": false +} diff --git a/packages/babel-generator/test/fixtures/sourcemaps/bar-record-tuple/input.js b/packages/babel-generator/test/fixtures/sourcemaps/bar-record-tuple-babel-7/input.js similarity index 100% rename from packages/babel-generator/test/fixtures/sourcemaps/bar-record-tuple/input.js rename to packages/babel-generator/test/fixtures/sourcemaps/bar-record-tuple-babel-7/input.js diff --git a/packages/babel-generator/test/fixtures/sourcemaps/bar-record-tuple/options.json b/packages/babel-generator/test/fixtures/sourcemaps/bar-record-tuple-babel-7/options.json similarity index 80% rename from packages/babel-generator/test/fixtures/sourcemaps/bar-record-tuple/options.json rename to packages/babel-generator/test/fixtures/sourcemaps/bar-record-tuple-babel-7/options.json index d2821ea96086..d0df0d292f30 100644 --- a/packages/babel-generator/test/fixtures/sourcemaps/bar-record-tuple/options.json +++ b/packages/babel-generator/test/fixtures/sourcemaps/bar-record-tuple-babel-7/options.json @@ -1,4 +1,5 @@ { + "BABEL_8_BREAKING": false, "recordAndTupleSyntaxType": "bar", "plugins": [["recordAndTuple", { "syntaxType": "bar" }]], "sourceMaps": true diff --git a/packages/babel-generator/test/fixtures/sourcemaps/bar-record-tuple/output.js b/packages/babel-generator/test/fixtures/sourcemaps/bar-record-tuple-babel-7/output.js similarity index 100% rename from packages/babel-generator/test/fixtures/sourcemaps/bar-record-tuple/output.js rename to packages/babel-generator/test/fixtures/sourcemaps/bar-record-tuple-babel-7/output.js diff --git a/packages/babel-generator/test/fixtures/sourcemaps/bar-record-tuple/source-map.json b/packages/babel-generator/test/fixtures/sourcemaps/bar-record-tuple-babel-7/source-map.json similarity index 81% rename from packages/babel-generator/test/fixtures/sourcemaps/bar-record-tuple/source-map.json rename to packages/babel-generator/test/fixtures/sourcemaps/bar-record-tuple-babel-7/source-map.json index 4f59319dc841..1cf152b67bbe 100644 --- a/packages/babel-generator/test/fixtures/sourcemaps/bar-record-tuple/source-map.json +++ b/packages/babel-generator/test/fixtures/sourcemaps/bar-record-tuple-babel-7/source-map.json @@ -5,7 +5,7 @@ "b" ], "sources": [ - "fixtures/sourcemaps/bar-record-tuple/input.js" + "fixtures/sourcemaps/bar-record-tuple-babel-7/input.js" ], "sourcesContent": [ "let a = [| 1 |];\nlet b = {| a: 1 |};" diff --git a/packages/babel-generator/test/fixtures/sourcemaps/hash-record-tuple-babel-7/input.js b/packages/babel-generator/test/fixtures/sourcemaps/hash-record-tuple-babel-7/input.js new file mode 100644 index 000000000000..8f3d3da881b1 --- /dev/null +++ b/packages/babel-generator/test/fixtures/sourcemaps/hash-record-tuple-babel-7/input.js @@ -0,0 +1,2 @@ +let a = #[1, 2, 3]; +let b = #{a: 1, b: 2, c: 3}; diff --git a/packages/babel-generator/test/fixtures/sourcemaps/hash-record-tuple-babel-7/options.json b/packages/babel-generator/test/fixtures/sourcemaps/hash-record-tuple-babel-7/options.json new file mode 100644 index 000000000000..cb26b748b0be --- /dev/null +++ b/packages/babel-generator/test/fixtures/sourcemaps/hash-record-tuple-babel-7/options.json @@ -0,0 +1,6 @@ +{ + "BABEL_8_BREAKING": false, + "recordAndTupleSyntaxType": "hash", + "plugins": [["recordAndTuple", { "syntaxType": "hash" }]], + "sourceMaps": true +} diff --git a/packages/babel-generator/test/fixtures/sourcemaps/hash-record-tuple-babel-7/output.js b/packages/babel-generator/test/fixtures/sourcemaps/hash-record-tuple-babel-7/output.js new file mode 100644 index 000000000000..984d0f9461d5 --- /dev/null +++ b/packages/babel-generator/test/fixtures/sourcemaps/hash-record-tuple-babel-7/output.js @@ -0,0 +1,6 @@ +let a = #[1, 2, 3]; +let b = #{ + a: 1, + b: 2, + c: 3 +}; \ No newline at end of file diff --git a/packages/babel-generator/test/fixtures/sourcemaps/hash-record-tuple-babel-7/source-map.json b/packages/babel-generator/test/fixtures/sourcemaps/hash-record-tuple-babel-7/source-map.json new file mode 100644 index 000000000000..804d5c4de817 --- /dev/null +++ b/packages/babel-generator/test/fixtures/sourcemaps/hash-record-tuple-babel-7/source-map.json @@ -0,0 +1,16 @@ +{ + "version": 3, + "names": [ + "a", + "b", + "c" + ], + "sources": [ + "fixtures/sourcemaps/hash-record-tuple-babel-7/input.js" + ], + "sourcesContent": [ + "let a = #[1, 2, 3];\nlet b = #{a: 1, b: 2, c: 3};" + ], + "mappings": "AAAA,IAAIA,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;AAClB,IAAIC,CAAC,GAAG;EAAED,CAAC,EAAE,CAAC;EAAEC,CAAC,EAAE,CAAC;EAAEC,CAAC,EAAE;AAAC,CAAC", + "ignoreList": [] +} \ No newline at end of file diff --git a/packages/babel-generator/test/fixtures/sourcemaps/hash-record-tuple/options.json b/packages/babel-generator/test/fixtures/sourcemaps/hash-record-tuple/options.json index 46b9d494bf8a..29d723e47a51 100644 --- a/packages/babel-generator/test/fixtures/sourcemaps/hash-record-tuple/options.json +++ b/packages/babel-generator/test/fixtures/sourcemaps/hash-record-tuple/options.json @@ -1,5 +1,6 @@ { + "BABEL_8_BREAKING": true, "recordAndTupleSyntaxType": "hash", - "plugins": [["recordAndTuple", { "syntaxType": "hash" }]], + "plugins": [["recordAndTuple"]], "sourceMaps": true } diff --git a/packages/babel-parser/src/plugin-utils.ts b/packages/babel-parser/src/plugin-utils.ts index d8ad0050b133..7964da009995 100644 --- a/packages/babel-parser/src/plugin-utils.ts +++ b/packages/babel-parser/src/plugin-utils.ts @@ -72,7 +72,6 @@ export function getPluginOption< const PIPELINE_PROPOSALS = ["minimal", "fsharp", "hack", "smart"]; const TOPIC_TOKENS = ["^^", "@@", "^", "%", "#"]; -const RECORD_AND_TUPLE_SYNTAX_TYPES = ["hash", "bar"]; export function validatePlugins(plugins: PluginList) { if (hasPlugin(plugins, "decorators")) { @@ -127,10 +126,13 @@ export function validatePlugins(plugins: PluginList) { ); } - const tupleSyntaxIsHash = hasPlugin(plugins, [ - "recordAndTuple", - { syntaxType: "hash" }, - ]); + const recordAndTupleConfigItem: + | "recordAndTuple" + | ["recordAndTuple", { syntaxType: "hash" }] = process.env + .BABEL_8_BREAKING + ? "recordAndTuple" + : ["recordAndTuple", { syntaxType: "hash" }]; + const tupleSyntaxIsHash = hasPlugin(plugins, recordAndTupleConfigItem); if (proposal === "hack") { if (hasPlugin(plugins, "placeholders")) { @@ -161,12 +163,12 @@ export function validatePlugins(plugins: PluginList) { if (topicToken === "#" && tupleSyntaxIsHash) { throw new Error( - 'Plugin conflict between `["pipelineOperator", { proposal: "hack", topicToken: "#" }]` and `["recordAndtuple", { syntaxType: "hash"}]`.', + `Plugin conflict between \`["pipelineOperator", { proposal: "hack", topicToken: "#" }]\` and \`${JSON.stringify(recordAndTupleConfigItem)}\`.`, ); } } else if (proposal === "smart" && tupleSyntaxIsHash) { throw new Error( - 'Plugin conflict between `["pipelineOperator", { proposal: "smart" }]` and `["recordAndtuple", { syntaxType: "hash"}]`.', + `Plugin conflict between \`["pipelineOperator", { proposal: "smart" }]\` and \`${JSON.stringify(recordAndTupleConfigItem)}\`.`, ); } } @@ -208,17 +210,29 @@ export function validatePlugins(plugins: PluginList) { ); } - if ( - hasPlugin(plugins, "recordAndTuple") && - getPluginOption(plugins, "recordAndTuple", "syntaxType") != null && - !RECORD_AND_TUPLE_SYNTAX_TYPES.includes( - getPluginOption(plugins, "recordAndTuple", "syntaxType"), - ) - ) { - throw new Error( - "The 'syntaxType' option of the 'recordAndTuple' plugin must be one of: " + - RECORD_AND_TUPLE_SYNTAX_TYPES.map(p => `'${p}'`).join(", "), - ); + if (hasPlugin(plugins, "recordAndTuple")) { + const syntaxType = getPluginOption(plugins, "recordAndTuple", "syntaxType"); + if (syntaxType != null) { + if (process.env.BABEL_8_BREAKING) { + if (syntaxType === "hash") { + throw new Error( + 'The syntaxType option is no longer required in Babel 8. You can safely remove { syntaxType: "hash" } from the recordAndTuple config.', + ); + } else { + throw new Error( + 'The syntaxType option is no longer required in Babel 8. Please remove { syntaxType: "bar" } from the recordAndTuple config and migrate to the hash syntax #{} and #[].', + ); + } + } else { + const RECORD_AND_TUPLE_SYNTAX_TYPES = ["hash", "bar"]; + if (!RECORD_AND_TUPLE_SYNTAX_TYPES.includes(syntaxType)) { + throw new Error( + "The 'syntaxType' option of the 'recordAndTuple' plugin must be one of: " + + RECORD_AND_TUPLE_SYNTAX_TYPES.map(p => `'${p}'`).join(", "), + ); + } + } + } } if ( diff --git a/packages/babel-parser/src/tokenizer/index.ts b/packages/babel-parser/src/tokenizer/index.ts index 99369d48bbf0..751c6a851c48 100644 --- a/packages/babel-parser/src/tokenizer/index.ts +++ b/packages/babel-parser/src/tokenizer/index.ts @@ -515,7 +515,10 @@ export default abstract class Tokenizer extends CommentsParser { // which is not allowed in the spec. Throwing expecting recordAndTuple is // misleading this.expectPlugin("recordAndTuple"); - if (this.getPluginOption("recordAndTuple", "syntaxType") === "bar") { + if ( + !process.env.BABEL_8_BREAKING && + this.getPluginOption("recordAndTuple", "syntaxType") === "bar" + ) { throw this.raise( next === charCodes.leftCurlyBrace ? Errors.RecordExpressionHashIncorrectStartSyntaxType @@ -640,6 +643,7 @@ export default abstract class Tokenizer extends CommentsParser { } // '|}' if ( + !process.env.BABEL_8_BREAKING && this.hasPlugin("recordAndTuple") && next === charCodes.rightCurlyBrace ) { @@ -656,6 +660,7 @@ export default abstract class Tokenizer extends CommentsParser { // '|]' if ( + !process.env.BABEL_8_BREAKING && this.hasPlugin("recordAndTuple") && next === charCodes.rightSquareBracket ) { @@ -872,6 +877,7 @@ export default abstract class Tokenizer extends CommentsParser { return; case charCodes.leftSquareBracket: if ( + !process.env.BABEL_8_BREAKING && this.hasPlugin("recordAndTuple") && this.input.charCodeAt(this.state.pos + 1) === charCodes.verticalBar ) { @@ -896,6 +902,7 @@ export default abstract class Tokenizer extends CommentsParser { return; case charCodes.leftCurlyBrace: if ( + !process.env.BABEL_8_BREAKING && this.hasPlugin("recordAndTuple") && this.input.charCodeAt(this.state.pos + 1) === charCodes.verticalBar ) { diff --git a/packages/babel-parser/test/fixtures/experimental/module-blocks/invalid-module-bracketBarL/input.js b/packages/babel-parser/test/fixtures/experimental/module-blocks/invalid-module-bracketBarL-babel-7/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/module-blocks/invalid-module-bracketBarL/input.js rename to packages/babel-parser/test/fixtures/experimental/module-blocks/invalid-module-bracketBarL-babel-7/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/module-blocks/invalid-module-bracketBarL/options.json b/packages/babel-parser/test/fixtures/experimental/module-blocks/invalid-module-bracketBarL-babel-7/options.json similarity index 85% rename from packages/babel-parser/test/fixtures/experimental/module-blocks/invalid-module-bracketBarL/options.json rename to packages/babel-parser/test/fixtures/experimental/module-blocks/invalid-module-bracketBarL-babel-7/options.json index 29c947b341b5..363fa761c38a 100644 --- a/packages/babel-parser/test/fixtures/experimental/module-blocks/invalid-module-bracketBarL/options.json +++ b/packages/babel-parser/test/fixtures/experimental/module-blocks/invalid-module-bracketBarL-babel-7/options.json @@ -1,4 +1,5 @@ { + "BABEL_8_BREAKING": false, "plugins": [ "moduleBlocks", [ diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-hash-tuple-babel-7/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-hash-tuple-babel-7/input.js new file mode 100644 index 000000000000..c9cafc96318d --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-hash-tuple-babel-7/input.js @@ -0,0 +1,2 @@ +#[0]; +1 |> #[0, ^]; diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-hash-tuple-babel-7/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-hash-tuple-babel-7/options.json new file mode 100644 index 000000000000..53fa6f57557a --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-hash-tuple-babel-7/options.json @@ -0,0 +1,18 @@ +{ + "BABEL_8_BREAKING": false, + "plugins": [ + [ + "pipelineOperator", + { + "proposal": "hack", + "topicToken": "^" + } + ], + [ + "recordAndTuple", + { + "syntaxType": "hash" + } + ] + ] +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-hash-tuple/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-hash-tuple-babel-7/output.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-hash-tuple/output.json rename to packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-hash-tuple-babel-7/output.json diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-hash-tuple/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-hash-tuple/options.json index e36d4a74acbc..db822f329f01 100644 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-hash-tuple/options.json +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-caret-proposal-hash-tuple/options.json @@ -1,6 +1,15 @@ { + "BABEL_8_BREAKING": true, "plugins": [ - ["pipelineOperator", { "proposal": "hack", "topicToken": "^" }], - ["recordAndTuple", { "syntaxType": "hash" }] + [ + "pipelineOperator", + { + "proposal": "hack", + "topicToken": "^" + } + ], + [ + "recordAndTuple" + ] ] } diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-double-at-proposal-hash-tuple-babel-7/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-double-at-proposal-hash-tuple-babel-7/input.js new file mode 100644 index 000000000000..81a3b28d74df --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-double-at-proposal-hash-tuple-babel-7/input.js @@ -0,0 +1,2 @@ +#[0]; +1 |> #[0, @@]; diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-double-at-proposal-hash-tuple-babel-7/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-double-at-proposal-hash-tuple-babel-7/options.json new file mode 100644 index 000000000000..d818a2dac134 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-double-at-proposal-hash-tuple-babel-7/options.json @@ -0,0 +1,18 @@ +{ + "BABEL_8_BREAKING": false, + "plugins": [ + [ + "pipelineOperator", + { + "proposal": "hack", + "topicToken": "@@" + } + ], + [ + "recordAndTuple", + { + "syntaxType": "hash" + } + ] + ] +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-double-at-proposal-hash-tuple-babel-7/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-double-at-proposal-hash-tuple-babel-7/output.json new file mode 100644 index 000000000000..03adb0307161 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-double-at-proposal-hash-tuple-babel-7/output.json @@ -0,0 +1,69 @@ +{ + "type": "File", + "start":0,"end":20,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":14,"index":20}}, + "program": { + "type": "Program", + "start":0,"end":20,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":14,"index":20}}, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start":0,"end":5,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":5,"index":5}}, + "expression": { + "type": "TupleExpression", + "start":0,"end":4,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":4,"index":4}}, + "elements": [ + { + "type": "NumericLiteral", + "start":2,"end":3,"loc":{"start":{"line":1,"column":2,"index":2},"end":{"line":1,"column":3,"index":3}}, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + } + ] + } + }, + { + "type": "ExpressionStatement", + "start":6,"end":20,"loc":{"start":{"line":2,"column":0,"index":6},"end":{"line":2,"column":14,"index":20}}, + "expression": { + "type": "BinaryExpression", + "start":6,"end":19,"loc":{"start":{"line":2,"column":0,"index":6},"end":{"line":2,"column":13,"index":19}}, + "left": { + "type": "NumericLiteral", + "start":6,"end":7,"loc":{"start":{"line":2,"column":0,"index":6},"end":{"line":2,"column":1,"index":7}}, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + }, + "operator": "|>", + "right": { + "type": "TupleExpression", + "start":11,"end":19,"loc":{"start":{"line":2,"column":5,"index":11},"end":{"line":2,"column":13,"index":19}}, + "elements": [ + { + "type": "NumericLiteral", + "start":13,"end":14,"loc":{"start":{"line":2,"column":7,"index":13},"end":{"line":2,"column":8,"index":14}}, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + }, + { + "type": "TopicReference", + "start":16,"end":18,"loc":{"start":{"line":2,"column":10,"index":16},"end":{"line":2,"column":12,"index":18}} + } + ] + } + } + } + ], + "directives": [] + } +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-double-at-proposal-hash-tuple/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-double-at-proposal-hash-tuple/options.json index 116be78612f4..5af8446e1af5 100644 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-double-at-proposal-hash-tuple/options.json +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-double-at-proposal-hash-tuple/options.json @@ -1,6 +1,15 @@ { + "BABEL_8_BREAKING": true, "plugins": [ - ["pipelineOperator", { "proposal": "hack", "topicToken": "@@" }], - ["recordAndTuple", { "syntaxType": "hash" }] + [ + "pipelineOperator", + { + "proposal": "hack", + "topicToken": "@@" + } + ], + [ + "recordAndTuple" + ] ] } diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-double-caret-proposal-hash-tuple-babel-7/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-double-caret-proposal-hash-tuple-babel-7/input.js new file mode 100644 index 000000000000..5a6ea279ee6f --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-double-caret-proposal-hash-tuple-babel-7/input.js @@ -0,0 +1,2 @@ +#[0]; +1 |> #[0, ^^]; diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-double-caret-proposal-hash-tuple-babel-7/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-double-caret-proposal-hash-tuple-babel-7/options.json new file mode 100644 index 000000000000..14900237ea7c --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-double-caret-proposal-hash-tuple-babel-7/options.json @@ -0,0 +1,18 @@ +{ + "BABEL_8_BREAKING": false, + "plugins": [ + [ + "pipelineOperator", + { + "proposal": "hack", + "topicToken": "^^" + } + ], + [ + "recordAndTuple", + { + "syntaxType": "hash" + } + ] + ] +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-double-caret-proposal-hash-tuple-babel-7/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-double-caret-proposal-hash-tuple-babel-7/output.json new file mode 100644 index 000000000000..03adb0307161 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-double-caret-proposal-hash-tuple-babel-7/output.json @@ -0,0 +1,69 @@ +{ + "type": "File", + "start":0,"end":20,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":14,"index":20}}, + "program": { + "type": "Program", + "start":0,"end":20,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":14,"index":20}}, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start":0,"end":5,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":5,"index":5}}, + "expression": { + "type": "TupleExpression", + "start":0,"end":4,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":4,"index":4}}, + "elements": [ + { + "type": "NumericLiteral", + "start":2,"end":3,"loc":{"start":{"line":1,"column":2,"index":2},"end":{"line":1,"column":3,"index":3}}, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + } + ] + } + }, + { + "type": "ExpressionStatement", + "start":6,"end":20,"loc":{"start":{"line":2,"column":0,"index":6},"end":{"line":2,"column":14,"index":20}}, + "expression": { + "type": "BinaryExpression", + "start":6,"end":19,"loc":{"start":{"line":2,"column":0,"index":6},"end":{"line":2,"column":13,"index":19}}, + "left": { + "type": "NumericLiteral", + "start":6,"end":7,"loc":{"start":{"line":2,"column":0,"index":6},"end":{"line":2,"column":1,"index":7}}, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + }, + "operator": "|>", + "right": { + "type": "TupleExpression", + "start":11,"end":19,"loc":{"start":{"line":2,"column":5,"index":11},"end":{"line":2,"column":13,"index":19}}, + "elements": [ + { + "type": "NumericLiteral", + "start":13,"end":14,"loc":{"start":{"line":2,"column":7,"index":13},"end":{"line":2,"column":8,"index":14}}, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + }, + { + "type": "TopicReference", + "start":16,"end":18,"loc":{"start":{"line":2,"column":10,"index":16},"end":{"line":2,"column":12,"index":18}} + } + ] + } + } + } + ], + "directives": [] + } +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-double-caret-proposal-hash-tuple/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-double-caret-proposal-hash-tuple/options.json index 16ae6a6075f2..765231e487e1 100644 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-double-caret-proposal-hash-tuple/options.json +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-double-caret-proposal-hash-tuple/options.json @@ -1,6 +1,15 @@ { + "BABEL_8_BREAKING": true, "plugins": [ - ["pipelineOperator", { "proposal": "hack", "topicToken": "^^" }], - ["recordAndTuple", { "syntaxType": "hash" }] + [ + "pipelineOperator", + { + "proposal": "hack", + "topicToken": "^^" + } + ], + [ + "recordAndTuple" + ] ] } diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-hash-tuple-babel-7/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-hash-tuple-babel-7/input.js new file mode 100644 index 000000000000..eb22843797b1 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-hash-tuple-babel-7/input.js @@ -0,0 +1,2 @@ +#[0]; +1 |> #[0]; diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-hash-tuple-babel-7/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-hash-tuple-babel-7/options.json new file mode 100644 index 000000000000..bea58a640abf --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-hash-tuple-babel-7/options.json @@ -0,0 +1,19 @@ +{ + "BABEL_8_BREAKING": false, + "plugins": [ + [ + "pipelineOperator", + { + "proposal": "hack", + "topicToken": "#" + } + ], + [ + "recordAndTuple", + { + "syntaxType": "hash" + } + ] + ], + "throws": "Plugin conflict between `[\"pipelineOperator\", { proposal: \"hack\", topicToken: \"#\" }]` and `[\"recordAndTuple\",{\"syntaxType\":\"hash\"}]`." +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-hash-tuple/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-hash-tuple/options.json index 12e635d49913..3f684f76811d 100644 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-hash-tuple/options.json +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-hash-proposal-hash-tuple/options.json @@ -1,7 +1,16 @@ { + "BABEL_8_BREAKING": true, "plugins": [ - ["pipelineOperator", { "proposal": "hack", "topicToken": "#" }], - ["recordAndTuple", { "syntaxType": "hash" }] + [ + "pipelineOperator", + { + "proposal": "hack", + "topicToken": "#" + } + ], + [ + "recordAndTuple" + ] ], - "throws": "Plugin conflict between `[\"pipelineOperator\", { proposal: \"hack\", topicToken: \"#\" }]` and `[\"recordAndtuple\", { syntaxType: \"hash\"}]`." + "throws": "Plugin conflict between `[\"pipelineOperator\", { proposal: \"hack\", topicToken: \"#\" }]` and `\"recordAndTuple\"`." } diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-hash-tuple-babel-7/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-hash-tuple-babel-7/input.js new file mode 100644 index 000000000000..dd96171689d2 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-hash-tuple-babel-7/input.js @@ -0,0 +1,2 @@ +#[0]; +1 |> #[0, %]; diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-hash-tuple-babel-7/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-hash-tuple-babel-7/options.json new file mode 100644 index 000000000000..5e7612e1882b --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-hash-tuple-babel-7/options.json @@ -0,0 +1,18 @@ +{ + "BABEL_8_BREAKING": false, + "plugins": [ + [ + "pipelineOperator", + { + "proposal": "hack", + "topicToken": "%" + } + ], + [ + "recordAndTuple", + { + "syntaxType": "hash" + } + ] + ] +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-hash-tuple-babel-7/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-hash-tuple-babel-7/output.json new file mode 100644 index 000000000000..5572d34eef39 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-hash-tuple-babel-7/output.json @@ -0,0 +1,69 @@ +{ + "type": "File", + "start":0,"end":19,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":13,"index":19}}, + "program": { + "type": "Program", + "start":0,"end":19,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":13,"index":19}}, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start":0,"end":5,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":5,"index":5}}, + "expression": { + "type": "TupleExpression", + "start":0,"end":4,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":4,"index":4}}, + "elements": [ + { + "type": "NumericLiteral", + "start":2,"end":3,"loc":{"start":{"line":1,"column":2,"index":2},"end":{"line":1,"column":3,"index":3}}, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + } + ] + } + }, + { + "type": "ExpressionStatement", + "start":6,"end":19,"loc":{"start":{"line":2,"column":0,"index":6},"end":{"line":2,"column":13,"index":19}}, + "expression": { + "type": "BinaryExpression", + "start":6,"end":18,"loc":{"start":{"line":2,"column":0,"index":6},"end":{"line":2,"column":12,"index":18}}, + "left": { + "type": "NumericLiteral", + "start":6,"end":7,"loc":{"start":{"line":2,"column":0,"index":6},"end":{"line":2,"column":1,"index":7}}, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + }, + "operator": "|>", + "right": { + "type": "TupleExpression", + "start":11,"end":18,"loc":{"start":{"line":2,"column":5,"index":11},"end":{"line":2,"column":12,"index":18}}, + "elements": [ + { + "type": "NumericLiteral", + "start":13,"end":14,"loc":{"start":{"line":2,"column":7,"index":13},"end":{"line":2,"column":8,"index":14}}, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + }, + { + "type": "TopicReference", + "start":16,"end":17,"loc":{"start":{"line":2,"column":10,"index":16},"end":{"line":2,"column":11,"index":17}} + } + ] + } + } + } + ], + "directives": [] + } +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-hash-tuple/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-hash-tuple/options.json index d2463c4b8271..0a09d8fa454a 100644 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-hash-tuple/options.json +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/hack-percent-proposal-hash-tuple/options.json @@ -1,6 +1,19 @@ { + "BABEL_8_BREAKING": true, "plugins": [ - ["pipelineOperator", { "proposal": "hack", "topicToken": "%" }], - ["recordAndTuple", { "syntaxType": "hash" }] - ] + [ + "pipelineOperator", + { + "proposal": "hack", + "topicToken": "%" + } + ], + [ + "recordAndTuple", + { + "syntaxType": "hash" + } + ] + ], + "throws": "The syntaxType option is no longer required in Babel 8. You can safely remove { syntaxType: \"hash\" } from the recordAndTuple config." } diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-hash-tuple-babel-7/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-hash-tuple-babel-7/input.js new file mode 100644 index 000000000000..eb22843797b1 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-hash-tuple-babel-7/input.js @@ -0,0 +1,2 @@ +#[0]; +1 |> #[0]; diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-hash-tuple-babel-7/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-hash-tuple-babel-7/options.json new file mode 100644 index 000000000000..601e01de7545 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-hash-tuple-babel-7/options.json @@ -0,0 +1,18 @@ +{ + "BABEL_8_BREAKING": false, + "plugins": [ + [ + "pipelineOperator", + { + "proposal": "smart" + } + ], + [ + "recordAndTuple", + { + "syntaxType": "hash" + } + ] + ], + "throws": "Plugin conflict between `[\"pipelineOperator\", { proposal: \"smart\" }]` and `[\"recordAndTuple\",{\"syntaxType\":\"hash\"}]`." +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-hash-tuple/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-hash-tuple/options.json index bfad2e9eeabd..3bfd5e5e0503 100644 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-hash-tuple/options.json +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/smart-proposal-hash-tuple/options.json @@ -1,7 +1,13 @@ { + "BABEL_8_BREAKING": true, "plugins": [ - ["pipelineOperator", { "proposal": "smart" }], - ["recordAndTuple", { "syntaxType": "hash" }] + [ + "pipelineOperator", + { + "proposal": "smart" + } + ], + ["recordAndTuple"] ], - "throws": "Plugin conflict between `[\"pipelineOperator\", { proposal: \"smart\" }]` and `[\"recordAndtuple\", { syntaxType: \"hash\"}]`." + "throws": "Plugin conflict between `[\"pipelineOperator\", { proposal: \"smart\" }]` and `\"recordAndTuple\"`." } diff --git a/packages/babel-parser/test/fixtures/experimental/record-and-tuple/as-jsx-attribute-value-bar/input.js b/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/as-jsx-attribute-value-bar/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/record-and-tuple/as-jsx-attribute-value-bar/input.js rename to packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/as-jsx-attribute-value-bar/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/as-jsx-attribute-value-bar/options.json b/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/as-jsx-attribute-value-bar/options.json new file mode 100644 index 000000000000..76686bd62bb8 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/as-jsx-attribute-value-bar/options.json @@ -0,0 +1,12 @@ +{ + "plugins": [ + "jsx", + "flow", + [ + "recordAndTuple", + { + "syntaxType": "bar" + } + ] + ] +} diff --git a/packages/babel-parser/test/fixtures/experimental/record-and-tuple/as-jsx-attribute-value-bar/output.json b/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/as-jsx-attribute-value-bar/output.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/record-and-tuple/as-jsx-attribute-value-bar/output.json rename to packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/as-jsx-attribute-value-bar/output.json diff --git a/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/as-jsx-attribute-value-hash/input.js b/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/as-jsx-attribute-value-hash/input.js new file mode 100644 index 000000000000..387feb4a9ef9 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/as-jsx-attribute-value-hash/input.js @@ -0,0 +1 @@ + diff --git a/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/as-jsx-attribute-value-hash/options.json b/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/as-jsx-attribute-value-hash/options.json new file mode 100644 index 000000000000..a30ae7756bac --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/as-jsx-attribute-value-hash/options.json @@ -0,0 +1,12 @@ +{ + "plugins": [ + "jsx", + "flow", + [ + "recordAndTuple", + { + "syntaxType": "hash" + } + ] + ] +} diff --git a/packages/babel-parser/test/fixtures/experimental/record-and-tuple/as-jsx-attribute-value-hash/output.json b/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/as-jsx-attribute-value-hash/output.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/record-and-tuple/as-jsx-attribute-value-hash/output.json rename to packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/as-jsx-attribute-value-hash/output.json diff --git a/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/bar-flow/input.js b/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/bar-flow/input.js new file mode 100644 index 000000000000..0562b27afb00 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/bar-flow/input.js @@ -0,0 +1 @@ +var a: {| x: number |} = {| x: 2 |} diff --git a/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/bar-flow/options.json b/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/bar-flow/options.json new file mode 100644 index 000000000000..91b308200e05 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/bar-flow/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Unexpected token (1:5)" +} diff --git a/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/bar-yield-without-argument/input.js b/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/bar-yield-without-argument/input.js new file mode 100644 index 000000000000..beab36c2ed68 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/bar-yield-without-argument/input.js @@ -0,0 +1,3 @@ +function *f() { + return {| foo: yield |} +} diff --git a/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/bar-yield-without-argument/options.json b/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/bar-yield-without-argument/options.json new file mode 100644 index 000000000000..5ba084000464 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/bar-yield-without-argument/options.json @@ -0,0 +1,10 @@ +{ + "plugins": [ + [ + "recordAndTuple", + { + "syntaxType": "bar" + } + ] + ] +} diff --git a/packages/babel-parser/test/fixtures/experimental/record-and-tuple/bar-yield-without-argument/output.json b/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/bar-yield-without-argument/output.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/record-and-tuple/bar-yield-without-argument/output.json rename to packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/bar-yield-without-argument/output.json diff --git a/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/bar/input.js b/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/bar/input.js new file mode 100644 index 000000000000..685ddb9ec7f4 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/bar/input.js @@ -0,0 +1,16 @@ +{||}; + +{| a: 1, b: 2, c: 3 |}; + +{| + a: 1, + b: {| + c: 3, + |}, +|}; + +[||]; + +[|1, 2, 3|]; + +[|1, [|2, 3|], 4|]; diff --git a/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/bar/options.json b/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/bar/options.json new file mode 100644 index 000000000000..5ba084000464 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/bar/options.json @@ -0,0 +1,10 @@ +{ + "plugins": [ + [ + "recordAndTuple", + { + "syntaxType": "bar" + } + ] + ] +} diff --git a/packages/babel-parser/test/fixtures/experimental/record-and-tuple/bar/output.json b/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/bar/output.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/record-and-tuple/bar/output.json rename to packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/bar/output.json diff --git a/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/default-hash/input.js b/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/default-hash/input.js new file mode 100644 index 000000000000..6412030c4216 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/default-hash/input.js @@ -0,0 +1 @@ +#{ a: 1 } diff --git a/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/default-hash/options.json b/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/default-hash/options.json new file mode 100644 index 000000000000..068639ecb02b --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/default-hash/options.json @@ -0,0 +1,3 @@ +{ + "plugins": ["recordAndTuple"] +} diff --git a/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/default-hash/output.json b/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/default-hash/output.json new file mode 100644 index 000000000000..678c4badd195 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/default-hash/output.json @@ -0,0 +1,44 @@ +{ + "type": "File", + "start":0,"end":9,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":9,"index":9}}, + "program": { + "type": "Program", + "start":0,"end":9,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":9,"index":9}}, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start":0,"end":9,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":9,"index":9}}, + "expression": { + "type": "RecordExpression", + "start":0,"end":9,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":9,"index":9}}, + "properties": [ + { + "type": "ObjectProperty", + "start":3,"end":7,"loc":{"start":{"line":1,"column":3,"index":3},"end":{"line":1,"column":7,"index":7}}, + "method": false, + "key": { + "type": "Identifier", + "start":3,"end":4,"loc":{"start":{"line":1,"column":3,"index":3},"end":{"line":1,"column":4,"index":4},"identifierName":"a"}, + "name": "a" + }, + "computed": false, + "shorthand": false, + "value": { + "type": "NumericLiteral", + "start":6,"end":7,"loc":{"start":{"line":1,"column":6,"index":6},"end":{"line":1,"column":7,"index":7}}, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + } + } + ] + } + } + ], + "directives": [] + } +} diff --git a/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/disambiguate-regex-hash/input.js b/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/disambiguate-regex-hash/input.js new file mode 100644 index 000000000000..605ff6ffa946 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/disambiguate-regex-hash/input.js @@ -0,0 +1 @@ +(#{})/foo diff --git a/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/disambiguate-regex-hash/options.json b/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/disambiguate-regex-hash/options.json new file mode 100644 index 000000000000..a30ae7756bac --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/disambiguate-regex-hash/options.json @@ -0,0 +1,12 @@ +{ + "plugins": [ + "jsx", + "flow", + [ + "recordAndTuple", + { + "syntaxType": "hash" + } + ] + ] +} diff --git a/packages/babel-parser/test/fixtures/experimental/record-and-tuple/disambiguate-regex-hash/output.json b/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/disambiguate-regex-hash/output.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/record-and-tuple/disambiguate-regex-hash/output.json rename to packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/disambiguate-regex-hash/output.json diff --git a/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/hash/input.js b/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/hash/input.js new file mode 100644 index 000000000000..9217cfe71b03 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/hash/input.js @@ -0,0 +1,16 @@ +#{}; + +#{ a: 1, b: 2, c: 3 }; + +#{ + a: 1, + b: #{ + c: 3, + }, +}; + +#[]; + +#[1, 2, 3]; + +#[1, #[2, 3], 4]; diff --git a/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/hash/options.json b/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/hash/options.json new file mode 100644 index 000000000000..58c1e82a3bca --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/hash/options.json @@ -0,0 +1,10 @@ +{ + "plugins": [ + [ + "recordAndTuple", + { + "syntaxType": "hash" + } + ] + ] +} diff --git a/packages/babel-parser/test/fixtures/experimental/record-and-tuple/hash/output.json b/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/hash/output.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/record-and-tuple/hash/output.json rename to packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/hash/output.json diff --git a/packages/babel-parser/test/fixtures/experimental/record-and-tuple/incorrect-type-record-end-bar/input.js b/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/incorrect-type-record-end-bar/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/record-and-tuple/incorrect-type-record-end-bar/input.js rename to packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/incorrect-type-record-end-bar/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/record-and-tuple/incorrect-type-record-end-bar/options.json b/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/incorrect-type-record-end-bar/options.json similarity index 99% rename from packages/babel-parser/test/fixtures/experimental/record-and-tuple/incorrect-type-record-end-bar/options.json rename to packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/incorrect-type-record-end-bar/options.json index a9774f0d38ea..26353dcd84e6 100644 --- a/packages/babel-parser/test/fixtures/experimental/record-and-tuple/incorrect-type-record-end-bar/options.json +++ b/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/incorrect-type-record-end-bar/options.json @@ -8,4 +8,4 @@ ] ], "throws": "Record expressions ending with '|}' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'bar'. (1:0)" -} \ No newline at end of file +} diff --git a/packages/babel-parser/test/fixtures/experimental/record-and-tuple/incorrect-type-record-start-bar/input.js b/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/incorrect-type-record-start-bar/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/record-and-tuple/incorrect-type-record-start-bar/input.js rename to packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/incorrect-type-record-start-bar/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/record-and-tuple/incorrect-type-record-start-bar/options.json b/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/incorrect-type-record-start-bar/options.json similarity index 99% rename from packages/babel-parser/test/fixtures/experimental/record-and-tuple/incorrect-type-record-start-bar/options.json rename to packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/incorrect-type-record-start-bar/options.json index 48de601e90a1..fbd9dce52e27 100644 --- a/packages/babel-parser/test/fixtures/experimental/record-and-tuple/incorrect-type-record-start-bar/options.json +++ b/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/incorrect-type-record-start-bar/options.json @@ -8,4 +8,4 @@ ] ], "throws": "Record expressions starting with '{|' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'bar'. (1:0)" -} \ No newline at end of file +} diff --git a/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/incorrect-type-record-start-hash/input.js b/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/incorrect-type-record-start-hash/input.js new file mode 100644 index 000000000000..1dff7ae1c597 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/incorrect-type-record-start-hash/input.js @@ -0,0 +1 @@ +#{ diff --git a/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/incorrect-type-record-start-hash/options.json b/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/incorrect-type-record-start-hash/options.json new file mode 100644 index 000000000000..2fc02a04e7ee --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/incorrect-type-record-start-hash/options.json @@ -0,0 +1,11 @@ +{ + "plugins": [ + [ + "recordAndTuple", + { + "syntaxType": "bar" + } + ] + ], + "throws": "Record expressions starting with '#{' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'hash'. (1:0)" +} diff --git a/packages/babel-parser/test/fixtures/experimental/record-and-tuple/incorrect-type-tuple-end-bar/input.js b/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/incorrect-type-tuple-end-bar/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/record-and-tuple/incorrect-type-tuple-end-bar/input.js rename to packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/incorrect-type-tuple-end-bar/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/record-and-tuple/incorrect-type-tuple-end-bar/options.json b/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/incorrect-type-tuple-end-bar/options.json similarity index 99% rename from packages/babel-parser/test/fixtures/experimental/record-and-tuple/incorrect-type-tuple-end-bar/options.json rename to packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/incorrect-type-tuple-end-bar/options.json index 9d8814b7e889..730ac0f6b675 100644 --- a/packages/babel-parser/test/fixtures/experimental/record-and-tuple/incorrect-type-tuple-end-bar/options.json +++ b/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/incorrect-type-tuple-end-bar/options.json @@ -8,4 +8,4 @@ ] ], "throws": "Tuple expressions ending with '|]' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'bar'. (1:0)" -} \ No newline at end of file +} diff --git a/packages/babel-parser/test/fixtures/experimental/record-and-tuple/incorrect-type-tuple-start-bar/input.js b/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/incorrect-type-tuple-start-bar/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/record-and-tuple/incorrect-type-tuple-start-bar/input.js rename to packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/incorrect-type-tuple-start-bar/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/record-and-tuple/incorrect-type-tuple-start-bar/options.json b/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/incorrect-type-tuple-start-bar/options.json similarity index 99% rename from packages/babel-parser/test/fixtures/experimental/record-and-tuple/incorrect-type-tuple-start-bar/options.json rename to packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/incorrect-type-tuple-start-bar/options.json index d217cbfae4d4..14988cfac1b0 100644 --- a/packages/babel-parser/test/fixtures/experimental/record-and-tuple/incorrect-type-tuple-start-bar/options.json +++ b/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/incorrect-type-tuple-start-bar/options.json @@ -8,4 +8,4 @@ ] ], "throws": "Tuple expressions starting with '[|' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'bar'. (1:0)" -} \ No newline at end of file +} diff --git a/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/incorrect-type-tuple-start-hash/input.js b/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/incorrect-type-tuple-start-hash/input.js new file mode 100644 index 000000000000..47ffe9864933 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/incorrect-type-tuple-start-hash/input.js @@ -0,0 +1 @@ +#[ diff --git a/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/incorrect-type-tuple-start-hash/options.json b/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/incorrect-type-tuple-start-hash/options.json new file mode 100644 index 000000000000..62a5c62b1f80 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/incorrect-type-tuple-start-hash/options.json @@ -0,0 +1,11 @@ +{ + "plugins": [ + [ + "recordAndTuple", + { + "syntaxType": "bar" + } + ] + ], + "throws": "Tuple expressions starting with '#[' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'hash'. (1:0)" +} diff --git a/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/invalid-private-key/input.js b/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/invalid-private-key/input.js new file mode 100644 index 000000000000..7d2ecb91874b --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/invalid-private-key/input.js @@ -0,0 +1 @@ +#{ #x: x } diff --git a/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/invalid-private-key/options.json b/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/invalid-private-key/options.json new file mode 100644 index 000000000000..ab2abe079cd3 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/invalid-private-key/options.json @@ -0,0 +1,3 @@ +{ + "throws": "This experimental syntax requires enabling the parser plugin: \"recordAndTuple\". (1:0)" +} diff --git a/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/invalid-property-initializer/input.js b/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/invalid-property-initializer/input.js new file mode 100644 index 000000000000..5c2964e9a89b --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/invalid-property-initializer/input.js @@ -0,0 +1 @@ +#{ x = 1 } diff --git a/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/invalid-property-initializer/options.json b/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/invalid-property-initializer/options.json new file mode 100644 index 000000000000..58c1e82a3bca --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/invalid-property-initializer/options.json @@ -0,0 +1,10 @@ +{ + "plugins": [ + [ + "recordAndTuple", + { + "syntaxType": "hash" + } + ] + ] +} diff --git a/packages/babel-parser/test/fixtures/experimental/record-and-tuple/invalid-property-initializer/output.json b/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/invalid-property-initializer/output.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/record-and-tuple/invalid-property-initializer/output.json rename to packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/invalid-property-initializer/output.json diff --git a/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/invalid-record-method/input.js b/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/invalid-record-method/input.js new file mode 100644 index 000000000000..b8504c1af706 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/invalid-record-method/input.js @@ -0,0 +1,7 @@ +#{ + a() {}, + async b() {}, + get c() {}, + set d(_) {}, + *e() {} +} diff --git a/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/invalid-record-method/options.json b/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/invalid-record-method/options.json new file mode 100644 index 000000000000..58c1e82a3bca --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/invalid-record-method/options.json @@ -0,0 +1,10 @@ +{ + "plugins": [ + [ + "recordAndTuple", + { + "syntaxType": "hash" + } + ] + ] +} diff --git a/packages/babel-parser/test/fixtures/experimental/record-and-tuple/invalid-record-method/output.json b/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/invalid-record-method/output.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/record-and-tuple/invalid-record-method/output.json rename to packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/invalid-record-method/output.json diff --git a/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/invalid-record-proto/input.js b/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/invalid-record-proto/input.js new file mode 100644 index 000000000000..68e990891a87 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/invalid-record-proto/input.js @@ -0,0 +1 @@ +#{ __proto__: null } diff --git a/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/invalid-record-proto/options.json b/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/invalid-record-proto/options.json new file mode 100644 index 000000000000..58c1e82a3bca --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/invalid-record-proto/options.json @@ -0,0 +1,10 @@ +{ + "plugins": [ + [ + "recordAndTuple", + { + "syntaxType": "hash" + } + ] + ] +} diff --git a/packages/babel-parser/test/fixtures/experimental/record-and-tuple/invalid-record-proto/output.json b/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/invalid-record-proto/output.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/record-and-tuple/invalid-record-proto/output.json rename to packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/invalid-record-proto/output.json diff --git a/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/invalid-tuple-holes/input.js b/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/invalid-tuple-holes/input.js new file mode 100644 index 000000000000..621be6b2e406 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/invalid-tuple-holes/input.js @@ -0,0 +1 @@ +#[,] diff --git a/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/invalid-tuple-holes/options.json b/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/invalid-tuple-holes/options.json new file mode 100644 index 000000000000..58c1e82a3bca --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/invalid-tuple-holes/options.json @@ -0,0 +1,10 @@ +{ + "plugins": [ + [ + "recordAndTuple", + { + "syntaxType": "hash" + } + ] + ] +} diff --git a/packages/babel-parser/test/fixtures/experimental/record-and-tuple/invalid-tuple-holes/output.json b/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/invalid-tuple-holes/output.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/record-and-tuple/invalid-tuple-holes/output.json rename to packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/invalid-tuple-holes/output.json diff --git a/packages/babel-parser/test/fixtures/experimental/record-and-tuple/invalid-type-bar-record/input.js b/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/invalid-type-bar-record/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/record-and-tuple/invalid-type-bar-record/input.js rename to packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/invalid-type-bar-record/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/invalid-type-bar-record/options.json b/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/invalid-type-bar-record/options.json new file mode 100644 index 000000000000..f97c6a16ee4d --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/invalid-type-bar-record/options.json @@ -0,0 +1,11 @@ +{ + "plugins": [ + [ + "recordAndTuple", + { + "syntaxType": "invalid" + } + ] + ], + "throws": "The 'syntaxType' option of the 'recordAndTuple' plugin must be one of: 'hash', 'bar'" +} diff --git a/packages/babel-parser/test/fixtures/experimental/record-and-tuple/invalid-type-bar-tuple/input.js b/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/invalid-type-bar-tuple/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/record-and-tuple/invalid-type-bar-tuple/input.js rename to packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/invalid-type-bar-tuple/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/invalid-type-bar-tuple/options.json b/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/invalid-type-bar-tuple/options.json new file mode 100644 index 000000000000..f97c6a16ee4d --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/invalid-type-bar-tuple/options.json @@ -0,0 +1,11 @@ +{ + "plugins": [ + [ + "recordAndTuple", + { + "syntaxType": "invalid" + } + ] + ], + "throws": "The 'syntaxType' option of the 'recordAndTuple' plugin must be one of: 'hash', 'bar'" +} diff --git a/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/invalid-type-hash-record/input.js b/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/invalid-type-hash-record/input.js new file mode 100644 index 000000000000..feca1c1b895f --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/invalid-type-hash-record/input.js @@ -0,0 +1 @@ +#{} diff --git a/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/invalid-type-hash-record/options.json b/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/invalid-type-hash-record/options.json new file mode 100644 index 000000000000..f97c6a16ee4d --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/invalid-type-hash-record/options.json @@ -0,0 +1,11 @@ +{ + "plugins": [ + [ + "recordAndTuple", + { + "syntaxType": "invalid" + } + ] + ], + "throws": "The 'syntaxType' option of the 'recordAndTuple' plugin must be one of: 'hash', 'bar'" +} diff --git a/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/invalid-type-hash-tuple/input.js b/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/invalid-type-hash-tuple/input.js new file mode 100644 index 000000000000..0fbee2942b3d --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/invalid-type-hash-tuple/input.js @@ -0,0 +1 @@ +#[] diff --git a/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/invalid-type-hash-tuple/options.json b/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/invalid-type-hash-tuple/options.json new file mode 100644 index 000000000000..ca189c74f69b --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/invalid-type-hash-tuple/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Unexpected token (1:0)" +} diff --git a/packages/babel-parser/test/fixtures/tokens/record-and-tuple/brace-bar/input.js b/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/not-enabled-bar/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/tokens/record-and-tuple/brace-bar/input.js rename to packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/not-enabled-bar/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/not-enabled-bar/options.json b/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/not-enabled-bar/options.json new file mode 100644 index 000000000000..3500bb1aae77 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/not-enabled-bar/options.json @@ -0,0 +1,4 @@ +{ + "plugins": [], + "throws": "Unexpected token (1:1)" +} diff --git a/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/not-enabled-hash/input.js b/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/not-enabled-hash/input.js new file mode 100644 index 000000000000..95bd07c248ed --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/not-enabled-hash/input.js @@ -0,0 +1 @@ +#{}; diff --git a/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/not-enabled-hash/options.json b/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/not-enabled-hash/options.json new file mode 100644 index 000000000000..114fc061bb0c --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/not-enabled-hash/options.json @@ -0,0 +1,3 @@ +{ + "throws": "This experimental syntax requires enabling the parser plugin: \"recordAndTuple\". (1:0)" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/options.json b/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/options.json new file mode 100644 index 000000000000..29a3f0e84167 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/options.json @@ -0,0 +1,3 @@ +{ + "BABEL_8_BREAKING": false +} diff --git a/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/trailing-comma-comments/input.js b/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/trailing-comma-comments/input.js new file mode 100644 index 000000000000..48b103a6a95c --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/trailing-comma-comments/input.js @@ -0,0 +1,2 @@ +#[ a,/* 1 */] +#{ a,/* 1 */} diff --git a/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/trailing-comma-comments/options.json b/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/trailing-comma-comments/options.json new file mode 100644 index 000000000000..58c1e82a3bca --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/trailing-comma-comments/options.json @@ -0,0 +1,10 @@ +{ + "plugins": [ + [ + "recordAndTuple", + { + "syntaxType": "hash" + } + ] + ] +} diff --git a/packages/babel-parser/test/fixtures/experimental/record-and-tuple/trailing-comma-comments/output.json b/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/trailing-comma-comments/output.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/record-and-tuple/trailing-comma-comments/output.json rename to packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/trailing-comma-comments/output.json diff --git a/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/tuple-trailing-comma/input.js b/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/tuple-trailing-comma/input.js new file mode 100644 index 000000000000..3e938abafda2 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/tuple-trailing-comma/input.js @@ -0,0 +1 @@ +#[1,] diff --git a/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/tuple-trailing-comma/options.json b/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/tuple-trailing-comma/options.json new file mode 100644 index 000000000000..58c1e82a3bca --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/tuple-trailing-comma/options.json @@ -0,0 +1,10 @@ +{ + "plugins": [ + [ + "recordAndTuple", + { + "syntaxType": "hash" + } + ] + ] +} diff --git a/packages/babel-parser/test/fixtures/experimental/record-and-tuple/tuple-trailing-comma/output.json b/packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/tuple-trailing-comma/output.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/record-and-tuple/tuple-trailing-comma/output.json rename to packages/babel-parser/test/fixtures/experimental/record-and-tuple-babel-7/tuple-trailing-comma/output.json diff --git a/packages/babel-parser/test/fixtures/experimental/record-and-tuple/as-jsx-attribute-value-bar/options.json b/packages/babel-parser/test/fixtures/experimental/record-and-tuple/as-jsx-attribute-value-bar/options.json deleted file mode 100644 index 663c67344986..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/record-and-tuple/as-jsx-attribute-value-bar/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "plugins": ["jsx", "flow", ["recordAndTuple", { "syntaxType": "bar" }]] -} diff --git a/packages/babel-parser/test/fixtures/experimental/record-and-tuple/as-jsx-attribute-value-hash/options.json b/packages/babel-parser/test/fixtures/experimental/record-and-tuple/as-jsx-attribute-value-hash/options.json index 625b0abffbc0..476a9cdd736f 100644 --- a/packages/babel-parser/test/fixtures/experimental/record-and-tuple/as-jsx-attribute-value-hash/options.json +++ b/packages/babel-parser/test/fixtures/experimental/record-and-tuple/as-jsx-attribute-value-hash/options.json @@ -1,3 +1,13 @@ { - "plugins": ["jsx", "flow", ["recordAndTuple", { "syntaxType": "hash" }]] + "plugins": [ + "jsx", + "flow", + [ + "recordAndTuple", + { + "syntaxType": "hash" + } + ] + ], + "throws": "The syntaxType option is no longer required in Babel 8. You can safely remove { syntaxType: \"hash\" } from the recordAndTuple config." } diff --git a/packages/babel-parser/test/fixtures/experimental/record-and-tuple/bar-flow/options.json b/packages/babel-parser/test/fixtures/experimental/record-and-tuple/bar-flow/options.json index 001c7217b722..91b308200e05 100644 --- a/packages/babel-parser/test/fixtures/experimental/record-and-tuple/bar-flow/options.json +++ b/packages/babel-parser/test/fixtures/experimental/record-and-tuple/bar-flow/options.json @@ -1,6 +1,3 @@ { - "plugins": [ - ["recordAndTuple", { "syntaxType": "bar" }], - ["flow"] - ] + "throws": "Unexpected token (1:5)" } diff --git a/packages/babel-parser/test/fixtures/experimental/record-and-tuple/bar-flow/output.json b/packages/babel-parser/test/fixtures/experimental/record-and-tuple/bar-flow/output.json deleted file mode 100644 index 43d7e73414c1..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/record-and-tuple/bar-flow/output.json +++ /dev/null @@ -1,90 +0,0 @@ -{ - "type": "File", - "start":0,"end":35,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":35,"index":35}}, - "program": { - "type": "Program", - "start":0,"end":35,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":35,"index":35}}, - "sourceType": "script", - "interpreter": null, - "body": [ - { - "type": "VariableDeclaration", - "start":0,"end":35,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":35,"index":35}}, - "declarations": [ - { - "type": "VariableDeclarator", - "start":4,"end":35,"loc":{"start":{"line":1,"column":4,"index":4},"end":{"line":1,"column":35,"index":35}}, - "id": { - "type": "Identifier", - "start":4,"end":22,"loc":{"start":{"line":1,"column":4,"index":4},"end":{"line":1,"column":22,"index":22},"identifierName":"a"}, - "name": "a", - "typeAnnotation": { - "type": "TypeAnnotation", - "start":5,"end":22,"loc":{"start":{"line":1,"column":5,"index":5},"end":{"line":1,"column":22,"index":22}}, - "typeAnnotation": { - "type": "ObjectTypeAnnotation", - "start":7,"end":22,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":22,"index":22}}, - "callProperties": [], - "properties": [ - { - "type": "ObjectTypeProperty", - "start":10,"end":19,"loc":{"start":{"line":1,"column":10,"index":10},"end":{"line":1,"column":19,"index":19}}, - "key": { - "type": "Identifier", - "start":10,"end":11,"loc":{"start":{"line":1,"column":10,"index":10},"end":{"line":1,"column":11,"index":11},"identifierName":"x"}, - "name": "x" - }, - "static": false, - "proto": false, - "kind": "init", - "method": false, - "value": { - "type": "NumberTypeAnnotation", - "start":13,"end":19,"loc":{"start":{"line":1,"column":13,"index":13},"end":{"line":1,"column":19,"index":19}} - }, - "variance": null, - "optional": false - } - ], - "indexers": [], - "internalSlots": [], - "exact": true, - "inexact": false - } - } - }, - "init": { - "type": "RecordExpression", - "start":25,"end":35,"loc":{"start":{"line":1,"column":25,"index":25},"end":{"line":1,"column":35,"index":35}}, - "properties": [ - { - "type": "ObjectProperty", - "start":28,"end":32,"loc":{"start":{"line":1,"column":28,"index":28},"end":{"line":1,"column":32,"index":32}}, - "method": false, - "key": { - "type": "Identifier", - "start":28,"end":29,"loc":{"start":{"line":1,"column":28,"index":28},"end":{"line":1,"column":29,"index":29},"identifierName":"x"}, - "name": "x" - }, - "computed": false, - "shorthand": false, - "value": { - "type": "NumericLiteral", - "start":31,"end":32,"loc":{"start":{"line":1,"column":31,"index":31},"end":{"line":1,"column":32,"index":32}}, - "extra": { - "rawValue": 2, - "raw": "2" - }, - "value": 2 - } - } - ] - } - } - ], - "kind": "var" - } - ], - "directives": [] - } -} diff --git a/packages/babel-parser/test/fixtures/experimental/record-and-tuple/bar-yield-without-argument/options.json b/packages/babel-parser/test/fixtures/experimental/record-and-tuple/bar-yield-without-argument/options.json index bf5a72aaff3c..b9395fcf9c2c 100644 --- a/packages/babel-parser/test/fixtures/experimental/record-and-tuple/bar-yield-without-argument/options.json +++ b/packages/babel-parser/test/fixtures/experimental/record-and-tuple/bar-yield-without-argument/options.json @@ -1,3 +1,11 @@ { - "plugins": [["recordAndTuple", { "syntaxType": "bar" }]] + "plugins": [ + [ + "recordAndTuple", + { + "syntaxType": "bar" + } + ] + ], + "throws": "The syntaxType option is no longer required in Babel 8. Please remove { syntaxType: \"bar\" } from the recordAndTuple config and migrate to the hash syntax #{} and #[]." } diff --git a/packages/babel-parser/test/fixtures/experimental/record-and-tuple/bar/options.json b/packages/babel-parser/test/fixtures/experimental/record-and-tuple/bar/options.json index bf5a72aaff3c..b9395fcf9c2c 100644 --- a/packages/babel-parser/test/fixtures/experimental/record-and-tuple/bar/options.json +++ b/packages/babel-parser/test/fixtures/experimental/record-and-tuple/bar/options.json @@ -1,3 +1,11 @@ { - "plugins": [["recordAndTuple", { "syntaxType": "bar" }]] + "plugins": [ + [ + "recordAndTuple", + { + "syntaxType": "bar" + } + ] + ], + "throws": "The syntaxType option is no longer required in Babel 8. Please remove { syntaxType: \"bar\" } from the recordAndTuple config and migrate to the hash syntax #{} and #[]." } diff --git a/packages/babel-parser/test/fixtures/experimental/record-and-tuple/disambiguate-regex-hash/options.json b/packages/babel-parser/test/fixtures/experimental/record-and-tuple/disambiguate-regex-hash/options.json index 625b0abffbc0..476a9cdd736f 100644 --- a/packages/babel-parser/test/fixtures/experimental/record-and-tuple/disambiguate-regex-hash/options.json +++ b/packages/babel-parser/test/fixtures/experimental/record-and-tuple/disambiguate-regex-hash/options.json @@ -1,3 +1,13 @@ { - "plugins": ["jsx", "flow", ["recordAndTuple", { "syntaxType": "hash" }]] + "plugins": [ + "jsx", + "flow", + [ + "recordAndTuple", + { + "syntaxType": "hash" + } + ] + ], + "throws": "The syntaxType option is no longer required in Babel 8. You can safely remove { syntaxType: \"hash\" } from the recordAndTuple config." } diff --git a/packages/babel-parser/test/fixtures/experimental/record-and-tuple/hash/options.json b/packages/babel-parser/test/fixtures/experimental/record-and-tuple/hash/options.json index 703c537be360..bf436ea3fea9 100644 --- a/packages/babel-parser/test/fixtures/experimental/record-and-tuple/hash/options.json +++ b/packages/babel-parser/test/fixtures/experimental/record-and-tuple/hash/options.json @@ -1,3 +1,11 @@ { - "plugins": [["recordAndTuple", { "syntaxType": "hash" }]] + "plugins": [ + [ + "recordAndTuple", + { + "syntaxType": "hash" + } + ] + ], + "throws": "The syntaxType option is no longer required in Babel 8. You can safely remove { syntaxType: \"hash\" } from the recordAndTuple config." } diff --git a/packages/babel-parser/test/fixtures/experimental/record-and-tuple/incorrect-type-record-start-hash/options.json b/packages/babel-parser/test/fixtures/experimental/record-and-tuple/incorrect-type-record-start-hash/options.json index c93ec6c9c98a..b9395fcf9c2c 100644 --- a/packages/babel-parser/test/fixtures/experimental/record-and-tuple/incorrect-type-record-start-hash/options.json +++ b/packages/babel-parser/test/fixtures/experimental/record-and-tuple/incorrect-type-record-start-hash/options.json @@ -7,5 +7,5 @@ } ] ], - "throws": "Record expressions starting with '#{' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'hash'. (1:0)" -} \ No newline at end of file + "throws": "The syntaxType option is no longer required in Babel 8. Please remove { syntaxType: \"bar\" } from the recordAndTuple config and migrate to the hash syntax #{} and #[]." +} diff --git a/packages/babel-parser/test/fixtures/experimental/record-and-tuple/incorrect-type-tuple-start-hash/options.json b/packages/babel-parser/test/fixtures/experimental/record-and-tuple/incorrect-type-tuple-start-hash/options.json index a6d1b353aaeb..b9395fcf9c2c 100644 --- a/packages/babel-parser/test/fixtures/experimental/record-and-tuple/incorrect-type-tuple-start-hash/options.json +++ b/packages/babel-parser/test/fixtures/experimental/record-and-tuple/incorrect-type-tuple-start-hash/options.json @@ -7,5 +7,5 @@ } ] ], - "throws": "Tuple expressions starting with '#[' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'hash'. (1:0)" -} \ No newline at end of file + "throws": "The syntaxType option is no longer required in Babel 8. Please remove { syntaxType: \"bar\" } from the recordAndTuple config and migrate to the hash syntax #{} and #[]." +} diff --git a/packages/babel-parser/test/fixtures/experimental/record-and-tuple/invalid-private-key/options.json b/packages/babel-parser/test/fixtures/experimental/record-and-tuple/invalid-private-key/options.json index 3bf47e579109..ab2abe079cd3 100644 --- a/packages/babel-parser/test/fixtures/experimental/record-and-tuple/invalid-private-key/options.json +++ b/packages/babel-parser/test/fixtures/experimental/record-and-tuple/invalid-private-key/options.json @@ -1,6 +1,3 @@ { - "plugins": [ - ["recordAndTuple", { "syntaxType": "hash" }], - "destructuringPrivate" - ] + "throws": "This experimental syntax requires enabling the parser plugin: \"recordAndTuple\". (1:0)" } diff --git a/packages/babel-parser/test/fixtures/experimental/record-and-tuple/invalid-private-key/output.json b/packages/babel-parser/test/fixtures/experimental/record-and-tuple/invalid-private-key/output.json deleted file mode 100644 index aa27c011e903..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/record-and-tuple/invalid-private-key/output.json +++ /dev/null @@ -1,46 +0,0 @@ -{ - "type": "File", - "start":0,"end":10,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":10,"index":10}}, - "errors": [ - "SyntaxError: Unexpected private name. (1:3)" - ], - "program": { - "type": "Program", - "start":0,"end":10,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":10,"index":10}}, - "sourceType": "script", - "interpreter": null, - "body": [ - { - "type": "ExpressionStatement", - "start":0,"end":10,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":10,"index":10}}, - "expression": { - "type": "RecordExpression", - "start":0,"end":10,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":10,"index":10}}, - "properties": [ - { - "type": "ObjectProperty", - "start":3,"end":8,"loc":{"start":{"line":1,"column":3,"index":3},"end":{"line":1,"column":8,"index":8}}, - "method": false, - "key": { - "type": "PrivateName", - "start":3,"end":5,"loc":{"start":{"line":1,"column":3,"index":3},"end":{"line":1,"column":5,"index":5}}, - "id": { - "type": "Identifier", - "start":4,"end":5,"loc":{"start":{"line":1,"column":4,"index":4},"end":{"line":1,"column":5,"index":5},"identifierName":"x"}, - "name": "x" - } - }, - "shorthand": false, - "value": { - "type": "Identifier", - "start":7,"end":8,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":8,"index":8},"identifierName":"x"}, - "name": "x" - } - } - ] - } - } - ], - "directives": [] - } -} diff --git a/packages/babel-parser/test/fixtures/experimental/record-and-tuple/invalid-property-initializer/options.json b/packages/babel-parser/test/fixtures/experimental/record-and-tuple/invalid-property-initializer/options.json index 703c537be360..bf436ea3fea9 100644 --- a/packages/babel-parser/test/fixtures/experimental/record-and-tuple/invalid-property-initializer/options.json +++ b/packages/babel-parser/test/fixtures/experimental/record-and-tuple/invalid-property-initializer/options.json @@ -1,3 +1,11 @@ { - "plugins": [["recordAndTuple", { "syntaxType": "hash" }]] + "plugins": [ + [ + "recordAndTuple", + { + "syntaxType": "hash" + } + ] + ], + "throws": "The syntaxType option is no longer required in Babel 8. You can safely remove { syntaxType: \"hash\" } from the recordAndTuple config." } diff --git a/packages/babel-parser/test/fixtures/experimental/record-and-tuple/invalid-record-method/options.json b/packages/babel-parser/test/fixtures/experimental/record-and-tuple/invalid-record-method/options.json index 703c537be360..bf436ea3fea9 100644 --- a/packages/babel-parser/test/fixtures/experimental/record-and-tuple/invalid-record-method/options.json +++ b/packages/babel-parser/test/fixtures/experimental/record-and-tuple/invalid-record-method/options.json @@ -1,3 +1,11 @@ { - "plugins": [["recordAndTuple", { "syntaxType": "hash" }]] + "plugins": [ + [ + "recordAndTuple", + { + "syntaxType": "hash" + } + ] + ], + "throws": "The syntaxType option is no longer required in Babel 8. You can safely remove { syntaxType: \"hash\" } from the recordAndTuple config." } diff --git a/packages/babel-parser/test/fixtures/experimental/record-and-tuple/invalid-record-proto/options.json b/packages/babel-parser/test/fixtures/experimental/record-and-tuple/invalid-record-proto/options.json index 703c537be360..bf436ea3fea9 100644 --- a/packages/babel-parser/test/fixtures/experimental/record-and-tuple/invalid-record-proto/options.json +++ b/packages/babel-parser/test/fixtures/experimental/record-and-tuple/invalid-record-proto/options.json @@ -1,3 +1,11 @@ { - "plugins": [["recordAndTuple", { "syntaxType": "hash" }]] + "plugins": [ + [ + "recordAndTuple", + { + "syntaxType": "hash" + } + ] + ], + "throws": "The syntaxType option is no longer required in Babel 8. You can safely remove { syntaxType: \"hash\" } from the recordAndTuple config." } diff --git a/packages/babel-parser/test/fixtures/experimental/record-and-tuple/invalid-tuple-holes/options.json b/packages/babel-parser/test/fixtures/experimental/record-and-tuple/invalid-tuple-holes/options.json index 30cab962984d..bf436ea3fea9 100644 --- a/packages/babel-parser/test/fixtures/experimental/record-and-tuple/invalid-tuple-holes/options.json +++ b/packages/babel-parser/test/fixtures/experimental/record-and-tuple/invalid-tuple-holes/options.json @@ -6,5 +6,6 @@ "syntaxType": "hash" } ] - ] -} \ No newline at end of file + ], + "throws": "The syntaxType option is no longer required in Babel 8. You can safely remove { syntaxType: \"hash\" } from the recordAndTuple config." +} diff --git a/packages/babel-parser/test/fixtures/experimental/record-and-tuple/invalid-type-bar-record/options.json b/packages/babel-parser/test/fixtures/experimental/record-and-tuple/invalid-type-bar-record/options.json deleted file mode 100644 index da006416f7ce..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/record-and-tuple/invalid-type-bar-record/options.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "plugins": [["recordAndTuple", { "syntaxType": "invalid" }]], - "throws": "The 'syntaxType' option of the 'recordAndTuple' plugin must be one of: 'hash', 'bar'" -} diff --git a/packages/babel-parser/test/fixtures/experimental/record-and-tuple/invalid-type-bar-tuple/options.json b/packages/babel-parser/test/fixtures/experimental/record-and-tuple/invalid-type-bar-tuple/options.json deleted file mode 100644 index da006416f7ce..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/record-and-tuple/invalid-type-bar-tuple/options.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "plugins": [["recordAndTuple", { "syntaxType": "invalid" }]], - "throws": "The 'syntaxType' option of the 'recordAndTuple' plugin must be one of: 'hash', 'bar'" -} diff --git a/packages/babel-parser/test/fixtures/experimental/record-and-tuple/invalid-type-hash-record/options.json b/packages/babel-parser/test/fixtures/experimental/record-and-tuple/invalid-type-hash-record/options.json index da006416f7ce..9fbcccf93d21 100644 --- a/packages/babel-parser/test/fixtures/experimental/record-and-tuple/invalid-type-hash-record/options.json +++ b/packages/babel-parser/test/fixtures/experimental/record-and-tuple/invalid-type-hash-record/options.json @@ -1,4 +1,11 @@ { - "plugins": [["recordAndTuple", { "syntaxType": "invalid" }]], - "throws": "The 'syntaxType' option of the 'recordAndTuple' plugin must be one of: 'hash', 'bar'" + "plugins": [ + [ + "recordAndTuple", + { + "syntaxType": "invalid" + } + ] + ], + "throws": "The syntaxType option is no longer required in Babel 8. Please remove { syntaxType: \"bar\" } from the recordAndTuple config and migrate to the hash syntax #{} and #[]." } diff --git a/packages/babel-parser/test/fixtures/experimental/record-and-tuple/invalid-type-hash-tuple/options.json b/packages/babel-parser/test/fixtures/experimental/record-and-tuple/invalid-type-hash-tuple/options.json index da006416f7ce..ca189c74f69b 100644 --- a/packages/babel-parser/test/fixtures/experimental/record-and-tuple/invalid-type-hash-tuple/options.json +++ b/packages/babel-parser/test/fixtures/experimental/record-and-tuple/invalid-type-hash-tuple/options.json @@ -1,4 +1,3 @@ { - "plugins": [["recordAndTuple", { "syntaxType": "invalid" }]], - "throws": "The 'syntaxType' option of the 'recordAndTuple' plugin must be one of: 'hash', 'bar'" + "throws": "Unexpected token (1:0)" } diff --git a/packages/babel-parser/test/fixtures/experimental/record-and-tuple/options.json b/packages/babel-parser/test/fixtures/experimental/record-and-tuple/options.json new file mode 100644 index 000000000000..cbf6d1595427 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/record-and-tuple/options.json @@ -0,0 +1,3 @@ +{ + "BABEL_8_BREAKING": true +} diff --git a/packages/babel-parser/test/fixtures/experimental/record-and-tuple/trailing-comma-comments/options.json b/packages/babel-parser/test/fixtures/experimental/record-and-tuple/trailing-comma-comments/options.json index 703c537be360..bf436ea3fea9 100644 --- a/packages/babel-parser/test/fixtures/experimental/record-and-tuple/trailing-comma-comments/options.json +++ b/packages/babel-parser/test/fixtures/experimental/record-and-tuple/trailing-comma-comments/options.json @@ -1,3 +1,11 @@ { - "plugins": [["recordAndTuple", { "syntaxType": "hash" }]] + "plugins": [ + [ + "recordAndTuple", + { + "syntaxType": "hash" + } + ] + ], + "throws": "The syntaxType option is no longer required in Babel 8. You can safely remove { syntaxType: \"hash\" } from the recordAndTuple config." } diff --git a/packages/babel-parser/test/fixtures/experimental/record-and-tuple/tuple-trailing-comma/options.json b/packages/babel-parser/test/fixtures/experimental/record-and-tuple/tuple-trailing-comma/options.json index 703c537be360..bf436ea3fea9 100644 --- a/packages/babel-parser/test/fixtures/experimental/record-and-tuple/tuple-trailing-comma/options.json +++ b/packages/babel-parser/test/fixtures/experimental/record-and-tuple/tuple-trailing-comma/options.json @@ -1,3 +1,11 @@ { - "plugins": [["recordAndTuple", { "syntaxType": "hash" }]] + "plugins": [ + [ + "recordAndTuple", + { + "syntaxType": "hash" + } + ] + ], + "throws": "The syntaxType option is no longer required in Babel 8. You can safely remove { syntaxType: \"hash\" } from the recordAndTuple config." } diff --git a/packages/babel-parser/test/fixtures/tokens/record-and-tuple/brace-bar/options.json b/packages/babel-parser/test/fixtures/tokens/record-and-tuple/brace-bar/options.json deleted file mode 100644 index 616dcd299767..000000000000 --- a/packages/babel-parser/test/fixtures/tokens/record-and-tuple/brace-bar/options.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "plugins": [["recordAndTuple", { "syntaxType": "bar" }]], - "tokens": true -} diff --git a/packages/babel-parser/test/fixtures/tokens/record-and-tuple/brace-bar/output.json b/packages/babel-parser/test/fixtures/tokens/record-and-tuple/brace-bar/output.json deleted file mode 100644 index c93d37ef971b..000000000000 --- a/packages/babel-parser/test/fixtures/tokens/record-and-tuple/brace-bar/output.json +++ /dev/null @@ -1,66 +0,0 @@ -{ - "type": "File", - "start":0,"end":4,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":4,"index":4}}, - "program": { - "type": "Program", - "start":0,"end":4,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":4,"index":4}}, - "sourceType": "script", - "interpreter": null, - "body": [ - { - "type": "ExpressionStatement", - "start":0,"end":4,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":4,"index":4}}, - "expression": { - "type": "RecordExpression", - "start":0,"end":4,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":4,"index":4}}, - "properties": [] - } - } - ], - "directives": [] - }, - "tokens": [ - { - "type": { - "label": "{|", - "beforeExpr": true, - "startsExpr": true, - "rightAssociative": false, - "isLoop": false, - "isAssign": false, - "prefix": false, - "postfix": false, - "binop": null - }, - "start":0,"end":2,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":2,"index":2}} - }, - { - "type": { - "label": "|}", - "beforeExpr": false, - "startsExpr": false, - "rightAssociative": false, - "isLoop": false, - "isAssign": false, - "prefix": false, - "postfix": false, - "binop": null - }, - "start":2,"end":4,"loc":{"start":{"line":1,"column":2,"index":2},"end":{"line":1,"column":4,"index":4}} - }, - { - "type": { - "label": "eof", - "beforeExpr": false, - "startsExpr": false, - "rightAssociative": false, - "isLoop": false, - "isAssign": false, - "prefix": false, - "postfix": false, - "binop": null - }, - "start":4,"end":4,"loc":{"start":{"line":1,"column":4,"index":4},"end":{"line":1,"column":4,"index":4}} - } - ] -} diff --git a/packages/babel-parser/test/fixtures/tokens/record-and-tuple/brace-hash/options.json b/packages/babel-parser/test/fixtures/tokens/record-and-tuple/brace-hash/options.json index 330c1681f890..d39392e30ad2 100644 --- a/packages/babel-parser/test/fixtures/tokens/record-and-tuple/brace-hash/options.json +++ b/packages/babel-parser/test/fixtures/tokens/record-and-tuple/brace-hash/options.json @@ -1,4 +1,8 @@ { - "plugins": [[ "recordAndTuple", { "syntaxType": "hash" }]], + "plugins": [ + [ + "recordAndTuple" + ] + ], "tokens": true } diff --git a/packages/babel-parser/test/fixtures/tokens/record-and-tuple/bracket-bar/input.js b/packages/babel-parser/test/fixtures/tokens/record-and-tuple/bracket-bar/input.js deleted file mode 100644 index 38030aa27cca..000000000000 --- a/packages/babel-parser/test/fixtures/tokens/record-and-tuple/bracket-bar/input.js +++ /dev/null @@ -1 +0,0 @@ -[||] diff --git a/packages/babel-parser/test/fixtures/tokens/record-and-tuple/bracket-bar/options.json b/packages/babel-parser/test/fixtures/tokens/record-and-tuple/bracket-bar/options.json deleted file mode 100644 index 616dcd299767..000000000000 --- a/packages/babel-parser/test/fixtures/tokens/record-and-tuple/bracket-bar/options.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "plugins": [["recordAndTuple", { "syntaxType": "bar" }]], - "tokens": true -} diff --git a/packages/babel-parser/test/fixtures/tokens/record-and-tuple/bracket-bar/output.json b/packages/babel-parser/test/fixtures/tokens/record-and-tuple/bracket-bar/output.json deleted file mode 100644 index 03198cf58eac..000000000000 --- a/packages/babel-parser/test/fixtures/tokens/record-and-tuple/bracket-bar/output.json +++ /dev/null @@ -1,66 +0,0 @@ -{ - "type": "File", - "start":0,"end":4,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":4,"index":4}}, - "program": { - "type": "Program", - "start":0,"end":4,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":4,"index":4}}, - "sourceType": "script", - "interpreter": null, - "body": [ - { - "type": "ExpressionStatement", - "start":0,"end":4,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":4,"index":4}}, - "expression": { - "type": "TupleExpression", - "start":0,"end":4,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":4,"index":4}}, - "elements": [] - } - } - ], - "directives": [] - }, - "tokens": [ - { - "type": { - "label": "[|", - "beforeExpr": true, - "startsExpr": true, - "rightAssociative": false, - "isLoop": false, - "isAssign": false, - "prefix": false, - "postfix": false, - "binop": null - }, - "start":0,"end":2,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":2,"index":2}} - }, - { - "type": { - "label": "|]", - "beforeExpr": false, - "startsExpr": false, - "rightAssociative": false, - "isLoop": false, - "isAssign": false, - "prefix": false, - "postfix": false, - "binop": null - }, - "start":2,"end":4,"loc":{"start":{"line":1,"column":2,"index":2},"end":{"line":1,"column":4,"index":4}} - }, - { - "type": { - "label": "eof", - "beforeExpr": false, - "startsExpr": false, - "rightAssociative": false, - "isLoop": false, - "isAssign": false, - "prefix": false, - "postfix": false, - "binop": null - }, - "start":4,"end":4,"loc":{"start":{"line":1,"column":4,"index":4},"end":{"line":1,"column":4,"index":4}} - } - ] -} diff --git a/packages/babel-parser/test/fixtures/tokens/record-and-tuple/bracket-hash/options.json b/packages/babel-parser/test/fixtures/tokens/record-and-tuple/bracket-hash/options.json index 330c1681f890..d39392e30ad2 100644 --- a/packages/babel-parser/test/fixtures/tokens/record-and-tuple/bracket-hash/options.json +++ b/packages/babel-parser/test/fixtures/tokens/record-and-tuple/bracket-hash/options.json @@ -1,4 +1,8 @@ { - "plugins": [[ "recordAndTuple", { "syntaxType": "hash" }]], + "plugins": [ + [ + "recordAndTuple" + ] + ], "tokens": true } diff --git a/packages/babel-parser/test/fixtures/typescript/types-arrow-function/array-pattern-with-es-tuple/options.json b/packages/babel-parser/test/fixtures/typescript/types-arrow-function/array-pattern-with-es-tuple/options.json index 06bbdd2b1524..80f97f83f0be 100644 --- a/packages/babel-parser/test/fixtures/typescript/types-arrow-function/array-pattern-with-es-tuple/options.json +++ b/packages/babel-parser/test/fixtures/typescript/types-arrow-function/array-pattern-with-es-tuple/options.json @@ -1,4 +1,7 @@ { "sourceType": "module", - "plugins": ["typescript", ["recordAndTuple", { "syntaxType": "hash" }]] + "plugins": [ + "typescript", + "recordAndTuple" + ] } diff --git a/packages/babel-parser/test/fixtures/typescript/types-arrow-function/object-pattern-with-es-record/options.json b/packages/babel-parser/test/fixtures/typescript/types-arrow-function/object-pattern-with-es-record/options.json index 51b5cace4df4..80f97f83f0be 100644 --- a/packages/babel-parser/test/fixtures/typescript/types-arrow-function/object-pattern-with-es-record/options.json +++ b/packages/babel-parser/test/fixtures/typescript/types-arrow-function/object-pattern-with-es-record/options.json @@ -2,11 +2,6 @@ "sourceType": "module", "plugins": [ "typescript", - [ - "recordAndTuple", - { - "syntaxType": "hash" - } - ] + "recordAndTuple" ] } diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/hash-tuple-babel-7/input.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/hash-tuple-babel-7/input.js new file mode 100644 index 000000000000..c9cafc96318d --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/hash-tuple-babel-7/input.js @@ -0,0 +1,2 @@ +#[0]; +1 |> #[0, ^]; diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/hash-tuple-babel-7/options.json b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/hash-tuple-babel-7/options.json new file mode 100644 index 000000000000..e20806924736 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/hash-tuple-babel-7/options.json @@ -0,0 +1,7 @@ +{ + "BABEL_8_BREAKING": false, + "plugins": [ + ["proposal-pipeline-operator", { "proposal": "hack", "topicToken": "^" }], + ["proposal-record-and-tuple", { "syntaxType": "hash" }] + ] +} diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/hash-tuple-babel-7/output.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/hash-tuple-babel-7/output.js new file mode 100644 index 000000000000..d4cfc944b3b8 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/hash-tuple-babel-7/output.js @@ -0,0 +1,2 @@ +Tuple(0); +Tuple(0, 1); diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/hash-tuple/options.json b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/hash-tuple/options.json index 6084a8087a59..712ad1e0bb53 100644 --- a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/hash-tuple/options.json +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-caret/hash-tuple/options.json @@ -1,6 +1,7 @@ { + "BABEL_8_BREAKING": true, "plugins": [ ["proposal-pipeline-operator", { "proposal": "hack", "topicToken": "^" }], - ["proposal-record-and-tuple", { "syntaxType": "hash" }] + ["proposal-record-and-tuple"] ] } diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-double-at/hash-tuple-babel-7/input.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-double-at/hash-tuple-babel-7/input.js new file mode 100644 index 000000000000..81a3b28d74df --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-double-at/hash-tuple-babel-7/input.js @@ -0,0 +1,2 @@ +#[0]; +1 |> #[0, @@]; diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-double-at/hash-tuple-babel-7/options.json b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-double-at/hash-tuple-babel-7/options.json new file mode 100644 index 000000000000..b181aebaad89 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-double-at/hash-tuple-babel-7/options.json @@ -0,0 +1,7 @@ +{ + "BABEL_8_BREAKING": false, + "plugins": [ + ["proposal-pipeline-operator", { "proposal": "hack", "topicToken": "@@" }], + ["proposal-record-and-tuple", { "syntaxType": "hash" }] + ] +} diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-double-at/hash-tuple-babel-7/output.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-double-at/hash-tuple-babel-7/output.js new file mode 100644 index 000000000000..d4cfc944b3b8 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-double-at/hash-tuple-babel-7/output.js @@ -0,0 +1,2 @@ +Tuple(0); +Tuple(0, 1); diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-double-at/hash-tuple/options.json b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-double-at/hash-tuple/options.json index 0e8928650c99..1bc012dc711d 100644 --- a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-double-at/hash-tuple/options.json +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-double-at/hash-tuple/options.json @@ -1,6 +1,7 @@ { + "BABEL_8_BREAKING": true, "plugins": [ ["proposal-pipeline-operator", { "proposal": "hack", "topicToken": "@@" }], - ["proposal-record-and-tuple", { "syntaxType": "hash" }] + ["proposal-record-and-tuple"] ] } diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-double-caret/hash-tuple-babel-7/input.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-double-caret/hash-tuple-babel-7/input.js new file mode 100644 index 000000000000..5a6ea279ee6f --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-double-caret/hash-tuple-babel-7/input.js @@ -0,0 +1,2 @@ +#[0]; +1 |> #[0, ^^]; diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-double-caret/hash-tuple-babel-7/options.json b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-double-caret/hash-tuple-babel-7/options.json new file mode 100644 index 000000000000..c2b207873035 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-double-caret/hash-tuple-babel-7/options.json @@ -0,0 +1,7 @@ +{ + "BABEL_8_BREAKING": false, + "plugins": [ + ["proposal-pipeline-operator", { "proposal": "hack", "topicToken": "^^" }], + ["proposal-record-and-tuple", { "syntaxType": "hash" }] + ] +} diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-double-caret/hash-tuple-babel-7/output.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-double-caret/hash-tuple-babel-7/output.js new file mode 100644 index 000000000000..d4cfc944b3b8 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-double-caret/hash-tuple-babel-7/output.js @@ -0,0 +1,2 @@ +Tuple(0); +Tuple(0, 1); diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-double-caret/hash-tuple/options.json b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-double-caret/hash-tuple/options.json index 2c2a31351921..450e4f05123f 100644 --- a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-double-caret/hash-tuple/options.json +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-double-caret/hash-tuple/options.json @@ -1,6 +1,7 @@ { + "BABEL_8_BREAKING": true, "plugins": [ ["proposal-pipeline-operator", { "proposal": "hack", "topicToken": "^^" }], - ["proposal-record-and-tuple", { "syntaxType": "hash" }] + ["proposal-record-and-tuple"] ] } diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/hash-tuple-babel-7/input.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/hash-tuple-babel-7/input.js new file mode 100644 index 000000000000..eb22843797b1 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/hash-tuple-babel-7/input.js @@ -0,0 +1,2 @@ +#[0]; +1 |> #[0]; diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/hash-tuple-babel-7/options.json b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/hash-tuple-babel-7/options.json new file mode 100644 index 000000000000..3dbaaa465ab5 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/hash-tuple-babel-7/options.json @@ -0,0 +1,8 @@ +{ + "BABEL_8_BREAKING": false, + "plugins": [ + ["proposal-pipeline-operator", { "proposal": "hack", "topicToken": "#" }], + ["proposal-record-and-tuple", { "syntaxType": "hash" }] + ], + "throws": "Plugin conflict between `[\"pipelineOperator\", { proposal: \"hack\", topicToken: \"#\" }]` and `[\"recordAndTuple\",{\"syntaxType\":\"hash\"}]`." +} diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/hash-tuple/options.json b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/hash-tuple/options.json index ffa897bcca2e..823caccec01a 100644 --- a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/hash-tuple/options.json +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-hash/hash-tuple/options.json @@ -1,7 +1,8 @@ { + "BABEL_8_BREAKING": true, "plugins": [ ["proposal-pipeline-operator", { "proposal": "hack", "topicToken": "#" }], - ["proposal-record-and-tuple", { "syntaxType": "hash" }] + ["proposal-record-and-tuple"] ], - "throws": "Plugin conflict between `[\"pipelineOperator\", { proposal: \"hack\", topicToken: \"#\" }]` and `[\"recordAndtuple\", { syntaxType: \"hash\"}]`." + "throws": "Plugin conflict between `[\"pipelineOperator\", { proposal: \"hack\", topicToken: \"#\" }]` and `\"recordAndTuple\"`." } diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/hash-tuple-babel-7/input.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/hash-tuple-babel-7/input.js new file mode 100644 index 000000000000..dd96171689d2 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/hash-tuple-babel-7/input.js @@ -0,0 +1,2 @@ +#[0]; +1 |> #[0, %]; diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/hash-tuple-babel-7/options.json b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/hash-tuple-babel-7/options.json new file mode 100644 index 000000000000..384b12ca52b5 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/hash-tuple-babel-7/options.json @@ -0,0 +1,7 @@ +{ + "BABEL_8_BREAKING": false, + "plugins": [ + ["proposal-pipeline-operator", { "proposal": "hack", "topicToken": "%" }], + ["proposal-record-and-tuple", { "syntaxType": "hash" }] + ] +} diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/hash-tuple-babel-7/output.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/hash-tuple-babel-7/output.js new file mode 100644 index 000000000000..d4cfc944b3b8 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/hash-tuple-babel-7/output.js @@ -0,0 +1,2 @@ +Tuple(0); +Tuple(0, 1); diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/hash-tuple/options.json b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/hash-tuple/options.json index 1d4946f1adfd..80cf3bc87306 100644 --- a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/hash-tuple/options.json +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/hack-percent/hash-tuple/options.json @@ -1,6 +1,7 @@ { + "BABEL_8_BREAKING": true, "plugins": [ ["proposal-pipeline-operator", { "proposal": "hack", "topicToken": "%" }], - ["proposal-record-and-tuple", { "syntaxType": "hash" }] + ["proposal-record-and-tuple"] ] } diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/hash-tuple-babel-7/input.js b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/hash-tuple-babel-7/input.js new file mode 100644 index 000000000000..eb22843797b1 --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/hash-tuple-babel-7/input.js @@ -0,0 +1,2 @@ +#[0]; +1 |> #[0]; diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/hash-tuple-babel-7/options.json b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/hash-tuple-babel-7/options.json new file mode 100644 index 000000000000..7aed164724be --- /dev/null +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/hash-tuple-babel-7/options.json @@ -0,0 +1,8 @@ +{ + "BABEL_8_BREAKING": false, + "plugins": [ + ["proposal-pipeline-operator", { "proposal": "smart" }], + ["proposal-record-and-tuple", { "syntaxType": "hash" }] + ], + "throws": "Plugin conflict between `[\"pipelineOperator\", { proposal: \"smart\" }]` and `[\"recordAndTuple\",{\"syntaxType\":\"hash\"}]`." +} diff --git a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/hash-tuple/options.json b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/hash-tuple/options.json index 69cdcba741f1..112d32be0426 100644 --- a/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/hash-tuple/options.json +++ b/packages/babel-plugin-proposal-pipeline-operator/test/fixtures/smart/hash-tuple/options.json @@ -1,7 +1,8 @@ { + "BABEL_8_BREAKING": true, "plugins": [ ["proposal-pipeline-operator", { "proposal": "smart" }], - ["proposal-record-and-tuple", { "syntaxType": "hash" }] + ["proposal-record-and-tuple"] ], - "throws": "Plugin conflict between `[\"pipelineOperator\", { proposal: \"smart\" }]` and `[\"recordAndtuple\", { syntaxType: \"hash\"}]`." + "throws": "Plugin conflict between `[\"pipelineOperator\", { proposal: \"smart\" }]` and `\"recordAndTuple\"`." } diff --git a/packages/babel-plugin-proposal-record-and-tuple/test/fixtures/import-polyfill-babel-7/commonjs/input.js b/packages/babel-plugin-proposal-record-and-tuple/test/fixtures/import-polyfill-babel-7/commonjs/input.js new file mode 100644 index 000000000000..f23d5c75b2a9 --- /dev/null +++ b/packages/babel-plugin-proposal-record-and-tuple/test/fixtures/import-polyfill-babel-7/commonjs/input.js @@ -0,0 +1,8 @@ +const r2 = #{ + a: #{ + b: 456, + }, + e: 789, +}; + +const t2 = #[1, #[2, 3, #[4], 5], 6]; diff --git a/packages/babel-plugin-proposal-record-and-tuple/test/fixtures/import-polyfill-babel-7/commonjs/options.json b/packages/babel-plugin-proposal-record-and-tuple/test/fixtures/import-polyfill-babel-7/commonjs/options.json new file mode 100644 index 000000000000..e7f8ad8681fc --- /dev/null +++ b/packages/babel-plugin-proposal-record-and-tuple/test/fixtures/import-polyfill-babel-7/commonjs/options.json @@ -0,0 +1,6 @@ +{ + "plugins": [["proposal-record-and-tuple", { + "syntaxType": "hash", + "importPolyfill": true + }]] +} diff --git a/packages/babel-plugin-proposal-record-and-tuple/test/fixtures/import-polyfill-babel-7/commonjs/output.js b/packages/babel-plugin-proposal-record-and-tuple/test/fixtures/import-polyfill-babel-7/commonjs/output.js new file mode 100644 index 000000000000..a5fc2c04e4e7 --- /dev/null +++ b/packages/babel-plugin-proposal-record-and-tuple/test/fixtures/import-polyfill-babel-7/commonjs/output.js @@ -0,0 +1,9 @@ +var _Tuple = require("@bloomberg/record-tuple-polyfill").Tuple; +var _Record = require("@bloomberg/record-tuple-polyfill").Record; +const r2 = _Record({ + a: _Record({ + b: 456 + }), + e: 789 +}); +const t2 = _Tuple(1, _Tuple(2, 3, _Tuple(4), 5), 6); diff --git a/packages/babel-plugin-proposal-record-and-tuple/test/fixtures/import-polyfill-babel-7/custom-name-implies-should-import/input.mjs b/packages/babel-plugin-proposal-record-and-tuple/test/fixtures/import-polyfill-babel-7/custom-name-implies-should-import/input.mjs new file mode 100644 index 000000000000..f23d5c75b2a9 --- /dev/null +++ b/packages/babel-plugin-proposal-record-and-tuple/test/fixtures/import-polyfill-babel-7/custom-name-implies-should-import/input.mjs @@ -0,0 +1,8 @@ +const r2 = #{ + a: #{ + b: 456, + }, + e: 789, +}; + +const t2 = #[1, #[2, 3, #[4], 5], 6]; diff --git a/packages/babel-plugin-proposal-record-and-tuple/test/fixtures/import-polyfill-babel-7/custom-name-implies-should-import/options.json b/packages/babel-plugin-proposal-record-and-tuple/test/fixtures/import-polyfill-babel-7/custom-name-implies-should-import/options.json new file mode 100644 index 000000000000..974da8bb9ead --- /dev/null +++ b/packages/babel-plugin-proposal-record-and-tuple/test/fixtures/import-polyfill-babel-7/custom-name-implies-should-import/options.json @@ -0,0 +1,6 @@ +{ + "plugins": [["proposal-record-and-tuple", { + "syntaxType": "hash", + "polyfillModuleName": "my-polyfill" + }]] +} diff --git a/packages/babel-plugin-proposal-record-and-tuple/test/fixtures/import-polyfill-babel-7/custom-name-implies-should-import/output.mjs b/packages/babel-plugin-proposal-record-and-tuple/test/fixtures/import-polyfill-babel-7/custom-name-implies-should-import/output.mjs new file mode 100644 index 000000000000..074aec7882df --- /dev/null +++ b/packages/babel-plugin-proposal-record-and-tuple/test/fixtures/import-polyfill-babel-7/custom-name-implies-should-import/output.mjs @@ -0,0 +1,8 @@ +import { Record as _Record, Tuple as _Tuple } from "my-polyfill"; +const r2 = _Record({ + a: _Record({ + b: 456 + }), + e: 789 +}); +const t2 = _Tuple(1, _Tuple(2, 3, _Tuple(4), 5), 6); diff --git a/packages/babel-plugin-proposal-record-and-tuple/test/fixtures/import-polyfill-babel-7/custom-name/input.mjs b/packages/babel-plugin-proposal-record-and-tuple/test/fixtures/import-polyfill-babel-7/custom-name/input.mjs new file mode 100644 index 000000000000..f23d5c75b2a9 --- /dev/null +++ b/packages/babel-plugin-proposal-record-and-tuple/test/fixtures/import-polyfill-babel-7/custom-name/input.mjs @@ -0,0 +1,8 @@ +const r2 = #{ + a: #{ + b: 456, + }, + e: 789, +}; + +const t2 = #[1, #[2, 3, #[4], 5], 6]; diff --git a/packages/babel-plugin-proposal-record-and-tuple/test/fixtures/import-polyfill-babel-7/custom-name/options.json b/packages/babel-plugin-proposal-record-and-tuple/test/fixtures/import-polyfill-babel-7/custom-name/options.json new file mode 100644 index 000000000000..96c638db09fd --- /dev/null +++ b/packages/babel-plugin-proposal-record-and-tuple/test/fixtures/import-polyfill-babel-7/custom-name/options.json @@ -0,0 +1,7 @@ +{ + "plugins": [["proposal-record-and-tuple", { + "syntaxType": "hash", + "importPolyfill": true, + "polyfillModuleName": "my-polyfill" + }]] +} diff --git a/packages/babel-plugin-proposal-record-and-tuple/test/fixtures/import-polyfill-babel-7/custom-name/output.mjs b/packages/babel-plugin-proposal-record-and-tuple/test/fixtures/import-polyfill-babel-7/custom-name/output.mjs new file mode 100644 index 000000000000..074aec7882df --- /dev/null +++ b/packages/babel-plugin-proposal-record-and-tuple/test/fixtures/import-polyfill-babel-7/custom-name/output.mjs @@ -0,0 +1,8 @@ +import { Record as _Record, Tuple as _Tuple } from "my-polyfill"; +const r2 = _Record({ + a: _Record({ + b: 456 + }), + e: 789 +}); +const t2 = _Tuple(1, _Tuple(2, 3, _Tuple(4), 5), 6); diff --git a/packages/babel-plugin-proposal-record-and-tuple/test/fixtures/import-polyfill-babel-7/default-name/input.mjs b/packages/babel-plugin-proposal-record-and-tuple/test/fixtures/import-polyfill-babel-7/default-name/input.mjs new file mode 100644 index 000000000000..f23d5c75b2a9 --- /dev/null +++ b/packages/babel-plugin-proposal-record-and-tuple/test/fixtures/import-polyfill-babel-7/default-name/input.mjs @@ -0,0 +1,8 @@ +const r2 = #{ + a: #{ + b: 456, + }, + e: 789, +}; + +const t2 = #[1, #[2, 3, #[4], 5], 6]; diff --git a/packages/babel-plugin-proposal-record-and-tuple/test/fixtures/import-polyfill-babel-7/default-name/options.json b/packages/babel-plugin-proposal-record-and-tuple/test/fixtures/import-polyfill-babel-7/default-name/options.json new file mode 100644 index 000000000000..e7f8ad8681fc --- /dev/null +++ b/packages/babel-plugin-proposal-record-and-tuple/test/fixtures/import-polyfill-babel-7/default-name/options.json @@ -0,0 +1,6 @@ +{ + "plugins": [["proposal-record-and-tuple", { + "syntaxType": "hash", + "importPolyfill": true + }]] +} diff --git a/packages/babel-plugin-proposal-record-and-tuple/test/fixtures/import-polyfill-babel-7/default-name/output.mjs b/packages/babel-plugin-proposal-record-and-tuple/test/fixtures/import-polyfill-babel-7/default-name/output.mjs new file mode 100644 index 000000000000..cb3d172afa49 --- /dev/null +++ b/packages/babel-plugin-proposal-record-and-tuple/test/fixtures/import-polyfill-babel-7/default-name/output.mjs @@ -0,0 +1,8 @@ +import { Record as _Record, Tuple as _Tuple } from "@bloomberg/record-tuple-polyfill"; +const r2 = _Record({ + a: _Record({ + b: 456 + }), + e: 789 +}); +const t2 = _Tuple(1, _Tuple(2, 3, _Tuple(4), 5), 6); diff --git a/packages/babel-plugin-proposal-record-and-tuple/test/fixtures/import-polyfill-babel-7/options.json b/packages/babel-plugin-proposal-record-and-tuple/test/fixtures/import-polyfill-babel-7/options.json new file mode 100644 index 000000000000..29a3f0e84167 --- /dev/null +++ b/packages/babel-plugin-proposal-record-and-tuple/test/fixtures/import-polyfill-babel-7/options.json @@ -0,0 +1,3 @@ +{ + "BABEL_8_BREAKING": false +} diff --git a/packages/babel-plugin-proposal-record-and-tuple/test/fixtures/import-polyfill/commonjs/options.json b/packages/babel-plugin-proposal-record-and-tuple/test/fixtures/import-polyfill/commonjs/options.json index e7f8ad8681fc..eaf5cfcff681 100644 --- a/packages/babel-plugin-proposal-record-and-tuple/test/fixtures/import-polyfill/commonjs/options.json +++ b/packages/babel-plugin-proposal-record-and-tuple/test/fixtures/import-polyfill/commonjs/options.json @@ -1,6 +1,10 @@ { - "plugins": [["proposal-record-and-tuple", { - "syntaxType": "hash", - "importPolyfill": true - }]] + "plugins": [ + [ + "proposal-record-and-tuple", + { + "importPolyfill": true + } + ] + ] } diff --git a/packages/babel-plugin-proposal-record-and-tuple/test/fixtures/import-polyfill/custom-name-implies-should-import/options.json b/packages/babel-plugin-proposal-record-and-tuple/test/fixtures/import-polyfill/custom-name-implies-should-import/options.json index 974da8bb9ead..7d2b7c9672a8 100644 --- a/packages/babel-plugin-proposal-record-and-tuple/test/fixtures/import-polyfill/custom-name-implies-should-import/options.json +++ b/packages/babel-plugin-proposal-record-and-tuple/test/fixtures/import-polyfill/custom-name-implies-should-import/options.json @@ -1,6 +1,10 @@ { - "plugins": [["proposal-record-and-tuple", { - "syntaxType": "hash", - "polyfillModuleName": "my-polyfill" - }]] + "plugins": [ + [ + "proposal-record-and-tuple", + { + "polyfillModuleName": "my-polyfill" + } + ] + ] } diff --git a/packages/babel-plugin-proposal-record-and-tuple/test/fixtures/import-polyfill/custom-name/options.json b/packages/babel-plugin-proposal-record-and-tuple/test/fixtures/import-polyfill/custom-name/options.json index 96c638db09fd..f3f136a1da31 100644 --- a/packages/babel-plugin-proposal-record-and-tuple/test/fixtures/import-polyfill/custom-name/options.json +++ b/packages/babel-plugin-proposal-record-and-tuple/test/fixtures/import-polyfill/custom-name/options.json @@ -1,7 +1,11 @@ { - "plugins": [["proposal-record-and-tuple", { - "syntaxType": "hash", - "importPolyfill": true, - "polyfillModuleName": "my-polyfill" - }]] + "plugins": [ + [ + "proposal-record-and-tuple", + { + "importPolyfill": true, + "polyfillModuleName": "my-polyfill" + } + ] + ] } diff --git a/packages/babel-plugin-proposal-record-and-tuple/test/fixtures/import-polyfill/default-name/options.json b/packages/babel-plugin-proposal-record-and-tuple/test/fixtures/import-polyfill/default-name/options.json index e7f8ad8681fc..eaf5cfcff681 100644 --- a/packages/babel-plugin-proposal-record-and-tuple/test/fixtures/import-polyfill/default-name/options.json +++ b/packages/babel-plugin-proposal-record-and-tuple/test/fixtures/import-polyfill/default-name/options.json @@ -1,6 +1,10 @@ { - "plugins": [["proposal-record-and-tuple", { - "syntaxType": "hash", - "importPolyfill": true - }]] + "plugins": [ + [ + "proposal-record-and-tuple", + { + "importPolyfill": true + } + ] + ] } diff --git a/packages/babel-plugin-proposal-record-and-tuple/test/fixtures/import-polyfill/options.json b/packages/babel-plugin-proposal-record-and-tuple/test/fixtures/import-polyfill/options.json new file mode 100644 index 000000000000..cbf6d1595427 --- /dev/null +++ b/packages/babel-plugin-proposal-record-and-tuple/test/fixtures/import-polyfill/options.json @@ -0,0 +1,3 @@ +{ + "BABEL_8_BREAKING": true +} diff --git a/packages/babel-plugin-proposal-record-and-tuple/test/fixtures/syntax-babel-7/bar/input.js b/packages/babel-plugin-proposal-record-and-tuple/test/fixtures/syntax-babel-7/bar/input.js new file mode 100644 index 000000000000..4a2296f0b5b8 --- /dev/null +++ b/packages/babel-plugin-proposal-record-and-tuple/test/fixtures/syntax-babel-7/bar/input.js @@ -0,0 +1,23 @@ +"use strict"; + +const r1 = {| + a: 1, + b: 2, + c: 3, +|}; + +const r2 = {| + a: {| + b: {| + c: 123, + |}, + d: 456, + |}, + e: 789, +|}; + +const t1 = [||]; + +const t2 = [|1,2,3|]; + +const t3 = [|1, [|2, 3, [|4|], 5|], 6|]; diff --git a/packages/babel-plugin-proposal-record-and-tuple/test/fixtures/syntax-babel-7/bar/options.json b/packages/babel-plugin-proposal-record-and-tuple/test/fixtures/syntax-babel-7/bar/options.json new file mode 100644 index 000000000000..d71eb7b25bc2 --- /dev/null +++ b/packages/babel-plugin-proposal-record-and-tuple/test/fixtures/syntax-babel-7/bar/options.json @@ -0,0 +1,3 @@ +{ + "plugins": [["proposal-record-and-tuple", { "syntaxType": "bar" }]] +} diff --git a/packages/babel-plugin-proposal-record-and-tuple/test/fixtures/syntax/bar/output.js b/packages/babel-plugin-proposal-record-and-tuple/test/fixtures/syntax-babel-7/bar/output.js similarity index 100% rename from packages/babel-plugin-proposal-record-and-tuple/test/fixtures/syntax/bar/output.js rename to packages/babel-plugin-proposal-record-and-tuple/test/fixtures/syntax-babel-7/bar/output.js diff --git a/packages/babel-plugin-proposal-record-and-tuple/test/fixtures/syntax-babel-7/hash/input.js b/packages/babel-plugin-proposal-record-and-tuple/test/fixtures/syntax-babel-7/hash/input.js new file mode 100644 index 000000000000..a280a50faf42 --- /dev/null +++ b/packages/babel-plugin-proposal-record-and-tuple/test/fixtures/syntax-babel-7/hash/input.js @@ -0,0 +1,21 @@ +"use strict"; + +const r1 = #{ + a: 1, + b: 2, + c: 3, +}; + +const r2 = #{ + a: #{ + b: #{ + c: 123, + }, + d: 456, + }, + e: 789, +}; + +const t1 = #[1,2,3]; + +const t2 = #[1, #[2, 3, #[4], 5], 6]; diff --git a/packages/babel-plugin-proposal-record-and-tuple/test/fixtures/syntax-babel-7/hash/options.json b/packages/babel-plugin-proposal-record-and-tuple/test/fixtures/syntax-babel-7/hash/options.json new file mode 100644 index 000000000000..c05cae49a024 --- /dev/null +++ b/packages/babel-plugin-proposal-record-and-tuple/test/fixtures/syntax-babel-7/hash/options.json @@ -0,0 +1,3 @@ +{ + "plugins": [["proposal-record-and-tuple", { "syntaxType": "hash" }]] +} diff --git a/packages/babel-plugin-proposal-record-and-tuple/test/fixtures/syntax/hash/output.js b/packages/babel-plugin-proposal-record-and-tuple/test/fixtures/syntax-babel-7/hash/output.js similarity index 100% rename from packages/babel-plugin-proposal-record-and-tuple/test/fixtures/syntax/hash/output.js rename to packages/babel-plugin-proposal-record-and-tuple/test/fixtures/syntax-babel-7/hash/output.js diff --git a/packages/babel-plugin-proposal-record-and-tuple/test/fixtures/syntax-babel-7/options.json b/packages/babel-plugin-proposal-record-and-tuple/test/fixtures/syntax-babel-7/options.json new file mode 100644 index 000000000000..29a3f0e84167 --- /dev/null +++ b/packages/babel-plugin-proposal-record-and-tuple/test/fixtures/syntax-babel-7/options.json @@ -0,0 +1,3 @@ +{ + "BABEL_8_BREAKING": false +} diff --git a/packages/babel-plugin-proposal-record-and-tuple/test/fixtures/syntax/bar/options.json b/packages/babel-plugin-proposal-record-and-tuple/test/fixtures/syntax/bar/options.json index d71eb7b25bc2..ca655056f908 100644 --- a/packages/babel-plugin-proposal-record-and-tuple/test/fixtures/syntax/bar/options.json +++ b/packages/babel-plugin-proposal-record-and-tuple/test/fixtures/syntax/bar/options.json @@ -1,3 +1,4 @@ { - "plugins": [["proposal-record-and-tuple", { "syntaxType": "bar" }]] + "plugins": [["proposal-record-and-tuple", { "syntaxType": "bar" }]], + "throws": "@babel/plugin-proposal-record-and-tuple: The syntaxType option is no longer supported. Please remove { syntaxType: \"bar\" } from your Babel config and migrate to the hash syntax #{} and #[]." } diff --git a/packages/babel-plugin-proposal-record-and-tuple/test/fixtures/syntax/default/input.js b/packages/babel-plugin-proposal-record-and-tuple/test/fixtures/syntax/default/input.js new file mode 100644 index 000000000000..a280a50faf42 --- /dev/null +++ b/packages/babel-plugin-proposal-record-and-tuple/test/fixtures/syntax/default/input.js @@ -0,0 +1,21 @@ +"use strict"; + +const r1 = #{ + a: 1, + b: 2, + c: 3, +}; + +const r2 = #{ + a: #{ + b: #{ + c: 123, + }, + d: 456, + }, + e: 789, +}; + +const t1 = #[1,2,3]; + +const t2 = #[1, #[2, 3, #[4], 5], 6]; diff --git a/packages/babel-plugin-proposal-record-and-tuple/test/fixtures/syntax/default/options.json b/packages/babel-plugin-proposal-record-and-tuple/test/fixtures/syntax/default/options.json new file mode 100644 index 000000000000..5b559693c096 --- /dev/null +++ b/packages/babel-plugin-proposal-record-and-tuple/test/fixtures/syntax/default/options.json @@ -0,0 +1,3 @@ +{ + "plugins": [["proposal-record-and-tuple"]] +} diff --git a/packages/babel-plugin-proposal-record-and-tuple/test/fixtures/syntax/default/output.js b/packages/babel-plugin-proposal-record-and-tuple/test/fixtures/syntax/default/output.js new file mode 100644 index 000000000000..f3676e85dc69 --- /dev/null +++ b/packages/babel-plugin-proposal-record-and-tuple/test/fixtures/syntax/default/output.js @@ -0,0 +1,18 @@ +"use strict"; + +const r1 = Record({ + a: 1, + b: 2, + c: 3 +}); +const r2 = Record({ + a: Record({ + b: Record({ + c: 123 + }), + d: 456 + }), + e: 789 +}); +const t1 = Tuple(1, 2, 3); +const t2 = Tuple(1, Tuple(2, 3, Tuple(4), 5), 6); diff --git a/packages/babel-plugin-proposal-record-and-tuple/test/fixtures/syntax/hash/options.json b/packages/babel-plugin-proposal-record-and-tuple/test/fixtures/syntax/hash/options.json index c05cae49a024..3858c060ab92 100644 --- a/packages/babel-plugin-proposal-record-and-tuple/test/fixtures/syntax/hash/options.json +++ b/packages/babel-plugin-proposal-record-and-tuple/test/fixtures/syntax/hash/options.json @@ -1,3 +1,4 @@ { - "plugins": [["proposal-record-and-tuple", { "syntaxType": "hash" }]] + "plugins": [["proposal-record-and-tuple", { "syntaxType": "hash" }]], + "throws": "@babel/plugin-proposal-record-and-tuple: The syntaxType option is no longer supported. You can safely remove { syntaxType: \"hash\" } from your Babel config." } diff --git a/packages/babel-plugin-proposal-record-and-tuple/test/fixtures/syntax/options.json b/packages/babel-plugin-proposal-record-and-tuple/test/fixtures/syntax/options.json new file mode 100644 index 000000000000..cbf6d1595427 --- /dev/null +++ b/packages/babel-plugin-proposal-record-and-tuple/test/fixtures/syntax/options.json @@ -0,0 +1,3 @@ +{ + "BABEL_8_BREAKING": true +} diff --git a/packages/babel-plugin-syntax-record-and-tuple/src/index.ts b/packages/babel-plugin-syntax-record-and-tuple/src/index.ts index 895312d65980..7089b910f81b 100644 --- a/packages/babel-plugin-syntax-record-and-tuple/src/index.ts +++ b/packages/babel-plugin-syntax-record-and-tuple/src/index.ts @@ -6,17 +6,32 @@ export interface Options { export default declare((api, options: Options) => { api.assertVersion(REQUIRED_VERSION(7)); + if (process.env.BABEL_8_BREAKING) { + if (options.syntaxType === "bar") { + throw new Error( + '@babel/plugin-proposal-record-and-tuple: The syntaxType option is no longer supported. Please remove { syntaxType: "bar" } from your Babel config and migrate to the hash syntax #{} and #[].', + ); + } else if (options.syntaxType === "hash") { + throw new Error( + '@babel/plugin-proposal-record-and-tuple: The syntaxType option is no longer supported. You can safely remove { syntaxType: "hash" } from your Babel config.', + ); + } + } return { name: "syntax-record-and-tuple", manipulateOptions(opts, parserOpts) { - opts.generatorOpts.recordAndTupleSyntaxType = options.syntaxType; + if (process.env.BABEL_8_BREAKING) { + parserOpts.plugins.push("recordAndTuple"); + } else { + opts.generatorOpts.recordAndTupleSyntaxType = options.syntaxType; - parserOpts.plugins.push([ - "recordAndTuple", - { syntaxType: options.syntaxType }, - ]); + parserOpts.plugins.push([ + "recordAndTuple", + { syntaxType: options.syntaxType }, + ]); + } }, }; }); diff --git a/packages/babel-standalone/src/preset-stage-1.ts b/packages/babel-standalone/src/preset-stage-1.ts index 9605af19b625..d68c6582a18f 100644 --- a/packages/babel-standalone/src/preset-stage-1.ts +++ b/packages/babel-standalone/src/preset-stage-1.ts @@ -10,7 +10,6 @@ export default (_: any, opts: any = {}) => { decoratorsBeforeExport, pipelineProposal, pipelineTopicToken, - recordAndTupleSyntax, optionalChainingAssignVersion = "2023-07", } = opts; @@ -18,16 +17,26 @@ export default (_: any, opts: any = {}) => { presets: [ [ presetStage2, - { - loose, - useBuiltIns, - decoratorsLegacy, - decoratorsVersion, - decoratorsBeforeExport, - pipelineProposal, - pipelineTopicToken, - recordAndTupleSyntax, - }, + process.env.BABEL_8_BREAKING + ? { + loose, + useBuiltIns, + decoratorsLegacy, + decoratorsVersion, + decoratorsBeforeExport, + pipelineProposal, + pipelineTopicToken, + } + : { + loose, + useBuiltIns, + decoratorsLegacy, + decoratorsVersion, + decoratorsBeforeExport, + pipelineProposal, + pipelineTopicToken, + recordAndTupleSyntax: opts.recordAndTupleSyntax, + }, ], ], plugins: [ diff --git a/packages/babel-standalone/src/preset-stage-2.ts b/packages/babel-standalone/src/preset-stage-2.ts index 80ba3c32452e..57608414e686 100644 --- a/packages/babel-standalone/src/preset-stage-2.ts +++ b/packages/babel-standalone/src/preset-stage-2.ts @@ -2,11 +2,7 @@ import presetStage3 from "./preset-stage-3.ts"; import * as babelPlugins from "./generated/plugins.ts"; export default (_: any, opts: any = {}) => { - const { - pipelineProposal = "minimal", - pipelineTopicToken = "%", - recordAndTupleSyntax = "hash", - } = opts; + const { pipelineProposal = "minimal", pipelineTopicToken = "%" } = opts; return { presets: [[presetStage3, opts]], @@ -18,10 +14,12 @@ export default (_: any, opts: any = {}) => { ], babelPlugins.proposalFunctionSent, babelPlugins.proposalThrowExpressions, - [ - babelPlugins.proposalRecordAndTuple, - { syntaxType: recordAndTupleSyntax }, - ], + process.env.BABEL_8_BREAKING + ? babelPlugins.proposalRecordAndTuple + : [ + babelPlugins.proposalRecordAndTuple, + { syntaxType: opts.recordAndTupleSyntax ?? "hash" }, + ], babelPlugins.syntaxModuleBlocks, babelPlugins.syntaxImportReflection, ], diff --git a/packages/babel-standalone/test/preset-stage-1.test.js b/packages/babel-standalone/test/preset-stage-1.test.js index 5387e6e2dbfc..e073dd8e35bd 100644 --- a/packages/babel-standalone/test/preset-stage-1.test.js +++ b/packages/babel-standalone/test/preset-stage-1.test.js @@ -1,4 +1,5 @@ import { createRequire } from "module"; +import { itBabel7 } from "$repo-utils"; const require = createRequire(import.meta.url); describe("stage-1 preset", () => { @@ -29,7 +30,7 @@ describe("stage-1 preset", () => { expect(output).toMatchInlineSnapshot(`"x;"`); }); - it("should support hack pipeline with `#` topic token", () => { + itBabel7("should support hack pipeline with `#` topic token", () => { const output = Babel.transform("x |> #", { presets: [ [ diff --git a/packages/babel-traverse/test/path/isPure.js b/packages/babel-traverse/test/path/isPure.js index 625ab863af66..5a93edf1f6fb 100644 --- a/packages/babel-traverse/test/path/isPure.js +++ b/packages/babel-traverse/test/path/isPure.js @@ -1,4 +1,5 @@ import { parse } from "@babel/parser"; +import { IS_BABEL_8 } from "$repo-utils"; import _traverse from "../../lib/index.js"; const traverse = _traverse.default || _traverse; @@ -6,8 +7,10 @@ const traverse = _traverse.default || _traverse; function getPath(code) { const ast = parse(code, { plugins: [ - ["decorators", { version: "2021-12", decoratorsBeforeExport: true }], - ["recordAndTuple", { syntaxType: "hash" }], + ["decorators", { version: "2023-11", decoratorsBeforeExport: true }], + IS_BABEL_8() + ? "recordAndTuple" + : ["recordAndTuple", { syntaxType: "hash" }], "decoratorAutoAccessors", ["pipelineOperator", { proposal: "hack", topicToken: "%" }], ], diff --git a/scripts/integration-tests/e2e-prettier.sh b/scripts/integration-tests/e2e-prettier.sh index 28db41594bf6..1d00ce49af00 100755 --- a/scripts/integration-tests/e2e-prettier.sh +++ b/scripts/integration-tests/e2e-prettier.sh @@ -27,6 +27,8 @@ if [ "$BABEL_8_BREAKING" = true ] ; then sed -i 's/const generate = babelGenerator.default/const generate = babelGenerator/' scripts/build/transform/index.js sed -i 's/,"updateContext":null//g' tests/integration/__tests__/__snapshots__/debug-print-ast.js.snap rm tests/unit/__snapshots__/visitor-keys.js.snap + # Update recordAndTuple usage + sed -i 's/\["recordAndTuple", { syntaxType: "hash" }\]/"recordAndTuple"/' src/language-js/parse/babel.js fi #==============================================================================#