diff --git a/.circleci/config.yml b/.circleci/config.yml index dfa4bf21bf96..f654bb91c696 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,4 +1,5 @@ -version: 2 +version: 2.1 + aliases: - &restore-node-modules-cache keys: @@ -39,15 +40,22 @@ aliases: - &artifact_test262_xunit path: ~/test-results + - &artifact_test262_diff_tap + path: ~/diff.tap + +executors: + node-executor: + docker: + - image: circleci/node:13 + working_directory: ~/babel + jobs: test: - working_directory: ~/babel - docker: - - image: circleci/node:12 + executor: node-executor steps: - checkout - - restore-cache: *restore-yarn-cache - - restore-cache: *restore-node-modules-cache + - restore_cache: *restore-yarn-cache + - restore_cache: *restore-node-modules-cache - run: yarn --version - run: make test-ci-coverage # Builds babel-standalone with the regular Babel config @@ -63,14 +71,21 @@ jobs: - store_artifacts: *artifact_env_min - save_cache: *save-node-modules-cache - save_cache: *save-yarn-cache + test262: - working_directory: ~/babel - docker: - - image: circleci/node:12 + executor: node-executor steps: - checkout - - restore-cache: *restore-yarn-cache - - restore-cache: *restore-node-modules-cache + - run: + name: Sync with latest master branch (only on PRs) + command: | + if [ -n "$CIRCLE_PULL_REQUEST" ] + then + git fetch origin refs/pull/$CIRCLE_PR_NUMBER/merge + git checkout -qf FETCH_HEAD + fi + - restore_cache: *restore-yarn-cache + - restore_cache: *restore-node-modules-cache - run: name: Build Babel command: BABEL_ENV=test make bootstrap @@ -96,27 +111,85 @@ jobs: yarn link $(./jq -j ".name" $package) done node lib/download-node + - run: + name: Download master branch Test262 artifact + command: node lib/download-master-artifact ~/master.tap + <<: *test262_workdir - run: name: Run Test262 command: node lib/run-tests I_AM_SURE | tee ~/test262.tap <<: *test262_workdir - store_artifacts: *artifact_test262_tap - run: - name: Output test262 results + name: Output Test262 results command: | cat ~/test262.tap | $(npm bin)/tap-mocha-reporter spec || true <<: *test262_workdir + - run: + name: Compare previous master branch & current job results + command: | + mkdir -p ~/test-results/test262 + node lib/compare-results ~/master.tap ~/test262.tap | tee ~/diff.tap + <<: *test262_workdir + - store_artifacts: *artifact_test262_diff_tap + - run: + name: Output comparision results and report to CircleCI + command: | + mkdir -p ~/test-results/test262 + cat ~/diff.tap | $(npm bin)/tap-merge | $(npm bin)/tap-mocha-reporter xunit | tee ~/test-results/test262/results.xml + <<: *test262_workdir + - store_test_results: *artifact_test262_xunit + publish-verdaccio: + executor: node-executor + steps: + - checkout + - run: yarn install + - run: ./scripts/integration-tests/publish-local.sh + - persist_to_workspace: + root: /tmp/verdaccio-workspace + paths: + - storage + - htpasswd + + e2e-babel: + executor: node-executor + steps: + - checkout + - attach_workspace: + at: /tmp/verdaccio-workspace + - run: ./scripts/integration-tests/e2e-babel.sh workflows: version: 2 test: jobs: - test - master: + test262-master: jobs: - test262: filters: branches: only: - master + test262: + jobs: + - approve-test262-run: + type: approval + filters: + branches: + ignore: + - master + - test262: + requires: + - approve-test262-run + filters: + branches: + ignore: + - master + e2e: + jobs: + - publish-verdaccio + - e2e-babel: + requires: + - publish-verdaccio diff --git a/.eslintignore b/.eslintignore index 092fbbb802cd..ab694692690c 100644 --- a/.eslintignore +++ b/.eslintignore @@ -24,3 +24,7 @@ packages/babel-preset-env-standalone/babel-preset-env.min.js packages/babel-standalone/babel.js packages/babel-standalone/babel.min.js packages/babel-parser/test/expressions + +eslint/*/node_modules +eslint/*/test +eslint/*/tests diff --git a/.travis.yml b/.travis.yml index 4b897a8e1a1a..d9fce0df2bd8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -27,16 +27,16 @@ matrix: include: - node_js: "node" env: JOB=lint - # We test the latest version on circleci - - node_js: "11" - # Move `windows` build to be the third since it is slow + # We test the latest version on circleci + - node_js: "12" + # Move `windows` build to be the third since it is slow - os: windows node_js: "node" env: - - JOB=test - # https://travis-ci.community/t/build-doesnt-finish-after-completing-tests/288/9 - - YARN_GPG=no - # Continue node_js matrix + - JOB=test + # https://travis-ci.community/t/build-doesnt-finish-after-completing-tests/288/9 + - YARN_GPG=no + # Continue node_js matrix - node_js: "6" - node_js: "10" - node_js: "8" diff --git a/CHANGELOG.md b/CHANGELOG.md index 9689c1be5cb1..ef3a4efcb9a6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,129 @@ See [Babylon's CHANGELOG](packages/babylon/CHANGELOG.md) for the Babylon pre-7.0 +## v7.7.3 (2019-11-08) + +#### :bug: Bug Fix +* `babel-parser` + * [#10682](https://github.com/babel/babel/pull/10682) Don't recover from "adjacent jsx elements" parser error ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo)) +## v7.7.2 (2019-11-07) + +#### :bug: Bug Fix +* `babel-parser` + * [#10669](https://github.com/babel/babel/pull/10669) Parse arrows with params annotations in conditional expressions ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo)) +* `babel-plugin-transform-typescript` + * [#10658](https://github.com/babel/babel/pull/10658) fix: remove accessibility of constructor ([@JLHwung](https://github.com/JLHwung)) +* `babel-traverse` + * [#10656](https://github.com/babel/babel/pull/10656) fix: add inList setter for compatibility with babel-minify ([@JLHwung](https://github.com/JLHwung)) +## v7.7.1 (2019-11-05) + +#### :bug: Bug Fix +* `babel-types` + * [#10650](https://github.com/babel/babel/pull/10650) Revert "throw a TypeError if identifier validation fails (#10621)" ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo)) +* `babel-preset-env` + * [#10649](https://github.com/babel/babel/pull/10649) Fix(babel-preset-env): check api.caller is a function to avoid to thr… ([@love2me](https://github.com/love2me)) + +## v7.7.0 (2019-11-05) + +#### :eyeglasses: Spec Compliance +* `babel-types` + * [#10621](https://github.com/babel/babel/pull/10621) throw a TypeError if identifier validation fails. ([@dentrado](https://github.com/dentrado)) +* `babel-parser` + * [#10559](https://github.com/babel/babel/pull/10559) fix: Exclude catch clause from let identifier error. ([@gonzarodriguezt](https://github.com/gonzarodriguezt)) + * [#10567](https://github.com/babel/babel/pull/10567) [parser] Exception to 8 and 9 in tagged template. ([@pnowak](https://github.com/pnowak)) + * [#10532](https://github.com/babel/babel/pull/10532) Allow duplicate __proto__ keys in patterns, simple case (#6705). ([@alejo90](https://github.com/alejo90)) + +#### :rocket: New Feature +* `babel-generator`, `babel-helper-create-class-features-plugin`, `babel-parser`, `babel-plugin-transform-typescript`, `babel-preset-typescript`, `babel-types` + * [#10545](https://github.com/babel/babel/pull/10545) Add support for TS declare modifier on fields. ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo)) +* `babel-core`, `babel-parser`, `babel-preset-typescript` + * [#10363](https://github.com/babel/babel/pull/10363) @babel/parser error recovery. ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo)) +* `babel-core` + * [#10599](https://github.com/babel/babel/pull/10599) Add support for .cjs config files. ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo)) + * [#10501](https://github.com/babel/babel/pull/10501) Add support for babel.config.json. ([@devongovett](https://github.com/devongovett)) + * [#10361](https://github.com/babel/babel/pull/10361) feat: if code frame error is on a single line, highlight the whole path. ([@SimenB](https://github.com/SimenB)) +* `babel-plugin-syntax-top-level-await`, `babel-preset-env` + * [#10573](https://github.com/babel/babel/pull/10573) Create @babel/plugin-syntax-top-level-await. ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo)) +* `babel-helper-builder-react-jsx`, `babel-plugin-transform-react-jsx`, `babel-preset-react` + * [#10572](https://github.com/babel/babel/pull/10572) [transform-react-jsx] Add useSpread option to transform JSX. ([@ivandevp](https://github.com/ivandevp)) +* `babel-generator`, `babel-parser`, `babel-plugin-proposal-decorators`, `babel-plugin-syntax-flow`, `babel-types` + * [#10344](https://github.com/babel/babel/pull/10344) Flow enums parsing. ([@gkz](https://github.com/gkz)) +* `babel-plugin-transform-function-name`, `babel-plugin-transform-modules-umd`, `babel-preset-env` + * [#10477](https://github.com/babel/babel/pull/10477) Changes UMD callsite to be more likely to pass in the intended object.. ([@MicahZoltu](https://github.com/MicahZoltu)) +* `babel-parser` + * [#10449](https://github.com/babel/babel/pull/10449) Create parser plugin "topLevelAwait". ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo)) + * [#10521](https://github.com/babel/babel/pull/10521) [parser] Enable "exportNamespaceFrom" by default. ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo)) + * [#10483](https://github.com/babel/babel/pull/10483) [parser] Add support for private fields in TypeScript. ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo)) +* `babel-generator`, `babel-parser`, `babel-types` + * [#10543](https://github.com/babel/babel/pull/10543) add assertions signature for TypeScript. ([@tanhauhau](https://github.com/tanhauhau)) +* `babel-cli`, `babel-register` + * [#8622](https://github.com/babel/babel/pull/8622) Make dir for babel --out-file. ([@TrySound](https://github.com/TrySound)) +* `babel-cli` + * [#10399](https://github.com/babel/babel/pull/10399) Closes [#8326](https://github.com/babel/babel/issues/8326), add back --quiet option.. ([@chris-peng-1244](https://github.com/chris-peng-1244)) + +#### :bug: Bug Fix +* `babel-helpers`, `babel-plugin-proposal-async-generator-functions`, `babel-plugin-proposal-function-sent`, `babel-preset-env` + * [#10422](https://github.com/babel/babel/pull/10422) Correctly delegate .return() in async generator. ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo)) +* `babel-helper-module-transforms`, `babel-plugin-transform-modules-commonjs` + * [#10628](https://github.com/babel/babel/pull/10628) Don't throw when destructuring into a var named as an import. ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo)) +* `babel-plugin-transform-modules-systemjs` + * [#10638](https://github.com/babel/babel/pull/10638) fix: remove ExportNamedDeclaration when the specifier is empty. ([@JLHwung](https://github.com/JLHwung)) +* `babel-parser` + * [#10631](https://github.com/babel/babel/pull/10631) [TS] Parse calls with type args in optional chains. ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo)) + * [#10607](https://github.com/babel/babel/pull/10607) fixed missing errors on assignment pattern in object expression. ([@vivek12345](https://github.com/vivek12345)) + * [#10594](https://github.com/babel/babel/pull/10594) [parser] Parse only modifiers of actual methods. ([@gonzarodriguezt](https://github.com/gonzarodriguezt)) +* `babel-plugin-transform-typescript` + * [#10555](https://github.com/babel/babel/pull/10555) [TS] Correctly transform computed strings and templates in enums. ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo)) +* `babel-core` + * [#10623](https://github.com/babel/babel/pull/10623) Fix: inputSourceMap should work when it is an external file. ([@JLHwung](https://github.com/JLHwung)) + * [#10539](https://github.com/babel/babel/pull/10539) fix: remove filename annotation in buildCodeFrameError. ([@JLHwung](https://github.com/JLHwung)) +* `babel-plugin-proposal-decorators` + * [#10578](https://github.com/babel/babel/pull/10578) [decorators] fix: support string literal properties. ([@mwhitworth](https://github.com/mwhitworth)) +* `babel-helpers`, `babel-plugin-proposal-dynamic-import`, `babel-plugin-transform-modules-commonjs`, `babel-preset-env` + * [#10574](https://github.com/babel/babel/pull/10574) fix: _interopRequireWildcard should only cache objects. ([@samMeow](https://github.com/samMeow)) +* `babel-traverse` + * [#9777](https://github.com/babel/babel/pull/9777) [traverse] Allow skipping nodes inserted with .replaceWith(). ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo)) +* `babel-preset-env` + * [#10146](https://github.com/babel/babel/pull/10146) Inject core-js@3 imports in Program:exit instead of on post(). ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo)) +* `babel-generator` + * [#10519](https://github.com/babel/babel/pull/10519) Fix generator missing parens around an arrow returning function type. ([@existentialism](https://github.com/existentialism)) +* `babel-plugin-transform-async-to-generator`, `babel-preset-env`, `babel-traverse` + * [#9939](https://github.com/babel/babel/pull/9939) Don't use args rest/spread to hoist super method calls. ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo)) + +#### :nail_care: Polish +* `babel-plugin-transform-classes`, `babel-plugin-transform-regenerator`, `babel-preset-env` + * [#9481](https://github.com/babel/babel/pull/9481) [preset-env] Don't use async-to-generator when already using regenerator. ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo)) +* `babel-helpers`, `babel-plugin-transform-modules-commonjs`, `babel-preset-env` + * [#10585](https://github.com/babel/babel/pull/10585) fix(babel‑helpers/interopRequireWildcard): Avoid double nullish check. ([@ExE-Boss](https://github.com/ExE-Boss)) +* `babel-register` + * [#10557](https://github.com/babel/babel/pull/10557) fix: disable caching when babel could not read/write cache. ([@JLHwung](https://github.com/JLHwung)) + +#### :house: Internal +* `babel-cli`, `babel-node` + * [#10619](https://github.com/babel/babel/pull/10619) chore: remove output-file-sync dependency. ([@JLHwung](https://github.com/JLHwung)) +* `babel-register` + * [#10614](https://github.com/babel/babel/pull/10614) chore: bump source-map-support to 0.5.14. ([@JLHwung](https://github.com/JLHwung)) +* `babel-helper-create-regexp-features-plugin`, `babel-plugin-proposal-unicode-property-regex`, `babel-plugin-transform-dotall-regex`, `babel-plugin-transform-named-capturing-groups-regex`, `babel-plugin-transform-unicode-regex`, `babel-preset-env` + * [#10447](https://github.com/babel/babel/pull/10447) Merge multiple regex transform plugin. ([@JLHwung](https://github.com/JLHwung)) +* `babel-preset-env` + * [#10612](https://github.com/babel/babel/pull/10612) chore: update web.immediate support fixtures. ([@JLHwung](https://github.com/JLHwung)) +* `babel-helper-module-imports` + * [#10608](https://github.com/babel/babel/pull/10608) Use .find instead of .filter to get targetPath in ImportInjector. ([@Andarist](https://github.com/Andarist)) +* Other + * [#10600](https://github.com/babel/babel/pull/10600) Test node@13 on circle. ([@existentialism](https://github.com/existentialism)) + * [#10593](https://github.com/babel/babel/pull/10593) chore: replace outdated travis-ci.org badges [ci skip]. ([@JLHwung](https://github.com/JLHwung)) + * [#10591](https://github.com/babel/babel/pull/10591) chore: test against Node.js 13. ([@JLHwung](https://github.com/JLHwung)) + * [#10556](https://github.com/babel/babel/pull/10556) Add master branch workflow for test262 tests. ([@jbhoosreddy](https://github.com/jbhoosreddy)) + * [#10553](https://github.com/babel/babel/pull/10553) chore: introduce envinfo into environment section. ([@JLHwung](https://github.com/JLHwung)) +* `babel-runtime` + * [#10418](https://github.com/babel/babel/pull/10418) docs: add homepage link. ([@DanArthurGallagher](https://github.com/DanArthurGallagher)) +* `babel-helper-annotate-as-pure`, `babel-helper-bindify-decorators`, `babel-helper-builder-binary-assignment-operator-visitor`, `babel-helper-builder-react-jsx`, `babel-helper-call-delegate`, `babel-helper-define-map`, `babel-helper-explode-assignable-expression`, `babel-helper-explode-class`, `babel-helper-function-name`, `babel-helper-get-function-arity`, `babel-helper-hoist-variables`, `babel-helper-member-expression-to-functions`, `babel-helper-module-imports`, `babel-helper-module-transforms`, `babel-helper-optimise-call-expression`, `babel-helper-remap-async-to-generator`, `babel-helper-replace-supers`, `babel-helper-simple-access`, `babel-helper-split-export-declaration`, `babel-helper-wrap-function`, `babel-helpers`, `babel-template` + * [#10568](https://github.com/babel/babel/pull/10568) Bump babel-types to ^7.6.3. ([@JLHwung](https://github.com/JLHwung)) + +#### :running_woman: Performance +* `babel-traverse` + * [#10480](https://github.com/babel/babel/pull/10480) Traverse performance. ([@JLHwung](https://github.com/JLHwung)) + ## v7.6.4 (2019-10-10) #### :eyeglasses: Spec Compliance diff --git a/Makefile b/Makefile index acec39fa4486..b2b2d3c4e7b9 100644 --- a/Makefile +++ b/Makefile @@ -1,10 +1,12 @@ FLOW_COMMIT = 09669846b7a7ca5a6c23c12d56bb3bebdafd67e9 TEST262_COMMIT = 8688c4ab79059c3097098605e69f1ee5eda6c409 +FORCE_PUBLISH = "@babel/runtime,@babel/runtime-corejs2,@babel/runtime-corejs3,@babel/standalone,@babel/preset-env-standalone" + # Fix color output until TravisCI fixes https://github.com/travis-ci/travis-ci/issues/7967 export FORCE_COLOR = true -SOURCES = packages codemods +SOURCES = packages codemods eslint .PHONY: build build-dist watch lint fix clean test-clean test-only test test-ci publish bootstrap @@ -189,7 +191,7 @@ prepublish: new-version: git pull --rebase - yarn lerna version --force-publish="@babel/runtime,@babel/runtime-corejs2,@babel/runtime-corejs3,@babel/standalone,@babel/preset-env-standalone" + yarn lerna version --force-publish=$(FORCE_PUBLISH) # NOTE: Run make new-version first publish: prepublish @@ -203,17 +205,28 @@ else echo "Missing NPM_TOKEN env var" exit 1 endif - yarn lerna publish from-git --require-scripts --yes + yarn lerna publish from-git --yes rm -f .npmrc $(MAKE) clean +publish-test: +ifneq ("$(I_AM_USING_VERDACCIO)", "I_AM_SURE") + echo "You probably don't know what you are doing" + exit 1 +endif + $(MAKE) prepublish-build + yarn lerna version patch --force-publish=$(FORCE_PUBLISH) --no-push --yes --tag-version-prefix="version-e2e-test-" + yarn lerna publish from-git --registry http://localhost:4873 --yes --tag-version-prefix="version-e2e-test-" + $(MAKE) clean + bootstrap-only: lerna-bootstrap yarn-install: clean-all yarn --ignore-engines lerna-bootstrap: yarn-install - yarn lerna bootstrap +# todo: remove `-- -- --ignore-engines` in Babel 8 + yarn lerna bootstrap -- -- --ignore-engines bootstrap: bootstrap-only $(MAKE) build diff --git a/README.md b/README.md index 51315b7a7e12..190b93622139 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ v6 npm Downloads

- Travis Status + Travis Status CircleCI Status Coverage Status Slack Status diff --git a/babel.config.js b/babel.config.js index fe0f90d0bad8..c7f53eaff39a 100644 --- a/babel.config.js +++ b/babel.config.js @@ -123,7 +123,10 @@ module.exports = function(api) { ], plugins: [ includeRuntime - ? ["@babel/transform-runtime", { version: "7.4.4" }] + ? [ + "@babel/transform-runtime", + { version: require("@babel/runtime/package").version }, + ] : null, ].filter(Boolean), }, diff --git a/eslint/babel-eslint-config-internal/.gitignore b/eslint/babel-eslint-config-internal/.gitignore new file mode 100644 index 000000000000..3c3629e647f5 --- /dev/null +++ b/eslint/babel-eslint-config-internal/.gitignore @@ -0,0 +1 @@ +node_modules diff --git a/eslint/babel-eslint-config-internal/README.md b/eslint/babel-eslint-config-internal/README.md new file mode 100644 index 000000000000..5f87298ead30 --- /dev/null +++ b/eslint/babel-eslint-config-internal/README.md @@ -0,0 +1,4 @@ +## eslint-config-babel +--- + +ESLint config for the Babel codebase (originally taken from `eslint-config-kittens`) diff --git a/eslint/babel-eslint-config-internal/index.js b/eslint/babel-eslint-config-internal/index.js new file mode 100644 index 000000000000..4d8e8da89bff --- /dev/null +++ b/eslint/babel-eslint-config-internal/index.js @@ -0,0 +1,48 @@ +module.exports = { + parser: "babel-eslint", + extends: "eslint:recommended", + plugins: ["flowtype"], + parserOptions: { + ecmaVersion: 2017, + sourceType: "module", + }, + rules: { + camelcase: "off", + "consistent-return": "off", + curly: ["error", "multi-line"], + "linebreak-style": ["error", "unix"], + "max-len": ["error", 110, 2], + "new-cap": "off", + "no-case-declarations": "error", + "no-cond-assign": "off", + "no-confusing-arrow": "error", + "no-console": "off", + "no-constant-condition": "off", + "no-empty": "off", + "no-fallthrough": "off", + "no-inner-declarations": "off", + "no-labels": "off", + "no-loop-func": "off", + "no-process-exit": "off", + "no-return-assign": "off", + "no-shadow": "off", + "no-underscore-dangle": "off", + "no-unreachable": "off", + "no-use-before-define": "off", + "no-var": "error", + "prefer-const": "error", + strict: "off", + "flowtype/define-flow-type": "warn", + "flowtype/use-flow-type": "warn", + }, + globals: { + // Flow + Iterator: true, + $Keys: true, + }, + env: { + node: true, + es6: true, + browser: true, + }, +}; diff --git a/eslint/babel-eslint-config-internal/package.json b/eslint/babel-eslint-config-internal/package.json new file mode 100644 index 000000000000..a46867e3c69f --- /dev/null +++ b/eslint/babel-eslint-config-internal/package.json @@ -0,0 +1,20 @@ +{ + "name": "eslint-config-babel", + "version": "9.0.0", + "description": "ESLint config for babel", + "author": "Sebastian McKenzie ", + "homepage": "https://babeljs.io/", + "license": "MIT", + "repository": { + "type": "git", + "url": "https://github.com/babel/eslint-config-babel" + }, + "main": "index.js", + "peerDependencies": { + "babel-eslint": "^10.0.0 || ^11.0.0-0", + "eslint-plugin-flowtype": "^3.0.0" + }, + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + } +} diff --git a/eslint/babel-eslint-parser/.eslintignore b/eslint/babel-eslint-parser/.eslintignore new file mode 100644 index 000000000000..b18b9022cf17 --- /dev/null +++ b/eslint/babel-eslint-parser/.eslintignore @@ -0,0 +1,2 @@ +!.*.js +test/fixtures diff --git a/eslint/babel-eslint-parser/.eslintrc.js b/eslint/babel-eslint-parser/.eslintrc.js new file mode 100644 index 000000000000..a8781be62911 --- /dev/null +++ b/eslint/babel-eslint-parser/.eslintrc.js @@ -0,0 +1,26 @@ +"use strict"; + +module.exports = { + root: true, + extends: "babel", + plugins: ["prettier"], + rules: { + "max-len": "off", + strict: "error", + "prettier/prettier": "error", + }, + env: { + node: true, + }, + parserOptions: { + sourceType: "script", + }, + overrides: [ + { + files: ["test/**/*"], + env: { + mocha: true, + }, + }, + ], +}; diff --git a/eslint/babel-eslint-parser/.gitignore b/eslint/babel-eslint-parser/.gitignore new file mode 100644 index 000000000000..93f136199161 --- /dev/null +++ b/eslint/babel-eslint-parser/.gitignore @@ -0,0 +1,2 @@ +node_modules +npm-debug.log diff --git a/eslint/babel-eslint-parser/.npmrc b/eslint/babel-eslint-parser/.npmrc new file mode 100644 index 000000000000..c1ca392feaa4 --- /dev/null +++ b/eslint/babel-eslint-parser/.npmrc @@ -0,0 +1 @@ +package-lock = false diff --git a/eslint/babel-eslint-parser/.travis.yml b/eslint/babel-eslint-parser/.travis.yml new file mode 100644 index 000000000000..8ece2fc21261 --- /dev/null +++ b/eslint/babel-eslint-parser/.travis.yml @@ -0,0 +1,16 @@ +sudo: false +language: node_js +node_js: + - "12" + - "10" + - "8" + +matrix: + fast_finish: true + include: + - node_js: "node" + env: LINT=true + +script: + - 'if [ -n "${LINT-}" ]; then npm run lint ; fi' + - 'if [ -z "${LINT-}" ]; then npm test ; fi' diff --git a/eslint/babel-eslint-parser/CODE_OF_CONDUCT.md b/eslint/babel-eslint-parser/CODE_OF_CONDUCT.md new file mode 100644 index 000000000000..1219f9578c90 --- /dev/null +++ b/eslint/babel-eslint-parser/CODE_OF_CONDUCT.md @@ -0,0 +1,3 @@ +# Code of Conduct + +This project shares the same code of conduct as [Babel](https://github.com/babel/babel), which can be found [here](https://github.com/babel/babel/blob/master/CODE_OF_CONDUCT.md). diff --git a/eslint/babel-eslint-parser/CONTRIBUTING.md b/eslint/babel-eslint-parser/CONTRIBUTING.md new file mode 100644 index 000000000000..c03d5e74e105 --- /dev/null +++ b/eslint/babel-eslint-parser/CONTRIBUTING.md @@ -0,0 +1,11 @@ +# Contributing + +Thanks for contributing! + +If you're about to report an issue - please first check if it's already been reported in the [issues page](https://github.com/babel/babel-eslint/issues). + +Also check to see if the latest versions of eslint/babel-eslint still produce the issue. + +Also check out the [Known Issues](https://github.com/babel/babel-eslint#known-issues) section of the README. + +If you are having issues with JSX you might want to check out eslint-plugin-react. If there's an issue with new experimental syntax you might need to report that in eslint-plugin-babel instead. diff --git a/eslint/babel-eslint-parser/LICENSE b/eslint/babel-eslint-parser/LICENSE new file mode 100644 index 000000000000..80194a854b94 --- /dev/null +++ b/eslint/babel-eslint-parser/LICENSE @@ -0,0 +1,22 @@ +Copyright (c) 2014-2016 Sebastian McKenzie + +MIT License + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/eslint/babel-eslint-parser/Makefile b/eslint/babel-eslint-parser/Makefile new file mode 100644 index 000000000000..d35bcfa016e2 --- /dev/null +++ b/eslint/babel-eslint-parser/Makefile @@ -0,0 +1,7 @@ +.PHONY: publish-patch + +publish-patch: + ./node_modules/.bin/mocha + npm version patch + npm publish + git push --follow-tags diff --git a/eslint/babel-eslint-parser/README.md b/eslint/babel-eslint-parser/README.md new file mode 100644 index 000000000000..cc7fd8f5141c --- /dev/null +++ b/eslint/babel-eslint-parser/README.md @@ -0,0 +1,128 @@ +# babel-eslint [![npm](https://img.shields.io/npm/v/babel-eslint.svg)](https://www.npmjs.com/package/babel-eslint) [![travis](https://img.shields.io/travis/babel/babel-eslint/master.svg)](https://travis-ci.org/babel/babel-eslint) [![npm-downloads](https://img.shields.io/npm/dm/babel-eslint.svg)](https://www.npmjs.com/package/babel-eslint) + +**babel-eslint** allows you to lint **ALL** valid Babel code with the fantastic +[ESLint](https://github.com/eslint/eslint). + +## Breaking change in v11.x.x + +As of the v11.x.x release, babel-eslint now requires Babel as a peer dependency and expects a valid [Babel configuration file](https://babeljs.io/docs/en/configuration) to exist. This ensures that the same Babel configuration is used during both linting and compilation. + +## When should I use babel-eslint? + +ESLint's default parser and core rules [only support the latest final ECMAScript standard](https://github.com/eslint/eslint/blob/a675c89573836adaf108a932696b061946abf1e6/README.md#what-about-experimental-features) and do not support experimental (such as new features) and non-standard (such as Flow or TypeScript types) syntax provided by Babel. babel-eslint is a parser that allows ESLint to run on source code that is transformed by Babel. + +**Note:** You only need to use babel-eslint if you are using Babel to transform your code. If this is not the case, please use the relevant parser for your chosen flavor of ECMAScript (note that the default parser supports all non-experimental syntax as well as JSX). + +## How does it work? + +ESLint allows for the use of [custom parsers](https://eslint.org/docs/developer-guide/working-with-custom-parsers). When using this plugin, your code is parsed by Babel's parser (using the configuration specified in your [Babel configuration file](https://babeljs.io/docs/en/configuration)) and the resulting AST is +transformed into an [ESTree](https://github.com/estree/estree)-compliant structure that ESLint can understand. All location info such as line numbers, +columns is also retained so you can track down errors with ease. + +**Note:** ESLint's core rules do not support experimental syntax and may therefore not work as expected when using babel-eslint. Please use the companion [`eslint-plugin-babel`](https://github.com/babel/eslint-plugin-babel) plugin for core rules that you have issues with. + +## Usage + +### Installation + +```sh +$ npm install eslint babel-eslint --save-dev +# or +$ yarn add eslint babel-eslint -D +``` + +**Note:** babel-eslint requires `babel/core@>=7.2.0` and a valid Babel configuration file to run. If you do not have this already set up, please see the [Babel Usage Guide](https://babeljs.io/docs/en/usage). + +### Setup + +To use babel-eslint, `"babel-eslint"` must be specified as the `parser` in your ESLint configuration file (see [here](https://eslint.org/docs/user-guide/configuring#specifying-parser) for more detailed information). + +**.eslintrc.js** + +```js +module.exports = { + parser: "babel-eslint", +}; +``` + +With the parser set, your configuration can be configured as described in the [Configuring ESLint](https://eslint.org/docs/user-guide/configuring) documentation. + +**Note:** The `parserOptions` described in the [official documentation](https://eslint.org/docs/user-guide/configuring#specifying-parser-options) are for the default parser and are not necessarily supported by babel-eslint. Please see the section directly below for supported `parserOptions`. + +### Additional parser configuration + +Additional configuration options can be set in your ESLint configuration under the `parserOptions` key. Please note that the `ecmaFeatures` config property may still be required for ESLint to work properly with features not in ECMAScript 5 by default. + +- `requireConfigFile` (default `true`) can be set to `false` to allow babel-eslint to run on files that do not have a Babel configuration associated with them. This can be useful for linting files that are not transformed by Babel (such as tooling configuration files), though we recommend using the default parser via [glob-based configuration](https://eslint.org/docs/user-guide/configuring#configuration-based-on-glob-patterns). Note: babel-eslint will not parse any experimental syntax when no configuration file is found. +- `sourceType` can be set to `"module"`(default) or `"script"` if your code isn't using ECMAScript modules. +- `allowImportExportEverywhere` (default `false`) can be set to `true` to allow import and export declarations to appear anywhere a statement is allowed if your build environment supports that. Otherwise import and export declarations can only appear at a program's top level. +- `ecmaFeatures.globalReturn` (default `false`) allow return statements in the global scope when used with `sourceType: "script"`. +- `babelOptions` passes through Babel's configuration [loading](https://babeljs.io/docs/en/options#config-loading-options) and [merging](https://babeljs.io/docs/en/options#config-merging-options) options (for instance, in case of a monorepo). When not defined, babel-eslint will use Babel's default configuration file resolution logic. + +**.eslintrc.js** + +```js +module.exports = { + parser: "babel-eslint", + parserOptions: { + sourceType: "module", + allowImportExportEverywhere: false, + ecmaFeatures: { + globalReturn: false, + }, + babelOptions: { + configFile: "path/to/config.js", + }, + }, +}; +``` + +**.eslintrc.js using glob-based configuration** + +This configuration would use the default parser for all files except for those found by the `"files/transformed/by/babel/*.js"` glob. + +```js +module.exports = { + rules: { + indent: "error" + }, + overrides: [ + { + files: ["files/transformed/by/babel/*.js"], + parser: "babel-eslint", + } + ] +}; +``` + +### Run + +```sh +$ ./node_modules/.bin/eslint yourfile.js +``` + +## Known issues + +Flow: + +> Check out [eslint-plugin-flowtype](https://github.com/gajus/eslint-plugin-flowtype): An `eslint` plugin that makes flow type annotations global variables and marks declarations as used. Solves the problem of false positives with `no-undef` and `no-unused-vars`. + +- `no-undef` for global flow types: `ReactElement`, `ReactClass` [#130](https://github.com/babel/babel-eslint/issues/130#issuecomment-111215076) + - Workaround: define types as globals in `.eslintrc` or define types and import them `import type ReactElement from './types'` +- `no-unused-vars/no-undef` with Flow declarations (`declare module A {}`) [#132](https://github.com/babel/babel-eslint/issues/132#issuecomment-112815926) + +Modules/strict mode + +- `no-unused-vars: ["error", { vars: local }]` [#136](https://github.com/babel/babel-eslint/issues/136) + +Please check out [eslint-plugin-react](https://github.com/yannickcr/eslint-plugin-react) for React/JSX issues. + +- `no-unused-vars` with jsx + +Please check out [eslint-plugin-babel](https://github.com/babel/eslint-plugin-babel) for other issues. + +## Questions and support + +If you have an issue, please first check if it can be reproduced with the default parser and with the latest versions of `eslint` and `babel-eslint`. If it is not reproducible with the default parser, it is most likely an issue with babel-eslint. + +For questions and support please visit the [`#discussion`](https://babeljs.slack.com/messages/discussion/) Babel Slack channel (sign up [here](https://github.com/babel/notes/issues/38)) or the ESLint [Gitter](https://gitter.im/eslint/eslint). diff --git a/eslint/babel-eslint-parser/lib/analyze-scope.js b/eslint/babel-eslint-parser/lib/analyze-scope.js new file mode 100644 index 000000000000..38561521d3f8 --- /dev/null +++ b/eslint/babel-eslint-parser/lib/analyze-scope.js @@ -0,0 +1,338 @@ +"use strict"; + +const t = require("@babel/core").types; +const escope = require("eslint-scope"); +const Definition = require("eslint-scope/lib/definition").Definition; +const OriginalPatternVisitor = require("eslint-scope/lib/pattern-visitor"); +const OriginalReferencer = require("eslint-scope/lib/referencer"); +const fallback = require("eslint-visitor-keys").getKeys; +const childVisitorKeys = require("./visitor-keys"); + +const flowFlippedAliasKeys = t.FLIPPED_ALIAS_KEYS.Flow.concat([ + "ArrayPattern", + "ClassDeclaration", + "ClassExpression", + "FunctionDeclaration", + "FunctionExpression", + "Identifier", + "ObjectPattern", + "RestElement", +]); +const visitorKeysMap = Object.keys(t.VISITOR_KEYS).reduce(function(acc, key) { + const value = t.VISITOR_KEYS[key]; + if (flowFlippedAliasKeys.indexOf(value) === -1) { + acc[key] = value; + } + return acc; +}, {}); + +const propertyTypes = { + // loops + callProperties: { type: "loop", values: ["value"] }, + indexers: { type: "loop", values: ["key", "value"] }, + properties: { type: "loop", values: ["argument", "value"] }, + types: { type: "loop" }, + params: { type: "loop" }, + // single property + argument: { type: "single" }, + elementType: { type: "single" }, + qualification: { type: "single" }, + rest: { type: "single" }, + returnType: { type: "single" }, + // others + typeAnnotation: { type: "typeAnnotation" }, + typeParameters: { type: "typeParameters" }, + id: { type: "id" }, +}; + +class PatternVisitor extends OriginalPatternVisitor { + ArrayPattern(node) { + node.elements.forEach(this.visit, this); + } + + ObjectPattern(node) { + node.properties.forEach(this.visit, this); + } +} + +class Referencer extends OriginalReferencer { + // inherits. + visitPattern(node, options, callback) { + if (!node) { + return; + } + + // Visit type annotations. + this._checkIdentifierOrVisit(node.typeAnnotation); + if (t.isAssignmentPattern(node)) { + this._checkIdentifierOrVisit(node.left.typeAnnotation); + } + + // Overwrite `super.visitPattern(node, options, callback)` in order to not visit `ArrayPattern#typeAnnotation` and `ObjectPattern#typeAnnotation`. + if (typeof options === "function") { + callback = options; + options = { processRightHandNodes: false }; + } + + const visitor = new PatternVisitor(this.options, node, callback); + visitor.visit(node); + + // Process the right hand nodes recursively. + if (options.processRightHandNodes) { + visitor.rightHandNodes.forEach(this.visit, this); + } + } + + // inherits. + visitClass(node) { + // Decorators. + this._visitArray(node.decorators); + + // Flow type parameters. + const typeParamScope = this._nestTypeParamScope(node); + + // Flow super types. + this._visitTypeAnnotation(node.implements); + this._visitTypeAnnotation( + node.superTypeParameters && node.superTypeParameters.params + ); + + // Basic. + super.visitClass(node); + + // Close the type parameter scope. + if (typeParamScope) { + this.close(node); + } + } + + // inherits. + visitFunction(node) { + const typeParamScope = this._nestTypeParamScope(node); + + // Flow return types. + this._checkIdentifierOrVisit(node.returnType); + + // Basic. + super.visitFunction(node); + + // Close the type parameter scope. + if (typeParamScope) { + this.close(node); + } + } + + // inherits. + visitProperty(node) { + if (node.value && node.value.type === "TypeCastExpression") { + this._visitTypeAnnotation(node.value); + } + this._visitArray(node.decorators); + super.visitProperty(node); + } + + InterfaceDeclaration(node) { + this._createScopeVariable(node, node.id); + + const typeParamScope = this._nestTypeParamScope(node); + + // TODO: Handle mixins + this._visitArray(node.extends); + this.visit(node.body); + + if (typeParamScope) { + this.close(node); + } + } + + TypeAlias(node) { + this._createScopeVariable(node, node.id); + + const typeParamScope = this._nestTypeParamScope(node); + + this.visit(node.right); + + if (typeParamScope) { + this.close(node); + } + } + + ClassProperty(node) { + this._visitClassProperty(node); + } + + ClassPrivateProperty(node) { + this._visitClassProperty(node); + } + + DeclareModule(node) { + this._visitDeclareX(node); + } + + DeclareFunction(node) { + this._visitDeclareX(node); + } + + DeclareVariable(node) { + this._visitDeclareX(node); + } + + DeclareClass(node) { + this._visitDeclareX(node); + } + + // visit OptionalMemberExpression as a MemberExpression. + OptionalMemberExpression(node) { + super.MemberExpression(node); + } + + _visitClassProperty(node) { + this._visitTypeAnnotation(node.typeAnnotation); + this.visitProperty(node); + } + + _visitDeclareX(node) { + if (node.id) { + this._createScopeVariable(node, node.id); + } + + const typeParamScope = this._nestTypeParamScope(node); + if (typeParamScope) { + this.close(node); + } + } + + _createScopeVariable(node, name) { + this.currentScope().variableScope.__define( + name, + new Definition("Variable", name, node, null, null, null) + ); + } + + _nestTypeParamScope(node) { + if (!node.typeParameters) { + return null; + } + + const parentScope = this.scopeManager.__currentScope; + const scope = new escope.Scope( + this.scopeManager, + "type-parameters", + parentScope, + node, + false + ); + + this.scopeManager.__nestScope(scope); + for (let j = 0; j < node.typeParameters.params.length; j++) { + const name = node.typeParameters.params[j]; + scope.__define(name, new Definition("TypeParameter", name, name)); + if (name.typeAnnotation) { + this._checkIdentifierOrVisit(name); + } + } + scope.__define = function() { + return parentScope.__define.apply(parentScope, arguments); + }; + + return scope; + } + + _visitTypeAnnotation(node) { + if (!node) { + return; + } + if (Array.isArray(node)) { + node.forEach(this._visitTypeAnnotation, this); + return; + } + + // get property to check (params, id, etc...) + const visitorValues = visitorKeysMap[node.type]; + if (!visitorValues) { + return; + } + + // can have multiple properties + for (let i = 0; i < visitorValues.length; i++) { + const visitorValue = visitorValues[i]; + const propertyType = propertyTypes[visitorValue]; + const nodeProperty = node[visitorValue]; + // check if property or type is defined + if (propertyType == null || nodeProperty == null) { + continue; + } + if (propertyType.type === "loop") { + for (let j = 0; j < nodeProperty.length; j++) { + if (Array.isArray(propertyType.values)) { + for (let k = 0; k < propertyType.values.length; k++) { + const loopPropertyNode = nodeProperty[j][propertyType.values[k]]; + if (loopPropertyNode) { + this._checkIdentifierOrVisit(loopPropertyNode); + } + } + } else { + this._checkIdentifierOrVisit(nodeProperty[j]); + } + } + } else if (propertyType.type === "single") { + this._checkIdentifierOrVisit(nodeProperty); + } else if (propertyType.type === "typeAnnotation") { + this._visitTypeAnnotation(node.typeAnnotation); + } else if (propertyType.type === "typeParameters") { + for (let l = 0; l < node.typeParameters.params.length; l++) { + this._checkIdentifierOrVisit(node.typeParameters.params[l]); + } + } else if (propertyType.type === "id") { + if (node.id.type === "Identifier") { + this._checkIdentifierOrVisit(node.id); + } else { + this._visitTypeAnnotation(node.id); + } + } + } + } + + _checkIdentifierOrVisit(node) { + if (node && node.typeAnnotation) { + this._visitTypeAnnotation(node.typeAnnotation); + } else if (node && node.type === "Identifier") { + this.visit(node); + } else { + this._visitTypeAnnotation(node); + } + } + + _visitArray(nodeList) { + if (nodeList) { + for (const node of nodeList) { + this.visit(node); + } + } + } +} + +module.exports = function(ast, parserOptions) { + const options = { + ignoreEval: true, + optimistic: false, + directive: false, + nodejsScope: + ast.sourceType === "script" && + (parserOptions.ecmaFeatures && + parserOptions.ecmaFeatures.globalReturn) === true, + impliedStrict: false, + sourceType: ast.sourceType, + ecmaVersion: parserOptions.ecmaVersion, + fallback, + }; + + options.childVisitorKeys = childVisitorKeys; + + const scopeManager = new escope.ScopeManager(options); + const referencer = new Referencer(options, scopeManager); + + referencer.visit(ast); + + return scopeManager; +}; diff --git a/eslint/babel-eslint-parser/lib/babylon-to-espree/convertAST.js b/eslint/babel-eslint-parser/lib/babylon-to-espree/convertAST.js new file mode 100644 index 000000000000..9f2fb000b920 --- /dev/null +++ b/eslint/babel-eslint-parser/lib/babylon-to-espree/convertAST.js @@ -0,0 +1,99 @@ +"use strict"; + +const t = require("@babel/core").types; +const convertProgramNode = require("./convertProgramNode"); + +module.exports = function(ast, traverse, code) { + const state = { source: code }; + + // Monkey patch visitor keys in order to be able to traverse the estree nodes + t.VISITOR_KEYS.Property = t.VISITOR_KEYS.ObjectProperty; + t.VISITOR_KEYS.MethodDefinition = [ + "key", + "value", + "decorators", + "returnType", + "typeParameters", + ]; + + traverse(ast, astTransformVisitor, null, state); + + delete t.VISITOR_KEYS.Property; + delete t.VISITOR_KEYS.MethodDefinition; + + convertProgramNode(ast); +}; + +const astTransformVisitor = { + noScope: true, + enter(path) { + const node = path.node; + + // private var to track original node type + node._babelType = node.type; + + if (node.innerComments) { + delete node.innerComments; + } + + if (node.trailingComments) { + delete node.trailingComments; + } + + if (node.leadingComments) { + delete node.leadingComments; + } + }, + exit(path) { + const node = path.node; + + if (path.isTypeParameter()) { + node.type = "Identifier"; + node.typeAnnotation = node.bound; + delete node.bound; + } + + // flow: prevent "no-undef" + // for "Component" in: "let x: React.Component" + if (path.isQualifiedTypeIdentifier()) { + delete node.id; + } + // for "b" in: "var a: { b: Foo }" + if (path.isObjectTypeProperty()) { + delete node.key; + } + // for "indexer" in: "var a: {[indexer: string]: number}" + if (path.isObjectTypeIndexer()) { + delete node.id; + } + // for "param" in: "var a: { func(param: Foo): Bar };" + if (path.isFunctionTypeParam()) { + delete node.name; + } + + // modules + + if (path.isImportDeclaration()) { + delete node.isType; + } + + // template string range fixes + if (path.isTemplateLiteral()) { + for (let j = 0; j < node.quasis.length; j++) { + const q = node.quasis[j]; + q.range[0] -= 1; + if (q.tail) { + q.range[1] += 1; + } else { + q.range[1] += 2; + } + q.loc.start.column -= 1; + if (q.tail) { + q.loc.end.column += 1; + } else { + q.loc.end.column += 2; + } + } + } + }, +}; diff --git a/eslint/babel-eslint-parser/lib/babylon-to-espree/convertComments.js b/eslint/babel-eslint-parser/lib/babylon-to-espree/convertComments.js new file mode 100644 index 000000000000..57b0e44d4d54 --- /dev/null +++ b/eslint/babel-eslint-parser/lib/babylon-to-espree/convertComments.js @@ -0,0 +1,17 @@ +"use strict"; + +module.exports = function(comments) { + for (let i = 0; i < comments.length; i++) { + const comment = comments[i]; + if (comment.type === "CommentBlock") { + comment.type = "Block"; + } else if (comment.type === "CommentLine") { + comment.type = "Line"; + } + // sometimes comments don't get ranges computed, + // even with options.ranges === true + if (!comment.range) { + comment.range = [comment.start, comment.end]; + } + } +}; diff --git a/eslint/babel-eslint-parser/lib/babylon-to-espree/convertProgramNode.js b/eslint/babel-eslint-parser/lib/babylon-to-espree/convertProgramNode.js new file mode 100644 index 000000000000..810b19888213 --- /dev/null +++ b/eslint/babel-eslint-parser/lib/babylon-to-espree/convertProgramNode.js @@ -0,0 +1,40 @@ +"use strict"; + +module.exports = function(ast) { + ast.type = "Program"; + ast.sourceType = ast.program.sourceType; + ast.directives = ast.program.directives; + ast.body = ast.program.body; + delete ast.program; + + if (ast.comments.length) { + const lastComment = ast.comments[ast.comments.length - 1]; + + if (!ast.tokens.length) { + // if no tokens, the program starts at the end of the last comment + ast.start = lastComment.end; + ast.loc.start.line = lastComment.loc.end.line; + ast.loc.start.column = lastComment.loc.end.column; + } else { + const lastToken = ast.tokens[ast.tokens.length - 1]; + + if (lastComment.end > lastToken.end) { + // If there is a comment after the last token, the program ends at the + // last token and not the comment + ast.range[1] = lastToken.end; + ast.loc.end.line = lastToken.loc.end.line; + ast.loc.end.column = lastToken.loc.end.column; + } + } + } else { + if (!ast.tokens.length) { + ast.loc.start.line = 1; + ast.loc.end.line = 1; + } + } + + if (ast.body && ast.body.length > 0) { + ast.loc.start.line = ast.body[0].loc.start.line; + ast.range[0] = ast.body[0].start; + } +}; diff --git a/eslint/babel-eslint-parser/lib/babylon-to-espree/convertTemplateType.js b/eslint/babel-eslint-parser/lib/babylon-to-espree/convertTemplateType.js new file mode 100644 index 000000000000..accde61e56d6 --- /dev/null +++ b/eslint/babel-eslint-parser/lib/babylon-to-espree/convertTemplateType.js @@ -0,0 +1,92 @@ +"use strict"; + +module.exports = function(tokens, tt) { + let curlyBrace = null; + let templateTokens = []; + const result = []; + + function addTemplateType() { + const start = templateTokens[0]; + const end = templateTokens[templateTokens.length - 1]; + + const value = templateTokens.reduce((result, token) => { + if (token.value) { + result += token.value; + } else if (token.type !== tt.template) { + result += token.type.label; + } + + return result; + }, ""); + + result.push({ + type: "Template", + value: value, + start: start.start, + end: end.end, + loc: { + start: start.loc.start, + end: end.loc.end, + }, + }); + + templateTokens = []; + } + + tokens.forEach(token => { + switch (token.type) { + case tt.backQuote: + if (curlyBrace) { + result.push(curlyBrace); + curlyBrace = null; + } + + templateTokens.push(token); + + if (templateTokens.length > 1) { + addTemplateType(); + } + + break; + + case tt.dollarBraceL: + templateTokens.push(token); + addTemplateType(); + break; + + case tt.braceR: + if (curlyBrace) { + result.push(curlyBrace); + } + + curlyBrace = token; + break; + + case tt.template: + if (curlyBrace) { + templateTokens.push(curlyBrace); + curlyBrace = null; + } + + templateTokens.push(token); + break; + + case tt.eof: + if (curlyBrace) { + result.push(curlyBrace); + } + + break; + + default: + if (curlyBrace) { + result.push(curlyBrace); + curlyBrace = null; + } + + result.push(token); + } + }); + + return result; +}; diff --git a/eslint/babel-eslint-parser/lib/babylon-to-espree/convertToken.js b/eslint/babel-eslint-parser/lib/babylon-to-espree/convertToken.js new file mode 100644 index 000000000000..2d8e9b1aac34 --- /dev/null +++ b/eslint/babel-eslint-parser/lib/babylon-to-espree/convertToken.js @@ -0,0 +1,85 @@ +"use strict"; + +module.exports = function(token, tt, source) { + const type = token.type; + token.range = [token.start, token.end]; + + if (type === tt.name) { + token.type = "Identifier"; + } else if ( + type === tt.semi || + type === tt.comma || + type === tt.parenL || + type === tt.parenR || + type === tt.braceL || + type === tt.braceR || + type === tt.slash || + type === tt.dot || + type === tt.bracketL || + type === tt.bracketR || + type === tt.ellipsis || + type === tt.arrow || + type === tt.pipeline || + type === tt.star || + type === tt.incDec || + type === tt.colon || + type === tt.question || + type === tt.questionDot || + type === tt.template || + type === tt.backQuote || + type === tt.dollarBraceL || + type === tt.at || + type === tt.logicalOR || + type === tt.logicalAND || + type === tt.nullishCoalescing || + type === tt.bitwiseOR || + type === tt.bitwiseXOR || + type === tt.bitwiseAND || + type === tt.equality || + type === tt.relational || + type === tt.bitShift || + type === tt.plusMin || + type === tt.modulo || + type === tt.exponent || + type === tt.bang || + type === tt.tilde || + type === tt.doubleColon || + type === tt.hash || + type.isAssign + ) { + token.type = "Punctuator"; + if (!token.value) token.value = type.label; + } else if (type === tt.jsxTagStart) { + token.type = "Punctuator"; + token.value = "<"; + } else if (type === tt.jsxTagEnd) { + token.type = "Punctuator"; + token.value = ">"; + } else if (type === tt.jsxName) { + token.type = "JSXIdentifier"; + } else if (type === tt.jsxText) { + token.type = "JSXText"; + } else if (type.keyword === "null") { + token.type = "Null"; + } else if (type.keyword === "false" || type.keyword === "true") { + token.type = "Boolean"; + } else if (type.keyword) { + token.type = "Keyword"; + } else if (type === tt.num) { + token.type = "Numeric"; + token.value = source.slice(token.start, token.end); + } else if (type === tt.string) { + token.type = "String"; + token.value = source.slice(token.start, token.end); + } else if (type === tt.regexp) { + token.type = "RegularExpression"; + const value = token.value; + token.regex = { + pattern: value.pattern, + flags: value.flags, + }; + token.value = `/${value.pattern}/${value.flags}`; + } + + return token; +}; diff --git a/eslint/babel-eslint-parser/lib/babylon-to-espree/convertTokens.js b/eslint/babel-eslint-parser/lib/babylon-to-espree/convertTokens.js new file mode 100644 index 000000000000..0f49d9373089 --- /dev/null +++ b/eslint/babel-eslint-parser/lib/babylon-to-espree/convertTokens.js @@ -0,0 +1,10 @@ +"use strict"; + +const convertTemplateType = require("./convertTemplateType"); +const convertToken = require("./convertToken"); + +module.exports = function(tokens, tt, code) { + return convertTemplateType(tokens, tt) + .filter(t => t.type !== "CommentLine" && t.type !== "CommentBlock") + .map(t => convertToken(t, tt, code)); +}; diff --git a/eslint/babel-eslint-parser/lib/babylon-to-espree/index.js b/eslint/babel-eslint-parser/lib/babylon-to-espree/index.js new file mode 100644 index 000000000000..cc4dda974358 --- /dev/null +++ b/eslint/babel-eslint-parser/lib/babylon-to-espree/index.js @@ -0,0 +1,11 @@ +"use strict"; + +const convertTokens = require("./convertTokens"); +const convertComments = require("./convertComments"); +const convertAST = require("./convertAST"); + +module.exports = function(ast, traverse, tt, code) { + ast.tokens = convertTokens(ast.tokens, tt, code); + convertComments(ast.comments); + convertAST(ast, traverse, code); +}; diff --git a/eslint/babel-eslint-parser/lib/index.js b/eslint/babel-eslint-parser/lib/index.js new file mode 100644 index 000000000000..2769d4a0c09a --- /dev/null +++ b/eslint/babel-eslint-parser/lib/index.js @@ -0,0 +1,33 @@ +"use strict"; + +const semver = require("semver"); +const babelCore = require("@babel/core"); +const packageJson = require("../package.json"); + +const CURRENT_BABEL_VERSION = babelCore.version; +const SUPPORTED_BABEL_VERSION_RANGE = + packageJson.peerDependencies["@babel/core"]; +const IS_RUNNING_SUPPORTED_VERSION = semver.satisfies( + CURRENT_BABEL_VERSION, + SUPPORTED_BABEL_VERSION_RANGE +); + +exports.parse = function(code, options) { + return exports.parseForESLint(code, options).ast; +}; + +exports.parseForESLint = function(code, options = {}) { + if (!IS_RUNNING_SUPPORTED_VERSION) { + throw new Error( + `babel-eslint@${packageJson.version} does not support @babel/core@${CURRENT_BABEL_VERSION}. Please downgrade to babel-eslint@^10 or upgrade to @babel/core@${SUPPORTED_BABEL_VERSION_RANGE}` + ); + } + + options.babelOptions = options.babelOptions || {}; + options.ecmaVersion = options.ecmaVersion || 2018; + options.sourceType = options.sourceType || "module"; + options.allowImportExportEverywhere = + options.allowImportExportEverywhere || false; + + return require("./parse-with-scope")(code, options); +}; diff --git a/eslint/babel-eslint-parser/lib/parse-with-scope.js b/eslint/babel-eslint-parser/lib/parse-with-scope.js new file mode 100644 index 000000000000..36e3fce5b067 --- /dev/null +++ b/eslint/babel-eslint-parser/lib/parse-with-scope.js @@ -0,0 +1,12 @@ +"use strict"; + +const visitorKeys = require("./visitor-keys"); +const analyzeScope = require("./analyze-scope"); +const parse = require("./parse"); + +module.exports = function(code, options) { + const ast = parse(code, options); + const scopeManager = analyzeScope(ast, options); + + return { ast, scopeManager, visitorKeys }; +}; diff --git a/eslint/babel-eslint-parser/lib/parse.js b/eslint/babel-eslint-parser/lib/parse.js new file mode 100644 index 000000000000..3930bb04057d --- /dev/null +++ b/eslint/babel-eslint-parser/lib/parse.js @@ -0,0 +1,73 @@ +"use strict"; + +const babylonToEspree = require("./babylon-to-espree"); +const { + parseSync: parse, + tokTypes: tt, + traverse, + loadPartialConfig, +} = require("@babel/core"); + +module.exports = function(code, options) { + let opts = { + sourceType: options.sourceType, + filename: options.filePath, + cwd: options.babelOptions.cwd, + root: options.babelOptions.root, + rootMode: options.babelOptions.rootMode, + envName: options.babelOptions.envName, + configFile: options.babelOptions.configFile, + babelrc: options.babelOptions.babelrc, + babelrcRoots: options.babelOptions.babelrcRoots, + extends: options.babelOptions.extends, + env: options.babelOptions.env, + overrides: options.babelOptions.overrides, + test: options.babelOptions.test, + include: options.babelOptions.include, + exclude: options.babelOptions.exclude, + ignore: options.babelOptions.ignore, + only: options.babelOptions.only, + parserOpts: { + allowImportExportEverywhere: options.allowImportExportEverywhere, // consistent with espree + allowReturnOutsideFunction: true, + allowSuperOutsideMethod: true, + ranges: true, + tokens: true, + plugins: ["estree"], + }, + caller: { + name: "babel-eslint", + }, + }; + + if (options.requireConfigFile !== false) { + const config = loadPartialConfig(opts); + + if (config !== null) { + if (!config.hasFilesystemConfig()) { + throw new Error( + `No Babel config file detected for ${config.options.filename}. Either disable config file checking with requireConfigFile: false, or configure Babel so that it can find the config files.` + ); + } + + opts = config.options; + } + } + + let ast; + + try { + ast = parse(code, opts); + } catch (err) { + if (err instanceof SyntaxError) { + err.lineNumber = err.loc.line; + err.column = err.loc.column; + } + + throw err; + } + + babylonToEspree(ast, traverse, tt, code); + + return ast; +}; diff --git a/eslint/babel-eslint-parser/lib/visitor-keys.js b/eslint/babel-eslint-parser/lib/visitor-keys.js new file mode 100644 index 000000000000..2ac01887f14c --- /dev/null +++ b/eslint/babel-eslint-parser/lib/visitor-keys.js @@ -0,0 +1,15 @@ +"use strict"; + +const BABEL_VISITOR_KEYS = require("@babel/core").types.VISITOR_KEYS; +const ESLINT_VISITOR_KEYS = require("eslint-visitor-keys").KEYS; + +module.exports = Object.assign( + { + Literal: ESLINT_VISITOR_KEYS.Literal, + MethodDefinition: ["decorators"].concat( + ESLINT_VISITOR_KEYS.MethodDefinition + ), + Property: ["decorators"].concat(ESLINT_VISITOR_KEYS.Property), + }, + BABEL_VISITOR_KEYS +); diff --git a/eslint/babel-eslint-parser/package.json b/eslint/babel-eslint-parser/package.json new file mode 100644 index 000000000000..a92949e7e0a6 --- /dev/null +++ b/eslint/babel-eslint-parser/package.json @@ -0,0 +1,56 @@ +{ + "name": "babel-eslint", + "version": "11.0.0-beta.0", + "description": "Custom parser for ESLint", + "author": "Sebastian McKenzie ", + "license": "MIT", + "repository": { + "type": "git", + "url": "https://github.com/babel/babel-eslint.git" + }, + "bugs": { + "url": "https://github.com/babel/babel-eslint/issues" + }, + "homepage": "https://github.com/babel/babel-eslint", + "scripts": { + "test": "cd test && mocha specs && cd -", + "preversion": "npm test", + "changelog": "git log `git describe --tags --abbrev=0`..HEAD --pretty=format:' * %s (%an)' | grep -v 'Merge pull request'" + }, + "engines": { + "node": ">=6" + }, + "main": "lib/index.js", + "files": [ + "lib" + ], + "peerDependencies": { + "@babel/core": ">=7.2.0", + "eslint": ">= 4.12.1" + }, + "dependencies": { + "eslint-scope": "3.7.1", + "eslint-visitor-keys": "^1.0.0", + "semver": "^6.3.0" + }, + "devDependencies": { + "@babel/core": "^7.2.0", + "@babel/plugin-proposal-class-properties": "^7.1.0", + "@babel/plugin-proposal-decorators": "^7.1.2", + "@babel/plugin-proposal-nullish-coalescing-operator": "^7.0.0", + "@babel/plugin-proposal-optional-chaining": "^7.0.0", + "@babel/plugin-proposal-pipeline-operator": "^7.0.0", + "@babel/plugin-syntax-dynamic-import": "^7.0.0", + "@babel/plugin-syntax-export-default-from": "^7.0.0", + "@babel/plugin-syntax-export-namespace-from": "^7.0.0", + "@babel/plugin-syntax-import-meta": "^7.0.0", + "@babel/plugin-syntax-numeric-separator": "^7.0.0", + "@babel/preset-env": "^7.1.5", + "@babel/preset-flow": "^7.0.0", + "@babel/preset-react": "^7.0.0", + "dedent": "^0.7.0", + "eslint": "^6.0.1", + "espree": "^6.0.0", + "mocha": "^6.1.4" + } +} diff --git a/eslint/babel-eslint-parser/test/babel.config.js b/eslint/babel-eslint-parser/test/babel.config.js new file mode 100644 index 000000000000..4d49158dba90 --- /dev/null +++ b/eslint/babel-eslint-parser/test/babel.config.js @@ -0,0 +1,21 @@ +"use strict"; + +module.exports = { + presets: [ + ["@babel/preset-env", { forceAllTransforms: true }], + ["@babel/preset-flow", { all: true }], + "@babel/preset-react", + ], + plugins: [ + "@babel/plugin-syntax-dynamic-import", + "@babel/plugin-syntax-import-meta", + "@babel/plugin-syntax-export-default-from", + "@babel/plugin-proposal-class-properties", + "@babel/plugin-proposal-nullish-coalescing-operator", + "@babel/plugin-proposal-optional-chaining", + "@babel/plugin-syntax-numeric-separator", + "@babel/plugin-syntax-export-namespace-from", + ["@babel/plugin-proposal-decorators", { decoratorsBeforeExport: false }], + ["@babel/plugin-proposal-pipeline-operator", { proposal: "minimal" }], + ], +}; diff --git a/eslint/babel-eslint-parser/test/fixtures/config/babel.config.decorators-legacy.js b/eslint/babel-eslint-parser/test/fixtures/config/babel.config.decorators-legacy.js new file mode 100644 index 000000000000..dbad846412e6 --- /dev/null +++ b/eslint/babel-eslint-parser/test/fixtures/config/babel.config.decorators-legacy.js @@ -0,0 +1,6 @@ +"use strict"; + +module.exports = { + presets: [["@babel/preset-env", { forceAllTransforms: true }]], + plugins: [["@babel/plugin-proposal-decorators", { legacy: true }]], +}; diff --git a/eslint/babel-eslint-parser/test/fixtures/eslint-plugin-import/.eslintrc.yml b/eslint/babel-eslint-parser/test/fixtures/eslint-plugin-import/.eslintrc.yml new file mode 100644 index 000000000000..418b3d0c0ceb --- /dev/null +++ b/eslint/babel-eslint-parser/test/fixtures/eslint-plugin-import/.eslintrc.yml @@ -0,0 +1,11 @@ +root: true + +# babel-eslint +parser: ../../../lib/index.js + +# use eslint-plugin-import +plugins: + - import +rules: + import/no-named-as-default: error + no-unused-vars: error diff --git a/eslint/babel-eslint-parser/test/fixtures/eslint-plugin-import/a.js b/eslint/babel-eslint-parser/test/fixtures/eslint-plugin-import/a.js new file mode 100644 index 000000000000..e8d96fc4d62d --- /dev/null +++ b/eslint/babel-eslint-parser/test/fixtures/eslint-plugin-import/a.js @@ -0,0 +1 @@ +export default function foo() { } diff --git a/eslint/babel-eslint-parser/test/fixtures/eslint-plugin-import/b.js b/eslint/babel-eslint-parser/test/fixtures/eslint-plugin-import/b.js new file mode 100644 index 000000000000..b3a52f870198 --- /dev/null +++ b/eslint/babel-eslint-parser/test/fixtures/eslint-plugin-import/b.js @@ -0,0 +1 @@ +import foo from './a.js'; diff --git a/eslint/babel-eslint-parser/test/fixtures/eslint-plugin-import/c.js b/eslint/babel-eslint-parser/test/fixtures/eslint-plugin-import/c.js new file mode 100644 index 000000000000..2beac98f3b74 --- /dev/null +++ b/eslint/babel-eslint-parser/test/fixtures/eslint-plugin-import/c.js @@ -0,0 +1,4 @@ +// @flow +type Foo = {}; + +const FlowTypeButton = ({ }: Foo) => { }; diff --git a/eslint/babel-eslint-parser/test/fixtures/rules/strict/function-with.js b/eslint/babel-eslint-parser/test/fixtures/rules/strict/function-with.js new file mode 100644 index 000000000000..3df7515269d5 --- /dev/null +++ b/eslint/babel-eslint-parser/test/fixtures/rules/strict/function-with.js @@ -0,0 +1,3 @@ +function x () { + "use strict"; +} diff --git a/eslint/babel-eslint-parser/test/fixtures/rules/strict/function-without.js b/eslint/babel-eslint-parser/test/fixtures/rules/strict/function-without.js new file mode 100644 index 000000000000..20b3e9e55005 --- /dev/null +++ b/eslint/babel-eslint-parser/test/fixtures/rules/strict/function-without.js @@ -0,0 +1 @@ +function x () {} diff --git a/eslint/babel-eslint-parser/test/fixtures/rules/strict/global-with-function-with.js b/eslint/babel-eslint-parser/test/fixtures/rules/strict/global-with-function-with.js new file mode 100644 index 000000000000..ef682f72c947 --- /dev/null +++ b/eslint/babel-eslint-parser/test/fixtures/rules/strict/global-with-function-with.js @@ -0,0 +1,5 @@ +"use strict"; + +function x () { + "use strict"; +} diff --git a/eslint/babel-eslint-parser/test/fixtures/rules/strict/global-with-function-without.js b/eslint/babel-eslint-parser/test/fixtures/rules/strict/global-with-function-without.js new file mode 100644 index 000000000000..206f708141b7 --- /dev/null +++ b/eslint/babel-eslint-parser/test/fixtures/rules/strict/global-with-function-without.js @@ -0,0 +1,3 @@ +"use strict"; + +function x () {} diff --git a/eslint/babel-eslint-parser/test/fixtures/rules/strict/global-with.js b/eslint/babel-eslint-parser/test/fixtures/rules/strict/global-with.js new file mode 100644 index 000000000000..e967aa4994d0 --- /dev/null +++ b/eslint/babel-eslint-parser/test/fixtures/rules/strict/global-with.js @@ -0,0 +1,6 @@ +"use strict"; +/* +The empty statement is intentional. As of now, ESLint won't enforce +string: [2, "global"] on a program with an empty body. A test for that without +massaging the AST to ESlint's input format should fail. +*/ diff --git a/eslint/babel-eslint-parser/test/fixtures/rules/strict/none.js b/eslint/babel-eslint-parser/test/fixtures/rules/strict/none.js new file mode 100644 index 000000000000..4a6db98f6226 --- /dev/null +++ b/eslint/babel-eslint-parser/test/fixtures/rules/strict/none.js @@ -0,0 +1 @@ +"no use strict anywhere"; diff --git a/eslint/babel-eslint-parser/test/fixtures/rules/syntax-error.js b/eslint/babel-eslint-parser/test/fixtures/rules/syntax-error.js new file mode 100644 index 000000000000..6fa194a18f9e --- /dev/null +++ b/eslint/babel-eslint-parser/test/fixtures/rules/syntax-error.js @@ -0,0 +1,6 @@ +class ClassName { + constructor() { + + }, + aMethod() {} +} diff --git a/eslint/babel-eslint-parser/test/helpers/assert-implements-ast.js b/eslint/babel-eslint-parser/test/helpers/assert-implements-ast.js new file mode 100644 index 000000000000..84e370f48ed2 --- /dev/null +++ b/eslint/babel-eslint-parser/test/helpers/assert-implements-ast.js @@ -0,0 +1,42 @@ +"use strict"; + +// Checks if the source ast implements the target ast. Ignores extra keys on source ast +module.exports = function assertImplementsAST(target, source, path) { + if (!path) { + path = []; + } + + function error(text) { + const err = new Error(`At ${path.join(".")}: ${text}:`); + err.depth = path.length + 1; + throw err; + } + + const typeA = target === null ? "null" : typeof target; + const typeB = source === null ? "null" : typeof source; + if (typeA !== typeB) { + error( + `have different types (${typeA} !== ${typeB}) (${target} !== ${source})` + ); + } else if ( + typeA === "object" && + ["RegExp"].indexOf(target.constructor.name) !== -1 && + target.constructor.name !== source.constructor.name + ) { + error( + `object have different constructors (${target.constructor.name} !== ${source.constructor.name}` + ); + } else if (typeA === "object") { + const keysTarget = Object.keys(target); + for (const i in keysTarget) { + const key = keysTarget[i]; + path.push(key); + assertImplementsAST(target[key], source[key], path); + path.pop(); + } + } else if (target !== source) { + error( + `are different (${JSON.stringify(target)} !== ${JSON.stringify(source)})` + ); + } +}; diff --git a/eslint/babel-eslint-parser/test/specs/babel-eslint.js b/eslint/babel-eslint-parser/test/specs/babel-eslint.js new file mode 100644 index 000000000000..7dedf3819243 --- /dev/null +++ b/eslint/babel-eslint-parser/test/specs/babel-eslint.js @@ -0,0 +1,518 @@ +"use strict"; + +const assert = require("assert"); +const babelEslint = require("../.."); +const espree = require("espree"); +const escope = require("eslint-scope"); +const unpad = require("dedent"); +const assertImplementsAST = require("../helpers/assert-implements-ast"); + +function parseAndAssertSame(code) { + code = unpad(code); + const esAST = espree.parse(code, { + ecmaFeatures: { + // enable JSX parsing + jsx: true, + // enable return in global scope + globalReturn: true, + // enable implied strict mode (if ecmaVersion >= 5) + impliedStrict: true, + // allow experimental object rest/spread + experimentalObjectRestSpread: true, + }, + tokens: true, + loc: true, + range: true, + comment: true, + ecmaVersion: 2018, + sourceType: "module", + }); + const babylonAST = babelEslint.parseForESLint(code, { + eslintVisitorKeys: true, + eslintScopeManager: true, + }).ast; + assertImplementsAST(esAST, babylonAST); +} + +describe("babylon-to-espree", () => { + describe("compatibility", () => { + it("should allow ast.analyze to be called without options", function() { + const esAST = babelEslint.parseForESLint("`test`", { + eslintScopeManager: true, + eslintVisitorKeys: true, + }).ast; + + assert.doesNotThrow( + () => { + escope.analyze(esAST); + }, + TypeError, + "Should allow no options argument." + ); + }); + }); + + describe("templates", () => { + it("empty template string", () => { + parseAndAssertSame("``"); + }); + + it("template string", () => { + parseAndAssertSame("`test`"); + }); + + it("template string using $", () => { + parseAndAssertSame("`$`"); + }); + + it("template string with expression", () => { + parseAndAssertSame("`${a}`"); + }); + + it("template string with multiple expressions", () => { + parseAndAssertSame("`${a}${b}${c}`"); + }); + + it("template string with expression and strings", () => { + parseAndAssertSame("`a${a}a`"); + }); + + it("template string with binary expression", () => { + parseAndAssertSame("`a${a + b}a`"); + }); + + it("tagged template", () => { + parseAndAssertSame("jsx``"); + }); + + it("tagged template with expression", () => { + parseAndAssertSame("jsx``"); + }); + + it("tagged template with new operator", () => { + parseAndAssertSame("new raw`42`"); + }); + + it("template with nested function/object", () => { + parseAndAssertSame( + "`outer${{x: {y: 10}}}bar${`nested${function(){return 1;}}endnest`}end`" + ); + }); + + it("template with braces inside and outside of template string #96", () => { + parseAndAssertSame( + "if (a) { var target = `{}a:${webpackPort}{}}}}`; } else { app.use(); }" + ); + }); + + it("template also with braces #96", () => { + parseAndAssertSame(` + export default function f1() { + function f2(foo) { + const bar = 3; + return \`\${foo} \${bar}\`; + } + return f2; + } + `); + }); + + it("template with destructuring #31", () => { + parseAndAssertSame(` + module.exports = { + render() { + var {name} = this.props; + return Math.max(null, \`Name: \${name}, Name: \${name}\`); + } + }; + `); + }); + + it("template with arrow returning template #603", () => { + parseAndAssertSame(` + var a = \`\${() => { + \`\${''}\` + }}\`; + `); + }); + + it("template string with object with template string inside", () => { + parseAndAssertSame("`${ { a:`${2}` } }`"); + }); + }); + + it("simple expression", () => { + parseAndAssertSame("a = 1"); + }); + + it("logical NOT", () => { + parseAndAssertSame("!0"); + }); + + it("bitwise NOT", () => { + parseAndAssertSame("~0"); + }); + + it("class declaration", () => { + parseAndAssertSame("class Foo {}"); + }); + + it("class expression", () => { + parseAndAssertSame("var a = class Foo {}"); + }); + + it("jsx expression", () => { + parseAndAssertSame(""); + }); + + it("jsx expression with 'this' as identifier", () => { + parseAndAssertSame(""); + }); + + it("jsx expression with a dynamic attribute", () => { + parseAndAssertSame(""); + }); + + it("jsx expression with a member expression as identifier", () => { + parseAndAssertSame(""); + }); + + it("jsx expression with spread", () => { + parseAndAssertSame("var myDivElement =

;"); + }); + + it("empty jsx text", () => { + parseAndAssertSame(""); + }); + + it("jsx text with content", () => { + parseAndAssertSame("Hello, world!"); + }); + + it("nested jsx", () => { + parseAndAssertSame("
\n

Wat

\n
"); + }); + + it("default import", () => { + parseAndAssertSame('import foo from "foo";'); + }); + + it("import specifier", () => { + parseAndAssertSame('import { foo } from "foo";'); + }); + + it("import specifier with name", () => { + parseAndAssertSame('import { foo as bar } from "foo";'); + }); + + it("import bare", () => { + parseAndAssertSame('import "foo";'); + }); + + it("export default class declaration", () => { + parseAndAssertSame("export default class Foo {}"); + }); + + it("export default class expression", () => { + parseAndAssertSame("export default class {}"); + }); + + it("export default function declaration", () => { + parseAndAssertSame("export default function Foo() {}"); + }); + + it("export default function expression", () => { + parseAndAssertSame("export default function () {}"); + }); + + it("export all", () => { + parseAndAssertSame('export * from "foo";'); + }); + + it("export named", () => { + parseAndAssertSame("var foo = 1;export { foo };"); + }); + + it("export named alias", () => { + parseAndAssertSame("var foo = 1;export { foo as bar };"); + }); + + // Espree doesn't support the optional chaining operator yet + it("optional chaining operator (token)", () => { + const code = "foo?.bar"; + const babylonAST = babelEslint.parseForESLint(code, { + eslintVisitorKeys: true, + eslintScopeManager: true, + }).ast; + assert.strictEqual(babylonAST.tokens[1].type, "Punctuator"); + }); + + // Espree doesn't support the nullish coalescing operator yet + it("nullish coalescing operator (token)", () => { + const code = "foo ?? bar"; + const babylonAST = babelEslint.parseForESLint(code, { + eslintVisitorKeys: true, + eslintScopeManager: true, + }).ast; + assert.strictEqual(babylonAST.tokens[1].type, "Punctuator"); + }); + + // Espree doesn't support the pipeline operator yet + it("pipeline operator (token)", () => { + const code = "foo |> bar"; + const babylonAST = babelEslint.parseForESLint(code, { + eslintVisitorKeys: true, + eslintScopeManager: true, + }).ast; + assert.strictEqual(babylonAST.tokens[1].type, "Punctuator"); + }); + + // Espree doesn't support the private fields yet + it("hash (token)", () => { + const code = "class A { #x }"; + const babylonAST = babelEslint.parseForESLint(code, { + eslintVisitorKeys: true, + eslintScopeManager: true, + }).ast; + assert.strictEqual(babylonAST.tokens[3].type, "Punctuator"); + assert.strictEqual(babylonAST.tokens[3].value, "#"); + }); + + it.skip("empty program with line comment", () => { + parseAndAssertSame("// single comment"); + }); + + it.skip("empty program with block comment", () => { + parseAndAssertSame(" /* multiline\n * comment\n*/"); + }); + + it("line comments", () => { + parseAndAssertSame(` + // single comment + var foo = 15; // comment next to statement + // second comment after statement + `); + }); + + it("block comments", () => { + parseAndAssertSame(` + /* single comment */ + var foo = 15; /* comment next to statement */ + /* + * multiline + * comment + */ + `); + }); + + it("block comments #124", () => { + parseAndAssertSame(` + React.createClass({ + render() { + // return ( + //
+ // ); // <-- this is the line that is reported + } + }); + `); + }); + + it("null", () => { + parseAndAssertSame("null"); + }); + + it("boolean", () => { + parseAndAssertSame("if (true) {} else if (false) {}"); + }); + + it("regexp", () => { + parseAndAssertSame("/affix-top|affix-bottom|affix|[a-z]/"); + }); + + it("regexp", () => { + parseAndAssertSame("const foo = /foo/;"); + }); + + it("regexp y flag", () => { + parseAndAssertSame("const foo = /foo/y;"); + }); + + it("regexp u flag", () => { + parseAndAssertSame("const foo = /foo/u;"); + }); + + it("regexp in a template string", () => { + parseAndAssertSame('`${/\\d/.exec("1")[0]}`'); + }); + + it("first line is empty", () => { + parseAndAssertSame('\nimport Immutable from "immutable";'); + }); + + it("empty", () => { + parseAndAssertSame(""); + }); + + it("jsdoc", () => { + parseAndAssertSame(` + /** + * @param {object} options + * @return {number} + */ + const test = function({ a, b, c }) { + return a + b + c; + }; + module.exports = test; + `); + }); + + it("empty block with comment", () => { + parseAndAssertSame(` + function a () { + try { + b(); + } catch (e) { + // asdf + } + } + `); + }); + + describe("babel tests", () => { + it("MethodDefinition", () => { + parseAndAssertSame(` + export default class A { + a() {} + } + `); + }); + + it("MethodDefinition 2", () => { + parseAndAssertSame( + "export default class Bar { get bar() { return 42; }}" + ); + }); + + it("ClassMethod", () => { + parseAndAssertSame(` + class A { + constructor() { + } + } + `); + }); + + it("ClassMethod multiple params", () => { + parseAndAssertSame(` + class A { + constructor(a, b, c) { + } + } + `); + }); + + it("ClassMethod multiline", () => { + parseAndAssertSame(` + class A { + constructor ( + a, + b, + c + ) + + { + + } + } + `); + }); + + it("ClassMethod oneline", () => { + parseAndAssertSame("class A { constructor(a, b, c) {} }"); + }); + + it("ObjectMethod", () => { + parseAndAssertSame(` + var a = { + b(c) { + } + } + `); + }); + + it("do not allow import export everywhere", () => { + assert.throws(() => { + parseAndAssertSame('function F() { import a from "a"; }'); + }, /SyntaxError: 'import' and 'export' may only appear at the top level/); + }); + + it("return outside function", () => { + parseAndAssertSame("return;"); + }); + + it("super outside method", () => { + assert.throws(() => { + parseAndAssertSame("function F() { super(); }"); + }, /SyntaxError: 'super' keyword outside a method/); + }); + + it("StringLiteral", () => { + parseAndAssertSame(""); + parseAndAssertSame(""); + parseAndAssertSame("a"); + }); + + it("getters and setters", () => { + parseAndAssertSame("class A { get x ( ) { ; } }"); + parseAndAssertSame(` + class A { + get x( + ) + { + ; + } + } + `); + parseAndAssertSame("class A { set x (a) { ; } }"); + parseAndAssertSame(` + class A { + set x(a + ) + { + ; + } + } + `); + parseAndAssertSame(` + var B = { + get x () { + return this.ecks; + }, + set x (ecks) { + this.ecks = ecks; + } + }; + `); + }); + + it("RestOperator", () => { + parseAndAssertSame("var { a, ...b } = c"); + parseAndAssertSame("var [ a, ...b ] = c"); + parseAndAssertSame("var a = function (...b) {}"); + }); + + it("SpreadOperator", () => { + parseAndAssertSame("var a = { b, ...c }"); + parseAndAssertSame("var a = [ a, ...b ]"); + parseAndAssertSame("var a = sum(...b)"); + }); + + it("Async/Await", () => { + parseAndAssertSame(` + async function a() { + await 1; + } + `); + }); + }); +}); diff --git a/eslint/babel-eslint-parser/test/specs/integration.js b/eslint/babel-eslint-parser/test/specs/integration.js new file mode 100644 index 000000000000..d13a5aa3ff97 --- /dev/null +++ b/eslint/babel-eslint-parser/test/specs/integration.js @@ -0,0 +1,240 @@ +"use strict"; + +const assert = require("assert"); +const eslint = require("eslint"); +const fs = require("fs"); +const path = require("path"); + +const parser = require("../.."); + +eslint.linter.defineParser("current-babel-eslint", parser); + +const paths = { + fixtures: path.join(__dirname, "..", "fixtures", "rules"), +}; + +const encoding = "utf8"; +const errorLevel = 2; + +const baseEslintOpts = { + parser: "current-babel-eslint", + parserOptions: { + sourceType: "script", + }, +}; + +/** + * Load a fixture and run eslint.linter.verify() on it. + * Pass the return value to done(). + * @param object opts + * @param function done + */ +function lint(opts, done) { + readFixture(opts.fixture, (err, src) => { + if (err) return done(err); + done(null, eslint.linter.verify(src, opts.eslint)); + }); +} + +/** + * Read a fixture file, passing the content to done(). + * @param string|array id + * @param function done + */ +function readFixture(id, done) { + if (Array.isArray(id)) id = path.join.apply(path, id); + if (!path.extname(id)) id += ".js"; + fs.readFile(path.join(paths.fixtures, id), encoding, done); +} +// readFixture + +describe("Rules:", () => { + describe("`strict`", strictSuite); +}); +// describe + +function strictSuite() { + const ruleId = "strict"; + + describe("when set to 'never'", () => { + const eslintOpts = Object.assign({}, baseEslintOpts, { + rules: {}, + }); + eslintOpts.rules[ruleId] = [errorLevel, "never"]; + + ["global-with", "function-with"].forEach(fixture => { + it(`should error on ${fixture.match(/^[^-]+/)[0]} directive`, done => { + lint( + { + fixture: ["strict", fixture], + eslint: eslintOpts, + }, + (err, report) => { + if (err) return done(err); + assert(report[0].ruleId === ruleId); + done(); + } + ); + }); + // it + }); + }); + // describe + + describe("when set to 'global'", () => { + const eslintOpts = Object.assign({}, baseEslintOpts, { + rules: {}, + }); + eslintOpts.rules[ruleId] = [errorLevel, "global"]; + + it("shouldn't error on single global directive", done => { + lint( + { + fixture: ["strict", "global-with"], + eslint: eslintOpts, + }, + (err, report) => { + if (err) return done(err); + assert(!report.length); + done(); + } + ); + }); + // it + + it("should error twice on global directive: no and function directive: yes", done => { + lint( + { + fixture: ["strict", "function-with"], + eslint: eslintOpts, + }, + (err, report) => { + if (err) return done(err); + [0, 1].forEach(i => { + assert(report[i].ruleId === ruleId); + }); + done(); + } + ); + }); + // it + + it("should error on function directive", done => { + lint( + { + fixture: ["strict", "global-with-function-with"], + eslint: eslintOpts, + }, + (err, report) => { + if (err) return done(err); + assert(report[0].ruleId === ruleId); + + // This is to make sure the test fails prior to adapting Babel AST + // directive representation to ESLint format. Otherwise it reports an + // error for missing global directive that masquerades as the expected + // result of the previous assertion. + assert(report[0].nodeType !== "Program"); + done(); + } + ); + }); + // it + + it("should error on no directive", done => { + lint( + { + fixture: ["strict", "none"], + eslint: eslintOpts, + }, + (err, report) => { + if (err) return done(err); + assert(report[0].ruleId === ruleId); + done(); + } + ); + }); + // it + }); + // describe + + describe("when set to 'function'", () => { + const eslintOpts = Object.assign({}, baseEslintOpts, { + rules: {}, + }); + eslintOpts.rules[ruleId] = [errorLevel, "function"]; + + it("shouldn't error on single function directive", done => { + lint( + { + fixture: ["strict", "function-with"], + eslint: eslintOpts, + }, + (err, report) => { + if (err) return done(err); + assert(!report.length); + done(); + } + ); + }); + // it + + it("should error twice on function directive: no and global directive: yes", done => { + lint( + { + fixture: ["strict", "global-with-function-without"], + eslint: eslintOpts, + }, + (err, report) => { + if (err) return done(err); + [0, 1].forEach(i => { + assert(report[i].ruleId === ruleId); + }); + done(); + } + ); + }); + // it + + it("should error on only global directive", done => { + lint( + { + fixture: ["strict", "global-with"], + eslint: eslintOpts, + }, + (err, report) => { + if (err) return done(err); + assert(report[0].ruleId === ruleId); + done(); + } + ); + }); + // it + + it("should error on extraneous global directive", done => { + lint( + { + fixture: ["strict", "global-with-function-with"], + eslint: eslintOpts, + }, + (err, report) => { + if (err) return done(err); + assert(report[0].ruleId === ruleId); + assert(report[0].nodeType.indexOf("Function") === -1); + done(); + } + ); + }); + // it + }); +} + +describe("https://github.com/babel/babel-eslint/issues/558", () => { + it("doesn't crash with eslint-plugin-import", () => { + const engine = new eslint.CLIEngine({ ignore: false }); + engine.executeOnFiles([ + "fixtures/eslint-plugin-import/a.js", + "fixtures/eslint-plugin-import/b.js", + "fixtures/eslint-plugin-import/c.js", + ]); + }); +}); diff --git a/eslint/babel-eslint-parser/test/specs/non-regression.js b/eslint/babel-eslint-parser/test/specs/non-regression.js new file mode 100644 index 000000000000..58d7056c42c5 --- /dev/null +++ b/eslint/babel-eslint-parser/test/specs/non-regression.js @@ -0,0 +1,1873 @@ +"use strict"; + +const eslint = require("eslint"); +const path = require("path"); +const unpad = require("dedent"); + +const parser = require("../.."); + +function verifyAndAssertMessagesWithSpecificESLint( + code, + rules, + expectedMessages, + sourceType, + overrideConfig, + linter +) { + const config = { + parser: "current-babel-eslint", + rules, + env: { + node: true, + es6: true, + }, + parserOptions: { + sourceType, + ecmaFeatures: { + globalReturn: true, + }, + }, + }; + + if (overrideConfig) { + for (const key in overrideConfig) { + config[key] = overrideConfig[key]; + } + } + + const messages = linter.verify(code, config); + + if (messages.length !== expectedMessages.length) { + throw new Error( + `Expected ${expectedMessages.length} message(s), got ${ + messages.length + }\n${JSON.stringify(messages, null, 2)}` + ); + } + + messages.forEach((message, i) => { + const formatedMessage = `${message.line}:${message.column} ${ + message.message + }${message.ruleId ? ` ${message.ruleId}` : ""}`; + if (formatedMessage !== expectedMessages[i]) { + throw new Error( + ` + Message ${i} does not match: + Expected: ${expectedMessages[i]} + Actual: ${formatedMessage} + ` + ); + } + }); +} + +function verifyAndAssertMessages( + code, + rules, + expectedMessages, + sourceType, + overrideConfig +) { + const linter = new eslint.Linter(); + linter.defineParser("current-babel-eslint", parser); + + verifyAndAssertMessagesWithSpecificESLint( + unpad(`${code}`), + rules || {}, + expectedMessages || [], + sourceType, + overrideConfig, + linter + ); +} + +describe("verify", () => { + it("arrow function support (issue #1)", () => { + verifyAndAssertMessages("describe('stuff', () => {});"); + }); + + it("EOL validation (issue #2)", () => { + verifyAndAssertMessages( + 'module.exports = "something";', + { "eol-last": 1, semi: 1 }, + ["1:30 Newline required at end of file but not found. eol-last"] + ); + }); + + xit("Readable error messages (issue #3)", () => { + verifyAndAssertMessages("{ , res }", {}, [ + "1:3 Parsing error: Unexpected token", + ]); + }); + + it("Modules support (issue #5)", () => { + verifyAndAssertMessages( + ` + import Foo from 'foo'; + export default Foo; + export const c = 'c'; + export class Store {} + ` + ); + }); + + it("Rest parameters (issue #7)", () => { + verifyAndAssertMessages("function foo(...args) { return args; }", { + "no-undef": 1, + }); + }); + + it("Exported classes should be used (issue #8)", () => { + verifyAndAssertMessages("class Foo {} module.exports = Foo;", { + "no-unused-vars": 1, + }); + }); + + it("super keyword in class (issue #10)", () => { + verifyAndAssertMessages("class Foo { constructor() { super() } }", { + "no-undef": 1, + }); + }); + + it("Rest parameter in destructuring assignment (issue #11)", () => { + verifyAndAssertMessages( + "const [a, ...rest] = ['1', '2', '3']; module.exports = rest;", + { "no-undef": 1 } + ); + }); + + it("JSX attribute names marked as variables (issue #12)", () => { + verifyAndAssertMessages('module.exports =
', { + "no-undef": 1, + }); + }); + + it("Multiple destructured assignment with compound properties (issue #16)", () => { + verifyAndAssertMessages("module.exports = { ...a.a, ...a.b };", { + "no-dupe-keys": 1, + }); + }); + + it("Arrow function with non-block bodies (issue #20)", () => { + verifyAndAssertMessages( + '"use strict"; () => 1', + { strict: [1, "global"] }, + [], + "script" + ); + }); + + it("#242", () => { + verifyAndAssertMessages('"use strict"; asdf;', { + "no-irregular-whitespace": 1, + }); + }); + + it("await keyword (issue #22)", () => { + verifyAndAssertMessages("async function foo() { await bar(); }", { + "no-unused-expressions": 1, + }); + }); + + it("arrow functions (issue #27)", () => { + verifyAndAssertMessages("[1, 2, 3].map(i => i * 2);", { + "func-names": 1, + "space-before-blocks": 1, + }); + }); + + it("comment with padded-blocks (issue #33)", () => { + verifyAndAssertMessages( + ` + if (a) { + // i'm a comment! + let b = c + } + `, + { "padded-blocks": [1, "never"] } + ); + }); + + describe("flow", () => { + it("check regular function", () => { + verifyAndAssertMessages( + "function a(b, c) { b += 1; c += 1; return b + c; } a;", + { "no-unused-vars": 1, "no-undef": 1 } + ); + }); + + it("type alias", () => { + verifyAndAssertMessages("type SomeNewType = any;", { "no-undef": 1 }); + }); + + it("type cast expression #102", () => { + verifyAndAssertMessages("for (let a of (a: Array)) {}"); + }); + + it("multiple nullable type annotations and return #108", () => { + verifyAndAssertMessages( + ` + import type Foo from 'foo'; + import type Foo2 from 'foo'; + import type Foo3 from 'foo'; + function log(foo: ?Foo, foo2: ?Foo2): ?Foo3 { + console.log(foo, foo2); + } + log(1, 2); + `, + { "no-unused-vars": 1, "no-undef": 1 } + ); + }); + + it("interface declaration", () => { + verifyAndAssertMessages( + ` + interface Foo {}; + interface Bar { + foo: Foo, + }; + `, + { "no-unused-vars": 1, "no-undef": 1 }, + ["2:11 'Bar' is defined but never used. no-unused-vars"] + ); + }); + + it("type parameter bounds (classes)", () => { + verifyAndAssertMessages( + ` + import type {Foo, Foo2} from 'foo'; + import Base from 'base'; + class Log extends Base { + messages: {[T1]: T2}; + } + new Log(); + `, + { "no-unused-vars": 1, "no-undef": 1 }, + ["3:34 'T4' is defined but never used. no-unused-vars"] + ); + }); + + it("type parameter scope (classes)", () => { + verifyAndAssertMessages( + ` + T; + class Foo {} + T; + new Foo(); + `, + { "no-unused-vars": 1, "no-undef": 1 }, + [ + "1:1 'T' is not defined. no-undef", + "2:11 'T' is defined but never used. no-unused-vars", + "3:1 'T' is not defined. no-undef", + ] + ); + }); + + it("type parameter bounds (interfaces)", () => { + verifyAndAssertMessages( + ` + import type {Foo, Foo2, Bar} from ''; + interface Log extends Bar { + messages: {[T1]: T2}; + } + `, + { "no-unused-vars": 1, "no-undef": 1 }, + [ + "2:11 'Log' is defined but never used. no-unused-vars", + "2:38 'T4' is defined but never used. no-unused-vars", + ] + ); + }); + + it("type parameter scope (interfaces)", () => { + verifyAndAssertMessages( + ` + T; + interface Foo {}; + T; + Foo; + `, + { "no-unused-vars": 1, "no-undef": 1 }, + [ + "1:1 'T' is not defined. no-undef", + "2:15 'T' is defined but never used. no-unused-vars", + "3:1 'T' is not defined. no-undef", + ] + ); + }); + + it("type parameter bounds (type aliases)", () => { + verifyAndAssertMessages( + ` + import type {Foo, Foo2, Foo3} from 'foo'; + type Log = { + messages: {[T1]: T2}; + delay: Foo3; + }; + `, + { "no-unused-vars": 1, "no-undef": 1 }, + [ + "2:6 'Log' is defined but never used. no-unused-vars", + "2:29 'T3' is defined but never used. no-unused-vars", + ] + ); + }); + + it("type parameter scope (type aliases)", () => { + verifyAndAssertMessages( + ` + T; + type Foo = {}; + T; + Foo; + `, + { "no-unused-vars": 1, "no-undef": 1 }, + [ + "1:1 'T' is not defined. no-undef", + "2:10 'T' is defined but never used. no-unused-vars", + "3:1 'T' is not defined. no-undef", + ] + ); + }); + + it("type parameter bounds (functions)", () => { + verifyAndAssertMessages( + ` + import type Foo from 'foo'; + import type Foo2 from 'foo'; + function log(a: T1, b: T2): T3 { return a + b; } + log(1, 2); + `, + { "no-unused-vars": 1, "no-undef": 1 }, + ["3:37 'T4' is defined but never used. no-unused-vars"] + ); + }); + + it("type parameter scope (functions)", () => { + verifyAndAssertMessages( + ` + T; + function log() {} + T; + log; + `, + { "no-unused-vars": 1, "no-undef": 1 }, + [ + "1:1 'T' is not defined. no-undef", + "2:14 'T' is defined but never used. no-unused-vars", + "3:1 'T' is not defined. no-undef", + ] + ); + }); + + it("nested type annotations", () => { + verifyAndAssertMessages( + ` + import type Foo from 'foo'; + function foo(callback: () => Foo) { + return callback(); + } + foo(); + `, + { "no-unused-vars": 1, "no-undef": 1 } + ); + }); + + it("type in var declaration", () => { + verifyAndAssertMessages( + ` + import type Foo from 'foo'; + var x: Foo = 1; + x; + `, + { "no-unused-vars": 1, "no-undef": 1 } + ); + }); + + it("object type annotation", () => { + verifyAndAssertMessages( + ` + import type Foo from 'foo'; + var a: {numVal: Foo}; + a; + `, + { "no-unused-vars": 1, "no-undef": 1 } + ); + }); + + it("object property types", () => { + verifyAndAssertMessages( + ` + import type Foo from 'foo'; + import type Foo2 from 'foo'; + var a = { + circle: (null : ?{ setNativeProps(props: Foo): Foo2 }) + }; + a; + `, + { "no-unused-vars": 1, "no-undef": 1 } + ); + }); + + it("namespaced types", () => { + verifyAndAssertMessages( + ` + var React = require('react-native'); + var b = { + openExternalExample: (null: ?React.Component) + }; + var c = { + render(): React.Component {} + }; + b; + c; + `, + { "no-unused-vars": 1, "no-undef": 1 } + ); + }); + + it("ArrayTypeAnnotation", () => { + verifyAndAssertMessages( + ` + import type Foo from 'foo'; + var x: Foo[]; x; + `, + { "no-unused-vars": 1, "no-undef": 1 } + ); + }); + + it("ClassImplements", () => { + verifyAndAssertMessages( + ` + import type Bar from 'foo'; + export default class Foo implements Bar {} + `, + { "no-unused-vars": 1, "no-undef": 1 } + ); + }); + + it("type alias creates declaration + usage", () => { + verifyAndAssertMessages( + ` + type Foo = any; + var x : Foo = 1; x; + `, + { "no-unused-vars": 1, "no-undef": 1 } + ); + }); + + it("type alias with type parameters", () => { + verifyAndAssertMessages( + ` + import type Bar from 'foo'; + import type Foo3 from 'foo'; + type Foo = Bar + var x : Foo = 1; x; + `, + { "no-unused-vars": 1, "no-undef": 1 } + ); + }); + + it("export type alias", () => { + verifyAndAssertMessages( + ` + import type Foo2 from 'foo'; + export type Foo = Foo2; + `, + { "no-unused-vars": 1, "no-undef": 1 } + ); + }); + + it("polymorphic types #109", () => { + verifyAndAssertMessages( + "export default function groupByEveryN(array: Array, n: number): Array> { n; }", + { "no-unused-vars": 1, "no-undef": 1 } + ); + }); + + it("types definition from import", () => { + verifyAndAssertMessages( + ` + import type Promise from 'bluebird'; + type Operation = () => Promise; + x: Operation; + `, + { "no-unused-vars": 1, "no-undef": 1 } + ); + }); + + it("polymorphic/generic types for class #123", () => { + verifyAndAssertMessages( + ` + class Box { + value: T; + } + var box = new Box(); + console.log(box.value); + `, + { "no-unused-vars": 1, "no-undef": 1 } + ); + }); + + it("polymorphic/generic types for function #123", () => { + verifyAndAssertMessages( + ` + export function identity(value) { + var a: T = value; a; + } + `, + { "no-unused-vars": 1, "no-undef": 1 } + ); + }); + + it("polymorphic/generic types for type alias #123", () => { + verifyAndAssertMessages( + ` + import Bar from './Bar'; + type Foo = Bar; var x: Foo = 1; console.log(x); + `, + { "no-unused-vars": 1, "no-undef": 1 } + ); + }); + + it("polymorphic/generic types - outside of fn scope #123", () => { + verifyAndAssertMessages( + ` + export function foo(value) { value; }; + var b: T = 1; b; + `, + { "no-unused-vars": 1, "no-undef": 1 }, + [ + "1:21 'T' is defined but never used. no-unused-vars", + "2:8 'T' is not defined. no-undef", + ] + ); + }); + + it("polymorphic/generic types - extending unknown #123", () => { + verifyAndAssertMessages( + ` + import Bar from 'bar'; + export class Foo extends Bar {} + `, + { "no-unused-vars": 1, "no-undef": 1 }, + ["2:30 'T' is not defined. no-undef"] + ); + }); + + it("polymorphic/generic types - function calls", () => { + verifyAndAssertMessages( + ` + function f(): T {} + f(); + `, + { "no-unused-vars": 1, "no-undef": 1 }, + ["2:3 'T' is not defined. no-undef"] + ); + }); + + it("polymorphic/generic types - function calls #644", () => { + verifyAndAssertMessages( + ` + import type {Type} from 'Type'; + function f(): T {} + f(); + `, + { "no-unused-vars": 1, "no-undef": 1 } + ); + }); + + it("support declarations #132", () => { + verifyAndAssertMessages( + ` + declare class A { static () : number } + declare module B { declare var x: number; } + declare function foo(): void; + declare var bar + A; B; foo(); bar; + `, + { "no-undef": 1, "no-unused-vars": 1 } + ); + }); + + it("supports type spreading", () => { + verifyAndAssertMessages( + ` + type U = {}; + type T = {a: number, ...U, ...V}; + `, + { "no-undef": 1, "no-unused-vars": 1 }, + [ + "2:6 'T' is defined but never used. no-unused-vars", + "2:31 'V' is not defined. no-undef", + ] + ); + }); + + it("1", () => { + verifyAndAssertMessages( + ` + import type Foo from 'foo'; + import type Foo2 from 'foo'; + export default function(a: Foo, b: ?Foo2, c){ a; b; c; } + `, + { "no-unused-vars": 1, "no-undef": 1 } + ); + }); + + it("2", () => { + verifyAndAssertMessages( + ` + import type Foo from 'foo'; + export default function(a: () => Foo){ a; } + `, + { "no-unused-vars": 1, "no-undef": 1 } + ); + }); + + it("3", () => { + verifyAndAssertMessages( + ` + import type Foo from 'foo'; + import type Foo2 from 'foo'; + export default function(a: (_:Foo) => Foo2){ a; } + `, + { "no-unused-vars": 1, "no-undef": 1 } + ); + }); + + it("4", () => { + verifyAndAssertMessages( + ` + import type Foo from 'foo'; + import type Foo2 from 'foo'; + import type Foo3 from 'foo'; + export default function(a: (_1:Foo, _2:Foo2) => Foo3){ a; } + `, + { "no-unused-vars": 1, "no-undef": 1 } + ); + }); + + it("5", () => { + verifyAndAssertMessages( + ` + import type Foo from 'foo'; + import type Foo2 from 'foo'; + export default function(a: (_1:Foo, ...foo:Array) => number){ a; } + `, + { "no-unused-vars": 1, "no-undef": 1 } + ); + }); + + it("6", () => { + verifyAndAssertMessages( + ` + import type Foo from 'foo'; + export default function(): Foo {} + `, + { "no-unused-vars": 1, "no-undef": 1 } + ); + }); + + it("7", () => { + verifyAndAssertMessages( + ` + import type Foo from 'foo'; + export default function():() => Foo {} + `, + { "no-unused-vars": 1, "no-undef": 1 } + ); + }); + + it("8", () => { + verifyAndAssertMessages( + ` + import type Foo from 'foo'; + import type Foo2 from 'foo'; + export default function():(_?:Foo) => Foo2{} + `, + { "no-unused-vars": 1, "no-undef": 1 } + ); + }); + + it("9", () => { + verifyAndAssertMessages( + "export default function (a: T1, b: T2) { b; }", + { "no-unused-vars": 1, "no-undef": 1 } + ); + }); + + it("10", () => { + verifyAndAssertMessages( + "var a=function(a: T1, b: T2) {return a + b;}; a;", + { "no-unused-vars": 1, "no-undef": 1 } + ); + }); + + it("11", () => { + verifyAndAssertMessages("var a={*id(x: T): T { x; }}; a;", { + "no-unused-vars": 1, + "no-undef": 1, + }); + }); + + it("12", () => { + verifyAndAssertMessages("var a={async id(x: T): T { x; }}; a;", { + "no-unused-vars": 1, + "no-undef": 1, + }); + }); + + it("13", () => { + verifyAndAssertMessages("var a={123(x: T): T { x; }}; a;", { + "no-unused-vars": 1, + "no-undef": 1, + }); + }); + + it("14", () => { + verifyAndAssertMessages( + ` + import type Foo from 'foo'; + import type Foo2 from 'foo'; + export default class Bar {set fooProp(value:Foo):Foo2{ value; }} + `, + { "no-unused-vars": 1, "no-undef": 1 } + ); + }); + + it("15", () => { + verifyAndAssertMessages( + ` + import type Foo2 from 'foo'; + export default class Foo {get fooProp(): Foo2{}} + `, + { "no-unused-vars": 1, "no-undef": 1 } + ); + }); + + it("16", () => { + verifyAndAssertMessages( + ` + import type Foo from 'foo'; + var numVal:Foo; numVal; + `, + { "no-unused-vars": 1, "no-undef": 1 } + ); + }); + + it("17", () => { + verifyAndAssertMessages( + ` + import type Foo from 'foo'; + var a: {numVal: Foo;}; a; + `, + { "no-unused-vars": 1, "no-undef": 1 } + ); + }); + + it("18", () => { + verifyAndAssertMessages( + ` + import type Foo from 'foo'; + import type Foo2 from 'foo'; + import type Foo3 from 'foo'; + var a: ?{numVal: Foo; [indexer: Foo2]: Foo3}; a; + `, + { "no-unused-vars": 1, "no-undef": 1 } + ); + }); + + it("19", () => { + verifyAndAssertMessages( + ` + import type Foo from 'foo'; + import type Foo2 from 'foo'; + var a: {numVal: Foo; subObj?: ?{strVal: Foo2}}; a; + `, + { "no-unused-vars": 1, "no-undef": 1 } + ); + }); + + it("20", () => { + verifyAndAssertMessages( + ` + import type Foo from 'foo'; + import type Foo2 from 'foo'; + import type Foo3 from 'foo'; + import type Foo4 from 'foo'; + var a: { [a: Foo]: Foo2; [b: Foo3]: Foo4; }; a; + `, + { "no-unused-vars": 1, "no-undef": 1 } + ); + }); + + it("21", () => { + verifyAndAssertMessages( + ` + import type Foo from 'foo'; + import type Foo2 from 'foo'; + import type Foo3 from 'foo'; + var a: {add(x:Foo, ...y:Array): Foo3}; a; + `, + { "no-unused-vars": 1, "no-undef": 1 } + ); + }); + + it("22", () => { + verifyAndAssertMessages( + ` + import type Foo from 'foo'; + import type Foo2 from 'foo'; + import type Foo3 from 'foo'; + var a: { id(x: Foo2): Foo3; }; a; + `, + { "no-unused-vars": 1, "no-undef": 1 } + ); + }); + + it("23", () => { + verifyAndAssertMessages( + ` + import type Foo from 'foo'; + var a:Array = [1, 2, 3]; a; + `, + { "no-unused-vars": 1, "no-undef": 1 } + ); + }); + + it("24", () => { + verifyAndAssertMessages( + ` + import type Baz from 'baz'; + export default class Bar extends Baz { }; + `, + { "no-unused-vars": 1, "no-undef": 1 } + ); + }); + + it("25", () => { + verifyAndAssertMessages( + "export default class Bar { bar(): T { return 42; }}", + { "no-unused-vars": 1, "no-undef": 1 } + ); + }); + + it("26", () => { + verifyAndAssertMessages( + ` + import type Foo from 'foo'; + import type Foo2 from 'foo'; + export default class Bar { static prop1:Foo; prop2:Foo2; } + `, + { "no-unused-vars": 1, "no-undef": 1 } + ); + }); + + it("27", () => { + verifyAndAssertMessages( + ` + import type Foo from 'foo'; + import type Foo2 from 'foo'; + var x : Foo | Foo2 = 4; x; + `, + { "no-unused-vars": 1, "no-undef": 1 } + ); + }); + + it("28", () => { + verifyAndAssertMessages( + ` + import type Foo from 'foo'; + import type Foo2 from 'foo'; + var x : () => Foo | () => Foo2; x; + `, + { "no-unused-vars": 1, "no-undef": 1 } + ); + }); + + it("29", () => { + verifyAndAssertMessages( + ` + import type Foo from 'foo'; + import type Foo2 from 'foo'; + var x: typeof Foo | number = Foo2; x; + `, + { "no-unused-vars": 1, "no-undef": 1 } + ); + }); + + it("30", () => { + verifyAndAssertMessages( + ` + import type Foo from 'foo'; + var {x}: {x: Foo; } = { x: 'hello' }; x; + `, + { "no-unused-vars": 1, "no-undef": 1 } + ); + }); + + it("31", () => { + verifyAndAssertMessages( + ` + import type Foo from 'foo'; + var [x]: Array = [ 'hello' ]; x; + `, + { "no-unused-vars": 1, "no-undef": 1 } + ); + }); + + it("32", () => { + verifyAndAssertMessages( + ` + import type Foo from 'foo'; + export default function({x}: { x: Foo; }) { x; } + `, + { "no-unused-vars": 1, "no-undef": 1 } + ); + }); + + it("33", () => { + verifyAndAssertMessages( + ` + import type Foo from 'foo'; + function foo([x]: Array) { x; } foo(); + `, + { "no-unused-vars": 1, "no-undef": 1 } + ); + }); + + it("34", () => { + verifyAndAssertMessages( + ` + import type Foo from 'foo'; + import type Foo2 from 'foo'; + var a: Map >; a; + `, + { "no-unused-vars": 1, "no-undef": 1 } + ); + }); + + it("35", () => { + verifyAndAssertMessages( + ` + import type Foo from 'foo'; + var a: ?Promise[]; a; + `, + { "no-unused-vars": 1, "no-undef": 1 } + ); + }); + + it("36", () => { + verifyAndAssertMessages( + ` + import type Foo from 'foo'; + import type Foo2 from 'foo'; + var a:(...rest:Array) => Foo2; a; + `, + { "no-unused-vars": 1, "no-undef": 1 } + ); + }); + + it("37", () => { + verifyAndAssertMessages( + ` + import type Foo from 'foo'; + import type Foo2 from 'foo'; + import type Foo3 from 'foo'; + import type Foo4 from 'foo'; + var a: (x: Foo2, ...y:Foo3[]) => Foo4; a; + `, + { "no-unused-vars": 1, "no-undef": 1 } + ); + }); + + it("38", () => { + verifyAndAssertMessages( + ` + import type {foo, bar} from 'baz'; + foo; bar; + `, + { "no-unused-vars": 1, "no-undef": 1 } + ); + }); + + it("39", () => { + verifyAndAssertMessages( + ` + import type {foo as bar} from 'baz'; + bar; + `, + { "no-unused-vars": 1, "no-undef": 1 } + ); + }); + + it("40", () => { + verifyAndAssertMessages( + ` + import type from 'foo'; + type; + `, + { "no-unused-vars": 1, "no-undef": 1 } + ); + }); + + it("41", () => { + verifyAndAssertMessages( + ` + import type, {foo} from 'bar'; + type; foo; + `, + { "no-unused-vars": 1, "no-undef": 1 } + ); + }); + + it("43", () => { + verifyAndAssertMessages( + ` + import type Foo from 'foo'; + var a: Foo[]; a; + `, + { "no-unused-vars": 1, "no-undef": 1 } + ); + }); + + it("44", () => { + verifyAndAssertMessages( + ` + import type Foo from 'foo'; + var a: ?Foo[]; a; + `, + { "no-unused-vars": 1, "no-undef": 1 } + ); + }); + + it("45", () => { + verifyAndAssertMessages( + ` + import type Foo from 'foo'; + var a: (?Foo)[]; a; + `, + { "no-unused-vars": 1, "no-undef": 1 } + ); + }); + + it("46", () => { + verifyAndAssertMessages( + ` + import type Foo from 'foo'; + var a: () => Foo[]; a; + `, + { "no-unused-vars": 1, "no-undef": 1 } + ); + }); + + it("47", () => { + verifyAndAssertMessages( + ` + import type Foo from 'foo'; + var a: (() => Foo)[]; a; + `, + { "no-unused-vars": 1, "no-undef": 1 } + ); + }); + + it("48", () => { + verifyAndAssertMessages( + ` + import type Foo from 'foo'; + var a: typeof Foo[]; a; + `, + { "no-unused-vars": 1, "no-undef": 1 } + ); + }); + + it("49", () => { + verifyAndAssertMessages( + ` + import type Foo from 'foo'; + import type Foo2 from 'foo'; + import type Foo3 from 'foo'; + var a : [Foo, Foo2,] = [123, 'duck',]; a; + `, + { "no-unused-vars": 1, "no-undef": 1 } + ); + }); + }); + + it("class usage", () => { + verifyAndAssertMessages("class Lol {} module.exports = Lol;", { + "no-unused-vars": 1, + }); + }); + + it("class definition: gaearon/redux#24", () => { + verifyAndAssertMessages( + ` + export default function root(stores) { + return DecoratedComponent => class ReduxRootDecorator { + a() { DecoratedComponent; stores; } + }; + } + `, + { "no-undef": 1, "no-unused-vars": 1 } + ); + }); + + it("class properties #71", () => { + verifyAndAssertMessages("class Lol { foo = 'bar'; }", { "no-undef": 1 }); + }); + + it("template strings #31", () => { + verifyAndAssertMessages("console.log(`${a}, b`);", { "comma-spacing": 1 }); + }); + + it("template with destructuring #31", () => { + verifyAndAssertMessages( + ` + module.exports = { + render() { + var {name} = this.props; + return Math.max(null, \`Name: \${name}, Name: \${name}\`); + } + }; + `, + { "comma-spacing": 1 } + ); + }); + + it("template with arrow returning template #603", () => { + verifyAndAssertMessages( + ` + var a = \`\${() => { + \`\${''}\` + }}\`; + `, + { indent: 1 }, + [] + ); + }); + + describe("decorators #72 (legacy)", () => { + function verifyDecoratorsLegacyAndAssertMessages( + code, + rules, + expectedMessages, + sourceType + ) { + const overrideConfig = { + parserOptions: { + sourceType, + babelOptions: { + configFile: path.resolve( + __dirname, + "../fixtures/config/babel.config.decorators-legacy.js" + ), + }, + }, + }; + return verifyAndAssertMessages( + code, + rules, + expectedMessages, + sourceType, + overrideConfig + ); + } + + it("class declaration", () => { + verifyDecoratorsLegacyAndAssertMessages( + ` + import classDeclaration from 'decorator'; + import decoratorParameter from 'decorator'; + @classDeclaration((parameter) => parameter) + @classDeclaration(decoratorParameter) + @classDeclaration + export class TextareaAutosize {} + `, + { "no-unused-vars": 1 } + ); + }); + + it("method definition", () => { + verifyDecoratorsLegacyAndAssertMessages( + ` + import classMethodDeclarationA from 'decorator'; + import decoratorParameter from 'decorator'; + export class TextareaAutosize { + @classMethodDeclarationA((parameter) => parameter) + @classMethodDeclarationA(decoratorParameter) + @classMethodDeclarationA + methodDeclaration(e) { + e(); + } + } + `, + { "no-unused-vars": 1 } + ); + }); + + it("method definition get/set", () => { + verifyDecoratorsLegacyAndAssertMessages( + ` + import classMethodDeclarationA from 'decorator'; + import decoratorParameter from 'decorator'; + export class TextareaAutosize { + @classMethodDeclarationA((parameter) => parameter) + @classMethodDeclarationA(decoratorParameter) + @classMethodDeclarationA + get bar() { } + @classMethodDeclarationA((parameter) => parameter) + @classMethodDeclarationA(decoratorParameter) + @classMethodDeclarationA + set bar(val) { val; } + } + `, + { "no-unused-vars": 1 } + ); + }); + + it("object property", () => { + verifyDecoratorsLegacyAndAssertMessages( + ` + import classMethodDeclarationA from 'decorator'; + import decoratorParameter from 'decorator'; + var obj = { + @classMethodDeclarationA((parameter) => parameter) + @classMethodDeclarationA(decoratorParameter) + @classMethodDeclarationA + methodDeclaration(e) { + e(); + } + }; + obj; + `, + { "no-unused-vars": 1 } + ); + }); + + it("object property get/set", () => { + verifyDecoratorsLegacyAndAssertMessages( + ` + import classMethodDeclarationA from 'decorator'; + import decoratorParameter from 'decorator'; + var obj = { + @classMethodDeclarationA((parameter) => parameter) + @classMethodDeclarationA(decoratorParameter) + @classMethodDeclarationA + get bar() { }, + @classMethodDeclarationA((parameter) => parameter) + @classMethodDeclarationA(decoratorParameter) + @classMethodDeclarationA + set bar(val) { val; } + }; + obj; + `, + { "no-unused-vars": 1 } + ); + }); + }); + + describe("decorators #72", () => { + it("class declaration", () => { + verifyAndAssertMessages( + ` + import classDeclaration from 'decorator'; + import decoratorParameter from 'decorator'; + export + @classDeclaration((parameter) => parameter) + @classDeclaration(decoratorParameter) + @classDeclaration + class TextareaAutosize {} + `, + { "no-unused-vars": 1 } + ); + }); + + it("method definition", () => { + verifyAndAssertMessages( + ` + import classMethodDeclarationA from 'decorator'; + import decoratorParameter from 'decorator'; + export class TextareaAutosize { + @classMethodDeclarationA((parameter) => parameter) + @classMethodDeclarationA(decoratorParameter) + @classMethodDeclarationA + methodDeclaration(e) { + e(); + } + } + `, + { "no-unused-vars": 1 } + ); + }); + + it("method definition get/set", () => { + verifyAndAssertMessages( + ` + import classMethodDeclarationA from 'decorator'; + import decoratorParameter from 'decorator'; + export class TextareaAutosize { + @classMethodDeclarationA((parameter) => parameter) + @classMethodDeclarationA(decoratorParameter) + @classMethodDeclarationA + get bar() { } + @classMethodDeclarationA((parameter) => parameter) + @classMethodDeclarationA(decoratorParameter) + @classMethodDeclarationA + set bar(val) { val; } + } + `, + { "no-unused-vars": 1 } + ); + }); + }); + + it("detects minimal no-unused-vars case #120", () => { + verifyAndAssertMessages("var unused;", { "no-unused-vars": 1 }, [ + "1:5 'unused' is defined but never used. no-unused-vars", + ]); + }); + + // This two tests are disabled, as the feature to visit properties when + // there is a spread/rest operator has been removed as it caused problems + // with other rules #249 + it.skip("visits excluded properties left of spread #95", () => { + verifyAndAssertMessages( + "var originalObject = {}; var {field1, field2, ...clone} = originalObject;", + { "no-unused-vars": 1 } + ); + }); + + it.skip("visits excluded properties left of spread #210", () => { + verifyAndAssertMessages( + "const props = { yo: 'yo' }; const { ...otherProps } = props;", + { "no-unused-vars": 1 } + ); + }); + + it("does not mark spread variables false-positive", () => { + verifyAndAssertMessages( + "var originalObject = {}; var {field1, field2, ...clone} = originalObject;", + { "no-undef": 1, "no-redeclare": 1 } + ); + }); + + it("does not mark spread variables false-positive", () => { + verifyAndAssertMessages( + "const props = { yo: 'yo' }; const { ...otherProps } = props;", + { "no-undef": 1, "no-redeclare": 1 } + ); + }); + + it("does not mark spread variables as use-before-define #249", () => { + verifyAndAssertMessages( + "var originalObject = {}; var {field1, field2, ...clone} = originalObject;", + { "no-use-before-define": 1 } + ); + }); + + it("detects no-unused-vars with object destructuring #142", () => { + verifyAndAssertMessages( + "const {Bacona} = require('baconjs')", + { "no-undef": 1, "no-unused-vars": 1 }, + ["1:8 'Bacona' is assigned a value but never used. no-unused-vars"] + ); + }); + + it("don't warn no-unused-vars with spread #142", () => { + verifyAndAssertMessages( + ` + export default function test(data) { + return { + foo: 'bar', + ...data + }; + } + `, + { "no-undef": 1, "no-unused-vars": 1 } + ); + }); + + it("excludes comment tokens #153", () => { + verifyAndAssertMessages( + ` + var a = [ + 1, + 2, // a trailing comment makes this line fail comma-dangle (always-multiline) + ]; + `, + { "comma-dangle": [2, "always-multiline"] } + ); + + verifyAndAssertMessages( + ` + switch (a) { + // A comment here makes the above line fail brace-style + case 1: + console.log(a); + } + `, + { "brace-style": 2 } + ); + }); + + it("ternary and parens #149", () => { + verifyAndAssertMessages("true ? (true) : false;", { "space-infix-ops": 1 }); + }); + + it("line comment space-in-parens #124", () => { + verifyAndAssertMessages( + ` + React.createClass({ + render() { + // return ( + //
+ // ); // <-- this is the line that is reported + } + }); + `, + { "space-in-parens": 1 } + ); + }); + + it("block comment space-in-parens #124", () => { + verifyAndAssertMessages( + ` + React.createClass({ + render() { + /* + return ( +
+ ); // <-- this is the line that is reported + */ + } + }); + `, + { "space-in-parens": 1 } + ); + }); + + it("no no-undef error with rest #11", () => { + verifyAndAssertMessages("const [a, ...rest] = ['1', '2', '3']; a; rest;", { + "no-undef": 1, + "no-unused-vars": 1, + }); + }); + + it("async function with space-before-function-paren #168", () => { + verifyAndAssertMessages("it('handles updates', async function() {});", { + "space-before-function-paren": [1, "never"], + }); + }); + + it("default param flow type no-unused-vars #184", () => { + verifyAndAssertMessages( + ` + type ResolveOptionType = { + depth?: number, + identifier?: string + }; + + export default function resolve( + options: ResolveOptionType = {} + ): Object { + options; + } + `, + { "no-unused-vars": 1, "no-undef": 1 } + ); + }); + + it("no-use-before-define #192", () => { + verifyAndAssertMessages( + ` + console.log(x); + var x = 1; + `, + { "no-use-before-define": 1 }, + ["1:13 'x' was used before it was defined. no-use-before-define"] + ); + }); + + it("jsx and stringliteral #216", () => { + verifyAndAssertMessages("
"); + }); + + it("getter/setter #218", () => { + verifyAndAssertMessages( + ` + class Person { + set a (v) { } + } + `, + { + "space-before-function-paren": 1, + "keyword-spacing": [1, { before: true }], + indent: 1, + } + ); + }); + + it("getter/setter #220", () => { + verifyAndAssertMessages( + ` + var B = { + get x () { + return this.ecks; + }, + set x (ecks) { + this.ecks = ecks; + } + }; + `, + { "no-dupe-keys": 1 } + ); + }); + + it("fixes issues with flow types and ObjectPattern", () => { + verifyAndAssertMessages( + ` + import type Foo from 'bar'; + export default class Foobar { + foo({ bar }: Foo) { bar; } + bar({ foo }: Foo) { foo; } + } + `, + { "no-unused-vars": 1, "no-shadow": 1 } + ); + }); + + it("correctly detects redeclares if in script mode #217", () => { + verifyAndAssertMessages( + ` + var a = 321; + var a = 123; + `, + { "no-redeclare": 1 }, + ["2:5 'a' is already defined. no-redeclare"], + "script" + ); + }); + + it("correctly detects redeclares if in module mode #217", () => { + verifyAndAssertMessages( + ` + var a = 321; + var a = 123; + `, + { "no-redeclare": 1 }, + ["2:5 'a' is already defined. no-redeclare"], + "module" + ); + }); + + it("no-implicit-globals in script", () => { + verifyAndAssertMessages( + "var leakedGlobal = 1;", + { "no-implicit-globals": 1 }, + [ + "1:5 Implicit global variable, assign as global property instead. no-implicit-globals", + ], + "script", + { + env: {}, + parserOptions: { ecmaVersion: 6, sourceType: "script" }, + } + ); + }); + + it("no-implicit-globals in module", () => { + verifyAndAssertMessages( + "var leakedGlobal = 1;", + { "no-implicit-globals": 1 }, + [], + "module", + { + env: {}, + parserOptions: { ecmaVersion: 6, sourceType: "module" }, + } + ); + }); + + it("no-implicit-globals in default", () => { + verifyAndAssertMessages( + "var leakedGlobal = 1;", + { "no-implicit-globals": 1 }, + [], + null, + { + env: {}, + parserOptions: { ecmaVersion: 6 }, + } + ); + }); + + it("allowImportExportEverywhere option (#327)", () => { + verifyAndAssertMessages( + ` + if (true) { import Foo from 'foo'; } + function foo() { import Bar from 'bar'; } + switch (a) { case 1: import FooBar from 'foobar'; } + `, + {}, + [], + "module", + { + env: {}, + parserOptions: { + ecmaVersion: 6, + sourceType: "module", + allowImportExportEverywhere: true, + }, + } + ); + }); + + it("with does not crash parsing in script mode (strict off) #171", () => { + verifyAndAssertMessages("with (arguments) { length; }", {}, [], "script"); + }); + + xit("with does crash parsing in module mode (strict on) #171", () => { + verifyAndAssertMessages("with (arguments) { length; }", {}, [ + "1:1 Parsing error: 'with' in strict mode", + ]); + }); + + it("new.target is not reported as undef #235", () => { + verifyAndAssertMessages("function foo () { return new.target }", { + "no-undef": 1, + }); + }); + + it("decorator does not create TypeError #229", () => { + verifyAndAssertMessages( + ` + class A { + @test + f() {} + } + `, + { "no-undef": 1 }, + ["2:4 'test' is not defined. no-undef"] + ); + }); + + it("Flow definition does not trigger warnings #223", () => { + verifyAndAssertMessages( + ` + import { Map as $Map } from 'immutable'; + function myFunction($state: $Map, { a, b, c } : { a: ?Object, b: ?Object, c: $Map }) {} + `, + { "no-dupe-args": 1, "no-redeclare": 1, "no-shadow": 1 } + ); + }); + + it("newline-before-return with comments #289", () => { + verifyAndAssertMessages( + ` + function a() { + if (b) { + /* eslint-disable no-console */ + console.log('test'); + /* eslint-enable no-console */ + } + + return hasGlobal; + } + `, + { "newline-before-return": 1 } + ); + }); + + it("spaced-comment with shebang #163", () => { + verifyAndAssertMessages( + ` + #!/usr/bin/env babel-node + import {spawn} from 'foobar'; + `, + { "spaced-comment": 1 } + ); + }); + + describe("Class Property Declarations", () => { + it("no-redeclare false positive 1", () => { + verifyAndAssertMessages( + ` + class Group { + static propTypes = {}; + } + class TypicalForm { + static propTypes = {}; + } + `, + { "no-redeclare": 1 } + ); + }); + + it("no-redeclare false positive 2", () => { + verifyAndAssertMessages( + ` + function validate() {} + class MyComponent { + static validate = validate; + } + `, + { "no-redeclare": 1 } + ); + }); + + it("check references", () => { + verifyAndAssertMessages( + ` + var a; + class A { + prop1; + prop2 = a; + prop3 = b; + } + new A + `, + { "no-undef": 1, "no-unused-vars": 1, "no-redeclare": 1 }, + ["5:11 'b' is not defined. no-undef"] + ); + }); + }); + + it("dynamic import support", () => { + verifyAndAssertMessages("import('test-module').then(() => {})"); + }); + + it("regex with es6 unicodeCodePointEscapes", () => { + verifyAndAssertMessages( + "string.replace(/[\u{0000A0}-\u{10FFFF}<>&]/gmiu, (char) => `&#x${char.codePointAt(0).toString(16)};`);" + ); + }); + + describe("private class properties", () => { + it("should not be undefined", () => { + verifyAndAssertMessages( + ` + class C { + #d = 1; + } + `, + { "no-undef": 1 } + ); + }); + + it("should not be unused", () => { + verifyAndAssertMessages( + ` + export class C { + #d = 1; + } + `, + { "no-unused-vars": 1 } + ); + }); + }); + + describe("optional chaining operator", () => { + it("should not be undefined #595", () => { + verifyAndAssertMessages( + ` + const foo = {}; + foo?.bar; + `, + { "no-undef": 1 } + ); + }); + }); + + it("flow types on class method should be visited correctly", () => { + verifyAndAssertMessages( + ` + import type NodeType from 'foo'; + class NodeUtils { + finishNodeAt(node: T): T { return node; } + } + + new NodeUtils(); + `, + { "no-unused-vars": 1 } + ); + }); + + it("works with dynamicImport", () => { + verifyAndAssertMessages( + ` + import('a'); + ` + ); + }); + + it("works with numericSeparator", () => { + verifyAndAssertMessages( + ` + 1_000 + ` + ); + }); + + it("works with optionalChaining", () => { + verifyAndAssertMessages( + ` + a?.b + ` + ); + }); + + it("works with import.meta", () => { + verifyAndAssertMessages( + ` + import.meta + ` + ); + }); + + it("works with classPrivateProperties", () => { + verifyAndAssertMessages( + ` + class A { #a = 1; } + ` + ); + }); + + it("works with optionalCatchBinding", () => { + verifyAndAssertMessages( + ` + try {} catch {} + try {} catch {} finally {} + ` + ); + }); + + it("exportDefaultFrom", () => { + verifyAndAssertMessages( + ` + export v from "mod" + ` + ); + }); + + it("exportNamespaceFrom", () => { + verifyAndAssertMessages( + ` + export * as ns from "mod" + ` + ); + }); + + it("ignore eval in scope analysis", () => { + verifyAndAssertMessages( + ` + const a = 1; + console.log(a); + eval(''); + `, + { "no-unused-vars": 1, "no-undef": 1 } + ); + }); +}); diff --git a/eslint/babel-eslint-plugin-development/.github/main.workflow b/eslint/babel-eslint-plugin-development/.github/main.workflow new file mode 100644 index 000000000000..6bad3e10057e --- /dev/null +++ b/eslint/babel-eslint-plugin-development/.github/main.workflow @@ -0,0 +1,23 @@ +workflow "Build, Lint and Test" { + resolves = ["Test", "Lint"] + on = "push" +} + +action "Build" { + uses = "docker://node:10" + runs = "yarn" +} + +action "Test" { + needs = "Build" + uses = "docker://node:10" + runs = "yarn" + args = "test" +} + +action "Lint" { + needs = "Build" + uses = "docker://node:10" + runs = "yarn" + args = "lint" +} diff --git a/eslint/babel-eslint-plugin-development/.gitignore b/eslint/babel-eslint-plugin-development/.gitignore new file mode 100644 index 000000000000..b512c09d4766 --- /dev/null +++ b/eslint/babel-eslint-plugin-development/.gitignore @@ -0,0 +1 @@ +node_modules \ No newline at end of file diff --git a/eslint/babel-eslint-plugin-development/.npmignore b/eslint/babel-eslint-plugin-development/.npmignore new file mode 100644 index 000000000000..5e0f958edde7 --- /dev/null +++ b/eslint/babel-eslint-plugin-development/.npmignore @@ -0,0 +1,3 @@ +tests/ +.github/ +.* \ No newline at end of file diff --git a/eslint/babel-eslint-plugin-development/README.md b/eslint/babel-eslint-plugin-development/README.md new file mode 100644 index 000000000000..12cc354b7470 --- /dev/null +++ b/eslint/babel-eslint-plugin-development/README.md @@ -0,0 +1,38 @@ +# @babel/eslint-plugin-development + +A set of eslint rules to enforce best practices in the development of Babel plugins. + +## Installation + +You'll first need to install [ESLint](http://eslint.org): + +``` +$ npm install --save-dev eslint +``` + +Next, install `@babel/eslint-plugin-development`: + +``` +$ npm install --save-dev @babel/eslint-plugin-development +``` + +Then, load the plugin in your `.eslintrc` configuration file. You can omit the `eslint-plugin-` prefix: + +```json +{ + "plugins": ["@babel/development"] +} +``` + +## Supported Rules + +> Note: Rules marked with :wrench: are autofixable. + +* `@babel/development/no-deprecated-clone` (:wrench:): Disallows using the deprecated + `t.clone(node)` and `t.cloneDeep(node)` methods from `@babel/types`. Those + calls are replaced with `t.cloneNode(node)` when using `eslint --fix`. +* `@babel/development/no-undefined-identifier`: Disallows using + `t.identifier("undefined")` to create a node which represents an `undefined` + value, since it might cause problem if `undefined` is redeclared. +* `@babel/development/plugin-name`: Requires plugins to have a `name` property, which + can be useful for debugging purposes. diff --git a/eslint/babel-eslint-plugin-development/package.json b/eslint/babel-eslint-plugin-development/package.json new file mode 100644 index 000000000000..9a65d7b6cf8a --- /dev/null +++ b/eslint/babel-eslint-plugin-development/package.json @@ -0,0 +1,34 @@ +{ + "name": "@babel/eslint-plugin-development", + "version": "1.0.1", + "description": "A set of eslint rules to enforce best practices in the development of Babel plugins.", + "keywords": [ + "eslint", + "eslintplugin", + "eslint-plugin" + ], + "author": { + "name": "Nicolò Ribaudo", + "email": "nicolo.ribaudo@gmail.com", + "url": "https://github.com/nicolo-ribaudo" + }, + "main": "src/index.js", + "scripts": { + "test": "mocha tests --recursive" + }, + "devDependencies": { + "eslint": "^5.9.0", + "mocha": "^5.2.0" + }, + "engines": { + "node": ">=8.0.0" + }, + "publishConfig": { + "access": "public" + }, + "license": "MIT", + "repository": { + "type": "git", + "url": "https://github.com/babel/eslint-plugin-babel-plugin.git" + } +} diff --git a/eslint/babel-eslint-plugin-development/src/index.js b/eslint/babel-eslint-plugin-development/src/index.js new file mode 100644 index 000000000000..3965315c844b --- /dev/null +++ b/eslint/babel-eslint-plugin-development/src/index.js @@ -0,0 +1,9 @@ +"use strict"; + +module.exports = { + rules: { + "no-deprecated-clone": require("./rules/no-deprecated-clone"), + "no-undefined-identifier": require("./rules/no-undefined-identifier"), + "plugin-name": require("./rules/plugin-name"), + }, +}; diff --git a/eslint/babel-eslint-plugin-development/src/rules/no-deprecated-clone.js b/eslint/babel-eslint-plugin-development/src/rules/no-deprecated-clone.js new file mode 100644 index 000000000000..e6e72f1b9b06 --- /dev/null +++ b/eslint/babel-eslint-plugin-development/src/rules/no-deprecated-clone.js @@ -0,0 +1,41 @@ +"use strict"; + +const getReferenceOrigin = require("../utils/get-reference-origin"); +const isFromBabelTypes = require("../utils/is-from-babel-types"); + +module.exports = { + meta: { + schema: [], + fixable: "code", + }, + create(context) { + return { + CallExpression(node) { + const { callee } = node; + const scope = context.getScope(); + + const origin = getReferenceOrigin(callee, scope); + if (!origin) return; + + const { name } = origin; + if ( + (name === "clone" || name === "cloneDeep") && + isFromBabelTypes(origin, scope) + ) { + const isMemberExpression = callee.type === "MemberExpression"; + const id = isMemberExpression ? callee.property : callee; + + context.report({ + node: id, + message: `t.${name}() is deprecated. Use t.cloneNode() instead.`, + fix(fixer) { + if (isMemberExpression) { + return fixer.replaceText(id, "cloneNode"); + } + }, + }); + } + }, + }; + }, +}; diff --git a/eslint/babel-eslint-plugin-development/src/rules/no-undefined-identifier.js b/eslint/babel-eslint-plugin-development/src/rules/no-undefined-identifier.js new file mode 100644 index 000000000000..7a433b160c75 --- /dev/null +++ b/eslint/babel-eslint-plugin-development/src/rules/no-undefined-identifier.js @@ -0,0 +1,41 @@ +"use strict"; + +const getReferenceOrigin = require("../utils/get-reference-origin"); +const isFromBabelTypes = require("../utils/is-from-babel-types"); + +function firstArgumentIsUndefinedString(argumentsArray) { + return ( + argumentsArray.length > 0 && + argumentsArray[0].type === "Literal" && + argumentsArray[0].value === "undefined" + ); +} + +module.exports = { + meta: { + schema: [], + }, + create(context) { + return { + CallExpression(node) { + const { callee } = node; + const scope = context.getScope(); + + const origin = getReferenceOrigin(callee, scope); + if (!origin) return; + + const { name } = origin; + if ( + (name === "identifier" || name === "Identifier") && + firstArgumentIsUndefinedString(node.arguments) && + isFromBabelTypes(origin, scope) + ) { + context.report( + node, + "Use path.scope.buildUndefinedNode() to create an undefined identifier directly." + ); + } + }, + }; + }, +}; diff --git a/eslint/babel-eslint-plugin-development/src/rules/plugin-name.js b/eslint/babel-eslint-plugin-development/src/rules/plugin-name.js new file mode 100644 index 000000000000..11dd02808a31 --- /dev/null +++ b/eslint/babel-eslint-plugin-development/src/rules/plugin-name.js @@ -0,0 +1,52 @@ +"use strict"; + +const isBabelPluginFactory = require("../utils/is-babel-plugin-factory"); + +function getReturnValue(node) { + const { body } = node; + + if (body.type === "BlockStatement") { + const returnNode = body.body.find(n => n.type === "ReturnStatement"); + return returnNode && returnNode.argument; + } + + // Arrow functions with implicit return + return body; +} + +module.exports = { + meta: { + schema: [], + }, + create(context /*: Context */) { + let pluginFound = false; + + return { + FunctionDeclaration: functionVisitor, + FunctionExpression: functionVisitor, + ArrowFunctionExpression: functionVisitor, + + "Program:exit"(node) { + if (!pluginFound) { + context.report(node, "This file does not export a Babel plugin."); + } + }, + }; + + function functionVisitor(node) { + if (!isBabelPluginFactory(node, context.getScope())) return; + + const returnValue = getReturnValue(node); + if (!returnValue || returnValue.type !== "ObjectExpression") return; + + pluginFound = true; + + if (!returnValue.properties.some(p => p.key.name === "name")) { + context.report( + returnValue, + "This Babel plugin doesn't have a 'name' property." + ); + } + } + }, +}; diff --git a/eslint/babel-eslint-plugin-development/src/utils/get-export-name.js b/eslint/babel-eslint-plugin-development/src/utils/get-export-name.js new file mode 100644 index 000000000000..8c6e2c5e4086 --- /dev/null +++ b/eslint/babel-eslint-plugin-development/src/utils/get-export-name.js @@ -0,0 +1,24 @@ +"use strict"; + +module.exports = function getExportName(node) { + const { parent } = node; + + if (parent.type === "ExportDefaultDeclaration") { + return "default"; + } + + if (parent.type === "ExportNamedDeclaration") { + return node.id.name; + } + + if ( + parent.type === "AssignmentExpression" && + parent.left.type === "MemberExpression" && + parent.left.object.type === "Identifier" && + parent.left.object.name === "module" && + parent.left.property.type === "Identifier" && + parent.left.property.name === "exports" + ) { + return "module.exports"; + } +}; diff --git a/eslint/babel-eslint-plugin-development/src/utils/get-reference-origin.js b/eslint/babel-eslint-plugin-development/src/utils/get-reference-origin.js new file mode 100644 index 000000000000..44cebc4edc0b --- /dev/null +++ b/eslint/babel-eslint-plugin-development/src/utils/get-reference-origin.js @@ -0,0 +1,142 @@ +"use strict"; + +module.exports = getReferenceOrigin; + +/*:: +type ReferenceOriginImport = { kind: "import", source: string, name: string }; +type ReferenceOriginParam = { + kind: "param", + index: number, + functionNode: Node, +}; + +type ReferenceOrigin = + | ReferenceOriginImport + | ReferenceOriginParam + | { kind: "import *", source: string } + | { + kind: "property", + base: ReferenceOriginImport | ReferenceOriginParam, + path: string, + name: string, + }; +*/ + +// Given a node and a context, returns a description of where its value comes +// from. +// It resolves imports, parameters of exported functions and property accesses. +// See the ReferenceOrigin type for more informations. +function getReferenceOrigin(node, scope) /*: ?ReferenceOrigin */ { + if (node.type === "Identifier") { + const variable = getVariableDefinition(node.name, scope); + if (!variable) return null; + + const definition = variable.definition; + const defNode = definition.node; + + if (definition.type === "ImportBinding") { + if (defNode.type === "ImportSpecifier") { + return { + kind: "import", + source: definition.parent.source.value, + name: defNode.imported.name, + }; + } + if (defNode.type === "ImportNamespaceSpecifier") { + return { + kind: "import *", + source: definition.parent.source.value, + }; + } + } + + if (definition.type === "Variable" && defNode.init) { + const origin = getReferenceOrigin(defNode.init, variable.scope); + return origin && patternToProperty(definition.name, origin); + } + + if (definition.type === "Parameter") { + return patternToProperty(definition.name, { + kind: "param", + index: definition.index, + functionNode: definition.node, + }); + } + } + + if (node.type === "MemberExpression" && !node.computed) { + const origin = getReferenceOrigin(node.object, scope); + return origin && addProperty(origin, node.property.name); + } + + return null; +} + +function getVariableDefinition(name, scope) { + let currentScope = scope; + do { + const variable = currentScope.set.get(name); + if (variable && variable.defs[0]) { + return { scope: currentScope, definition: variable.defs[0] }; + } + } while ((currentScope = currentScope.upper)); +} + +function patternToProperty(id, base) { + const path = getPatternPath(id); + return path && path.reduce(addProperty, base); +} + +// Adds a property to a given origin. If it was a namespace import it becomes +// a named import, so that `import * as x from "foo"; x.bar` and +// `import { bar } from "foo"` have the same origin. +function addProperty(origin, name) { + if (origin.kind === "import *") { + return { + kind: "import", + source: origin.source, + name, + }; + } + if (origin.kind === "property") { + return { + kind: "property", + base: origin.base, + path: origin.path + "." + name, + name, + }; + } + return { + kind: "property", + base: origin, + path: name, + name, + }; +} + +// if "node" is c of { a: { b: c } }, the result is ["a","b"] +function getPatternPath(node) { + let current = node; + const path = []; + + // Unshift keys to path while going up + do { + const property = current.parent; + if ( + property.type === "ArrayPattern" || + property.type === "AssignmentPattern" || + property.computed + ) { + // These nodes are not supported. + return null; + } + if (property.type === "Property") { + path.unshift(property.key.name); + } else { + // The destructuring pattern is finished + break; + } + } while ((current = current.parent.parent)); + + return path; +} diff --git a/eslint/babel-eslint-plugin-development/src/utils/is-babel-plugin-factory.js b/eslint/babel-eslint-plugin-development/src/utils/is-babel-plugin-factory.js new file mode 100644 index 000000000000..287124e22809 --- /dev/null +++ b/eslint/babel-eslint-plugin-development/src/utils/is-babel-plugin-factory.js @@ -0,0 +1,26 @@ +"use strict"; + +const getReferenceOrigin = require("./get-reference-origin"); +const getExportName = require("./get-export-name"); + +module.exports = function isBabelPluginFactory(node, scope) { + const { parent } = node; + + if (parent.type === "CallExpression") { + const calleeOrigin = getReferenceOrigin(parent.callee, scope); + + // Using "declare" from "@babel/helper-plugin-utils" + return !!( + calleeOrigin && + calleeOrigin.kind === "import" && + calleeOrigin.name === "declare" && + calleeOrigin.source === "@babel/helper-plugin-utils" + ); + } + + const exportName = getExportName(node); + + // export default function ({ types: t }) {} + // module.exports = function ({ types: t }) {} + return exportName === "default" || exportName === "module.exports"; +}; diff --git a/eslint/babel-eslint-plugin-development/src/utils/is-from-babel-types.js b/eslint/babel-eslint-plugin-development/src/utils/is-from-babel-types.js new file mode 100644 index 000000000000..304561621732 --- /dev/null +++ b/eslint/babel-eslint-plugin-development/src/utils/is-from-babel-types.js @@ -0,0 +1,35 @@ +"use strict"; + +const isBabelPluginFactory = require("./is-babel-plugin-factory"); + +// Check if a ReferenceOrigin (returned by ./get-reference-origin.js) +// is a reference to a @babel/types export. +module.exports = function isFromBabelTypes( + origin /*: ReferenceOrigin */, + scope /*: Scope */ +) { + if (origin.kind === "import" && origin.source === "@babel/types") { + // imported from @babel/types + return true; + } + + if ( + origin.kind === "property" && + origin.base.kind === "import" && + origin.base.name === "types" && + origin.base.source === "@babel/core" + ) { + // imported from @babel/core + return true; + } + + if ( + origin.kind === "property" && + origin.base.kind === "param" && + origin.base.index === 0 + ) { + return isBabelPluginFactory(origin.base.functionNode, scope); + } + + return false; +}; diff --git a/eslint/babel-eslint-plugin-development/tests/rules/no-deprecated-clone.js b/eslint/babel-eslint-plugin-development/tests/rules/no-deprecated-clone.js new file mode 100644 index 000000000000..473a3a32b21a --- /dev/null +++ b/eslint/babel-eslint-plugin-development/tests/rules/no-deprecated-clone.js @@ -0,0 +1,138 @@ +"use strict"; + +const rule = require("../../src/rules/no-deprecated-clone"); +const { RuleTester } = require("eslint"); + +const cloneError = "t.clone() is deprecated. Use t.cloneNode() instead."; +const cloneDeepError = + "t.cloneDeep() is deprecated. Use t.cloneNode() instead."; + +const ruleTester = new RuleTester({ + parserOptions: { sourceType: "module" }, +}); + +ruleTester.run("no-deprecated-clone", rule, { + valid: [ + `_.clone(obj)`, + `_.cloneDeep(obj)`, + `import * as t from "lib"; t.clone();`, + `import * as t from "lib"; t.cloneDeep();`, + `function f(_) { _.types.clone(); }`, + `function f(_) { _.types.cloneDeep(); }`, + `import * as t from "@babel/types"; t.cloneNode();`, + ], + invalid: [ + { + code: `import { clone } from "@babel/types"; clone();`, + errors: [cloneError], + }, + { + code: `import { cloneDeep } from "@babel/types"; cloneDeep();`, + errors: [cloneDeepError], + }, + { + code: `import { clone } from "@babel/types"; var clone2 = clone; clone2();`, + errors: [cloneError], + }, + { + code: `import { cloneDeep } from "@babel/types"; var cloneDeep2 = cloneDeep; cloneDeep2();`, + errors: [cloneDeepError], + }, + { + code: `import * as t from "@babel/types"; t.clone();`, + errors: [cloneError], + }, + { + code: `import * as t from "@babel/types"; t.cloneDeep();`, + errors: [cloneDeepError], + }, + { + code: `import * as t from "@babel/types"; var { clone } = t; clone();`, + errors: [cloneError], + }, + { + code: `import * as t from "@babel/types"; var { cloneDeep } = t; cloneDeep();`, + errors: [cloneDeepError], + }, + { + code: `import { clone as c } from "@babel/types"; c();`, + errors: [cloneError], + }, + { + code: `import { cloneDeep as cD } from "@babel/types"; cD();`, + errors: [cloneDeepError], + }, + { + code: `import * as babel from "@babel/core"; babel.types.clone();`, + errors: [cloneError], + }, + { + code: `import * as babel from "@babel/core"; babel.types.cloneDeep();`, + errors: [cloneDeepError], + }, + { + code: `import { types } from "@babel/core"; types.clone();`, + errors: [cloneError], + }, + { + code: `import { types } from "@babel/core"; types.cloneDeep();`, + errors: [cloneDeepError], + }, + { + code: `import { types as t } from "@babel/core"; t.clone();`, + errors: [cloneError], + }, + { + code: `import { types as t } from "@babel/core"; t.cloneDeep();`, + errors: [cloneDeepError], + }, + { + code: `export default function plugin(babel) { babel.types.clone() }`, + errors: [cloneError], + }, + { + code: `export default function plugin(babel) { babel.types.cloneDeep() }`, + errors: [cloneDeepError], + }, + { + code: `export default function plugin({ types }) { types.clone() }`, + errors: [cloneError], + }, + { + code: `export default function plugin({ types }) { types.cloneDeep() }`, + errors: [cloneDeepError], + }, + { + code: `export default function plugin({ types: t }) { t.clone() }`, + errors: [cloneError], + }, + { + code: `export default function plugin({ types: t }) { t.cloneDeep() }`, + errors: [cloneDeepError], + }, + { + code: `export default ({ types }) => { types.clone() }`, + errors: [cloneError], + }, + { + code: `export default ({ types }) => { types.cloneDeep() }`, + errors: [cloneDeepError], + }, + { + code: `module.exports = function plugin({ types }) { types.clone() }`, + errors: [cloneError], + }, + { + code: `module.exports = function plugin({ types }) { types.cloneDeep() }`, + errors: [cloneDeepError], + }, + { + code: `import { declare } from "@babel/helper-plugin-utils"; declare(({ types }) => { types.clone() });`, + errors: [cloneError], + }, + { + code: `import { declare } from "@babel/helper-plugin-utils"; declare(({ types }) => { types.cloneDeep() });`, + errors: [cloneDeepError], + }, + ], +}); diff --git a/eslint/babel-eslint-plugin-development/tests/rules/no-undefined-identifier.js b/eslint/babel-eslint-plugin-development/tests/rules/no-undefined-identifier.js new file mode 100644 index 000000000000..c77516b177a4 --- /dev/null +++ b/eslint/babel-eslint-plugin-development/tests/rules/no-undefined-identifier.js @@ -0,0 +1,80 @@ +"use strict"; + +const rule = require("../../src/rules/no-undefined-identifier"); +const { RuleTester } = require("eslint"); + +const error = + "Use path.scope.buildUndefinedNode() to create an undefined identifier directly."; + +const ruleTester = new RuleTester({ + parserOptions: { sourceType: "module" }, +}); + +ruleTester.run("no-undefined-identifier", rule, { + valid: [ + `_.identifier("undefined")`, + `_.Identifier("undefined")`, + `import * as t from "lib"; t.identifier("undefined");`, + `function f(_) { _.types.identifier("undefined"); }`, + `import * as t from "@babel/types"; t.identifier("not_undefined");`, + `path.scope.buildUndefinedNode();`, + ], + invalid: [ + { + code: `import { identifier } from "@babel/types"; identifier("undefined");`, + errors: [error], + }, + { + code: `import { Identifier } from "@babel/types"; Identifier("undefined");`, + errors: [error], + }, + { + code: `import * as t from "@babel/types"; t.identifier("undefined");`, + errors: [error], + }, + { + code: `import * as t from "@babel/types"; var { identifier } = t; identifier("undefined");`, + errors: [error], + }, + { + code: `import { identifier as id } from "@babel/types"; id("undefined");`, + errors: [error], + }, + { + code: `import * as babel from "@babel/core"; babel.types.identifier("undefined");`, + errors: [error], + }, + { + code: `import { types } from "@babel/core"; types.identifier("undefined");`, + errors: [error], + }, + { + code: `import { types as t } from "@babel/core"; t.identifier("undefined");`, + errors: [error], + }, + { + code: `export default function plugin(babel) { babel.types.identifier("undefined") }`, + errors: [error], + }, + { + code: `export default function plugin({ types }) { types.identifier("undefined") }`, + errors: [error], + }, + { + code: `export default function plugin({ types: t }) { t.identifier("undefined") }`, + errors: [error], + }, + { + code: `export default ({ types }) => { types.identifier("undefined") }`, + errors: [error], + }, + { + code: `module.exports = function plugin({ types }) { types.identifier("undefined") }`, + errors: [error], + }, + { + code: `import { declare } from "@babel/helper-plugin-utils"; declare(({ types }) => { types.identifier("undefined") });`, + errors: [error], + }, + ], +}); diff --git a/eslint/babel-eslint-plugin-development/tests/rules/plugin-name.js b/eslint/babel-eslint-plugin-development/tests/rules/plugin-name.js new file mode 100644 index 000000000000..670ced512279 --- /dev/null +++ b/eslint/babel-eslint-plugin-development/tests/rules/plugin-name.js @@ -0,0 +1,54 @@ +"use strict"; + +const rule = require("../../src/rules/plugin-name"); +const { RuleTester } = require("eslint"); + +const missingPluginError = "This file does not export a Babel plugin."; +const missingNameError = "This Babel plugin doesn't have a 'name' property."; + +const ruleTester = new RuleTester({ + parserOptions: { sourceType: "module" }, +}); + +ruleTester.run("plugin-name", rule, { + valid: [ + `export default function () { return { name: "test-plugin" } }`, + `import { declare } from "@babel/helper-plugin-utils"; declare(() => { return { name: "test-plugin" } })`, + `import { declare } from "@babel/helper-plugin-utils"; declare(() => ({ name: "test-plugin" }))`, + `module.exports = function () { return { name: "foo" }; }`, + ], + invalid: [ + { + code: `function fn() { return { name: "foo" } }`, + errors: [missingPluginError], + }, + { + code: `export function fn() { return { name: "foo" } }`, + errors: [missingPluginError], + }, + { + code: `(function fn() { return { name: "foo" } })`, + errors: [missingPluginError], + }, + { + code: `() => { return { name: "foo" } }`, + errors: [missingPluginError], + }, + { + code: `export default function fn() {}`, + errors: [missingPluginError], + }, + { + code: `export default function fn() { return {} }`, + errors: [missingNameError], + }, + { + code: `import { declare } from "@babel/helper-plugin-utils"; declare(() => ({}))`, + errors: [missingNameError], + }, + { + code: `module.exports = function () { return {} }`, + errors: [missingNameError], + }, + ], +}); diff --git a/eslint/babel-eslint-plugin/.gitignore b/eslint/babel-eslint-plugin/.gitignore new file mode 100644 index 000000000000..3c3629e647f5 --- /dev/null +++ b/eslint/babel-eslint-plugin/.gitignore @@ -0,0 +1 @@ +node_modules diff --git a/eslint/babel-eslint-plugin/.travis.yml b/eslint/babel-eslint-plugin/.travis.yml new file mode 100644 index 000000000000..068a0122c856 --- /dev/null +++ b/eslint/babel-eslint-plugin/.travis.yml @@ -0,0 +1,9 @@ +--- +git: + depth: 1 +sudo: false +language: node_js +node_js: + - 6 + - 8 + - 10 diff --git a/eslint/babel-eslint-plugin/LICENSE b/eslint/babel-eslint-plugin/LICENSE new file mode 100644 index 000000000000..3d0e2f3067b8 --- /dev/null +++ b/eslint/babel-eslint-plugin/LICENSE @@ -0,0 +1,23 @@ +Copyright (c) 2014-2015 Jason Quense +Original work by respective rule authors; copywrites noted in files. + +MIT License + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/eslint/babel-eslint-plugin/README.md b/eslint/babel-eslint-plugin/README.md new file mode 100644 index 000000000000..fba35aa4dc3f --- /dev/null +++ b/eslint/babel-eslint-plugin/README.md @@ -0,0 +1,67 @@ +# eslint-plugin-babel + +An `eslint` plugin companion to `babel-eslint`. `babel-eslint` does a great job at adapting `eslint` +for use with Babel, but it can't change the built in rules to support experimental features. +`eslint-plugin-babel` re-implements problematic rules so they do not give false positives or negatives. + +> Requires Node 4 or greater + +### Install + +```sh +npm install eslint-plugin-babel --save-dev +``` + +Load the plugin in your `.eslintrc` file: + +```json +{ + "plugins": [ + "babel" + ] +} +``` + +Finally enable all the rules you would like to use (remember to disable the +original ones as well!). + +```json +{ + "rules": { + "babel/new-cap": 1, + "babel/camelcase": 1, + "babel/no-invalid-this": 1, + "babel/object-curly-spacing": 1, + "babel/quotes": 1, + "babel/semi": 1, + "babel/no-unused-expressions": 1, + "babel/valid-typeof": 1 + } +} +``` +### Rules + +Each rule corresponds to a core `eslint` rule, and has the same options. + +🛠: means it's autofixable with `--fix`. + +- `babel/new-cap`: Ignores capitalized decorators (`@Decorator`) +- `babel/camelcase: doesn't complain about optional chaining (`var foo = bar?.a_b;`) +- `babel/no-invalid-this`: doesn't fail when inside class properties (`class A { a = this.b; }`) +- `babel/object-curly-spacing`: doesn't complain about `export x from "mod";` or `export * as x from "mod";` (🛠) +- `babel/quotes`: doesn't complain about JSX fragment shorthand syntax (`<>foo;`) +- `babel/semi`: doesn't fail when using `for await (let something of {})`. Includes class properties (🛠) +- `babel/no-unused-expressions`: doesn't fail when using `do` expressions or [optional chaining](https://github.com/tc39/proposal-optional-chaining) (`a?.b()`). +- `babel/valid-typeof`: doesn't complain when used with [BigInt](https://github.com/tc39/proposal-bigint) (`typeof BigInt(9007199254740991) === 'bigint'`). + +#### Deprecated + +| Rule | Notes | +|:---------------------------------|:-----------------------------------| +| `babel/generator-star-spacing` | Use [`generator-star-spacing`](http://eslint.org/docs/rules/generator-star-spacing) since eslint@3.6.0 | +| `babel/object-shorthand` | Use [`object-shorthand`](http://eslint.org/docs/rules/object-shorthand) since eslint@0.20.0 | +| `babel/arrow-parens` | Use [`arrow-parens`](http://eslint.org/docs/rules/arrow-parens) since eslint@3.10.0 | +| `babel/func-params-comma-dangle` | Use [`comma-dangle`](http://eslint.org/docs/rules/comma-dangle) since eslint@3.8.0 | +| `babel/array-bracket-spacing` | Use [`array-bracket-spacing`](http://eslint.org/docs/rules/array-bracket-spacing) since eslint@3.9.0 | +| `babel/flow-object-type` | Use [`flowtype/object-type-delimiter`](https://github.com/gajus/eslint-plugin-flowtype#eslint-plugin-flowtype-rules-object-type-delimiter) since eslint-plugin-flowtype@2.23.0 | +| `babel/no-await-in-loop` | Use [`no-await-in-loop`](http://eslint.org/docs/rules/no-await-in-loop) since eslint@3.12.0 | diff --git a/eslint/babel-eslint-plugin/index.js b/eslint/babel-eslint-plugin/index.js new file mode 100644 index 000000000000..eda05b28c808 --- /dev/null +++ b/eslint/babel-eslint-plugin/index.js @@ -0,0 +1,38 @@ +"use strict"; + +module.exports = { + rules: { + "array-bracket-spacing": require("./rules/array-bracket-spacing"), + "arrow-parens": require("./rules/arrow-parens"), + "flow-object-type": require("./rules/flow-object-type"), + "func-params-comma-dangle": require("./rules/func-params-comma-dangle"), + "generator-star-spacing": require("./rules/generator-star-spacing"), + "new-cap": require("./rules/new-cap"), + camelcase: require("./rules/camelcase"), + "no-await-in-loop": require("./rules/no-await-in-loop"), + "no-invalid-this": require("./rules/no-invalid-this"), + "no-unused-expressions": require("./rules/no-unused-expressions"), + "object-curly-spacing": require("./rules/object-curly-spacing"), + "object-shorthand": require("./rules/object-shorthand"), + quotes: require("./rules/quotes"), + semi: require("./rules/semi"), + "valid-typeof": require("./rules/valid-typeof"), + }, + rulesConfig: { + "array-bracket-spacing": 0, + "arrow-parens": 0, + camelcase: 0, + "flow-object-type": 0, + "func-params-comma-dangle": 0, + "generator-star-spacing": 0, + "new-cap": 0, + "no-await-in-loop": 0, + "no-invalid-this": 0, + "no-unused-expressions": 0, + "object-curly-spacing": 0, + "object-shorthand": 0, + quotes: 0, + semi: 0, + "valid-typeof": 0, + }, +}; diff --git a/eslint/babel-eslint-plugin/package.json b/eslint/babel-eslint-plugin/package.json new file mode 100644 index 000000000000..1d07201d0473 --- /dev/null +++ b/eslint/babel-eslint-plugin/package.json @@ -0,0 +1,41 @@ +{ + "name": "eslint-plugin-babel", + "version": "5.3.0", + "description": "an eslint rule plugin companion to babel-eslint", + "main": "index.js", + "scripts": { + "test": "mocha ./tests/rules/*.js" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/babel/eslint-plugin-babel.git" + }, + "keywords": [ + "babel", + "eslint", + "eslintplugin", + "eslint-plugin", + "babel-eslint" + ], + "author": "Jason Quense @monasticpanic", + "license": "MIT", + "engines": { + "node": ">=4" + }, + "bugs": { + "url": "https://github.com/babel/eslint-plugin-babel/issues" + }, + "homepage": "https://github.com/babel/eslint-plugin-babel#readme", + "peerDependencies": { + "eslint": ">=4.0.0" + }, + "dependencies": { + "eslint-rule-composer": "^0.3.0" + }, + "devDependencies": { + "babel-eslint": "^8.2.2", + "eslint": "^4.19.1", + "lodash.clonedeep": "^4.5.0", + "mocha": "^5.2.0" + } +} diff --git a/eslint/babel-eslint-plugin/rules/array-bracket-spacing.js b/eslint/babel-eslint-plugin/rules/array-bracket-spacing.js new file mode 100644 index 000000000000..e7eafff0d265 --- /dev/null +++ b/eslint/babel-eslint-plugin/rules/array-bracket-spacing.js @@ -0,0 +1,46 @@ +"use strict"; + +let isWarnedForDeprecation = false; +module.exports = { + meta: { + deprecated: true, + schema: [ + { + enum: ["always", "never"], + }, + { + type: "object", + properties: { + singleValue: { + type: "boolean", + }, + objectsInArrays: { + type: "boolean", + }, + arraysInArrays: { + type: "boolean", + }, + }, + additionalProperties: false, + }, + ], + }, + create: function() { + return { + Program: function() { + if ( + isWarnedForDeprecation || + /=-(f|-format)=/.test(process.argv.join("=")) + ) { + return; + } + + console.log( + "The babel/array-bracket-spacing rule is deprecated. Please " + + "use the built in array-bracket-spacing rule instead." + ); + isWarnedForDeprecation = true; + }, + }; + }, +}; diff --git a/eslint/babel-eslint-plugin/rules/arrow-parens.js b/eslint/babel-eslint-plugin/rules/arrow-parens.js new file mode 100644 index 000000000000..848045ff7bcb --- /dev/null +++ b/eslint/babel-eslint-plugin/rules/arrow-parens.js @@ -0,0 +1,31 @@ +"use strict"; + +let isWarnedForDeprecation = false; +module.exports = { + meta: { + deprecated: true, + schema: [ + { + enum: ["always", "as-needed"], + }, + ], + }, + create: function() { + return { + Program: function() { + if ( + isWarnedForDeprecation || + /=-(f|-format)=/.test(process.argv.join("=")) + ) { + return; + } + + console.log( + "The babel/arrow-parens rule is deprecated. Please " + + "use the built in arrow-parens rule instead." + ); + isWarnedForDeprecation = true; + }, + }; + }, +}; diff --git a/eslint/babel-eslint-plugin/rules/camelcase.js b/eslint/babel-eslint-plugin/rules/camelcase.js new file mode 100644 index 000000000000..6528b4a7f423 --- /dev/null +++ b/eslint/babel-eslint-plugin/rules/camelcase.js @@ -0,0 +1,231 @@ +/** + * @fileoverview Rule to flag non-camelcased identifiers + * @author Nicholas C. Zakas + */ + +"use strict"; + +//------------------------------------------------------------------------------ +// Rule Definition +//------------------------------------------------------------------------------ + +module.exports = { + meta: { + docs: { + description: "enforce camelcase naming convention", + category: "Stylistic Issues", + recommended: false, + url: "https://eslint.org/docs/rules/camelcase", + }, + + schema: [ + { + type: "object", + properties: { + ignoreDestructuring: { + type: "boolean", + }, + properties: { + enum: ["always", "never"], + }, + }, + additionalProperties: false, + }, + ], + + messages: { + notCamelCase: "Identifier '{{name}}' is not in camel case.", + }, + }, + + create(context) { + //-------------------------------------------------------------------------- + // Helpers + //-------------------------------------------------------------------------- + + // contains reported nodes to avoid reporting twice on destructuring with shorthand notation + const reported = []; + const ALLOWED_PARENT_TYPES = new Set(["CallExpression", "NewExpression"]); + const MEMBER_EXPRESSIONS = ["MemberExpression", "OptionalMemberExpression"]; + + /** + * Checks if expression is supported member expression. + * + * @param {string} expression - An expression to check. + * @returns {boolean} `true` if the expression type is supported + */ + function isMemberExpression(expression) { + return MEMBER_EXPRESSIONS.indexOf(expression) >= 0; + } + + /** + * Checks if a string contains an underscore and isn't all upper-case + * @param {string} name The string to check. + * @returns {boolean} if the string is underscored + * @private + */ + function isUnderscored(name) { + // if there's an underscore, it might be A_CONSTANT, which is okay + return name.indexOf("_") > -1 && name !== name.toUpperCase(); + } + + /** + * Checks if a parent of a node is an ObjectPattern. + * @param {ASTNode} node The node to check. + * @returns {boolean} if the node is inside an ObjectPattern + * @private + */ + function isInsideObjectPattern(node) { + let { parent } = node; + + while (parent) { + if (parent.type === "ObjectPattern") { + return true; + } + + parent = parent.parent; + } + + return false; + } + + /** + * Reports an AST node as a rule violation. + * @param {ASTNode} node The node to report. + * @returns {void} + * @private + */ + function report(node) { + if (reported.indexOf(node.parent) < 0) { + reported.push(node.parent); + context.report({ + node, + messageId: "notCamelCase", + data: { name: node.name }, + }); + } + } + + const options = context.options[0] || {}; + let properties = options.properties || ""; + const ignoreDestructuring = options.ignoreDestructuring || false; + + if (properties !== "always" && properties !== "never") { + properties = "always"; + } + + return { + Identifier(node) { + /* + * Leading and trailing underscores are commonly used to flag + * private/protected identifiers, strip them + */ + const name = node.name.replace(/^_+|_+$/g, ""), + effectiveParent = isMemberExpression(node.parent.type) + ? node.parent.parent + : node.parent; + + // MemberExpressions get special rules + if (isMemberExpression(node.parent.type)) { + // "never" check properties + if (properties === "never") { + return; + } + + // Always report underscored object names + if ( + node.parent.object.type === "Identifier" && + node.parent.object.name === node.name && + isUnderscored(name) + ) { + report(node); + + // Report AssignmentExpressions only if they are the left side of the assignment + } else if ( + effectiveParent.type === "AssignmentExpression" && + isUnderscored(name) && + (!isMemberExpression(effectiveParent.right.type) || + (isMemberExpression(effectiveParent.left.type) && + effectiveParent.left.property.name === node.name)) + ) { + report(node); + } + + /* + * Properties have their own rules, and + * AssignmentPattern nodes can be treated like Properties: + * e.g.: const { no_camelcased = false } = bar; + */ + } else if ( + node.parent.type === "Property" || + node.parent.type === "AssignmentPattern" + ) { + if ( + node.parent.parent && + node.parent.parent.type === "ObjectPattern" + ) { + const assignmentKeyEqualsValue = + node.parent.key.name === node.parent.value.name; + + // prevent checking righthand side of destructured object + if (node.parent.key === node && node.parent.value !== node) { + return; + } + + const valueIsUnderscored = + node.parent.value.name && isUnderscored(name); + + // ignore destructuring if the option is set, unless a new identifier is created + if ( + valueIsUnderscored && + !(assignmentKeyEqualsValue && ignoreDestructuring) + ) { + report(node); + } + } + + // "never" check properties or always ignore destructuring + if ( + properties === "never" || + (ignoreDestructuring && isInsideObjectPattern(node)) + ) { + return; + } + + // don't check right hand side of AssignmentExpression to prevent duplicate warnings + if ( + isUnderscored(name) && + !ALLOWED_PARENT_TYPES.has(effectiveParent.type) && + !(node.parent.right === node) + ) { + report(node); + } + + // Check if it's an import specifier + } else if ( + [ + "ImportSpecifier", + "ImportNamespaceSpecifier", + "ImportDefaultSpecifier", + ].indexOf(node.parent.type) >= 0 + ) { + // Report only if the local imported identifier is underscored + if ( + node.parent.local && + node.parent.local.name === node.name && + isUnderscored(name) + ) { + report(node); + } + + // Report anything that is underscored that isn't a CallExpression + } else if ( + isUnderscored(name) && + !ALLOWED_PARENT_TYPES.has(effectiveParent.type) + ) { + report(node); + } + }, + }; + }, +}; diff --git a/eslint/babel-eslint-plugin/rules/flow-object-type.js b/eslint/babel-eslint-plugin/rules/flow-object-type.js new file mode 100644 index 000000000000..4e45f8328b03 --- /dev/null +++ b/eslint/babel-eslint-plugin/rules/flow-object-type.js @@ -0,0 +1,34 @@ +"use strict"; + +let isWarnedForDeprecation = false; +module.exports = { + meta: { + deprecated: true, + schema: [ + { + enum: ["semicolon", "comma"], + }, + ], + }, + create: function() { + return { + Program: function() { + if ( + isWarnedForDeprecation || + /=-(f|-format)=/.test(process.argv.join("=")) + ) { + return; + } + + console.log( + "The babel/flow-object-type rule is deprecated. Please " + + "use the flowtype/object-type-delimiter rule instead.\n" + + // eslint-disable-next-line + "Check out https://github.com/gajus/eslint-plugin-flowtype#eslint-plugin-flowtype-rules-object-type-delimiter" + ); + + isWarnedForDeprecation = true; + }, + }; + }, +}; diff --git a/eslint/babel-eslint-plugin/rules/func-params-comma-dangle.js b/eslint/babel-eslint-plugin/rules/func-params-comma-dangle.js new file mode 100644 index 000000000000..40bd08b3bbd3 --- /dev/null +++ b/eslint/babel-eslint-plugin/rules/func-params-comma-dangle.js @@ -0,0 +1,31 @@ +"use strict"; + +let isWarnedForDeprecation = false; +module.exports = { + meta: { + deprecated: true, + schema: [ + { + enum: ["always", "always-multiline", "only-multiline", "never"], + }, + ], + }, + create: function() { + return { + Program: function() { + if ( + isWarnedForDeprecation || + /=-(f|-format)=/.test(process.argv.join("=")) + ) { + return; + } + + console.log( + "The babel/func-params-comma-dangle rule is deprecated. Please " + + "use the built in comma-dangle rule instead." + ); + isWarnedForDeprecation = true; + }, + }; + }, +}; diff --git a/eslint/babel-eslint-plugin/rules/generator-star-spacing.js b/eslint/babel-eslint-plugin/rules/generator-star-spacing.js new file mode 100644 index 000000000000..6befc25d04ea --- /dev/null +++ b/eslint/babel-eslint-plugin/rules/generator-star-spacing.js @@ -0,0 +1,43 @@ +"use strict"; + +let isWarnedForDeprecation = false; +module.exports = { + meta: { + deprecated: true, + schema: [ + { + oneOf: [ + { + enum: ["before", "after", "both", "neither"], + }, + { + type: "object", + properties: { + before: { type: "boolean" }, + after: { type: "boolean" }, + }, + additionalProperties: false, + }, + ], + }, + ], + }, + create: function() { + return { + Program: function() { + if ( + isWarnedForDeprecation || + /=-(f|-format)=/.test(process.argv.join("=")) + ) { + return; + } + + console.log( + "The babel/generator-star-spacing rule is deprecated. Please " + + "use the built in generator-star-spacing rule instead." + ); + isWarnedForDeprecation = true; + }, + }; + }, +}; diff --git a/eslint/babel-eslint-plugin/rules/new-cap.js b/eslint/babel-eslint-plugin/rules/new-cap.js new file mode 100644 index 000000000000..3e09bb25df4b --- /dev/null +++ b/eslint/babel-eslint-plugin/rules/new-cap.js @@ -0,0 +1,19 @@ +"use strict"; + +const ruleComposer = require("eslint-rule-composer"); +const eslint = require("eslint"); +const newCapRule = new eslint.Linter().getRules().get("new-cap"); + +/** + * Returns whether a node is under a decorator or not. + * @param {ASTNode} node CallExpression node + * @returns {Boolean} Returns true if the node is under a decorator. + */ +function isDecorator(node) { + return node.parent.type === "Decorator"; +} + +module.exports = ruleComposer.filterReports( + newCapRule, + problem => !isDecorator(problem.node) +); diff --git a/eslint/babel-eslint-plugin/rules/no-await-in-loop.js b/eslint/babel-eslint-plugin/rules/no-await-in-loop.js new file mode 100644 index 000000000000..a46a19da8876 --- /dev/null +++ b/eslint/babel-eslint-plugin/rules/no-await-in-loop.js @@ -0,0 +1,27 @@ +"use strict"; + +let isWarnedForDeprecation = false; +module.exports = { + meta: { + deprecated: true, + schema: [], + }, + create: function() { + return { + Program: function() { + if ( + isWarnedForDeprecation || + /=-(f|-format)=/.test(process.argv.join("=")) + ) { + return; + } + + console.log( + "The babel/no-await-in-loop rule is deprecated. Please " + + "use the built in no-await-in-loop rule instead." + ); + isWarnedForDeprecation = true; + }, + }; + }, +}; diff --git a/eslint/babel-eslint-plugin/rules/no-invalid-this.js b/eslint/babel-eslint-plugin/rules/no-invalid-this.js new file mode 100644 index 000000000000..101ec655a6d8 --- /dev/null +++ b/eslint/babel-eslint-plugin/rules/no-invalid-this.js @@ -0,0 +1,21 @@ +"use strict"; + +const ruleComposer = require("eslint-rule-composer"); +const eslint = require("eslint"); +const noInvalidThisRule = new eslint.Linter().getRules().get("no-invalid-this"); + +module.exports = ruleComposer.filterReports(noInvalidThisRule, problem => { + let inClassProperty = false; + let node = problem.node; + + while (node) { + if (node.type === "ClassProperty" || node.type === "ClassPrivateProperty") { + inClassProperty = true; + return; + } + + node = node.parent; + } + + return !inClassProperty; +}); diff --git a/eslint/babel-eslint-plugin/rules/no-unused-expressions.js b/eslint/babel-eslint-plugin/rules/no-unused-expressions.js new file mode 100644 index 000000000000..81c779d3c78e --- /dev/null +++ b/eslint/babel-eslint-plugin/rules/no-unused-expressions.js @@ -0,0 +1,64 @@ +"use strict"; + +const ruleComposer = require("eslint-rule-composer"); +const eslint = require("eslint"); +const rule = new eslint.Linter().getRules().get("no-unused-expressions"); + +/** + * @param {ASTNode} node - any node + * @returns {boolean} whether the given node is either an IfStatement or an + * ExpressionStatement and is the last node in the body of a BlockStatement + */ +function isFinalStatementInBlockStatement(node) { + const parent = node.parent; + return ( + /^(?:If|Expression)Statement$/.test(node.type) && + parent.type === "BlockStatement" && + parent.body[parent.body.length - 1] === node + ); +} + +/** + * @param {ASTNode} node - any node + * @returns {boolean} whether the given node represents an unbroken chain of + * tail ExpressionStatements and IfStatements within a DoExpression + */ +function isInDoStatement(node) { + if (!node) return false; + + if (node.type === "DoExpression") return true; + + // this is an `else if` + if ( + node.type === "IfStatement" && + node.parent && + node.parent.type === "IfStatement" + ) { + return isInDoStatement(node.parent); + } + + if (isFinalStatementInBlockStatement(node)) { + return isInDoStatement(node.parent.parent); + } + + return false; +} + +/** + * @param {ASTNode} node - any node + * @returns {boolean} whether the given node is an optional call expression, + * see https://github.com/tc39/proposal-optional-chaining + */ +function isOptionalCallExpression(node) { + return ( + !!node && + node.type === "ExpressionStatement" && + node.expression.type === "OptionalCallExpression" + ); +} + +module.exports = ruleComposer.filterReports( + rule, + problem => + !isInDoStatement(problem.node) && !isOptionalCallExpression(problem.node) +); diff --git a/eslint/babel-eslint-plugin/rules/object-curly-spacing.js b/eslint/babel-eslint-plugin/rules/object-curly-spacing.js new file mode 100644 index 000000000000..d3ec19620158 --- /dev/null +++ b/eslint/babel-eslint-plugin/rules/object-curly-spacing.js @@ -0,0 +1,27 @@ +"use strict"; + +const ruleComposer = require("eslint-rule-composer"); +const eslint = require("eslint"); +const objectCurlySpacingRule = new eslint.Linter() + .getRules() + .get("object-curly-spacing"); + +module.exports = ruleComposer.filterReports( + objectCurlySpacingRule, + (problem, metadata) => { + const node = problem.node; + + // Allow `exportNamespaceFrom` and `exportDefaultFrom` syntax: + // export * as x from '...'; + // export x from '...'; + if ( + node.type === "ExportNamedDeclaration" && + node.specifiers.length > 0 && + metadata.sourceCode.getTokenBefore(node.specifiers[0]).value === "export" + ) { + return false; + } + + return true; + } +); diff --git a/eslint/babel-eslint-plugin/rules/object-shorthand.js b/eslint/babel-eslint-plugin/rules/object-shorthand.js new file mode 100644 index 000000000000..21f41e639e79 --- /dev/null +++ b/eslint/babel-eslint-plugin/rules/object-shorthand.js @@ -0,0 +1,31 @@ +"use strict"; + +let isWarnedForDeprecation = false; +module.exports = { + meta: { + deprecated: true, + schema: [ + { + enum: ["always", "methods", "properties", "never"], + }, + ], + }, + create: function() { + return { + Program: function() { + if ( + isWarnedForDeprecation || + /=-(f|-format)=/.test(process.argv.join("=")) + ) { + return; + } + + console.log( + "The babel/object-shorthand rule is deprecated. Please " + + "use the built in object-shorthand rule instead." + ); + isWarnedForDeprecation = true; + }, + }; + }, +}; diff --git a/eslint/babel-eslint-plugin/rules/quotes.js b/eslint/babel-eslint-plugin/rules/quotes.js new file mode 100644 index 000000000000..a4bb46df453f --- /dev/null +++ b/eslint/babel-eslint-plugin/rules/quotes.js @@ -0,0 +1,15 @@ +"use strict"; + +const ruleComposer = require("eslint-rule-composer"); +const eslint = require("eslint"); +const quotesRule = new eslint.Linter().getRules().get("quotes"); + +module.exports = ruleComposer.filterReports(quotesRule, problem => { + // Workaround for JSX fragment syntax until + // https://github.com/eslint/eslint/issues/9662 + if (problem.node.parent.type === "JSXFragment") { + return false; + } + + return true; +}); diff --git a/eslint/babel-eslint-plugin/rules/semi.js b/eslint/babel-eslint-plugin/rules/semi.js new file mode 100644 index 000000000000..8888bf4cacc8 --- /dev/null +++ b/eslint/babel-eslint-plugin/rules/semi.js @@ -0,0 +1,123 @@ +"use strict"; + +const ruleComposer = require("eslint-rule-composer"); +const eslint = require("eslint"); +const semiRule = new eslint.Linter().getRules().get("semi"); + +const OPT_OUT_PATTERN = /^[-[(/+`]/; // One of [(/+-` + +const isSemicolon = token => token.type === "Punctuator" && token.value === ";"; + +const isUnnecessarySemicolon = (context, lastToken) => { + if (!isSemicolon(lastToken)) { + return false; + } + + const nextToken = context.getSourceCode().getTokenAfter(lastToken); + + if (!nextToken) { + return true; + } + + const lastTokenLine = lastToken.loc.end.line; + const nextTokenLine = nextToken.loc.start.line; + const isOptOutToken = + OPT_OUT_PATTERN.test(nextToken.value) && + nextToken.value !== "++" && + nextToken.value !== "--"; + const isDivider = nextToken.value === "}" || nextToken.value === ";"; + + return (lastTokenLine !== nextTokenLine && !isOptOutToken) || isDivider; +}; + +const isOneLinerBlock = (context, node) => { + const nextToken = context.getSourceCode().getTokenAfter(node); + + if (!nextToken || nextToken.value !== "}") { + return false; + } + + const parent = node.parent; + + return ( + parent && + parent.type === "BlockStatement" && + parent.loc.start.line === parent.loc.end.line + ); +}; + +const report = (context, node, missing) => { + const lastToken = context.getSourceCode().getLastToken(node); + + let message, + fix, + loc = lastToken.loc; + + if (!missing) { + message = "Missing semicolon."; + loc = loc.end; + fix = function(fixer) { + return fixer.insertTextAfter(lastToken, ";"); + }; + } else { + message = "Extra semicolon."; + loc = loc.start; + fix = function(fixer) { + return fixer.remove(lastToken); + }; + } + + context.report({ + node, + loc, + message, + fix, + }); +}; + +const semiRuleWithClassProperty = ruleComposer.joinReports([ + semiRule, + context => ({ + ClassProperty(node) { + const options = context.options[1]; + const exceptOneLine = options && options.omitLastInOneLineBlock === true; + + const sourceCode = context.getSourceCode(); + const lastToken = sourceCode.getLastToken(node); + + if (context.options[0] === "never") { + if (isUnnecessarySemicolon(context, lastToken)) { + report(context, node, true); + } + } else { + if (!isSemicolon(lastToken)) { + if (!exceptOneLine || !isOneLinerBlock(context, node)) { + report(context, node); + } + } else { + if (exceptOneLine && isOneLinerBlock(context, node)) { + report(context, node, true); + } + } + } + }, + }), +]); + +module.exports = ruleComposer.filterReports( + semiRuleWithClassProperty, + problem => { + const node = problem.node; + + // Handle async iterator: + // for await (let something of {}) + if ( + node.type === "VariableDeclaration" && + node.parent.type === "ForAwaitStatement" + ) { + return false; + } + + return true; + } +); diff --git a/eslint/babel-eslint-plugin/rules/valid-typeof.js b/eslint/babel-eslint-plugin/rules/valid-typeof.js new file mode 100644 index 000000000000..aa8321ec98f9 --- /dev/null +++ b/eslint/babel-eslint-plugin/rules/valid-typeof.js @@ -0,0 +1,9 @@ +"use strict"; + +const ruleComposer = require("eslint-rule-composer"); +const eslint = require("eslint"); +const validTypeOf = new eslint.Linter().getRules().get("valid-typeof"); + +module.exports = ruleComposer.filterReports(validTypeOf, problem => { + return problem.node.value !== "bigint"; +}); diff --git a/eslint/babel-eslint-plugin/tests/RuleTester.js b/eslint/babel-eslint-plugin/tests/RuleTester.js new file mode 100644 index 000000000000..e183277bfb40 --- /dev/null +++ b/eslint/babel-eslint-plugin/tests/RuleTester.js @@ -0,0 +1,7 @@ +var RuleTester = require("eslint").RuleTester; + +RuleTester.setDefaultConfig({ + parser: 'babel-eslint' +}); + +module.exports = RuleTester; diff --git a/eslint/babel-eslint-plugin/tests/rules/camelcase.js b/eslint/babel-eslint-plugin/tests/rules/camelcase.js new file mode 100644 index 000000000000..0344018515b8 --- /dev/null +++ b/eslint/babel-eslint-plugin/tests/rules/camelcase.js @@ -0,0 +1,568 @@ +/** + * @fileoverview Tests for camelcase rule. + * @author Nicholas C. Zakas + */ + +"use strict"; + +//------------------------------------------------------------------------------ +// Requirements +//------------------------------------------------------------------------------ + +const rule = require("../../rules/camelcase"), + RuleTester = require("../RuleTester"); + +//------------------------------------------------------------------------------ +// Tests +//------------------------------------------------------------------------------ + +const ruleTester = new RuleTester(); + +ruleTester.run("camelcase", rule, { + valid: [ + // Original test cases. + "firstName = \"Nicholas\"", + "FIRST_NAME = \"Nicholas\"", + "__myPrivateVariable = \"Patrick\"", + "myPrivateVariable_ = \"Patrick\"", + "function doSomething(){}", + "do_something()", + "new do_something", + "new do_something()", + "foo.do_something()", + "var foo = bar.baz_boom;", + "var foo = bar.baz_boom.something;", + "foo.boom_pow.qux = bar.baz_boom.something;", + "if (bar.baz_boom) {}", + "var obj = { key: foo.bar_baz };", + "var arr = [foo.bar_baz];", + "[foo.bar_baz]", + "var arr = [foo.bar_baz.qux];", + "[foo.bar_baz.nesting]", + "if (foo.bar_baz === boom.bam_pow) { [foo.baz_boom] }", + { + code: "var o = {key: 1}", + options: [{ properties: "always" }] + }, + { + code: "var o = {_leading: 1}", + options: [{ properties: "always" }] + }, + { + code: "var o = {trailing_: 1}", + options: [{ properties: "always" }] + }, + { + code: "var o = {bar_baz: 1}", + options: [{ properties: "never" }] + }, + { + code: "var o = {_leading: 1}", + options: [{ properties: "never" }] + }, + { + code: "var o = {trailing_: 1}", + options: [{ properties: "never" }] + }, + { + code: "obj.a_b = 2;", + options: [{ properties: "never" }] + }, + { + code: "obj._a = 2;", + options: [{ properties: "always" }] + }, + { + code: "obj.a_ = 2;", + options: [{ properties: "always" }] + }, + { + code: "obj._a = 2;", + options: [{ properties: "never" }] + }, + { + code: "obj.a_ = 2;", + options: [{ properties: "never" }] + }, + { + code: "var obj = {\n a_a: 1 \n};\n obj.a_b = 2;", + options: [{ properties: "never" }] + }, + { + code: "obj.foo_bar = function(){};", + options: [{ properties: "never" }] + }, + { + code: "var { category_id } = query;", + options: [{ ignoreDestructuring: true }], + parserOptions: { ecmaVersion: 6 } + }, + { + code: "var { category_id: category_id } = query;", + options: [{ ignoreDestructuring: true }], + parserOptions: { ecmaVersion: 6 } + }, + { + code: "var { category_id = 1 } = query;", + options: [{ ignoreDestructuring: true }], + parserOptions: { ecmaVersion: 6 }, + + }, + { + code: "var { category_id: category } = query;", + parserOptions: { ecmaVersion: 6 } + }, + { + code: "var { _leading } = query;", + parserOptions: { ecmaVersion: 6 } + }, + { + code: "var { trailing_ } = query;", + parserOptions: { ecmaVersion: 6 } + }, + { + code: "import { camelCased } from \"external module\";", + parserOptions: { ecmaVersion: 6, sourceType: "module" } + }, + { + code: "import { _leading } from \"external module\";", + parserOptions: { ecmaVersion: 6, sourceType: "module" } + }, + { + code: "import { trailing_ } from \"external module\";", + parserOptions: { ecmaVersion: 6, sourceType: "module" } + }, + { + code: "import { no_camelcased as camelCased } from \"external-module\";", + parserOptions: { ecmaVersion: 6, sourceType: "module" } + }, + { + code: "import { no_camelcased as _leading } from \"external-module\";", + parserOptions: { ecmaVersion: 6, sourceType: "module" } + }, + { + code: "import { no_camelcased as trailing_ } from \"external-module\";", + parserOptions: { ecmaVersion: 6, sourceType: "module" } + }, + { + code: "import { no_camelcased as camelCased, anoterCamelCased } from \"external-module\";", + parserOptions: { ecmaVersion: 6, sourceType: "module" } + }, + { + code: "function foo({ no_camelcased: camelCased }) {};", + parserOptions: { ecmaVersion: 6 } + }, + { + code: "function foo({ no_camelcased: _leading }) {};", + parserOptions: { ecmaVersion: 6 } + }, + { + code: "function foo({ no_camelcased: trailing_ }) {};", + parserOptions: { ecmaVersion: 6 } + }, + { + code: "function foo({ camelCased = 'default value' }) {};", + parserOptions: { ecmaVersion: 6 } + }, + { + code: "function foo({ _leading = 'default value' }) {};", + parserOptions: { ecmaVersion: 6 } + }, + { + code: "function foo({ trailing_ = 'default value' }) {};", + parserOptions: { ecmaVersion: 6 } + }, + { + code: "function foo({ camelCased }) {};", + parserOptions: { ecmaVersion: 6 } + }, + { + code: "function foo({ _leading }) {}", + parserOptions: { ecmaVersion: 6 } + }, + { + code: "function foo({ trailing_ }) {}", + parserOptions: { ecmaVersion: 6 } + }, + + // Babel-specific test cases + { + code: "var foo = bar?.a_b;", + options: [{ properties: "never" }] + }, + ], + invalid: [ + { + code: "first_name = \"Nicholas\"", + errors: [ + { + messageId: "notCamelCase", + data: { name: "first_name" }, + type: "Identifier" + } + ] + }, + { + code: "__private_first_name = \"Patrick\"", + errors: [ + { + messageId: "notCamelCase", + data: { name: "__private_first_name" }, + type: "Identifier" + } + ] + }, + { + code: "function foo_bar(){}", + errors: [ + { + messageId: "notCamelCase", + data: { name: "foo_bar" }, + type: "Identifier" + } + ] + }, + { + code: "obj.foo_bar = function(){};", + errors: [ + { + messageId: "notCamelCase", + data: { name: "foo_bar" }, + type: "Identifier" + } + ] + }, + { + code: "bar_baz.foo = function(){};", + errors: [ + { + messageId: "notCamelCase", + data: { name: "bar_baz" }, + type: "Identifier" + } + ] + }, + { + code: "[foo_bar.baz]", + errors: [ + { + messageId: "notCamelCase", + data: { name: "foo_bar" }, + type: "Identifier" + } + ] + }, + { + code: "if (foo.bar_baz === boom.bam_pow) { [foo_bar.baz] }", + errors: [ + { + messageId: "notCamelCase", + data: { name: "foo_bar" }, + type: "Identifier" + } + ] + }, + { + code: "foo.bar_baz = boom.bam_pow", + errors: [ + { + messageId: "notCamelCase", + data: { name: "bar_baz" }, + type: "Identifier" + } + ] + }, + { + code: "var foo = { bar_baz: boom.bam_pow }", + errors: [ + { + messageId: "notCamelCase", + data: { name: "bar_baz" }, + type: "Identifier" + } + ] + }, + { + code: "foo.qux.boom_pow = { bar: boom.bam_pow }", + errors: [ + { + messageId: "notCamelCase", + data: { name: "boom_pow" }, + type: "Identifier" + } + ] + }, + { + code: "var o = {bar_baz: 1}", + options: [{ properties: "always" }], + errors: [ + { + messageId: "notCamelCase", + data: { name: "bar_baz" }, + type: "Identifier" + } + ] + }, + { + code: "obj.a_b = 2;", + options: [{ properties: "always" }], + errors: [ + { + messageId: "notCamelCase", + data: { name: "a_b" }, + type: "Identifier" + } + ] + }, + { + code: "var { category_id: category_alias } = query;", + parserOptions: { ecmaVersion: 6 }, + errors: [ + { + messageId: "notCamelCase", + data: { name: "category_alias" }, + type: "Identifier" + } + ] + }, + { + code: "var { category_id: category_alias } = query;", + options: [{ ignoreDestructuring: true }], + parserOptions: { ecmaVersion: 6 }, + errors: [ + { + messageId: "notCamelCase", + data: { name: "category_alias" }, + type: "Identifier" + } + ] + }, + { + code: "var { category_id: categoryId, ...other_props } = query;", + options: [{ ignoreDestructuring: true }], + parserOptions: { ecmaVersion: 2018 }, + errors: [ + { + messageId: "notCamelCase", + data: { name: "other_props" }, + type: "Identifier" + } + ] + }, + { + code: "var { category_id } = query;", + parserOptions: { ecmaVersion: 6 }, + errors: [ + { + messageId: "notCamelCase", + data: { name: "category_id" }, + type: "Identifier" + } + ] + }, + { + code: "var { category_id: category_id } = query;", + parserOptions: { ecmaVersion: 6 }, + errors: [ + { + messageId: "notCamelCase", + data: { name: "category_id" }, + type: "Identifier" + } + ] + }, + { + code: "var { category_id = 1 } = query;", + parserOptions: { ecmaVersion: 6 }, + errors: [ + { + message: "Identifier 'category_id' is not in camel case.", + type: "Identifier" + } + ] + }, + { + code: "import no_camelcased from \"external-module\";", + parserOptions: { ecmaVersion: 6, sourceType: "module" }, + errors: [ + { + messageId: "notCamelCase", + data: { name: "no_camelcased" }, + type: "Identifier" + } + ] + }, + { + code: "import * as no_camelcased from \"external-module\";", + parserOptions: { ecmaVersion: 6, sourceType: "module" }, + errors: [ + { + messageId: "notCamelCase", + data: { name: "no_camelcased" }, + type: "Identifier" + } + ] + }, + { + code: "import { no_camelcased } from \"external-module\";", + parserOptions: { ecmaVersion: 6, sourceType: "module" }, + errors: [ + { + messageId: "notCamelCase", + data: { name: "no_camelcased" }, + type: "Identifier" + } + ] + }, + { + code: "import { no_camelcased as no_camel_cased } from \"external module\";", + parserOptions: { ecmaVersion: 6, sourceType: "module" }, + errors: [ + { + messageId: "notCamelCase", + data: { name: "no_camel_cased" }, + type: "Identifier" + } + ] + }, + { + code: "import { camelCased as no_camel_cased } from \"external module\";", + parserOptions: { ecmaVersion: 6, sourceType: "module" }, + errors: [ + { + messageId: "notCamelCase", + data: { name: "no_camel_cased" }, + type: "Identifier" + } + ] + }, + { + code: "import { camelCased, no_camelcased } from \"external-module\";", + parserOptions: { ecmaVersion: 6, sourceType: "module" }, + errors: [ + { + messageId: "notCamelCase", + data: { name: "no_camelcased" }, + type: "Identifier" + } + ] + }, + { + code: "import { no_camelcased as camelCased, another_no_camelcased } from \"external-module\";", + parserOptions: { ecmaVersion: 6, sourceType: "module" }, + errors: [ + { + messageId: "notCamelCase", + data: { name: "another_no_camelcased" }, + type: "Identifier" + } + ] + }, + { + code: "import camelCased, { no_camelcased } from \"external-module\";", + parserOptions: { ecmaVersion: 6, sourceType: "module" }, + errors: [ + { + messageId: "notCamelCase", + data: { name: "no_camelcased" }, + type: "Identifier" + } + ] + }, + { + code: "import no_camelcased, { another_no_camelcased as camelCased } from \"external-module\";", + parserOptions: { ecmaVersion: 6, sourceType: "module" }, + errors: [ + { + messageId: "notCamelCase", + data: { name: "no_camelcased" }, + type: "Identifier" + } + ] + }, + { + code: "function foo({ no_camelcased }) {};", + parserOptions: { ecmaVersion: 6 }, + errors: [ + { + message: "Identifier 'no_camelcased' is not in camel case.", + type: "Identifier" + } + ] + }, + { + code: "function foo({ no_camelcased = 'default value' }) {};", + parserOptions: { ecmaVersion: 6 }, + errors: [ + { + message: "Identifier 'no_camelcased' is not in camel case.", + type: "Identifier" + } + ] + }, + { + code: "const no_camelcased = 0; function foo({ camelcased_value = no_camelcased}) {}", + parserOptions: { ecmaVersion: 6 }, + errors: [ + { + message: "Identifier 'no_camelcased' is not in camel case.", + type: "Identifier" + }, + { + message: "Identifier 'camelcased_value' is not in camel case.", + type: "Identifier" + } + ] + }, + { + code: "const { bar: no_camelcased } = foo;", + parserOptions: { ecmaVersion: 6 }, + errors: [ + { + message: "Identifier 'no_camelcased' is not in camel case.", + type: "Identifier" + } + ] + }, + { + code: "function foo({ value_1: my_default }) {}", + parserOptions: { ecmaVersion: 6 }, + errors: [ + { + message: "Identifier 'my_default' is not in camel case.", + type: "Identifier" + } + ] + }, + { + code: "function foo({ isCamelcased: no_camelcased }) {};", + parserOptions: { ecmaVersion: 6 }, + errors: [ + { + message: "Identifier 'no_camelcased' is not in camel case.", + type: "Identifier" + } + ] + }, + { + code: "var { foo: bar_baz = 1 } = quz;", + parserOptions: { ecmaVersion: 6 }, + errors: [ + { + message: "Identifier 'bar_baz' is not in camel case.", + type: "Identifier" + } + ] + }, + { + code: "const { no_camelcased = false } = bar;", + parserOptions: { ecmaVersion: 6 }, + errors: [ + { + message: "Identifier 'no_camelcased' is not in camel case.", + type: "Identifier" + } + ] + } + ] +}); diff --git a/eslint/babel-eslint-plugin/tests/rules/new-cap.js b/eslint/babel-eslint-plugin/tests/rules/new-cap.js new file mode 100644 index 000000000000..c37f2e9f06a9 --- /dev/null +++ b/eslint/babel-eslint-plugin/tests/rules/new-cap.js @@ -0,0 +1,157 @@ +/** + * @fileoverview Tests for new-cap rule. + * @author Nicholas C. Zakas + */ + +var rule = require('../../rules/new-cap'), + RuleTester = require('../RuleTester'); + +var ruleTester = new RuleTester(); +ruleTester.run('babel/new-cap', rule, { + valid: [ + // Original test cases. + "var x = new Constructor();", + "var x = new a.b.Constructor();", + "var x = new a.b['Constructor']();", + "var x = new a.b[Constructor]();", + "var x = new a.b[constructor]();", + "var x = new function(){};", + "var x = new _;", + "var x = new $;", + "var x = new Σ;", + "var x = new _x;", + "var x = new $x;", + "var x = new this;", + "var x = Array(42)", + "var x = Boolean(42)", + "var x = Date(42)", + "var x = Date.UTC(2000, 0)", + "var x = Error('error')", + "var x = Function('return 0')", + "var x = Number(42)", + "var x = Object(null)", + "var x = RegExp(42)", + "var x = String(42)", + "var x = Symbol('symbol')", + "var x = _();", + "var x = $();", + { code: "var x = Foo(42)", options: [{ capIsNew: false }] }, + { code: "var x = bar.Foo(42)", options: [{ capIsNew: false }] }, + { code: "var x = Foo.bar(42)", options: [{ capIsNew: false }] }, + "var x = bar[Foo](42)", + { code: "var x = bar['Foo'](42)", options: [{ capIsNew: false }] }, + "var x = Foo.bar(42)", + { code: "var x = new foo(42)", options: [{ newIsCap: false }] }, + "var o = { 1: function() {} }; o[1]();", + "var o = { 1: function() {} }; new o[1]();", + { code: "var x = Foo(42);", options: [{ capIsNew: true, capIsNewExceptions: ["Foo"] }] }, + { code: "var x = Foo(42);", options: [{ capIsNewExceptionPattern: "^Foo" }] }, + { code: "var x = new foo(42);", options: [{ newIsCap: true, newIsCapExceptions: ["foo"] }] }, + { code: "var x = new foo(42);", options: [{ newIsCapExceptionPattern: "^foo" }] }, + { code: "var x = Object(42);", options: [{ capIsNewExceptions: ["Foo"] }] }, + + { code: "var x = Foo.Bar(42);", options: [{ capIsNewExceptions: ["Bar"] }] }, + { code: "var x = Foo.Bar(42);", options: [{ capIsNewExceptions: ["Foo.Bar"] }] }, + + { code: "var x = Foo.Bar(42);", options: [{ capIsNewExceptionPattern: "^Foo\\.." }] }, + { code: "var x = new foo.bar(42);", options: [{ newIsCapExceptions: ["bar"] }] }, + { code: "var x = new foo.bar(42);", options: [{ newIsCapExceptions: ["foo.bar"] }] }, + + { code: "var x = new foo.bar(42);", options: [{ newIsCapExceptionPattern: "^foo\\.." }] }, + { code: "var x = new foo.bar(42);", options: [{ properties: false }] }, + { code: "var x = Foo.bar(42);", options: [{ properties: false }] }, + { code: "var x = foo.Bar(42);", options: [{ capIsNew: false, properties: false }] }, + + // Babel-specific test cases. + { code: "@MyDecorator(123) class MyClass{}", parser: "babel-eslint" }, + ], + invalid: [ + { code: "var x = new c();", errors: [{ message: "A constructor name should not start with a lowercase letter.", type: "NewExpression" }] }, + { code: "var x = new φ;", errors: [{ message: "A constructor name should not start with a lowercase letter.", type: "NewExpression" }] }, + { code: "var x = new a.b.c;", errors: [{ message: "A constructor name should not start with a lowercase letter.", type: "NewExpression" }] }, + { code: "var x = new a.b['c'];", errors: [{ message: "A constructor name should not start with a lowercase letter.", type: "NewExpression" }] }, + { code: "var b = Foo();", errors: [{ message: "A function with a name starting with an uppercase letter should only be used as a constructor.", type: "CallExpression" }] }, + { code: "var b = a.Foo();", errors: [{ message: "A function with a name starting with an uppercase letter should only be used as a constructor.", type: "CallExpression" }] }, + { code: "var b = a['Foo']();", errors: [{ message: "A function with a name starting with an uppercase letter should only be used as a constructor.", type: "CallExpression" }] }, + { code: "var b = a.Date.UTC();", errors: [{ message: "A function with a name starting with an uppercase letter should only be used as a constructor.", type: "CallExpression" }] }, + { code: "var b = UTC();", errors: [{ message: "A function with a name starting with an uppercase letter should only be used as a constructor.", type: "CallExpression" }] }, + { + code: "var a = B.C();", + errors: [ + { + message: "A function with a name starting with an uppercase letter should only be used as a constructor.", + type: "CallExpression", + line: 1, + column: 11 + } + ] + }, + { + code: "var a = B\n.C();", + errors: [ + { + message: "A function with a name starting with an uppercase letter should only be used as a constructor.", + type: "CallExpression", + line: 2, + column: 2 + } + ] + }, + { + code: "var a = new B.c();", + errors: [ + { + message: "A constructor name should not start with a lowercase letter.", + type: "NewExpression", + line: 1, + column: 15 + } + ] + }, + { + code: "var a = new B.\nc();", + errors: [ + { + message: "A constructor name should not start with a lowercase letter.", + type: "NewExpression", + line: 2, + column: 1 + } + ] + }, + { + code: "var a = new c();", + errors: [ + { + message: "A constructor name should not start with a lowercase letter.", + type: "NewExpression", + line: 1, + column: 13 + } + ] + }, + + { + code: "var x = Foo.Bar(42);", + options: [{ capIsNewExceptions: ["Foo"] }], + errors: [{ type: "CallExpression", message: "A function with a name starting with an uppercase letter should only be used as a constructor." }] + }, + { + code: "var x = Bar.Foo(42);", + + options: [{ capIsNewExceptionPattern: "^Foo\\.." }], + errors: [{ type: "CallExpression", message: "A function with a name starting with an uppercase letter should only be used as a constructor." }] + }, + { + code: "var x = new foo.bar(42);", + options: [{ newIsCapExceptions: ["foo"] }], + errors: [{ type: "NewExpression", message: "A constructor name should not start with a lowercase letter." }] + }, + { + code: "var x = new bar.foo(42);", + + options: [{ newIsCapExceptionPattern: "^foo\\.." }], + errors: [{ type: "NewExpression", message: "A constructor name should not start with a lowercase letter." }] + } + ] +}); diff --git a/eslint/babel-eslint-plugin/tests/rules/no-invalid-this.js b/eslint/babel-eslint-plugin/tests/rules/no-invalid-this.js new file mode 100644 index 000000000000..e28c77aa5e07 --- /dev/null +++ b/eslint/babel-eslint-plugin/tests/rules/no-invalid-this.js @@ -0,0 +1,627 @@ +/** + * @fileoverview Tests for no-invalid-this rule. + * @author Toru Nagashima + */ + +"use strict"; + +//------------------------------------------------------------------------------ +// Requirements +//------------------------------------------------------------------------------ + +const cloneDeep = require("lodash.clonedeep"); +const rule = require("../../rules/no-invalid-this"); +const RuleTester = require("../RuleTester"); + +//------------------------------------------------------------------------------ +// Helpers +//------------------------------------------------------------------------------ + +/** + * A constant value for non strict mode environment. + * @returns {void} + */ +function NORMAL(pattern) { + pattern.parserOptions.sourceType = "script"; +} + +/** + * A constant value for strict mode environment. + * This modifies pattern object to make strict mode. + * @param {Object} pattern - A pattern object to modify. + * @returns {void} + */ +function USE_STRICT(pattern) { + pattern.code = "\"use strict\"; " + pattern.code; +} + +/** + * A constant value for implied strict mode. + * This modifies pattern object to impose strict mode. + * @param {Object} pattern - A pattern object to modify. + * @returns {void} + */ +function IMPLIED_STRICT(pattern) { + pattern.code = "/* implied strict mode */ " + pattern.code; + pattern.parserOptions.ecmaFeatures = pattern.parserOptions.ecmaFeatures || {}; + pattern.parserOptions.ecmaFeatures.impliedStrict = true; +} + +/** + * A constant value for modules environment. + * This modifies pattern object to make modules. + * @param {Object} pattern - A pattern object to modify. + * @returns {void} + */ +function MODULES(pattern) { + pattern.code = "/* modules */ " + pattern.code; +} + +/** + * Extracts patterns each condition for a specified type. The type is `valid` or `invalid`. + * @param {Object[]} patterns - Original patterns. + * @param {string} type - One of `"valid"` or `"invalid"`. + * @returns {Object[]} Test patterns. + */ +function extractPatterns(patterns, type) { + + // Clone and apply the pattern environment. + const patternsList = patterns.map(function(pattern) { + return pattern[type].map(function(applyCondition) { + const thisPattern = cloneDeep(pattern); + + applyCondition(thisPattern); + + if (type === "valid") { + thisPattern.errors = []; + } else { + thisPattern.code += " /* should error */"; + } + + delete thisPattern.invalid; + delete thisPattern.valid; + + return thisPattern; + }); + }); + + // Flatten. + return Array.prototype.concat.apply([], patternsList); +} + + +//------------------------------------------------------------------------------ +// Tests +//------------------------------------------------------------------------------ + +const errors = [ + {message: "Unexpected 'this'.", type: "ThisExpression"}, + {message: "Unexpected 'this'.", type: "ThisExpression"} +]; + +const patterns = [ + + // Global. + { + code: "console.log(this); z(x => console.log(x, this));", + parserOptions: { ecmaVersion: 6 }, + errors, + valid: [NORMAL], + invalid: [USE_STRICT, IMPLIED_STRICT, MODULES] + }, + { + code: "console.log(this); z(x => console.log(x, this));", + parserOptions: { + ecmaVersion: 6, + ecmaFeatures: {globalReturn: true} + }, + errors, + valid: [NORMAL], + invalid: [USE_STRICT, IMPLIED_STRICT, MODULES] + }, + + // IIFE. + { + code: "(function() { console.log(this); z(x => console.log(x, this)); })();", + parserOptions: { ecmaVersion: 6 }, + errors, + valid: [NORMAL], + invalid: [USE_STRICT, IMPLIED_STRICT, MODULES] + }, + + // Just functions. + { + code: "function foo() { console.log(this); z(x => console.log(x, this)); }", + parserOptions: { ecmaVersion: 6 }, + errors, + valid: [NORMAL], + invalid: [USE_STRICT, IMPLIED_STRICT, MODULES] + }, + { + code: "function foo() { \"use strict\"; console.log(this); z(x => console.log(x, this)); }", + parserOptions: { ecmaVersion: 6 }, + errors, + valid: [], + invalid: [NORMAL, USE_STRICT, IMPLIED_STRICT, MODULES] + }, + { + code: "return function() { console.log(this); z(x => console.log(x, this)); };", + parserOptions: { + ecmaVersion: 6, + ecmaFeatures: {globalReturn: true} + }, + errors, + valid: [NORMAL], + invalid: [USE_STRICT, IMPLIED_STRICT] // modules cannot return on global. + }, + { + code: "var foo = (function() { console.log(this); z(x => console.log(x, this)); }).bar(obj);", + parserOptions: { ecmaVersion: 6 }, + errors, + valid: [NORMAL], + invalid: [USE_STRICT, IMPLIED_STRICT, MODULES] + }, + + // Functions in methods. + { + code: "var obj = {foo: function() { function foo() { console.log(this); z(x => console.log(x, this)); } foo(); }};", + parserOptions: { ecmaVersion: 6 }, + errors, + valid: [NORMAL], + invalid: [USE_STRICT, IMPLIED_STRICT, MODULES] + }, + { + code: "var obj = {foo() { function foo() { console.log(this); z(x => console.log(x, this)); } foo(); }};", + parserOptions: { ecmaVersion: 6 }, + errors, + valid: [NORMAL], + invalid: [USE_STRICT, IMPLIED_STRICT, MODULES] + }, + { + code: "var obj = {foo: function() { return function() { console.log(this); z(x => console.log(x, this)); }; }};", + parserOptions: { ecmaVersion: 6 }, + errors, + valid: [NORMAL], + invalid: [USE_STRICT, IMPLIED_STRICT, MODULES] + }, + { + code: "var obj = {foo: function() { \"use strict\"; return function() { console.log(this); z(x => console.log(x, this)); }; }};", + parserOptions: { ecmaVersion: 6 }, + errors, + valid: [], + invalid: [NORMAL, USE_STRICT, IMPLIED_STRICT, MODULES] + }, + { + code: "obj.foo = function() { return function() { console.log(this); z(x => console.log(x, this)); }; };", + parserOptions: { ecmaVersion: 6 }, + errors, + valid: [NORMAL], + invalid: [USE_STRICT, IMPLIED_STRICT, MODULES] + }, + { + code: "obj.foo = function() { \"use strict\"; return function() { console.log(this); z(x => console.log(x, this)); }; };", + parserOptions: { ecmaVersion: 6 }, + errors, + valid: [], + invalid: [NORMAL, USE_STRICT, IMPLIED_STRICT, MODULES] + }, + { + code: "class A { foo() { return function() { console.log(this); z(x => console.log(x, this)); }; } }", + parserOptions: { ecmaVersion: 6 }, + errors, + valid: [], + invalid: [NORMAL, USE_STRICT, IMPLIED_STRICT, MODULES] + }, + + // Class Static methods. + { + code: "class A {static foo() { console.log(this); z(x => console.log(x, this)); }};", + parserOptions: { ecmaVersion: 6 }, + errors, + valid: [NORMAL, USE_STRICT, IMPLIED_STRICT, MODULES], + invalid: [] + }, + + // Constructors. + { + code: "function Foo() { console.log(this); z(x => console.log(x, this)); }", + parserOptions: { ecmaVersion: 6 }, + valid: [NORMAL, USE_STRICT, IMPLIED_STRICT, MODULES], + invalid: [] + }, + { + code: "var Foo = function Foo() { console.log(this); z(x => console.log(x, this)); };", + parserOptions: { ecmaVersion: 6 }, + valid: [NORMAL, USE_STRICT, IMPLIED_STRICT, MODULES], + invalid: [] + }, + { + code: "class A {constructor() { console.log(this); z(x => console.log(x, this)); }};", + parserOptions: { ecmaVersion: 6 }, + valid: [NORMAL, USE_STRICT, IMPLIED_STRICT, MODULES], + invalid: [] + }, + + // On a property. + { + code: "var obj = {foo: function() { console.log(this); z(x => console.log(x, this)); }};", + parserOptions: { ecmaVersion: 6 }, + valid: [NORMAL, USE_STRICT, IMPLIED_STRICT, MODULES], + invalid: [] + }, + { + code: "var obj = {foo() { console.log(this); z(x => console.log(x, this)); }};", + parserOptions: { ecmaVersion: 6 }, + valid: [NORMAL, USE_STRICT, IMPLIED_STRICT, MODULES], + invalid: [] + }, + { + code: "var obj = {foo: foo || function() { console.log(this); z(x => console.log(x, this)); }};", + parserOptions: { ecmaVersion: 6 }, + valid: [NORMAL, USE_STRICT, IMPLIED_STRICT, MODULES], + invalid: [] + }, + { + code: "var obj = {foo: hasNative ? foo : function() { console.log(this); z(x => console.log(x, this)); }};", + parserOptions: { ecmaVersion: 6 }, + valid: [NORMAL, USE_STRICT, IMPLIED_STRICT, MODULES], + invalid: [] + }, + { + code: "var obj = {foo: (function() { return function() { console.log(this); z(x => console.log(x, this)); }; })()};", + parserOptions: { ecmaVersion: 6 }, + valid: [NORMAL, USE_STRICT, IMPLIED_STRICT, MODULES], + invalid: [] + }, + { + code: "Object.defineProperty(obj, \"foo\", {value: function() { console.log(this); z(x => console.log(x, this)); }})", + parserOptions: { ecmaVersion: 6 }, + valid: [NORMAL, USE_STRICT, IMPLIED_STRICT, MODULES], + invalid: [] + }, + { + code: "Object.defineProperties(obj, {foo: {value: function() { console.log(this); z(x => console.log(x, this)); }}})", + parserOptions: { ecmaVersion: 6 }, + valid: [NORMAL, USE_STRICT, IMPLIED_STRICT, MODULES], + invalid: [] + }, + + // Assigns to a property. + { + code: "obj.foo = function() { console.log(this); z(x => console.log(x, this)); };", + parserOptions: { ecmaVersion: 6 }, + valid: [NORMAL, USE_STRICT, IMPLIED_STRICT, MODULES], + invalid: [] + }, + { + code: "obj.foo = foo || function() { console.log(this); z(x => console.log(x, this)); };", + parserOptions: { ecmaVersion: 6 }, + valid: [NORMAL, USE_STRICT, IMPLIED_STRICT, MODULES], + invalid: [] + }, + { + code: "obj.foo = foo ? bar : function() { console.log(this); z(x => console.log(x, this)); };", + parserOptions: { ecmaVersion: 6 }, + valid: [NORMAL, USE_STRICT, IMPLIED_STRICT, MODULES], + invalid: [] + }, + { + code: "obj.foo = (function() { return function() { console.log(this); z(x => console.log(x, this)); }; })();", + parserOptions: { ecmaVersion: 6 }, + valid: [NORMAL, USE_STRICT, IMPLIED_STRICT, MODULES], + invalid: [] + }, + + // Class Instance Methods. + { + code: "class A {foo() { console.log(this); z(x => console.log(x, this)); }};", + parserOptions: { ecmaVersion: 6 }, + valid: [NORMAL, USE_STRICT, IMPLIED_STRICT, MODULES], + invalid: [] + }, + + // Bind/Call/Apply + { + code: "var foo = function() { console.log(this); z(x => console.log(x, this)); }.bind(obj);", + parserOptions: { ecmaVersion: 6 }, + valid: [NORMAL, USE_STRICT, IMPLIED_STRICT, MODULES], + invalid: [] + }, + { + code: "var foo = function() { console.log(this); z(x => console.log(x, this)); }.bind(null);", + parserOptions: { ecmaVersion: 6 }, + errors, + valid: [NORMAL], + invalid: [USE_STRICT, IMPLIED_STRICT, MODULES] + }, + { + code: "(function() { console.log(this); z(x => console.log(x, this)); }).call(obj);", + parserOptions: { ecmaVersion: 6 }, + valid: [NORMAL, USE_STRICT, IMPLIED_STRICT, MODULES], + invalid: [] + }, + { + code: "(function() { console.log(this); z(x => console.log(x, this)); }).call(undefined);", + parserOptions: { ecmaVersion: 6 }, + errors, + valid: [NORMAL], + invalid: [USE_STRICT, IMPLIED_STRICT, MODULES] + }, + { + code: "(function() { console.log(this); z(x => console.log(x, this)); }).apply(obj);", + parserOptions: { ecmaVersion: 6 }, + valid: [NORMAL, USE_STRICT, IMPLIED_STRICT, MODULES], + invalid: [] + }, + { + code: "(function() { console.log(this); z(x => console.log(x, this)); }).apply(void 0);", + parserOptions: { ecmaVersion: 6 }, + errors, + valid: [NORMAL], + invalid: [USE_STRICT, IMPLIED_STRICT, MODULES] + }, + { + code: "Reflect.apply(function() { console.log(this); z(x => console.log(x, this)); }, obj, []);", + parserOptions: { ecmaVersion: 6 }, + valid: [NORMAL, USE_STRICT, IMPLIED_STRICT, MODULES], + invalid: [] + }, + + // Array methods. + { + code: "Array.from([], function() { console.log(this); z(x => console.log(x, this)); });", + parserOptions: { ecmaVersion: 6 }, + errors, + valid: [NORMAL], + invalid: [USE_STRICT, IMPLIED_STRICT, MODULES] + }, + { + code: "foo.every(function() { console.log(this); z(x => console.log(x, this)); });", + parserOptions: { ecmaVersion: 6 }, + errors, + valid: [NORMAL], + invalid: [USE_STRICT, IMPLIED_STRICT, MODULES] + }, + { + code: "foo.filter(function() { console.log(this); z(x => console.log(x, this)); });", + parserOptions: { ecmaVersion: 6 }, + errors, + valid: [NORMAL], + invalid: [USE_STRICT, IMPLIED_STRICT, MODULES] + }, + { + code: "foo.find(function() { console.log(this); z(x => console.log(x, this)); });", + parserOptions: { ecmaVersion: 6 }, + errors, + valid: [NORMAL], + invalid: [USE_STRICT, IMPLIED_STRICT, MODULES] + }, + { + code: "foo.findIndex(function() { console.log(this); z(x => console.log(x, this)); });", + parserOptions: { ecmaVersion: 6 }, + errors, + valid: [NORMAL], + invalid: [USE_STRICT, IMPLIED_STRICT, MODULES] + }, + { + code: "foo.forEach(function() { console.log(this); z(x => console.log(x, this)); });", + parserOptions: { ecmaVersion: 6 }, + errors, + valid: [NORMAL], + invalid: [USE_STRICT, IMPLIED_STRICT, MODULES] + }, + { + code: "foo.map(function() { console.log(this); z(x => console.log(x, this)); });", + parserOptions: { ecmaVersion: 6 }, + errors, + valid: [NORMAL], + invalid: [USE_STRICT, IMPLIED_STRICT, MODULES] + }, + { + code: "foo.some(function() { console.log(this); z(x => console.log(x, this)); });", + parserOptions: { ecmaVersion: 6 }, + errors, + valid: [NORMAL], + invalid: [USE_STRICT, IMPLIED_STRICT, MODULES] + }, + { + code: "Array.from([], function() { console.log(this); z(x => console.log(x, this)); }, obj);", + parserOptions: { ecmaVersion: 6 }, + valid: [NORMAL, USE_STRICT, IMPLIED_STRICT, MODULES], + invalid: [] + }, + { + code: "foo.every(function() { console.log(this); z(x => console.log(x, this)); }, obj);", + parserOptions: { ecmaVersion: 6 }, + valid: [NORMAL, USE_STRICT, IMPLIED_STRICT, MODULES], + invalid: [] + }, + { + code: "foo.filter(function() { console.log(this); z(x => console.log(x, this)); }, obj);", + parserOptions: { ecmaVersion: 6 }, + valid: [NORMAL, USE_STRICT, IMPLIED_STRICT, MODULES], + invalid: [] + }, + { + code: "foo.find(function() { console.log(this); z(x => console.log(x, this)); }, obj);", + parserOptions: { ecmaVersion: 6 }, + valid: [NORMAL, USE_STRICT, IMPLIED_STRICT, MODULES], + invalid: [] + }, + { + code: "foo.findIndex(function() { console.log(this); z(x => console.log(x, this)); }, obj);", + parserOptions: { ecmaVersion: 6 }, + valid: [NORMAL, USE_STRICT, IMPLIED_STRICT, MODULES], + invalid: [] + }, + { + code: "foo.forEach(function() { console.log(this); z(x => console.log(x, this)); }, obj);", + parserOptions: { ecmaVersion: 6 }, + valid: [NORMAL, USE_STRICT, IMPLIED_STRICT, MODULES], + invalid: [] + }, + { + code: "foo.map(function() { console.log(this); z(x => console.log(x, this)); }, obj);", + parserOptions: { ecmaVersion: 6 }, + valid: [NORMAL, USE_STRICT, IMPLIED_STRICT, MODULES], + invalid: [] + }, + { + code: "foo.some(function() { console.log(this); z(x => console.log(x, this)); }, obj);", + parserOptions: { ecmaVersion: 6 }, + valid: [NORMAL, USE_STRICT, IMPLIED_STRICT, MODULES], + invalid: [] + }, + { + code: "foo.forEach(function() { console.log(this); z(x => console.log(x, this)); }, null);", + parserOptions: { ecmaVersion: 6 }, + errors, + valid: [NORMAL], + invalid: [USE_STRICT, IMPLIED_STRICT, MODULES] + }, + + // @this tag. + { + code: "/** @this Obj */ function foo() { console.log(this); z(x => console.log(x, this)); }", + parserOptions: { ecmaVersion: 6 }, + valid: [NORMAL, USE_STRICT, IMPLIED_STRICT, MODULES], + invalid: [] + }, + { + code: "/**\n * @returns {void}\n * @this Obj\n */\nfunction foo() { console.log(this); z(x => console.log(x, this)); }", + parserOptions: { ecmaVersion: 6 }, + valid: [NORMAL, USE_STRICT, IMPLIED_STRICT, MODULES], + invalid: [] + }, + { + code: "/** @returns {void} */ function foo() { console.log(this); z(x => console.log(x, this)); }", + parserOptions: { ecmaVersion: 6 }, + errors, + valid: [NORMAL], + invalid: [USE_STRICT, IMPLIED_STRICT, MODULES] + }, + { + code: "/** @this Obj */ foo(function() { console.log(this); z(x => console.log(x, this)); });", + parserOptions: { ecmaVersion: 6 }, + errors, + valid: [NORMAL], + invalid: [USE_STRICT, IMPLIED_STRICT, MODULES] + }, + { + code: "foo(/* @this Obj */ function() { console.log(this); z(x => console.log(x, this)); });", + parserOptions: { ecmaVersion: 6 }, + errors, + valid: [NORMAL, USE_STRICT, IMPLIED_STRICT, MODULES], + invalid: [] + }, + + // https://github.com/eslint/eslint/issues/3254 + { + code: "function foo() { console.log(this); z(x => console.log(x, this)); }", + parserOptions: { ecmaVersion: 6 }, + errors, + valid: [NORMAL], + invalid: [USE_STRICT, IMPLIED_STRICT, MODULES] + }, + + // https://github.com/eslint/eslint/issues/3287 + { + code: "function foo() { /** @this Obj*/ return function bar() { console.log(this); z(x => console.log(x, this)); }; }", + parserOptions: { ecmaVersion: 6 }, + valid: [NORMAL, USE_STRICT, IMPLIED_STRICT, MODULES], + invalid: [] + }, + + // https://github.com/eslint/eslint/issues/6824 + { + code: "var Ctor = function() { console.log(this); z(x => console.log(x, this)); }", + parserOptions: { ecmaVersion: 6 }, + valid: [NORMAL, USE_STRICT, IMPLIED_STRICT, MODULES], + invalid: [] + }, + { + code: "var func = function() { console.log(this); z(x => console.log(x, this)); }", + parserOptions: { ecmaVersion: 6 }, + errors, + valid: [NORMAL], + invalid: [USE_STRICT, IMPLIED_STRICT, MODULES] + }, + { + code: "Ctor = function() { console.log(this); z(x => console.log(x, this)); }", + parserOptions: { ecmaVersion: 6 }, + valid: [NORMAL, USE_STRICT, IMPLIED_STRICT, MODULES], + invalid: [] + }, + { + code: "func = function() { console.log(this); z(x => console.log(x, this)); }", + parserOptions: { ecmaVersion: 6 }, + errors, + valid: [NORMAL], + invalid: [USE_STRICT, IMPLIED_STRICT, MODULES] + }, + { + code: "function foo(Ctor = function() { console.log(this); z(x => console.log(x, this)); }) {}", + parserOptions: { ecmaVersion: 6 }, + valid: [NORMAL, USE_STRICT, IMPLIED_STRICT, MODULES], + invalid: [] + }, + { + code: "function foo(func = function() { console.log(this); z(x => console.log(x, this)); }) {}", + parserOptions: { ecmaVersion: 6 }, + errors, + valid: [NORMAL], + invalid: [USE_STRICT, IMPLIED_STRICT, MODULES] + }, + { + code: "[obj.method = function() { console.log(this); z(x => console.log(x, this)); }] = a", + parserOptions: { ecmaVersion: 6 }, + valid: [NORMAL, USE_STRICT, IMPLIED_STRICT, MODULES], + invalid: [] + }, + { + code: "[func = function() { console.log(this); z(x => console.log(x, this)); }] = a", + parserOptions: { ecmaVersion: 6 }, + errors, + valid: [NORMAL], + invalid: [USE_STRICT, IMPLIED_STRICT, MODULES] + }, + + // babel/no-invalid-this + + // Class Instance Properties. + { + code: "class A {a = this.b;};", + parserOptions: { ecmaVersion: 6 }, + valid: [NORMAL, USE_STRICT, IMPLIED_STRICT, MODULES], + invalid: [] + }, + + { + code: "class A {a = () => {return this.b;};};", + parserOptions: { ecmaVersion: 6 }, + valid: [NORMAL, USE_STRICT, IMPLIED_STRICT, MODULES], + invalid: [] + }, + + // Class Private Instance Properties. + { + code: "class A {#a = this.b;};", + parserOptions: { ecmaVersion: 6 }, + valid: [NORMAL, USE_STRICT, IMPLIED_STRICT, MODULES], + invalid: [] + }, + + { + code: "class A {#a = () => {return this.b;};};", + parserOptions: { ecmaVersion: 6 }, + valid: [NORMAL, USE_STRICT, IMPLIED_STRICT, MODULES], + invalid: [] + }, +]; + +const ruleTester = new RuleTester(); + +ruleTester.run("no-invalid-this", rule, { + valid: extractPatterns(patterns, "valid"), + invalid: extractPatterns(patterns, "invalid") +}); diff --git a/eslint/babel-eslint-plugin/tests/rules/no-unused-expressions.js b/eslint/babel-eslint-plugin/tests/rules/no-unused-expressions.js new file mode 100644 index 000000000000..8ecbf68f2622 --- /dev/null +++ b/eslint/babel-eslint-plugin/tests/rules/no-unused-expressions.js @@ -0,0 +1,144 @@ +/** + * @fileoverview Tests for no-unused-expressions rule. + * @author Michael Ficarra + */ + +"use strict"; + +//------------------------------------------------------------------------------ +// Requirements +//------------------------------------------------------------------------------ + +const rule = require("../../rules/no-unused-expressions"), + RuleTester = require("../RuleTester"); + +//------------------------------------------------------------------------------ +// Tests +//------------------------------------------------------------------------------ + +const ruleTester = new RuleTester(); + +ruleTester.run("no-unused-expressions", rule, { + valid: [ + // Original test cases. + "function f(){}", + "a = b", + "new a", + "{}", + "f(); g()", + "i++", + "a()", + { code: "a && a()", options: [{ allowShortCircuit: true }] }, + { code: "a() || (b = c)", options: [{ allowShortCircuit: true }] }, + { code: "a ? b() : c()", options: [{ allowTernary: true }] }, + { code: "a ? b() || (c = d) : e()", options: [{ allowShortCircuit: true, allowTernary: true }] }, + "delete foo.bar", + "void new C", + "\"use strict\";", + "\"directive one\"; \"directive two\"; f();", + "function foo() {\"use strict\"; return true; }", + { code: "var foo = () => {\"use strict\"; return true; }", parserOptions: { ecmaVersion: 6 } }, + "function foo() {\"directive one\"; \"directive two\"; f(); }", + "function foo() { var foo = \"use strict\"; return true; }", + { + code: "function* foo(){ yield 0; }", + parserOptions: { ecmaVersion: 6 } + }, + { + code: "async function foo() { await 5; }", + parserOptions: { ecmaVersion: 8 } + }, + { + code: "async function foo() { await foo.bar; }", + parserOptions: { ecmaVersion: 8 } + }, + { + code: "async function foo() { bar && await baz; }", + options: [{ allowShortCircuit: true }], + parserOptions: { ecmaVersion: 8 } + }, + { + code: "async function foo() { foo ? await bar : await baz; }", + options: [{ allowTernary: true }], + parserOptions: { ecmaVersion: 8 } + }, + { + code: "tag`tagged template literal`", + options: [{ allowTaggedTemplates: true }], + parserOptions: { ecmaVersion: 6 } + }, + { + code: "shouldNotBeAffectedByAllowTemplateTagsOption()", + options: [{ allowTaggedTemplates: true }], + parserOptions: { ecmaVersion: 6 } + }, + + // Babel-specific test cases. + "let a = do { if (foo) { foo.bar; } }", + "let a = do { foo; }", + "let a = do { let b = 2; foo; }", + "let a = do { (foo + 1); }", + "let a = do { if (foo) { if (foo.bar) { foo.bar; } } }", + "let a = do { if (foo) { if (foo.bar) { foo.bar; } else if (foo.baz) { foo.baz; } } }", + "foo.bar?.();", + + ], + invalid: [ + { code: "0", errors: [{ message: "Expected an assignment or function call and instead saw an expression.", type: "ExpressionStatement" }] }, + { code: "a", errors: [{ message: "Expected an assignment or function call and instead saw an expression.", type: "ExpressionStatement" }] }, + { code: "f(), 0", errors: [{ message: "Expected an assignment or function call and instead saw an expression.", type: "ExpressionStatement" }] }, + { code: "{0}", errors: [{ message: "Expected an assignment or function call and instead saw an expression.", type: "ExpressionStatement" }] }, + { code: "[]", errors: [{ message: "Expected an assignment or function call and instead saw an expression.", type: "ExpressionStatement" }] }, + { code: "a && b();", errors: [{ message: "Expected an assignment or function call and instead saw an expression.", type: "ExpressionStatement" }] }, + { code: "a() || false", errors: [{ message: "Expected an assignment or function call and instead saw an expression.", type: "ExpressionStatement" }] }, + { code: "a || (b = c)", errors: [{ message: "Expected an assignment or function call and instead saw an expression.", type: "ExpressionStatement" }] }, + { code: "a ? b() || (c = d) : e", errors: [{ message: "Expected an assignment or function call and instead saw an expression.", type: "ExpressionStatement" }] }, + { + code: "`untagged template literal`", + parserOptions: { ecmaVersion: 6 }, + errors: ["Expected an assignment or function call and instead saw an expression."] + }, + { + code: "tag`tagged template literal`", + parserOptions: { ecmaVersion: 6 }, + errors: ["Expected an assignment or function call and instead saw an expression."] + }, + { code: "a && b()", options: [{ allowTernary: true }], errors: [{ message: "Expected an assignment or function call and instead saw an expression.", type: "ExpressionStatement" }] }, + { code: "a ? b() : c()", options: [{ allowShortCircuit: true }], errors: [{ message: "Expected an assignment or function call and instead saw an expression.", type: "ExpressionStatement" }] }, + { code: "a || b", options: [{ allowShortCircuit: true }], errors: [{ message: "Expected an assignment or function call and instead saw an expression.", type: "ExpressionStatement" }] }, + { code: "a() && b", options: [{ allowShortCircuit: true }], errors: [{ message: "Expected an assignment or function call and instead saw an expression.", type: "ExpressionStatement" }] }, + { code: "a ? b : 0", options: [{ allowTernary: true }], errors: [{ message: "Expected an assignment or function call and instead saw an expression.", type: "ExpressionStatement" }] }, + { code: "a ? b : c()", options: [{ allowTernary: true }], errors: [{ message: "Expected an assignment or function call and instead saw an expression.", type: "ExpressionStatement" }] }, + { code: "foo.bar;", errors: [{ message: "Expected an assignment or function call and instead saw an expression.", type: "ExpressionStatement" }] }, + { code: "!a", errors: [{ message: "Expected an assignment or function call and instead saw an expression.", type: "ExpressionStatement" }] }, + { code: "+a", errors: [{ message: "Expected an assignment or function call and instead saw an expression.", type: "ExpressionStatement" }] }, + { code: "\"directive one\"; f(); \"directive two\";", errors: [{ message: "Expected an assignment or function call and instead saw an expression.", type: "ExpressionStatement" }] }, + { code: "function foo() {\"directive one\"; f(); \"directive two\"; }", errors: [{ message: "Expected an assignment or function call and instead saw an expression.", type: "ExpressionStatement" }] }, + { code: "if (0) { \"not a directive\"; f(); }", errors: [{ message: "Expected an assignment or function call and instead saw an expression.", type: "ExpressionStatement" }] }, + { code: "function foo() { var foo = true; \"use strict\"; }", errors: [{ message: "Expected an assignment or function call and instead saw an expression.", type: "ExpressionStatement" }] }, + { code: "var foo = () => { var foo = true; \"use strict\"; }", parserOptions: { ecmaVersion: 6 }, errors: [{ message: "Expected an assignment or function call and instead saw an expression.", type: "ExpressionStatement" }] }, + { + code: "`untagged template literal`", + options: [{ allowTaggedTemplates: true }], + parserOptions: { ecmaVersion: 6 }, + errors: ["Expected an assignment or function call and instead saw an expression."] + }, + { + code: "`untagged template literal`", + options: [{ allowTaggedTemplates: false }], + parserOptions: { ecmaVersion: 6 }, + errors: ["Expected an assignment or function call and instead saw an expression."] + }, + { + code: "tag`tagged template literal`", + options: [{ allowTaggedTemplates: false }], + parserOptions: { ecmaVersion: 6 }, + errors: ["Expected an assignment or function call and instead saw an expression."] + }, + + // Babel-specific test cases. + { code: "let a = do { foo; let b = 2; }", errors: [{ message: "Expected an assignment or function call and instead saw an expression.", type: "ExpressionStatement" }] }, + { code: "let a = do { if (foo) { foo.bar } else { a; bar.foo } }", errors: [{ message: "Expected an assignment or function call and instead saw an expression.", type: "ExpressionStatement" }] }, + + ] +}); diff --git a/eslint/babel-eslint-plugin/tests/rules/object-curly-spacing.js b/eslint/babel-eslint-plugin/tests/rules/object-curly-spacing.js new file mode 100644 index 000000000000..a982ba5d3954 --- /dev/null +++ b/eslint/babel-eslint-plugin/tests/rules/object-curly-spacing.js @@ -0,0 +1,841 @@ +/** + * @fileoverview Disallows or enforces spaces inside of object literals. + * @author Jamund Ferguson + * @copyright 2014 Vignesh Anand. All rights reserved. + * @copyright 2015 Jamund Ferguson. All rights reserved. + * @copyright 2015 Mathieu M-Gosselin. All rights reserved. + */ + +var rule = require('../../rules/object-curly-spacing'), + RuleTester = require('../RuleTester'); + +var ruleTester = new RuleTester(); +ruleTester.run('babel/object-curly-spacing', rule, { + + valid: [ + + // always - object literals + { code: "var obj = { foo: bar, baz: qux };", options: ["always"] }, + { code: "var obj = { foo: { bar: quxx }, baz: qux };", options: ["always"] }, + { code: "var obj = {\nfoo: bar,\nbaz: qux\n};", options: ["always"] }, + + // always - destructuring + { code: "var { x } = y", options: ["always"], ecmaFeatures: { destructuring: true } }, + { code: "var { x, y } = y", options: ["always"], ecmaFeatures: { destructuring: true } }, + { code: "var { x,y } = y", options: ["always"], ecmaFeatures: { destructuring: true } }, + { code: "var {\nx,y } = y", options: ["always"], ecmaFeatures: { destructuring: true } }, + { code: "var {\nx,y\n} = z", options: ["always"], ecmaFeatures: { destructuring: true } }, + { code: "var { x = 10, y } = y", options: ["always"], ecmaFeatures: { destructuring: true } }, + { code: "var { x: { z }, y } = y", options: ["always"], ecmaFeatures: { destructuring: true } }, + { code: "var {\ny,\n} = x", options: ["always"], ecmaFeatures: { destructuring: true } }, + { code: "var { y, } = x", options: ["always"], ecmaFeatures: { destructuring: true } }, + { code: "var { y: x } = x", options: ["always"], ecmaFeatures: { destructuring: true } }, + + // always - import / export + { code: "import door from 'room'", options: ["always"], ecmaFeatures: { modules: true } }, + { code: "import * as door from 'room'", options: ["always"], ecmaFeatures: { modules: true } }, + { code: "import { door } from 'room'", options: ["always"], ecmaFeatures: { modules: true } }, + { code: "import {\ndoor } from 'room'", options: ["always"], ecmaFeatures: { modules: true } }, + { code: "export { door } from 'room'", options: ["always"], ecmaFeatures: { modules: true } }, + { code: "import { house, mouse } from 'caravan'", options: ["always"], ecmaFeatures: { modules: true } }, + { code: "import {\nhouse,\nmouse\n} from 'caravan'", options: ["always"], ecmaFeatures: { modules: true } }, + { code: "import {\nhouse,\nmouse,\n} from 'caravan'", options: ["always"], ecmaFeatures: { modules: true } }, + { code: "import house, { mouse } from 'caravan'", options: ["always"], ecmaFeatures: { modules: true } }, + { code: "import door, { house, mouse } from 'caravan'", options: ["always"], ecmaFeatures: { modules: true } }, + { code: "export { door }", options: ["always"], ecmaFeatures: { modules: true } }, + { code: "export {\ndoor,\nhouse\n}", options: ["always"], ecmaFeatures: { modules: true } }, + { code: "export {\ndoor,\nhouse,\n}", options: ["always"], ecmaFeatures: { modules: true } }, + { code: "import 'room'", options: ["always"], ecmaFeatures: { modules: true } }, + { code: "import { bar as x } from 'foo';", options: ["always"], ecmaFeatures: { modules: true } }, + { code: "import { x, } from 'foo';", options: ["always"], ecmaFeatures: { modules: true } }, + { code: "import {\nx,\n} from 'foo';", options: ["always"], ecmaFeatures: { modules: true } }, + { code: "export { x, } from 'foo';", options: ["always"], ecmaFeatures: { modules: true } }, + { code: "export {\nx,\n} from 'foo';", options: ["always"], ecmaFeatures: { modules: true } }, + + // always - empty object + { code: "var foo = {};", options: ["always"] }, + + // always - objectsInObjects + { code: "var obj = { 'foo': { 'bar': 1, 'baz': 2 }};", options: ["always", {"objectsInObjects": false}] }, + + // always - arraysInObjects + { code: "var obj = { 'foo': [ 1, 2 ]};", options: ["always", {"arraysInObjects": false}] }, + + // always - arraysInObjects, objectsInObjects + { code: "var obj = { 'qux': [ 1, 2 ], 'foo': { 'bar': 1, 'baz': 2 }};", options: ["always", {"arraysInObjects": false, "objectsInObjects": false}] }, + + // always - arraysInObjects, objectsInObjects (reverse) + { code: "var obj = { 'foo': { 'bar': 1, 'baz': 2 }, 'qux': [ 1, 2 ]};", options: ["always", {"arraysInObjects": false, "objectsInObjects": false}] }, + + // never + { code: "var obj = {foo: bar,\nbaz: qux\n};", options: ["never"] }, + { code: "var obj = {\nfoo: bar,\nbaz: qux};", options: ["never"] }, + + // never - object literals + { code: "var obj = {foo: bar, baz: qux};", options: ["never"] }, + { code: "var obj = {foo: {bar: quxx}, baz: qux};", options: ["never"] }, + { code: "var obj = {foo: {\nbar: quxx}, baz: qux\n};", options: ["never"] }, + { code: "var obj = {foo: {\nbar: quxx\n}, baz: qux};", options: ["never"] }, + { code: "var obj = {\nfoo: bar,\nbaz: qux\n};", options: ["never"] }, + + // never - destructuring + { code: "var {x} = y", options: ["never"], ecmaFeatures: { destructuring: true } }, + { code: "var {x, y} = y", options: ["never"], ecmaFeatures: { destructuring: true } }, + { code: "var {x,y} = y", options: ["never"], ecmaFeatures: { destructuring: true } }, + { code: "var {\nx,y\n} = y", options: ["never"], ecmaFeatures: { destructuring: true } }, + { code: "var {x = 10} = y", options: ["never"], ecmaFeatures: { destructuring: true } }, + { code: "var {x = 10, y} = y", options: ["never"], ecmaFeatures: { destructuring: true } }, + { code: "var {x: {z}, y} = y", options: ["never"], ecmaFeatures: { destructuring: true } }, + { code: "var {\nx: {z\n}, y} = y", options: ["never"], ecmaFeatures: { destructuring: true } }, + { code: "var {\ny,\n} = x", options: ["never"], ecmaFeatures: { destructuring: true } }, + { code: "var {y,} = x", options: ["never"], ecmaFeatures: { destructuring: true } }, + { code: "var {y:x} = x", options: ["never"], ecmaFeatures: { destructuring: true } }, + + // never - import / export + { code: "import door from 'room'", options: ["never"], ecmaFeatures: { modules: true } }, + { code: "import * as door from 'room'", options: ["never"], ecmaFeatures: { modules: true } }, + { code: "import {door} from 'room'", options: ["never"], ecmaFeatures: { modules: true } }, + { code: "export {door} from 'room'", options: ["never"], ecmaFeatures: { modules: true } }, + { code: "import {\ndoor} from 'room'", options: ["never"], ecmaFeatures: { modules: true } }, + { code: "export {\ndoor\n} from 'room'", options: ["never"], ecmaFeatures: { modules: true } }, + { code: "import {house,mouse} from 'caravan'", options: ["never"], ecmaFeatures: { modules: true } }, + { code: "import {house, mouse} from 'caravan'", options: ["never"], ecmaFeatures: { modules: true } }, + { code: "import {\nhouse,\nmouse} from 'caravan'", options: ["never"], ecmaFeatures: { modules: true } }, + { code: "import {\nhouse,\nmouse,\n} from 'caravan'", options: ["never"], ecmaFeatures: { modules: true } }, + { code: "export {door}", options: ["never"], ecmaFeatures: { modules: true } }, + { code: "export {\ndoor,\nmouse\n}", options: ["never"], ecmaFeatures: { modules: true } }, + { code: "export {\ndoor,\nmouse,\n}", options: ["never"], ecmaFeatures: { modules: true } }, + { code: "import 'room'", options: ["never"], ecmaFeatures: { modules: true } }, + { code: "import x, {bar} from 'foo';", options: ["never"], ecmaFeatures: { modules: true } }, + { code: "import x, {bar, baz} from 'foo';", options: ["never"], ecmaFeatures: { modules: true } }, + { code: "import {bar as y} from 'foo';", options: ["never"], ecmaFeatures: { modules: true } }, + { code: "import {x,} from 'foo';", options: ["never"], ecmaFeatures: { modules: true } }, + { code: "import {\nx,\n} from 'foo';", options: ["never"], ecmaFeatures: { modules: true } }, + { code: "export {x,} from 'foo';", options: ["never"], ecmaFeatures: { modules: true } }, + { code: "export {\nx,\n} from 'foo';", options: ["never"], ecmaFeatures: { modules: true } }, + + + // never - empty object + { code: "var foo = {};", options: ["never"] }, + + // never - objectsInObjects + { code: "var obj = {'foo': {'bar': 1, 'baz': 2} };", options: ["never", {"objectsInObjects": true}]}, + + // https://github.com/eslint/eslint/issues/3658 + // Empty cases. + { code: "var {} = foo;", ecmaFeatures: { destructuring: true }}, + { code: "var [] = foo;", ecmaFeatures: { destructuring: true }}, + { code: "var {a: {}} = foo;", ecmaFeatures: { destructuring: true }}, + { code: "var {a: []} = foo;", ecmaFeatures: { destructuring: true }}, + { code: "import {} from 'foo';", ecmaFeatures: { modules: true }}, + { code: "export {} from 'foo';", ecmaFeatures: { modules: true }}, + { code: "export {};", ecmaFeatures: { modules: true }}, + { code: "var {} = foo;", options: ["never"], ecmaFeatures: { destructuring: true }}, + { code: "var [] = foo;", options: ["never"], ecmaFeatures: { destructuring: true }}, + { code: "var {a: {}} = foo;", options: ["never"], ecmaFeatures: { destructuring: true }}, + { code: "var {a: []} = foo;", options: ["never"], ecmaFeatures: { destructuring: true }}, + { code: "import {} from 'foo';", options: ["never"], ecmaFeatures: { modules: true }}, + { code: "export {} from 'foo';", options: ["never"], ecmaFeatures: { modules: true }}, + { code: "export {};", options: ["never"], ecmaFeatures: { modules: true }}, + + // Babel test cases. + { code: "export * as x from \"mod\";", parser: "babel-eslint", ecmaFeatures: { modules: true } }, + { code: "export x from \"mod\";", parser: "babel-eslint", ecmaFeatures: { modules: true } }, + + // always - destructuring typed object param + { code: "function fn({ a,b }:Object){}", options: ["always"], parser: "babel-eslint", ecmaFeatures: { destructuring: true } }, + + // never - destructuring typed object param + { code: "function fn({a,b}: Object){}", options: ["never"], parser: "babel-eslint", ecmaFeatures: { destructuring: true } }, + ], + + invalid: [ + { + code: "import {bar} from 'foo.js';", + output: "import { bar } from 'foo.js';", + options: ["always"], + ecmaFeatures: { + modules: true + }, + errors: [ + { + message: "A space is required after '{'.", + type: "ImportDeclaration", + line: 1, + column: 8 + }, + { + message: "A space is required before '}'.", + type: "ImportDeclaration", + line: 1, + column: 12 + } + ] + }, + { + code: "import { bar as y} from 'foo.js';", + output: "import { bar as y } from 'foo.js';", + options: ["always"], + ecmaFeatures: { + modules: true + }, + errors: [ + { + message: "A space is required before '}'.", + type: "ImportDeclaration", + line: 1, + column: 18 + } + ] + }, + { + code: "import {bar as y} from 'foo.js';", + output: "import { bar as y } from 'foo.js';", + options: ["always"], + ecmaFeatures: { + modules: true + }, + errors: [ + { + message: "A space is required after '{'.", + type: "ImportDeclaration", + line: 1, + column: 8 + }, + { + message: "A space is required before '}'.", + type: "ImportDeclaration", + line: 1, + column: 17 + } + ] + }, + { + code: "import { bar} from 'foo.js';", + output: "import { bar } from 'foo.js';", + options: ["always"], + ecmaFeatures: { + modules: true + }, + errors: [ + { + message: "A space is required before '}'.", + type: "ImportDeclaration", + line: 1, + column: 13 + } + ] + }, + { + code: "import x, { bar} from 'foo';", + output: "import x, { bar } from 'foo';", + options: ["always"], + ecmaFeatures: { + modules: true + }, + errors: [ + { + message: "A space is required before '}'.", + type: "ImportDeclaration", + line: 1, + column: 16 + } + + ] + }, + { + code: "import x, { bar, baz} from 'foo';", + output: "import x, { bar, baz } from 'foo';", + options: ["always"], + ecmaFeatures: { + modules: true + }, + errors: [ + { + message: "A space is required before '}'.", + type: "ImportDeclaration", + line: 1, + column: 21 + } + + ] + }, + { + code: "import x, {bar} from 'foo';", + output: "import x, { bar } from 'foo';", + options: ["always"], + ecmaFeatures: { + modules: true + }, + errors: [ + { + message: "A space is required after '{'.", + type: "ImportDeclaration", + line: 1, + column: 11 + }, + { + message: "A space is required before '}'.", + type: "ImportDeclaration", + line: 1, + column: 15 + } + + ] + }, + { + code: "import x, {bar, baz} from 'foo';", + output: "import x, { bar, baz } from 'foo';", + options: ["always"], + ecmaFeatures: { + modules: true + }, + errors: [ + { + message: "A space is required after '{'.", + type: "ImportDeclaration", + line: 1, + column: 11 + }, + { + message: "A space is required before '}'.", + type: "ImportDeclaration", + line: 1, + column: 20 + } + ] + }, + { + code: "import {bar,} from 'foo';", + output: "import { bar, } from 'foo';", + options: ["always"], + ecmaFeatures: { + modules: true + }, + errors: [ + { + message: "A space is required after '{'.", + type: "ImportDeclaration", + line: 1, + column: 8 + }, + { + message: "A space is required before '}'.", + type: "ImportDeclaration", + line: 1, + column: 13 + } + + ] + }, + { + code: "import { bar, } from 'foo';", + output: "import {bar,} from 'foo';", + options: ["never"], + ecmaFeatures: { + modules: true + }, + errors: [ + { + message: "There should be no space after '{'.", + type: "ImportDeclaration", + line: 1, + column: 8 + }, + { + message: "There should be no space before '}'.", + type: "ImportDeclaration", + line: 1, + column: 15 + } + ] + }, + { + code: "export {bar};", + output: "export { bar };", + options: ["always"], + ecmaFeatures: { + modules: true + }, + errors: [ + { + message: "A space is required after '{'.", + type: "ExportNamedDeclaration", + line: 1, + column: 8 + }, + { + message: "A space is required before '}'.", + type: "ExportNamedDeclaration", + line: 1, + column: 12 + } + ] + }, + + // always - arraysInObjects + { + code: "var obj = { 'foo': [ 1, 2 ] };", + output: "var obj = { 'foo': [ 1, 2 ]};", + options: ["always", {"arraysInObjects": false}], + errors: [ + { + message: "There should be no space before '}'.", + type: "ObjectExpression" + } + ] + }, + { + code: "var obj = { 'foo': [ 1, 2 ] , 'bar': [ 'baz', 'qux' ] };", + output: "var obj = { 'foo': [ 1, 2 ] , 'bar': [ 'baz', 'qux' ]};", + options: ["always", {"arraysInObjects": false}], + errors: [ + { + message: "There should be no space before '}'.", + type: "ObjectExpression" + } + ] + }, + + // always-objectsInObjects + { + code: "var obj = { 'foo': { 'bar': 1, 'baz': 2 } };", + output: "var obj = { 'foo': { 'bar': 1, 'baz': 2 }};", + options: ["always", {"objectsInObjects": false}], + errors: [ + { + message: "There should be no space before '}'.", + type: "ObjectExpression", + line: 1, + column: 43 + } + ] + }, + { + code: "var obj = { 'foo': [ 1, 2 ] , 'bar': { 'baz': 1, 'qux': 2 } };", + output: "var obj = { 'foo': [ 1, 2 ] , 'bar': { 'baz': 1, 'qux': 2 }};", + options: ["always", {"objectsInObjects": false}], + errors: [ + { + message: "There should be no space before '}'.", + type: "ObjectExpression", + line: 1, + column: 61 + } + ] + }, + + // always-destructuring trailing comma + { + code: "var { a,} = x;", + output: "var { a, } = x;", + options: ["always"], + ecmaFeatures: { destructuring: true }, + errors: [ + { + message: "A space is required before '}'.", + type: "ObjectPattern", + line: 1, + column: 9 + } + ] + }, + { + code: "var {a, } = x;", + output: "var {a,} = x;", + options: ["never"], + ecmaFeatures: { destructuring: true }, + errors: [ + { + message: "There should be no space before '}'.", + type: "ObjectPattern", + line: 1, + column: 9 + } + ] + }, + { + code: "var {a:b } = x;", + output: "var {a:b} = x;", + options: ["never"], + ecmaFeatures: { destructuring: true }, + errors: [ + { + message: "There should be no space before '}'.", + type: "ObjectPattern", + line: 1, + column: 10 + } + ] + }, + { + code: "var { a:b } = x;", + output: "var {a:b} = x;", + options: ["never"], + ecmaFeatures: { destructuring: true }, + errors: [ + { + message: "There should be no space after '{'.", + type: "ObjectPattern", + line: 1, + column: 5 + }, + { + message: "There should be no space before '}'.", + type: "ObjectPattern", + line: 1, + column: 11 + } + ] + }, + + // never-objectsInObjects + { + code: "var obj = {'foo': {'bar': 1, 'baz': 2}};", + output: "var obj = {'foo': {'bar': 1, 'baz': 2} };", + options: ["never", {"objectsInObjects": true}], + errors: [ + { + message: "A space is required before '}'.", + type: "ObjectExpression", + line: 1, + column: 39 + } + ] + }, + { + code: "var obj = {'foo': [1, 2] , 'bar': {'baz': 1, 'qux': 2}};", + output: "var obj = {'foo': [1, 2] , 'bar': {'baz': 1, 'qux': 2} };", + options: ["never", {"objectsInObjects": true}], + errors: [ + { + message: "A space is required before '}'.", + type: "ObjectExpression", + line: 1, + column: 55 + } + ] + }, + + // always & never + { + code: "var obj = {foo: bar, baz: qux};", + output: "var obj = { foo: bar, baz: qux };", + options: ["always"], + errors: [ + { + message: "A space is required after '{'.", + type: "ObjectExpression", + line: 1, + column: 11 + }, + { + message: "A space is required before '}'.", + type: "ObjectExpression", + line: 1, + column: 30 + } + ] + }, + { + code: "var obj = {foo: bar, baz: qux };", + output: "var obj = { foo: bar, baz: qux };", + options: ["always"], + errors: [ + { + message: "A space is required after '{'.", + type: "ObjectExpression", + line: 1, + column: 11 + } + ] + }, + { + code: "var obj = { foo: bar, baz: qux};", + output: "var obj = { foo: bar, baz: qux };", + options: ["always"], + errors: [ + { + message: "A space is required before '}'.", + type: "ObjectExpression", + line: 1, + column: 31 + } + ] + }, + { + code: "var obj = { foo: bar, baz: qux };", + output: "var obj = {foo: bar, baz: qux};", + options: ["never"], + errors: [ + { + message: "There should be no space after '{'.", + type: "ObjectExpression", + line: 1, + column: 11 + }, + { + message: "There should be no space before '}'.", + type: "ObjectExpression", + line: 1, + column: 32 + } + ] + }, + { + code: "var obj = {foo: bar, baz: qux };", + output: "var obj = {foo: bar, baz: qux};", + options: ["never"], + errors: [ + { + message: "There should be no space before '}'.", + type: "ObjectExpression", + line: 1, + column: 31 + } + ] + }, + { + code: "var obj = { foo: bar, baz: qux};", + output: "var obj = {foo: bar, baz: qux};", + options: ["never"], + errors: [ + { + message: "There should be no space after '{'.", + type: "ObjectExpression", + line: 1, + column: 11 + } + ] + }, + { + code: "var obj = { foo: { bar: quxx}, baz: qux};", + output: "var obj = {foo: {bar: quxx}, baz: qux};", + options: ["never"], + errors: [ + { + message: "There should be no space after '{'.", + type: "ObjectExpression", + line: 1, + column: 11 + }, + { + message: "There should be no space after '{'.", + type: "ObjectExpression", + line: 1, + column: 18 + } + ] + }, + { + code: "var obj = {foo: {bar: quxx }, baz: qux };", + output: "var obj = {foo: {bar: quxx}, baz: qux};", + options: ["never"], + errors: [ + { + message: "There should be no space before '}'.", + type: "ObjectExpression", + line: 1, + column: 28 + }, + { + message: "There should be no space before '}'.", + type: "ObjectExpression", + line: 1, + column: 40 + } + ] + }, + { + code: "export const thing = {value: 1 };", + output: "export const thing = { value: 1 };", + ecmaFeatures: { + modules: true, + blockBindings: true + }, + options: ["always"], + errors: [ + { + message: "A space is required after '{'.", + type: "ObjectExpression", + line: 1, + column: 22 + } + ] + }, + + // destructuring + { + code: "var {x, y} = y", + output: "var { x, y } = y", + ecmaFeatures: {destructuring: true}, + options: ["always"], + errors: [ + { + message: "A space is required after '{'.", + type: "ObjectPattern", + line: 1, + column: 5 + }, + { + message: "A space is required before '}'.", + type: "ObjectPattern", + line: 1, + column: 10 + } + ] + }, + { + code: "var { x, y} = y", + output: "var { x, y } = y", + ecmaFeatures: {destructuring: true}, + options: ["always"], + errors: [ + { + message: "A space is required before '}'.", + type: "ObjectPattern", + line: 1, + column: 11 + } + ] + }, + { + code: "var { x, y } = y", + output: "var {x, y} = y", + ecmaFeatures: {destructuring: true}, + options: ["never"], + errors: [ + { + message: "There should be no space after '{'.", + type: "ObjectPattern", + line: 1, + column: 5 + }, + { + message: "There should be no space before '}'.", + type: "ObjectPattern", + line: 1, + column: 12 + } + ] + }, + { + code: "var {x, y } = y", + output: "var {x, y} = y", + ecmaFeatures: {destructuring: true}, + options: ["never"], + errors: [ + { + message: "There should be no space before '}'.", + type: "ObjectPattern", + line: 1, + column: 11 + } + ] + }, + { + code: "var { x=10} = y", + output: "var { x=10 } = y", + ecmaFeatures: {destructuring: true}, + options: ["always"], + errors: [ + { + message: "A space is required before '}'.", + type: "ObjectPattern", + line: 1, + column: 11 + } + ] + }, + { + code: "var {x=10 } = y", + output: "var { x=10 } = y", + ecmaFeatures: {destructuring: true}, + options: ["always"], + errors: [ + { + message: "A space is required after '{'.", + type: "ObjectPattern", + line: 1, + column: 5 + } + ] + }, + + // never - arraysInObjects + { + code: "var obj = {'foo': [1, 2]};", + output: "var obj = {'foo': [1, 2] };", + options: ["never", {"arraysInObjects": true}], + errors: [ + { + message: "A space is required before '}'.", + type: "ObjectExpression" + } + ] + }, + { + code: "var obj = {'foo': [1, 2] , 'bar': ['baz', 'qux']};", + output: "var obj = {'foo': [1, 2] , 'bar': ['baz', 'qux'] };", + options: ["never", {"arraysInObjects": true}], + errors: [ + { + message: "A space is required before '}'.", + type: "ObjectExpression" + } + ] + }, + + // Babel test cases. + + // always - destructuring typed object param + { + code: "function fn({a,b}: Object){}", + output: "function fn({ a,b }: Object){}", + options: ["always"], + parser: "babel-eslint", + ecmaFeatures: { + destructuring: true + }, + errors: [ + { + message: "A space is required after '{'.", + type: "ObjectPattern", + line: 1, + column: 13 + }, + { + message: "A space is required before '}'.", + type: "ObjectPattern", + line: 1, + column: 17 + } + ] + }, + + // never - destructuring typed object param + { + code: "function fn({ a,b }: Object){}", + output: "function fn({a,b}: Object){}", + options: ["never"], + parser: "babel-eslint", + ecmaFeatures: { + destructuring: true + }, + errors: [ + { + message: "There should be no space after '{'.", + type: "ObjectPattern", + line: 1, + column: 13 + }, + { + message: "There should be no space before '}'.", + type: "ObjectPattern", + line: 1, + column: 19 + } + ] + } + ] +}); diff --git a/eslint/babel-eslint-plugin/tests/rules/quotes.js b/eslint/babel-eslint-plugin/tests/rules/quotes.js new file mode 100644 index 000000000000..96b93e674a57 --- /dev/null +++ b/eslint/babel-eslint-plugin/tests/rules/quotes.js @@ -0,0 +1,320 @@ +var rule = require('../../rules/quotes'), + RuleTester = require('../RuleTester'); + +var ruleTester = new RuleTester(); +ruleTester.run('babel/quotes', rule, { + valid: [ + "var foo = \"bar\";", + { code: "var foo = 'bar';", options: ["single"] }, + { code: "var foo = \"bar\";", options: ["double"] }, + { code: "var foo = 1;", options: ["single"] }, + { code: "var foo = 1;", options: ["double"] }, + { code: "var foo = \"'\";", options: ["single", { avoidEscape: true }] }, + { code: "var foo = '\"';", options: ["double", { avoidEscape: true }] }, + { code: "var foo =
Hello world
;", options: ["single"], parserOptions: { ecmaVersion: 6, ecmaFeatures: { jsx: true } } }, + { code: "var foo =
;", options: ["single"], parserOptions: { ecmaVersion: 6, ecmaFeatures: { jsx: true } } }, + { code: "var foo =
Hello world
;", options: ["double"], parserOptions: { ecmaVersion: 6, ecmaFeatures: { jsx: true } } }, + { code: "var foo =
Hello world
;", options: ["double", { avoidEscape: true }], parserOptions: { ecmaVersion: 6, ecmaFeatures: { jsx: true } } }, + { code: "var foo = `bar`;", options: ["backtick"], parserOptions: { ecmaVersion: 6 } }, + { code: "var foo = `bar 'baz'`;", options: ["backtick"], parserOptions: { ecmaVersion: 6 } }, + { code: "var foo = `bar \"baz\"`;", options: ["backtick"], parserOptions: { ecmaVersion: 6 } }, + { code: "var foo = 1;", options: ["backtick"] }, + { code: "var foo = \"a string containing `backtick` quotes\";", options: ["backtick", { avoidEscape: true }] }, + { code: "var foo =
;", options: ["backtick"], parserOptions: { ecmaVersion: 6, ecmaFeatures: { jsx: true } } }, + { code: "var foo =
Hello world
;", options: ["backtick"], parserOptions: { ecmaVersion: 6, ecmaFeatures: { jsx: true } } }, + + // Backticks are only okay if they have substitutions, contain a line break, or are tagged + { code: "var foo = `back\ntick`;", options: ["single"], parserOptions: { ecmaVersion: 6 } }, + { code: "var foo = `back\rtick`;", options: ["single"], parserOptions: { ecmaVersion: 6 } }, + { code: "var foo = `back\u2028tick`;", options: ["single"], parserOptions: { ecmaVersion: 6 } }, + { code: "var foo = `back\u2029tick`;", options: ["single"], parserOptions: { ecmaVersion: 6 } }, + { + code: "var foo = `back\\\\\ntick`;", // 2 backslashes followed by a newline + options: ["single"], + parserOptions: { ecmaVersion: 6 } + }, + { code: "var foo = `back\\\\\\\\\ntick`;", options: ["single"], parserOptions: { ecmaVersion: 6 } }, + { code: "var foo = `\n`;", options: ["single"], parserOptions: { ecmaVersion: 6 } }, + { code: "var foo = `back${x}tick`;", options: ["double"], parserOptions: { ecmaVersion: 6 } }, + { code: "var foo = tag`backtick`;", options: ["double"], parserOptions: { ecmaVersion: 6 } }, + + // Backticks are also okay if allowTemplateLiterals + { code: "var foo = `bar 'foo' baz` + 'bar';", options: ["single", { allowTemplateLiterals: true }], parserOptions: { ecmaVersion: 6 } }, + { code: "var foo = `bar 'foo' baz` + \"bar\";", options: ["double", { allowTemplateLiterals: true }], parserOptions: { ecmaVersion: 6 } }, + { code: "var foo = `bar 'foo' baz` + `bar`;", options: ["backtick", { allowTemplateLiterals: true }], parserOptions: { ecmaVersion: 6 } }, + + // `backtick` should not warn the directive prologues. + { code: "\"use strict\"; var foo = `backtick`;", options: ["backtick"], parserOptions: { ecmaVersion: 6 } }, + { code: "\"use strict\"; 'use strong'; \"use asm\"; var foo = `backtick`;", options: ["backtick"], parserOptions: { ecmaVersion: 6 } }, + { code: "function foo() { \"use strict\"; \"use strong\"; \"use asm\"; var foo = `backtick`; }", options: ["backtick"], parserOptions: { ecmaVersion: 6 } }, + { code: "(function() { 'use strict'; 'use strong'; 'use asm'; var foo = `backtick`; })();", options: ["backtick"], parserOptions: { ecmaVersion: 6 } }, + { code: "(() => { \"use strict\"; \"use strong\"; \"use asm\"; var foo = `backtick`; })();", options: ["backtick"], parserOptions: { ecmaVersion: 6 } }, + + // `backtick` should not warn import/export sources. + { code: "import \"a\"; import 'b';", options: ["backtick"], parserOptions: { sourceType: "module" } }, + { code: "import a from \"a\"; import b from 'b';", options: ["backtick"], parserOptions: { sourceType: "module" } }, + { code: "export * from \"a\"; export * from 'b';", options: ["backtick"], parserOptions: { sourceType: "module" } }, + + // `backtick` should not warn property/method names (not computed). + { code: "var obj = {\"key0\": 0, 'key1': 1};", options: ["backtick"], parserOptions: { ecmaVersion: 6 } }, + { code: "class Foo { 'bar'(){} }", options: ["backtick"], parserOptions: { ecmaVersion: 6 } }, + { code: "class Foo { static ''(){} }", options: ["backtick"], parserOptions: { ecmaVersion: 6 } }, + + // Babel + '<>foo;', + { code: '<>foo;', options: ['single'] }, + { code: '<>foo;', options: ['double'] }, + '<>
;', + { code: '<>
;', options: ['single'] }, + { code: '<>
;', options: ['double'] }, + ], + invalid: [ + { + code: "var foo = 'bar';", + output: "var foo = \"bar\";", + errors: [{ message: "Strings must use doublequote.", type: "Literal" }] + }, + { + code: "var foo = \"bar\";", + output: "var foo = 'bar';", + options: ["single"], + errors: [{ message: "Strings must use singlequote.", type: "Literal" }] + }, + { + code: "var foo = `bar`;", + output: "var foo = 'bar';", + options: ["single"], + parserOptions: { + ecmaVersion: 6 + }, + errors: [{ message: "Strings must use singlequote.", type: "TemplateLiteral" }] + }, + { + code: "var foo = 'don\\'t';", + output: "var foo = \"don't\";", + errors: [{ message: "Strings must use doublequote.", type: "Literal" }] + }, + { + code: "var msg = \"Plugin '\" + name + \"' not found\"", + output: "var msg = 'Plugin \\'' + name + '\\' not found'", + options: ["single"], + errors: [ + { message: "Strings must use singlequote.", type: "Literal", column: 11 }, + { message: "Strings must use singlequote.", type: "Literal", column: 31 } + ] + }, + { + code: "var foo = 'bar';", + output: "var foo = \"bar\";", + options: ["double"], + errors: [{ message: "Strings must use doublequote.", type: "Literal" }] + }, + { + code: "var foo = `bar`;", + output: "var foo = \"bar\";", + options: ["double"], + parserOptions: { + ecmaVersion: 6 + }, + errors: [{ message: "Strings must use doublequote.", type: "TemplateLiteral" }] + }, + { + code: "var foo = \"bar\";", + output: "var foo = 'bar';", + options: ["single", { avoidEscape: true }], + errors: [{ message: "Strings must use singlequote.", type: "Literal" }] + }, + { + code: "var foo = 'bar';", + output: "var foo = \"bar\";", + options: ["double", { avoidEscape: true }], + errors: [{ message: "Strings must use doublequote.", type: "Literal" }] + }, + { + code: "var foo = '\\\\';", + output: "var foo = \"\\\\\";", + options: ["double", { avoidEscape: true }], + errors: [{ message: "Strings must use doublequote.", type: "Literal" }] + }, + { + code: "var foo = \"bar\";", + output: "var foo = 'bar';", + options: ["single", { allowTemplateLiterals: true }], + errors: [{ message: "Strings must use singlequote.", type: "Literal" }] + }, + { + code: "var foo = 'bar';", + output: "var foo = \"bar\";", + options: ["double", { allowTemplateLiterals: true }], + errors: [{ message: "Strings must use doublequote.", type: "Literal" }] + }, + { + code: "var foo = 'bar';", + output: "var foo = `bar`;", + options: ["backtick"], + errors: [{ message: "Strings must use backtick.", type: "Literal" }] + }, + { + code: "var foo = 'b${x}a$r';", + output: "var foo = `b\\${x}a$r`;", + options: ["backtick"], + errors: [{ message: "Strings must use backtick.", type: "Literal" }] + }, + { + code: "var foo = \"bar\";", + output: "var foo = `bar`;", + options: ["backtick"], + errors: [{ message: "Strings must use backtick.", type: "Literal" }] + }, + { + code: "var foo = \"bar\";", + output: "var foo = `bar`;", + options: ["backtick", { avoidEscape: true }], + errors: [{ message: "Strings must use backtick.", type: "Literal" }] + }, + { + code: "var foo = 'bar';", + output: "var foo = `bar`;", + options: ["backtick", { avoidEscape: true }], + errors: [{ message: "Strings must use backtick.", type: "Literal" }] + }, + + // "use strict" is *not* a directive prologue in these statements so is subject to the rule + { + code: "var foo = `backtick`; \"use strict\";", + output: "var foo = `backtick`; `use strict`;", + options: ["backtick"], + parserOptions: { ecmaVersion: 6 }, + errors: [{ message: "Strings must use backtick.", type: "Literal" }] + }, + { + code: "{ \"use strict\"; var foo = `backtick`; }", + output: "{ `use strict`; var foo = `backtick`; }", + options: ["backtick"], + parserOptions: { ecmaVersion: 6 }, + errors: [{ message: "Strings must use backtick.", type: "Literal" }] + }, + { + code: "if (1) { \"use strict\"; var foo = `backtick`; }", + output: "if (1) { `use strict`; var foo = `backtick`; }", + options: ["backtick"], + parserOptions: { ecmaVersion: 6 }, + errors: [{ message: "Strings must use backtick.", type: "Literal" }] + }, + + // `backtick` should warn computed property names. + { + code: "var obj = {[\"key0\"]: 0, ['key1']: 1};", + output: "var obj = {[`key0`]: 0, [`key1`]: 1};", + options: ["backtick"], + parserOptions: { ecmaVersion: 6 }, + errors: [ + { message: "Strings must use backtick.", type: "Literal" }, + { message: "Strings must use backtick.", type: "Literal" } + ] + }, + { + code: "class Foo { ['a'](){} static ['b'](){} }", + output: "class Foo { [`a`](){} static [`b`](){} }", + options: ["backtick"], + parserOptions: { ecmaVersion: 6 }, + errors: [ + { message: "Strings must use backtick.", type: "Literal" }, + { message: "Strings must use backtick.", type: "Literal" } + ] + }, + + // https://github.com/eslint/eslint/issues/7084 + { + code: "
", + output: "
", + options: ["single"], + parserOptions: { ecmaFeatures: { jsx: true } }, + errors: [ + { message: "Strings must use singlequote.", type: "Literal" } + ] + }, + { + code: "
", + output: "
", + options: ["double"], + parserOptions: { ecmaFeatures: { jsx: true } }, + errors: [ + { message: "Strings must use doublequote.", type: "Literal" } + ] + }, + { + code: "
", + output: "
", + options: ["backtick"], + parserOptions: { ecmaFeatures: { jsx: true } }, + errors: [ + { message: "Strings must use backtick.", type: "Literal" } + ] + }, + + // https://github.com/eslint/eslint/issues/7610 + { + code: "`use strict`;", + output: null, + parserOptions: { ecmaVersion: 6 }, + errors: [{ message: "Strings must use doublequote.", type: "TemplateLiteral" }] + }, + { + code: "function foo() { `use strict`; foo(); }", + output: null, + parserOptions: { ecmaVersion: 6 }, + errors: [{ message: "Strings must use doublequote.", type: "TemplateLiteral" }] + }, + { + code: "foo = function() { `use strict`; foo(); }", + output: null, + parserOptions: { ecmaVersion: 6 }, + errors: [{ message: "Strings must use doublequote.", type: "TemplateLiteral" }] + }, + { + code: "() => { `use strict`; foo(); }", + output: null, + parserOptions: { ecmaVersion: 6 }, + errors: [{ message: "Strings must use doublequote.", type: "TemplateLiteral" }] + }, + { + code: "() => { foo(); `use strict`; }", + output: "() => { foo(); \"use strict\"; }", + parserOptions: { ecmaVersion: 6 }, + errors: [{ message: "Strings must use doublequote.", type: "TemplateLiteral" }] + }, + { + code: "foo(); `use strict`;", + output: "foo(); \"use strict\";", + parserOptions: { ecmaVersion: 6 }, + errors: [{ message: "Strings must use doublequote.", type: "TemplateLiteral" }] + }, + + // https://github.com/eslint/eslint/issues/7646 + { + code: "var foo = `foo\\nbar`;", + output: "var foo = \"foo\\nbar\";", + parserOptions: { ecmaVersion: 6 }, + errors: [{ message: "Strings must use doublequote.", type: "TemplateLiteral" }] + }, + { + code: "var foo = `foo\\\nbar`;", // 1 backslash followed by a newline + output: "var foo = \"foo\\\nbar\";", + parserOptions: { ecmaVersion: 6 }, + errors: [{ message: "Strings must use doublequote.", type: "TemplateLiteral" }] + }, + { + code: "var foo = `foo\\\\\\\nbar`;", // 3 backslashes followed by a newline + output: "var foo = \"foo\\\\\\\nbar\";", + parserOptions: { ecmaVersion: 6 }, + errors: [{ message: "Strings must use doublequote.", type: "TemplateLiteral" }] + }, + { + code: "````", + output: "\"\"``", + parserOptions: { ecmaVersion: 6 }, + errors: [{ message: "Strings must use doublequote.", type: "TemplateLiteral", line: 1, column: 1 }] + } + ], +}); diff --git a/eslint/babel-eslint-plugin/tests/rules/semi.js b/eslint/babel-eslint-plugin/tests/rules/semi.js new file mode 100644 index 000000000000..15ebea037ff6 --- /dev/null +++ b/eslint/babel-eslint-plugin/tests/rules/semi.js @@ -0,0 +1,204 @@ +/* eslnit-disable */ +/** + * @fileoverview Tests for semi rule. + * @author Nicholas C. Zakas + */ + +"use strict"; + +//------------------------------------------------------------------------------ +// Requirements +//------------------------------------------------------------------------------ + +const rule = require("../../rules/semi"), + RuleTester = require("../RuleTester"); + +const ruleTester = new RuleTester(); + +ruleTester.run("semi", rule, { + valid: [ + "var x = 5;", + "var x =5, y;", + "foo();", + "x = foo();", + "setTimeout(function() {foo = \"bar\"; });", + "setTimeout(function() {foo = \"bar\";});", + "for (var a in b){}", + "for (var i;;){}", + "if (true) {}\n;[global, extended].forEach(function(){});", + "throw new Error('foo');", + { code: "throw new Error('foo')", options: ["never"] }, + { code: "var x = 5", options: ["never"] }, + { code: "var x =5, y", options: ["never"] }, + { code: "foo()", options: ["never"] }, + { code: "debugger", options: ["never"] }, + { code: "for (var a in b){}", options: ["never"] }, + { code: "for (var i;;){}", options: ["never"] }, + { code: "x = foo()", options: ["never"] }, + { code: "if (true) {}\n;[global, extended].forEach(function(){})", options: ["never"] }, + { code: "(function bar() {})\n;(function foo(){})", options: ["never"] }, + { code: ";/foo/.test('bar')", options: ["never"] }, + { code: ";+5", options: ["never"] }, + { code: ";-foo()", options: ["never"] }, + { code: "a++\nb++", options: ["never"] }, + { code: "a++; b++", options: ["never"] }, + { code: "for (let thing of {}) {\n console.log(thing);\n}", parserOptions: { ecmaVersion: 6 } }, + { code: "do{}while(true)", options: ["never"] }, + { code: "do{}while(true);", options: ["always"] }, + + { code: "if (foo) { bar() }", options: ["always", { omitLastInOneLineBlock: true }] }, + { code: "if (foo) { bar(); baz() }", options: ["always", { omitLastInOneLineBlock: true }] }, + + + // method definitions don't have a semicolon. + { code: "class A { a() {} b() {} }", parserOptions: { ecmaVersion: 6 } }, + { code: "var A = class { a() {} b() {} };", parserOptions: { ecmaVersion: 6 } }, + + { code: "import theDefault, { named1, named2 } from 'src/mylib';", parserOptions: { sourceType: "module" } }, + { code: "import theDefault, { named1, named2 } from 'src/mylib'", options: ["never"], parserOptions: { sourceType: "module" } }, + + // exports, "always" + { code: "export * from 'foo';", parserOptions: { sourceType: "module" } }, + { code: "export { foo } from 'foo';", parserOptions: { sourceType: "module" } }, + { code: "export { foo };", parserOptions: { sourceType: "module" } }, + { code: "export var foo;", parserOptions: { sourceType: "module" } }, + { code: "export function foo () { }", parserOptions: { sourceType: "module" } }, + { code: "export function* foo () { }", parserOptions: { sourceType: "module" } }, + { code: "export class Foo { }", parserOptions: { sourceType: "module" } }, + { code: "export let foo;", parserOptions: { sourceType: "module" } }, + { code: "export const FOO = 42;", parserOptions: { sourceType: "module" } }, + { code: "export default function() { }", parserOptions: { sourceType: "module" } }, + { code: "export default function* () { }", parserOptions: { sourceType: "module" } }, + { code: "export default class { }", parserOptions: { sourceType: "module" } }, + { code: "export default foo || bar;", parserOptions: { sourceType: "module" } }, + { code: "export default (foo) => foo.bar();", parserOptions: { sourceType: "module" } }, + { code: "export default foo = 42;", parserOptions: { sourceType: "module" } }, + { code: "export default foo += 42;", parserOptions: { sourceType: "module" } }, + + // exports, "never" + { code: "export * from 'foo'", options: ["never"], parserOptions: { sourceType: "module" } }, + { code: "export { foo } from 'foo'", options: ["never"], parserOptions: { sourceType: "module" } }, + { code: "export { foo }", options: ["never"], parserOptions: { sourceType: "module" } }, + { code: "export var foo", options: ["never"], parserOptions: { sourceType: "module" } }, + { code: "export function foo () { }", options: ["never"], parserOptions: { sourceType: "module" } }, + { code: "export function* foo () { }", options: ["never"], parserOptions: { sourceType: "module" } }, + { code: "export class Foo { }", options: ["never"], parserOptions: { sourceType: "module" } }, + { code: "export let foo", options: ["never"], parserOptions: { sourceType: "module" } }, + { code: "export const FOO = 42", options: ["never"], parserOptions: { sourceType: "module" } }, + { code: "export default function() { }", options: ["never"], parserOptions: { sourceType: "module" } }, + { code: "export default function* () { }", options: ["never"], parserOptions: { sourceType: "module" } }, + { code: "export default class { }", options: ["never"], parserOptions: { sourceType: "module" } }, + { code: "export default foo || bar", options: ["never"], parserOptions: { sourceType: "module" } }, + { code: "export default (foo) => foo.bar()", options: ["never"], parserOptions: { sourceType: "module" } }, + { code: "export default foo = 42", options: ["never"], parserOptions: { sourceType: "module" } }, + { code: "export default foo += 42", options: ["never"], parserOptions: { sourceType: "module" } }, + { code: "++\nfoo;", options: ["always"] }, + { code: "var a = b;\n+ c", options: ["never"] }, + + // https://github.com/eslint/eslint/issues/7782 + { code: "var a = b;\n/foo/.test(c)", options: ["never"] }, + { code: "var a = b;\n`foo`", options: ["never"], parserOptions: { ecmaVersion: 6 } }, + + // babel + "class Foo { bar = 'example'; }", + "class Foo { static bar = 'example'; }", + { code: "async function foo() { for await (let thing of {}) { console.log(thing); } }", parserOptions: { ecmaVersion: 6 } }, + { code: "class Foo { bar = () => {}; }", options: ["always", { omitLastInOneLineBlock: true }] }, + + // babel, "never" + { code: "class Foo { bar = 'example' }", options: ["never"] }, + { code: "class Foo { static bar = 'example' }", options: ["never"] }, + { code: "class Foo { bar = () => {} }", options: ["never"] }, + ], + invalid: [ + { code: "import * as utils from './utils'", output: "import * as utils from './utils';", parserOptions: { sourceType: "module" }, errors: [{ message: "Missing semicolon.", type: "ImportDeclaration", column: 33 }] }, + { code: "import { square, diag } from 'lib'", output: "import { square, diag } from 'lib';", parserOptions: { sourceType: "module" }, errors: [{ message: "Missing semicolon.", type: "ImportDeclaration" }] }, + { code: "import { default as foo } from 'lib'", output: "import { default as foo } from 'lib';", parserOptions: { sourceType: "module" }, errors: [{ message: "Missing semicolon.", type: "ImportDeclaration" }] }, + { code: "import 'src/mylib'", output: "import 'src/mylib';", parserOptions: { sourceType: "module" }, errors: [{ message: "Missing semicolon.", type: "ImportDeclaration" }] }, + { code: "import theDefault, { named1, named2 } from 'src/mylib'", output: "import theDefault, { named1, named2 } from 'src/mylib';", parserOptions: { sourceType: "module" }, errors: [{ message: "Missing semicolon.", type: "ImportDeclaration" }] }, + { code: "function foo() { return [] }", output: "function foo() { return []; }", errors: [{ message: "Missing semicolon.", type: "ReturnStatement" }] }, + { code: "while(true) { break }", output: "while(true) { break; }", errors: [{ message: "Missing semicolon.", type: "BreakStatement" }] }, + { code: "while(true) { continue }", output: "while(true) { continue; }", errors: [{ message: "Missing semicolon.", type: "ContinueStatement" }] }, + { code: "let x = 5", output: "let x = 5;", parserOptions: { ecmaVersion: 6 }, errors: [{ message: "Missing semicolon.", type: "VariableDeclaration" }] }, + { code: "var x = 5", output: "var x = 5;", errors: [{ message: "Missing semicolon.", type: "VariableDeclaration" }] }, + { code: "var x = 5, y", output: "var x = 5, y;", errors: [{ message: "Missing semicolon.", type: "VariableDeclaration" }] }, + { code: "debugger", output: "debugger;", errors: [{ message: "Missing semicolon.", type: "DebuggerStatement" }] }, + { code: "foo()", output: "foo();", errors: [{ message: "Missing semicolon.", type: "ExpressionStatement" }] }, + { code: "var x = 5, y", output: "var x = 5, y;", errors: [{ message: "Missing semicolon.", type: "VariableDeclaration" }] }, + { code: "for (var a in b) var i ", output: "for (var a in b) var i; ", errors: [{ message: "Missing semicolon.", type: "VariableDeclaration" }] }, + { code: "for (;;){var i}", output: "for (;;){var i;}", errors: [{ message: "Missing semicolon.", type: "VariableDeclaration" }] }, + { code: "for (;;) var i ", output: "for (;;) var i; ", errors: [{ message: "Missing semicolon.", type: "VariableDeclaration" }] }, + { code: "for (var j;;) {var i}", output: "for (var j;;) {var i;}", errors: [{ message: "Missing semicolon.", type: "VariableDeclaration" }] }, + { code: "var foo = {\n bar: baz\n}", output: "var foo = {\n bar: baz\n};", errors: [{ message: "Missing semicolon.", type: "VariableDeclaration", line: 3 }] }, + { code: "var foo\nvar bar;", output: "var foo;\nvar bar;", errors: [{ message: "Missing semicolon.", type: "VariableDeclaration", line: 1 }] }, + { code: "throw new Error('foo')", output: "throw new Error('foo');", errors: [{ message: "Missing semicolon.", type: "ThrowStatement", line: 1 }] }, + { code: "do{}while(true)", output: "do{}while(true);", errors: [{ message: "Missing semicolon.", type: "DoWhileStatement", line: 1 }] }, + + { code: "throw new Error('foo');", output: "throw new Error('foo')", options: ["never"], errors: [{ message: "Extra semicolon.", type: "ThrowStatement", column: 23 }] }, + { code: "function foo() { return []; }", output: "function foo() { return [] }", options: ["never"], errors: [{ message: "Extra semicolon.", type: "ReturnStatement" }] }, + { code: "while(true) { break; }", output: "while(true) { break }", options: ["never"], errors: [{ message: "Extra semicolon.", type: "BreakStatement" }] }, + { code: "while(true) { continue; }", output: "while(true) { continue }", options: ["never"], errors: [{ message: "Extra semicolon.", type: "ContinueStatement" }] }, + { code: "let x = 5;", output: "let x = 5", parserOptions: { ecmaVersion: 6 }, options: ["never"], errors: [{ message: "Extra semicolon.", type: "VariableDeclaration" }] }, + { code: "var x = 5;", output: "var x = 5", options: ["never"], errors: [{ message: "Extra semicolon.", type: "VariableDeclaration" }] }, + { code: "var x = 5, y;", output: "var x = 5, y", options: ["never"], errors: [{ message: "Extra semicolon.", type: "VariableDeclaration" }] }, + { code: "debugger;", output: "debugger", options: ["never"], errors: [{ message: "Extra semicolon.", type: "DebuggerStatement" }] }, + { code: "foo();", output: "foo()", options: ["never"], errors: [{ message: "Extra semicolon.", type: "ExpressionStatement" }] }, + { code: "var x = 5, y;", output: "var x = 5, y", options: ["never"], errors: [{ message: "Extra semicolon.", type: "VariableDeclaration" }] }, + { code: "for (var a in b) var i; ", output: "for (var a in b) var i ", options: ["never"], errors: [{ message: "Extra semicolon.", type: "VariableDeclaration" }] }, + { code: "for (;;){var i;}", output: "for (;;){var i}", options: ["never"], errors: [{ message: "Extra semicolon.", type: "VariableDeclaration" }] }, + { code: "for (;;) var i; ", output: "for (;;) var i ", options: ["never"], errors: [{ message: "Extra semicolon.", type: "VariableDeclaration" }] }, + { code: "for (var j;;) {var i;}", output: "for (var j;;) {var i}", options: ["never"], errors: [{ message: "Extra semicolon.", type: "VariableDeclaration" }] }, + { code: "var foo = {\n bar: baz\n};", output: "var foo = {\n bar: baz\n}", options: ["never"], errors: [{ message: "Extra semicolon.", type: "VariableDeclaration", line: 3 }] }, + { code: "import theDefault, { named1, named2 } from 'src/mylib';", output: "import theDefault, { named1, named2 } from 'src/mylib'", options: ["never"], parserOptions: { sourceType: "module" }, errors: [{ message: "Extra semicolon.", type: "ImportDeclaration" }] }, + { code: "do{}while(true);", output: "do{}while(true)", options: ["never"], errors: [{ message: "Extra semicolon.", type: "DoWhileStatement", line: 1 }] }, + + { code: "if (foo) { bar()\n }", options: ["always", { omitLastInOneLineBlock: true }], errors: [{ message: "Missing semicolon." }] }, + { code: "if (foo) {\n bar() }", options: ["always", { omitLastInOneLineBlock: true }], errors: [{ message: "Missing semicolon." }] }, + { code: "if (foo) {\n bar(); baz() }", options: ["always", { omitLastInOneLineBlock: true }], errors: [{ message: "Missing semicolon." }] }, + { code: "if (foo) { bar(); }", options: ["always", { omitLastInOneLineBlock: true }], errors: [{ message: "Extra semicolon." }] }, + + + // exports, "always" + { code: "export * from 'foo'", output: "export * from 'foo';", parserOptions: { sourceType: "module" }, errors: [{ message: "Missing semicolon.", type: "ExportAllDeclaration" }] }, + { code: "export { foo } from 'foo'", output: "export { foo } from 'foo';", parserOptions: { sourceType: "module" }, errors: [{ message: "Missing semicolon.", type: "ExportNamedDeclaration" }] }, + { code: "export { foo }", output: "export { foo };", parserOptions: { sourceType: "module" }, errors: [{ message: "Missing semicolon.", type: "ExportNamedDeclaration" }] }, + { code: "export var foo", output: "export var foo;", parserOptions: { sourceType: "module" }, errors: [{ message: "Missing semicolon.", type: "VariableDeclaration" }] }, + { code: "export let foo", output: "export let foo;", parserOptions: { sourceType: "module" }, errors: [{ message: "Missing semicolon.", type: "VariableDeclaration" }] }, + { code: "export const FOO = 42", output: "export const FOO = 42;", parserOptions: { sourceType: "module" }, errors: [{ message: "Missing semicolon.", type: "VariableDeclaration" }] }, + { code: "export default foo || bar", output: "export default foo || bar;", parserOptions: { sourceType: "module" }, errors: [{ message: "Missing semicolon.", type: "ExportDefaultDeclaration" }] }, + { code: "export default (foo) => foo.bar()", output: "export default (foo) => foo.bar();", parserOptions: { sourceType: "module" }, errors: [{ message: "Missing semicolon.", type: "ExportDefaultDeclaration" }] }, + { code: "export default foo = 42", output: "export default foo = 42;", parserOptions: { sourceType: "module" }, errors: [{ message: "Missing semicolon.", type: "ExportDefaultDeclaration" }] }, + { code: "export default foo += 42", output: "export default foo += 42;", parserOptions: { sourceType: "module" }, errors: [{ message: "Missing semicolon.", type: "ExportDefaultDeclaration" }] }, + + // exports, "never" + { code: "export * from 'foo';", output: "export * from 'foo'", options: ["never"], parserOptions: { sourceType: "module" }, errors: [{ message: "Extra semicolon.", type: "ExportAllDeclaration" }] }, + { code: "export { foo } from 'foo';", output: "export { foo } from 'foo'", options: ["never"], parserOptions: { sourceType: "module" }, errors: [{ message: "Extra semicolon.", type: "ExportNamedDeclaration" }] }, + { code: "export { foo };", output: "export { foo }", options: ["never"], parserOptions: { sourceType: "module" }, errors: [{ message: "Extra semicolon.", type: "ExportNamedDeclaration" }] }, + { code: "export var foo;", output: "export var foo", options: ["never"], parserOptions: { sourceType: "module" }, errors: [{ message: "Extra semicolon.", type: "VariableDeclaration" }] }, + { code: "export let foo;", output: "export let foo", options: ["never"], parserOptions: { sourceType: "module" }, errors: [{ message: "Extra semicolon.", type: "VariableDeclaration" }] }, + { code: "export const FOO = 42;", output: "export const FOO = 42", options: ["never"], parserOptions: { sourceType: "module" }, errors: [{ message: "Extra semicolon.", type: "VariableDeclaration" }] }, + { code: "export default foo || bar;", output: "export default foo || bar", options: ["never"], parserOptions: { sourceType: "module" }, errors: [{ message: "Extra semicolon.", type: "ExportDefaultDeclaration" }] }, + { code: "export default (foo) => foo.bar();", output: "export default (foo) => foo.bar()", options: ["never"], parserOptions: { sourceType: "module" }, errors: [{ message: "Extra semicolon.", type: "ExportDefaultDeclaration" }] }, + { code: "export default foo = 42;", output: "export default foo = 42", options: ["never"], parserOptions: { sourceType: "module" }, errors: [{ message: "Extra semicolon.", type: "ExportDefaultDeclaration" }] }, + { code: "export default foo += 42;", output: "export default foo += 42", options: ["never"], parserOptions: { sourceType: "module" }, errors: [{ message: "Extra semicolon.", type: "ExportDefaultDeclaration" }] }, + { code: "a;\n++b", output: "a\n++b", options: ["never"], errors: [{ message: "Extra semicolon." }] }, + + // babel + { code: "class Foo { bar = 'example' }", errors: [{ message: "Missing semicolon." }] }, + { code: "class Foo { static bar = 'example' }", errors: [{ message: "Missing semicolon." }] }, + { + code: "class Foo { bar = () => {} }", + options: ["always", { omitLastInOneLineBlock: true }], + errors: [{ message: "Missing semicolon." }] + }, + + // babel, "never" + { code: "class Foo { bar = 'example'; }", options: ["never"], errors: [{ message: "Extra semicolon." }] }, + { code: "class Foo { static bar = 'example'; }", options: ["never"], errors: [{ message: "Extra semicolon." }] }, + { + code: "class Foo { bar = () => {}; }", + options: ["never"], + errors: [{ message: "Extra semicolon." }] + }, + ] +}); diff --git a/eslint/babel-eslint-plugin/tests/rules/valid-typeof.js b/eslint/babel-eslint-plugin/tests/rules/valid-typeof.js new file mode 100644 index 000000000000..8e474f6bb123 --- /dev/null +++ b/eslint/babel-eslint-plugin/tests/rules/valid-typeof.js @@ -0,0 +1,193 @@ +/** + * @fileoverview Ensures that the results of typeof are compared against a valid string + * @author Ian Christian Myers + */ + +"use strict"; + +//------------------------------------------------------------------------------ +// Requirements +//------------------------------------------------------------------------------ + +const rule = require("../../rules/valid-typeof"), + RuleTester = require("../RuleTester"); + +//------------------------------------------------------------------------------ +// Tests +//------------------------------------------------------------------------------ + +const ruleTester = new RuleTester(); + +ruleTester.run("valid-typeof", rule, { + valid: [ + // Original test cases. + "typeof foo === 'string'", + "typeof foo === 'object'", + "typeof foo === 'function'", + "typeof foo === 'undefined'", + "typeof foo === 'boolean'", + "typeof foo === 'number'", + "'string' === typeof foo", + "'object' === typeof foo", + "'function' === typeof foo", + "'undefined' === typeof foo", + "'boolean' === typeof foo", + "'number' === typeof foo", + "typeof foo === typeof bar", + "typeof foo === baz", + "typeof foo !== someType", + "typeof bar != someType", + "someType === typeof bar", + "someType == typeof bar", + "typeof foo == 'string'", + "typeof(foo) === 'string'", + "typeof(foo) !== 'string'", + "typeof(foo) == 'string'", + "typeof(foo) != 'string'", + "var oddUse = typeof foo + 'thing'", + { + code: "typeof foo === 'number'", + options: [{ requireStringLiterals: true }] + }, + { + code: "typeof foo === \"number\"", + options: [{ requireStringLiterals: true }] + }, + { + code: "var baz = typeof foo + 'thing'", + options: [{ requireStringLiterals: true }] + }, + { + code: "typeof foo === typeof bar", + options: [{ requireStringLiterals: true }] + }, + { + code: "typeof foo === `string`", + options: [{ requireStringLiterals: true }], + parserOptions: { ecmaVersion: 6 } + }, + { + code: "`object` === typeof foo", + options: [{ requireStringLiterals: true }], + parserOptions: { ecmaVersion: 6 } + }, + { + code: "typeof foo === `str${somethingElse}`", + parserOptions: { ecmaVersion: 6 } + }, + + // Babel-specific test cases. + { + code: "typeof BigInt(Number.MAX_SAFE_INTEGER) === 'bigint'" + }, + { + code: "'bigint' === typeof BigInt(Number.MAX_SAFE_INTEGER)" + }, + { + code: "typeof BigInt(Number.MAX_SAFE_INTEGER) === 'bigint'", + options: [{ requireStringLiterals: true }] + }, + ], + invalid: [ + { + code: "typeof foo === 'strnig'", + errors: [{ message: "Invalid typeof comparison value.", type: "Literal" }] + }, + { + code: "'strnig' === typeof foo", + errors: [{ message: "Invalid typeof comparison value.", type: "Literal" }] + }, + { + code: "if (typeof bar === 'umdefined') {}", + errors: [{ message: "Invalid typeof comparison value.", type: "Literal" }] + }, + { + code: "typeof foo !== 'strnig'", + errors: [{ message: "Invalid typeof comparison value.", type: "Literal" }] + }, + { + code: "'strnig' !== typeof foo", + errors: [{ message: "Invalid typeof comparison value.", type: "Literal" }] + }, + { + code: "if (typeof bar !== 'umdefined') {}", + errors: [{ message: "Invalid typeof comparison value.", type: "Literal" }] + }, + { + code: "typeof foo != 'strnig'", + errors: [{ message: "Invalid typeof comparison value.", type: "Literal" }] + }, + { + code: "'strnig' != typeof foo", + errors: [{ message: "Invalid typeof comparison value.", type: "Literal" }] + }, + { + code: "if (typeof bar != 'umdefined') {}", + errors: [{ message: "Invalid typeof comparison value.", type: "Literal" }] + }, + { + code: "typeof foo == 'strnig'", + errors: [{ message: "Invalid typeof comparison value.", type: "Literal" }] + }, + { + code: "'strnig' == typeof foo", + errors: [{ message: "Invalid typeof comparison value.", type: "Literal" }] + }, + { + code: "if (typeof bar == 'umdefined') {}", + errors: [{ message: "Invalid typeof comparison value.", type: "Literal" }] + }, + { + code: "if (typeof bar === `umdefined`) {}", + parserOptions: { ecmaVersion: 6 }, + errors: [{ message: "Invalid typeof comparison value.", type: "TemplateLiteral" }] + }, + { + code: "typeof foo == 'invalid string'", + options: [{ requireStringLiterals: true }], + errors: [{ message: "Invalid typeof comparison value.", type: "Literal" }] + }, + { + code: "typeof foo == Object", + options: [{ requireStringLiterals: true }], + errors: [{ message: "Typeof comparisons should be to string literals.", type: "Identifier" }] + }, + { + code: "typeof foo === undefined", + options: [{ requireStringLiterals: true }], + errors: [{ message: "Typeof comparisons should be to string literals.", type: "Identifier" }] + }, + { + code: "undefined === typeof foo", + options: [{ requireStringLiterals: true }], + errors: [{ message: "Typeof comparisons should be to string literals.", type: "Identifier" }] + }, + { + code: "undefined == typeof foo", + options: [{ requireStringLiterals: true }], + errors: [{ message: "Typeof comparisons should be to string literals.", type: "Identifier" }] + }, + { + code: "typeof foo === `undefined${foo}`", + options: [{ requireStringLiterals: true }], + parserOptions: { ecmaVersion: 6 }, + errors: [{ message: "Typeof comparisons should be to string literals.", type: "TemplateLiteral" }] + }, + { + code: "typeof foo === `${string}`", + options: [{ requireStringLiterals: true }], + parserOptions: { ecmaVersion: 6 }, + errors: [{ message: "Typeof comparisons should be to string literals.", type: "TemplateLiteral" }] + }, + + // Babel-specific test cases. + { + code: "typeof foo === 'bgiint'", + errors: [{ message: "Invalid typeof comparison value.", type: "Literal" }] + }, + { + code: "'bignit' === typeof foo", + errors: [{ message: "Invalid typeof comparison value.", type: "Literal" }] + }, + ] +}); diff --git a/lerna.json b/lerna.json index 551e14079f47..d51103fbc211 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "7.6.4", + "version": "7.7.3", "changelog": { "repo": "babel/babel", "cacheDir": ".changelog", @@ -28,6 +28,7 @@ }, "packages": [ "codemods/*", + "eslint/*", "packages/*" ], "npmClient": "yarn", diff --git a/package.json b/package.json index 1fbd8da7d90c..a601cabc9e8c 100644 --- a/package.json +++ b/package.json @@ -9,20 +9,20 @@ "test": "make test" }, "devDependencies": { - "@babel/cli": "^7.6.0", - "@babel/core": "^7.6.0", + "@babel/cli": "^7.7.0", + "@babel/core": "^7.7.2", "@babel/eslint-plugin-development": "^1.0.1", - "@babel/plugin-proposal-class-properties": "^7.5.5", + "@babel/plugin-proposal-class-properties": "^7.7.0", "@babel/plugin-proposal-export-namespace-from": "^7.5.2", "@babel/plugin-proposal-nullish-coalescing-operator": "^7.4.4", "@babel/plugin-proposal-numeric-separator": "^7.2.0", "@babel/plugin-proposal-optional-chaining": "^7.6.0", - "@babel/plugin-transform-modules-commonjs": "^7.6.0", - "@babel/plugin-transform-runtime": "^7.6.0", - "@babel/preset-env": "^7.6.0", + "@babel/plugin-transform-modules-commonjs": "^7.7.0", + "@babel/plugin-transform-runtime": "^7.6.2", + "@babel/preset-env": "^7.7.1", "@babel/preset-flow": "^7.0.0", - "@babel/register": "^7.6.0", - "@babel/runtime": "^7.6.0", + "@babel/register": "^7.7.0", + "@babel/runtime": "^7.7.2", "babel-eslint": "^11.0.0-beta.0", "babel-jest": "^24.9.0", "babel-loader": "^8.0.6", @@ -76,7 +76,7 @@ "@lerna/**/@lerna/collect-updates": "https://github.com/babel/lerna.git#babel-collect-updates" }, "engines": { - "node": ">= 6.9.0 < 13.0.0", + "node": ">= 6.9.0 < 14.0.0", "npm": ">= 3.x <= 6.x", "yarn": ">=0.27.5 || >=1.0.0-20170811" }, diff --git a/packages/babel-cli/package.json b/packages/babel-cli/package.json index 4e42d3ca83e5..c5b1e90485d6 100644 --- a/packages/babel-cli/package.json +++ b/packages/babel-cli/package.json @@ -1,6 +1,6 @@ { "name": "@babel/cli", - "version": "7.6.4", + "version": "7.7.0", "description": "Babel command line.", "author": "Sebastian McKenzie ", "homepage": "https://babeljs.io/", @@ -19,13 +19,12 @@ "compiler" ], "dependencies": { - "commander": "^2.8.1", + "commander": "^4.0.1", "convert-source-map": "^1.1.0", "fs-readdir-recursive": "^1.1.0", "glob": "^7.0.0", "lodash": "^4.17.13", - "mkdirp": "^0.5.1", - "output-file-sync": "^2.0.0", + "make-dir": "^2.1.0", "slash": "^2.0.0", "source-map": "^0.5.0" }, @@ -36,7 +35,7 @@ "@babel/core": "^7.0.0-0" }, "devDependencies": { - "@babel/core": "^7.6.4", + "@babel/core": "^7.7.0", "@babel/helper-fixtures": "^7.6.3" }, "bin": { diff --git a/packages/babel-cli/src/babel/dir.js b/packages/babel-cli/src/babel/dir.js index 32136b78f02a..234eb7c8f60b 100644 --- a/packages/babel-cli/src/babel/dir.js +++ b/packages/babel-cli/src/babel/dir.js @@ -1,8 +1,7 @@ // @flow import defaults from "lodash/defaults"; -import outputFileSync from "output-file-sync"; -import { sync as mkdirpSync } from "mkdirp"; +import { sync as makeDirSync } from "make-dir"; import slash from "slash"; import path from "path"; import fs from "fs"; @@ -10,6 +9,11 @@ import fs from "fs"; import * as util from "./util"; import { type CmdOptions } from "./options"; +function outputFileSync(filePath: string, data: string | Buffer): void { + makeDirSync(path.dirname(filePath)); + fs.writeFileSync(filePath, data); +} + export default async function({ cliOptions, babelOptions, @@ -122,24 +126,26 @@ export default async function({ util.deleteDir(cliOptions.outDir); } - mkdirpSync(cliOptions.outDir); + makeDirSync(cliOptions.outDir); let compiledFiles = 0; for (const filename of cliOptions.filenames) { compiledFiles += await handle(filename); } - console.log( - `Successfully compiled ${compiledFiles} ${ - compiledFiles !== 1 ? "files" : "file" - } with Babel.`, - ); + if (!cliOptions.quiet) { + console.log( + `Successfully compiled ${compiledFiles} ${ + compiledFiles !== 1 ? "files" : "file" + } with Babel.`, + ); + } } if (cliOptions.watch) { const chokidar = util.requireChokidar(); - filenames.forEach(function(filenameOrDir) { + filenames.forEach(function(filenameOrDir: string): void { const watcher = chokidar.watch(filenameOrDir, { persistent: true, ignoreInitial: true, @@ -149,8 +155,8 @@ export default async function({ }, }); - ["add", "change"].forEach(function(type) { - watcher.on(type, function(filename) { + ["add", "change"].forEach(function(type: string): void { + watcher.on(type, function(filename: string): void { handleFile( filename, filename === filenameOrDir diff --git a/packages/babel-cli/src/babel/file.js b/packages/babel-cli/src/babel/file.js index 7c38d3052f3d..1ad5d6b84772 100644 --- a/packages/babel-cli/src/babel/file.js +++ b/packages/babel-cli/src/babel/file.js @@ -4,6 +4,7 @@ import convertSourceMap from "convert-source-map"; import defaults from "lodash/defaults"; import sourceMap from "source-map"; import slash from "slash"; +import { sync as makeDirSync } from "make-dir"; import path from "path"; import fs from "fs"; @@ -89,6 +90,8 @@ export default async function({ const result = buildResult(fileResults); if (cliOptions.outFile) { + makeDirSync(path.dirname(cliOptions.outFile)); + // we've requested for a sourcemap to be written to disk if (babelOptions.sourceMaps && babelOptions.sourceMaps !== "inline") { const mapLoc = cliOptions.outFile + ".map"; @@ -220,7 +223,7 @@ export default async function({ pollInterval: 10, }, }) - .on("all", function(type: string, filename: string) { + .on("all", function(type: string, filename: string): void { if (!util.isCompilableExtension(filename, cliOptions.extensions)) { return; } diff --git a/packages/babel-cli/src/babel/options.js b/packages/babel-cli/src/babel/options.js index 897c05ba16da..fa09d6b64ed3 100644 --- a/packages/babel-cli/src/babel/options.js +++ b/packages/babel-cli/src/babel/options.js @@ -12,19 +12,19 @@ import pkg from "../../package.json"; // Standard Babel input configs. commander.option( "-f, --filename [filename]", - "filename to use when reading from stdin - this will be used in source-maps, errors etc", + "The filename to use when reading from stdin. This will be used in source-maps, errors etc.", ); commander.option( "--presets [list]", - "comma-separated list of preset names", + "A comma-separated list of preset names.", collect, ); commander.option( "--plugins [list]", - "comma-separated list of plugin names", + "A comma-separated list of plugin names.", collect, ); -commander.option("--config-file [path]", "Path to a .babelrc file to use"); +commander.option("--config-file [path]", "Path to a .babelrc file to use."); commander.option( "--env-name [name]", "The name of the 'env' to use when loading configs and plugins. " + @@ -40,97 +40,101 @@ commander.option( commander.option("--source-type [script|module]", ""); commander.option( "--no-babelrc", - "Whether or not to look up .babelrc and .babelignore files", + "Whether or not to look up .babelrc and .babelignore files.", ); commander.option( "--ignore [list]", - "list of glob paths to **not** compile", + "List of glob paths to **not** compile.", collect, ); commander.option( "--only [list]", - "list of glob paths to **only** compile", + "List of glob paths to **only** compile.", collect, ); // Misc babel config. commander.option( "--no-highlight-code", - "enable/disable ANSI syntax highlighting of code frames (on by default)", + "Enable or disable ANSI syntax highlighting of code frames. (on by default)", ); // General output formatting. commander.option( "--no-comments", - "write comments to generated output (true by default)", + "Write comments to generated output. (true by default)", ); commander.option( "--retain-lines", - "retain line numbers - will result in really ugly code", + "Retain line numbers. This will result in really ugly code.", ); commander.option( "--compact [true|false|auto]", - "do not include superfluous whitespace characters and line terminators", + "Do not include superfluous whitespace characters and line terminators.", booleanify, ); -commander.option("--minified", "save as much bytes when printing [true|false]"); +commander.option( + "--minified [true|false]", + "Save as many bytes when printing.", +); commander.option( "--auxiliary-comment-before [string]", - "print a comment before any injected non-user code", + "Print a comment before any injected non-user code.", ); commander.option( "--auxiliary-comment-after [string]", - "print a comment after any injected non-user code", + "Print a comment after any injected non-user code.", ); // General source map formatting. commander.option("-s, --source-maps [true|false|inline|both]", "", booleanify); commander.option( "--source-map-target [string]", - "set `file` on returned source map", + "Set `file` on returned source map.", ); commander.option( "--source-file-name [string]", - "set `sources[0]` on returned source map", + "Set `sources[0]` on returned source map.", ); commander.option( "--source-root [filename]", - "the root from which all sources are relative", + "The root from which all sources are relative.", ); // Config params for certain module output formats. commander.option( "--module-root [filename]", - "optional prefix for the AMD module formatter that will be prepend to the filename on module definitions", + // eslint-disable-next-line max-len + "Optional prefix for the AMD module formatter that will be prepended to the filename on module definitions.", ); -commander.option("-M, --module-ids", "insert an explicit id for modules"); +commander.option("-M, --module-ids", "Insert an explicit id for modules."); commander.option( "--module-id [string]", - "specify a custom name for module ids", + "Specify a custom name for module ids.", ); // "babel" command specific arguments that are not passed to @babel/core. commander.option( "-x, --extensions [extensions]", - "List of extensions to compile when a directory has been input [.es6,.js,.es,.jsx,.mjs]", + "List of extensions to compile when a directory has been the input. [.es6,.js,.es,.jsx,.mjs]", collect, ); commander.option( "--keep-file-extension", - "Preserve the file extensions of the input files", + "Preserve the file extensions of the input files.", ); -commander.option("-w, --watch", "Recompile files on changes"); +commander.option("-w, --watch", "Recompile files on changes."); commander.option( "--skip-initial-build", - "Do not compile files before watching", + "Do not compile files before watching.", ); commander.option( "-o, --out-file [out]", - "Compile all input files into a single file", + "Compile all input files into a single file.", ); commander.option( "-d, --out-dir [out]", - "Compile an input directory of modules into an output directory", + "Compile an input directory of modules into an output directory.", ); commander.option( "--relative", @@ -138,20 +142,31 @@ commander.option( ); commander.option( "-D, --copy-files", - "When compiling a directory copy over non-compilable files", + "When compiling a directory copy over non-compilable files.", ); commander.option( "--include-dotfiles", - "Include dotfiles when compiling and copying non-compilable files", + "Include dotfiles when compiling and copying non-compilable files.", +); +commander.option( + "--verbose", + "Log everything. This option conflicts with --quiet", +); +commander.option( + "--quiet", + "Don't log anything. This option conflicts with --verbose", ); -commander.option("--verbose", "Log everything"); commander.option( "--delete-dir-on-start", - "Delete the out directory before compilation", + "Delete the out directory before compilation.", ); commander.version(pkg.version + " (@babel/core " + version + ")"); commander.usage("[options] "); +// register an empty action handler so that commander.js can throw on +// unknown options _after_ args +// see https://github.com/tj/commander.js/issues/561#issuecomment-522209408 +commander.action(() => {}); export type CmdOptions = { babelOptions: Object, @@ -207,6 +222,10 @@ export default function parseArgv(args: Array): CmdOptions | null { errors.push("--delete-dir-on-start requires --out-dir"); } + if (commander.verbose && commander.quiet) { + errors.push("--verbose and --quiet cannot be used together"); + } + if ( !commander.outDir && filenames.length === 0 && @@ -282,6 +301,7 @@ export default function parseArgv(args: Array): CmdOptions | null { copyFiles: opts.copyFiles, includeDotfiles: opts.includeDotfiles, verbose: opts.verbose, + quiet: opts.quiet, deleteDirOnStart: opts.deleteDirOnStart, sourceMapTarget: opts.sourceMapTarget, }, @@ -300,7 +320,10 @@ function booleanify(val: any): boolean | any { return val; } -function collect(value, previousValue): Array { +function collect( + value: string | any, + previousValue: Array, +): Array { // If the user passed the option with no value, like "babel file.js --presets", do nothing. if (typeof value !== "string") return previousValue; diff --git a/packages/babel-cli/test/fixtures/babel/error incorrect options after args/in-files/script.js b/packages/babel-cli/test/fixtures/babel/error incorrect options after args/in-files/script.js new file mode 100644 index 000000000000..4bc9539528d4 --- /dev/null +++ b/packages/babel-cli/test/fixtures/babel/error incorrect options after args/in-files/script.js @@ -0,0 +1 @@ +arr.map(x => x * MULTIPLIER); diff --git a/packages/babel-cli/test/fixtures/babel/error incorrect options after args/options.json b/packages/babel-cli/test/fixtures/babel/error incorrect options after args/options.json new file mode 100644 index 000000000000..dde64755da06 --- /dev/null +++ b/packages/babel-cli/test/fixtures/babel/error incorrect options after args/options.json @@ -0,0 +1,4 @@ +{ + "args": ["script.js", "--spruce-maps"], + "stderrContains": true +} diff --git a/packages/babel-cli/test/fixtures/babel/error incorrect options after args/stderr.txt b/packages/babel-cli/test/fixtures/babel/error incorrect options after args/stderr.txt new file mode 100644 index 000000000000..294d5ccaeaed --- /dev/null +++ b/packages/babel-cli/test/fixtures/babel/error incorrect options after args/stderr.txt @@ -0,0 +1 @@ +error: unknown option '--spruce-maps' diff --git a/packages/babel-cli/test/fixtures/babel/error incorrect options before args/in-files/script.js b/packages/babel-cli/test/fixtures/babel/error incorrect options before args/in-files/script.js new file mode 100644 index 000000000000..4bc9539528d4 --- /dev/null +++ b/packages/babel-cli/test/fixtures/babel/error incorrect options before args/in-files/script.js @@ -0,0 +1 @@ +arr.map(x => x * MULTIPLIER); diff --git a/packages/babel-cli/test/fixtures/babel/error incorrect options before args/options.json b/packages/babel-cli/test/fixtures/babel/error incorrect options before args/options.json new file mode 100644 index 000000000000..0d7953971726 --- /dev/null +++ b/packages/babel-cli/test/fixtures/babel/error incorrect options before args/options.json @@ -0,0 +1,4 @@ +{ + "args": ["--spruce-maps", "script.js"], + "stderrContains": true +} diff --git a/packages/babel-cli/test/fixtures/babel/error incorrect options before args/stderr.txt b/packages/babel-cli/test/fixtures/babel/error incorrect options before args/stderr.txt new file mode 100644 index 000000000000..294d5ccaeaed --- /dev/null +++ b/packages/babel-cli/test/fixtures/babel/error incorrect options before args/stderr.txt @@ -0,0 +1 @@ +error: unknown option '--spruce-maps' diff --git a/packages/babel-cli/test/fixtures/babel/filename --out-file deep/in-files/script.js b/packages/babel-cli/test/fixtures/babel/filename --out-file deep/in-files/script.js new file mode 100644 index 000000000000..4bc9539528d4 --- /dev/null +++ b/packages/babel-cli/test/fixtures/babel/filename --out-file deep/in-files/script.js @@ -0,0 +1 @@ +arr.map(x => x * MULTIPLIER); diff --git a/packages/babel-cli/test/fixtures/babel/filename --out-file deep/options.json b/packages/babel-cli/test/fixtures/babel/filename --out-file deep/options.json new file mode 100644 index 000000000000..d24719ba4a76 --- /dev/null +++ b/packages/babel-cli/test/fixtures/babel/filename --out-file deep/options.json @@ -0,0 +1,3 @@ +{ + "args": ["script.js", "--out-file", "folder/nested/script.js"] +} diff --git a/packages/babel-cli/test/fixtures/babel/filename --out-file deep/out-files/folder/nested/script.js b/packages/babel-cli/test/fixtures/babel/filename --out-file deep/out-files/folder/nested/script.js new file mode 100644 index 000000000000..ae4557e57bc3 --- /dev/null +++ b/packages/babel-cli/test/fixtures/babel/filename --out-file deep/out-files/folder/nested/script.js @@ -0,0 +1,5 @@ +"use strict"; + +arr.map(function (x) { + return x * MULTIPLIER; +}); diff --git a/packages/babel-cli/test/index.js b/packages/babel-cli/test/index.js index 7aa457b00fb8..88d596740133 100644 --- a/packages/babel-cli/test/index.js +++ b/packages/babel-cli/test/index.js @@ -1,7 +1,7 @@ const readdir = require("fs-readdir-recursive"); const helper = require("@babel/helper-fixtures"); const rimraf = require("rimraf"); -const outputFileSync = require("output-file-sync"); +const { sync: makeDirSync } = require("make-dir"); const child = require("child_process"); const merge = require("lodash/merge"); const path = require("path"); @@ -14,6 +14,11 @@ const fileFilter = function(x) { return x !== ".DS_Store"; }; +const outputFileSync = function(filePath, data) { + makeDirSync(path.dirname(filePath)); + fs.writeFileSync(filePath, data); +}; + const presetLocs = [path.join(__dirname, "../../babel-preset-react")]; const pluginLocs = [ diff --git a/packages/babel-core/package.json b/packages/babel-core/package.json index f4dd6723634d..4da69a87d404 100644 --- a/packages/babel-core/package.json +++ b/packages/babel-core/package.json @@ -1,6 +1,6 @@ { "name": "@babel/core", - "version": "7.6.4", + "version": "7.7.2", "description": "Babel compiler core.", "main": "lib/index.js", "author": "Sebastian McKenzie ", @@ -28,19 +28,23 @@ "engines": { "node": ">=6.9.0" }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/babel" + }, "browser": { "./lib/config/files/index.js": "./lib/config/files/index-browser.js", "./lib/transform-file.js": "./lib/transform-file-browser.js" }, "dependencies": { "@babel/code-frame": "^7.5.5", - "@babel/generator": "^7.6.4", - "@babel/helpers": "^7.6.2", - "@babel/parser": "^7.6.4", - "@babel/template": "^7.6.0", - "@babel/traverse": "^7.6.3", - "@babel/types": "^7.6.3", - "convert-source-map": "^1.1.0", + "@babel/generator": "^7.7.2", + "@babel/helpers": "^7.7.0", + "@babel/parser": "^7.7.2", + "@babel/template": "^7.7.0", + "@babel/traverse": "^7.7.2", + "@babel/types": "^7.7.2", + "convert-source-map": "^1.7.0", "debug": "^4.1.0", "json5": "^2.1.0", "lodash": "^4.17.13", diff --git a/packages/babel-core/src/config/files/configuration.js b/packages/babel-core/src/config/files/configuration.js index ab3353f6fde3..515171ceba94 100644 --- a/packages/babel-core/src/config/files/configuration.js +++ b/packages/babel-core/src/config/files/configuration.js @@ -18,18 +18,22 @@ import type { CallerMetadata } from "../validation/options"; const debug = buildDebug("babel:config:loading:files:configuration"); -const BABEL_CONFIG_JS_FILENAME = "babel.config.js"; +const ROOT_CONFIG_FILENAMES = [ + "babel.config.js", + "babel.config.cjs", + "babel.config.json", +]; +const RELATIVE_CONFIG_FILENAMES = [".babelrc", ".babelrc.js", ".babelrc.cjs"]; -const BABELRC_FILENAME = ".babelrc"; -const BABELRC_JS_FILENAME = ".babelrc.js"; const BABELIGNORE_FILENAME = ".babelignore"; export function findConfigUpwards(rootDir: string): string | null { let dirname = rootDir; while (true) { - if (fs.existsSync(path.join(dirname, BABEL_CONFIG_JS_FILENAME))) { - return dirname; - } + const configFileFound = ROOT_CONFIG_FILENAMES.some(filename => + fs.existsSync(path.join(dirname, filename)), + ); + if (configFileFound) return dirname; const nextDir = path.dirname(dirname); if (dirname === nextDir) break; @@ -51,45 +55,15 @@ export function findRelativeConfig( for (const loc of packageData.directories) { if (!config) { - config = [BABELRC_FILENAME, BABELRC_JS_FILENAME].reduce( - (previousConfig: ConfigFile | null, name) => { - const filepath = path.join(loc, name); - const config = readConfig(filepath, envName, caller); - - if (config && previousConfig) { - throw new Error( - `Multiple configuration files found. Please remove one:\n` + - ` - ${path.basename(previousConfig.filepath)}\n` + - ` - ${name}\n` + - `from ${loc}`, - ); - } - - return config || previousConfig; - }, - null, - ); - - const pkgConfig = + config = loadOneConfig( + RELATIVE_CONFIG_FILENAMES, + loc, + envName, + caller, packageData.pkg && packageData.pkg.dirname === loc ? packageToBabelConfig(packageData.pkg) - : null; - - if (pkgConfig) { - if (config) { - throw new Error( - `Multiple configuration files found. Please remove one:\n` + - ` - ${path.basename(pkgConfig.filepath)}#babel\n` + - ` - ${path.basename(config.filepath)}\n` + - `from ${loc}`, - ); - } - config = pkgConfig; - } - - if (config) { - debug("Found configuration %o from %o.", config.filepath, dirname); - } + : null, + ); } if (!ignore) { @@ -110,13 +84,36 @@ export function findRootConfig( envName: string, caller: CallerMetadata | void, ): ConfigFile | null { - const filepath = path.resolve(dirname, BABEL_CONFIG_JS_FILENAME); + return loadOneConfig(ROOT_CONFIG_FILENAMES, dirname, envName, caller); +} - const conf = readConfig(filepath, envName, caller); - if (conf) { - debug("Found root config %o in %o.", BABEL_CONFIG_JS_FILENAME, dirname); +function loadOneConfig( + names: string[], + dirname: string, + envName: string, + caller: CallerMetadata | void, + previousConfig?: ConfigFile | null = null, +): ConfigFile | null { + const config = names.reduce((previousConfig: ConfigFile | null, name) => { + const filepath = path.resolve(dirname, name); + const config = readConfig(filepath, envName, caller); + + if (config && previousConfig) { + throw new Error( + `Multiple configuration files found. Please remove one:\n` + + ` - ${path.basename(previousConfig.filepath)}\n` + + ` - ${name}\n` + + `from ${dirname}`, + ); + } + + return config || previousConfig; + }, previousConfig); + + if (config) { + debug("Found configuration %o from %o.", config.filepath, dirname); } - return conf; + return config; } export function loadConfig( @@ -141,7 +138,8 @@ export function loadConfig( * throw if there are parsing errors while loading a config. */ function readConfig(filepath, envName, caller): ConfigFile | null { - return path.extname(filepath) === ".js" + const ext = path.extname(filepath); + return ext === ".js" || ext === ".cjs" ? readConfigJS(filepath, { envName, caller }) : readConfigJSON5(filepath); } diff --git a/packages/babel-core/src/transformation/file/file.js b/packages/babel-core/src/transformation/file/file.js index 1aa6070c73c2..ed86452c64ff 100644 --- a/packages/babel-core/src/transformation/file/file.js +++ b/packages/babel-core/src/transformation/file/file.js @@ -19,6 +19,17 @@ const errorVisitor = { }, }; +export type NodeLocation = { + loc?: { + end?: { line: number, column: number }, + start: { line: number, column: number }, + }, + _loc?: { + end?: { line: number, column: number }, + start: { line: number, column: number }, + }, +}; + export default class File { _map: Map = new Map(); opts: Object; @@ -250,10 +261,7 @@ export default class File { } buildCodeFrameError( - node: ?{ - loc?: { start: { line: number, column: number } }, - _loc?: { start: { line: number, column: number } }, - }, + node: ?NodeLocation, msg: string, Error: typeof Error = SyntaxError, ): Error { @@ -285,6 +293,13 @@ export default class File { line: loc.start.line, column: loc.start.column + 1, }, + end: + loc.end && loc.start.line === loc.end.line + ? { + line: loc.end.line, + column: loc.end.column + 1, + } + : undefined, }, { highlightCode }, ); diff --git a/packages/babel-core/src/transformation/normalize-file.js b/packages/babel-core/src/transformation/normalize-file.js index 6326dd385e66..cc7db60a5478 100644 --- a/packages/babel-core/src/transformation/normalize-file.js +++ b/packages/babel-core/src/transformation/normalize-file.js @@ -65,7 +65,8 @@ export default function normalizeFile( if (typeof options.filename === "string" && lastComment) { try { inputMap = convertSourceMap.fromMapFileComment( - lastComment, + // fromMapFileComment requires the whole comment block + `//${lastComment}`, path.dirname(options.filename), ); } catch (err) { @@ -156,7 +157,7 @@ function parser( // eslint-disable-next-line max-len const INLINE_SOURCEMAP_REGEX = /^[@#]\s+sourceMappingURL=data:(?:application|text)\/json;(?:charset[:=]\S+?;)?base64,(?:.*)$/; -const EXTERNAL_SOURCEMAP_REGEX = /^[@#][ \t]+sourceMappingURL=([^\s'"`]+?)[ \t]*$/; +const EXTERNAL_SOURCEMAP_REGEX = /^[@#][ \t]+sourceMappingURL=(?:[^\s'"`]+?)[ \t]*$/; function extractCommentsFromList(regex, comments, lastComment) { if (comments) { diff --git a/packages/babel-core/src/transformation/plugin-pass.js b/packages/babel-core/src/transformation/plugin-pass.js index 6e62c42bc786..e11f97804745 100644 --- a/packages/babel-core/src/transformation/plugin-pass.js +++ b/packages/babel-core/src/transformation/plugin-pass.js @@ -1,6 +1,7 @@ // @flow import type File from "./file/file"; +import type NodeLocation from "./file/file"; export default class PluginPass { _map: Map = new Map(); @@ -47,14 +48,7 @@ export default class PluginPass { return this.file.getModuleName(); } - buildCodeFrameError( - node: ?{ - loc?: { start: { line: number, column: number } }, - _loc?: { start: { line: number, column: number } }, - }, - msg: string, - Error?: typeof Error, - ) { + buildCodeFrameError(node: ?NodeLocation, msg: string, Error?: typeof Error) { return this.file.buildCodeFrameError(node, msg, Error); } } diff --git a/packages/babel-core/test/config-chain.js b/packages/babel-core/test/config-chain.js index 32513b1a4519..078cd91dce97 100644 --- a/packages/babel-core/test/config-chain.js +++ b/packages/babel-core/test/config-chain.js @@ -1,8 +1,44 @@ import fs from "fs"; +import os from "os"; import path from "path"; import escapeRegExp from "lodash/escapeRegExp"; import { loadOptions as loadOptionsOrig } from "../lib"; +// TODO: In Babel 8, we can directly uses fs.promises which is supported by +// node 8+ +const pfs = + fs.promises ?? + new Proxy(fs, { + get(target, name) { + if (name === "copyFile") { + // fs.copyFile is only supported since node 8.5 + // https://stackoverflow.com/a/30405105/2359289 + return function copyFile(source, target) { + const rd = fs.createReadStream(source); + const wr = fs.createWriteStream(target); + return new Promise(function(resolve, reject) { + rd.on("error", reject); + wr.on("error", reject); + wr.on("finish", resolve); + rd.pipe(wr); + }).catch(function(error) { + rd.destroy(); + wr.end(); + throw error; + }); + }; + } + + return (...args) => + new Promise((resolve, reject) => + target[name](...args, (error, result) => { + if (error) reject(error); + else resolve(result); + }), + ); + }, + }); + function fixture(...args) { return path.join(__dirname, "fixtures", "config", ...args); } @@ -14,6 +50,24 @@ function loadOptions(opts) { }); } +function pairs(items) { + const pairs = []; + for (let i = 0; i < items.length - 1; i++) { + for (let j = i + 1; j < items.length; j++) { + pairs.push([items[i], items[j]]); + } + } + return pairs; +} + +async function getTemp(name) { + const cwd = await pfs.mkdtemp(os.tmpdir() + path.sep + name); + const tmp = name => path.join(cwd, name); + const config = name => + pfs.copyFile(fixture("config-files-templates", name), tmp(name)); + return { cwd, tmp, config }; +} + describe("buildConfigChain", function() { describe("test", () => { describe("single", () => { @@ -944,111 +998,120 @@ describe("buildConfigChain", function() { } }); - it("should load .babelrc", () => { - const filename = fixture("config-files", "babelrc", "src.js"); - - expect( - loadOptions({ - filename, - cwd: path.dirname(filename), - }), - ).toEqual({ - ...getDefaults(), - filename: filename, - cwd: path.dirname(filename), - root: path.dirname(filename), - comments: true, - }); - }); - - it("should load .babelrc.js", () => { - const filename = fixture("config-files", "babelrc-js", "src.js"); + describe("root", () => { + test.each(["babel.config.json", "babel.config.js", "babel.config.cjs"])( + "should load %s", + async name => { + const { cwd, tmp, config } = await getTemp( + `babel-test-load-config-${name}`, + ); + const filename = tmp("src.js"); + + await config(name); + + expect( + loadOptions({ + filename, + cwd, + }), + ).toEqual({ + ...getDefaults(), + filename, + cwd, + root: cwd, + comments: true, + }); + }, + ); - expect(loadOptions({ filename, cwd: path.dirname(filename) })).toEqual({ - ...getDefaults(), - filename: filename, - cwd: path.dirname(filename), - root: path.dirname(filename), - comments: true, - }); - }); + test.each( + pairs(["babel.config.json", "babel.config.js", "babel.config.cjs"]), + )("should throw if both %s and %s are used", async (name1, name2) => { + const { cwd, tmp, config } = await getTemp( + `babel-test-dup-config-${name1}-${name2}`, + ); - it("should load package.json#babel", () => { - const filename = fixture("config-files", "pkg", "src.js"); + await Promise.all([config(name1), config(name2)]); - expect(loadOptions({ filename, cwd: path.dirname(filename) })).toEqual({ - ...getDefaults(), - filename: filename, - cwd: path.dirname(filename), - root: path.dirname(filename), - comments: true, + expect(() => loadOptions({ filename: tmp("src.js"), cwd })).toThrow( + /Multiple configuration files found/, + ); }); }); - it("should load .babelignore", () => { - const filename = fixture("config-files", "babelignore", "src.js"); - - expect(loadOptions({ filename, cwd: path.dirname(filename) })).toBeNull(); - }); - - it("should throw if there are both .babelrc and .babelrc.js", () => { - const filename = fixture("config-files", "both-babelrc", "src.js"); - - expect(() => - loadOptions({ filename, cwd: path.dirname(filename) }), - ).toThrow(/Multiple configuration files found/); - }); - - it("should throw if there are both .babelrc and package.json", () => { - const filename = fixture("config-files", "pkg-babelrc", "src.js"); + describe("relative", () => { + test.each(["package.json", ".babelrc", ".babelrc.js", ".babelrc.cjs"])( + "should load %s", + async name => { + const { cwd, tmp, config } = await getTemp( + `babel-test-load-config-${name}`, + ); + const filename = tmp("src.js"); + + await config(name); + + expect( + loadOptions({ + filename, + cwd, + }), + ).toEqual({ + ...getDefaults(), + filename, + cwd, + root: cwd, + comments: true, + }); + }, + ); - expect(() => - loadOptions({ filename, cwd: path.dirname(filename) }), - ).toThrow(/Multiple configuration files found/); - }); + it("should load .babelignore", () => { + const filename = fixture("config-files", "babelignore", "src.js"); - it("should throw if there are both .babelrc.js and package.json", () => { - const filename = fixture("config-files", "pkg-babelrc-js", "src.js"); + expect( + loadOptions({ filename, cwd: path.dirname(filename) }), + ).toBeNull(); + }); - expect(() => - loadOptions({ filename, cwd: path.dirname(filename) }), - ).toThrow(/Multiple configuration files found/); - }); + test.each( + pairs(["package.json", ".babelrc", ".babelrc.js", ".babelrc.cjs"]), + )("should throw if both %s and %s are used", async (name1, name2) => { + const { cwd, tmp, config } = await getTemp( + `babel-test-dup-config-${name1}-${name2}`, + ); - it("should ignore package.json without a 'babel' property", () => { - const filename = fixture("config-files", "pkg-ignored", "src.js"); + await Promise.all([config(name1), config(name2)]); - expect(loadOptions({ filename, cwd: path.dirname(filename) })).toEqual({ - ...getDefaults(), - filename: filename, - cwd: path.dirname(filename), - root: path.dirname(filename), - comments: true, + expect(() => loadOptions({ filename: tmp("src.js"), cwd })).toThrow( + /Multiple configuration files found/, + ); }); - }); - - it("should show helpful errors for .babelrc", () => { - const filename = fixture("config-files", "babelrc-error", "src.js"); - expect(() => - loadOptions({ filename, cwd: path.dirname(filename) }), - ).toThrow(/Error while parsing config - /); - }); - - it("should show helpful errors for .babelrc.js", () => { - const filename = fixture("config-files", "babelrc-js-error", "src.js"); + it("should ignore package.json without a 'babel' property", () => { + const filename = fixture("config-files", "pkg-ignored", "src.js"); - expect(() => - loadOptions({ filename, cwd: path.dirname(filename) }), - ).toThrow(/Babelrc threw an error/); - }); + expect(loadOptions({ filename, cwd: path.dirname(filename) })).toEqual({ + ...getDefaults(), + filename: filename, + cwd: path.dirname(filename), + root: path.dirname(filename), + comments: true, + }); + }); - it("should show helpful errors for package.json", () => { - const filename = fixture("config-files", "pkg-error", "src.js"); + test.each` + config | dir | error + ${".babelrc"} | ${"babelrc-error"} | ${/Error while parsing config - /} + ${".babelrc.js"} | ${"babelrc-js-error"} | ${/Babelrc threw an error/} + ${".babelrc.cjs"} | ${"babelrc-cjs-error"} | ${/Babelrc threw an error/} + ${"package.json"} | ${"pkg-error"} | ${/Error while parsing JSON - /} + `("should show helpful errors for $config", ({ dir, error }) => { + const filename = fixture("config-files", dir, "src.js"); - expect(() => - loadOptions({ filename, cwd: path.dirname(filename) }), - ).toThrow(/Error while parsing JSON - /); + expect(() => + loadOptions({ filename, cwd: path.dirname(filename) }), + ).toThrow(error); + }); }); it("should throw when `test` presents but `filename` is not passed", () => { diff --git a/packages/babel-core/test/fixtures/config/config-files-templates/.babelrc b/packages/babel-core/test/fixtures/config/config-files-templates/.babelrc new file mode 100644 index 000000000000..b445e5d66381 --- /dev/null +++ b/packages/babel-core/test/fixtures/config/config-files-templates/.babelrc @@ -0,0 +1,3 @@ +{ + "comments": true +} diff --git a/packages/babel-core/test/fixtures/config/config-files-templates/.babelrc.cjs b/packages/babel-core/test/fixtures/config/config-files-templates/.babelrc.cjs new file mode 100644 index 000000000000..409f4a98ac90 --- /dev/null +++ b/packages/babel-core/test/fixtures/config/config-files-templates/.babelrc.cjs @@ -0,0 +1,3 @@ +module.exports = { + comments: true +}; diff --git a/packages/babel-core/test/fixtures/config/config-files-templates/.babelrc.js b/packages/babel-core/test/fixtures/config/config-files-templates/.babelrc.js new file mode 100644 index 000000000000..409f4a98ac90 --- /dev/null +++ b/packages/babel-core/test/fixtures/config/config-files-templates/.babelrc.js @@ -0,0 +1,3 @@ +module.exports = { + comments: true +}; diff --git a/packages/babel-core/test/fixtures/config/config-files-templates/babel.config.cjs b/packages/babel-core/test/fixtures/config/config-files-templates/babel.config.cjs new file mode 100644 index 000000000000..409f4a98ac90 --- /dev/null +++ b/packages/babel-core/test/fixtures/config/config-files-templates/babel.config.cjs @@ -0,0 +1,3 @@ +module.exports = { + comments: true +}; diff --git a/packages/babel-core/test/fixtures/config/config-files-templates/babel.config.js b/packages/babel-core/test/fixtures/config/config-files-templates/babel.config.js new file mode 100644 index 000000000000..409f4a98ac90 --- /dev/null +++ b/packages/babel-core/test/fixtures/config/config-files-templates/babel.config.js @@ -0,0 +1,3 @@ +module.exports = { + comments: true +}; diff --git a/packages/babel-core/test/fixtures/config/config-files-templates/babel.config.json b/packages/babel-core/test/fixtures/config/config-files-templates/babel.config.json new file mode 100644 index 000000000000..4b7be6033f68 --- /dev/null +++ b/packages/babel-core/test/fixtures/config/config-files-templates/babel.config.json @@ -0,0 +1,3 @@ +{ + "comments": true +} \ No newline at end of file diff --git a/packages/babel-core/test/fixtures/config/config-files/pkg/package.json b/packages/babel-core/test/fixtures/config/config-files-templates/package.json similarity index 100% rename from packages/babel-core/test/fixtures/config/config-files/pkg/package.json rename to packages/babel-core/test/fixtures/config/config-files-templates/package.json diff --git a/packages/babel-core/test/fixtures/config/config-files/babelrc-cjs-error/.babelrc.cjs b/packages/babel-core/test/fixtures/config/config-files/babelrc-cjs-error/.babelrc.cjs new file mode 100644 index 000000000000..accbe7c461f1 --- /dev/null +++ b/packages/babel-core/test/fixtures/config/config-files/babelrc-cjs-error/.babelrc.cjs @@ -0,0 +1,3 @@ +module.exports = function() { + throw new Error("Babelrc threw an error"); +}; diff --git a/packages/babel-core/test/fixtures/config/config-files/babelrc-js/.babelrc.js b/packages/babel-core/test/fixtures/config/config-files/babelrc-js/.babelrc.js deleted file mode 100644 index 37622f0ad309..000000000000 --- a/packages/babel-core/test/fixtures/config/config-files/babelrc-js/.babelrc.js +++ /dev/null @@ -1,3 +0,0 @@ -module.exports = { - comments: true, -}; diff --git a/packages/babel-core/test/fixtures/config/config-files/babelrc/.babelrc b/packages/babel-core/test/fixtures/config/config-files/babelrc/.babelrc deleted file mode 100644 index 2f6b10872c8d..000000000000 --- a/packages/babel-core/test/fixtures/config/config-files/babelrc/.babelrc +++ /dev/null @@ -1,3 +0,0 @@ -{ - comments: true, -} diff --git a/packages/babel-core/test/fixtures/config/config-files/both-babelrc/.babelrc b/packages/babel-core/test/fixtures/config/config-files/both-babelrc/.babelrc deleted file mode 100644 index 0967ef424bce..000000000000 --- a/packages/babel-core/test/fixtures/config/config-files/both-babelrc/.babelrc +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/packages/babel-core/test/fixtures/config/config-files/both-babelrc/.babelrc.js b/packages/babel-core/test/fixtures/config/config-files/both-babelrc/.babelrc.js deleted file mode 100644 index f053ebf7976e..000000000000 --- a/packages/babel-core/test/fixtures/config/config-files/both-babelrc/.babelrc.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = {}; diff --git a/packages/babel-core/test/fixtures/config/config-files/pkg-babelrc-js/.babelrc.js b/packages/babel-core/test/fixtures/config/config-files/pkg-babelrc-js/.babelrc.js deleted file mode 100644 index f053ebf7976e..000000000000 --- a/packages/babel-core/test/fixtures/config/config-files/pkg-babelrc-js/.babelrc.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = {}; diff --git a/packages/babel-core/test/fixtures/config/config-files/pkg-babelrc-js/package.json b/packages/babel-core/test/fixtures/config/config-files/pkg-babelrc-js/package.json deleted file mode 100644 index e25be3ecd260..000000000000 --- a/packages/babel-core/test/fixtures/config/config-files/pkg-babelrc-js/package.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "babel": {} -} diff --git a/packages/babel-core/test/fixtures/config/config-files/pkg-babelrc/.babelrc b/packages/babel-core/test/fixtures/config/config-files/pkg-babelrc/.babelrc deleted file mode 100644 index 0967ef424bce..000000000000 --- a/packages/babel-core/test/fixtures/config/config-files/pkg-babelrc/.babelrc +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/packages/babel-core/test/fixtures/config/config-files/pkg-babelrc/package.json b/packages/babel-core/test/fixtures/config/config-files/pkg-babelrc/package.json deleted file mode 100644 index e25be3ecd260..000000000000 --- a/packages/babel-core/test/fixtures/config/config-files/pkg-babelrc/package.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "babel": {} -} diff --git a/packages/babel-core/test/fixtures/parse/output.json b/packages/babel-core/test/fixtures/parse/output.json index 06fb684869dc..5c48f0e09836 100644 --- a/packages/babel-core/test/fixtures/parse/output.json +++ b/packages/babel-core/test/fixtures/parse/output.json @@ -2,6 +2,7 @@ "type": "File", "start": 0, "end": 91, + "errors": [], "loc": { "start": { "line": 1, diff --git a/packages/babel-core/test/fixtures/transformation/source-maps/input-source-map-external/input.js b/packages/babel-core/test/fixtures/transformation/source-maps/input-source-map-external/input.js new file mode 100644 index 000000000000..f7250b67d0b4 --- /dev/null +++ b/packages/babel-core/test/fixtures/transformation/source-maps/input-source-map-external/input.js @@ -0,0 +1,5 @@ +var foo = function () { + return 4; +}; + +//# sourceMappingURL=input.js.map diff --git a/packages/babel-core/test/fixtures/transformation/source-maps/input-source-map-external/input.js.map b/packages/babel-core/test/fixtures/transformation/source-maps/input-source-map-external/input.js.map new file mode 100644 index 000000000000..cb88961ebdc0 --- /dev/null +++ b/packages/babel-core/test/fixtures/transformation/source-maps/input-source-map-external/input.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["original.js"],"names":[],"mappings":"AAAA,UAAU,Y;SAAM,C;CAAC","sourcesContent":["var foo = () => 4;"]} diff --git a/packages/babel-core/test/fixtures/transformation/source-maps/input-source-map-external/options.json b/packages/babel-core/test/fixtures/transformation/source-maps/input-source-map-external/options.json new file mode 100644 index 000000000000..0e6084f210d8 --- /dev/null +++ b/packages/babel-core/test/fixtures/transformation/source-maps/input-source-map-external/options.json @@ -0,0 +1,3 @@ +{ + "inputSourceMap": true +} diff --git a/packages/babel-core/test/fixtures/transformation/source-maps/input-source-map-external/output.js b/packages/babel-core/test/fixtures/transformation/source-maps/input-source-map-external/output.js new file mode 100644 index 000000000000..cf3efeceb306 --- /dev/null +++ b/packages/babel-core/test/fixtures/transformation/source-maps/input-source-map-external/output.js @@ -0,0 +1,3 @@ +var foo = function () { + return 4; +}; diff --git a/packages/babel-core/test/fixtures/transformation/source-maps/input-source-map-external/source-map.json b/packages/babel-core/test/fixtures/transformation/source-maps/input-source-map-external/source-map.json new file mode 100644 index 000000000000..63c01db5fede --- /dev/null +++ b/packages/babel-core/test/fixtures/transformation/source-maps/input-source-map-external/source-map.json @@ -0,0 +1,7 @@ +{ + "mappings": "AAAA,IAAA,GAAA,GAAU,Y;SAAM,C;AAAC,CAAjB", + "names": [], + "sources": ["original.js"], + "sourcesContent": ["var foo = () => 4;"], + "version": 3 +} diff --git a/packages/babel-generator/package.json b/packages/babel-generator/package.json index 92dc51d1bda9..9d4a96b51756 100644 --- a/packages/babel-generator/package.json +++ b/packages/babel-generator/package.json @@ -1,6 +1,6 @@ { "name": "@babel/generator", - "version": "7.6.4", + "version": "7.7.2", "description": "Turns an AST into code.", "author": "Sebastian McKenzie ", "homepage": "https://babeljs.io/", @@ -14,13 +14,13 @@ "lib" ], "dependencies": { - "@babel/types": "^7.6.3", + "@babel/types": "^7.7.2", "jsesc": "^2.5.1", "lodash": "^4.17.13", "source-map": "^0.5.0" }, "devDependencies": { "@babel/helper-fixtures": "^7.6.3", - "@babel/parser": "^7.6.4" + "@babel/parser": "^7.7.2" } } diff --git a/packages/babel-generator/src/generators/classes.js b/packages/babel-generator/src/generators/classes.js index e8c62339a6d2..1713293369d4 100644 --- a/packages/babel-generator/src/generators/classes.js +++ b/packages/babel-generator/src/generators/classes.js @@ -71,26 +71,8 @@ export function ClassBody(node: Object) { export function ClassProperty(node: Object) { this.printJoin(node.decorators, node); + this.tsPrintClassMemberModifiers(node, /* isField */ true); - if (node.accessibility) { - // TS - this.word(node.accessibility); - this.space(); - } - if (node.static) { - this.word("static"); - this.space(); - } - if (node.abstract) { - // TS - this.word("abstract"); - this.space(); - } - if (node.readonly) { - // TS - this.word("readonly"); - this.space(); - } if (node.computed) { this.token("["); this.print(node.key, node); @@ -148,23 +130,6 @@ export function ClassPrivateMethod(node: Object) { export function _classMethodHead(node) { this.printJoin(node.decorators, node); - - if (node.accessibility) { - // TS - this.word(node.accessibility); - this.space(); - } - - if (node.abstract) { - // TS - this.word("abstract"); - this.space(); - } - - if (node.static) { - this.word("static"); - this.space(); - } - + this.tsPrintClassMemberModifiers(node, /* isField */ false); this._methodHead(node); } diff --git a/packages/babel-generator/src/generators/flow.js b/packages/babel-generator/src/generators/flow.js index 225428b00801..9a8441ba827c 100644 --- a/packages/babel-generator/src/generators/flow.js +++ b/packages/babel-generator/src/generators/flow.js @@ -134,6 +134,92 @@ export function DeclareExportAllDeclaration(/*node: Object*/) { ExportAllDeclaration.apply(this, arguments); } +export function EnumDeclaration(node: Object) { + const { id, body } = node; + this.word("enum"); + this.space(); + this.print(id, node); + this.print(body, node); +} + +function enumExplicitType( + context: Object, + name: string, + hasExplicitType: boolean, +) { + if (hasExplicitType) { + context.space(); + context.word("of"); + context.space(); + context.word(name); + } + context.space(); +} + +function enumBody(context: Object, node: Object) { + const { members } = node; + context.token("{"); + context.indent(); + context.newline(); + for (const member of members) { + context.print(member, node); + context.newline(); + } + context.dedent(); + context.token("}"); +} + +export function EnumBooleanBody(node: Object) { + const { explicitType } = node; + enumExplicitType(this, "boolean", explicitType); + enumBody(this, node); +} + +export function EnumNumberBody(node: Object) { + const { explicitType } = node; + enumExplicitType(this, "number", explicitType); + enumBody(this, node); +} + +export function EnumStringBody(node: Object) { + const { explicitType } = node; + enumExplicitType(this, "string", explicitType); + enumBody(this, node); +} + +export function EnumSymbolBody(node: Object) { + enumExplicitType(this, "symbol", true); + enumBody(this, node); +} + +export function EnumDefaultedMember(node: Object) { + const { id } = node; + this.print(id, node); + this.token(","); +} + +function enumInitializedMember(context: Object, node: Object) { + const { id, init } = node; + context.print(id, node); + context.space(); + context.token("="); + context.space(); + context.print(init, node); + context.token(","); +} + +export function EnumBooleanMember(node: Object) { + enumInitializedMember(this, node); +} + +export function EnumNumberMember(node: Object) { + enumInitializedMember(this, node); +} + +export function EnumStringMember(node: Object) { + enumInitializedMember(this, node); +} + function FlowExportDeclaration(node: Object) { if (node.declaration) { const declar = node.declaration; diff --git a/packages/babel-generator/src/generators/typescript.js b/packages/babel-generator/src/generators/typescript.js index 4ff2fe1ad188..39c580d74d2f 100644 --- a/packages/babel-generator/src/generators/typescript.js +++ b/packages/babel-generator/src/generators/typescript.js @@ -197,11 +197,17 @@ export function TSTypeReference(node) { } export function TSTypePredicate(node) { + if (node.asserts) { + this.word("asserts"); + this.space(); + } this.print(node.parameterName); - this.space(); - this.word("is"); - this.space(); - this.print(node.typeAnnotation.typeAnnotation); + if (node.typeAnnotation) { + this.space(); + this.word("is"); + this.space(); + this.print(node.typeAnnotation.typeAnnotation); + } } export function TSTypeQuery(node) { @@ -550,3 +556,26 @@ export function tsPrintSignatureDeclarationBase(node) { this.token(")"); this.print(node.typeAnnotation, node); } + +export function tsPrintClassMemberModifiers(node, isField) { + if (isField && node.declare) { + this.word("declare"); + this.space(); + } + if (node.accessibility) { + this.word(node.accessibility); + this.space(); + } + if (node.static) { + this.word("static"); + this.space(); + } + if (node.abstract) { + this.word("abstract"); + this.space(); + } + if (isField && node.readonly) { + this.word("readonly"); + this.space(); + } +} diff --git a/packages/babel-generator/test/fixtures/flow/enum-declaration/input.js b/packages/babel-generator/test/fixtures/flow/enum-declaration/input.js new file mode 100644 index 000000000000..f59944f78e18 --- /dev/null +++ b/packages/babel-generator/test/fixtures/flow/enum-declaration/input.js @@ -0,0 +1,36 @@ +enum E { + A = true, + B = false, +} +enum E of boolean { + A = true, + B = false, +} +enum E { + A = 1, + B = 2, +} +enum E of number { + A = 1, + B = 2, +} +enum E { + A, + B, +} +enum E of string { + A, + B, +} +enum E { + A = "a", + B = "b", +} +enum E of string { + A = "a", + B = "b", +} +enum E of symbol { + A, + B, +} diff --git a/packages/babel-generator/test/fixtures/flow/enum-declaration/options.json b/packages/babel-generator/test/fixtures/flow/enum-declaration/options.json new file mode 100644 index 000000000000..53fd48c051cb --- /dev/null +++ b/packages/babel-generator/test/fixtures/flow/enum-declaration/options.json @@ -0,0 +1,3 @@ +{ + "plugins": [["flow", { "enums": true }]] +} diff --git a/packages/babel-generator/test/fixtures/flow/enum-declaration/output.js b/packages/babel-generator/test/fixtures/flow/enum-declaration/output.js new file mode 100644 index 000000000000..f59944f78e18 --- /dev/null +++ b/packages/babel-generator/test/fixtures/flow/enum-declaration/output.js @@ -0,0 +1,36 @@ +enum E { + A = true, + B = false, +} +enum E of boolean { + A = true, + B = false, +} +enum E { + A = 1, + B = 2, +} +enum E of number { + A = 1, + B = 2, +} +enum E { + A, + B, +} +enum E of string { + A, + B, +} +enum E { + A = "a", + B = "b", +} +enum E of string { + A = "a", + B = "b", +} +enum E of symbol { + A, + B, +} diff --git a/packages/babel-generator/test/fixtures/typescript/arrow-function-assertion/input.js b/packages/babel-generator/test/fixtures/typescript/arrow-function-assertion/input.js new file mode 100644 index 000000000000..67e467cda8ed --- /dev/null +++ b/packages/babel-generator/test/fixtures/typescript/arrow-function-assertion/input.js @@ -0,0 +1,2 @@ +(x: any): asserts x => true; +(x: any): asserts x is boolean => true; \ No newline at end of file diff --git a/packages/babel-generator/test/fixtures/typescript/arrow-function-assertion/output.js b/packages/babel-generator/test/fixtures/typescript/arrow-function-assertion/output.js new file mode 100644 index 000000000000..b0befa69dc24 --- /dev/null +++ b/packages/babel-generator/test/fixtures/typescript/arrow-function-assertion/output.js @@ -0,0 +1,3 @@ +(x: any): asserts x => true; + +(x: any): asserts x is boolean => true; \ No newline at end of file diff --git a/packages/babel-generator/test/fixtures/typescript/class-field-declare/input.js b/packages/babel-generator/test/fixtures/typescript/class-field-declare/input.js new file mode 100644 index 000000000000..0e524a92bb8a --- /dev/null +++ b/packages/babel-generator/test/fixtures/typescript/class-field-declare/input.js @@ -0,0 +1,5 @@ +class A { + declare foo; + declare bar: string; + declare readonly bax: number; +} diff --git a/packages/babel-generator/test/fixtures/typescript/class-field-declare/options.json b/packages/babel-generator/test/fixtures/typescript/class-field-declare/options.json new file mode 100644 index 000000000000..9f3a0c2c0ff1 --- /dev/null +++ b/packages/babel-generator/test/fixtures/typescript/class-field-declare/options.json @@ -0,0 +1,4 @@ +{ + "sourceType": "module", + "plugins": ["typescript", "classProperties"] +} diff --git a/packages/babel-generator/test/fixtures/typescript/class-field-declare/output.js b/packages/babel-generator/test/fixtures/typescript/class-field-declare/output.js new file mode 100644 index 000000000000..d1d7b1be56aa --- /dev/null +++ b/packages/babel-generator/test/fixtures/typescript/class-field-declare/output.js @@ -0,0 +1,5 @@ +class A { + declare foo; + declare bar: string; + declare readonly bax: number; +} \ No newline at end of file diff --git a/packages/babel-generator/test/fixtures/typescript/function-assertion/input.js b/packages/babel-generator/test/fixtures/typescript/function-assertion/input.js new file mode 100644 index 000000000000..17db65c5a77f --- /dev/null +++ b/packages/babel-generator/test/fixtures/typescript/function-assertion/input.js @@ -0,0 +1,2 @@ +function f(x: any): asserts x {} +(function(x: any): asserts x is boolean {}) diff --git a/packages/babel-generator/test/fixtures/typescript/function-assertion/output.js b/packages/babel-generator/test/fixtures/typescript/function-assertion/output.js new file mode 100644 index 000000000000..b55c84620cc9 --- /dev/null +++ b/packages/babel-generator/test/fixtures/typescript/function-assertion/output.js @@ -0,0 +1,3 @@ +function f(x: any): asserts x {} + +(function (x: any): asserts x is boolean {}); \ No newline at end of file diff --git a/packages/babel-generator/test/index.js b/packages/babel-generator/test/index.js index 826610d2b85d..e247686e2488 100644 --- a/packages/babel-generator/test/index.js +++ b/packages/babel-generator/test/index.js @@ -197,7 +197,7 @@ describe("generation", function() { const id2 = fn.body.body[0].expression; id2.name += "2"; - id2.loc.identiferName = "bar"; + id2.loc.identifierName = "bar"; const generated = generate( ast, diff --git a/packages/babel-helper-annotate-as-pure/package.json b/packages/babel-helper-annotate-as-pure/package.json index 0ccaace9f494..49ad791e871f 100644 --- a/packages/babel-helper-annotate-as-pure/package.json +++ b/packages/babel-helper-annotate-as-pure/package.json @@ -1,6 +1,6 @@ { "name": "@babel/helper-annotate-as-pure", - "version": "7.0.0", + "version": "7.7.0", "description": "Helper function to annotate paths and nodes with #__PURE__ comment", "repository": "https://github.com/babel/babel/tree/master/packages/babel-helper-annotate-as-pure", "license": "MIT", @@ -9,6 +9,6 @@ }, "main": "lib/index.js", "dependencies": { - "@babel/types": "^7.6.3" + "@babel/types": "^7.7.0" } } diff --git a/packages/babel-helper-bindify-decorators/package.json b/packages/babel-helper-bindify-decorators/package.json index 0b3c4c587696..855c07d721a1 100644 --- a/packages/babel-helper-bindify-decorators/package.json +++ b/packages/babel-helper-bindify-decorators/package.json @@ -1,6 +1,6 @@ { "name": "@babel/helper-bindify-decorators", - "version": "7.1.0", + "version": "7.7.0", "description": "Helper function to bindify decorators", "repository": "https://github.com/babel/babel/tree/master/packages/babel-helper-bindify-decorators", "license": "MIT", @@ -9,7 +9,7 @@ }, "main": "lib/index.js", "dependencies": { - "@babel/traverse": "^7.1.0", - "@babel/types": "^7.6.3" + "@babel/traverse": "^7.7.0", + "@babel/types": "^7.7.0" } } diff --git a/packages/babel-helper-builder-binary-assignment-operator-visitor/package.json b/packages/babel-helper-builder-binary-assignment-operator-visitor/package.json index f52081203a1e..de2fdf665951 100644 --- a/packages/babel-helper-builder-binary-assignment-operator-visitor/package.json +++ b/packages/babel-helper-builder-binary-assignment-operator-visitor/package.json @@ -1,6 +1,6 @@ { "name": "@babel/helper-builder-binary-assignment-operator-visitor", - "version": "7.1.0", + "version": "7.7.0", "description": "Helper function to build binary assignment operator visitors", "repository": "https://github.com/babel/babel/tree/master/packages/babel-helper-builder-binary-assignment-operator-visitor", "license": "MIT", @@ -9,7 +9,7 @@ }, "main": "lib/index.js", "dependencies": { - "@babel/helper-explode-assignable-expression": "^7.1.0", - "@babel/types": "^7.6.3" + "@babel/helper-explode-assignable-expression": "^7.7.0", + "@babel/types": "^7.7.0" } } diff --git a/packages/babel-helper-builder-react-jsx/package.json b/packages/babel-helper-builder-react-jsx/package.json index cf082d88cf9c..d0d46f8fecb1 100644 --- a/packages/babel-helper-builder-react-jsx/package.json +++ b/packages/babel-helper-builder-react-jsx/package.json @@ -1,6 +1,6 @@ { "name": "@babel/helper-builder-react-jsx", - "version": "7.3.0", + "version": "7.7.0", "description": "Helper function to build react jsx", "repository": "https://github.com/babel/babel/tree/master/packages/babel-helper-builder-react-jsx", "license": "MIT", @@ -9,7 +9,7 @@ }, "main": "lib/index.js", "dependencies": { - "@babel/types": "^7.6.3", + "@babel/types": "^7.7.0", "esutils": "^2.0.0" } } diff --git a/packages/babel-helper-builder-react-jsx/src/index.js b/packages/babel-helper-builder-react-jsx/src/index.js index 3602ecb8496e..64b136923f45 100644 --- a/packages/babel-helper-builder-react-jsx/src/index.js +++ b/packages/babel-helper-builder-react-jsx/src/index.js @@ -87,13 +87,15 @@ You can turn on the 'throwIfNamespace' flag to bypass this warning.`, function convertAttribute(node) { const value = convertAttributeValue(node.value || t.booleanLiteral(true)); + if (t.isJSXSpreadAttribute(node)) { + return t.spreadElement(node.argument); + } + if (t.isStringLiteral(value) && !t.isJSXExpressionContainer(node.value)) { value.value = value.value.replace(/\n\s+/g, " "); // "raw" JSXText should not be used from a StringLiteral because it needs to be escaped. - if (value.extra && value.extra.raw) { - delete value.extra.raw; - } + delete value.extra?.raw; } if (t.isJSXNamespacedName(node.name)) { @@ -172,6 +174,14 @@ You can turn on the 'throwIfNamespace' flag to bypass this warning.`, let _props = []; const objs = []; + const { useSpread = false } = file.opts; + if (typeof useSpread !== "boolean") { + throw new Error( + "transform-react-jsx currently only accepts a boolean option for " + + "useSpread (defaults to false)", + ); + } + const useBuiltIns = file.opts.useBuiltIns || false; if (typeof useBuiltIns !== "boolean") { throw new Error( @@ -180,6 +190,18 @@ You can turn on the 'throwIfNamespace' flag to bypass this warning.`, ); } + if (useSpread && useBuiltIns) { + throw new Error( + "transform-react-jsx currently only accepts useBuiltIns or useSpread " + + "but not both", + ); + } + + if (useSpread) { + const props = attribs.map(convertAttribute); + return t.objectExpression(props); + } + while (attribs.length) { const prop = attribs.shift(); if (t.isJSXSpreadAttribute(prop)) { diff --git a/packages/babel-helper-call-delegate/package.json b/packages/babel-helper-call-delegate/package.json index c7e9e0222d25..e978c18e56b5 100644 --- a/packages/babel-helper-call-delegate/package.json +++ b/packages/babel-helper-call-delegate/package.json @@ -1,6 +1,6 @@ { "name": "@babel/helper-call-delegate", - "version": "7.4.4", + "version": "7.7.0", "description": "Helper function to call delegate", "repository": "https://github.com/babel/babel/tree/master/packages/babel-helper-call-delegate", "license": "MIT", @@ -9,8 +9,8 @@ }, "main": "lib/index.js", "dependencies": { - "@babel/helper-hoist-variables": "^7.4.4", - "@babel/traverse": "^7.4.4", - "@babel/types": "^7.6.3" + "@babel/helper-hoist-variables": "^7.7.0", + "@babel/traverse": "^7.7.0", + "@babel/types": "^7.7.0" } } diff --git a/packages/babel-helper-create-class-features-plugin/package.json b/packages/babel-helper-create-class-features-plugin/package.json index 3884dece47f5..10a9d838580a 100644 --- a/packages/babel-helper-create-class-features-plugin/package.json +++ b/packages/babel-helper-create-class-features-plugin/package.json @@ -1,6 +1,6 @@ { "name": "@babel/helper-create-class-features-plugin", - "version": "7.6.0", + "version": "7.7.0", "author": "The Babel Team (https://babeljs.io/team)", "license": "MIT", "description": "Compile class public and private fields, private methods and decorators to ES6", @@ -14,18 +14,18 @@ "babel-plugin" ], "dependencies": { - "@babel/helper-function-name": "^7.1.0", - "@babel/helper-member-expression-to-functions": "^7.5.5", - "@babel/helper-optimise-call-expression": "^7.0.0", + "@babel/helper-function-name": "^7.7.0", + "@babel/helper-member-expression-to-functions": "^7.7.0", + "@babel/helper-optimise-call-expression": "^7.7.0", "@babel/helper-plugin-utils": "^7.0.0", - "@babel/helper-replace-supers": "^7.5.5", - "@babel/helper-split-export-declaration": "^7.4.4" + "@babel/helper-replace-supers": "^7.7.0", + "@babel/helper-split-export-declaration": "^7.7.0" }, "peerDependencies": { "@babel/core": "^7.0.0" }, "devDependencies": { - "@babel/core": "^7.6.0", + "@babel/core": "^7.7.0", "@babel/helper-plugin-test-runner": "^7.0.0" } } diff --git a/packages/babel-helper-create-class-features-plugin/src/fields.js b/packages/babel-helper-create-class-features-plugin/src/fields.js index 4cdaccd1bbb5..167e894cae33 100644 --- a/packages/babel-helper-create-class-features-plugin/src/fields.js +++ b/packages/babel-helper-create-class-features-plugin/src/fields.js @@ -5,6 +5,8 @@ import ReplaceSupers, { import memberExpressionToFunctions from "@babel/helper-member-expression-to-functions"; import optimiseCall from "@babel/helper-optimise-call-expression"; +import * as ts from "./typescript"; + export function buildPrivateNamesMap(props) { const privateNamesMap = new Map(); for (const prop of props) { @@ -556,6 +558,8 @@ export function buildFieldsInitNodes( let needsClassRef = false; for (const prop of props) { + ts.assertFieldTransformed(prop); + const isStatic = prop.node.static; const isInstance = !isStatic; const isPrivate = prop.isPrivate(); diff --git a/packages/babel-helper-create-class-features-plugin/src/typescript.js b/packages/babel-helper-create-class-features-plugin/src/typescript.js new file mode 100644 index 000000000000..c18f0ea17389 --- /dev/null +++ b/packages/babel-helper-create-class-features-plugin/src/typescript.js @@ -0,0 +1,19 @@ +// @flow + +import type { NodePath } from "@babel/traverse"; + +export function assertFieldTransformed(path: NodePath) { + // TODO (Babel 8): Also check path.node.definite + + if (path.node.declare) { + throw path.buildCodeFrameError( + `TypeScript 'declare' fields must first be transformed by ` + + `@babel/plugin-transform-typescript.\n` + + `If you have already enabled that plugin (or '@babel/preset-typescript'), make sure ` + + `that it runs before any plugin related to additional class features:\n` + + ` - @babel/plugin-proposal-class-properties\n` + + ` - @babel/plugin-proposal-private-methods\n` + + ` - @babel/plugin-proposal-decorators`, + ); + } +} diff --git a/packages/babel-helper-create-regexp-features-plugin/.npmignore b/packages/babel-helper-create-regexp-features-plugin/.npmignore new file mode 100644 index 000000000000..f9806945836e --- /dev/null +++ b/packages/babel-helper-create-regexp-features-plugin/.npmignore @@ -0,0 +1,3 @@ +src +test +*.log diff --git a/packages/babel-helper-create-regexp-features-plugin/README.md b/packages/babel-helper-create-regexp-features-plugin/README.md new file mode 100644 index 000000000000..69f661bd987e --- /dev/null +++ b/packages/babel-helper-create-regexp-features-plugin/README.md @@ -0,0 +1,19 @@ +# @babel/helper-create-regexp-features-plugin + +> Compile ESNext Regular Expressions to ES5 + +See our website [@babel/helper-create-regexp-features-plugin](https://babeljs.io/docs/en/next/babel-helper-create-regexp-features-plugin.html) for more information. + +## Install + +Using npm: + +```sh +npm install --save-dev @babel/helper-create-regexp-features-plugin +``` + +or using yarn: + +```sh +yarn add @babel/helper-create-regexp-features-plugin --dev +``` diff --git a/packages/babel-helper-create-regexp-features-plugin/package.json b/packages/babel-helper-create-regexp-features-plugin/package.json new file mode 100644 index 000000000000..c0e278155fce --- /dev/null +++ b/packages/babel-helper-create-regexp-features-plugin/package.json @@ -0,0 +1,31 @@ +{ + "name": "@babel/helper-create-regexp-features-plugin", + "version": "7.7.2", + "author": "The Babel Team (https://babeljs.io/team)", + "license": "MIT", + "description": "Compile ESNext Regular Expressions to ES5", + "repository": { + "type": "git", + "url": "https://github.com/babel/babel", + "directory": "packages/babel-helper-create-regexp-features-plugin" + }, + "main": "lib/index.js", + "publishConfig": { + "access": "public" + }, + "keywords": [ + "babel", + "babel-plugin" + ], + "dependencies": { + "@babel/helper-regex": "^7.4.4", + "regexpu-core": "^4.6.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0" + }, + "devDependencies": { + "@babel/core": "^7.7.2", + "@babel/helper-plugin-test-runner": "^7.0.0" + } +} diff --git a/packages/babel-helper-create-regexp-features-plugin/src/features.js b/packages/babel-helper-create-regexp-features-plugin/src/features.js new file mode 100644 index 000000000000..8e82b1342e88 --- /dev/null +++ b/packages/babel-helper-create-regexp-features-plugin/src/features.js @@ -0,0 +1,27 @@ +// @flow +export const FEATURES = Object.freeze({ + unicodeFlag: 1 << 0, + dotAllFlag: 1 << 1, + unicodePropertyEscape: 1 << 2, + namedCaptureGroups: 1 << 3, +}); + +// We can't use a symbol because this needs to always be the same, even if +// this package isn't deduped by npm. e.g. +// - node_modules/ +// - @babel/plugin-regexp-features +// - @babel/plugin-proposal-unicode-property-regex +// - node_modules +// - @babel-plugin-regexp-features +export const featuresKey = "@babel/plugin-regexp-features/featuresKey"; +export const runtimeKey = "@babel/plugin-regexp-features/runtimeKey"; + +type FeatureType = $Values; + +export function enableFeature(features: number, feature: FeatureType): number { + return features | feature; +} + +export function hasFeature(features: number, feature: FeatureType) { + return !!(features & feature); +} diff --git a/packages/babel-helper-create-regexp-features-plugin/src/index.js b/packages/babel-helper-create-regexp-features-plugin/src/index.js new file mode 100644 index 000000000000..49554be42ad2 --- /dev/null +++ b/packages/babel-helper-create-regexp-features-plugin/src/index.js @@ -0,0 +1,96 @@ +import rewritePattern from "regexpu-core"; +import { + featuresKey, + FEATURES, + enableFeature, + runtimeKey, + hasFeature, +} from "./features"; +import { generateRegexpuOptions } from "./util"; + +import pkg from "../package.json"; +import { types as t } from "@babel/core"; +import { pullFlag } from "@babel/helper-regex"; + +// Note: Versions are represented as an integer. e.g. 7.1.5 is represented +// as 70000100005. This method is easier than using a semver-parsing +// package, but it breaks if we release x.y.z where x, y or z are +// greater than 99_999. +const version = pkg.version.split(".").reduce((v, x) => v * 1e5 + +x, 0); +const versionKey = "@babel/plugin-regexp-features/version"; + +export function createRegExpFeaturePlugin({ name, feature, options = {} }) { + return { + name, + pre() { + const { file } = this; + const features = file.get(featuresKey) ?? 0; + let newFeatures = enableFeature(features, FEATURES[feature]); + + const { useUnicodeFlag, runtime = true } = options; + if (useUnicodeFlag === false) { + newFeatures = enableFeature(newFeatures, FEATURES.unicodeFlag); + } + if (newFeatures !== features) { + file.set(featuresKey, newFeatures); + } + + if (!runtime) { + file.set(runtimeKey, false); + } + + if (!file.has(versionKey) || file.get(versionKey) < version) { + file.set(versionKey, version); + } + }, + + visitor: { + RegExpLiteral(path) { + const { node } = path; + const { file } = this; + const features = file.get(featuresKey); + const runtime = file.get(runtimeKey) ?? true; + const regexpuOptions = generateRegexpuOptions(node, features); + if (regexpuOptions === null) { + return; + } + const namedCaptureGroups = {}; + if (regexpuOptions.namedGroup) { + regexpuOptions.onNamedGroup = (name, index) => { + namedCaptureGroups[name] = index; + }; + } + node.pattern = rewritePattern(node.pattern, node.flags, regexpuOptions); + + if ( + regexpuOptions.namedGroup && + Object.keys(namedCaptureGroups).length > 0 && + runtime && + !isRegExpTest(path) + ) { + path.replaceWith( + t.callExpression(this.addHelper("wrapRegExp"), [ + node, + t.valueToNode(namedCaptureGroups), + ]), + ); + } + if (hasFeature(features, FEATURES.unicodeFlag)) { + pullFlag(node, "u"); + } + if (hasFeature(features, FEATURES.dotAllFlag)) { + pullFlag(node, "s"); + } + }, + }, + }; +} + +function isRegExpTest(path) { + return ( + path.parentPath.isMemberExpression({ + object: path.node, + computed: false, + }) && path.parentPath.get("property").isIdentifier({ name: "test" }) + ); +} diff --git a/packages/babel-helper-create-regexp-features-plugin/src/util.js b/packages/babel-helper-create-regexp-features-plugin/src/util.js new file mode 100644 index 000000000000..bc6f89dcebce --- /dev/null +++ b/packages/babel-helper-create-regexp-features-plugin/src/util.js @@ -0,0 +1,56 @@ +import { FEATURES, hasFeature } from "./features"; + +export function generateRegexpuOptions(node, features) { + let useUnicodeFlag = false, + dotAllFlag = false, + unicodePropertyEscape = false, + namedGroup = false; + const { flags, pattern } = node; + const flagsIncludesU = flags.includes("u"); + + if (flagsIncludesU) { + if (!hasFeature(features, FEATURES.unicodeFlag)) { + useUnicodeFlag = true; + } + if ( + hasFeature(features, FEATURES.unicodePropertyEscape) && + /\\[pP]{/.test(pattern) + ) { + unicodePropertyEscape = true; + } + } + + if (hasFeature(features, FEATURES.dotAllFlag) && flags.indexOf("s") >= 0) { + dotAllFlag = true; + } + if ( + hasFeature(features, FEATURES.namedCaptureGroups) && + /\(\?<(?![=!])/.test(pattern) + ) { + namedGroup = true; + } + if ( + !namedGroup && + !unicodePropertyEscape && + !dotAllFlag && + (!flagsIncludesU || useUnicodeFlag) + ) { + return null; + } + // Now we have to feed regexpu-core the regex + if (flagsIncludesU && flags.indexOf("s") >= 0) { + // When flags includes u, `config.unicode` will be enabled even if `u` is supported natively. + // In this case we have to enable dotAllFlag, otherwise `rewritePattern(/./su)` will return + // incorrect result + // https://github.com/mathiasbynens/regexpu-core/blob/v4.6.0/rewrite-pattern.js#L191 + dotAllFlag = true; + } + return { + useUnicodeFlag, + onNamedGroup: () => {}, + namedGroup, + unicodePropertyEscape, + dotAllFlag, + lookbehind: true, + }; +} diff --git a/packages/babel-helper-create-regexp-features-plugin/test/fixtures/plugin-proposal-unicode-property-regex/use-unicode-flag-false-not-overwritten/input.mjs b/packages/babel-helper-create-regexp-features-plugin/test/fixtures/plugin-proposal-unicode-property-regex/use-unicode-flag-false-not-overwritten/input.mjs new file mode 100644 index 000000000000..f972b98245a9 --- /dev/null +++ b/packages/babel-helper-create-regexp-features-plugin/test/fixtures/plugin-proposal-unicode-property-regex/use-unicode-flag-false-not-overwritten/input.mjs @@ -0,0 +1 @@ +/\p{Script_Extensions=Wancho}/u diff --git a/packages/babel-helper-create-regexp-features-plugin/test/fixtures/plugin-proposal-unicode-property-regex/use-unicode-flag-false-not-overwritten/options.json b/packages/babel-helper-create-regexp-features-plugin/test/fixtures/plugin-proposal-unicode-property-regex/use-unicode-flag-false-not-overwritten/options.json new file mode 100644 index 000000000000..d1c7bd8740ad --- /dev/null +++ b/packages/babel-helper-create-regexp-features-plugin/test/fixtures/plugin-proposal-unicode-property-regex/use-unicode-flag-false-not-overwritten/options.json @@ -0,0 +1,6 @@ +{ + "plugins": [ + ["proposal-unicode-property-regex", { "useUnicodeFlag": false }, "name 1"], + ["proposal-unicode-property-regex", { "useUnicodeFlag": true }, "name 2"] + ] +} diff --git a/packages/babel-helper-create-regexp-features-plugin/test/fixtures/plugin-proposal-unicode-property-regex/use-unicode-flag-false-not-overwritten/output.mjs b/packages/babel-helper-create-regexp-features-plugin/test/fixtures/plugin-proposal-unicode-property-regex/use-unicode-flag-false-not-overwritten/output.mjs new file mode 100644 index 000000000000..f43a80b8405b --- /dev/null +++ b/packages/babel-helper-create-regexp-features-plugin/test/fixtures/plugin-proposal-unicode-property-regex/use-unicode-flag-false-not-overwritten/output.mjs @@ -0,0 +1 @@ +/(?:\uD838[\uDEC0-\uDEF9\uDEFF])/; diff --git a/packages/babel-helper-create-regexp-features-plugin/test/fixtures/plugin-transform-named-capturing-groups-regex/runtime-false-not-overwritten/input.mjs b/packages/babel-helper-create-regexp-features-plugin/test/fixtures/plugin-transform-named-capturing-groups-regex/runtime-false-not-overwritten/input.mjs new file mode 100644 index 000000000000..3d7f5b1517b5 --- /dev/null +++ b/packages/babel-helper-create-regexp-features-plugin/test/fixtures/plugin-transform-named-capturing-groups-regex/runtime-false-not-overwritten/input.mjs @@ -0,0 +1 @@ +/(?\d{4})/ diff --git a/packages/babel-helper-create-regexp-features-plugin/test/fixtures/plugin-transform-named-capturing-groups-regex/runtime-false-not-overwritten/options.json b/packages/babel-helper-create-regexp-features-plugin/test/fixtures/plugin-transform-named-capturing-groups-regex/runtime-false-not-overwritten/options.json new file mode 100644 index 000000000000..ca279789330b --- /dev/null +++ b/packages/babel-helper-create-regexp-features-plugin/test/fixtures/plugin-transform-named-capturing-groups-regex/runtime-false-not-overwritten/options.json @@ -0,0 +1,6 @@ +{ + "plugins": [ + ["transform-named-capturing-groups-regex", { "runtime": false }, "name 1"], + ["transform-named-capturing-groups-regex", { "runtime": true }, "name 2"] + ] +} diff --git a/packages/babel-helper-create-regexp-features-plugin/test/fixtures/plugin-transform-named-capturing-groups-regex/runtime-false-not-overwritten/output.mjs b/packages/babel-helper-create-regexp-features-plugin/test/fixtures/plugin-transform-named-capturing-groups-regex/runtime-false-not-overwritten/output.mjs new file mode 100644 index 000000000000..f47a50b38088 --- /dev/null +++ b/packages/babel-helper-create-regexp-features-plugin/test/fixtures/plugin-transform-named-capturing-groups-regex/runtime-false-not-overwritten/output.mjs @@ -0,0 +1 @@ +/([0-9]{4})/; diff --git a/packages/babel-helper-create-regexp-features-plugin/test/index.js b/packages/babel-helper-create-regexp-features-plugin/test/index.js new file mode 100644 index 000000000000..1b534b8fc64a --- /dev/null +++ b/packages/babel-helper-create-regexp-features-plugin/test/index.js @@ -0,0 +1,3 @@ +import runner from "@babel/helper-plugin-test-runner"; + +runner(__dirname); diff --git a/packages/babel-helper-define-map/package.json b/packages/babel-helper-define-map/package.json index ac574448da1f..dd8f635f8fc2 100644 --- a/packages/babel-helper-define-map/package.json +++ b/packages/babel-helper-define-map/package.json @@ -1,6 +1,6 @@ { "name": "@babel/helper-define-map", - "version": "7.5.5", + "version": "7.7.0", "description": "Helper function to define a map", "repository": "https://github.com/babel/babel/tree/master/packages/babel-helper-define-map", "license": "MIT", @@ -9,8 +9,8 @@ }, "main": "lib/index.js", "dependencies": { - "@babel/helper-function-name": "^7.1.0", - "@babel/types": "^7.6.3", + "@babel/helper-function-name": "^7.7.0", + "@babel/types": "^7.7.0", "lodash": "^4.17.13" } } diff --git a/packages/babel-helper-explode-assignable-expression/package.json b/packages/babel-helper-explode-assignable-expression/package.json index 8cbf2aaeb781..3dd23b0405c3 100644 --- a/packages/babel-helper-explode-assignable-expression/package.json +++ b/packages/babel-helper-explode-assignable-expression/package.json @@ -1,6 +1,6 @@ { "name": "@babel/helper-explode-assignable-expression", - "version": "7.1.0", + "version": "7.7.0", "description": "Helper function to explode an assignable expression", "repository": "https://github.com/babel/babel/tree/master/packages/babel-helper-explode-assignable-expression", "license": "MIT", @@ -9,7 +9,7 @@ }, "main": "lib/index.js", "dependencies": { - "@babel/traverse": "^7.1.0", - "@babel/types": "^7.6.3" + "@babel/traverse": "^7.7.0", + "@babel/types": "^7.7.0" } } diff --git a/packages/babel-helper-explode-class/package.json b/packages/babel-helper-explode-class/package.json index 630951905259..a30a169acc57 100644 --- a/packages/babel-helper-explode-class/package.json +++ b/packages/babel-helper-explode-class/package.json @@ -1,6 +1,6 @@ { "name": "@babel/helper-explode-class", - "version": "7.1.0", + "version": "7.7.0", "description": "Helper function to explode class", "repository": "https://github.com/babel/babel/tree/master/packages/babel-helper-explode-class", "license": "MIT", @@ -9,8 +9,8 @@ }, "main": "lib/index.js", "dependencies": { - "@babel/helper-bindify-decorators": "^7.1.0", - "@babel/traverse": "^7.1.0", - "@babel/types": "^7.6.3" + "@babel/helper-bindify-decorators": "^7.7.0", + "@babel/traverse": "^7.7.0", + "@babel/types": "^7.7.0" } } diff --git a/packages/babel-helper-function-name/package.json b/packages/babel-helper-function-name/package.json index ab39d5f4d5db..c4a46b4c9279 100644 --- a/packages/babel-helper-function-name/package.json +++ b/packages/babel-helper-function-name/package.json @@ -1,6 +1,6 @@ { "name": "@babel/helper-function-name", - "version": "7.1.0", + "version": "7.7.0", "description": "Helper function to change the property 'name' of every function", "repository": "https://github.com/babel/babel/tree/master/packages/babel-helper-function-name", "license": "MIT", @@ -9,8 +9,8 @@ }, "main": "lib/index.js", "dependencies": { - "@babel/helper-get-function-arity": "^7.0.0", - "@babel/template": "^7.1.0", - "@babel/types": "^7.6.3" + "@babel/helper-get-function-arity": "^7.7.0", + "@babel/template": "^7.7.0", + "@babel/types": "^7.7.0" } } diff --git a/packages/babel-helper-get-function-arity/package.json b/packages/babel-helper-get-function-arity/package.json index ec3f4a85c2cf..a9ab2ebebed2 100644 --- a/packages/babel-helper-get-function-arity/package.json +++ b/packages/babel-helper-get-function-arity/package.json @@ -1,6 +1,6 @@ { "name": "@babel/helper-get-function-arity", - "version": "7.0.0", + "version": "7.7.0", "description": "Helper function to get function arity", "repository": "https://github.com/babel/babel/tree/master/packages/babel-helper-get-function-arity", "license": "MIT", @@ -9,6 +9,6 @@ }, "main": "lib/index.js", "dependencies": { - "@babel/types": "^7.6.3" + "@babel/types": "^7.7.0" } } diff --git a/packages/babel-helper-hoist-variables/package.json b/packages/babel-helper-hoist-variables/package.json index 98cb86eec955..51acf5b0def5 100644 --- a/packages/babel-helper-hoist-variables/package.json +++ b/packages/babel-helper-hoist-variables/package.json @@ -1,6 +1,6 @@ { "name": "@babel/helper-hoist-variables", - "version": "7.4.4", + "version": "7.7.0", "description": "Helper function to hoist variables", "repository": "https://github.com/babel/babel/tree/master/packages/babel-helper-hoist-variables", "license": "MIT", @@ -9,6 +9,6 @@ }, "main": "lib/index.js", "dependencies": { - "@babel/types": "^7.6.3" + "@babel/types": "^7.7.0" } } diff --git a/packages/babel-helper-member-expression-to-functions/package.json b/packages/babel-helper-member-expression-to-functions/package.json index 571c84a18a7b..ddf3f9e002ce 100644 --- a/packages/babel-helper-member-expression-to-functions/package.json +++ b/packages/babel-helper-member-expression-to-functions/package.json @@ -1,6 +1,6 @@ { "name": "@babel/helper-member-expression-to-functions", - "version": "7.5.5", + "version": "7.7.0", "description": "Helper function to replace certain member expressions with function calls", "repository": "https://github.com/babel/babel/tree/master/packages/babel-helper-member-expression-to-functions", "license": "MIT", @@ -10,6 +10,6 @@ "main": "lib/index.js", "author": "Justin Ridgewell ", "dependencies": { - "@babel/types": "^7.6.3" + "@babel/types": "^7.7.0" } } diff --git a/packages/babel-helper-module-imports/package.json b/packages/babel-helper-module-imports/package.json index 7e6bad8b26c9..ee5f134217e3 100644 --- a/packages/babel-helper-module-imports/package.json +++ b/packages/babel-helper-module-imports/package.json @@ -1,6 +1,6 @@ { "name": "@babel/helper-module-imports", - "version": "7.0.0", + "version": "7.7.0", "description": "Babel helper functions for inserting module loads", "author": "Logan Smyth ", "homepage": "https://babeljs.io/", @@ -11,9 +11,9 @@ "repository": "https://github.com/babel/babel/tree/master/packages/babel-helper-module-imports", "main": "lib/index.js", "dependencies": { - "@babel/types": "^7.6.3" + "@babel/types": "^7.7.0" }, "devDependencies": { - "@babel/core": "^7.0.0" + "@babel/core": "^7.7.0" } } diff --git a/packages/babel-helper-module-imports/src/import-injector.js b/packages/babel-helper-module-imports/src/import-injector.js index 0e38f9188ab9..59375b6c9cac 100644 --- a/packages/babel-helper-module-imports/src/import-injector.js +++ b/packages/babel-helper-module-imports/src/import-injector.js @@ -417,10 +417,10 @@ export default class ImportInjector { node._blockHoist = blockHoist; }); - const targetPath = this._programPath.get("body").filter(p => { + const targetPath = this._programPath.get("body").find(p => { const val = p.node._blockHoist; return Number.isFinite(val) && val < 4; - })[0]; + }); if (targetPath) { targetPath.insertBefore(statements); diff --git a/packages/babel-helper-module-transforms/package.json b/packages/babel-helper-module-transforms/package.json index f8f7ef94092a..7d1e61d78dfa 100644 --- a/packages/babel-helper-module-transforms/package.json +++ b/packages/babel-helper-module-transforms/package.json @@ -1,6 +1,6 @@ { "name": "@babel/helper-module-transforms", - "version": "7.5.5", + "version": "7.7.0", "description": "Babel helper functions for implementing ES6 module transformations", "author": "Logan Smyth ", "homepage": "https://babeljs.io/", @@ -11,11 +11,11 @@ "repository": "https://github.com/babel/babel/tree/master/packages/babel-helper-module-transforms", "main": "lib/index.js", "dependencies": { - "@babel/helper-module-imports": "^7.0.0", - "@babel/helper-simple-access": "^7.1.0", - "@babel/helper-split-export-declaration": "^7.4.4", - "@babel/template": "^7.4.4", - "@babel/types": "^7.6.3", + "@babel/helper-module-imports": "^7.7.0", + "@babel/helper-simple-access": "^7.7.0", + "@babel/helper-split-export-declaration": "^7.7.0", + "@babel/template": "^7.7.0", + "@babel/types": "^7.7.0", "lodash": "^4.17.13" } } diff --git a/packages/babel-helper-module-transforms/src/rewrite-live-references.js b/packages/babel-helper-module-transforms/src/rewrite-live-references.js index 185ba9142220..8bd93f509c25 100644 --- a/packages/babel-helper-module-transforms/src/rewrite-live-references.js +++ b/packages/babel-helper-module-transforms/src/rewrite-live-references.js @@ -224,6 +224,10 @@ const rewriteReferencesVisitor = { seen.add(path.node); const left = path.get("left"); + + // No change needed + if (left.isMemberExpression()) return; + if (left.isIdentifier()) { // Simple update-assign foo += 1; export { foo }; // => exports.foo = (foo += 1); @@ -234,9 +238,9 @@ const rewriteReferencesVisitor = { return; } - const exportedNames = exported.get(localName) || []; + const exportedNames = exported.get(localName); const importData = imported.get(localName); - if (exportedNames.length > 0 || importData) { + if (exportedNames?.length > 0 || importData) { assert(path.node.operator === "=", "Path was not simplified"); const assignment = path.node; @@ -259,13 +263,14 @@ const rewriteReferencesVisitor = { ); requeueInParent(path); } - } else if (left.isMemberExpression()) { - // No change needed } else { const ids = left.getOuterBindingIdentifiers(); - const id = Object.keys(ids) - .filter(localName => imported.has(localName)) - .pop(); + const programScopeIds = Object.keys(ids).filter( + localName => + scope.getBinding(localName) === path.scope.getBinding(localName), + ); + const id = programScopeIds.find(localName => imported.has(localName)); + if (id) { path.node.right = t.sequenceExpression([ path.node.right, @@ -276,14 +281,7 @@ const rewriteReferencesVisitor = { // Complex ({a, b, c} = {}); export { a, c }; // => ({a, b, c} = {}), (exports.a = a, exports.c = c); const items = []; - Object.keys(ids).forEach(localName => { - // redeclared in this scope - if ( - scope.getBinding(localName) !== path.scope.getBinding(localName) - ) { - return; - } - + programScopeIds.forEach(localName => { const exportedNames = exported.get(localName) || []; if (exportedNames.length > 0) { items.push( diff --git a/packages/babel-helper-optimise-call-expression/package.json b/packages/babel-helper-optimise-call-expression/package.json index 9c9245260c78..374d7d4ba5f2 100644 --- a/packages/babel-helper-optimise-call-expression/package.json +++ b/packages/babel-helper-optimise-call-expression/package.json @@ -1,6 +1,6 @@ { "name": "@babel/helper-optimise-call-expression", - "version": "7.0.0", + "version": "7.7.0", "description": "Helper function to optimise call expression", "repository": "https://github.com/babel/babel/tree/master/packages/babel-helper-optimise-call-expression", "license": "MIT", @@ -9,6 +9,6 @@ }, "main": "lib/index.js", "dependencies": { - "@babel/types": "^7.6.3" + "@babel/types": "^7.7.0" } } diff --git a/packages/babel-helper-remap-async-to-generator/package.json b/packages/babel-helper-remap-async-to-generator/package.json index e0033b85c2c4..09149e3704de 100644 --- a/packages/babel-helper-remap-async-to-generator/package.json +++ b/packages/babel-helper-remap-async-to-generator/package.json @@ -1,6 +1,6 @@ { "name": "@babel/helper-remap-async-to-generator", - "version": "7.1.0", + "version": "7.7.0", "description": "Helper function to remap async functions to generators", "repository": "https://github.com/babel/babel/tree/master/packages/babel-helper-remap-async-to-generator", "license": "MIT", @@ -9,10 +9,10 @@ }, "main": "lib/index.js", "dependencies": { - "@babel/helper-annotate-as-pure": "^7.0.0", - "@babel/helper-wrap-function": "^7.1.0", - "@babel/template": "^7.1.0", - "@babel/traverse": "^7.1.0", - "@babel/types": "^7.6.3" + "@babel/helper-annotate-as-pure": "^7.7.0", + "@babel/helper-wrap-function": "^7.7.0", + "@babel/template": "^7.7.0", + "@babel/traverse": "^7.7.0", + "@babel/types": "^7.7.0" } } diff --git a/packages/babel-helper-replace-supers/package.json b/packages/babel-helper-replace-supers/package.json index b762e5ea0f2a..1291e2a4a9a2 100644 --- a/packages/babel-helper-replace-supers/package.json +++ b/packages/babel-helper-replace-supers/package.json @@ -1,6 +1,6 @@ { "name": "@babel/helper-replace-supers", - "version": "7.5.5", + "version": "7.7.0", "description": "Helper function to replace supers", "repository": "https://github.com/babel/babel/tree/master/packages/babel-helper-replace-supers", "license": "MIT", @@ -9,9 +9,9 @@ }, "main": "lib/index.js", "dependencies": { - "@babel/helper-member-expression-to-functions": "^7.5.5", - "@babel/helper-optimise-call-expression": "^7.0.0", - "@babel/traverse": "^7.5.5", - "@babel/types": "^7.6.3" + "@babel/helper-member-expression-to-functions": "^7.7.0", + "@babel/helper-optimise-call-expression": "^7.7.0", + "@babel/traverse": "^7.7.0", + "@babel/types": "^7.7.0" } } diff --git a/packages/babel-helper-simple-access/package.json b/packages/babel-helper-simple-access/package.json index 4fd9ee272372..b904fc3e757f 100644 --- a/packages/babel-helper-simple-access/package.json +++ b/packages/babel-helper-simple-access/package.json @@ -1,6 +1,6 @@ { "name": "@babel/helper-simple-access", - "version": "7.1.0", + "version": "7.7.0", "description": "Babel helper for ensuring that access to a given value is performed through simple accesses", "author": "Logan Smyth ", "homepage": "https://babeljs.io/", @@ -11,7 +11,7 @@ "repository": "https://github.com/babel/babel/tree/master/packages/babel-helper-simple-access", "main": "lib/index.js", "dependencies": { - "@babel/template": "^7.1.0", - "@babel/types": "^7.6.3" + "@babel/template": "^7.7.0", + "@babel/types": "^7.7.0" } } diff --git a/packages/babel-helper-split-export-declaration/package.json b/packages/babel-helper-split-export-declaration/package.json index e4ae3ae051fe..c877e501f0d3 100644 --- a/packages/babel-helper-split-export-declaration/package.json +++ b/packages/babel-helper-split-export-declaration/package.json @@ -1,6 +1,6 @@ { "name": "@babel/helper-split-export-declaration", - "version": "7.4.4", + "version": "7.7.0", "description": "", "repository": "https://github.com/babel/babel/tree/master/packages/babel-helper-split-export-declaration", "license": "MIT", @@ -9,6 +9,6 @@ }, "main": "lib/index.js", "dependencies": { - "@babel/types": "^7.6.3" + "@babel/types": "^7.7.0" } } diff --git a/packages/babel-helper-wrap-function/package.json b/packages/babel-helper-wrap-function/package.json index 6d06942e0e5c..743c33bf99a4 100644 --- a/packages/babel-helper-wrap-function/package.json +++ b/packages/babel-helper-wrap-function/package.json @@ -1,6 +1,6 @@ { "name": "@babel/helper-wrap-function", - "version": "7.2.0", + "version": "7.7.0", "description": "Helper to wrap functions inside a function call.", "repository": "https://github.com/babel/babel/tree/master/packages/babel-helper-wrap-function", "license": "MIT", @@ -9,9 +9,9 @@ }, "main": "lib/index.js", "dependencies": { - "@babel/helper-function-name": "^7.1.0", - "@babel/template": "^7.1.0", - "@babel/traverse": "^7.1.0", - "@babel/types": "^7.6.3" + "@babel/helper-function-name": "^7.7.0", + "@babel/template": "^7.7.0", + "@babel/traverse": "^7.7.0", + "@babel/types": "^7.7.0" } } diff --git a/packages/babel-helpers/package.json b/packages/babel-helpers/package.json index 555a469caa6f..31ff1ee3c5a5 100644 --- a/packages/babel-helpers/package.json +++ b/packages/babel-helpers/package.json @@ -1,6 +1,6 @@ { "name": "@babel/helpers", - "version": "7.6.2", + "version": "7.7.0", "description": "Collection of helper functions used by Babel transforms.", "author": "Sebastian McKenzie ", "homepage": "https://babeljs.io/", @@ -11,9 +11,9 @@ "repository": "https://github.com/babel/babel/tree/master/packages/babel-helpers", "main": "lib/index.js", "dependencies": { - "@babel/template": "^7.6.0", - "@babel/traverse": "^7.6.2", - "@babel/types": "^7.6.3" + "@babel/template": "^7.7.0", + "@babel/traverse": "^7.7.0", + "@babel/types": "^7.7.0" }, "devDependencies": { "@babel/helper-plugin-test-runner": "^7.0.0" diff --git a/packages/babel-helpers/src/helpers.js b/packages/babel-helpers/src/helpers.js index 32cbee4fc000..d235cf328569 100644 --- a/packages/babel-helpers/src/helpers.js +++ b/packages/babel-helpers/src/helpers.js @@ -136,7 +136,7 @@ helpers.AsyncGenerator = helper("7.0.0-beta.0")` Promise.resolve(wrappedAwait ? value.wrapped : value).then( function (arg) { if (wrappedAwait) { - resume("next", arg); + resume(key === "return" ? "return" : "next", arg); return } @@ -238,6 +238,10 @@ helpers.asyncGeneratorDelegate = helper("7.0.0-beta.0")` if (typeof inner.return === "function") { iter.return = function (value) { + if (waiting) { + waiting = false; + return value; + } return pump("return", value); }; } @@ -393,7 +397,7 @@ helpers.objectSpread = helper("7.0.0-beta.0")` export default function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = (arguments[i] != null) ? arguments[i] : {}; - var ownKeys = Object.keys(source); + var ownKeys = Object.keys(Object(source)); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; @@ -430,13 +434,13 @@ helpers.objectSpread2 = helper("7.5.0")` for (var i = 1; i < arguments.length; i++) { var source = (arguments[i] != null) ? arguments[i] : {}; if (i % 2) { - ownKeys(source, true).forEach(function (key) { + ownKeys(Object(source), true).forEach(function (key) { defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { - ownKeys(source).forEach(function (key) { + ownKeys(Object(source)).forEach(function (key) { Object.defineProperty( target, key, @@ -630,18 +634,16 @@ helpers.interopRequireWildcard = helper("7.0.0-beta.0")` } var newObj = {}; - if (obj != null) { - var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; - for (var key in obj) { - if (Object.prototype.hasOwnProperty.call(obj, key)) { - var desc = hasPropertyDescriptor - ? Object.getOwnPropertyDescriptor(obj, key) - : null; - if (desc && (desc.get || desc.set)) { - Object.defineProperty(newObj, key, desc); - } else { - newObj[key] = obj[key]; - } + var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; + for (var key in obj) { + if (Object.prototype.hasOwnProperty.call(obj, key)) { + var desc = hasPropertyDescriptor + ? Object.getOwnPropertyDescriptor(obj, key) + : null; + if (desc && (desc.get || desc.set)) { + Object.defineProperty(newObj, key, desc); + } else { + newObj[key] = obj[key]; } } } @@ -1042,9 +1044,7 @@ helpers.initializerWarningHelper = helper("7.0.0-beta.0")` export default function _initializerWarningHelper(descriptor, context){ throw new Error( 'Decorating class property failed. Please ensure that ' + - 'proposal-class-properties is enabled and set to use loose mode. ' + - 'To use proposal-class-properties in spec mode with decorators, wait for ' + - 'the next major version of decorators in stage 2.' + 'proposal-class-properties is enabled and runs after the decorators transform.' ); } `; diff --git a/packages/babel-node/package.json b/packages/babel-node/package.json index f2b77567c4fb..ace2ab57c6ad 100644 --- a/packages/babel-node/package.json +++ b/packages/babel-node/package.json @@ -1,6 +1,6 @@ { "name": "@babel/node", - "version": "7.6.3", + "version": "7.7.0", "description": "Babel command line", "author": "Sebastian McKenzie ", "homepage": "https://babeljs.io/", @@ -19,7 +19,7 @@ "compiler" ], "dependencies": { - "@babel/register": "^7.6.2", + "@babel/register": "^7.7.0", "commander": "^2.8.1", "core-js": "^3.2.1", "lodash": "^4.17.13", @@ -31,10 +31,10 @@ "@babel/core": "^7.0.0-0" }, "devDependencies": { - "@babel/core": "^7.6.3", + "@babel/core": "^7.7.0", "@babel/helper-fixtures": "^7.6.3", "fs-readdir-recursive": "^1.0.0", - "output-file-sync": "^2.0.0" + "make-dir": "^2.1.0" }, "bin": { "babel-node": "./bin/babel-node.js" diff --git a/packages/babel-node/test/index.js b/packages/babel-node/test/index.js index 45283de76957..97ee54c02450 100644 --- a/packages/babel-node/test/index.js +++ b/packages/babel-node/test/index.js @@ -2,7 +2,7 @@ const includes = require("lodash/includes"); const readdir = require("fs-readdir-recursive"); const helper = require("@babel/helper-fixtures"); const rimraf = require("rimraf"); -const outputFileSync = require("output-file-sync"); +const { sync: makeDirSync } = require("make-dir"); const child = require("child_process"); const merge = require("lodash/merge"); const path = require("path"); @@ -15,6 +15,11 @@ const fileFilter = function(x) { return x !== ".DS_Store"; }; +const outputFileSync = function(filePath, data) { + makeDirSync(path.dirname(filePath)); + fs.writeFileSync(filePath, data); +}; + const presetLocs = [ path.join(__dirname, "../../babel-preset-env"), path.join(__dirname, "../../babel-preset-react"), diff --git a/packages/babel-parser/package.json b/packages/babel-parser/package.json index 3760270b1672..ebf2db424378 100644 --- a/packages/babel-parser/package.json +++ b/packages/babel-parser/package.json @@ -1,6 +1,6 @@ { "name": "@babel/parser", - "version": "7.6.4", + "version": "7.7.3", "description": "A JavaScript parser", "author": "Sebastian McKenzie ", "homepage": "https://babeljs.io/", diff --git a/packages/babel-parser/src/index.js b/packages/babel-parser/src/index.js index d9f812695545..3e9696b858fc 100755 --- a/packages/babel-parser/src/index.js +++ b/packages/babel-parser/src/index.js @@ -25,15 +25,32 @@ export function parse(input: string, options?: Options): File { const parser = getParser(options, input); const ast = parser.parse(); - // Rather than try to parse as a script first, we opt to parse as a module and convert back - // to a script where possible to avoid having to do a full re-parse of the input content. - if (!parser.sawUnambiguousESM) ast.program.sourceType = "script"; + if (parser.sawUnambiguousESM) { + return ast; + } + + if (parser.ambiguousScriptDifferentAst) { + // Top level await introduces code which can be both a valid script and + // a valid module, but which produces different ASTs: + // await + // 0 + // can be parsed either as an AwaitExpression, or as two ExpressionStatements. + try { + options.sourceType = "script"; + return getParser(options, input).parse(); + } catch {} + } else { + // This is both a valid module and a valid script, but + // we parse it as a script by default + ast.program.sourceType = "script"; + } + return ast; } catch (moduleError) { try { options.sourceType = "script"; return getParser(options, input).parse(); - } catch (scriptError) {} + } catch {} throw moduleError; } diff --git a/packages/babel-parser/src/options.js b/packages/babel-parser/src/options.js index 8b030847f970..eb4dd6789605 100755 --- a/packages/babel-parser/src/options.js +++ b/packages/babel-parser/src/options.js @@ -21,6 +21,7 @@ export type Options = { ranges: boolean, tokens: boolean, createParenthesizedExpressions: boolean, + errorRecovery: boolean, }; export const defaultOptions: Options = { @@ -62,6 +63,9 @@ export const defaultOptions: Options = { // Whether to create ParenthesizedExpression AST nodes (if false // the parser sets extra.parenthesized on the expression nodes instead). createParenthesizedExpressions: false, + // When enabled, errors are attached to the AST instead of being directly thrown. + // Some errors will still throw, because @babel/parser can't always recover. + errorRecovery: false, }; // Interpret and default an options object diff --git a/packages/babel-parser/src/parser/base.js b/packages/babel-parser/src/parser/base.js index 1e451794158c..f4fb9f3b66e0 100644 --- a/packages/babel-parser/src/parser/base.js +++ b/packages/babel-parser/src/parser/base.js @@ -13,6 +13,7 @@ export default class BaseParser { plugins: PluginsMap; filename: ?string; sawUnambiguousESM: boolean = false; + ambiguousScriptDifferentAst: boolean = false; // Initialized by Tokenizer state: State; diff --git a/packages/babel-parser/src/parser/expression.js b/packages/babel-parser/src/parser/expression.js index 556ac6daa7be..89088db4d98b 100644 --- a/packages/babel-parser/src/parser/expression.js +++ b/packages/babel-parser/src/parser/expression.js @@ -108,6 +108,7 @@ export default class ExpressionParser extends LValParser { this.unexpected(); } expr.comments = this.state.comments; + expr.errors = this.state.errors; return expr; } @@ -204,7 +205,10 @@ export default class ExpressionParser extends LValParser { node.left = this.match(tt.eq) ? this.toAssignable(left, undefined, "assignment expression") : left; - refShorthandDefaultPos.start = 0; // reset because shorthand default was used correctly + + if (refShorthandDefaultPos.start >= node.left.start) { + refShorthandDefaultPos.start = 0; // reset because shorthand default was used correctly + } this.checkLVal(left, undefined, undefined, "assignment expression"); @@ -380,7 +384,7 @@ export default class ExpressionParser extends LValParser { * so for ?? operator we need to check in this case the right expression to have parenthesis * second case a && b ?? c * here a && b => This is considered as a logical expression in the ast tree - * c => identifer + * c => identifier * so now here for ?? operator we need to check the left expression to have parenthesis * if the parenthesis is missing we raise an error and throw it */ @@ -625,7 +629,7 @@ export default class ExpressionParser extends LValParser { node.callee = base; node.arguments = this.parseCallExpressionArguments(tt.parenR, false); node.optional = true; - return this.finishNode(node, "OptionalCallExpression"); + return this.finishCallExpression(node, /* optional */ true); } else { node.object = base; node.property = this.parseIdentifier(true); @@ -680,11 +684,7 @@ export default class ExpressionParser extends LValParser { base.type !== "Super", node, ); - if (!state.optionalChainMember) { - this.finishCallExpression(node); - } else { - this.finishOptionalCallExpression(node); - } + this.finishCallExpression(node, state.optionalChainMember); if (state.maybeAsyncArrow && this.shouldParseAsyncArrow()) { state.stop = true; @@ -780,32 +780,24 @@ export default class ExpressionParser extends LValParser { ); } - finishCallExpression(node: N.CallExpression): N.CallExpression { - if (node.callee.type === "Import") { - if (node.arguments.length !== 1) { - this.raise(node.start, "import() requires exactly one argument"); - } - - const importArg = node.arguments[0]; - if (importArg && importArg.type === "SpreadElement") { - this.raise(importArg.start, "... is not allowed in import()"); - } - } - return this.finishNode(node, "CallExpression"); - } - - finishOptionalCallExpression(node: N.CallExpression): N.CallExpression { + finishCallExpression( + node: T, + optional: boolean, + ): T { if (node.callee.type === "Import") { if (node.arguments.length !== 1) { this.raise(node.start, "import() requires exactly one argument"); - } - - const importArg = node.arguments[0]; - if (importArg && importArg.type === "SpreadElement") { - this.raise(importArg.start, "... is not allowed in import()"); + } else { + const importArg = node.arguments[0]; + if (importArg && importArg.type === "SpreadElement") { + this.raise(importArg.start, "... is not allowed in import()"); + } } } - return this.finishNode(node, "OptionalCallExpression"); + return this.finishNode( + node, + optional ? "OptionalCallExpression" : "CallExpression", + ); } parseCallExpressionArguments( @@ -912,13 +904,6 @@ export default class ExpressionParser extends LValParser { switch (this.state.type) { case tt._super: - if (!this.scope.allowSuper && !this.options.allowSuperOutsideMethod) { - this.raise( - this.state.start, - "super is only allowed in object methods and classes", - ); - } - node = this.startNode(); this.next(); if ( @@ -931,6 +916,14 @@ export default class ExpressionParser extends LValParser { "super() is only valid inside a class constructor of a subclass. " + "Maybe a typo in the method name ('constructor') or not extending another class?", ); + } else if ( + !this.scope.allowSuper && + !this.options.allowSuperOutsideMethod + ) { + this.raise( + node.start, + "super is only allowed in object methods and classes", + ); } if ( @@ -938,7 +931,11 @@ export default class ExpressionParser extends LValParser { !this.match(tt.bracketL) && !this.match(tt.dot) ) { - this.unexpected(); + this.raise( + node.start, + "super can only be used with function calls (i.e. super()) or " + + "in property accesses (i.e. super.prop or super[prop])", + ); } return this.finishNode(node, "Super"); @@ -1115,15 +1112,16 @@ export default class ExpressionParser extends LValParser { } this.next(); - if (this.primaryTopicReferenceIsAllowedInCurrentTopicContext()) { - this.registerTopicReference(); - return this.finishNode(node, "PipelinePrimaryTopicReference"); - } else { - throw this.raise( + + if (!this.primaryTopicReferenceIsAllowedInCurrentTopicContext()) { + this.raise( node.start, `Topic reference was used in a lexical context without topic binding`, ); } + + this.registerTopicReference(); + return this.finishNode(node, "PipelinePrimaryTopicReference"); } } @@ -1208,6 +1206,15 @@ export default class ExpressionParser extends LValParser { if (this.isContextual("meta")) { this.expectPlugin("importMeta"); + + if (!this.inModule) { + this.raise( + id.start, + `import.meta may appear only with 'sourceType: "module"'`, + { code: "BABEL_PARSER_SOURCETYPE_MODULE_REQUIRED" }, + ); + } + this.sawUnambiguousESM = true; } else if (!this.hasPlugin("importMeta")) { this.raise( id.start, @@ -1215,15 +1222,6 @@ export default class ExpressionParser extends LValParser { ); } - if (!this.inModule) { - this.raise( - id.start, - `import.meta may appear only with 'sourceType: "module"'`, - { code: "BABEL_PARSER_SOURCETYPE_MODULE_REQUIRED" }, - ); - } - this.sawUnambiguousESM = true; - return this.parseMetaProperty(node, id, "meta"); } @@ -1395,7 +1393,10 @@ export default class ExpressionParser extends LValParser { parseNew(): N.NewExpression | N.MetaProperty { const node = this.startNode(); - const meta = this.parseIdentifier(true); + + let meta = this.startNode(); + this.next(); + meta = this.createIdentifier(meta, "new"); if (this.eat(tt.dot)) { const metaProp = this.parseMetaProperty(node, meta, "target"); @@ -1562,12 +1563,12 @@ export default class ExpressionParser extends LValParser { this.state.start, "Stage 2 decorators disallow object literal property decorators", ); - } else { - // we needn't check if decorators (stage 0) plugin is enabled since it's checked by - // the call to this.parseDecorator - while (this.match(tt.at)) { - decorators.push(this.parseDecorator()); - } + } + + // we needn't check if decorators (stage 0) plugin is enabled since it's checked by + // the call to this.parseDecorator + while (this.match(tt.at)) { + decorators.push(this.parseDecorator()); } } @@ -1942,7 +1943,7 @@ export default class ExpressionParser extends LValParser { if (isExpression) { node.body = this.parseMaybeAssign(); - this.checkParams(node, false, allowExpression); + this.checkParams(node, false, allowExpression, false); } else { const nonSimple = !this.isSimpleParamList(node.params); if (!oldStrict || nonSimple) { @@ -1976,6 +1977,7 @@ export default class ExpressionParser extends LValParser { node, !oldStrict && !useStrict && !allowExpression && !isMethod && !nonSimple, allowExpression, + !oldStrict && useStrict, ); node.body = this.parseBlock(true, false); this.state.labels = oldLabels; @@ -1984,7 +1986,14 @@ export default class ExpressionParser extends LValParser { this.state.inParameters = oldInParameters; // Ensure the function name isn't a forbidden identifier in strict mode, e.g. 'eval' if (this.state.strict && node.id) { - this.checkLVal(node.id, BIND_OUTSIDE, undefined, "function name"); + this.checkLVal( + node.id, + BIND_OUTSIDE, + undefined, + "function name", + undefined, + !oldStrict && useStrict, + ); } this.state.strict = oldStrict; } @@ -2003,6 +2012,7 @@ export default class ExpressionParser extends LValParser { allowDuplicates: boolean, // eslint-disable-next-line no-unused-vars isArrowFunction: ?boolean, + strictModeChanged?: boolean = true, ): void { // $FlowIssue const nameHash: {} = Object.create(null); @@ -2012,6 +2022,8 @@ export default class ExpressionParser extends LValParser { BIND_VAR, allowDuplicates ? null : nameHash, "function parameter list", + undefined, + strictModeChanged, ); } } @@ -2093,6 +2105,8 @@ export default class ExpressionParser extends LValParser { // Parse the next token as an identifier. If `liberal` is true (used // when parsing properties), it will also convert keywords into // identifiers. + // This shouldn't be used to parse the keywords of meta properties, since they + // are not identifiers and cannot contain escape sequences. parseIdentifier(liberal?: boolean): N.Identifier { const node = this.startNode(); @@ -2113,11 +2127,6 @@ export default class ExpressionParser extends LValParser { if (this.match(tt.name)) { name = this.state.value; - - // An escaped identifier whose value is the same as a keyword - if (!liberal && this.state.containsEsc && isKeyword(name)) { - this.raise(this.state.pos, `Escape sequence in keyword ${name}`); - } } else if (this.state.type.keyword) { name = this.state.type.keyword; @@ -2137,7 +2146,11 @@ export default class ExpressionParser extends LValParser { throw this.unexpected(); } - if (!liberal) { + if (liberal) { + // If the current token is not used as a keyword, set its type to "tt.name". + // This will prevent this.next() from throwing about unexpected escapes. + this.state.type = tt.name; + } else { this.checkReservedWord( name, this.state.start, @@ -2162,6 +2175,7 @@ export default class ExpressionParser extends LValParser { startLoc, "Can not use 'yield' as identifier inside a generator", ); + return; } if (word === "await") { @@ -2170,7 +2184,9 @@ export default class ExpressionParser extends LValParser { startLoc, "Can not use 'await' as identifier inside an async function", ); - } else if ( + return; + } + if ( this.state.awaitPos === -1 && (this.state.maybeInArrowParameters || this.isAwaitAllowed()) ) { @@ -2183,9 +2199,11 @@ export default class ExpressionParser extends LValParser { startLoc, "'arguments' is not allowed in class field initializer", ); + return; } if (checkKeywords && isKeyword(word)) { this.raise(startLoc, `Unexpected keyword '${word}'`); + return; } const reservedTest = !this.state.strict @@ -2200,23 +2218,22 @@ export default class ExpressionParser extends LValParser { startLoc, "Can not use keyword 'await' outside an async function", ); + } else { + this.raise(startLoc, `Unexpected reserved word '${word}'`); } - this.raise(startLoc, `Unexpected reserved word '${word}'`); } } isAwaitAllowed(): boolean { if (this.scope.inFunction) return this.scope.inAsync; if (this.options.allowAwaitOutsideFunction) return true; + if (this.hasPlugin("topLevelAwait")) return this.inModule; return false; } // Parses await expression inside async function. parseAwait(): N.AwaitExpression { - if (this.state.awaitPos === -1) { - this.state.awaitPos = this.state.start; - } const node = this.startNode(); this.next(); @@ -2226,30 +2243,55 @@ export default class ExpressionParser extends LValParser { node.start, "await is not allowed in async function parameters", ); + } else if (this.state.awaitPos === -1) { + this.state.awaitPos = node.start; } - if (this.match(tt.star)) { + if (this.eat(tt.star)) { this.raise( node.start, "await* has been removed from the async functions proposal. Use Promise.all() instead.", ); } + if (!this.scope.inFunction && !this.options.allowAwaitOutsideFunction) { + if ( + this.hasPrecedingLineBreak() || + // All the following expressions are ambiguous: + // await + 0, await - 0, await ( 0 ), await [ 0 ], await / 0 /u, await `` + this.match(tt.plusMin) || + this.match(tt.parenL) || + this.match(tt.bracketL) || + this.match(tt.backQuote) || + // Sometimes the tokenizer generates tt.slash for regexps, and this is + // handler by parseExprAtom + this.match(tt.regexp) || + this.match(tt.slash) || + // This code could be parsed both as a modulo operator or as an intrinsic: + // await %x(0) + (this.hasPlugin("v8intrinsic") && this.match(tt.modulo)) + ) { + this.ambiguousScriptDifferentAst = true; + } else { + this.sawUnambiguousESM = true; + } + } + if (!this.state.soloAwait) { node.argument = this.parseMaybeUnary(); } + return this.finishNode(node, "AwaitExpression"); } // Parses yield expression inside generator. parseYield(noIn?: ?boolean): N.YieldExpression { - if (this.state.yieldPos === -1) { - this.state.yieldPos = this.state.start; - } const node = this.startNode(); if (this.state.inParameters) { this.raise(node.start, "yield is not allowed in generator parameters"); + } else if (this.state.yieldPos === -1) { + this.state.yieldPos = node.start; } this.next(); @@ -2275,7 +2317,7 @@ export default class ExpressionParser extends LValParser { if (left.type === "SequenceExpression") { // Ensure that the pipeline head is not a comma-delimited // sequence expression. - throw this.raise( + this.raise( leftStartPos, `Pipeline head should not be a comma-separated sequence expression`, ); @@ -2320,7 +2362,7 @@ export default class ExpressionParser extends LValParser { pipelineStyle === "PipelineTopicExpression" && childExpression.type === "SequenceExpression" ) { - throw this.raise( + this.raise( startPos, `Pipeline body may not be a comma-separated sequence expression`, ); @@ -2346,7 +2388,7 @@ export default class ExpressionParser extends LValParser { break; case "PipelineTopicExpression": if (!this.topicReferenceWasUsedInCurrentTopicContext()) { - throw this.raise( + this.raise( startPos, `Pipeline is in topic style but does not use topic reference`, ); @@ -2354,7 +2396,9 @@ export default class ExpressionParser extends LValParser { bodyNode.expression = childExpression; break; default: - throw this.raise(startPos, `Unknown pipeline style ${pipelineStyle}`); + throw new Error( + `Internal @babel/parser error: Unknown pipeline style (${pipelineStyle})`, + ); } return this.finishNode(bodyNode, pipelineStyle); } diff --git a/packages/babel-parser/src/parser/index.js b/packages/babel-parser/src/parser/index.js index 9e75bf6044d3..2c96336f1c13 100644 --- a/packages/babel-parser/src/parser/index.js +++ b/packages/babel-parser/src/parser/index.js @@ -39,7 +39,10 @@ export default class Parser extends StatementParser { const file = this.startNode(); const program = this.startNode(); this.nextToken(); - return this.parseTopLevel(file, program); + file.errors = null; + this.parseTopLevel(file, program); + file.errors = this.state.errors; + return file; } } diff --git a/packages/babel-parser/src/parser/location.js b/packages/babel-parser/src/parser/location.js index 1839f359ae4c..3694a567090a 100644 --- a/packages/babel-parser/src/parser/location.js +++ b/packages/babel-parser/src/parser/location.js @@ -10,6 +10,8 @@ import CommentsParser from "./comments"; // message. export default class LocationParser extends CommentsParser { + +isLookahead: boolean; + getLocationForPosition(pos: number): Position { let loc; if (pos === this.state.start) loc = this.state.startLoc; @@ -31,7 +33,7 @@ export default class LocationParser extends CommentsParser { missingPluginNames?: Array, code?: string, } = {}, - ): empty { + ): Error | empty { const loc = this.getLocationForPosition(pos); message += ` (${loc.line}:${loc.column})`; @@ -47,6 +49,12 @@ export default class LocationParser extends CommentsParser { if (code !== undefined) { err.code = code; } - throw err; + + if (this.options.errorRecovery) { + if (!this.isLookahead) this.state.errors.push(err); + return err; + } else { + throw err; + } } } diff --git a/packages/babel-parser/src/parser/lval.js b/packages/babel-parser/src/parser/lval.js index 050bb1eda6c1..547441b0ce41 100644 --- a/packages/babel-parser/src/parser/lval.js +++ b/packages/babel-parser/src/parser/lval.js @@ -15,7 +15,10 @@ import type { SpreadElement, } from "../types"; import type { Pos, Position } from "../util/location"; -import { isStrictBindReservedWord } from "../util/identifier"; +import { + isStrictBindOnlyReservedWord, + isStrictBindReservedWord, +} from "../util/identifier"; import { NodeUtils } from "./node"; import { type BindingTypes, BIND_NONE } from "../util/scopeflags"; @@ -37,6 +40,8 @@ export default class LValParser extends NodeUtils { // Convert existing expression atom to assignable pattern // if possible. + // NOTE: There is a corresponding "isAssignable" method in flow.js. + // When this one is updated, please check if also that one needs to be updated. toAssignable( node: Node, @@ -96,15 +101,16 @@ export default class LValParser extends NodeUtils { break; case "AssignmentExpression": - if (node.operator === "=") { - node.type = "AssignmentPattern"; - delete node.operator; - } else { + if (node.operator !== "=") { this.raise( node.left.end, "Only '=' operator can be used for specifying default value.", ); } + + node.type = "AssignmentPattern"; + delete node.operator; + this.toAssignable(node.left, isBinding, contextDescription); break; case "ParenthesizedExpression": @@ -118,14 +124,9 @@ export default class LValParser extends NodeUtils { case "MemberExpression": if (!isBinding) break; - default: { - const message = - "Invalid left-hand side" + - (contextDescription - ? " in " + contextDescription - : /* istanbul ignore next */ "expression"); - this.raise(node.start, message); - } + default: + // We don't know how to deal with this node. It will + // be reported by a later call to checkLVal } } return node; @@ -349,12 +350,18 @@ export default class LValParser extends NodeUtils { checkClashes: ?{ [key: string]: boolean }, contextDescription: string, disallowLetBinding?: boolean, + strictModeChanged?: boolean = false, ): void { switch (expr.type) { case "Identifier": if ( this.state.strict && - isStrictBindReservedWord(expr.name, this.inModule) + // "Global" reserved words have already been checked by parseIdentifier, + // unless they have been found in the id or parameters of a strict-mode + // function in a sloppy context. + (strictModeChanged + ? isStrictBindReservedWord(expr.name, this.inModule) + : isStrictBindOnlyReservedWord(expr.name)) ) { this.raise( expr.start, @@ -404,6 +411,11 @@ export default class LValParser extends NodeUtils { case "ObjectPattern": for (let prop of expr.properties) { if (prop.type === "ObjectProperty") prop = prop.value; + // If we find here an ObjectMethod, it's because this was originally + // an ObjectExpression which has then been converted. + // toAssignable already reported this error with a nicer message. + else if (prop.type === "ObjectMethod") continue; + this.checkLVal( prop, bindingType, @@ -489,7 +501,7 @@ export default class LValParser extends NodeUtils { } raiseRestNotLast(pos: number) { - this.raise(pos, `Rest element must be last element`); + throw this.raise(pos, `Rest element must be last element`); } raiseTrailingCommaAfterRest(pos: number) { diff --git a/packages/babel-parser/src/parser/statement.js b/packages/babel-parser/src/parser/statement.js index 81e310debd7b..827cedfbd7d9 100644 --- a/packages/babel-parser/src/parser/statement.js +++ b/packages/babel-parser/src/parser/statement.js @@ -203,7 +203,7 @@ export default class StatementParser extends ExpressionParser { case tt._var: kind = kind || this.state.value; if (context && kind !== "var") { - this.unexpected( + this.raise( this.state.start, "Lexical declaration cannot appear in a single-statement context", ); @@ -269,8 +269,8 @@ export default class StatementParser extends ExpressionParser { default: { if (this.isAsyncFunction()) { if (context) { - this.unexpected( - null, + this.raise( + this.state.start, "Async functions can only be declared at the top level or inside a block", ); } @@ -351,7 +351,7 @@ export default class StatementParser extends ExpressionParser { ); } } else if (!this.canHaveLeadingDecorator()) { - this.raise( + throw this.raise( this.state.start, "Leading decorators must be attached to a class declaration", ); @@ -495,11 +495,7 @@ export default class StatementParser extends ExpressionParser { this.state.labels.push(loopLabel); let awaitAt = -1; - if ( - (this.scope.inAsync || - (!this.scope.inFunction && this.options.allowAwaitOutsideFunction)) && - this.eatContextual("await") - ) { + if (this.isAwaitAllowed() && this.eatContextual("await")) { awaitAt = this.state.lastTokStart; } this.scope.enter(SCOPE_OTHER); @@ -1040,7 +1036,7 @@ export default class StatementParser extends ExpressionParser { this.initFunction(node, isAsync); if (this.match(tt.star) && isHangingStatement) { - this.unexpected( + this.raise( this.state.start, "Generators can only be declared at the top level or inside a block", ); @@ -1081,10 +1077,10 @@ export default class StatementParser extends ExpressionParser { this.scope.exit(); if (isStatement && !isHangingStatement) { - // We need to validate this _after_ parsing the function body + // We need to register this _after_ parsing the function body // because of TypeScript body-less function declarations, // which shouldn't be added to the scope. - this.checkFunctionStatementId(node); + this.registerFunctionStatementId(node); } this.state.maybeInArrowParameters = oldMaybeInArrowParameters; @@ -1115,22 +1111,21 @@ export default class StatementParser extends ExpressionParser { this.checkYieldAwaitInDefaultParams(); } - checkFunctionStatementId(node: N.Function): void { + registerFunctionStatementId(node: N.Function): void { if (!node.id) return; // If it is a regular function declaration in sloppy mode, then it is // subject to Annex B semantics (BIND_FUNCTION). Otherwise, the binding // mode depends on properties of the current scope (see // treatFunctionsAsVar). - this.checkLVal( - node.id, + this.scope.declareName( + node.id.name, this.state.strict || node.generator || node.async ? this.scope.treatFunctionsAsVar ? BIND_VAR : BIND_LEXICAL : BIND_FUNCTION, - null, - "function name", + node.id.start, ); } @@ -1195,7 +1190,7 @@ export default class StatementParser extends ExpressionParser { while (!this.eat(tt.braceR)) { if (this.eat(tt.semi)) { if (decorators.length > 0) { - this.raise( + throw this.raise( this.state.lastTokEnd, "Decorators must not be followed by a semicolon", ); @@ -1233,7 +1228,7 @@ export default class StatementParser extends ExpressionParser { }); if (decorators.length) { - this.raise( + throw this.raise( this.state.start, "You have trailing decorators with no method", ); @@ -1348,6 +1343,7 @@ export default class StatementParser extends ExpressionParser { const isPrivate = key.type === "PrivateName"; // Check the key is not a computed expression or string literal. const isSimple = key.type === "Identifier"; + const maybeQuestionTokenStart = this.state.start; this.parsePostMemberNameModifiers(publicMember); @@ -1365,13 +1361,6 @@ export default class StatementParser extends ExpressionParser { if (isConstructor) { publicMethod.kind = "constructor"; - if (publicMethod.decorators) { - this.raise( - publicMethod.start, - "You can't attach decorators to a class constructor", - ); - } - // TypeScript allows multiple overloaded constructor declarations. if (state.hadConstructor && !this.hasPlugin("typescript")) { this.raise(key.start, "Duplicate constructor in the same class"); @@ -1403,6 +1392,10 @@ export default class StatementParser extends ExpressionParser { // an async method const isGenerator = this.eat(tt.star); + if (publicMember.optional) { + this.unexpected(maybeQuestionTokenStart); + } + method.kind = "method"; // The so-called parsed name would have been "async": get the real name. this.parseClassPropertyName(method); @@ -1714,7 +1707,6 @@ export default class StatementParser extends ExpressionParser { maybeParseExportNamespaceSpecifier(node: N.Node): boolean { if (this.isContextual("as")) { if (!node.specifiers) node.specifiers = []; - this.expectPlugin("exportNamespaceFrom"); const specifier = this.startNodeAt( this.state.lastTokStart, @@ -1797,7 +1789,7 @@ export default class StatementParser extends ExpressionParser { this.hasPlugin("decorators") && this.getPluginOption("decorators", "decoratorsBeforeExport") ) { - this.unexpected( + this.raise( this.state.start, "Decorators must be placed *before* the 'export' keyword." + " You can set the 'decoratorsBeforeExport' option to false to use" + @@ -1807,7 +1799,7 @@ export default class StatementParser extends ExpressionParser { this.parseDecorators(false); return this.parseClass(expr, true, true); } else if (this.match(tt._const) || this.match(tt._var) || this.isLet()) { - return this.raise( + throw this.raise( this.state.start, "Only expressions, functions or classes are allowed as the `default` export.", ); @@ -1977,7 +1969,7 @@ export default class StatementParser extends ExpressionParser { name: string, ): void { if (this.state.exportedIdentifiers.indexOf(name) > -1) { - throw this.raise( + this.raise( node.start, name === "default" ? "Only one default export allowed per module." @@ -2098,8 +2090,8 @@ export default class StatementParser extends ExpressionParser { } else { // Detect an attempt to deep destructure if (this.eat(tt.colon)) { - this.unexpected( - null, + throw this.raise( + this.state.start, "ES2015 named imports do not destructure. " + "Use another statement for destructuring after the import.", ); diff --git a/packages/babel-parser/src/parser/util.js b/packages/babel-parser/src/parser/util.js index d66671551ee2..f1093f31b57f 100644 --- a/packages/babel-parser/src/parser/util.js +++ b/packages/babel-parser/src/parser/util.js @@ -2,6 +2,7 @@ import { types as tt, type TokenType } from "../tokenizer/types"; import Tokenizer from "../tokenizer"; +import State from "../tokenizer/state"; import type { Node } from "../types"; import { lineBreak, skipWhiteSpace } from "../util/whitespace"; import { isIdentifierChar } from "../util/identifier"; @@ -9,6 +10,14 @@ import * as charCodes from "charcodes"; const literal = /^('|")((?:\\?.)*?)\1/; +type TryParse = { + node: Node, + error: Error, + thrown: Thrown, + aborted: Aborted, + failState: FailState, +}; + // ## Parser utilities export default class UtilParser extends Tokenizer { @@ -215,4 +224,58 @@ export default class UtilParser extends Tokenizer { return false; } + + // tryParse will clone parser state. + // It is expensive and should be used with cautions + tryParse>( + fn: (abort: (node?: T) => empty) => T, + oldState: State = this.state.clone(), + ): + | TryParse + | TryParse + | TryParse { + const abortSignal: { node: T | null } = { node: null }; + try { + const node = fn((node = null) => { + abortSignal.node = node; + throw abortSignal; + }); + if (this.state.errors.length > oldState.errors.length) { + const failState = this.state; + this.state = oldState; + return { + node, + error: (failState.errors[oldState.errors.length]: SyntaxError), + thrown: false, + aborted: false, + failState, + }; + } + + return { + node, + error: null, + thrown: false, + aborted: false, + failState: null, + }; + } catch (error) { + const failState = this.state; + this.state = oldState; + if (error instanceof SyntaxError) { + return { node: null, error, thrown: true, aborted: false, failState }; + } + if (error === abortSignal) { + return { + node: abortSignal.node, + error: null, + thrown: false, + aborted: true, + failState, + }; + } + + throw error; + } + } } diff --git a/packages/babel-parser/src/plugins/estree.js b/packages/babel-parser/src/plugins/estree.js index 014a1a54067d..60bc1effffa7 100644 --- a/packages/babel-parser/src/plugins/estree.js +++ b/packages/babel-parser/src/plugins/estree.js @@ -93,9 +93,10 @@ export default (superClass: Class): Class => } else { this.raise(start, "setter must have exactly one formal parameter"); } - } - - if (prop.kind === "set" && prop.value.params[0].type === "RestElement") { + } else if ( + prop.kind === "set" && + prop.value.params[0].type === "RestElement" + ) { this.raise( start, "setter function argument must not be a rest parameter", @@ -382,12 +383,15 @@ export default (superClass: Class): Class => isLast: boolean, ) { if (prop.kind === "get" || prop.kind === "set") { - this.raise( + throw this.raise( prop.key.start, "Object pattern can't contain getter or setter", ); } else if (prop.method) { - this.raise(prop.key.start, "Object pattern can't contain methods"); + throw this.raise( + prop.key.start, + "Object pattern can't contain methods", + ); } else { super.toAssignableObjectExpressionProp(prop, isBinding, isLast); } diff --git a/packages/babel-parser/src/plugins/flow.js b/packages/babel-parser/src/plugins/flow.js index 867c31243010..ab5f646b6efb 100644 --- a/packages/babel-parser/src/plugins/flow.js +++ b/packages/babel-parser/src/plugins/flow.js @@ -1,5 +1,7 @@ // @flow +/*:: declare var invariant; */ + import type Parser from "../parser"; import { types as tt, type TokenType } from "../tokenizer/types"; import * as N from "../types"; @@ -81,6 +83,20 @@ function partition( const FLOW_PRAGMA_REGEX = /\*?\s*@((?:no)?flow)\b/; +// Flow enums types +type EnumExplicitType = null | "boolean" | "number" | "string" | "symbol"; +type EnumContext = {| + enumName: string, + explicitType: EnumExplicitType, + memberName: string, +|}; +type EnumMemberInit = + | {| type: "number", pos: number, value: N.Node |} + | {| type: "string", pos: number, value: N.Node |} + | {| type: "boolean", pos: number, value: N.Node |} + | {| type: "invalid", pos: number |} + | {| type: "none", pos: number |}; + export default (superClass: Class): Class => class extends superClass { // The value of the @flow/@noflow pragma. Initially undefined, transitions @@ -97,6 +113,10 @@ export default (superClass: Class): Class => return this.getPluginOption("flow", "all") || this.flowPragma === "flow"; } + shouldParseEnums(): boolean { + return !!this.getPluginOption("flow", "enums"); + } + finishToken(type: TokenType, val: any): void { if ( type !== tt.string && @@ -245,7 +265,7 @@ export default (superClass: Class): Class => return this.flowParseDeclareModuleExports(node); } else { if (insideModule) { - this.unexpected( + this.raise( this.state.lastTokStart, "`declare module` cannot be used inside another `declare module`", ); @@ -295,7 +315,7 @@ export default (superClass: Class): Class => if (this.match(tt._import)) { this.next(); if (!this.isContextual("type") && !this.match(tt._typeof)) { - this.unexpected( + this.raise( this.state.lastTokStart, "Imports within a `declare module` body must always be `import type` or `import typeof`", ); @@ -327,17 +347,17 @@ export default (superClass: Class): Class => body.forEach(bodyElement => { if (isEsModuleType(bodyElement)) { if (kind === "CommonJS") { - this.unexpected(bodyElement.start, errorMessage); + this.raise(bodyElement.start, errorMessage); } kind = "ES"; } else if (bodyElement.type === "DeclareModuleExports") { if (hasModuleExport) { - this.unexpected( + this.raise( bodyElement.start, "Duplicate `declare module.exports` statement", ); } - if (kind === "ES") this.unexpected(bodyElement.start, errorMessage); + if (kind === "ES") this.raise(bodyElement.start, errorMessage); kind = "CommonJS"; hasModuleExport = true; } @@ -530,8 +550,8 @@ export default (superClass: Class): Class => checkNotUnderscore(word: string) { if (word === "_") { - throw this.unexpected( - null, + this.raise( + this.state.start, "`_` is only allowed as a type argument to call or new", ); } @@ -614,7 +634,7 @@ export default (superClass: Class): Class => node.default = this.flowParseType(); } else { if (requireDefault) { - this.unexpected( + this.raise( nodeStart, // eslint-disable-next-line max-len "Type parameter declaration needs a default, since a preceding type parameter declaration has a default.", @@ -860,6 +880,7 @@ export default (superClass: Class): Class => while (!this.match(endDelim)) { let isStatic = false; let protoStart: ?number = null; + let inexactStart: ?number = null; const node = this.startNode(); if (allowProto && this.isContextual("proto")) { @@ -932,17 +953,29 @@ export default (superClass: Class): Class => variance, kind, allowSpread, - allowInexact, + allowInexact ?? !exact, ); if (propOrInexact === null) { inexact = true; + inexactStart = this.state.lastTokStart; } else { nodeStart.properties.push(propOrInexact); } } this.flowObjectTypeSemicolon(); + + if ( + inexactStart && + !this.match(tt.braceR) && + !this.match(tt.braceBarR) + ) { + this.raise( + inexactStart, + "Explicit inexact syntax must appear at the end of an inexact object", + ); + } } this.expect(endDelim); @@ -972,10 +1005,38 @@ export default (superClass: Class): Class => allowSpread: boolean, allowInexact: boolean, ): (N.FlowObjectTypeProperty | N.FlowObjectTypeSpreadProperty) | null { - if (this.match(tt.ellipsis)) { + if (this.eat(tt.ellipsis)) { + const isInexactToken = + this.match(tt.comma) || + this.match(tt.semi) || + this.match(tt.braceR) || + this.match(tt.braceBarR); + + if (isInexactToken) { + if (!allowSpread) { + this.raise( + this.state.lastTokStart, + "Explicit inexact syntax cannot appear in class or interface definitions", + ); + } else if (!allowInexact) { + this.raise( + this.state.lastTokStart, + "Explicit inexact syntax cannot appear inside an explicit exact object type", + ); + } + if (variance) { + this.raise( + variance.start, + "Explicit inexact syntax cannot have variance", + ); + } + + return null; + } + if (!allowSpread) { - this.unexpected( - null, + this.raise( + this.state.lastTokStart, "Spread operator cannot appear in class or interface definitions", ); } @@ -983,35 +1044,9 @@ export default (superClass: Class): Class => this.unexpected(protoStart); } if (variance) { - this.unexpected( - variance.start, - "Spread properties cannot have variance", - ); - } - this.expect(tt.ellipsis); - const isInexactToken = this.eat(tt.comma) || this.eat(tt.semi); - - if (this.match(tt.braceR)) { - if (allowInexact) return null; - this.unexpected( - null, - "Explicit inexact syntax is only allowed inside inexact objects", - ); - } - - if (this.match(tt.braceBarR)) { - this.unexpected( - null, - "Explicit inexact syntax cannot appear inside an explicit exact object type", - ); + this.raise(variance.start, "Spread properties cannot have variance"); } - if (isInexactToken) { - this.unexpected( - null, - "Explicit inexact syntax must appear at the end of an inexact object", - ); - } node.argument = this.flowParseType(); return this.finishNode(node, "ObjectTypeSpreadProperty"); } else { @@ -1382,8 +1417,8 @@ export default (superClass: Class): Class => ); } - this.unexpected( - null, + throw this.raise( + this.state.start, `Unexpected token, expected "number" or "bigint"`, ); } @@ -1604,7 +1639,7 @@ export default (superClass: Class): Class => super.parseFunctionBodyAndFinish(node, type, isMethod); } - // interfaces + // interfaces and enums parseStatement(context: ?string, topLevel?: boolean): N.Statement { // strict mode handling of `interface` since it's a reserved word if ( @@ -1615,6 +1650,10 @@ export default (superClass: Class): Class => const node = this.startNode(); this.next(); return this.flowParseInterface(node); + } else if (this.shouldParseEnums() && this.isContextual("enum")) { + const node = this.startNode(); + this.next(); + return this.flowParseEnumDeclaration(node); } else { const stmt = super.parseStatement(context, topLevel); // We will parse a flow pragma in any comment before the first statement. @@ -1661,6 +1700,7 @@ export default (superClass: Class): Class => this.isContextual("type") || this.isContextual("interface") || this.isContextual("opaque") || + (this.shouldParseEnums() && this.isContextual("enum")) || super.shouldParseExportDeclaration() ); } @@ -1670,7 +1710,8 @@ export default (superClass: Class): Class => this.match(tt.name) && (this.state.value === "type" || this.state.value === "interface" || - this.state.value === "opaque") + this.state.value === "opaque" || + (this.shouldParseEnums() && this.state.value === "enum")) ) { return false; } @@ -1678,6 +1719,15 @@ export default (superClass: Class): Class => return super.isExportDefaultSpecifier(); } + parseExportDefaultExpression(): N.Expression | N.Declaration { + if (this.shouldParseEnums() && this.isContextual("enum")) { + const node = this.startNode(); + this.next(); + return this.flowParseEnumDeclaration(node); + } + return super.parseExportDefaultExpression(); + } + parseConditional( expr: N.Expression, noIn: ?boolean, @@ -1687,23 +1737,23 @@ export default (superClass: Class): Class => ): N.Expression { if (!this.match(tt.question)) return expr; - // only do the expensive clone if there is a question mark + // only use the expensive "tryParse" method if there is a question mark // and if we come from inside parens if (refNeedsArrowPos) { - const state = this.state.clone(); - try { - return super.parseConditional(expr, noIn, startPos, startLoc); - } catch (err) { - if (err instanceof SyntaxError) { - this.state = state; - refNeedsArrowPos.start = err.pos || this.state.start; - return expr; - } else { - // istanbul ignore next: no such error is expected - throw err; - } + const result = this.tryParse(() => + super.parseConditional(expr, noIn, startPos, startLoc), + ); + + if (!result.node) { + // $FlowIgnore + refNeedsArrowPos.start = result.error.pos || this.state.start; + return expr; } + + if (result.error) this.state = result.failState; + return result.node; } + this.expect(tt.question); const state = this.state.clone(); const originalNoArrowAt = this.state.noArrowAt; @@ -1743,10 +1793,10 @@ export default (superClass: Class): Class => this.state.noArrowAt = noArrowAt.concat(valid[0].start); ({ consequent, failed } = this.tryParseConditionalConsequent()); } - - this.getArrowLikeExpressions(consequent, true); } + this.getArrowLikeExpressions(consequent, true); + this.state.noArrowAt = originalNoArrowAt; this.expect(tt.colon); @@ -1792,19 +1842,7 @@ export default (superClass: Class): Class => if (node.type === "ArrowFunctionExpression") { if (node.typeParameters || !node.returnType) { // This is an arrow expression without ambiguity, so check its parameters - this.toAssignableList( - // node.params is Expression[] instead of $ReadOnlyArray because it - // has not been converted yet. - ((node.params: any): N.Expression[]), - true, - "arrow function parameters", - node.extra?.trailingComma, - ); - // Enter scope, as checkParams defines bindings - this.scope.enter(functionFlags(false, false) | SCOPE_ARROW); - // Use super's method to force the parameters to be checked - super.checkParams(node, false, true); - this.scope.exit(); + this.finishArrowValidation(node); } else { arrows.push(node); } @@ -1816,30 +1854,29 @@ export default (superClass: Class): Class => } if (disallowInvalid) { - for (let i = 0; i < arrows.length; i++) { - this.toAssignableList( - ((node.params: any): N.Expression[]), - true, - "arrow function parameters", - node.extra?.trailingComma, - ); - } + arrows.forEach(node => this.finishArrowValidation(node)); return [arrows, []]; } - return partition(arrows, node => { - try { - this.toAssignableList( - ((node.params: any): N.Expression[]), - true, - "arrow function parameters", - node.extra?.trailingComma, - ); - return true; - } catch (err) { - return false; - } - }); + return partition(arrows, node => + node.params.every(param => this.isAssignable(param, true)), + ); + } + + finishArrowValidation(node: N.ArrowFunctionExpression) { + this.toAssignableList( + // node.params is Expression[] instead of $ReadOnlyArray because it + // has not been converted yet. + ((node.params: any): N.Expression[]), + true, + "arrow function parameters", + node.extra?.trailingComma, + ); + // Enter scope, as checkParams defines bindings + this.scope.enter(functionFlags(false, false) | SCOPE_ARROW); + // Use super's method to force the parameters to be checked + super.checkParams(node, false, true); + this.scope.exit(); } forwardNoArrowParamsConversionAt(node: N.Node, parse: () => T): T { @@ -1935,6 +1972,11 @@ export default (superClass: Class): Class => const declarationNode = this.startNode(); this.next(); return this.flowParseInterface(declarationNode); + } else if (this.shouldParseEnums() && this.isContextual("enum")) { + node.exportKind = "value"; + const declarationNode = this.startNode(); + this.next(); + return this.flowParseEnumDeclaration(declarationNode); } else { return super.parseExportDeclaration(node); } @@ -1987,6 +2029,50 @@ export default (superClass: Class): Class => } } + isAssignable(node: N.Node, isBinding?: boolean): boolean { + switch (node.type) { + case "Identifier": + case "ObjectPattern": + case "ArrayPattern": + case "AssignmentPattern": + return true; + + case "ObjectExpression": { + const last = node.properties.length - 1; + return node.properties.every((prop, i) => { + return ( + prop.type !== "ObjectMethod" && + (i === last || prop.type === "SpreadElement") && + this.isAssignable(prop) + ); + }); + } + + case "ObjectProperty": + return this.isAssignable(node.value); + + case "SpreadElement": + return this.isAssignable(node.argument); + + case "ArrayExpression": + return node.elements.every(element => this.isAssignable(element)); + + case "AssignmentExpression": + return node.operator === "="; + + case "ParenthesizedExpression": + case "TypeCastExpression": + return this.isAssignable(node.expression); + + case "MemberExpression": + case "OptionalMemberExpression": + return !isBinding; + + default: + return false; + } + } + toAssignable( node: N.Node, isBinding: ?boolean, @@ -2215,13 +2301,13 @@ export default (superClass: Class): Class => parseAssignableListItemTypes(param: N.Pattern): N.Pattern { if (this.eat(tt.question)) { if (param.type !== "Identifier") { - throw this.raise( + this.raise( param.start, "A binding pattern parameter cannot be optional in an implementation signature.", ); } - param.optional = true; + ((param: any): N.Identifier).optional = true; } if (this.match(tt.colon)) { param.typeAnnotation = this.flowParseTypeAnnotation(); @@ -2452,45 +2538,50 @@ export default (superClass: Class): Class => afterLeftParse?: Function, refNeedsArrowPos?: ?Pos, ): N.Expression { - let jsxError = null; + let state = null; + + let jsx; + if ( this.hasPlugin("jsx") && (this.match(tt.jsxTagStart) || this.isRelational("<")) ) { - const state = this.state.clone(); - try { - return super.parseMaybeAssign( - noIn, - refShorthandDefaultPos, - afterLeftParse, - refNeedsArrowPos, - ); - } catch (err) { - if (err instanceof SyntaxError) { - this.state = state; - - // Remove `tc.j_expr` and `tc.j_oTag` from context added - // by parsing `jsxTagStart` to stop the JSX plugin from - // messing with the tokens - const cLength = this.state.context.length; - if (this.state.context[cLength - 1] === tc.j_oTag) { - this.state.context.length -= 2; - } - - jsxError = err; - } else { - // istanbul ignore next: no such error is expected - throw err; - } + state = this.state.clone(); + + jsx = this.tryParse( + () => + super.parseMaybeAssign( + noIn, + refShorthandDefaultPos, + afterLeftParse, + refNeedsArrowPos, + ), + state, + ); + /*:: invariant(!jsx.aborted) */ + + if (!jsx.error) return jsx.node; + + // Remove `tc.j_expr` and `tc.j_oTag` from context added + // by parsing `jsxTagStart` to stop the JSX plugin from + // messing with the tokens + const { context } = this.state; + if (context[context.length - 1] === tc.j_oTag) { + context.length -= 2; + } else if (context[context.length - 1] === tc.j_expr) { + context.length -= 1; } } - if (jsxError != null || this.isRelational("<")) { - let arrowExpression; + if ((jsx && jsx.error) || this.isRelational("<")) { + state = state || this.state.clone(); + let typeParameters; - try { + + const arrow = this.tryParse(() => { typeParameters = this.flowParseTypeParameterDeclaration(); - arrowExpression = this.forwardNoArrowParamsConversionAt( + + const arrowExpression = this.forwardNoArrowParamsConversionAt( typeParameters, () => super.parseMaybeAssign( @@ -2502,20 +2593,43 @@ export default (superClass: Class): Class => ); arrowExpression.typeParameters = typeParameters; this.resetStartLocationFromNode(arrowExpression, typeParameters); - } catch (err) { - throw jsxError || err; + + return arrowExpression; + }, state); + + const arrowExpression: ?N.ArrowFunctionExpression = + arrow.node && arrow.node.type === "ArrowFunctionExpression" + ? arrow.node + : null; + + if (!arrow.error && arrowExpression) return arrowExpression; + + // If we are here, both JSX and Flow parsing attemps failed. + // Give the precedence to the JSX error, except if JSX had an + // unrecoverable error while Flow didn't. + // If the error is recoverable, we can only re-report it if there is + // a node we can return. + + if (jsx && jsx.node) { + /*:: invariant(jsx.failState) */ + this.state = jsx.failState; + return jsx.node; } - if (arrowExpression.type === "ArrowFunctionExpression") { + if (arrowExpression) { + /*:: invariant(arrow.failState) */ + this.state = arrow.failState; return arrowExpression; - } else if (jsxError != null) { - throw jsxError; - } else { - this.raise( - typeParameters.start, - "Expected an arrow function after this type parameter declaration", - ); } + + if (jsx && jsx.thrown) throw jsx.error; + if (arrow.thrown) throw arrow.error; + + /*:: invariant(typeParameters) */ + throw this.raise( + typeParameters.start, + "Expected an arrow function after this type parameter declaration", + ); } return super.parseMaybeAssign( @@ -2529,8 +2643,7 @@ export default (superClass: Class): Class => // handle return types for arrow functions parseArrow(node: N.ArrowFunctionExpression): ?N.ArrowFunctionExpression { if (this.match(tt.colon)) { - const state = this.state.clone(); - try { + const result = this.tryParse(() => { const oldNoAnonFunctionType = this.state.noAnonFunctionType; this.state.noAnonFunctionType = true; @@ -2548,18 +2661,18 @@ export default (superClass: Class): Class => if (this.canInsertSemicolon()) this.unexpected(); if (!this.match(tt.arrow)) this.unexpected(); - // assign after it is clear it is an arrow - node.returnType = typeNode.typeAnnotation - ? this.finishNode(typeNode, "TypeAnnotation") - : null; - } catch (err) { - if (err instanceof SyntaxError) { - this.state = state; - } else { - // istanbul ignore next: no such error is expected - throw err; - } - } + return typeNode; + }); + + if (result.thrown) return null; + /*:: invariant(result.node) */ + + if (result.error) this.state = result.failState; + + // assign after it is clear it is an arrow + node.returnType = result.node.typeAnnotation + ? this.finishNode(result.node, "TypeAnnotation") + : null; } return super.parseArrow(node); @@ -2592,7 +2705,7 @@ export default (superClass: Class): Class => return; } - return super.checkParams(node, allowDuplicates, isArrowFunction); + return super.checkParams(...arguments); } parseParenAndDistinguishExpression(canBeArrow: boolean): N.Expression { @@ -2624,23 +2737,33 @@ export default (superClass: Class): Class => this.isRelational("<") ) { const state = this.state.clone(); - let error; - try { - const node = this.parseAsyncArrowWithTypeParameters( - startPos, - startLoc, - ); - if (node) return node; - } catch (e) { - error = e; + const arrow = this.tryParse( + abort => + this.parseAsyncArrowWithTypeParameters(startPos, startLoc) || + abort(), + state, + ); + + if (!arrow.error && !arrow.aborted) return arrow.node; + + const result = this.tryParse( + () => super.parseSubscripts(base, startPos, startLoc, noCalls), + state, + ); + + if (result.node && !result.error) return result.node; + + if (arrow.node) { + this.state = arrow.failState; + return arrow.node; } - this.state = state; - try { - return super.parseSubscripts(base, startPos, startLoc, noCalls); - } catch (e) { - throw error || e; + if (result.node) { + this.state = result.failState; + return result.node; } + + throw arrow.error || result.error; } return super.parseSubscripts(base, startPos, startLoc, noCalls); @@ -2671,7 +2794,7 @@ export default (superClass: Class): Class => // $FlowFixMe node.arguments = this.parseCallExpressionArguments(tt.parenR, false); node.optional = true; - return this.finishNode(node, "OptionalCallExpression"); + return this.finishCallExpression(node, /* optional */ true); } else if ( !noCalls && this.shouldParseTypes() && @@ -2679,22 +2802,21 @@ export default (superClass: Class): Class => ) { const node = this.startNodeAt(startPos, startLoc); node.callee = base; - const state = this.state.clone(); - try { + + const result = this.tryParse(() => { node.typeArguments = this.flowParseTypeParameterInstantiationCallOrNew(); this.expect(tt.parenL); node.arguments = this.parseCallExpressionArguments(tt.parenR, false); - if (subscriptState.optionalChainMember) { - node.optional = false; - return this.finishNode(node, "OptionalCallExpression"); - } - return this.finishNode(node, "CallExpression"); - } catch (e) { - if (e instanceof SyntaxError) { - this.state = state; - } else { - throw e; - } + if (subscriptState.optionalChainMember) node.optional = false; + return this.finishCallExpression( + node, + subscriptState.optionalChainMember, + ); + }); + + if (result.node) { + if (result.error) this.state = result.failState; + return result.node; } } @@ -2710,16 +2832,9 @@ export default (superClass: Class): Class => parseNewArguments(node: N.NewExpression): void { let targs = null; if (this.shouldParseTypes() && this.isRelational("<")) { - const state = this.state.clone(); - try { - targs = this.flowParseTypeParameterInstantiationCallOrNew(); - } catch (e) { - if (e instanceof SyntaxError) { - this.state = state; - } else { - throw e; - } - } + targs = this.tryParse(() => + this.flowParseTypeParameterInstantiationCallOrNew(), + ).node; } node.typeArguments = targs; @@ -2773,7 +2888,7 @@ export default (superClass: Class): Class => parseTopLevel(file: N.File, program: N.Program): N.File { const fileNode = super.parseTopLevel(file, program); if (this.state.hasFlowComment) { - this.unexpected(null, "Unterminated flow-comment"); + this.raise(this.state.pos, "Unterminated flow-comment"); } return fileNode; } @@ -2794,7 +2909,9 @@ export default (superClass: Class): Class => if (this.state.hasFlowComment) { const end = this.input.indexOf("*-/", (this.state.pos += 2)); - if (end === -1) this.raise(this.state.pos - 2, "Unterminated comment"); + if (end === -1) { + throw this.raise(this.state.pos - 2, "Unterminated comment"); + } this.state.pos = end + 3; return; } @@ -2836,7 +2953,421 @@ export default (superClass: Class): Class => hasFlowCommentCompletion(): void { const end = this.input.indexOf("*/", this.state.pos); if (end === -1) { - this.raise(this.state.pos, "Unterminated comment"); + throw this.raise(this.state.pos, "Unterminated comment"); + } + } + + // Flow enum parsing + + flowEnumErrorBooleanMemberNotInitialized( + pos: number, + { enumName, memberName }: { enumName: string, memberName: string }, + ): void { + this.raise( + pos, + `Boolean enum members need to be initialized. Use either \`${memberName} = true,\` ` + + `or \`${memberName} = false,\` in enum \`${enumName}\`.`, + ); + } + + flowEnumErrorInvalidMemberName( + pos: number, + { enumName, memberName }: { enumName: string, memberName: string }, + ): void { + const suggestion = memberName[0].toUpperCase() + memberName.slice(1); + this.raise( + pos, + `Enum member names cannot start with lowercase 'a' through 'z'. Instead of using ` + + `\`${memberName}\`, consider using \`${suggestion}\`, in enum \`${enumName}\`.`, + ); + } + + flowEnumErrorDuplicateMemberName( + pos: number, + { enumName, memberName }: { enumName: string, memberName: string }, + ): void { + this.raise( + pos, + `Enum member names need to be unique, but the name \`${memberName}\` has already been used ` + + `before in enum \`${enumName}\`.`, + ); + } + + flowEnumErrorInconsistentMemberValues( + pos: number, + { enumName }: { enumName: string }, + ): void { + this.raise( + pos, + `Enum \`${enumName}\` has inconsistent member initializers. Either use no initializers, or ` + + `consistently use literals (either booleans, numbers, or strings) for all member initializers.`, + ); + } + + flowEnumErrorInvalidExplicitType( + pos: number, + { + enumName, + suppliedType, + }: { enumName: string, suppliedType: null | string }, + ) { + const suggestion = + `Use one of \`boolean\`, \`number\`, \`string\`, or \`symbol\` in ` + + `enum \`${enumName}\`.`; + const message = + suppliedType === null + ? `Supplied enum type is not valid. ${suggestion}` + : `Enum type \`${suppliedType}\` is not valid. ${suggestion}`; + return this.raise(pos, message); + } + + flowEnumErrorInvalidMemberInitializer( + pos: number, + { enumName, explicitType, memberName }: EnumContext, + ) { + let message = null; + switch (explicitType) { + case "boolean": + case "number": + case "string": + message = + `Enum \`${enumName}\` has type \`${explicitType}\`, so the initializer of ` + + `\`${memberName}\` needs to be a ${explicitType} literal.`; + break; + case "symbol": + message = + `Symbol enum members cannot be initialized. Use \`${memberName},\` in ` + + `enum \`${enumName}\`.`; + break; + default: + // null + message = + `The enum member initializer for \`${memberName}\` needs to be a literal (either ` + + `a boolean, number, or string) in enum \`${enumName}\`.`; + } + return this.raise(pos, message); + } + + flowEnumErrorNumberMemberNotInitialized( + pos: number, + { enumName, memberName }: { enumName: string, memberName: string }, + ): void { + this.raise( + pos, + `Number enum members need to be initialized, e.g. \`${memberName} = 1\` in enum \`${enumName}\`.`, + ); + } + + flowEnumErrorStringMemberInconsistentlyInitailized( + pos: number, + { enumName }: { enumName: string }, + ): void { + this.raise( + pos, + `String enum members need to consistently either all use initializers, or use no initializers, ` + + `in enum \`${enumName}\`.`, + ); + } + + flowEnumMemberInit(): EnumMemberInit { + const startPos = this.state.start; + const endOfInit = () => this.match(tt.comma) || this.match(tt.braceR); + switch (this.state.type) { + case tt.num: { + const literal = this.parseLiteral(this.state.value, "NumericLiteral"); + if (endOfInit()) { + return { type: "number", pos: literal.start, value: literal }; + } + return { type: "invalid", pos: startPos }; + } + case tt.string: { + const literal = this.parseLiteral(this.state.value, "StringLiteral"); + if (endOfInit()) { + return { type: "string", pos: literal.start, value: literal }; + } + return { type: "invalid", pos: startPos }; + } + case tt._true: + case tt._false: { + const literal = this.parseBooleanLiteral(); + if (endOfInit()) { + return { + type: "boolean", + pos: literal.start, + value: literal, + }; + } + return { type: "invalid", pos: startPos }; + } + default: + return { type: "invalid", pos: startPos }; + } + } + + flowEnumMemberRaw(): { id: N.Node, init: EnumMemberInit } { + const pos = this.state.start; + const id = this.parseIdentifier(true); + const init = this.eat(tt.eq) + ? this.flowEnumMemberInit() + : { type: "none", pos }; + return { id, init }; + } + + flowEnumCheckExplicitTypeMismatch( + pos: number, + context: EnumContext, + expectedType: EnumExplicitType, + ): void { + const { explicitType } = context; + if (explicitType === null) { + return; + } + if (explicitType !== expectedType) { + this.flowEnumErrorInvalidMemberInitializer(pos, context); + } + } + + flowEnumMembers({ + enumName, + explicitType, + }: { + enumName: string, + explicitType: EnumExplicitType, + }): {| + booleanMembers: Array, + numberMembers: Array, + stringMembers: Array, + defaultedMembers: Array, + |} { + const seenNames = new Set(); + const members = { + booleanMembers: [], + numberMembers: [], + stringMembers: [], + defaultedMembers: [], + }; + while (!this.match(tt.braceR)) { + const memberNode = this.startNode(); + const { id, init } = this.flowEnumMemberRaw(); + const memberName = id.name; + if (memberName === "") { + continue; + } + if (/^[a-z]/.test(memberName)) { + this.flowEnumErrorInvalidMemberName(id.start, { + enumName, + memberName, + }); + } + if (seenNames.has(memberName)) { + this.flowEnumErrorDuplicateMemberName(id.start, { + enumName, + memberName, + }); + } + seenNames.add(memberName); + const context = { enumName, explicitType, memberName }; + memberNode.id = id; + switch (init.type) { + case "boolean": { + this.flowEnumCheckExplicitTypeMismatch( + init.pos, + context, + "boolean", + ); + memberNode.init = init.value; + members.booleanMembers.push( + this.finishNode(memberNode, "EnumBooleanMember"), + ); + break; + } + case "number": { + this.flowEnumCheckExplicitTypeMismatch(init.pos, context, "number"); + memberNode.init = init.value; + members.numberMembers.push( + this.finishNode(memberNode, "EnumNumberMember"), + ); + break; + } + case "string": { + this.flowEnumCheckExplicitTypeMismatch(init.pos, context, "string"); + memberNode.init = init.value; + members.stringMembers.push( + this.finishNode(memberNode, "EnumStringMember"), + ); + break; + } + case "invalid": { + throw this.flowEnumErrorInvalidMemberInitializer(init.pos, context); + } + case "none": { + switch (explicitType) { + case "boolean": + this.flowEnumErrorBooleanMemberNotInitialized( + init.pos, + context, + ); + break; + case "number": + this.flowEnumErrorNumberMemberNotInitialized(init.pos, context); + break; + default: + members.defaultedMembers.push( + this.finishNode(memberNode, "EnumDefaultedMember"), + ); + } + } + } + + if (!this.match(tt.braceR)) { + this.expect(tt.comma); + } + } + return members; + } + + flowEnumStringBody( + bodyNode: N.Node, + initializedMembers: Array, + defaultedMembers: Array, + { enumName }: { enumName: string }, + ): N.Node { + if (initializedMembers.length === 0) { + bodyNode.members = defaultedMembers; + } else if (defaultedMembers.length === 0) { + bodyNode.members = initializedMembers; + } else if (defaultedMembers.length > initializedMembers.length) { + bodyNode.members = defaultedMembers; + for (const member of initializedMembers) { + this.flowEnumErrorStringMemberInconsistentlyInitailized( + member.start, + { enumName }, + ); + } + } else { + bodyNode.members = initializedMembers; + for (const member of defaultedMembers) { + this.flowEnumErrorStringMemberInconsistentlyInitailized( + member.start, + { enumName }, + ); + } + } + return this.finishNode(bodyNode, "EnumStringBody"); + } + + flowEnumParseExplicitType({ + enumName, + }: { + enumName: string, + }): EnumExplicitType { + if (this.eatContextual("of")) { + if (!this.match(tt.name)) { + throw this.flowEnumErrorInvalidExplicitType(this.state.start, { + enumName, + suppliedType: null, + }); + } + + const { value } = this.state; + this.next(); + + if ( + value !== "boolean" && + value !== "number" && + value !== "string" && + value !== "symbol" + ) { + this.flowEnumErrorInvalidExplicitType(this.state.start, { + enumName, + suppliedType: value, + }); + } + + return value; } + return null; + } + + flowParseEnumDeclaration(node: N.Node): N.Node { + const id = this.parseIdentifier(); + node.id = id; + const enumName = id.name; + const explicitType = this.flowEnumParseExplicitType({ enumName }); + this.expect(tt.braceL); + const bodyNode = this.startNode(); + const members = this.flowEnumMembers({ enumName, explicitType }); + + switch (explicitType) { + case "boolean": + bodyNode.explicitType = true; + bodyNode.members = members.booleanMembers; + node.body = this.finishNode(bodyNode, "EnumBooleanBody"); + break; + case "number": + bodyNode.explicitType = true; + bodyNode.members = members.numberMembers; + node.body = this.finishNode(bodyNode, "EnumNumberBody"); + break; + case "string": + bodyNode.explicitType = true; + node.body = this.flowEnumStringBody( + bodyNode, + members.stringMembers, + members.defaultedMembers, + { enumName }, + ); + break; + case "symbol": + bodyNode.members = members.defaultedMembers; + node.body = this.finishNode(bodyNode, "EnumSymbolBody"); + break; + default: { + // null + const empty = () => { + bodyNode.members = []; + return this.finishNode(bodyNode, "EnumStringBody"); + }; + bodyNode.explicitType = false; + const boolsLen = members.booleanMembers.length; + const numsLen = members.numberMembers.length; + const strsLen = members.stringMembers.length; + const defaultedLen = members.defaultedMembers.length; + + if (!boolsLen && !numsLen && !strsLen && !defaultedLen) { + node.body = empty(); + } else if (!boolsLen && !numsLen) { + node.body = this.flowEnumStringBody( + bodyNode, + members.stringMembers, + members.defaultedMembers, + { enumName }, + ); + } else if (!numsLen && !strsLen && boolsLen >= defaultedLen) { + bodyNode.members = members.booleanMembers; + node.body = this.finishNode(bodyNode, "EnumBooleanBody"); + for (const member of members.defaultedMembers) { + this.flowEnumErrorBooleanMemberNotInitialized(member.start, { + enumName, + memberName: member.id.name, + }); + } + } else if (!boolsLen && !strsLen && numsLen >= defaultedLen) { + bodyNode.members = members.numberMembers; + node.body = this.finishNode(bodyNode, "EnumNumberBody"); + for (const member of members.defaultedMembers) { + this.flowEnumErrorNumberMemberNotInitialized(member.start, { + enumName, + memberName: member.id.name, + }); + } + } else { + node.body = empty(); + this.flowEnumErrorInconsistentMemberValues(id.start, { enumName }); + } + } + } + this.expect(tt.braceR); + return this.finishNode(node, "EnumDeclaration"); } }; diff --git a/packages/babel-parser/src/plugins/jsx/index.js b/packages/babel-parser/src/plugins/jsx/index.js index 4daa31ef545d..2aba709267f2 100644 --- a/packages/babel-parser/src/plugins/jsx/index.js +++ b/packages/babel-parser/src/plugins/jsx/index.js @@ -82,7 +82,7 @@ export default (superClass: Class): Class => let chunkStart = this.state.pos; for (;;) { if (this.state.pos >= this.length) { - this.raise(this.state.start, "Unterminated JSX contents"); + throw this.raise(this.state.start, "Unterminated JSX contents"); } const ch = this.input.charCodeAt(this.state.pos); @@ -142,7 +142,7 @@ export default (superClass: Class): Class => let chunkStart = ++this.state.pos; for (;;) { if (this.state.pos >= this.length) { - this.raise(this.state.start, "Unterminated string constant"); + throw this.raise(this.state.start, "Unterminated string constant"); } const ch = this.input.charCodeAt(this.state.pos); @@ -279,13 +279,12 @@ export default (superClass: Class): Class => this.next(); node = this.jsxParseExpressionContainer(node); if (node.expression.type === "JSXEmptyExpression") { - throw this.raise( + this.raise( node.start, "JSX attributes must only be assigned a non-empty expression", ); - } else { - return node; } + return node; case tt.jsxTagStart: case tt.string: @@ -485,8 +484,8 @@ export default (superClass: Class): Class => node.closingElement = closingElement; } node.children = children; - if (this.match(tt.relational) && this.state.value === "<") { - this.raise( + if (this.isRelational("<")) { + throw this.raise( this.state.start, "Adjacent JSX elements must be wrapped in an enclosing tag. " + "Did you want a JSX fragment <>...?", diff --git a/packages/babel-parser/src/plugins/typescript/index.js b/packages/babel-parser/src/plugins/typescript/index.js index 8adf82f1568a..4cf196b9a704 100644 --- a/packages/babel-parser/src/plugins/typescript/index.js +++ b/packages/babel-parser/src/plugins/typescript/index.js @@ -1,6 +1,9 @@ // @flow +/*:: declare var invariant; */ + import type { TokenType } from "../../tokenizer/types"; +import type State from "../../tokenizer/state"; import { types as tt } from "../../tokenizer/types"; import { types as ct } from "../../tokenizer/context"; import * as N from "../../types"; @@ -25,6 +28,7 @@ import * as charCodes from "charcodes"; type TsModifier = | "readonly" | "abstract" + | "declare" | "static" | "public" | "private" @@ -126,6 +130,31 @@ export default (superClass: Class): Class => return undefined; } + /** Parses a list of modifiers, in any order. + * If you need a specific order, you must call this function multiple times: + * this.tsParseModifiers(["public"]); + * this.tsParseModifiers(["abstract", "readonly"]); + */ + tsParseModifiers( + allowedModifiers: T[], + ): { [key: TsModifier]: ?true, __proto__: null } { + const modifiers = Object.create(null); + + while (true) { + const startPos = this.state.start; + const modifier: ?T = this.tsParseModifier(allowedModifiers); + + if (!modifier) break; + + if (Object.hasOwnProperty.call(modifiers, modifier)) { + this.raise(startPos, `Duplicate modifier: '${modifier}'`); + } + modifiers[modifier] = true; + } + + return modifiers; + } + tsIsListTerminator(kind: ParsingContext): boolean { switch (kind) { case "EnumMembers": @@ -234,8 +263,8 @@ export default (superClass: Class): Class => this.expect(tt._import); this.expect(tt.parenL); if (!this.match(tt.string)) { - throw this.unexpected( - null, + this.raise( + this.state.start, "Argument in a type import must be a string literal", ); } @@ -371,13 +400,13 @@ export default (superClass: Class): Class => pattern.type !== "ObjectPattern" && pattern.type !== "ArrayPattern" ) { - throw this.unexpected( + this.raise( pattern.start, "Name in a signature must be an Identifier, ObjectPattern or ArrayPattern," + `instead got ${pattern.type}`, ); } - return pattern; + return (pattern: any); }, ); } @@ -402,7 +431,7 @@ export default (superClass: Class): Class => return this.eat(tt.name) && this.match(tt.colon); } - tsTryParseIndexSignature(node: N.TsIndexSignature): ?N.TsIndexSignature { + tsTryParseIndexSignature(node: N.Node): ?N.TsIndexSignature { if ( !( this.match(tt.bracketL) && @@ -642,7 +671,7 @@ export default (superClass: Class): Class => const node: N.TsLiteralType = this.startNode(); const templateNode = this.parseTemplate(false); if (templateNode.expressions.length > 0) { - throw this.raise( + this.raise( templateNode.expressions[0].start, "Template literal types cannot have any substitution", ); @@ -651,6 +680,15 @@ export default (superClass: Class): Class => return this.finishNode(node, "TSLiteralType"); } + tsParseThisTypeOrThisTypePredicate(): N.TsThisType | N.TsTypePredicate { + const thisKeyword = this.tsParseThisTypeNode(); + if (this.isContextual("is") && !this.hasPrecedingLineBreak()) { + return this.tsParseThisTypePredicate(thisKeyword); + } else { + return thisKeyword; + } + } + tsParseNonArrayType(): N.TsType { switch (this.state.type) { case tt.name: @@ -686,14 +724,8 @@ export default (superClass: Class): Class => return this.finishNode(node, "TSLiteralType"); } break; - case tt._this: { - const thisKeyword = this.tsParseThisTypeNode(); - if (this.isContextual("is") && !this.hasPrecedingLineBreak()) { - return this.tsParseThisTypePredicate(thisKeyword); - } else { - return thisKeyword; - } - } + case tt._this: + return this.tsParseThisTypeOrThisTypePredicate(); case tt._typeof: return this.tsParseTypeQuery(); case tt._import: @@ -904,21 +936,52 @@ export default (superClass: Class): Class => const t: N.TsTypeAnnotation = this.startNode(); this.expect(returnToken); + const asserts = this.tsTryParse( + this.tsParseTypePredicateAsserts.bind(this), + ); + + if (asserts && this.match(tt._this)) { + // When asserts is false, thisKeyword is handled by tsParseNonArrayType + // : asserts this is type + let thisTypePredicate = this.tsParseThisTypeOrThisTypePredicate(); + // if it turns out to be a `TSThisType`, wrap it with `TSTypePredicate` + // : asserts this + if (thisTypePredicate.type === "TSThisType") { + const node: N.TsTypePredicate = this.startNodeAtNode(t); + node.parameterName = (thisTypePredicate: N.TsThisType); + node.asserts = true; + thisTypePredicate = this.finishNode(node, "TSTypePredicate"); + } else { + (thisTypePredicate: N.TsTypePredicate).asserts = true; + } + t.typeAnnotation = thisTypePredicate; + return this.finishNode(t, "TSTypeAnnotation"); + } + const typePredicateVariable = this.tsIsIdentifier() && this.tsTryParse(this.tsParseTypePredicatePrefix.bind(this)); if (!typePredicateVariable) { - return this.tsParseTypeAnnotation(/* eatColon */ false, t); + if (!asserts) { + // : type + return this.tsParseTypeAnnotation(/* eatColon */ false, t); + } + + const node: N.TsTypePredicate = this.startNodeAtNode(t); + // : asserts foo + node.parameterName = this.parseIdentifier(); + node.asserts = asserts; + t.typeAnnotation = this.finishNode(node, "TSTypePredicate"); + return this.finishNode(t, "TSTypeAnnotation"); } + // : asserts foo is type const type = this.tsParseTypeAnnotation(/* eatColon */ false); - - const node: N.TsTypePredicate = this.startNodeAtNode( - typePredicateVariable, - ); + const node = this.startNodeAtNode(t); node.parameterName = typePredicateVariable; node.typeAnnotation = type; + node.asserts = asserts; t.typeAnnotation = this.finishNode(node, "TSTypePredicate"); return this.finishNode(t, "TSTypeAnnotation"); }); @@ -946,6 +1009,30 @@ export default (superClass: Class): Class => } } + tsParseTypePredicateAsserts(): boolean { + if ( + !this.match(tt.name) || + this.state.value !== "asserts" || + this.hasPrecedingLineBreak() + ) { + return false; + } + const containsEsc = this.state.containsEsc; + this.next(); + if (!this.match(tt.name) && !this.match(tt._this)) { + return false; + } + + if (containsEsc) { + this.raise( + this.state.lastTokStart, + "Escape sequence in keyword asserts", + ); + } + + return true; + } + tsParseTypeAnnotation( eatColon = true, t: N.TsTypeAnnotation = this.startNode(), @@ -1246,17 +1333,12 @@ export default (superClass: Class): Class => return res; } - tsTryParseAndCatch(f: () => T): ?T { - const state = this.state.clone(); - try { - return f(); - } catch (e) { - if (e instanceof SyntaxError) { - this.state = state; - return undefined; - } - throw e; - } + tsTryParseAndCatch(f: () => T): ?T { + const result = this.tryParse(abort => f() || abort()); + + if (result.aborted || !result.node) return undefined; + if (result.error) this.state = result.failState; + return result.node; } tsTryParse(f: () => ?T): ?T { @@ -1528,12 +1610,12 @@ export default (superClass: Class): Class => if (accessibility) pp.accessibility = accessibility; if (readonly) pp.readonly = readonly; if (elt.type !== "Identifier" && elt.type !== "AssignmentPattern") { - throw this.raise( + this.raise( pp.start, "A parameter property may not be declared using a binding pattern.", ); } - pp.parameter = elt; + pp.parameter = ((elt: any): N.Identifier | N.AssignmentPattern); return this.finishNode(pp, "TSParameterProperty"); } @@ -1567,11 +1649,13 @@ export default (superClass: Class): Class => super.parseFunctionBodyAndFinish(node, type, isMethod); } - checkFunctionStatementId(node: N.Function): void { + registerFunctionStatementId(node: N.Function): void { if (!node.body && node.id) { + // Function ids are validated after parsing their body. + // For bodyless function, we need to do it here. this.checkLVal(node.id, BIND_TS_AMBIENT, null, "function name"); } else { - super.checkFunctionStatementId(...arguments); + super.registerFunctionStatementId(...arguments); } } @@ -1625,7 +1709,7 @@ export default (superClass: Class): Class => /* possibleAsync */ false, ); node.typeParameters = typeArguments; - return this.finishCallExpression(node); + return this.finishCallExpression(node, state.optionalChainMember); } else if (this.match(tt.backQuote)) { return this.parseTaggedTemplateExpression( startPos, @@ -1814,50 +1898,49 @@ export default (superClass: Class): Class => parseClassMemberWithIsStatic( classBody: N.ClassBody, - member: any, + member: N.ClassMember | N.TsIndexSignature, state: { hadConstructor: boolean }, isStatic: boolean, constructorAllowsSuper: boolean, ): void { - const methodOrProp: N.ClassMethod | N.ClassProperty = member; - const prop: N.ClassProperty = member; - const propOrIdx: N.ClassProperty | N.TsIndexSignature = member; - - let abstract = false, - readonly = false; - - const mod = this.tsParseModifier(["abstract", "readonly"]); - switch (mod) { - case "readonly": - readonly = true; - abstract = !!this.tsParseModifier(["abstract"]); - break; - case "abstract": - abstract = true; - readonly = !!this.tsParseModifier(["readonly"]); - break; - } + const modifiers = this.tsParseModifiers([ + "abstract", + "readonly", + "declare", + ]); - if (abstract) methodOrProp.abstract = true; - if (readonly) propOrIdx.readonly = true; + Object.assign(member, modifiers); - if (!abstract && !isStatic && !methodOrProp.accessibility) { - const idx = this.tsTryParseIndexSignature(member); - if (idx) { - classBody.body.push(idx); - return; + const idx = this.tsTryParseIndexSignature(member); + if (idx) { + classBody.body.push(idx); + + if (modifiers.abstract) { + this.raise( + member.start, + "Index signatures cannot have the 'abstract' modifier", + ); + } + if (isStatic) { + this.raise( + member.start, + "Index signatures cannot have the 'static' modifier", + ); + } + if ((member: any).accessibility) { + this.raise( + member.start, + `Index signatures cannot have an accessibility modifier ('${ + (member: any).accessibility + }')`, + ); } - } - if (readonly) { - // Must be a property (if not an index signature). - methodOrProp.static = isStatic; - this.parseClassPropertyName(prop); - this.parsePostMemberNameModifiers(methodOrProp); - this.pushClassProperty(classBody, prop); return; } + /*:: invariant(member.type !== "TSIndexSignature") */ + super.parseClassMemberWithIsStatic( classBody, member, @@ -1868,10 +1951,24 @@ export default (superClass: Class): Class => } parsePostMemberNameModifiers( - methodOrProp: N.ClassMethod | N.ClassProperty, + methodOrProp: N.ClassMethod | N.ClassProperty | N.ClassPrivateProperty, ): void { const optional = this.eat(tt.question); if (optional) methodOrProp.optional = true; + + if ((methodOrProp: any).readonly && this.match(tt.parenL)) { + this.raise( + methodOrProp.start, + "Class methods cannot have the 'readonly' modifier", + ); + } + + if ((methodOrProp: any).declare && this.match(tt.parenL)) { + this.raise( + methodOrProp.start, + "Class methods cannot have the 'declare' modifier", + ); + } } // Note: The reason we do this in `parseExpressionStatement` and not `parseStatement` @@ -1916,19 +2013,17 @@ export default (superClass: Class): Class => ); } - const state = this.state.clone(); - try { - return super.parseConditional(expr, noIn, startPos, startLoc); - } catch (err) { - if (!(err instanceof SyntaxError)) { - // istanbul ignore next: no such error is expected - throw err; - } + const result = this.tryParse(() => + super.parseConditional(expr, noIn, startPos, startLoc), + ); - this.state = state; - refNeedsArrowPos.start = err.pos || this.state.start; + if (!result.node) { + // $FlowIgnore + refNeedsArrowPos.start = result.error.pos || this.state.start; return expr; } + if (result.error) this.state = result.failState; + return result.node; } // Note: These "type casts" are *not* valid TS expressions. @@ -2007,16 +2102,53 @@ export default (superClass: Class): Class => if (typeParameters) node.typeParameters = typeParameters; } - parseClassProperty(node: N.ClassProperty): N.ClassProperty { + parseClassPropertyAnnotation( + node: N.ClassProperty | N.ClassPrivateProperty, + ): void { if (!node.optional && this.eat(tt.bang)) { node.definite = true; } const type = this.tsTryParseTypeAnnotation(); if (type) node.typeAnnotation = type; + } + + parseClassProperty(node: N.ClassProperty): N.ClassProperty { + this.parseClassPropertyAnnotation(node); + + if (node.declare && this.match(tt.equal)) { + this.raise( + this.state.start, + "'declare' class fields cannot have an initializer", + ); + } + return super.parseClassProperty(node); } + parseClassPrivateProperty( + node: N.ClassPrivateProperty, + ): N.ClassPrivateProperty { + // $FlowIgnore + if (node.abstract) { + this.raise( + node.start, + "Private elements cannot have the 'abstract' modifier.", + ); + } + + // $FlowIgnore + if (node.accessibility) { + this.raise( + node.start, + `Private elements cannot have an accessibility modifier ('${node.accessibility}')`, + ); + } + + this.parseClassPropertyAnnotation(node); + return super.parseClassPrivateProperty(node); + } + pushClassMethod( classBody: N.ClassBody, method: N.ClassMethod, @@ -2102,80 +2234,97 @@ export default (superClass: Class): Class => parseMaybeAssign(...args): N.Expression { // Note: When the JSX plugin is on, type assertions (` x`) aren't valid syntax. - let jsxError: ?SyntaxError; + let state: ?State; + let jsx; + let typeCast; if (this.match(tt.jsxTagStart)) { - const context = this.curContext(); - assert(context === ct.j_oTag); - // Only time j_oTag is pushed is right after j_expr. - assert(this.state.context[this.state.context.length - 2] === ct.j_expr); - // Prefer to parse JSX if possible. But may be an arrow fn. - const state = this.state.clone(); - try { - return super.parseMaybeAssign(...args); - } catch (err) { - if (!(err instanceof SyntaxError)) { - // istanbul ignore next: no such error is expected - throw err; - } + state = this.state.clone(); + + jsx = this.tryParse(() => super.parseMaybeAssign(...args), state); + /*:: invariant(!jsx.aborted) */ + + if (!jsx.error) return jsx.node; - this.state = state; - // Pop the context added by the jsxTagStart. - assert(this.curContext() === ct.j_oTag); - this.state.context.pop(); - assert(this.curContext() === ct.j_expr); - this.state.context.pop(); - jsxError = err; + // Remove `tc.j_expr` and `tc.j_oTag` from context added + // by parsing `jsxTagStart` to stop the JSX plugin from + // messing with the tokens + const { context } = this.state; + if (context[context.length - 1] === ct.j_oTag) { + context.length -= 2; + } else if (context[context.length - 1] === ct.j_expr) { + context.length -= 1; } } - if (jsxError === undefined && !this.isRelational("<")) { + if (!(jsx && jsx.error) && !this.isRelational("<")) { return super.parseMaybeAssign(...args); } // Either way, we're looking at a '<': tt.jsxTagStart or relational. - let arrowExpression; let typeParameters: N.TsTypeParameterDeclaration; - const state = this.state.clone(); - try { + state = state || this.state.clone(); + + const arrow = this.tryParse(abort => { // This is similar to TypeScript's `tryParseParenthesizedArrowFunctionExpression`. typeParameters = this.tsParseTypeParameters(); - arrowExpression = super.parseMaybeAssign(...args); + const expr = super.parseMaybeAssign(...args); + if ( - arrowExpression.type !== "ArrowFunctionExpression" || - (arrowExpression.extra && arrowExpression.extra.parenthesized) + expr.type !== "ArrowFunctionExpression" || + (expr.extra && expr.extra.parenthesized) ) { - this.unexpected(); // Go to the catch block (needs a SyntaxError). - } - } catch (err) { - if (!(err instanceof SyntaxError)) { - // istanbul ignore next: no such error is expected - throw err; + abort(); } - if (jsxError) { - throw jsxError; + // Correct TypeScript code should have at least 1 type parameter, but don't crash on bad code. + if (typeParameters && typeParameters.params.length !== 0) { + this.resetStartLocationFromNode(expr, typeParameters); } + expr.typeParameters = typeParameters; + return expr; + }, state); + if (!arrow.error && !arrow.aborted) return arrow.node; + + if (!jsx) { // Try parsing a type cast instead of an arrow function. // This will never happen outside of JSX. // (Because in JSX the '<' should be a jsxTagStart and not a relational. assert(!this.hasPlugin("jsx")); - // Parsing an arrow function failed, so try a type cast. - this.state = state; + // This will start with a type assertion (via parseMaybeUnary). // But don't directly call `this.tsParseTypeAssertion` because we want to handle any binary after it. - return super.parseMaybeAssign(...args); + typeCast = this.tryParse(() => super.parseMaybeAssign(...args), state); + /*:: invariant(!typeCast.aborted) */ + if (!typeCast.error) return typeCast.node; + } + + if (jsx && jsx.node) { + /*:: invariant(jsx.failState) */ + this.state = jsx.failState; + return jsx.node; } - // Correct TypeScript code should have at least 1 type parameter, but don't crash on bad code. - if (typeParameters && typeParameters.params.length !== 0) { - this.resetStartLocationFromNode(arrowExpression, typeParameters); + if (arrow.node) { + /*:: invariant(arrow.failState) */ + this.state = arrow.failState; + return arrow.node; } - arrowExpression.typeParameters = typeParameters; - return arrowExpression; + + if (typeCast && typeCast.node) { + /*:: invariant(typeCast.failState) */ + this.state = typeCast.failState; + return typeCast.node; + } + + if (jsx && jsx.thrown) throw jsx.error; + if (arrow.thrown) throw arrow.error; + if (typeCast && typeCast.thrown) throw typeCast.error; + + throw (jsx && jsx.error) || arrow.error || (typeCast && typeCast.error); } // Handle type assertions @@ -2191,23 +2340,20 @@ export default (superClass: Class): Class => if (this.match(tt.colon)) { // This is different from how the TS parser does it. // TS uses lookahead. The Babel Parser parses it as a parenthesized expression and converts. - const state = this.state.clone(); - try { + + const result = this.tryParse(abort => { const returnType = this.tsParseTypeOrTypePredicateAnnotation( tt.colon, ); - if (this.canInsertSemicolon() || !this.match(tt.arrow)) { - this.state = state; - return undefined; - } - node.returnType = returnType; - } catch (err) { - if (err instanceof SyntaxError) { - this.state = state; - } else { - // istanbul ignore next: no such error is expected - throw err; - } + if (this.canInsertSemicolon() || !this.match(tt.arrow)) abort(); + return returnType; + }); + + if (result.aborted) return; + + if (!result.thrown) { + if (result.error) this.state = result.failState; + node.returnType = result.node; } } @@ -2218,13 +2364,13 @@ export default (superClass: Class): Class => parseAssignableListItemTypes(param: N.Pattern) { if (this.eat(tt.question)) { if (param.type !== "Identifier") { - throw this.raise( + this.raise( param.start, "A binding pattern parameter cannot be optional in an implementation signature.", ); } - param.optional = true; + ((param: any): N.Identifier).optional = true; } const type = this.tsTryParseTypeAnnotation(); if (type) param.typeAnnotation = type; @@ -2365,7 +2511,10 @@ export default (superClass: Class): Class => } } - toAssignableList(exprList: N.Expression[]): $ReadOnlyArray { + toAssignableList( + exprList: N.Expression[], + isBinding: ?boolean, + ): $ReadOnlyArray { for (let i = 0; i < exprList.length; i++) { const expr = exprList[i]; if (!expr) continue; @@ -2375,10 +2524,14 @@ export default (superClass: Class): Class => break; case "TSAsExpression": case "TSTypeAssertion": - this.raise( - expr.start, - "Unexpected type cast in parameter position.", - ); + if (!isBinding) { + exprList[i] = this.typeCastToParameter(expr); + } else { + this.raise( + expr.start, + "Unexpected type cast in parameter position.", + ); + } break; } } diff --git a/packages/babel-parser/src/tokenizer/index.js b/packages/babel-parser/src/tokenizer/index.js index ab0dbe5b9237..32c8a03fc0b9 100644 --- a/packages/babel-parser/src/tokenizer/index.js +++ b/packages/babel-parser/src/tokenizer/index.js @@ -126,8 +126,11 @@ export default class Tokenizer extends LocationParser { // Move to the next token next(): void { - if (this.options.tokens && !this.isLookahead) { - this.state.tokens.push(new Token(this.state)); + if (!this.isLookahead) { + this.checkKeywordEscapes(); + if (this.options.tokens) { + this.state.tokens.push(new Token(this.state)); + } } this.state.lastTokEnd = this.state.end; @@ -248,7 +251,7 @@ export default class Tokenizer extends LocationParser { const startLoc = this.state.curPosition(); const start = this.state.pos; const end = this.input.indexOf("*/", this.state.pos + 2); - if (end === -1) this.raise(start, "Unterminated comment"); + if (end === -1) throw this.raise(start, "Unterminated comment"); this.state.pos = end + 2; lineBreakG.lastIndex = start; @@ -384,7 +387,7 @@ export default class Tokenizer extends LocationParser { const nextPos = this.state.pos + 1; const next = this.input.charCodeAt(nextPos); if (next >= charCodes.digit0 && next <= charCodes.digit9) { - this.raise(this.state.pos, "Unexpected digit after hash token"); + throw this.raise(this.state.pos, "Unexpected digit after hash token"); } if ( @@ -400,7 +403,7 @@ export default class Tokenizer extends LocationParser { ) { this.finishOp(tt.hash, 1); } else { - this.raise(this.state.pos, "Unexpected character '#'"); + throw this.raise(this.state.pos, "Unexpected character '#'"); } } @@ -808,7 +811,7 @@ export default class Tokenizer extends LocationParser { } } - this.raise( + throw this.raise( this.state.pos, `Unexpected character '${String.fromCodePoint(code)}'`, ); @@ -825,11 +828,11 @@ export default class Tokenizer extends LocationParser { let escaped, inClass; for (;;) { if (this.state.pos >= this.length) { - this.raise(start, "Unterminated regular expression"); + throw this.raise(start, "Unterminated regular expression"); } const ch = this.input.charAt(this.state.pos); if (lineBreak.test(ch)) { - this.raise(start, "Unterminated regular expression"); + throw this.raise(start, "Unterminated regular expression"); } if (escaped) { escaped = false; @@ -858,9 +861,6 @@ export default class Tokenizer extends LocationParser { if (mods.indexOf(char) > -1) { this.raise(this.state.pos + 1, "Duplicate regular expression flag"); } - - ++this.state.pos; - mods += char; } else if ( isIdentifierChar(charCode) || charCode === charCodes.backslash @@ -869,6 +869,9 @@ export default class Tokenizer extends LocationParser { } else { break; } + + ++this.state.pos; + mods += char; } this.finishToken(tt.regexp, { @@ -880,10 +883,16 @@ export default class Tokenizer extends LocationParser { // Read an integer in the given radix. Return null if zero digits // were read, the integer value otherwise. When `len` is given, this // will return `null` unless the integer has exactly `len` digits. + // When `forceLen` is `true`, it means that we already know that in case + // of a malformed number we have to skip `len` characters anyway, instead + // of bailing out early. For example, in "\u{123Z}" we want to read up to } + // anyway, while in "\u00Z" we will stop at Z instead of consuming four + // characters (and thus the closing quote). readInt( radix: number, len?: number, + forceLen?: boolean, allowNumSeparator: boolean = true, ): number | null { const start = this.state.pos; @@ -900,6 +909,7 @@ export default class Tokenizer extends LocationParser { ? allowedNumericSeparatorSiblings.oct : allowedNumericSeparatorSiblings.bin; + let invalid = false; let total = 0; for (let i = 0, e = len == null ? Infinity : len; i < e; ++i) { @@ -911,15 +921,19 @@ export default class Tokenizer extends LocationParser { const prev = this.input.charCodeAt(this.state.pos - 1); const next = this.input.charCodeAt(this.state.pos + 1); if (allowedSiblings.indexOf(next) === -1) { - this.raise(this.state.pos, "Invalid or unexpected token"); - } - - if ( + this.raise( + this.state.pos, + "A numeric separator is only allowed between two digits", + ); + } else if ( forbiddenSiblings.indexOf(prev) > -1 || forbiddenSiblings.indexOf(next) > -1 || Number.isNaN(next) ) { - this.raise(this.state.pos, "Invalid or unexpected token"); + this.raise( + this.state.pos, + "A numeric separator is only allowed between two digits", + ); } if (!allowNumSeparator) { @@ -944,13 +958,30 @@ export default class Tokenizer extends LocationParser { } else { val = Infinity; } - if (val >= radix) break; + if (val >= radix) { + // If we are in "errorRecovery" mode and we found a digit which is too big, + // don't break the loop. + + if (this.options.errorRecovery && val <= 9) { + val = 0; + this.raise( + this.state.start + i + 2, + "Expected number in radix " + radix, + ); + } else if (forceLen) { + val = 0; + invalid = true; + } else { + break; + } + } ++this.state.pos; total = total * radix + val; } if ( this.state.pos === start || - (len != null && this.state.pos - start !== len) + (len != null && this.state.pos - start !== len) || + invalid ) { return null; } @@ -976,7 +1007,7 @@ export default class Tokenizer extends LocationParser { } if (isIdentifierStart(this.input.codePointAt(this.state.pos))) { - this.raise(this.state.pos, "Identifier directly after number"); + throw this.raise(this.state.pos, "Identifier directly after number"); } if (isBigInt) { @@ -1062,7 +1093,7 @@ export default class Tokenizer extends LocationParser { } if (isIdentifierStart(this.input.codePointAt(this.state.pos))) { - this.raise(this.state.pos, "Identifier directly after number"); + throw this.raise(this.state.pos, "Identifier directly after number"); } // remove "_" for numeric literal separator, and "n" for BigInts @@ -1087,6 +1118,7 @@ export default class Tokenizer extends LocationParser { const codePos = ++this.state.pos; code = this.readHexChar( this.input.indexOf("}", this.state.pos) - this.state.pos, + true, throwOnInvalid, ); ++this.state.pos; @@ -1102,7 +1134,7 @@ export default class Tokenizer extends LocationParser { } } } else { - code = this.readHexChar(4, throwOnInvalid); + code = this.readHexChar(4, false, throwOnInvalid); } return code; } @@ -1112,7 +1144,7 @@ export default class Tokenizer extends LocationParser { chunkStart = ++this.state.pos; for (;;) { if (this.state.pos >= this.length) { - this.raise(this.state.start, "Unterminated string constant"); + throw this.raise(this.state.start, "Unterminated string constant"); } const ch = this.input.charCodeAt(this.state.pos); if (ch === quote) break; @@ -1128,7 +1160,7 @@ export default class Tokenizer extends LocationParser { ++this.state.pos; ++this.state.curLine; } else if (isNewLine(ch)) { - this.raise(this.state.start, "Unterminated string constant"); + throw this.raise(this.state.start, "Unterminated string constant"); } else { ++this.state.pos; } @@ -1145,7 +1177,7 @@ export default class Tokenizer extends LocationParser { containsInvalid = false; for (;;) { if (this.state.pos >= this.length) { - this.raise(this.state.start, "Unterminated template"); + throw this.raise(this.state.start, "Unterminated template"); } const ch = this.input.charCodeAt(this.state.pos); if ( @@ -1214,7 +1246,7 @@ export default class Tokenizer extends LocationParser { case charCodes.lowercaseR: return "\r"; case charCodes.lowercaseX: { - const code = this.readHexChar(2, throwOnInvalid); + const code = this.readHexChar(2, false, throwOnInvalid); return code === null ? null : String.fromCharCode(code); } case charCodes.lowercaseU: { @@ -1288,9 +1320,13 @@ export default class Tokenizer extends LocationParser { // Used to read character escape sequences ('\x', '\u'). - readHexChar(len: number, throwOnInvalid: boolean): number | null { + readHexChar( + len: number, + forceLen: boolean, + throwOnInvalid: boolean, + ): number | null { const codePos = this.state.pos; - const n = this.readInt(16, len, false); + const n = this.readInt(16, len, forceLen, false); if (n === null) { if (throwOnInvalid) { this.raise(codePos, "Bad character escape sequence"); @@ -1333,20 +1369,18 @@ export default class Tokenizer extends LocationParser { this.state.pos, "Expecting Unicode escape sequence \\uXXXX", ); + continue; } ++this.state.pos; const esc = this.readCodePoint(true); + if (esc !== null) { + if (!identifierCheck(esc)) { + this.raise(escStart, "Invalid Unicode escape"); + } - if ( - // $FlowFixMe (thinks esc may be null, but throwOnInvalid is true) - !identifierCheck(esc, true) - ) { - this.raise(escStart, "Invalid Unicode escape"); + word += String.fromCodePoint(esc); } - - // $FlowFixMe - word += String.fromCodePoint(esc); chunkStart = this.state.pos; } else { break; @@ -1364,7 +1398,7 @@ export default class Tokenizer extends LocationParser { readWord(): void { const word = this.readWord1(); - const type = (!this.state.containsEsc && keywordTypes.get(word)) || tt.name; + const type = keywordTypes.get(word) || tt.name; // Allow @@iterator and @@asyncIterator as a identifier only inside type if ( @@ -1377,6 +1411,13 @@ export default class Tokenizer extends LocationParser { this.finishToken(type, word); } + checkKeywordEscapes(): void { + const kw = this.state.type.keyword; + if (kw && this.state.containsEsc) { + this.raise(this.state.start, `Escape sequence in keyword ${kw}`); + } + } + braceIsBlock(prevType: TokenType): boolean { const parent = this.curContext(); if (parent === ct.functionExpression || parent === ct.functionStatement) { diff --git a/packages/babel-parser/src/tokenizer/state.js b/packages/babel-parser/src/tokenizer/state.js index 4ee937e1d292..6ff711f373c6 100644 --- a/packages/babel-parser/src/tokenizer/state.js +++ b/packages/babel-parser/src/tokenizer/state.js @@ -38,6 +38,8 @@ export default class State { this.startLoc = this.endLoc = this.curPosition(); } + errors: SyntaxError[] = []; + // Used to signify the start of a potential arrow function potentialArrowAt: number = -1; diff --git a/packages/babel-parser/src/types.js b/packages/babel-parser/src/types.js index 8560da3a3f73..82815b1443d6 100644 --- a/packages/babel-parser/src/types.js +++ b/packages/babel-parser/src/types.js @@ -743,18 +743,19 @@ export type ClassPrivateMethod = NodeBase & computed: false, }; -export type ClassProperty = ClassMemberBase & { - type: "ClassProperty", - key: Expression, - value: ?Expression, // TODO: Not in spec that this is nullable. +export type ClassProperty = ClassMemberBase & + DeclarationBase & { + type: "ClassProperty", + key: Expression, + value: ?Expression, // TODO: Not in spec that this is nullable. - typeAnnotation?: ?TypeAnnotationBase, // TODO: Not in spec - variance?: ?FlowVariance, // TODO: Not in spec + typeAnnotation?: ?TypeAnnotationBase, // TODO: Not in spec + variance?: ?FlowVariance, // TODO: Not in spec - // TypeScript only: (TODO: Not in spec) - readonly?: true, - definite?: true, -}; + // TypeScript only: (TODO: Not in spec) + readonly?: true, + definite?: true, + }; export type ClassPrivateProperty = NodeBase & { type: "ClassPrivateProperty", @@ -762,7 +763,14 @@ export type ClassPrivateProperty = NodeBase & { value: ?Expression, // TODO: Not in spec that this is nullable. static: boolean, computed: false, - typeAnnotation?: ?TypeAnnotation, // TODO: Not in spec + + // Flow and Typescript + typeAnnotation?: ?TypeAnnotationBase, + + // TypeScript only + optional?: true, + definite?: true, + readonly?: true, }; export type OptClassDeclaration = ClassBase & @@ -1219,6 +1227,7 @@ export type TsTypePredicate = TsTypeBase & { type: "TSTypePredicate", parameterName: Identifier | TsThisType, typeAnnotation: TsTypeAnnotation, + asserts?: boolean, }; // `typeof` operator diff --git a/packages/babel-parser/src/util/identifier.js b/packages/babel-parser/src/util/identifier.js index 7fda0e27de71..cbcc59cb6f81 100644 --- a/packages/babel-parser/src/util/identifier.js +++ b/packages/babel-parser/src/util/identifier.js @@ -21,9 +21,7 @@ const reservedWords = { }; const reservedWordsStrictSet = new Set(reservedWords.strict); -const reservedWordsStrictBindSet = new Set( - reservedWords.strict.concat(reservedWords.strictBind), -); +const reservedWordsStrictBindSet = new Set(reservedWords.strictBind); /** * Checks if word is a reserved word in non-strict mode @@ -41,6 +39,14 @@ export function isStrictReservedWord(word: string, inModule: boolean): boolean { return isReservedWord(word, inModule) || reservedWordsStrictSet.has(word); } +/** + * Checks if word is a reserved word in binding strict mode, but it is allowed as + * a normal identifier. + */ +export function isStrictBindOnlyReservedWord(word: string): boolean { + return reservedWordsStrictBindSet.has(word); +} + /** * Checks if word is a reserved word in binding strict mode * @@ -50,7 +56,9 @@ export function isStrictBindReservedWord( word: string, inModule: boolean, ): boolean { - return isReservedWord(word, inModule) || reservedWordsStrictBindSet.has(word); + return ( + isStrictReservedWord(word, inModule) || isStrictBindOnlyReservedWord(word) + ); } export function isKeyword(word: string): boolean { diff --git a/packages/babel-parser/test/expressions/is-expression-babel-parser/fail/7/options.json b/packages/babel-parser/test/expressions/is-expression-babel-parser/fail/7/options.json deleted file mode 100644 index 12b18792fcc4..000000000000 --- a/packages/babel-parser/test/expressions/is-expression-babel-parser/fail/7/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Illegal 'use strict' directive in function with non-simple parameter list (1:0)" -} diff --git a/packages/babel-parser/test/expressions/is-expression-babel-parser/fail/7/output.json b/packages/babel-parser/test/expressions/is-expression-babel-parser/fail/7/output.json new file mode 100644 index 000000000000..bed17cab3909 --- /dev/null +++ b/packages/babel-parser/test/expressions/is-expression-babel-parser/fail/7/output.json @@ -0,0 +1,128 @@ +{ + "type": "FunctionExpression", + "start": 0, + "end": 40, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 40 + } + }, + "id": null, + "generator": false, + "async": false, + "params": [ + { + "type": "AssignmentPattern", + "start": 10, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "left": { + "type": "Identifier", + "start": 10, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 11 + }, + "identifierName": "a" + }, + "name": "a" + }, + "right": { + "type": "StringLiteral", + "start": 14, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "extra": { + "rawValue": "default", + "raw": "\"default\"" + }, + "value": "default" + } + } + ], + "body": { + "type": "BlockStatement", + "start": 25, + "end": 40, + "loc": { + "start": { + "line": 1, + "column": 25 + }, + "end": { + "line": 1, + "column": 40 + } + }, + "body": [], + "directives": [ + { + "type": "Directive", + "start": 26, + "end": 39, + "loc": { + "start": { + "line": 1, + "column": 26 + }, + "end": { + "line": 1, + "column": 39 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 26, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 26 + }, + "end": { + "line": 1, + "column": 38 + } + }, + "value": "use strict", + "extra": { + "raw": "\"use strict\"", + "rawValue": "use strict" + } + } + } + ] + }, + "errors": [ + "SyntaxError: Illegal 'use strict' directive in function with non-simple parameter list (1:0)" + ] +} \ No newline at end of file diff --git a/packages/babel-parser/test/expressions/is-expression-babel-parser/fail/8/options.json b/packages/babel-parser/test/expressions/is-expression-babel-parser/fail/8/options.json index 5f24fc4399ed..4f434cf0aa86 100644 --- a/packages/babel-parser/test/expressions/is-expression-babel-parser/fail/8/options.json +++ b/packages/babel-parser/test/expressions/is-expression-babel-parser/fail/8/options.json @@ -1,4 +1,3 @@ { - "strictMode": true, - "throws": "Unexpected reserved word 'public' (2:0)" -} + "strictMode": true +} \ No newline at end of file diff --git a/packages/babel-parser/test/expressions/is-expression-babel-parser/fail/8/output.json b/packages/babel-parser/test/expressions/is-expression-babel-parser/fail/8/output.json new file mode 100644 index 000000000000..df12702dd8b4 --- /dev/null +++ b/packages/babel-parser/test/expressions/is-expression-babel-parser/fail/8/output.json @@ -0,0 +1,20 @@ +{ + "type": "Identifier", + "start": 1, + "end": 7, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 6 + }, + "identifierName": "public" + }, + "name": "public", + "errors": [ + "SyntaxError: Unexpected reserved word 'public' (2:0)" + ] +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/categorized/invalid-fn-decl-inside-loop/options.json b/packages/babel-parser/test/fixtures/core/categorized/invalid-fn-decl-inside-loop/options.json deleted file mode 100644 index 05a7826ae8ba..000000000000 --- a/packages/babel-parser/test/fixtures/core/categorized/invalid-fn-decl-inside-loop/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "In non-strict mode code, functions can only be declared at top level, inside a block, or as the body of an if statement (1:10)" -} diff --git a/packages/babel-parser/test/fixtures/core/categorized/invalid-fn-decl-inside-loop/output.json b/packages/babel-parser/test/fixtures/core/categorized/invalid-fn-decl-inside-loop/output.json new file mode 100644 index 000000000000..7ad34b6ae910 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/categorized/invalid-fn-decl-inside-loop/output.json @@ -0,0 +1,125 @@ +{ + "type": "File", + "start": 0, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "errors": [ + "SyntaxError: In non-strict mode code, functions can only be declared at top level, inside a block, or as the body of an if statement (1:10)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "WhileStatement", + "start": 0, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "test": { + "type": "NumericLiteral", + "start": 7, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + }, + "body": { + "type": "FunctionDeclaration", + "start": 10, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "id": { + "type": "Identifier", + "start": 19, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 22 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 24, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 24 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "body": [], + "directives": [] + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/categorized/invalid-fn-decl-labeled-inside-loop/options.json b/packages/babel-parser/test/fixtures/core/categorized/invalid-fn-decl-labeled-inside-loop/options.json deleted file mode 100644 index 395620bfa2f8..000000000000 --- a/packages/babel-parser/test/fixtures/core/categorized/invalid-fn-decl-labeled-inside-loop/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "In non-strict mode code, functions can only be declared at top level, inside a block, or as the body of an if statement (1:20)" -} diff --git a/packages/babel-parser/test/fixtures/core/categorized/invalid-fn-decl-labeled-inside-loop/output.json b/packages/babel-parser/test/fixtures/core/categorized/invalid-fn-decl-labeled-inside-loop/output.json new file mode 100644 index 000000000000..64064c04c2b9 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/categorized/invalid-fn-decl-labeled-inside-loop/output.json @@ -0,0 +1,189 @@ +{ + "type": "File", + "start": 0, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "errors": [ + "SyntaxError: In non-strict mode code, functions can only be declared at top level, inside a block, or as the body of an if statement (1:20)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "WhileStatement", + "start": 0, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "test": { + "type": "NumericLiteral", + "start": 7, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + }, + "body": { + "type": "LabeledStatement", + "start": 10, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "body": { + "type": "LabeledStatement", + "start": 15, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "body": { + "type": "FunctionDeclaration", + "start": 20, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 20 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "id": { + "type": "Identifier", + "start": 29, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 29 + }, + "end": { + "line": 1, + "column": 32 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 34, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 34 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "body": [], + "directives": [] + } + }, + "label": { + "type": "Identifier", + "start": 15, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 18 + }, + "identifierName": "bar" + }, + "name": "bar" + } + }, + "label": { + "type": "Identifier", + "start": 10, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 13 + }, + "identifierName": "foo" + }, + "name": "foo" + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/escape-keyword/invalid/options.json b/packages/babel-parser/test/fixtures/core/escape-keyword/invalid/options.json deleted file mode 100644 index 3ef90d2032d2..000000000000 --- a/packages/babel-parser/test/fixtures/core/escape-keyword/invalid/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Unexpected keyword 'break' (2:2)" -} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/escape-keyword/invalid/output.json b/packages/babel-parser/test/fixtures/core/escape-keyword/invalid/output.json new file mode 100644 index 000000000000..742ca4b45728 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/escape-keyword/invalid/output.json @@ -0,0 +1,160 @@ +{ + "type": "File", + "start": 0, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 2 + } + }, + "errors": [ + "SyntaxError: Unexpected keyword 'break' (2:2)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 2 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "VariableDeclaration", + "start": 0, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 2 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 4, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 4, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 5 + }, + "identifierName": "a" + }, + "name": "a" + }, + "init": { + "type": "ObjectExpression", + "start": 8, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "properties": [ + { + "type": "ObjectProperty", + "start": 12, + "end": 22, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 12 + } + }, + "method": false, + "key": { + "type": "Identifier", + "start": 12, + "end": 22, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 12 + }, + "identifierName": "break" + }, + "name": "break" + }, + "computed": false, + "shorthand": true, + "value": { + "type": "Identifier", + "start": 12, + "end": 22, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 12 + }, + "identifierName": "break" + }, + "name": "break" + }, + "extra": { + "shorthand": true + } + } + ] + } + } + ], + "kind": "var" + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/escape-template/non-octal-eight/options.json b/packages/babel-parser/test/fixtures/core/escape-template/non-octal-eight/options.json deleted file mode 100644 index 3ae5cb6c96c4..000000000000 --- a/packages/babel-parser/test/fixtures/core/escape-template/non-octal-eight/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid escape sequence in template (1:2)" -} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/escape-template/non-octal-eight/output.json b/packages/babel-parser/test/fixtures/core/escape-template/non-octal-eight/output.json new file mode 100644 index 000000000000..20b84ecf03fa --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/escape-template/non-octal-eight/output.json @@ -0,0 +1,91 @@ +{ + "type": "File", + "start": 0, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "errors": [ + "SyntaxError: Invalid escape sequence in template (1:2)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "expression": { + "type": "TemplateLiteral", + "start": 0, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "expressions": [], + "quasis": [ + { + "type": "TemplateElement", + "start": 1, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "value": { + "raw": "\\8", + "cooked": null + }, + "tail": true + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/escape-template/non-octal-nine/options.json b/packages/babel-parser/test/fixtures/core/escape-template/non-octal-nine/options.json deleted file mode 100644 index 3ae5cb6c96c4..000000000000 --- a/packages/babel-parser/test/fixtures/core/escape-template/non-octal-nine/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid escape sequence in template (1:2)" -} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/escape-template/non-octal-nine/output.json b/packages/babel-parser/test/fixtures/core/escape-template/non-octal-nine/output.json new file mode 100644 index 000000000000..9e0985f69a92 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/escape-template/non-octal-nine/output.json @@ -0,0 +1,91 @@ +{ + "type": "File", + "start": 0, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "errors": [ + "SyntaxError: Invalid escape sequence in template (1:2)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "expression": { + "type": "TemplateLiteral", + "start": 0, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "expressions": [], + "quasis": [ + { + "type": "TemplateElement", + "start": 1, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "value": { + "raw": "\\9", + "cooked": null + }, + "tail": true + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/object/invalid-property-initializer-1/input.js b/packages/babel-parser/test/fixtures/core/object/invalid-property-initializer-1/input.js new file mode 100644 index 000000000000..9538075c50c3 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/object/invalid-property-initializer-1/input.js @@ -0,0 +1,4 @@ +const obj = { + bar: x = 123, + foo = 123 +}; diff --git a/packages/babel-parser/test/fixtures/core/object/invalid-property-initializer-1/options.json b/packages/babel-parser/test/fixtures/core/object/invalid-property-initializer-1/options.json new file mode 100644 index 000000000000..e92fc4e28742 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/object/invalid-property-initializer-1/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Unexpected token (3:6)" +} diff --git a/packages/babel-parser/test/fixtures/core/object/invalid-property-initializer/input.js b/packages/babel-parser/test/fixtures/core/object/invalid-property-initializer/input.js new file mode 100644 index 000000000000..868f237838df --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/object/invalid-property-initializer/input.js @@ -0,0 +1,4 @@ +const obj = { + foo = 123, + bar: x = 123 +}; diff --git a/packages/babel-parser/test/fixtures/core/object/invalid-property-initializer/options.json b/packages/babel-parser/test/fixtures/core/object/invalid-property-initializer/options.json new file mode 100644 index 000000000000..9660494a29ea --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/object/invalid-property-initializer/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Unexpected token (2:6)" +} diff --git a/packages/babel-parser/test/fixtures/core/object/valid-property-initializer/input.js b/packages/babel-parser/test/fixtures/core/object/valid-property-initializer/input.js new file mode 100644 index 000000000000..0cd0f5146c8d --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/object/valid-property-initializer/input.js @@ -0,0 +1,4 @@ +const obj = { + foo = 123, + bar: x = 123, +} = { foo: 24, bar: 45 }; diff --git a/packages/babel-parser/test/fixtures/core/object/valid-property-initializer/output.json b/packages/babel-parser/test/fixtures/core/object/valid-property-initializer/output.json new file mode 100644 index 000000000000..7b1a47d91e7a --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/object/valid-property-initializer/output.json @@ -0,0 +1,425 @@ +{ + "type": "File", + "start": 0, + "end": 68, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 25 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 68, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 25 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "VariableDeclaration", + "start": 0, + "end": 68, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 25 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 6, + "end": 67, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 4, + "column": 24 + } + }, + "id": { + "type": "Identifier", + "start": 6, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 9 + }, + "identifierName": "obj" + }, + "name": "obj" + }, + "init": { + "type": "AssignmentExpression", + "start": 12, + "end": 67, + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 4, + "column": 24 + } + }, + "operator": "=", + "left": { + "type": "ObjectPattern", + "start": 12, + "end": 44, + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "properties": [ + { + "type": "ObjectProperty", + "start": 16, + "end": 25, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 11 + } + }, + "method": false, + "key": { + "type": "Identifier", + "start": 16, + "end": 19, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 5 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "computed": false, + "shorthand": true, + "value": { + "type": "AssignmentPattern", + "start": 16, + "end": 25, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 11 + } + }, + "left": { + "type": "Identifier", + "start": 16, + "end": 19, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 5 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "right": { + "type": "NumericLiteral", + "start": 22, + "end": 25, + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 11 + } + }, + "extra": { + "rawValue": 123, + "raw": "123" + }, + "value": 123 + } + }, + "extra": { + "shorthand": true + } + }, + { + "type": "ObjectProperty", + "start": 29, + "end": 41, + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 3, + "column": 14 + } + }, + "method": false, + "key": { + "type": "Identifier", + "start": 29, + "end": 32, + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 3, + "column": 5 + }, + "identifierName": "bar" + }, + "name": "bar" + }, + "computed": false, + "shorthand": false, + "value": { + "type": "AssignmentPattern", + "start": 34, + "end": 41, + "loc": { + "start": { + "line": 3, + "column": 7 + }, + "end": { + "line": 3, + "column": 14 + } + }, + "left": { + "type": "Identifier", + "start": 34, + "end": 35, + "loc": { + "start": { + "line": 3, + "column": 7 + }, + "end": { + "line": 3, + "column": 8 + }, + "identifierName": "x" + }, + "name": "x" + }, + "right": { + "type": "NumericLiteral", + "start": 38, + "end": 41, + "loc": { + "start": { + "line": 3, + "column": 11 + }, + "end": { + "line": 3, + "column": 14 + } + }, + "extra": { + "rawValue": 123, + "raw": "123" + }, + "value": 123 + } + } + } + ], + "extra": { + "trailingComma": 41 + } + }, + "right": { + "type": "ObjectExpression", + "start": 47, + "end": 67, + "loc": { + "start": { + "line": 4, + "column": 4 + }, + "end": { + "line": 4, + "column": 24 + } + }, + "properties": [ + { + "type": "ObjectProperty", + "start": 49, + "end": 56, + "loc": { + "start": { + "line": 4, + "column": 6 + }, + "end": { + "line": 4, + "column": 13 + } + }, + "method": false, + "key": { + "type": "Identifier", + "start": 49, + "end": 52, + "loc": { + "start": { + "line": 4, + "column": 6 + }, + "end": { + "line": 4, + "column": 9 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "computed": false, + "shorthand": false, + "value": { + "type": "NumericLiteral", + "start": 54, + "end": 56, + "loc": { + "start": { + "line": 4, + "column": 11 + }, + "end": { + "line": 4, + "column": 13 + } + }, + "extra": { + "rawValue": 24, + "raw": "24" + }, + "value": 24 + } + }, + { + "type": "ObjectProperty", + "start": 58, + "end": 65, + "loc": { + "start": { + "line": 4, + "column": 15 + }, + "end": { + "line": 4, + "column": 22 + } + }, + "method": false, + "key": { + "type": "Identifier", + "start": 58, + "end": 61, + "loc": { + "start": { + "line": 4, + "column": 15 + }, + "end": { + "line": 4, + "column": 18 + }, + "identifierName": "bar" + }, + "name": "bar" + }, + "computed": false, + "shorthand": false, + "value": { + "type": "NumericLiteral", + "start": 63, + "end": 65, + "loc": { + "start": { + "line": 4, + "column": 20 + }, + "end": { + "line": 4, + "column": 22 + } + }, + "extra": { + "rawValue": 45, + "raw": "45" + }, + "value": 45 + } + } + ] + } + } + } + ], + "kind": "const" + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/regression/non-octal-float-strict-mode/options.json b/packages/babel-parser/test/fixtures/core/regression/non-octal-float-strict-mode/options.json index 8ac5b45f7194..54925950e059 100644 --- a/packages/babel-parser/test/fixtures/core/regression/non-octal-float-strict-mode/options.json +++ b/packages/babel-parser/test/fixtures/core/regression/non-octal-float-strict-mode/options.json @@ -1,4 +1,3 @@ { - "sourceType": "module", - "throws": "Legacy octal literals are not allowed in strict mode (1:0)" -} + "sourceType": "module" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/regression/non-octal-float-strict-mode/output.json b/packages/babel-parser/test/fixtures/core/regression/non-octal-float-strict-mode/output.json new file mode 100644 index 000000000000..99253558c815 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/regression/non-octal-float-strict-mode/output.json @@ -0,0 +1,73 @@ +{ + "type": "File", + "start": 0, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "errors": [ + "SyntaxError: Legacy octal literals are not allowed in strict mode (1:0)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 0, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "extra": { + "rawValue": 9.5, + "raw": "09.5" + }, + "value": 9.5 + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-2nd-lvl-lex-nested/options.json b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-2nd-lvl-lex-nested/options.json deleted file mode 100644 index b14806508f97..000000000000 --- a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-2nd-lvl-lex-nested/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Identifier 'foo' has already been declared (4:6)" -} diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-2nd-lvl-lex-nested/output.json b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-2nd-lvl-lex-nested/output.json new file mode 100644 index 000000000000..f017f0fa5f00 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-2nd-lvl-lex-nested/output.json @@ -0,0 +1,247 @@ +{ + "type": "File", + "start": 0, + "end": 44, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 5, + "column": 1 + } + }, + "errors": [ + "SyntaxError: Identifier 'foo' has already been declared (4:6)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 44, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 5, + "column": 1 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "BlockStatement", + "start": 0, + "end": 44, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 5, + "column": 1 + } + }, + "body": [ + { + "type": "VariableDeclaration", + "start": 4, + "end": 12, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 10 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 8, + "end": 11, + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 9 + } + }, + "id": { + "type": "Identifier", + "start": 8, + "end": 11, + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 9 + }, + "identifierName": "bar" + }, + "name": "bar" + }, + "init": null + } + ], + "kind": "let" + }, + { + "type": "VariableDeclaration", + "start": 15, + "end": 27, + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 3, + "column": 14 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 19, + "end": 26, + "loc": { + "start": { + "line": 3, + "column": 6 + }, + "end": { + "line": 3, + "column": 13 + } + }, + "id": { + "type": "Identifier", + "start": 19, + "end": 22, + "loc": { + "start": { + "line": 3, + "column": 6 + }, + "end": { + "line": 3, + "column": 9 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "init": { + "type": "NumericLiteral", + "start": 25, + "end": 26, + "loc": { + "start": { + "line": 3, + "column": 12 + }, + "end": { + "line": 3, + "column": 13 + } + }, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + } + } + ], + "kind": "var" + }, + { + "type": "VariableDeclaration", + "start": 30, + "end": 42, + "loc": { + "start": { + "line": 4, + "column": 2 + }, + "end": { + "line": 4, + "column": 14 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 34, + "end": 41, + "loc": { + "start": { + "line": 4, + "column": 6 + }, + "end": { + "line": 4, + "column": 13 + } + }, + "id": { + "type": "Identifier", + "start": 34, + "end": 37, + "loc": { + "start": { + "line": 4, + "column": 6 + }, + "end": { + "line": 4, + "column": 9 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "init": { + "type": "NumericLiteral", + "start": 40, + "end": 41, + "loc": { + "start": { + "line": 4, + "column": 12 + }, + "end": { + "line": 4, + "column": 13 + } + }, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + } + } + ], + "kind": "let" + } + ], + "directives": [] + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-2nd-lvl-lex/options.json b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-2nd-lvl-lex/options.json deleted file mode 100644 index 6a0c16d56696..000000000000 --- a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-2nd-lvl-lex/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Identifier 'foo' has already been declared (3:4)" -} diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-2nd-lvl-lex/output.json b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-2nd-lvl-lex/output.json new file mode 100644 index 000000000000..758528386efb --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-2nd-lvl-lex/output.json @@ -0,0 +1,229 @@ +{ + "type": "File", + "start": 0, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 12 + } + }, + "errors": [ + "SyntaxError: Identifier 'foo' has already been declared (3:4)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 12 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "VariableDeclaration", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 4, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "id": { + "type": "Identifier", + "start": 4, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 7 + }, + "identifierName": "bar" + }, + "name": "bar" + }, + "init": null + } + ], + "kind": "let" + }, + { + "type": "VariableDeclaration", + "start": 9, + "end": 21, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 12 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 13, + "end": 20, + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 11 + } + }, + "id": { + "type": "Identifier", + "start": 13, + "end": 16, + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 7 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "init": { + "type": "NumericLiteral", + "start": 19, + "end": 20, + "loc": { + "start": { + "line": 2, + "column": 10 + }, + "end": { + "line": 2, + "column": 11 + } + }, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + } + } + ], + "kind": "var" + }, + { + "type": "VariableDeclaration", + "start": 22, + "end": 34, + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 12 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 26, + "end": 33, + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 11 + } + }, + "id": { + "type": "Identifier", + "start": 26, + "end": 29, + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 7 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "init": { + "type": "NumericLiteral", + "start": 32, + "end": 33, + "loc": { + "start": { + "line": 3, + "column": 10 + }, + "end": { + "line": 3, + "column": 11 + } + }, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + } + } + ], + "kind": "let" + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-2nd-lvl-var-nested/options.json b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-2nd-lvl-var-nested/options.json deleted file mode 100644 index b14806508f97..000000000000 --- a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-2nd-lvl-var-nested/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Identifier 'foo' has already been declared (4:6)" -} diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-2nd-lvl-var-nested/output.json b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-2nd-lvl-var-nested/output.json new file mode 100644 index 000000000000..0444f665d33d --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-2nd-lvl-var-nested/output.json @@ -0,0 +1,247 @@ +{ + "type": "File", + "start": 0, + "end": 44, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 5, + "column": 1 + } + }, + "errors": [ + "SyntaxError: Identifier 'foo' has already been declared (4:6)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 44, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 5, + "column": 1 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "BlockStatement", + "start": 0, + "end": 44, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 5, + "column": 1 + } + }, + "body": [ + { + "type": "VariableDeclaration", + "start": 4, + "end": 12, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 10 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 8, + "end": 11, + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 9 + } + }, + "id": { + "type": "Identifier", + "start": 8, + "end": 11, + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 9 + }, + "identifierName": "bar" + }, + "name": "bar" + }, + "init": null + } + ], + "kind": "let" + }, + { + "type": "VariableDeclaration", + "start": 15, + "end": 27, + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 3, + "column": 14 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 19, + "end": 26, + "loc": { + "start": { + "line": 3, + "column": 6 + }, + "end": { + "line": 3, + "column": 13 + } + }, + "id": { + "type": "Identifier", + "start": 19, + "end": 22, + "loc": { + "start": { + "line": 3, + "column": 6 + }, + "end": { + "line": 3, + "column": 9 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "init": { + "type": "NumericLiteral", + "start": 25, + "end": 26, + "loc": { + "start": { + "line": 3, + "column": 12 + }, + "end": { + "line": 3, + "column": 13 + } + }, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + } + } + ], + "kind": "let" + }, + { + "type": "VariableDeclaration", + "start": 30, + "end": 42, + "loc": { + "start": { + "line": 4, + "column": 2 + }, + "end": { + "line": 4, + "column": 14 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 34, + "end": 41, + "loc": { + "start": { + "line": 4, + "column": 6 + }, + "end": { + "line": 4, + "column": 13 + } + }, + "id": { + "type": "Identifier", + "start": 34, + "end": 37, + "loc": { + "start": { + "line": 4, + "column": 6 + }, + "end": { + "line": 4, + "column": 9 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "init": { + "type": "NumericLiteral", + "start": 40, + "end": 41, + "loc": { + "start": { + "line": 4, + "column": 12 + }, + "end": { + "line": 4, + "column": 13 + } + }, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + } + } + ], + "kind": "var" + } + ], + "directives": [] + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-2nd-lvl-var/options.json b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-2nd-lvl-var/options.json deleted file mode 100644 index 6a0c16d56696..000000000000 --- a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-2nd-lvl-var/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Identifier 'foo' has already been declared (3:4)" -} diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-2nd-lvl-var/output.json b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-2nd-lvl-var/output.json new file mode 100644 index 000000000000..76f48823dd81 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-2nd-lvl-var/output.json @@ -0,0 +1,229 @@ +{ + "type": "File", + "start": 0, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 12 + } + }, + "errors": [ + "SyntaxError: Identifier 'foo' has already been declared (3:4)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 12 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "VariableDeclaration", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 4, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "id": { + "type": "Identifier", + "start": 4, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 7 + }, + "identifierName": "bar" + }, + "name": "bar" + }, + "init": null + } + ], + "kind": "let" + }, + { + "type": "VariableDeclaration", + "start": 9, + "end": 21, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 12 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 13, + "end": 20, + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 11 + } + }, + "id": { + "type": "Identifier", + "start": 13, + "end": 16, + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 7 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "init": { + "type": "NumericLiteral", + "start": 19, + "end": 20, + "loc": { + "start": { + "line": 2, + "column": 10 + }, + "end": { + "line": 2, + "column": 11 + } + }, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + } + } + ], + "kind": "let" + }, + { + "type": "VariableDeclaration", + "start": 22, + "end": 34, + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 12 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 26, + "end": 33, + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 11 + } + }, + "id": { + "type": "Identifier", + "start": 26, + "end": 29, + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 7 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "init": { + "type": "NumericLiteral", + "start": 32, + "end": 33, + "loc": { + "start": { + "line": 3, + "column": 10 + }, + "end": { + "line": 3, + "column": 11 + } + }, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + } + } + ], + "kind": "var" + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-arr-destr/options.json b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-arr-destr/options.json deleted file mode 100644 index 2cbe06c40914..000000000000 --- a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-arr-destr/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Identifier 'foo' has already been declared (2:15)" -} diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-arr-destr/output.json b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-arr-destr/output.json new file mode 100644 index 000000000000..899412645531 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-arr-destr/output.json @@ -0,0 +1,154 @@ +{ + "type": "File", + "start": 0, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "errors": [ + "SyntaxError: Identifier 'foo' has already been declared (2:15)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "TryStatement", + "start": 0, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "block": { + "type": "BlockStatement", + "start": 4, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 2, + "column": 1 + } + }, + "body": [], + "directives": [] + }, + "handler": { + "type": "CatchClause", + "start": 8, + "end": 30, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "param": { + "type": "ArrayPattern", + "start": 15, + "end": 25, + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 19 + } + }, + "elements": [ + { + "type": "Identifier", + "start": 16, + "end": 19, + "loc": { + "start": { + "line": 2, + "column": 10 + }, + "end": { + "line": 2, + "column": 13 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + { + "type": "Identifier", + "start": 21, + "end": 24, + "loc": { + "start": { + "line": 2, + "column": 15 + }, + "end": { + "line": 2, + "column": 18 + }, + "identifierName": "foo" + }, + "name": "foo" + } + ] + }, + "body": { + "type": "BlockStatement", + "start": 27, + "end": 30, + "loc": { + "start": { + "line": 2, + "column": 21 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "body": [], + "directives": [] + } + }, + "finalizer": null + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-dbl-let/options.json b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-dbl-let/options.json deleted file mode 100644 index ac735b2ace22..000000000000 --- a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-dbl-let/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Identifier 'foo' has already been declared (1:35)" -} diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-dbl-let/output.json b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-dbl-let/output.json new file mode 100644 index 000000000000..cddf0493cba9 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-dbl-let/output.json @@ -0,0 +1,222 @@ +{ + "type": "File", + "start": 0, + "end": 39, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 39 + } + }, + "errors": [ + "SyntaxError: Identifier 'foo' has already been declared (1:35)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 39, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 39 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "VariableDeclaration", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 4, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "id": { + "type": "Identifier", + "start": 4, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 7 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "init": null + } + ], + "kind": "let" + }, + { + "type": "TryStatement", + "start": 9, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "block": { + "type": "BlockStatement", + "start": 13, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "body": [], + "directives": [] + }, + "handler": { + "type": "CatchClause", + "start": 16, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "param": { + "type": "Identifier", + "start": 23, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 23 + }, + "end": { + "line": 1, + "column": 26 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "body": { + "type": "BlockStatement", + "start": 28, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 28 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "body": [], + "directives": [] + } + }, + "finalizer": null + }, + { + "type": "VariableDeclaration", + "start": 31, + "end": 39, + "loc": { + "start": { + "line": 1, + "column": 31 + }, + "end": { + "line": 1, + "column": 39 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 35, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 35 + }, + "end": { + "line": 1, + "column": 38 + } + }, + "id": { + "type": "Identifier", + "start": 35, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 35 + }, + "end": { + "line": 1, + "column": 38 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "init": null + } + ], + "kind": "let" + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-func/options.json b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-func/options.json deleted file mode 100644 index 6f5b5641a148..000000000000 --- a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-func/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Identifier 'foo' has already been declared (3:11)" -} diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-func/output.json b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-func/output.json new file mode 100644 index 000000000000..ab1db27cf0a8 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-func/output.json @@ -0,0 +1,173 @@ +{ + "type": "File", + "start": 0, + "end": 43, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "errors": [ + "SyntaxError: Identifier 'foo' has already been declared (3:11)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 43, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "TryStatement", + "start": 0, + "end": 43, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "block": { + "type": "BlockStatement", + "start": 4, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 2, + "column": 1 + } + }, + "body": [], + "directives": [] + }, + "handler": { + "type": "CatchClause", + "start": 8, + "end": 43, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "param": { + "type": "Identifier", + "start": 15, + "end": 18, + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 12 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "body": { + "type": "BlockStatement", + "start": 20, + "end": 43, + "loc": { + "start": { + "line": 2, + "column": 14 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "body": [ + { + "type": "FunctionDeclaration", + "start": 24, + "end": 41, + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 3, + "column": 19 + } + }, + "id": { + "type": "Identifier", + "start": 33, + "end": 36, + "loc": { + "start": { + "line": 3, + "column": 11 + }, + "end": { + "line": 3, + "column": 14 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 39, + "end": 41, + "loc": { + "start": { + "line": 3, + "column": 17 + }, + "end": { + "line": 3, + "column": 19 + } + }, + "body": [], + "directives": [] + } + } + ], + "directives": [] + } + }, + "finalizer": null + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-let/options.json b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-let/options.json deleted file mode 100644 index 254a763e653e..000000000000 --- a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-let/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Identifier 'foo' has already been declared (3:6)" -} diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-let/output.json b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-let/output.json new file mode 100644 index 000000000000..e759f28d0434 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-let/output.json @@ -0,0 +1,172 @@ +{ + "type": "File", + "start": 0, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "errors": [ + "SyntaxError: Identifier 'foo' has already been declared (3:6)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "TryStatement", + "start": 0, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "block": { + "type": "BlockStatement", + "start": 4, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 2, + "column": 1 + } + }, + "body": [], + "directives": [] + }, + "handler": { + "type": "CatchClause", + "start": 8, + "end": 34, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "param": { + "type": "Identifier", + "start": 15, + "end": 18, + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 12 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "body": { + "type": "BlockStatement", + "start": 20, + "end": 34, + "loc": { + "start": { + "line": 2, + "column": 14 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "body": [ + { + "type": "VariableDeclaration", + "start": 24, + "end": 32, + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 3, + "column": 10 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 28, + "end": 31, + "loc": { + "start": { + "line": 3, + "column": 6 + }, + "end": { + "line": 3, + "column": 9 + } + }, + "id": { + "type": "Identifier", + "start": 28, + "end": 31, + "loc": { + "start": { + "line": 3, + "column": 6 + }, + "end": { + "line": 3, + "column": 9 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "init": null + } + ], + "kind": "let" + } + ], + "directives": [] + } + }, + "finalizer": null + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-obj-destr/options.json b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-obj-destr/options.json deleted file mode 100644 index bf345ea77127..000000000000 --- a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-obj-destr/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Identifier 'foo' has already been declared (2:28)" -} diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-obj-destr/output.json b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-obj-destr/output.json new file mode 100644 index 000000000000..5a4c9d365dbe --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-obj-destr/output.json @@ -0,0 +1,293 @@ +{ + "type": "File", + "start": 0, + "end": 47, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "errors": [ + "SyntaxError: Identifier 'foo' has already been declared (2:28)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 47, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "TryStatement", + "start": 0, + "end": 47, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "block": { + "type": "BlockStatement", + "start": 4, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 2, + "column": 1 + } + }, + "body": [], + "directives": [] + }, + "handler": { + "type": "CatchClause", + "start": 8, + "end": 47, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "param": { + "type": "ObjectPattern", + "start": 15, + "end": 42, + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 36 + } + }, + "properties": [ + { + "type": "ObjectProperty", + "start": 17, + "end": 23, + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 17 + } + }, + "method": false, + "key": { + "type": "Identifier", + "start": 17, + "end": 18, + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 12 + }, + "identifierName": "a" + }, + "name": "a" + }, + "computed": false, + "shorthand": false, + "value": { + "type": "Identifier", + "start": 20, + "end": 23, + "loc": { + "start": { + "line": 2, + "column": 14 + }, + "end": { + "line": 2, + "column": 17 + }, + "identifierName": "foo" + }, + "name": "foo" + } + }, + { + "type": "ObjectProperty", + "start": 25, + "end": 40, + "loc": { + "start": { + "line": 2, + "column": 19 + }, + "end": { + "line": 2, + "column": 34 + } + }, + "method": false, + "key": { + "type": "Identifier", + "start": 25, + "end": 26, + "loc": { + "start": { + "line": 2, + "column": 19 + }, + "end": { + "line": 2, + "column": 20 + }, + "identifierName": "b" + }, + "name": "b" + }, + "computed": false, + "shorthand": false, + "value": { + "type": "ObjectPattern", + "start": 28, + "end": 40, + "loc": { + "start": { + "line": 2, + "column": 22 + }, + "end": { + "line": 2, + "column": 34 + } + }, + "properties": [ + { + "type": "ObjectProperty", + "start": 30, + "end": 38, + "loc": { + "start": { + "line": 2, + "column": 24 + }, + "end": { + "line": 2, + "column": 32 + } + }, + "method": false, + "key": { + "type": "Identifier", + "start": 30, + "end": 31, + "loc": { + "start": { + "line": 2, + "column": 24 + }, + "end": { + "line": 2, + "column": 25 + }, + "identifierName": "c" + }, + "name": "c" + }, + "computed": false, + "shorthand": false, + "value": { + "type": "ArrayPattern", + "start": 33, + "end": 38, + "loc": { + "start": { + "line": 2, + "column": 27 + }, + "end": { + "line": 2, + "column": 32 + } + }, + "elements": [ + { + "type": "Identifier", + "start": 34, + "end": 37, + "loc": { + "start": { + "line": 2, + "column": 28 + }, + "end": { + "line": 2, + "column": 31 + }, + "identifierName": "foo" + }, + "name": "foo" + } + ] + } + } + ] + } + } + ] + }, + "body": { + "type": "BlockStatement", + "start": 44, + "end": 47, + "loc": { + "start": { + "line": 2, + "column": 38 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "body": [], + "directives": [] + } + }, + "finalizer": null + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-var-arr-destr/options.json b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-var-arr-destr/options.json deleted file mode 100644 index 254a763e653e..000000000000 --- a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-var-arr-destr/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Identifier 'foo' has already been declared (3:6)" -} diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-var-arr-destr/output.json b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-var-arr-destr/output.json new file mode 100644 index 000000000000..40bb3df74915 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-var-arr-destr/output.json @@ -0,0 +1,189 @@ +{ + "type": "File", + "start": 0, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "errors": [ + "SyntaxError: Identifier 'foo' has already been declared (3:6)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "TryStatement", + "start": 0, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "block": { + "type": "BlockStatement", + "start": 4, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 2, + "column": 1 + } + }, + "body": [], + "directives": [] + }, + "handler": { + "type": "CatchClause", + "start": 8, + "end": 36, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "param": { + "type": "ArrayPattern", + "start": 15, + "end": 20, + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 14 + } + }, + "elements": [ + { + "type": "Identifier", + "start": 16, + "end": 19, + "loc": { + "start": { + "line": 2, + "column": 10 + }, + "end": { + "line": 2, + "column": 13 + }, + "identifierName": "foo" + }, + "name": "foo" + } + ] + }, + "body": { + "type": "BlockStatement", + "start": 22, + "end": 36, + "loc": { + "start": { + "line": 2, + "column": 16 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "body": [ + { + "type": "VariableDeclaration", + "start": 26, + "end": 34, + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 3, + "column": 10 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 30, + "end": 33, + "loc": { + "start": { + "line": 3, + "column": 6 + }, + "end": { + "line": 3, + "column": 9 + } + }, + "id": { + "type": "Identifier", + "start": 30, + "end": 33, + "loc": { + "start": { + "line": 3, + "column": 6 + }, + "end": { + "line": 3, + "column": 9 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "init": null + } + ], + "kind": "var" + } + ], + "directives": [] + } + }, + "finalizer": null + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-var-obj-destr/options.json b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-var-obj-destr/options.json deleted file mode 100644 index 254a763e653e..000000000000 --- a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-var-obj-destr/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Identifier 'foo' has already been declared (3:6)" -} diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-var-obj-destr/output.json b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-var-obj-destr/output.json new file mode 100644 index 000000000000..5cd4c6abd102 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-var-obj-destr/output.json @@ -0,0 +1,227 @@ +{ + "type": "File", + "start": 0, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "errors": [ + "SyntaxError: Identifier 'foo' has already been declared (3:6)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "TryStatement", + "start": 0, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "block": { + "type": "BlockStatement", + "start": 4, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 2, + "column": 1 + } + }, + "body": [], + "directives": [] + }, + "handler": { + "type": "CatchClause", + "start": 8, + "end": 38, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "param": { + "type": "ObjectPattern", + "start": 15, + "end": 22, + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 16 + } + }, + "properties": [ + { + "type": "ObjectProperty", + "start": 17, + "end": 20, + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 14 + } + }, + "method": false, + "key": { + "type": "Identifier", + "start": 17, + "end": 20, + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 14 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "computed": false, + "shorthand": true, + "value": { + "type": "Identifier", + "start": 17, + "end": 20, + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 14 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "extra": { + "shorthand": true + } + } + ] + }, + "body": { + "type": "BlockStatement", + "start": 24, + "end": 38, + "loc": { + "start": { + "line": 2, + "column": 18 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "body": [ + { + "type": "VariableDeclaration", + "start": 28, + "end": 36, + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 3, + "column": 10 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 32, + "end": 35, + "loc": { + "start": { + "line": 3, + "column": 6 + }, + "end": { + "line": 3, + "column": 9 + } + }, + "id": { + "type": "Identifier", + "start": 32, + "end": 35, + "loc": { + "start": { + "line": 3, + "column": 6 + }, + "end": { + "line": 3, + "column": 9 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "init": null + } + ], + "kind": "var" + } + ], + "directives": [] + } + }, + "finalizer": null + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-class-class/options.json b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-class-class/options.json deleted file mode 100644 index cdd0ac832c57..000000000000 --- a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-class-class/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Identifier 'foo' has already been declared (2:6)" -} diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-class-class/output.json b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-class-class/output.json new file mode 100644 index 000000000000..6d2e82b586ae --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-class-class/output.json @@ -0,0 +1,166 @@ +{ + "type": "File", + "start": 0, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 13 + } + }, + "errors": [ + "SyntaxError: Identifier 'foo' has already been declared (2:6)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 13 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ClassDeclaration", + "start": 0, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "id": { + "type": "Identifier", + "start": 6, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 9 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "start": 10, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "body": [] + } + }, + { + "type": "EmptyStatement", + "start": 12, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 13 + } + } + }, + { + "type": "ClassDeclaration", + "start": 14, + "end": 26, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 12 + } + }, + "id": { + "type": "Identifier", + "start": 20, + "end": 23, + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 9 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "start": 24, + "end": 26, + "loc": { + "start": { + "line": 2, + "column": 10 + }, + "end": { + "line": 2, + "column": 12 + } + }, + "body": [] + } + }, + { + "type": "EmptyStatement", + "start": 26, + "end": 27, + "loc": { + "start": { + "line": 2, + "column": 12 + }, + "end": { + "line": 2, + "column": 13 + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-class-const/options.json b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-class-const/options.json deleted file mode 100644 index cdd0ac832c57..000000000000 --- a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-class-const/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Identifier 'foo' has already been declared (2:6)" -} diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-class-const/output.json b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-class-const/output.json new file mode 100644 index 000000000000..a23d95cfc217 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-class-const/output.json @@ -0,0 +1,172 @@ +{ + "type": "File", + "start": 0, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 14 + } + }, + "errors": [ + "SyntaxError: Identifier 'foo' has already been declared (2:6)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 14 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ClassDeclaration", + "start": 0, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "id": { + "type": "Identifier", + "start": 6, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 9 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "start": 10, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "body": [] + } + }, + { + "type": "EmptyStatement", + "start": 12, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 13 + } + } + }, + { + "type": "VariableDeclaration", + "start": 14, + "end": 28, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 14 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 20, + "end": 27, + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 13 + } + }, + "id": { + "type": "Identifier", + "start": 20, + "end": 23, + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 9 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "init": { + "type": "NumericLiteral", + "start": 26, + "end": 27, + "loc": { + "start": { + "line": 2, + "column": 12 + }, + "end": { + "line": 2, + "column": 13 + } + }, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + } + } + ], + "kind": "const" + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-class-func/options.json b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-class-func/options.json deleted file mode 100644 index a3504d289fd7..000000000000 --- a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-class-func/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Identifier 'foo' has already been declared (2:9)" -} diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-class-func/output.json b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-class-func/output.json new file mode 100644 index 000000000000..a6bf56aa7623 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-class-func/output.json @@ -0,0 +1,169 @@ +{ + "type": "File", + "start": 0, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 19 + } + }, + "errors": [ + "SyntaxError: Identifier 'foo' has already been declared (2:9)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 19 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ClassDeclaration", + "start": 0, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "id": { + "type": "Identifier", + "start": 6, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 9 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "start": 10, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "body": [] + } + }, + { + "type": "EmptyStatement", + "start": 12, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 13 + } + } + }, + { + "type": "FunctionDeclaration", + "start": 14, + "end": 32, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 18 + } + }, + "id": { + "type": "Identifier", + "start": 23, + "end": 26, + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 12 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 30, + "end": 32, + "loc": { + "start": { + "line": 2, + "column": 16 + }, + "end": { + "line": 2, + "column": 18 + } + }, + "body": [], + "directives": [] + } + }, + { + "type": "EmptyStatement", + "start": 32, + "end": 33, + "loc": { + "start": { + "line": 2, + "column": 18 + }, + "end": { + "line": 2, + "column": 19 + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-class-let/options.json b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-class-let/options.json deleted file mode 100644 index c04a6f3e48eb..000000000000 --- a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-class-let/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Identifier 'foo' has already been declared (2:4)" -} diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-class-let/output.json b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-class-let/output.json new file mode 100644 index 000000000000..49daeec3aef6 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-class-let/output.json @@ -0,0 +1,172 @@ +{ + "type": "File", + "start": 0, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 12 + } + }, + "errors": [ + "SyntaxError: Identifier 'foo' has already been declared (2:4)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 12 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ClassDeclaration", + "start": 0, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "id": { + "type": "Identifier", + "start": 6, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 9 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "start": 10, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "body": [] + } + }, + { + "type": "EmptyStatement", + "start": 12, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 13 + } + } + }, + { + "type": "VariableDeclaration", + "start": 14, + "end": 26, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 12 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 18, + "end": 25, + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 11 + } + }, + "id": { + "type": "Identifier", + "start": 18, + "end": 21, + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 7 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "init": { + "type": "NumericLiteral", + "start": 24, + "end": 25, + "loc": { + "start": { + "line": 2, + "column": 10 + }, + "end": { + "line": 2, + "column": 11 + } + }, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + } + } + ], + "kind": "let" + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-class-var/options.json b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-class-var/options.json deleted file mode 100644 index c04a6f3e48eb..000000000000 --- a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-class-var/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Identifier 'foo' has already been declared (2:4)" -} diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-class-var/output.json b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-class-var/output.json new file mode 100644 index 000000000000..205470069b5d --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-class-var/output.json @@ -0,0 +1,153 @@ +{ + "type": "File", + "start": 0, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 8 + } + }, + "errors": [ + "SyntaxError: Identifier 'foo' has already been declared (2:4)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 8 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ClassDeclaration", + "start": 0, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "id": { + "type": "Identifier", + "start": 6, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 9 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "start": 10, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "body": [] + } + }, + { + "type": "EmptyStatement", + "start": 12, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 13 + } + } + }, + { + "type": "VariableDeclaration", + "start": 14, + "end": 22, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 8 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 18, + "end": 21, + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 7 + } + }, + "id": { + "type": "Identifier", + "start": 18, + "end": 21, + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 7 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "init": null + } + ], + "kind": "var" + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-const-const/options.json b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-const-const/options.json deleted file mode 100644 index d62aabfd1b07..000000000000 --- a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-const-const/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Identifier 'foo' has already been declared (1:13)" -} diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-const-const/output.json b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-const-const/output.json new file mode 100644 index 000000000000..b6f764fce7a5 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-const-const/output.json @@ -0,0 +1,160 @@ +{ + "type": "File", + "start": 0, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "errors": [ + "SyntaxError: Identifier 'foo' has already been declared (1:13)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "VariableDeclaration", + "start": 0, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 6, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "id": { + "type": "Identifier", + "start": 6, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 9 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "init": { + "type": "NumericLiteral", + "start": 10, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + } + }, + { + "type": "VariableDeclarator", + "start": 13, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "id": { + "type": "Identifier", + "start": 13, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 16 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "init": { + "type": "NumericLiteral", + "start": 17, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "extra": { + "rawValue": 2, + "raw": "2" + }, + "value": 2 + } + } + ], + "kind": "const" + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-func-gen/options.json b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-func-gen/options.json deleted file mode 100644 index 1b6192a1bc04..000000000000 --- a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-func-gen/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Identifier 'f' has already been declared (1:28)" -} diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-func-gen/output.json b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-func-gen/output.json new file mode 100644 index 000000000000..ebd20401ed0f --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-func-gen/output.json @@ -0,0 +1,160 @@ +{ + "type": "File", + "start": 0, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "errors": [ + "SyntaxError: Identifier 'f' has already been declared (1:28)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "BlockStatement", + "start": 0, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "body": [ + { + "type": "FunctionDeclaration", + "start": 2, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 2 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "id": { + "type": "Identifier", + "start": 11, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 12 + }, + "identifierName": "f" + }, + "name": "f" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 15, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "body": [], + "directives": [] + } + }, + { + "type": "FunctionDeclaration", + "start": 18, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 34 + } + }, + "id": { + "type": "Identifier", + "start": 28, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 28 + }, + "end": { + "line": 1, + "column": 29 + }, + "identifierName": "f" + }, + "name": "f" + }, + "generator": true, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 32, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 34 + } + }, + "body": [], + "directives": [] + } + } + ], + "directives": [] + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-func-module-sloppy/options.json b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-func-module-sloppy/options.json index 3f4250fbe917..54925950e059 100644 --- a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-func-module-sloppy/options.json +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-func-module-sloppy/options.json @@ -1,4 +1,3 @@ { - "sourceType": "module", - "throws": "Identifier 'foo' has already been declared (1:29)" -} + "sourceType": "module" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-func-module-sloppy/output.json b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-func-module-sloppy/output.json new file mode 100644 index 000000000000..c1b2c1a85a29 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-func-module-sloppy/output.json @@ -0,0 +1,160 @@ +{ + "type": "File", + "start": 0, + "end": 39, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 39 + } + }, + "errors": [ + "SyntaxError: Identifier 'foo' has already been declared (1:29)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 39, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 39 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "BlockStatement", + "start": 0, + "end": 39, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 39 + } + }, + "body": [ + { + "type": "FunctionDeclaration", + "start": 2, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 2 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "id": { + "type": "Identifier", + "start": 11, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 14 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 17, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "body": [], + "directives": [] + } + }, + { + "type": "FunctionDeclaration", + "start": 20, + "end": 37, + "loc": { + "start": { + "line": 1, + "column": 20 + }, + "end": { + "line": 1, + "column": 37 + } + }, + "id": { + "type": "Identifier", + "start": 29, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 29 + }, + "end": { + "line": 1, + "column": 32 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 35, + "end": 37, + "loc": { + "start": { + "line": 1, + "column": 35 + }, + "end": { + "line": 1, + "column": 37 + } + }, + "body": [], + "directives": [] + } + } + ], + "directives": [] + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-func-module/options.json b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-func-module/options.json index e253f0a85f47..54925950e059 100644 --- a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-func-module/options.json +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-func-module/options.json @@ -1,4 +1,3 @@ { - "sourceType": "module", - "throws": "Identifier 'foo' has already been declared (2:9)" -} + "sourceType": "module" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-func-module/output.json b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-func-module/output.json new file mode 100644 index 000000000000..eadbdeeb68f8 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-func-module/output.json @@ -0,0 +1,142 @@ +{ + "type": "File", + "start": 0, + "end": 35, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 17 + } + }, + "errors": [ + "SyntaxError: Identifier 'foo' has already been declared (2:9)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 35, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 17 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 12 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 15, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "body": [], + "directives": [] + } + }, + { + "type": "FunctionDeclaration", + "start": 18, + "end": 35, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 17 + } + }, + "id": { + "type": "Identifier", + "start": 27, + "end": 30, + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 12 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 33, + "end": 35, + "loc": { + "start": { + "line": 2, + "column": 15 + }, + "end": { + "line": 2, + "column": 17 + } + }, + "body": [], + "directives": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-func-var-sloppy/options.json b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-func-var-sloppy/options.json deleted file mode 100644 index 254a763e653e..000000000000 --- a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-func-var-sloppy/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Identifier 'foo' has already been declared (3:6)" -} diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-func-var-sloppy/output.json b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-func-var-sloppy/output.json new file mode 100644 index 000000000000..454a440c3426 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-func-var-sloppy/output.json @@ -0,0 +1,178 @@ +{ + "type": "File", + "start": 0, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "errors": [ + "SyntaxError: Identifier 'foo' has already been declared (3:6)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "BlockStatement", + "start": 0, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "body": [ + { + "type": "FunctionDeclaration", + "start": 4, + "end": 21, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 19 + } + }, + "id": { + "type": "Identifier", + "start": 13, + "end": 16, + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 14 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 19, + "end": 21, + "loc": { + "start": { + "line": 2, + "column": 17 + }, + "end": { + "line": 2, + "column": 19 + } + }, + "body": [], + "directives": [] + } + }, + { + "type": "VariableDeclaration", + "start": 24, + "end": 36, + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 3, + "column": 14 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 28, + "end": 35, + "loc": { + "start": { + "line": 3, + "column": 6 + }, + "end": { + "line": 3, + "column": 13 + } + }, + "id": { + "type": "Identifier", + "start": 28, + "end": 31, + "loc": { + "start": { + "line": 3, + "column": 6 + }, + "end": { + "line": 3, + "column": 9 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "init": { + "type": "NumericLiteral", + "start": 34, + "end": 35, + "loc": { + "start": { + "line": 3, + "column": 12 + }, + "end": { + "line": 3, + "column": 13 + } + }, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + } + } + ], + "kind": "var" + } + ], + "directives": [] + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-gen-func/options.json b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-gen-func/options.json deleted file mode 100644 index 1b6192a1bc04..000000000000 --- a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-gen-func/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Identifier 'f' has already been declared (1:28)" -} diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-gen-func/output.json b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-gen-func/output.json new file mode 100644 index 000000000000..fdad445b5deb --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-gen-func/output.json @@ -0,0 +1,160 @@ +{ + "type": "File", + "start": 0, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "errors": [ + "SyntaxError: Identifier 'f' has already been declared (1:28)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "BlockStatement", + "start": 0, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "body": [ + { + "type": "FunctionDeclaration", + "start": 2, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 2 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "id": { + "type": "Identifier", + "start": 12, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 13 + }, + "identifierName": "f" + }, + "name": "f" + }, + "generator": true, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 16, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "body": [], + "directives": [] + } + }, + { + "type": "FunctionDeclaration", + "start": 19, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 34 + } + }, + "id": { + "type": "Identifier", + "start": 28, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 28 + }, + "end": { + "line": 1, + "column": 29 + }, + "identifierName": "f" + }, + "name": "f" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 32, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 34 + } + }, + "body": [], + "directives": [] + } + } + ], + "directives": [] + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-let-let/options.json b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-let-let/options.json deleted file mode 100644 index 8ca49120a98a..000000000000 --- a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-let-let/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Identifier 'foo' has already been declared (1:9)" -} diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-let-let/output.json b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-let-let/output.json new file mode 100644 index 000000000000..e28bf9f399b0 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-let-let/output.json @@ -0,0 +1,122 @@ +{ + "type": "File", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "errors": [ + "SyntaxError: Identifier 'foo' has already been declared (1:9)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "VariableDeclaration", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 4, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "id": { + "type": "Identifier", + "start": 4, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 7 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "init": null + }, + { + "type": "VariableDeclarator", + "start": 9, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 12 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "init": null + } + ], + "kind": "let" + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-nested-let-var/options.json b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-nested-let-var/options.json deleted file mode 100644 index 3eaa378d43e7..000000000000 --- a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-nested-let-var/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Identifier 'a' has already been declared (3:8)" -} diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-nested-let-var/output.json b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-nested-let-var/output.json new file mode 100644 index 000000000000..f925321aef98 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-nested-let-var/output.json @@ -0,0 +1,176 @@ +{ + "type": "File", + "start": 0, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "errors": [ + "SyntaxError: Identifier 'a' has already been declared (3:8)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "BlockStatement", + "start": 0, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "body": [ + { + "type": "VariableDeclaration", + "start": 4, + "end": 10, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 8 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 8, + "end": 9, + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 7 + } + }, + "id": { + "type": "Identifier", + "start": 8, + "end": 9, + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 7 + }, + "identifierName": "a" + }, + "name": "a" + }, + "init": null + } + ], + "kind": "let" + }, + { + "type": "BlockStatement", + "start": 13, + "end": 23, + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 3, + "column": 12 + } + }, + "body": [ + { + "type": "VariableDeclaration", + "start": 15, + "end": 21, + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 10 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 19, + "end": 20, + "loc": { + "start": { + "line": 3, + "column": 8 + }, + "end": { + "line": 3, + "column": 9 + } + }, + "id": { + "type": "Identifier", + "start": 19, + "end": 20, + "loc": { + "start": { + "line": 3, + "column": 8 + }, + "end": { + "line": 3, + "column": 9 + }, + "identifierName": "a" + }, + "name": "a" + }, + "init": null + } + ], + "kind": "var" + } + ], + "directives": [] + } + ], + "directives": [] + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/scope/for-var/options.json b/packages/babel-parser/test/fixtures/core/scope/for-var/options.json deleted file mode 100644 index 5f2332a9ed8f..000000000000 --- a/packages/babel-parser/test/fixtures/core/scope/for-var/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Identifier 'i' has already been declared (2:8)" -} diff --git a/packages/babel-parser/test/fixtures/core/scope/for-var/output.json b/packages/babel-parser/test/fixtures/core/scope/for-var/output.json new file mode 100644 index 000000000000..bfd483ec7fb4 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/for-var/output.json @@ -0,0 +1,194 @@ +{ + "type": "File", + "start": 0, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "errors": [ + "SyntaxError: Identifier 'i' has already been declared (2:8)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ForStatement", + "start": 0, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "init": { + "type": "VariableDeclaration", + "start": 5, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 9, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 10 + }, + "identifierName": "i" + }, + "name": "i" + }, + "init": { + "type": "NumericLiteral", + "start": 13, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + } + } + ], + "kind": "let" + }, + "test": null, + "update": null, + "body": { + "type": "BlockStatement", + "start": 18, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "body": [ + { + "type": "VariableDeclaration", + "start": 24, + "end": 30, + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 10 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 28, + "end": 29, + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 9 + } + }, + "id": { + "type": "Identifier", + "start": 28, + "end": 29, + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 9 + }, + "identifierName": "i" + }, + "name": "i" + }, + "init": null + } + ], + "kind": "var" + } + ], + "directives": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/scope/undecl-export-as-default/options.json b/packages/babel-parser/test/fixtures/core/scope/undecl-export-as-default/options.json index 8448889cf253..54925950e059 100644 --- a/packages/babel-parser/test/fixtures/core/scope/undecl-export-as-default/options.json +++ b/packages/babel-parser/test/fixtures/core/scope/undecl-export-as-default/options.json @@ -1,4 +1,3 @@ { - "sourceType": "module", - "throws": "Export 'encrypt' is not defined (1:9)" -} + "sourceType": "module" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/scope/undecl-export-as-default/output.json b/packages/babel-parser/test/fixtures/core/scope/undecl-export-as-default/output.json new file mode 100644 index 000000000000..996bc32d815d --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/undecl-export-as-default/output.json @@ -0,0 +1,106 @@ +{ + "type": "File", + "start": 0, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "errors": [ + "SyntaxError: Export 'encrypt' is not defined (1:9)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExportNamedDeclaration", + "start": 0, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "specifiers": [ + { + "type": "ExportSpecifier", + "start": 9, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 27 + } + }, + "local": { + "type": "Identifier", + "start": 9, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 16 + }, + "identifierName": "encrypt" + }, + "name": "encrypt" + }, + "exported": { + "type": "Identifier", + "start": 20, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 20 + }, + "end": { + "line": 1, + "column": 27 + }, + "identifierName": "default" + }, + "name": "default" + } + } + ], + "source": null, + "declaration": null + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/scope/undecl-export-as/options.json b/packages/babel-parser/test/fixtures/core/scope/undecl-export-as/options.json index 8448889cf253..54925950e059 100644 --- a/packages/babel-parser/test/fixtures/core/scope/undecl-export-as/options.json +++ b/packages/babel-parser/test/fixtures/core/scope/undecl-export-as/options.json @@ -1,4 +1,3 @@ { - "sourceType": "module", - "throws": "Export 'encrypt' is not defined (1:9)" -} + "sourceType": "module" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/scope/undecl-export-as/output.json b/packages/babel-parser/test/fixtures/core/scope/undecl-export-as/output.json new file mode 100644 index 000000000000..11a778f34809 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/undecl-export-as/output.json @@ -0,0 +1,158 @@ +{ + "type": "File", + "start": 0, + "end": 52, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 21 + } + }, + "errors": [ + "SyntaxError: Export 'encrypt' is not defined (1:9)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 52, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 21 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExportNamedDeclaration", + "start": 0, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "specifiers": [ + { + "type": "ExportSpecifier", + "start": 9, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 27 + } + }, + "local": { + "type": "Identifier", + "start": 9, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 16 + }, + "identifierName": "encrypt" + }, + "name": "encrypt" + }, + "exported": { + "type": "Identifier", + "start": 20, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 20 + }, + "end": { + "line": 1, + "column": 27 + }, + "identifierName": "decrypt" + }, + "name": "decrypt" + } + } + ], + "source": null, + "declaration": null + }, + { + "type": "FunctionDeclaration", + "start": 31, + "end": 52, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 21 + } + }, + "id": { + "type": "Identifier", + "start": 40, + "end": 47, + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 16 + }, + "identifierName": "decrypt" + }, + "name": "decrypt" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 50, + "end": 52, + "loc": { + "start": { + "line": 2, + "column": 19 + }, + "end": { + "line": 2, + "column": 21 + } + }, + "body": [], + "directives": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/scope/undecl-export-block/options.json b/packages/babel-parser/test/fixtures/core/scope/undecl-export-block/options.json index 0844d3e80e68..54925950e059 100644 --- a/packages/babel-parser/test/fixtures/core/scope/undecl-export-block/options.json +++ b/packages/babel-parser/test/fixtures/core/scope/undecl-export-block/options.json @@ -1,4 +1,3 @@ { - "sourceType": "module", - "throws": "Export 'encrypt' is not defined (4:9)" -} + "sourceType": "module" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/scope/undecl-export-block/output.json b/packages/babel-parser/test/fixtures/core/scope/undecl-export-block/output.json new file mode 100644 index 000000000000..a660653865e5 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/undecl-export-block/output.json @@ -0,0 +1,176 @@ +{ + "type": "File", + "start": 0, + "end": 46, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 18 + } + }, + "errors": [ + "SyntaxError: Export 'encrypt' is not defined (4:9)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 46, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 18 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "BlockStatement", + "start": 0, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "body": [ + { + "type": "FunctionDeclaration", + "start": 4, + "end": 25, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 23 + } + }, + "id": { + "type": "Identifier", + "start": 13, + "end": 20, + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 18 + }, + "identifierName": "encrypt" + }, + "name": "encrypt" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 23, + "end": 25, + "loc": { + "start": { + "line": 2, + "column": 21 + }, + "end": { + "line": 2, + "column": 23 + } + }, + "body": [], + "directives": [] + } + } + ], + "directives": [] + }, + { + "type": "ExportNamedDeclaration", + "start": 28, + "end": 46, + "loc": { + "start": { + "line": 4, + "column": 0 + }, + "end": { + "line": 4, + "column": 18 + } + }, + "specifiers": [ + { + "type": "ExportSpecifier", + "start": 37, + "end": 44, + "loc": { + "start": { + "line": 4, + "column": 9 + }, + "end": { + "line": 4, + "column": 16 + } + }, + "local": { + "type": "Identifier", + "start": 37, + "end": 44, + "loc": { + "start": { + "line": 4, + "column": 9 + }, + "end": { + "line": 4, + "column": 16 + }, + "identifierName": "encrypt" + }, + "name": "encrypt" + }, + "exported": { + "type": "Identifier", + "start": 37, + "end": 44, + "loc": { + "start": { + "line": 4, + "column": 9 + }, + "end": { + "line": 4, + "column": 16 + }, + "identifierName": "encrypt" + }, + "name": "encrypt" + } + } + ], + "source": null, + "declaration": null + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/scope/undecl-export-builtin-as/options.json b/packages/babel-parser/test/fixtures/core/scope/undecl-export-builtin-as/options.json index cbab70613300..54925950e059 100644 --- a/packages/babel-parser/test/fixtures/core/scope/undecl-export-builtin-as/options.json +++ b/packages/babel-parser/test/fixtures/core/scope/undecl-export-builtin-as/options.json @@ -1,4 +1,3 @@ { - "sourceType": "module", - "throws": "Export 'Object' is not defined (1:9)" -} + "sourceType": "module" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/scope/undecl-export-builtin-as/output.json b/packages/babel-parser/test/fixtures/core/scope/undecl-export-builtin-as/output.json new file mode 100644 index 000000000000..ce100047f2fe --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/undecl-export-builtin-as/output.json @@ -0,0 +1,106 @@ +{ + "type": "File", + "start": 0, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 25 + } + }, + "errors": [ + "SyntaxError: Export 'Object' is not defined (1:9)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 25 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExportNamedDeclaration", + "start": 0, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 25 + } + }, + "specifiers": [ + { + "type": "ExportSpecifier", + "start": 9, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "local": { + "type": "Identifier", + "start": 9, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 15 + }, + "identifierName": "Object" + }, + "name": "Object" + }, + "exported": { + "type": "Identifier", + "start": 19, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 22 + }, + "identifierName": "Obj" + }, + "name": "Obj" + } + } + ], + "source": null, + "declaration": null + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/scope/undecl-export-builtin/options.json b/packages/babel-parser/test/fixtures/core/scope/undecl-export-builtin/options.json index cbab70613300..54925950e059 100644 --- a/packages/babel-parser/test/fixtures/core/scope/undecl-export-builtin/options.json +++ b/packages/babel-parser/test/fixtures/core/scope/undecl-export-builtin/options.json @@ -1,4 +1,3 @@ { - "sourceType": "module", - "throws": "Export 'Object' is not defined (1:9)" -} + "sourceType": "module" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/scope/undecl-export-builtin/output.json b/packages/babel-parser/test/fixtures/core/scope/undecl-export-builtin/output.json new file mode 100644 index 000000000000..22aa25d45da7 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/undecl-export-builtin/output.json @@ -0,0 +1,106 @@ +{ + "type": "File", + "start": 0, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "errors": [ + "SyntaxError: Export 'Object' is not defined (1:9)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExportNamedDeclaration", + "start": 0, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "specifiers": [ + { + "type": "ExportSpecifier", + "start": 9, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "local": { + "type": "Identifier", + "start": 9, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 15 + }, + "identifierName": "Object" + }, + "name": "Object" + }, + "exported": { + "type": "Identifier", + "start": 9, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 15 + }, + "identifierName": "Object" + }, + "name": "Object" + } + } + ], + "source": null, + "declaration": null + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/scope/undecl-export-if/options.json b/packages/babel-parser/test/fixtures/core/scope/undecl-export-if/options.json index 2c97b3ce5a78..54925950e059 100644 --- a/packages/babel-parser/test/fixtures/core/scope/undecl-export-if/options.json +++ b/packages/babel-parser/test/fixtures/core/scope/undecl-export-if/options.json @@ -1,4 +1,3 @@ { - "sourceType": "module", - "throws": "In strict mode code, functions can only be declared at top level or inside a block (2:10)" -} + "sourceType": "module" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/scope/undecl-export-if/output.json b/packages/babel-parser/test/fixtures/core/scope/undecl-export-if/output.json new file mode 100644 index 000000000000..dbff016172cc --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/undecl-export-if/output.json @@ -0,0 +1,191 @@ +{ + "type": "File", + "start": 0, + "end": 51, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 31 + } + }, + "errors": [ + "SyntaxError: In strict mode code, functions can only be declared at top level or inside a block (2:10)", + "SyntaxError: Export 'encrypt' is not defined (1:9)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 51, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 31 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExportNamedDeclaration", + "start": 0, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "specifiers": [ + { + "type": "ExportSpecifier", + "start": 9, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "local": { + "type": "Identifier", + "start": 9, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 16 + }, + "identifierName": "encrypt" + }, + "name": "encrypt" + }, + "exported": { + "type": "Identifier", + "start": 9, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 16 + }, + "identifierName": "encrypt" + }, + "name": "encrypt" + } + } + ], + "source": null, + "declaration": null + }, + { + "type": "IfStatement", + "start": 20, + "end": 51, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 31 + } + }, + "test": { + "type": "BooleanLiteral", + "start": 24, + "end": 28, + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 8 + } + }, + "value": true + }, + "consequent": { + "type": "FunctionDeclaration", + "start": 30, + "end": 51, + "loc": { + "start": { + "line": 2, + "column": 10 + }, + "end": { + "line": 2, + "column": 31 + } + }, + "id": { + "type": "Identifier", + "start": 39, + "end": 46, + "loc": { + "start": { + "line": 2, + "column": 19 + }, + "end": { + "line": 2, + "column": 26 + }, + "identifierName": "encrypt" + }, + "name": "encrypt" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 49, + "end": 51, + "loc": { + "start": { + "line": 2, + "column": 29 + }, + "end": { + "line": 2, + "column": 31 + } + }, + "body": [], + "directives": [] + } + }, + "alternate": null + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/scope/undecl-export/options.json b/packages/babel-parser/test/fixtures/core/scope/undecl-export/options.json index 8448889cf253..54925950e059 100644 --- a/packages/babel-parser/test/fixtures/core/scope/undecl-export/options.json +++ b/packages/babel-parser/test/fixtures/core/scope/undecl-export/options.json @@ -1,4 +1,3 @@ { - "sourceType": "module", - "throws": "Export 'encrypt' is not defined (1:9)" -} + "sourceType": "module" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/scope/undecl-export/output.json b/packages/babel-parser/test/fixtures/core/scope/undecl-export/output.json new file mode 100644 index 000000000000..6293e83f540f --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/undecl-export/output.json @@ -0,0 +1,106 @@ +{ + "type": "File", + "start": 0, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "errors": [ + "SyntaxError: Export 'encrypt' is not defined (1:9)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExportNamedDeclaration", + "start": 0, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "specifiers": [ + { + "type": "ExportSpecifier", + "start": 9, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "local": { + "type": "Identifier", + "start": 9, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 16 + }, + "identifierName": "encrypt" + }, + "name": "encrypt" + }, + "exported": { + "type": "Identifier", + "start": 9, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 16 + }, + "identifierName": "encrypt" + }, + "name": "encrypt" + } + } + ], + "source": null, + "declaration": null + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/108/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/108/options.json deleted file mode 100644 index 080cb0eaaa8a..000000000000 --- a/packages/babel-parser/test/fixtures/core/uncategorised/108/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid regular expression flag (1:17)" -} diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/108/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/108/output.json new file mode 100644 index 000000000000..65ac2b95f145 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/uncategorised/108/output.json @@ -0,0 +1,112 @@ +{ + "type": "File", + "start": 0, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "errors": [ + "SyntaxError: Invalid regular expression flag (1:17)", + "SyntaxError: Invalid regular expression flag (1:19)", + "SyntaxError: Invalid regular expression flag (1:20)", + "SyntaxError: Invalid regular expression flag (1:21)", + "SyntaxError: Invalid regular expression flag (1:22)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "VariableDeclaration", + "start": 0, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 4, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "id": { + "type": "Identifier", + "start": 4, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 5 + }, + "identifierName": "x" + }, + "name": "x" + }, + "init": { + "type": "RegExpLiteral", + "start": 8, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "extra": { + "raw": "/[P QR]/\\u0067" + }, + "pattern": "[P QR]", + "flags": "\\u0067" + } + } + ], + "kind": "var" + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/347/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/347/options.json index 91bb1eef0c0d..aa61ff56c2b3 100644 --- a/packages/babel-parser/test/fixtures/core/uncategorised/347/options.json +++ b/packages/babel-parser/test/fixtures/core/uncategorised/347/options.json @@ -1,3 +1,3 @@ { - "throws": "Invalid number (1:0)" -} + "throws": "Identifier directly after number (1:2)" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/349/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/349/options.json deleted file mode 100644 index 91bb1eef0c0d..000000000000 --- a/packages/babel-parser/test/fixtures/core/uncategorised/349/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid number (1:0)" -} diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/349/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/349/output.json new file mode 100644 index 000000000000..284fac8c4357 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/uncategorised/349/output.json @@ -0,0 +1,73 @@ +{ + "type": "File", + "start": 0, + "end": 2, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 2 + } + }, + "errors": [ + "SyntaxError: Invalid number (1:0)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 2, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 2 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 2, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 2 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 0, + "end": 2, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 2 + } + }, + "extra": { + "rawValue": 3, + "raw": "3e" + }, + "value": 3 + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/350/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/350/options.json deleted file mode 100644 index 91bb1eef0c0d..000000000000 --- a/packages/babel-parser/test/fixtures/core/uncategorised/350/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid number (1:0)" -} diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/350/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/350/output.json new file mode 100644 index 000000000000..6b6e666b00ca --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/uncategorised/350/output.json @@ -0,0 +1,73 @@ +{ + "type": "File", + "start": 0, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "errors": [ + "SyntaxError: Invalid number (1:0)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 0, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "extra": { + "rawValue": 3, + "raw": "3e+" + }, + "value": 3 + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/351/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/351/options.json deleted file mode 100644 index 91bb1eef0c0d..000000000000 --- a/packages/babel-parser/test/fixtures/core/uncategorised/351/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid number (1:0)" -} diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/351/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/351/output.json new file mode 100644 index 000000000000..b52b27d1ef37 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/uncategorised/351/output.json @@ -0,0 +1,73 @@ +{ + "type": "File", + "start": 0, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "errors": [ + "SyntaxError: Invalid number (1:0)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 0, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "extra": { + "rawValue": 3, + "raw": "3e-" + }, + "value": 3 + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/354/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/354/options.json deleted file mode 100644 index 1a0693338eee..000000000000 --- a/packages/babel-parser/test/fixtures/core/uncategorised/354/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Expected number in radix 16 (1:2)" -} diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/354/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/354/output.json new file mode 100644 index 000000000000..ffcb3680fd0b --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/uncategorised/354/output.json @@ -0,0 +1,73 @@ +{ + "type": "File", + "start": 0, + "end": 2, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 2 + } + }, + "errors": [ + "SyntaxError: Expected number in radix 16 (1:2)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 2, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 2 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 2, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 2 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 0, + "end": 2, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 2 + } + }, + "extra": { + "rawValue": null, + "raw": "0x" + }, + "value": null + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/361/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/361/options.json deleted file mode 100644 index 18c53b997b56..000000000000 --- a/packages/babel-parser/test/fixtures/core/uncategorised/361/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Expecting Unicode escape sequence \\uXXXX (1:2)" -} diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/361/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/361/output.json new file mode 100644 index 000000000000..fbb1d3b5d554 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/uncategorised/361/output.json @@ -0,0 +1,70 @@ +{ + "type": "File", + "start": 0, + "end": 2, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 2 + } + }, + "errors": [ + "SyntaxError: Expecting Unicode escape sequence \\uXXXX (1:2)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 2, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 2 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 2, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 2 + } + }, + "expression": { + "type": "Identifier", + "start": 0, + "end": 2, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 2 + }, + "identifierName": "xx\\" + }, + "name": "xx\\" + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/362/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/362/options.json deleted file mode 100644 index ea7ba01dc69c..000000000000 --- a/packages/babel-parser/test/fixtures/core/uncategorised/362/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid Unicode escape (1:1)" -} diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/362/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/362/output.json new file mode 100644 index 000000000000..fae32b78cde4 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/uncategorised/362/output.json @@ -0,0 +1,70 @@ +{ + "type": "File", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "errors": [ + "SyntaxError: Invalid Unicode escape (1:1)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "expression": { + "type": "Identifier", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + }, + "identifierName": "x\\" + }, + "name": "x\\" + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/363/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/363/options.json deleted file mode 100644 index ea7ba01dc69c..000000000000 --- a/packages/babel-parser/test/fixtures/core/uncategorised/363/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid Unicode escape (1:1)" -} diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/363/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/363/output.json new file mode 100644 index 000000000000..37312f42ce97 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/uncategorised/363/output.json @@ -0,0 +1,70 @@ +{ + "type": "File", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "errors": [ + "SyntaxError: Invalid Unicode escape (1:1)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "expression": { + "type": "Identifier", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + }, + "identifierName": "x*" + }, + "name": "x*" + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/366/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/366/options.json deleted file mode 100644 index adf556b0a352..000000000000 --- a/packages/babel-parser/test/fixtures/core/uncategorised/366/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid regular expression flag (1:16)" -} diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/366/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/366/output.json new file mode 100644 index 000000000000..68d637a98170 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/uncategorised/366/output.json @@ -0,0 +1,109 @@ +{ + "type": "File", + "start": 0, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "errors": [ + "SyntaxError: Invalid regular expression flag (1:16)", + "SyntaxError: Invalid regular expression flag (1:18)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "VariableDeclaration", + "start": 0, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 4, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "id": { + "type": "Identifier", + "start": 4, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 5 + }, + "identifierName": "x" + }, + "name": "x" + }, + "init": { + "type": "RegExpLiteral", + "start": 8, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "extra": { + "raw": "/[a-z]/\\ux" + }, + "pattern": "[a-z]", + "flags": "\\ux" + } + } + ], + "kind": "var" + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/367/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/367/options.json deleted file mode 100644 index 6010e96ed144..000000000000 --- a/packages/babel-parser/test/fixtures/core/uncategorised/367/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid left-hand side in assignment expression (1:0)" -} diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/367/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/367/output.json new file mode 100644 index 000000000000..99a3e74a04af --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/uncategorised/367/output.json @@ -0,0 +1,109 @@ +{ + "type": "File", + "start": 0, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "errors": [ + "SyntaxError: Invalid left-hand side in assignment expression (1:0)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "expression": { + "type": "AssignmentExpression", + "start": 0, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "operator": "=", + "left": { + "type": "NumericLiteral", + "start": 0, + "end": 1, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 1 + } + }, + "extra": { + "rawValue": 3, + "raw": "3" + }, + "value": 3 + }, + "right": { + "type": "NumericLiteral", + "start": 4, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "extra": { + "rawValue": 4, + "raw": "4" + }, + "value": 4 + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/368/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/368/options.json deleted file mode 100644 index 6010e96ed144..000000000000 --- a/packages/babel-parser/test/fixtures/core/uncategorised/368/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid left-hand side in assignment expression (1:0)" -} diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/368/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/368/output.json new file mode 100644 index 000000000000..8770df4abba7 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/uncategorised/368/output.json @@ -0,0 +1,122 @@ +{ + "type": "File", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "errors": [ + "SyntaxError: Invalid left-hand side in assignment expression (1:0)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "expression": { + "type": "AssignmentExpression", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "operator": "=", + "left": { + "type": "CallExpression", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "callee": { + "type": "Identifier", + "start": 0, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 4 + }, + "identifierName": "func" + }, + "name": "func" + }, + "arguments": [] + }, + "right": { + "type": "NumericLiteral", + "start": 9, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "extra": { + "rawValue": 4, + "raw": "4" + }, + "value": 4 + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/369/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/369/options.json deleted file mode 100644 index 7c5f08eb9ba6..000000000000 --- a/packages/babel-parser/test/fixtures/core/uncategorised/369/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid left-hand side in assignment expression (1:1)" -} diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/369/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/369/output.json new file mode 100644 index 000000000000..42614106f157 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/uncategorised/369/output.json @@ -0,0 +1,149 @@ +{ + "type": "File", + "start": 0, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "errors": [ + "SyntaxError: Invalid left-hand side in assignment expression (1:1)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "expression": { + "type": "AssignmentExpression", + "start": 0, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "operator": "=", + "left": { + "type": "BinaryExpression", + "start": 1, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "left": { + "type": "NumericLiteral", + "start": 1, + "end": 2, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 2 + } + }, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + }, + "operator": "+", + "right": { + "type": "NumericLiteral", + "start": 5, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + }, + "extra": { + "parenthesized": true, + "parenStart": 0 + } + }, + "right": { + "type": "NumericLiteral", + "start": 10, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "extra": { + "rawValue": 10, + "raw": "10" + }, + "value": 10 + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/370/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/370/options.json deleted file mode 100644 index c09dac1301de..000000000000 --- a/packages/babel-parser/test/fixtures/core/uncategorised/370/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid left-hand side in postfix operation (1:0)" -} diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/370/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/370/output.json new file mode 100644 index 000000000000..ce2cb3d23d67 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/uncategorised/370/output.json @@ -0,0 +1,90 @@ +{ + "type": "File", + "start": 0, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "errors": [ + "SyntaxError: Invalid left-hand side in postfix operation (1:0)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "expression": { + "type": "UpdateExpression", + "start": 0, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "operator": "++", + "prefix": false, + "argument": { + "type": "NumericLiteral", + "start": 0, + "end": 1, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 1 + } + }, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/371/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/371/options.json deleted file mode 100644 index c09dac1301de..000000000000 --- a/packages/babel-parser/test/fixtures/core/uncategorised/371/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid left-hand side in postfix operation (1:0)" -} diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/371/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/371/output.json new file mode 100644 index 000000000000..57d55fec0b5d --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/uncategorised/371/output.json @@ -0,0 +1,90 @@ +{ + "type": "File", + "start": 0, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "errors": [ + "SyntaxError: Invalid left-hand side in postfix operation (1:0)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "expression": { + "type": "UpdateExpression", + "start": 0, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "operator": "--", + "prefix": false, + "argument": { + "type": "NumericLiteral", + "start": 0, + "end": 1, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 1 + } + }, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/372/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/372/options.json deleted file mode 100644 index 515e441e8ea7..000000000000 --- a/packages/babel-parser/test/fixtures/core/uncategorised/372/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid left-hand side in prefix operation (1:2)" -} diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/372/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/372/output.json new file mode 100644 index 000000000000..9a7a240c5b4a --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/uncategorised/372/output.json @@ -0,0 +1,90 @@ +{ + "type": "File", + "start": 0, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "errors": [ + "SyntaxError: Invalid left-hand side in prefix operation (1:2)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "expression": { + "type": "UpdateExpression", + "start": 0, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "operator": "++", + "prefix": true, + "argument": { + "type": "NumericLiteral", + "start": 2, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 2 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/373/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/373/options.json deleted file mode 100644 index 515e441e8ea7..000000000000 --- a/packages/babel-parser/test/fixtures/core/uncategorised/373/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid left-hand side in prefix operation (1:2)" -} diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/373/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/373/output.json new file mode 100644 index 000000000000..85107220dae5 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/uncategorised/373/output.json @@ -0,0 +1,90 @@ +{ + "type": "File", + "start": 0, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "errors": [ + "SyntaxError: Invalid left-hand side in prefix operation (1:2)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "expression": { + "type": "UpdateExpression", + "start": 0, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "operator": "--", + "prefix": true, + "argument": { + "type": "NumericLiteral", + "start": 2, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 2 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/374/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/374/options.json deleted file mode 100644 index f8560a7de9d6..000000000000 --- a/packages/babel-parser/test/fixtures/core/uncategorised/374/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid left-hand side in for-in statement (1:5)" -} diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/374/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/374/output.json new file mode 100644 index 000000000000..f9e5df01e76a --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/uncategorised/374/output.json @@ -0,0 +1,196 @@ +{ + "type": "File", + "start": 0, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "errors": [ + "SyntaxError: Invalid left-hand side in for-in statement (1:5)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ForInStatement", + "start": 0, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "left": { + "type": "BinaryExpression", + "start": 5, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "left": { + "type": "NumericLiteral", + "start": 5, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + }, + "operator": "+", + "right": { + "type": "NumericLiteral", + "start": 9, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + }, + "extra": { + "parenthesized": true, + "parenStart": 4 + } + }, + "right": { + "type": "Identifier", + "start": 15, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 19 + }, + "identifierName": "list" + }, + "name": "list" + }, + "body": { + "type": "ExpressionStatement", + "start": 21, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 21 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "expression": { + "type": "CallExpression", + "start": 21, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 21 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "callee": { + "type": "Identifier", + "start": 21, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 21 + }, + "end": { + "line": 1, + "column": 28 + }, + "identifierName": "process" + }, + "name": "process" + }, + "arguments": [ + { + "type": "Identifier", + "start": 29, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 29 + }, + "end": { + "line": 1, + "column": 30 + }, + "identifierName": "x" + }, + "name": "x" + } + ] + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/382/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/382/options.json deleted file mode 100644 index 2b91be8d5115..000000000000 --- a/packages/babel-parser/test/fixtures/core/uncategorised/382/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Unexpected keyword 'if' (1:4)" -} diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/382/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/382/output.json new file mode 100644 index 000000000000..ac910291b748 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/uncategorised/382/output.json @@ -0,0 +1,108 @@ +{ + "type": "File", + "start": 0, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "errors": [ + "SyntaxError: Unexpected keyword 'if' (1:4)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "VariableDeclaration", + "start": 0, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 4, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "id": { + "type": "Identifier", + "start": 4, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 6 + }, + "identifierName": "if" + }, + "name": "if" + }, + "init": { + "type": "NumericLiteral", + "start": 9, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "extra": { + "rawValue": 42, + "raw": "42" + }, + "value": 42 + } + } + ], + "kind": "var" + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/383/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/383/options.json deleted file mode 100644 index 6010e96ed144..000000000000 --- a/packages/babel-parser/test/fixtures/core/uncategorised/383/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid left-hand side in assignment expression (1:0)" -} diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/383/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/383/output.json new file mode 100644 index 000000000000..56547ff7be13 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/uncategorised/383/output.json @@ -0,0 +1,142 @@ +{ + "type": "File", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "errors": [ + "SyntaxError: Invalid left-hand side in assignment expression (1:0)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "expression": { + "type": "AssignmentExpression", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "operator": "=", + "left": { + "type": "BinaryExpression", + "start": 0, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "left": { + "type": "Identifier", + "start": 0, + "end": 1, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 1 + }, + "identifierName": "i" + }, + "name": "i" + }, + "operator": "+", + "right": { + "type": "NumericLiteral", + "start": 4, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "extra": { + "rawValue": 2, + "raw": "2" + }, + "value": 2 + } + }, + "right": { + "type": "NumericLiteral", + "start": 8, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "extra": { + "rawValue": 42, + "raw": "42" + }, + "value": 42 + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/384/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/384/options.json deleted file mode 100644 index 6010e96ed144..000000000000 --- a/packages/babel-parser/test/fixtures/core/uncategorised/384/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid left-hand side in assignment expression (1:0)" -} diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/384/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/384/output.json new file mode 100644 index 000000000000..ece139488ea0 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/uncategorised/384/output.json @@ -0,0 +1,123 @@ +{ + "type": "File", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "errors": [ + "SyntaxError: Invalid left-hand side in assignment expression (1:0)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "expression": { + "type": "AssignmentExpression", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "operator": "=", + "left": { + "type": "UnaryExpression", + "start": 0, + "end": 2, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 2 + } + }, + "operator": "+", + "prefix": true, + "argument": { + "type": "Identifier", + "start": 1, + "end": 2, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 2 + }, + "identifierName": "i" + }, + "name": "i" + } + }, + "right": { + "type": "NumericLiteral", + "start": 5, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "extra": { + "rawValue": 42, + "raw": "42" + }, + "value": 42 + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/397/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/397/options.json deleted file mode 100644 index f9543317a817..000000000000 --- a/packages/babel-parser/test/fixtures/core/uncategorised/397/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Unexpected keyword 'if' (1:11)" -} diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/397/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/397/output.json new file mode 100644 index 000000000000..0e5a7503ecdd --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/uncategorised/397/output.json @@ -0,0 +1,108 @@ +{ + "type": "File", + "start": 0, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "errors": [ + "SyntaxError: Unexpected keyword 'if' (1:11)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 10 + }, + "identifierName": "t" + }, + "name": "t" + }, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "start": 11, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 13 + }, + "identifierName": "if" + }, + "name": "if" + } + ], + "body": { + "type": "BlockStatement", + "start": 15, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "body": [], + "directives": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/398/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/398/options.json deleted file mode 100644 index bba7a057d842..000000000000 --- a/packages/babel-parser/test/fixtures/core/uncategorised/398/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Unexpected keyword 'true' (1:11)" -} diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/398/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/398/output.json new file mode 100644 index 000000000000..9da054e4ab90 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/uncategorised/398/output.json @@ -0,0 +1,108 @@ +{ + "type": "File", + "start": 0, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "errors": [ + "SyntaxError: Unexpected keyword 'true' (1:11)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 10 + }, + "identifierName": "t" + }, + "name": "t" + }, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "start": 11, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 15 + }, + "identifierName": "true" + }, + "name": "true" + } + ], + "body": { + "type": "BlockStatement", + "start": 17, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "body": [], + "directives": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/399/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/399/options.json deleted file mode 100644 index b04b18396af1..000000000000 --- a/packages/babel-parser/test/fixtures/core/uncategorised/399/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Unexpected keyword 'false' (1:11)" -} diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/399/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/399/output.json new file mode 100644 index 000000000000..f4f5b906e9c7 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/uncategorised/399/output.json @@ -0,0 +1,108 @@ +{ + "type": "File", + "start": 0, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "errors": [ + "SyntaxError: Unexpected keyword 'false' (1:11)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 10 + }, + "identifierName": "t" + }, + "name": "t" + }, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "start": 11, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 16 + }, + "identifierName": "false" + }, + "name": "false" + } + ], + "body": { + "type": "BlockStatement", + "start": 18, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "body": [], + "directives": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/400/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/400/options.json deleted file mode 100644 index 667f2cc8816d..000000000000 --- a/packages/babel-parser/test/fixtures/core/uncategorised/400/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Unexpected keyword 'null' (1:11)" -} diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/400/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/400/output.json new file mode 100644 index 000000000000..b8eaca925ad4 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/uncategorised/400/output.json @@ -0,0 +1,108 @@ +{ + "type": "File", + "start": 0, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "errors": [ + "SyntaxError: Unexpected keyword 'null' (1:11)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 10 + }, + "identifierName": "t" + }, + "name": "t" + }, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "start": 11, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 15 + }, + "identifierName": "null" + }, + "name": "null" + } + ], + "body": { + "type": "BlockStatement", + "start": 17, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "body": [], + "directives": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/401/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/401/options.json deleted file mode 100644 index fa57d4f43f70..000000000000 --- a/packages/babel-parser/test/fixtures/core/uncategorised/401/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Unexpected keyword 'null' (1:9)" -} diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/401/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/401/output.json new file mode 100644 index 000000000000..3fea78461b66 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/uncategorised/401/output.json @@ -0,0 +1,90 @@ +{ + "type": "File", + "start": 0, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "errors": [ + "SyntaxError: Unexpected keyword 'null' (1:9)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 13 + }, + "identifierName": "null" + }, + "name": "null" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 16, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "body": [], + "directives": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/402/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/402/options.json deleted file mode 100644 index c4a7ead13704..000000000000 --- a/packages/babel-parser/test/fixtures/core/uncategorised/402/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Unexpected keyword 'true' (1:9)" -} diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/402/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/402/output.json new file mode 100644 index 000000000000..fc0c10f2f765 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/uncategorised/402/output.json @@ -0,0 +1,90 @@ +{ + "type": "File", + "start": 0, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "errors": [ + "SyntaxError: Unexpected keyword 'true' (1:9)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 13 + }, + "identifierName": "true" + }, + "name": "true" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 16, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "body": [], + "directives": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/403/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/403/options.json deleted file mode 100644 index 0e9cf8962aae..000000000000 --- a/packages/babel-parser/test/fixtures/core/uncategorised/403/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Unexpected keyword 'false' (1:9)" -} diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/403/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/403/output.json new file mode 100644 index 000000000000..7e708faf3684 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/uncategorised/403/output.json @@ -0,0 +1,90 @@ +{ + "type": "File", + "start": 0, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "errors": [ + "SyntaxError: Unexpected keyword 'false' (1:9)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 14 + }, + "identifierName": "false" + }, + "name": "false" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 17, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "body": [], + "directives": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/404/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/404/options.json deleted file mode 100644 index a87aa98c0e01..000000000000 --- a/packages/babel-parser/test/fixtures/core/uncategorised/404/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Unexpected keyword 'if' (1:9)" -} diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/404/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/404/output.json new file mode 100644 index 000000000000..813c4e9b903a --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/uncategorised/404/output.json @@ -0,0 +1,90 @@ +{ + "type": "File", + "start": 0, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "errors": [ + "SyntaxError: Unexpected keyword 'if' (1:9)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 11 + }, + "identifierName": "if" + }, + "name": "if" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 14, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "body": [], + "directives": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/409/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/409/options.json deleted file mode 100644 index 701f9fe8f27a..000000000000 --- a/packages/babel-parser/test/fixtures/core/uncategorised/409/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Unsyntactic break (1:0)" -} diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/409/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/409/output.json new file mode 100644 index 000000000000..d3a105c584dd --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/uncategorised/409/output.json @@ -0,0 +1,54 @@ +{ + "type": "File", + "start": 0, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "errors": [ + "SyntaxError: Unsyntactic break (1:0)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "BreakStatement", + "start": 0, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "label": null + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/411/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/411/options.json deleted file mode 100644 index de66853a7a3d..000000000000 --- a/packages/babel-parser/test/fixtures/core/uncategorised/411/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Unsyntactic continue (1:0)" -} diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/411/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/411/output.json new file mode 100644 index 000000000000..c32c5b089115 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/uncategorised/411/output.json @@ -0,0 +1,54 @@ +{ + "type": "File", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "errors": [ + "SyntaxError: Unsyntactic continue (1:0)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ContinueStatement", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "label": null + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/417/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/417/options.json deleted file mode 100644 index f8560a7de9d6..000000000000 --- a/packages/babel-parser/test/fixtures/core/uncategorised/417/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid left-hand side in for-in statement (1:5)" -} diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/417/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/417/output.json new file mode 100644 index 000000000000..3844a4d151a7 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/uncategorised/417/output.json @@ -0,0 +1,137 @@ +{ + "type": "File", + "start": 0, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "errors": [ + "SyntaxError: Invalid left-hand side in for-in statement (1:5)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ForInStatement", + "start": 0, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "left": { + "type": "BinaryExpression", + "start": 5, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "left": { + "type": "Identifier", + "start": 5, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 6 + }, + "identifierName": "i" + }, + "name": "i" + }, + "operator": "+", + "right": { + "type": "NumericLiteral", + "start": 9, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + } + }, + "right": { + "type": "ObjectExpression", + "start": 14, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "properties": [] + }, + "body": { + "type": "EmptyStatement", + "start": 17, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 18 + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/418/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/418/options.json deleted file mode 100644 index f8560a7de9d6..000000000000 --- a/packages/babel-parser/test/fixtures/core/uncategorised/418/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid left-hand side in for-in statement (1:5)" -} diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/418/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/418/output.json new file mode 100644 index 000000000000..9d008175f644 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/uncategorised/418/output.json @@ -0,0 +1,118 @@ +{ + "type": "File", + "start": 0, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "errors": [ + "SyntaxError: Invalid left-hand side in for-in statement (1:5)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ForInStatement", + "start": 0, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "left": { + "type": "UnaryExpression", + "start": 5, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "operator": "+", + "prefix": true, + "argument": { + "type": "Identifier", + "start": 6, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + }, + "identifierName": "i" + }, + "name": "i" + } + }, + "right": { + "type": "ObjectExpression", + "start": 11, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "properties": [] + }, + "body": { + "type": "EmptyStatement", + "start": 14, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 15 + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/425/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/425/options.json deleted file mode 100644 index 429d96ca3f9a..000000000000 --- a/packages/babel-parser/test/fixtures/core/uncategorised/425/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Missing catch or finally clause (1:0)" -} diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/425/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/425/output.json new file mode 100644 index 000000000000..3d2ee0555b85 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/uncategorised/425/output.json @@ -0,0 +1,72 @@ +{ + "type": "File", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "errors": [ + "SyntaxError: Missing catch or finally clause (1:0)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "TryStatement", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "block": { + "type": "BlockStatement", + "start": 4, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "body": [], + "directives": [] + }, + "handler": null, + "finalizer": null + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/427/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/427/options.json deleted file mode 100644 index aadfa63716c2..000000000000 --- a/packages/babel-parser/test/fixtures/core/uncategorised/427/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Multiple default clauses (1:22)" -} diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/427/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/427/output.json new file mode 100644 index 000000000000..c90c4eefdc6f --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/uncategorised/427/output.json @@ -0,0 +1,106 @@ +{ + "type": "File", + "start": 0, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "errors": [ + "SyntaxError: Multiple default clauses (1:22)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "SwitchStatement", + "start": 0, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "discriminant": { + "type": "Identifier", + "start": 8, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 9 + }, + "identifierName": "c" + }, + "name": "c" + }, + "cases": [ + { + "type": "SwitchCase", + "start": 13, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "consequent": [], + "test": null + }, + { + "type": "SwitchCase", + "start": 22, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 22 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "consequent": [], + "test": null + } + ] + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/446/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/446/options.json deleted file mode 100644 index 381fd12ce2d0..000000000000 --- a/packages/babel-parser/test/fixtures/core/uncategorised/446/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Expecting Unicode escape sequence \\uXXXX (1:1)" -} diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/446/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/446/output.json new file mode 100644 index 000000000000..1db488318bdf --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/uncategorised/446/output.json @@ -0,0 +1,71 @@ +{ + "type": "File", + "start": 0, + "end": 2, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 2 + } + }, + "errors": [ + "SyntaxError: Expecting Unicode escape sequence \\uXXXX (1:1)", + "SyntaxError: Expecting Unicode escape sequence \\uXXXX (1:2)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 2, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 2 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 2, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 2 + } + }, + "expression": { + "type": "Identifier", + "start": 0, + "end": 2, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 2 + }, + "identifierName": "\\\\\\" + }, + "name": "\\\\\\" + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/447/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/447/options.json deleted file mode 100644 index 82bcfe621c49..000000000000 --- a/packages/babel-parser/test/fixtures/core/uncategorised/447/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid Unicode escape (1:0)" -} diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/447/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/447/output.json new file mode 100644 index 000000000000..d44909ca998a --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/uncategorised/447/output.json @@ -0,0 +1,70 @@ +{ + "type": "File", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "errors": [ + "SyntaxError: Invalid Unicode escape (1:0)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "expression": { + "type": "Identifier", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + }, + "identifierName": "\\" + }, + "name": "\\" + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/448/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/448/options.json deleted file mode 100644 index 381fd12ce2d0..000000000000 --- a/packages/babel-parser/test/fixtures/core/uncategorised/448/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Expecting Unicode escape sequence \\uXXXX (1:1)" -} diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/448/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/448/output.json new file mode 100644 index 000000000000..38cc0c05b021 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/uncategorised/448/output.json @@ -0,0 +1,70 @@ +{ + "type": "File", + "start": 0, + "end": 2, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 2 + } + }, + "errors": [ + "SyntaxError: Expecting Unicode escape sequence \\uXXXX (1:1)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 2, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 2 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 2, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 2 + } + }, + "expression": { + "type": "Identifier", + "start": 0, + "end": 2, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 2 + }, + "identifierName": "\\x" + }, + "name": "\\x" + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/449/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/449/options.json deleted file mode 100644 index 82bcfe621c49..000000000000 --- a/packages/babel-parser/test/fixtures/core/uncategorised/449/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid Unicode escape (1:0)" -} diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/449/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/449/output.json new file mode 100644 index 000000000000..380e6ec698ef --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/uncategorised/449/output.json @@ -0,0 +1,70 @@ +{ + "type": "File", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "errors": [ + "SyntaxError: Invalid Unicode escape (1:0)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "expression": { + "type": "Identifier", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + }, + "identifierName": "\u0000" + }, + "name": "\u0000" + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/453/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/453/options.json index 8e0dce66eff8..a760565b1bd2 100644 --- a/packages/babel-parser/test/fixtures/core/uncategorised/453/options.json +++ b/packages/babel-parser/test/fixtures/core/uncategorised/453/options.json @@ -1,3 +1,3 @@ { - "throws": "Bad character escape sequence (1:3)" -} + "throws": "Unterminated string constant (1:0)" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/454/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/454/options.json deleted file mode 100644 index f9d29c7f328c..000000000000 --- a/packages/babel-parser/test/fixtures/core/uncategorised/454/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "'return' outside of function (1:0)" -} diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/454/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/454/output.json new file mode 100644 index 000000000000..e43da2374537 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/uncategorised/454/output.json @@ -0,0 +1,54 @@ +{ + "type": "File", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "errors": [ + "SyntaxError: 'return' outside of function (1:0)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ReturnStatement", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "argument": null + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/455/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/455/options.json deleted file mode 100644 index 701f9fe8f27a..000000000000 --- a/packages/babel-parser/test/fixtures/core/uncategorised/455/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Unsyntactic break (1:0)" -} diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/455/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/455/output.json new file mode 100644 index 000000000000..d3a105c584dd --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/uncategorised/455/output.json @@ -0,0 +1,54 @@ +{ + "type": "File", + "start": 0, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "errors": [ + "SyntaxError: Unsyntactic break (1:0)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "BreakStatement", + "start": 0, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "label": null + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/456/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/456/options.json deleted file mode 100644 index de66853a7a3d..000000000000 --- a/packages/babel-parser/test/fixtures/core/uncategorised/456/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Unsyntactic continue (1:0)" -} diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/456/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/456/output.json new file mode 100644 index 000000000000..c32c5b089115 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/uncategorised/456/output.json @@ -0,0 +1,54 @@ +{ + "type": "File", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "errors": [ + "SyntaxError: Unsyntactic continue (1:0)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ContinueStatement", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "label": null + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/457/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/457/options.json deleted file mode 100644 index c726e8fa98e4..000000000000 --- a/packages/babel-parser/test/fixtures/core/uncategorised/457/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Unsyntactic continue (1:22)" -} diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/457/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/457/output.json new file mode 100644 index 000000000000..b83145faf5ab --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/uncategorised/457/output.json @@ -0,0 +1,106 @@ +{ + "type": "File", + "start": 0, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 33 + } + }, + "errors": [ + "SyntaxError: Unsyntactic continue (1:22)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 33 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "SwitchStatement", + "start": 0, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 33 + } + }, + "discriminant": { + "type": "Identifier", + "start": 8, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 9 + }, + "identifierName": "x" + }, + "name": "x" + }, + "cases": [ + { + "type": "SwitchCase", + "start": 13, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "consequent": [ + { + "type": "ContinueStatement", + "start": 22, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 22 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "label": null + } + ], + "test": null + } + ] + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/459/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/459/options.json deleted file mode 100644 index 070e662e80d4..000000000000 --- a/packages/babel-parser/test/fixtures/core/uncategorised/459/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Unsyntactic break (1:15)" -} diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/459/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/459/output.json new file mode 100644 index 000000000000..a7c8d4f9a0ca --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/uncategorised/459/output.json @@ -0,0 +1,119 @@ +{ + "type": "File", + "start": 0, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 25 + } + }, + "errors": [ + "SyntaxError: Unsyntactic break (1:15)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 25 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "WhileStatement", + "start": 0, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 25 + } + }, + "test": { + "type": "BooleanLiteral", + "start": 7, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "value": true + }, + "body": { + "type": "BlockStatement", + "start": 13, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 25 + } + }, + "body": [ + { + "type": "BreakStatement", + "start": 15, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "label": { + "type": "Identifier", + "start": 21, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 21 + }, + "end": { + "line": 1, + "column": 22 + }, + "identifierName": "x" + }, + "name": "x" + } + } + ], + "directives": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/460/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/460/options.json deleted file mode 100644 index 2a2e15787aa7..000000000000 --- a/packages/babel-parser/test/fixtures/core/uncategorised/460/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Unsyntactic continue (1:15)" -} diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/460/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/460/output.json new file mode 100644 index 000000000000..2f1c8737b22e --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/uncategorised/460/output.json @@ -0,0 +1,119 @@ +{ + "type": "File", + "start": 0, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 28 + } + }, + "errors": [ + "SyntaxError: Unsyntactic continue (1:15)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 28 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "WhileStatement", + "start": 0, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 28 + } + }, + "test": { + "type": "BooleanLiteral", + "start": 7, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "value": true + }, + "body": { + "type": "BlockStatement", + "start": 13, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 28 + } + }, + "body": [ + { + "type": "ContinueStatement", + "start": 15, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "label": { + "type": "Identifier", + "start": 24, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 24 + }, + "end": { + "line": 1, + "column": 25 + }, + "identifierName": "x" + }, + "name": "x" + } + } + ], + "directives": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/461/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/461/options.json deleted file mode 100644 index 464af80a1561..000000000000 --- a/packages/babel-parser/test/fixtures/core/uncategorised/461/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Unsyntactic break (1:33)" -} diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/461/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/461/output.json new file mode 100644 index 000000000000..7337acd3e8fd --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/uncategorised/461/output.json @@ -0,0 +1,207 @@ +{ + "type": "File", + "start": 0, + "end": 47, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 47 + } + }, + "errors": [ + "SyntaxError: Unsyntactic break (1:33)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 47, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 47 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "LabeledStatement", + "start": 0, + "end": 47, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 47 + } + }, + "body": { + "type": "WhileStatement", + "start": 3, + "end": 47, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 47 + } + }, + "test": { + "type": "BooleanLiteral", + "start": 10, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "value": true + }, + "body": { + "type": "BlockStatement", + "start": 16, + "end": 47, + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 47 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 18, + "end": 45, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 45 + } + }, + "expression": { + "type": "FunctionExpression", + "start": 19, + "end": 43, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 43 + } + }, + "id": null, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 31, + "end": 43, + "loc": { + "start": { + "line": 1, + "column": 31 + }, + "end": { + "line": 1, + "column": 43 + } + }, + "body": [ + { + "type": "BreakStatement", + "start": 33, + "end": 41, + "loc": { + "start": { + "line": 1, + "column": 33 + }, + "end": { + "line": 1, + "column": 41 + } + }, + "label": { + "type": "Identifier", + "start": 39, + "end": 40, + "loc": { + "start": { + "line": 1, + "column": 39 + }, + "end": { + "line": 1, + "column": 40 + }, + "identifierName": "x" + }, + "name": "x" + } + } + ], + "directives": [] + }, + "extra": { + "parenthesized": true, + "parenStart": 18 + } + } + } + ], + "directives": [] + } + }, + "label": { + "type": "Identifier", + "start": 0, + "end": 1, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 1 + }, + "identifierName": "x" + }, + "name": "x" + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/462/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/462/options.json deleted file mode 100644 index a056cb50e190..000000000000 --- a/packages/babel-parser/test/fixtures/core/uncategorised/462/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Unsyntactic continue (1:33)" -} diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/462/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/462/output.json new file mode 100644 index 000000000000..18bc9b977ca7 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/uncategorised/462/output.json @@ -0,0 +1,207 @@ +{ + "type": "File", + "start": 0, + "end": 50, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 50 + } + }, + "errors": [ + "SyntaxError: Unsyntactic continue (1:33)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 50, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 50 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "LabeledStatement", + "start": 0, + "end": 50, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 50 + } + }, + "body": { + "type": "WhileStatement", + "start": 3, + "end": 50, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 50 + } + }, + "test": { + "type": "BooleanLiteral", + "start": 10, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "value": true + }, + "body": { + "type": "BlockStatement", + "start": 16, + "end": 50, + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 50 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 18, + "end": 48, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 48 + } + }, + "expression": { + "type": "FunctionExpression", + "start": 19, + "end": 46, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 46 + } + }, + "id": null, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 31, + "end": 46, + "loc": { + "start": { + "line": 1, + "column": 31 + }, + "end": { + "line": 1, + "column": 46 + } + }, + "body": [ + { + "type": "ContinueStatement", + "start": 33, + "end": 44, + "loc": { + "start": { + "line": 1, + "column": 33 + }, + "end": { + "line": 1, + "column": 44 + } + }, + "label": { + "type": "Identifier", + "start": 42, + "end": 43, + "loc": { + "start": { + "line": 1, + "column": 42 + }, + "end": { + "line": 1, + "column": 43 + }, + "identifierName": "x" + }, + "name": "x" + } + } + ], + "directives": [] + }, + "extra": { + "parenthesized": true, + "parenStart": 18 + } + } + } + ], + "directives": [] + } + }, + "label": { + "type": "Identifier", + "start": 0, + "end": 1, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 1 + }, + "identifierName": "x" + }, + "name": "x" + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/463/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/463/options.json deleted file mode 100644 index 464af80a1561..000000000000 --- a/packages/babel-parser/test/fixtures/core/uncategorised/463/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Unsyntactic break (1:33)" -} diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/463/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/463/output.json new file mode 100644 index 000000000000..59ae007d6fba --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/uncategorised/463/output.json @@ -0,0 +1,191 @@ +{ + "type": "File", + "start": 0, + "end": 45, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 45 + } + }, + "errors": [ + "SyntaxError: Unsyntactic break (1:33)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 45, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 45 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "LabeledStatement", + "start": 0, + "end": 45, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 45 + } + }, + "body": { + "type": "WhileStatement", + "start": 3, + "end": 45, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 45 + } + }, + "test": { + "type": "BooleanLiteral", + "start": 10, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "value": true + }, + "body": { + "type": "BlockStatement", + "start": 16, + "end": 45, + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 45 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 18, + "end": 43, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 43 + } + }, + "expression": { + "type": "FunctionExpression", + "start": 19, + "end": 41, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 41 + } + }, + "id": null, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 31, + "end": 41, + "loc": { + "start": { + "line": 1, + "column": 31 + }, + "end": { + "line": 1, + "column": 41 + } + }, + "body": [ + { + "type": "BreakStatement", + "start": 33, + "end": 39, + "loc": { + "start": { + "line": 1, + "column": 33 + }, + "end": { + "line": 1, + "column": 39 + } + }, + "label": null + } + ], + "directives": [] + }, + "extra": { + "parenthesized": true, + "parenStart": 18 + } + } + } + ], + "directives": [] + } + }, + "label": { + "type": "Identifier", + "start": 0, + "end": 1, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 1 + }, + "identifierName": "x" + }, + "name": "x" + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/464/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/464/options.json deleted file mode 100644 index a056cb50e190..000000000000 --- a/packages/babel-parser/test/fixtures/core/uncategorised/464/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Unsyntactic continue (1:33)" -} diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/464/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/464/output.json new file mode 100644 index 000000000000..d26e37b08031 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/uncategorised/464/output.json @@ -0,0 +1,191 @@ +{ + "type": "File", + "start": 0, + "end": 48, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 48 + } + }, + "errors": [ + "SyntaxError: Unsyntactic continue (1:33)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 48, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 48 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "LabeledStatement", + "start": 0, + "end": 48, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 48 + } + }, + "body": { + "type": "WhileStatement", + "start": 3, + "end": 48, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 48 + } + }, + "test": { + "type": "BooleanLiteral", + "start": 10, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "value": true + }, + "body": { + "type": "BlockStatement", + "start": 16, + "end": 48, + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 48 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 18, + "end": 46, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 46 + } + }, + "expression": { + "type": "FunctionExpression", + "start": 19, + "end": 44, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 44 + } + }, + "id": null, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 31, + "end": 44, + "loc": { + "start": { + "line": 1, + "column": 31 + }, + "end": { + "line": 1, + "column": 44 + } + }, + "body": [ + { + "type": "ContinueStatement", + "start": 33, + "end": 42, + "loc": { + "start": { + "line": 1, + "column": 33 + }, + "end": { + "line": 1, + "column": 42 + } + }, + "label": null + } + ], + "directives": [] + }, + "extra": { + "parenthesized": true, + "parenStart": 18 + } + } + } + ], + "directives": [] + } + }, + "label": { + "type": "Identifier", + "start": 0, + "end": 1, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 1 + }, + "identifierName": "x" + }, + "name": "x" + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/465/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/465/options.json deleted file mode 100644 index da7f2590db0b..000000000000 --- a/packages/babel-parser/test/fixtures/core/uncategorised/465/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Label 'x' is already declared (1:18)" -} diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/465/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/465/output.json new file mode 100644 index 000000000000..3025d6bfbf72 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/uncategorised/465/output.json @@ -0,0 +1,199 @@ +{ + "type": "File", + "start": 0, + "end": 39, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 39 + } + }, + "errors": [ + "SyntaxError: Label 'x' is already declared (1:18)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 39, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 39 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "LabeledStatement", + "start": 0, + "end": 39, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 39 + } + }, + "body": { + "type": "WhileStatement", + "start": 3, + "end": 39, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 39 + } + }, + "test": { + "type": "BooleanLiteral", + "start": 10, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "value": true + }, + "body": { + "type": "BlockStatement", + "start": 16, + "end": 39, + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 39 + } + }, + "body": [ + { + "type": "LabeledStatement", + "start": 18, + "end": 37, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 37 + } + }, + "body": { + "type": "WhileStatement", + "start": 21, + "end": 37, + "loc": { + "start": { + "line": 1, + "column": 21 + }, + "end": { + "line": 1, + "column": 37 + } + }, + "test": { + "type": "BooleanLiteral", + "start": 28, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 28 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "value": true + }, + "body": { + "type": "BlockStatement", + "start": 34, + "end": 37, + "loc": { + "start": { + "line": 1, + "column": 34 + }, + "end": { + "line": 1, + "column": 37 + } + }, + "body": [], + "directives": [] + } + }, + "label": { + "type": "Identifier", + "start": 18, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 19 + }, + "identifierName": "x" + }, + "name": "x" + } + } + ], + "directives": [] + } + }, + "label": { + "type": "Identifier", + "start": 0, + "end": 1, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 1 + }, + "identifierName": "x" + }, + "name": "x" + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/466/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/466/options.json deleted file mode 100644 index 1517e1719333..000000000000 --- a/packages/babel-parser/test/fixtures/core/uncategorised/466/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Deleting local variable in strict mode (1:29)" -} diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/466/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/466/output.json new file mode 100644 index 000000000000..f22f0efb0609 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/uncategorised/466/output.json @@ -0,0 +1,195 @@ +{ + "type": "File", + "start": 0, + "end": 43, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 43 + } + }, + "errors": [ + "SyntaxError: Deleting local variable in strict mode (1:29)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 43, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 43 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 43, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 43 + } + }, + "expression": { + "type": "CallExpression", + "start": 1, + "end": 42, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 42 + } + }, + "callee": { + "type": "FunctionExpression", + "start": 1, + "end": 40, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 40 + } + }, + "id": null, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 13, + "end": 40, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 40 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 29, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 29 + }, + "end": { + "line": 1, + "column": 38 + } + }, + "expression": { + "type": "UnaryExpression", + "start": 29, + "end": 37, + "loc": { + "start": { + "line": 1, + "column": 29 + }, + "end": { + "line": 1, + "column": 37 + } + }, + "operator": "delete", + "prefix": true, + "argument": { + "type": "Identifier", + "start": 36, + "end": 37, + "loc": { + "start": { + "line": 1, + "column": 36 + }, + "end": { + "line": 1, + "column": 37 + }, + "identifierName": "i" + }, + "name": "i" + } + } + } + ], + "directives": [ + { + "type": "Directive", + "start": 15, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 28 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 15, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 27 + } + }, + "value": "use strict", + "extra": { + "raw": "'use strict'", + "rawValue": "use strict" + } + } + } + ] + } + }, + "arguments": [], + "extra": { + "parenthesized": true, + "parenStart": 0 + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/467/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/467/options.json deleted file mode 100644 index 31b4c6d2a040..000000000000 --- a/packages/babel-parser/test/fixtures/core/uncategorised/467/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "'with' in strict mode (1:29)" -} diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/467/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/467/output.json new file mode 100644 index 000000000000..1567b18881d6 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/uncategorised/467/output.json @@ -0,0 +1,193 @@ +{ + "type": "File", + "start": 0, + "end": 43, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 43 + } + }, + "errors": [ + "SyntaxError: 'with' in strict mode (1:29)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 43, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 43 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 43, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 43 + } + }, + "expression": { + "type": "CallExpression", + "start": 1, + "end": 42, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 42 + } + }, + "callee": { + "type": "FunctionExpression", + "start": 1, + "end": 40, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 40 + } + }, + "id": null, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 13, + "end": 40, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 40 + } + }, + "body": [ + { + "type": "WithStatement", + "start": 29, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 29 + }, + "end": { + "line": 1, + "column": 38 + } + }, + "object": { + "type": "Identifier", + "start": 35, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 35 + }, + "end": { + "line": 1, + "column": 36 + }, + "identifierName": "i" + }, + "name": "i" + }, + "body": { + "type": "EmptyStatement", + "start": 37, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 37 + }, + "end": { + "line": 1, + "column": 38 + } + } + } + } + ], + "directives": [ + { + "type": "Directive", + "start": 15, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 28 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 15, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 27 + } + }, + "value": "use strict", + "extra": { + "raw": "'use strict'", + "rawValue": "use strict" + } + } + } + ] + } + }, + "arguments": [], + "extra": { + "parenthesized": true, + "parenStart": 0 + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/468/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/468/options.json deleted file mode 100644 index dfbf1f6d0d1c..000000000000 --- a/packages/babel-parser/test/fixtures/core/uncategorised/468/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Binding 'eval' in strict mode (1:36)" -} diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/468/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/468/output.json new file mode 100644 index 000000000000..7598b7431e9f --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/uncategorised/468/output.json @@ -0,0 +1,197 @@ +{ + "type": "File", + "start": 0, + "end": 48, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 48 + } + }, + "errors": [ + "SyntaxError: Binding 'eval' in strict mode (1:36)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 48, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 48 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 48, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 48 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 14 + }, + "identifierName": "hello" + }, + "name": "hello" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 17, + "end": 48, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 48 + } + }, + "body": [ + { + "type": "VariableDeclaration", + "start": 32, + "end": 46, + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 46 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 36, + "end": 45, + "loc": { + "start": { + "line": 1, + "column": 36 + }, + "end": { + "line": 1, + "column": 45 + } + }, + "id": { + "type": "Identifier", + "start": 36, + "end": 40, + "loc": { + "start": { + "line": 1, + "column": 36 + }, + "end": { + "line": 1, + "column": 40 + }, + "identifierName": "eval" + }, + "name": "eval" + }, + "init": { + "type": "NumericLiteral", + "start": 43, + "end": 45, + "loc": { + "start": { + "line": 1, + "column": 43 + }, + "end": { + "line": 1, + "column": 45 + } + }, + "extra": { + "rawValue": 10, + "raw": "10" + }, + "value": 10 + } + } + ], + "kind": "var" + } + ], + "directives": [ + { + "type": "Directive", + "start": 18, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 18, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "value": "use strict", + "extra": { + "raw": "'use strict'", + "rawValue": "use strict" + } + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/469/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/469/options.json deleted file mode 100644 index b74dfcf59199..000000000000 --- a/packages/babel-parser/test/fixtures/core/uncategorised/469/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Binding 'arguments' in strict mode (1:36)" -} diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/469/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/469/output.json new file mode 100644 index 000000000000..7101109189a2 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/uncategorised/469/output.json @@ -0,0 +1,197 @@ +{ + "type": "File", + "start": 0, + "end": 53, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 53 + } + }, + "errors": [ + "SyntaxError: Binding 'arguments' in strict mode (1:36)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 53, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 53 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 53, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 53 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 14 + }, + "identifierName": "hello" + }, + "name": "hello" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 17, + "end": 53, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 53 + } + }, + "body": [ + { + "type": "VariableDeclaration", + "start": 32, + "end": 51, + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 51 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 36, + "end": 50, + "loc": { + "start": { + "line": 1, + "column": 36 + }, + "end": { + "line": 1, + "column": 50 + } + }, + "id": { + "type": "Identifier", + "start": 36, + "end": 45, + "loc": { + "start": { + "line": 1, + "column": 36 + }, + "end": { + "line": 1, + "column": 45 + }, + "identifierName": "arguments" + }, + "name": "arguments" + }, + "init": { + "type": "NumericLiteral", + "start": 48, + "end": 50, + "loc": { + "start": { + "line": 1, + "column": 48 + }, + "end": { + "line": 1, + "column": 50 + } + }, + "extra": { + "rawValue": 10, + "raw": "10" + }, + "value": 10 + } + } + ], + "kind": "var" + } + ], + "directives": [ + { + "type": "Directive", + "start": 18, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 18, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "value": "use strict", + "extra": { + "raw": "'use strict'", + "rawValue": "use strict" + } + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/470/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/470/options.json deleted file mode 100644 index e95a2d7f7535..000000000000 --- a/packages/babel-parser/test/fixtures/core/uncategorised/470/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Binding 'eval' in strict mode (1:47)" -} diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/470/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/470/output.json new file mode 100644 index 000000000000..dd5fca85f2e5 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/uncategorised/470/output.json @@ -0,0 +1,209 @@ +{ + "type": "File", + "start": 0, + "end": 58, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 58 + } + }, + "errors": [ + "SyntaxError: Binding 'eval' in strict mode (1:47)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 58, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 58 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 58, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 58 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 14 + }, + "identifierName": "hello" + }, + "name": "hello" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 17, + "end": 58, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 58 + } + }, + "body": [ + { + "type": "TryStatement", + "start": 32, + "end": 56, + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 56 + } + }, + "block": { + "type": "BlockStatement", + "start": 36, + "end": 39, + "loc": { + "start": { + "line": 1, + "column": 36 + }, + "end": { + "line": 1, + "column": 39 + } + }, + "body": [], + "directives": [] + }, + "handler": { + "type": "CatchClause", + "start": 40, + "end": 56, + "loc": { + "start": { + "line": 1, + "column": 40 + }, + "end": { + "line": 1, + "column": 56 + } + }, + "param": { + "type": "Identifier", + "start": 47, + "end": 51, + "loc": { + "start": { + "line": 1, + "column": 47 + }, + "end": { + "line": 1, + "column": 51 + }, + "identifierName": "eval" + }, + "name": "eval" + }, + "body": { + "type": "BlockStatement", + "start": 53, + "end": 56, + "loc": { + "start": { + "line": 1, + "column": 53 + }, + "end": { + "line": 1, + "column": 56 + } + }, + "body": [], + "directives": [] + } + }, + "finalizer": null + } + ], + "directives": [ + { + "type": "Directive", + "start": 18, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 18, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "value": "use strict", + "extra": { + "raw": "'use strict'", + "rawValue": "use strict" + } + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/471/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/471/options.json deleted file mode 100644 index 14d96617b4b6..000000000000 --- a/packages/babel-parser/test/fixtures/core/uncategorised/471/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Binding 'arguments' in strict mode (1:47)" -} diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/471/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/471/output.json new file mode 100644 index 000000000000..3b89f63424e2 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/uncategorised/471/output.json @@ -0,0 +1,209 @@ +{ + "type": "File", + "start": 0, + "end": 63, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 63 + } + }, + "errors": [ + "SyntaxError: Binding 'arguments' in strict mode (1:47)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 63, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 63 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 63, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 63 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 14 + }, + "identifierName": "hello" + }, + "name": "hello" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 17, + "end": 63, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 63 + } + }, + "body": [ + { + "type": "TryStatement", + "start": 32, + "end": 61, + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 61 + } + }, + "block": { + "type": "BlockStatement", + "start": 36, + "end": 39, + "loc": { + "start": { + "line": 1, + "column": 36 + }, + "end": { + "line": 1, + "column": 39 + } + }, + "body": [], + "directives": [] + }, + "handler": { + "type": "CatchClause", + "start": 40, + "end": 61, + "loc": { + "start": { + "line": 1, + "column": 40 + }, + "end": { + "line": 1, + "column": 61 + } + }, + "param": { + "type": "Identifier", + "start": 47, + "end": 56, + "loc": { + "start": { + "line": 1, + "column": 47 + }, + "end": { + "line": 1, + "column": 56 + }, + "identifierName": "arguments" + }, + "name": "arguments" + }, + "body": { + "type": "BlockStatement", + "start": 58, + "end": 61, + "loc": { + "start": { + "line": 1, + "column": 58 + }, + "end": { + "line": 1, + "column": 61 + } + }, + "body": [], + "directives": [] + } + }, + "finalizer": null + } + ], + "directives": [ + { + "type": "Directive", + "start": 18, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 18, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "value": "use strict", + "extra": { + "raw": "'use strict'", + "rawValue": "use strict" + } + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/472/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/472/options.json deleted file mode 100644 index 6faa5d0476c3..000000000000 --- a/packages/babel-parser/test/fixtures/core/uncategorised/472/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Assigning to 'eval' in strict mode (1:32)" -} diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/472/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/472/output.json new file mode 100644 index 000000000000..2973f3517639 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/uncategorised/472/output.json @@ -0,0 +1,195 @@ +{ + "type": "File", + "start": 0, + "end": 44, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 44 + } + }, + "errors": [ + "SyntaxError: Assigning to 'eval' in strict mode (1:32)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 44, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 44 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 44, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 44 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 14 + }, + "identifierName": "hello" + }, + "name": "hello" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 17, + "end": 44, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 44 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 32, + "end": 42, + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 42 + } + }, + "expression": { + "type": "AssignmentExpression", + "start": 32, + "end": 41, + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 41 + } + }, + "operator": "=", + "left": { + "type": "Identifier", + "start": 32, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 36 + }, + "identifierName": "eval" + }, + "name": "eval" + }, + "right": { + "type": "NumericLiteral", + "start": 39, + "end": 41, + "loc": { + "start": { + "line": 1, + "column": 39 + }, + "end": { + "line": 1, + "column": 41 + } + }, + "extra": { + "rawValue": 10, + "raw": "10" + }, + "value": 10 + } + } + } + ], + "directives": [ + { + "type": "Directive", + "start": 18, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 18, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "value": "use strict", + "extra": { + "raw": "'use strict'", + "rawValue": "use strict" + } + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/473/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/473/options.json deleted file mode 100644 index 2f502104f7d4..000000000000 --- a/packages/babel-parser/test/fixtures/core/uncategorised/473/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Assigning to 'arguments' in strict mode (1:32)" -} diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/473/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/473/output.json new file mode 100644 index 000000000000..e328a1e98ef9 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/uncategorised/473/output.json @@ -0,0 +1,195 @@ +{ + "type": "File", + "start": 0, + "end": 49, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 49 + } + }, + "errors": [ + "SyntaxError: Assigning to 'arguments' in strict mode (1:32)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 49, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 49 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 49, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 49 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 14 + }, + "identifierName": "hello" + }, + "name": "hello" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 17, + "end": 49, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 49 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 32, + "end": 47, + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 47 + } + }, + "expression": { + "type": "AssignmentExpression", + "start": 32, + "end": 46, + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 46 + } + }, + "operator": "=", + "left": { + "type": "Identifier", + "start": 32, + "end": 41, + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 41 + }, + "identifierName": "arguments" + }, + "name": "arguments" + }, + "right": { + "type": "NumericLiteral", + "start": 44, + "end": 46, + "loc": { + "start": { + "line": 1, + "column": 44 + }, + "end": { + "line": 1, + "column": 46 + } + }, + "extra": { + "rawValue": 10, + "raw": "10" + }, + "value": 10 + } + } + } + ], + "directives": [ + { + "type": "Directive", + "start": 18, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 18, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "value": "use strict", + "extra": { + "raw": "'use strict'", + "rawValue": "use strict" + } + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/474/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/474/options.json deleted file mode 100644 index 0964911894d9..000000000000 --- a/packages/babel-parser/test/fixtures/core/uncategorised/474/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Assigning to 'eval' in strict mode (1:34)" -} diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/474/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/474/output.json new file mode 100644 index 000000000000..95091e65367d --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/uncategorised/474/output.json @@ -0,0 +1,176 @@ +{ + "type": "File", + "start": 0, + "end": 41, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 41 + } + }, + "errors": [ + "SyntaxError: Assigning to 'eval' in strict mode (1:34)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 41, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 41 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 41, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 41 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 14 + }, + "identifierName": "hello" + }, + "name": "hello" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 17, + "end": 41, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 41 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 32, + "end": 39, + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 39 + } + }, + "expression": { + "type": "UpdateExpression", + "start": 32, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 38 + } + }, + "operator": "++", + "prefix": true, + "argument": { + "type": "Identifier", + "start": 34, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 34 + }, + "end": { + "line": 1, + "column": 38 + }, + "identifierName": "eval" + }, + "name": "eval" + } + } + } + ], + "directives": [ + { + "type": "Directive", + "start": 18, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 18, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "value": "use strict", + "extra": { + "raw": "'use strict'", + "rawValue": "use strict" + } + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/475/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/475/options.json deleted file mode 100644 index 0964911894d9..000000000000 --- a/packages/babel-parser/test/fixtures/core/uncategorised/475/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Assigning to 'eval' in strict mode (1:34)" -} diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/475/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/475/output.json new file mode 100644 index 000000000000..8473055a411c --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/uncategorised/475/output.json @@ -0,0 +1,176 @@ +{ + "type": "File", + "start": 0, + "end": 41, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 41 + } + }, + "errors": [ + "SyntaxError: Assigning to 'eval' in strict mode (1:34)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 41, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 41 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 41, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 41 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 14 + }, + "identifierName": "hello" + }, + "name": "hello" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 17, + "end": 41, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 41 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 32, + "end": 39, + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 39 + } + }, + "expression": { + "type": "UpdateExpression", + "start": 32, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 38 + } + }, + "operator": "--", + "prefix": true, + "argument": { + "type": "Identifier", + "start": 34, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 34 + }, + "end": { + "line": 1, + "column": 38 + }, + "identifierName": "eval" + }, + "name": "eval" + } + } + } + ], + "directives": [ + { + "type": "Directive", + "start": 18, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 18, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "value": "use strict", + "extra": { + "raw": "'use strict'", + "rawValue": "use strict" + } + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/476/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/476/options.json deleted file mode 100644 index ba5ef9dd55cc..000000000000 --- a/packages/babel-parser/test/fixtures/core/uncategorised/476/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Assigning to 'arguments' in strict mode (1:34)" -} diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/476/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/476/output.json new file mode 100644 index 000000000000..c9974932443e --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/uncategorised/476/output.json @@ -0,0 +1,176 @@ +{ + "type": "File", + "start": 0, + "end": 46, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 46 + } + }, + "errors": [ + "SyntaxError: Assigning to 'arguments' in strict mode (1:34)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 46, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 46 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 46, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 46 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 14 + }, + "identifierName": "hello" + }, + "name": "hello" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 17, + "end": 46, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 46 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 32, + "end": 44, + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 44 + } + }, + "expression": { + "type": "UpdateExpression", + "start": 32, + "end": 43, + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 43 + } + }, + "operator": "++", + "prefix": true, + "argument": { + "type": "Identifier", + "start": 34, + "end": 43, + "loc": { + "start": { + "line": 1, + "column": 34 + }, + "end": { + "line": 1, + "column": 43 + }, + "identifierName": "arguments" + }, + "name": "arguments" + } + } + } + ], + "directives": [ + { + "type": "Directive", + "start": 18, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 18, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "value": "use strict", + "extra": { + "raw": "'use strict'", + "rawValue": "use strict" + } + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/477/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/477/options.json deleted file mode 100644 index ba5ef9dd55cc..000000000000 --- a/packages/babel-parser/test/fixtures/core/uncategorised/477/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Assigning to 'arguments' in strict mode (1:34)" -} diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/477/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/477/output.json new file mode 100644 index 000000000000..cf31420c53a0 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/uncategorised/477/output.json @@ -0,0 +1,176 @@ +{ + "type": "File", + "start": 0, + "end": 46, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 46 + } + }, + "errors": [ + "SyntaxError: Assigning to 'arguments' in strict mode (1:34)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 46, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 46 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 46, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 46 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 14 + }, + "identifierName": "hello" + }, + "name": "hello" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 17, + "end": 46, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 46 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 32, + "end": 44, + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 44 + } + }, + "expression": { + "type": "UpdateExpression", + "start": 32, + "end": 43, + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 43 + } + }, + "operator": "--", + "prefix": true, + "argument": { + "type": "Identifier", + "start": 34, + "end": 43, + "loc": { + "start": { + "line": 1, + "column": 34 + }, + "end": { + "line": 1, + "column": 43 + }, + "identifierName": "arguments" + }, + "name": "arguments" + } + } + } + ], + "directives": [ + { + "type": "Directive", + "start": 18, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 18, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "value": "use strict", + "extra": { + "raw": "'use strict'", + "rawValue": "use strict" + } + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/478/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/478/options.json deleted file mode 100644 index 6faa5d0476c3..000000000000 --- a/packages/babel-parser/test/fixtures/core/uncategorised/478/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Assigning to 'eval' in strict mode (1:32)" -} diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/478/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/478/output.json new file mode 100644 index 000000000000..59618c91e2ca --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/uncategorised/478/output.json @@ -0,0 +1,176 @@ +{ + "type": "File", + "start": 0, + "end": 41, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 41 + } + }, + "errors": [ + "SyntaxError: Assigning to 'eval' in strict mode (1:32)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 41, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 41 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 41, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 41 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 14 + }, + "identifierName": "hello" + }, + "name": "hello" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 17, + "end": 41, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 41 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 32, + "end": 39, + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 39 + } + }, + "expression": { + "type": "UpdateExpression", + "start": 32, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 38 + } + }, + "operator": "++", + "prefix": false, + "argument": { + "type": "Identifier", + "start": 32, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 36 + }, + "identifierName": "eval" + }, + "name": "eval" + } + } + } + ], + "directives": [ + { + "type": "Directive", + "start": 18, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 18, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "value": "use strict", + "extra": { + "raw": "'use strict'", + "rawValue": "use strict" + } + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/479/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/479/options.json deleted file mode 100644 index 6faa5d0476c3..000000000000 --- a/packages/babel-parser/test/fixtures/core/uncategorised/479/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Assigning to 'eval' in strict mode (1:32)" -} diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/479/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/479/output.json new file mode 100644 index 000000000000..0b6b047c7b58 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/uncategorised/479/output.json @@ -0,0 +1,176 @@ +{ + "type": "File", + "start": 0, + "end": 41, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 41 + } + }, + "errors": [ + "SyntaxError: Assigning to 'eval' in strict mode (1:32)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 41, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 41 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 41, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 41 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 14 + }, + "identifierName": "hello" + }, + "name": "hello" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 17, + "end": 41, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 41 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 32, + "end": 39, + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 39 + } + }, + "expression": { + "type": "UpdateExpression", + "start": 32, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 38 + } + }, + "operator": "--", + "prefix": false, + "argument": { + "type": "Identifier", + "start": 32, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 36 + }, + "identifierName": "eval" + }, + "name": "eval" + } + } + } + ], + "directives": [ + { + "type": "Directive", + "start": 18, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 18, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "value": "use strict", + "extra": { + "raw": "'use strict'", + "rawValue": "use strict" + } + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/480/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/480/options.json deleted file mode 100644 index 2f502104f7d4..000000000000 --- a/packages/babel-parser/test/fixtures/core/uncategorised/480/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Assigning to 'arguments' in strict mode (1:32)" -} diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/480/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/480/output.json new file mode 100644 index 000000000000..64f2c09fd91e --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/uncategorised/480/output.json @@ -0,0 +1,176 @@ +{ + "type": "File", + "start": 0, + "end": 46, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 46 + } + }, + "errors": [ + "SyntaxError: Assigning to 'arguments' in strict mode (1:32)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 46, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 46 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 46, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 46 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 14 + }, + "identifierName": "hello" + }, + "name": "hello" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 17, + "end": 46, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 46 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 32, + "end": 44, + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 44 + } + }, + "expression": { + "type": "UpdateExpression", + "start": 32, + "end": 43, + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 43 + } + }, + "operator": "++", + "prefix": false, + "argument": { + "type": "Identifier", + "start": 32, + "end": 41, + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 41 + }, + "identifierName": "arguments" + }, + "name": "arguments" + } + } + } + ], + "directives": [ + { + "type": "Directive", + "start": 18, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 18, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "value": "use strict", + "extra": { + "raw": "'use strict'", + "rawValue": "use strict" + } + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/481/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/481/options.json deleted file mode 100644 index 2f502104f7d4..000000000000 --- a/packages/babel-parser/test/fixtures/core/uncategorised/481/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Assigning to 'arguments' in strict mode (1:32)" -} diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/481/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/481/output.json new file mode 100644 index 000000000000..34c1b59c4e79 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/uncategorised/481/output.json @@ -0,0 +1,176 @@ +{ + "type": "File", + "start": 0, + "end": 46, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 46 + } + }, + "errors": [ + "SyntaxError: Assigning to 'arguments' in strict mode (1:32)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 46, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 46 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 46, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 46 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 14 + }, + "identifierName": "hello" + }, + "name": "hello" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 17, + "end": 46, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 46 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 32, + "end": 44, + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 44 + } + }, + "expression": { + "type": "UpdateExpression", + "start": 32, + "end": 43, + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 43 + } + }, + "operator": "--", + "prefix": false, + "argument": { + "type": "Identifier", + "start": 32, + "end": 41, + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 41 + }, + "identifierName": "arguments" + }, + "name": "arguments" + } + } + } + ], + "directives": [ + { + "type": "Directive", + "start": 18, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 18, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "value": "use strict", + "extra": { + "raw": "'use strict'", + "rawValue": "use strict" + } + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/482/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/482/options.json deleted file mode 100644 index 439ffff53e89..000000000000 --- a/packages/babel-parser/test/fixtures/core/uncategorised/482/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Binding 'eval' in strict mode (1:41)" -} diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/482/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/482/output.json new file mode 100644 index 000000000000..35af060b7c6e --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/uncategorised/482/output.json @@ -0,0 +1,179 @@ +{ + "type": "File", + "start": 0, + "end": 53, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 53 + } + }, + "errors": [ + "SyntaxError: Binding 'eval' in strict mode (1:41)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 53, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 53 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 53, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 53 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 14 + }, + "identifierName": "hello" + }, + "name": "hello" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 17, + "end": 53, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 53 + } + }, + "body": [ + { + "type": "FunctionDeclaration", + "start": 32, + "end": 51, + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 51 + } + }, + "id": { + "type": "Identifier", + "start": 41, + "end": 45, + "loc": { + "start": { + "line": 1, + "column": 41 + }, + "end": { + "line": 1, + "column": 45 + }, + "identifierName": "eval" + }, + "name": "eval" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 48, + "end": 51, + "loc": { + "start": { + "line": 1, + "column": 48 + }, + "end": { + "line": 1, + "column": 51 + } + }, + "body": [], + "directives": [] + } + } + ], + "directives": [ + { + "type": "Directive", + "start": 18, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 18, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "value": "use strict", + "extra": { + "raw": "'use strict'", + "rawValue": "use strict" + } + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/483/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/483/options.json deleted file mode 100644 index ad15b27f9b9a..000000000000 --- a/packages/babel-parser/test/fixtures/core/uncategorised/483/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Binding 'arguments' in strict mode (1:41)" -} diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/483/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/483/output.json new file mode 100644 index 000000000000..7419ba446dc9 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/uncategorised/483/output.json @@ -0,0 +1,179 @@ +{ + "type": "File", + "start": 0, + "end": 58, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 58 + } + }, + "errors": [ + "SyntaxError: Binding 'arguments' in strict mode (1:41)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 58, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 58 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 58, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 58 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 14 + }, + "identifierName": "hello" + }, + "name": "hello" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 17, + "end": 58, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 58 + } + }, + "body": [ + { + "type": "FunctionDeclaration", + "start": 32, + "end": 56, + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 56 + } + }, + "id": { + "type": "Identifier", + "start": 41, + "end": 50, + "loc": { + "start": { + "line": 1, + "column": 41 + }, + "end": { + "line": 1, + "column": 50 + }, + "identifierName": "arguments" + }, + "name": "arguments" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 53, + "end": 56, + "loc": { + "start": { + "line": 1, + "column": 53 + }, + "end": { + "line": 1, + "column": 56 + } + }, + "body": [], + "directives": [] + } + } + ], + "directives": [ + { + "type": "Directive", + "start": 18, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 18, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "value": "use strict", + "extra": { + "raw": "'use strict'", + "rawValue": "use strict" + } + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/484/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/484/options.json deleted file mode 100644 index 1eb91299eb1b..000000000000 --- a/packages/babel-parser/test/fixtures/core/uncategorised/484/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Binding 'eval' in strict mode (1:9)" -} diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/484/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/484/output.json new file mode 100644 index 000000000000..ede15490b692 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/uncategorised/484/output.json @@ -0,0 +1,126 @@ +{ + "type": "File", + "start": 0, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "errors": [ + "SyntaxError: Binding 'eval' in strict mode (1:9)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 13 + }, + "identifierName": "eval" + }, + "name": "eval" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 16, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "body": [], + "directives": [ + { + "type": "Directive", + "start": 17, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 17, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "value": "use strict", + "extra": { + "raw": "'use strict'", + "rawValue": "use strict" + } + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/485/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/485/options.json deleted file mode 100644 index c903c1205ce8..000000000000 --- a/packages/babel-parser/test/fixtures/core/uncategorised/485/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Binding 'arguments' in strict mode (1:9)" -} diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/485/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/485/output.json new file mode 100644 index 000000000000..aeccd1a07ed9 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/uncategorised/485/output.json @@ -0,0 +1,126 @@ +{ + "type": "File", + "start": 0, + "end": 37, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 37 + } + }, + "errors": [ + "SyntaxError: Binding 'arguments' in strict mode (1:9)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 37, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 37 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 37, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 37 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 18 + }, + "identifierName": "arguments" + }, + "name": "arguments" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 21, + "end": 37, + "loc": { + "start": { + "line": 1, + "column": 21 + }, + "end": { + "line": 1, + "column": 37 + } + }, + "body": [], + "directives": [ + { + "type": "Directive", + "start": 22, + "end": 35, + "loc": { + "start": { + "line": 1, + "column": 22 + }, + "end": { + "line": 1, + "column": 35 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 22, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 22 + }, + "end": { + "line": 1, + "column": 34 + } + }, + "value": "use strict", + "extra": { + "raw": "'use strict'", + "rawValue": "use strict" + } + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/486/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/486/options.json deleted file mode 100644 index 884ab94e3403..000000000000 --- a/packages/babel-parser/test/fixtures/core/uncategorised/486/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Binding 'eval' in strict mode (1:42)" -} diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/486/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/486/output.json new file mode 100644 index 000000000000..4e8af9c85d04 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/uncategorised/486/output.json @@ -0,0 +1,214 @@ +{ + "type": "File", + "start": 0, + "end": 57, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 57 + } + }, + "errors": [ + "SyntaxError: Binding 'eval' in strict mode (1:42)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 57, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 57 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 57, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 57 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 14 + }, + "identifierName": "hello" + }, + "name": "hello" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 17, + "end": 57, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 57 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 32, + "end": 55, + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 55 + } + }, + "expression": { + "type": "CallExpression", + "start": 33, + "end": 54, + "loc": { + "start": { + "line": 1, + "column": 33 + }, + "end": { + "line": 1, + "column": 54 + } + }, + "callee": { + "type": "FunctionExpression", + "start": 33, + "end": 52, + "loc": { + "start": { + "line": 1, + "column": 33 + }, + "end": { + "line": 1, + "column": 52 + } + }, + "id": { + "type": "Identifier", + "start": 42, + "end": 46, + "loc": { + "start": { + "line": 1, + "column": 42 + }, + "end": { + "line": 1, + "column": 46 + }, + "identifierName": "eval" + }, + "name": "eval" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 49, + "end": 52, + "loc": { + "start": { + "line": 1, + "column": 49 + }, + "end": { + "line": 1, + "column": 52 + } + }, + "body": [], + "directives": [] + } + }, + "arguments": [], + "extra": { + "parenthesized": true, + "parenStart": 32 + } + } + } + ], + "directives": [ + { + "type": "Directive", + "start": 18, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 18, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "value": "use strict", + "extra": { + "raw": "'use strict'", + "rawValue": "use strict" + } + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/487/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/487/options.json deleted file mode 100644 index 58a98e4ca953..000000000000 --- a/packages/babel-parser/test/fixtures/core/uncategorised/487/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Binding 'arguments' in strict mode (1:42)" -} diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/487/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/487/output.json new file mode 100644 index 000000000000..49a2e0086f28 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/uncategorised/487/output.json @@ -0,0 +1,214 @@ +{ + "type": "File", + "start": 0, + "end": 62, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 62 + } + }, + "errors": [ + "SyntaxError: Binding 'arguments' in strict mode (1:42)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 62, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 62 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 62, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 62 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 14 + }, + "identifierName": "hello" + }, + "name": "hello" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 17, + "end": 62, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 62 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 32, + "end": 60, + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 60 + } + }, + "expression": { + "type": "CallExpression", + "start": 33, + "end": 59, + "loc": { + "start": { + "line": 1, + "column": 33 + }, + "end": { + "line": 1, + "column": 59 + } + }, + "callee": { + "type": "FunctionExpression", + "start": 33, + "end": 57, + "loc": { + "start": { + "line": 1, + "column": 33 + }, + "end": { + "line": 1, + "column": 57 + } + }, + "id": { + "type": "Identifier", + "start": 42, + "end": 51, + "loc": { + "start": { + "line": 1, + "column": 42 + }, + "end": { + "line": 1, + "column": 51 + }, + "identifierName": "arguments" + }, + "name": "arguments" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 54, + "end": 57, + "loc": { + "start": { + "line": 1, + "column": 54 + }, + "end": { + "line": 1, + "column": 57 + } + }, + "body": [], + "directives": [] + } + }, + "arguments": [], + "extra": { + "parenthesized": true, + "parenStart": 32 + } + } + } + ], + "directives": [ + { + "type": "Directive", + "start": 18, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 18, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "value": "use strict", + "extra": { + "raw": "'use strict'", + "rawValue": "use strict" + } + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/488/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/488/options.json deleted file mode 100644 index aa44c4aafa4d..000000000000 --- a/packages/babel-parser/test/fixtures/core/uncategorised/488/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Binding 'eval' in strict mode (1:10)" -} diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/488/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/488/output.json new file mode 100644 index 000000000000..6d1387258a3e --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/uncategorised/488/output.json @@ -0,0 +1,161 @@ +{ + "type": "File", + "start": 0, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "errors": [ + "SyntaxError: Binding 'eval' in strict mode (1:10)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "expression": { + "type": "CallExpression", + "start": 0, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "callee": { + "type": "FunctionExpression", + "start": 1, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 33 + } + }, + "id": { + "type": "Identifier", + "start": 10, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 14 + }, + "identifierName": "eval" + }, + "name": "eval" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 17, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 33 + } + }, + "body": [], + "directives": [ + { + "type": "Directive", + "start": 18, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 18, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "value": "use strict", + "extra": { + "raw": "'use strict'", + "rawValue": "use strict" + } + } + } + ] + }, + "extra": { + "parenthesized": true, + "parenStart": 0 + } + }, + "arguments": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/489/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/489/options.json deleted file mode 100644 index 59ccf8eb8209..000000000000 --- a/packages/babel-parser/test/fixtures/core/uncategorised/489/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Binding 'arguments' in strict mode (1:10)" -} diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/489/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/489/output.json new file mode 100644 index 000000000000..d3b5c3628386 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/uncategorised/489/output.json @@ -0,0 +1,161 @@ +{ + "type": "File", + "start": 0, + "end": 41, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 41 + } + }, + "errors": [ + "SyntaxError: Binding 'arguments' in strict mode (1:10)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 41, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 41 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 41, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 41 + } + }, + "expression": { + "type": "CallExpression", + "start": 0, + "end": 41, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 41 + } + }, + "callee": { + "type": "FunctionExpression", + "start": 1, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 38 + } + }, + "id": { + "type": "Identifier", + "start": 10, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 19 + }, + "identifierName": "arguments" + }, + "name": "arguments" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 22, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 22 + }, + "end": { + "line": 1, + "column": 38 + } + }, + "body": [], + "directives": [ + { + "type": "Directive", + "start": 23, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 23 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 23, + "end": 35, + "loc": { + "start": { + "line": 1, + "column": 23 + }, + "end": { + "line": 1, + "column": 35 + } + }, + "value": "use strict", + "extra": { + "raw": "'use strict'", + "rawValue": "use strict" + } + } + } + ] + }, + "extra": { + "parenthesized": true, + "parenStart": 0 + } + }, + "arguments": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/490/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/490/options.json deleted file mode 100644 index e95a2d7f7535..000000000000 --- a/packages/babel-parser/test/fixtures/core/uncategorised/490/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Binding 'eval' in strict mode (1:47)" -} diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/490/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/490/output.json new file mode 100644 index 000000000000..d0eb8e29b2a1 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/uncategorised/490/output.json @@ -0,0 +1,250 @@ +{ + "type": "File", + "start": 0, + "end": 63, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 63 + } + }, + "errors": [ + "SyntaxError: Binding 'eval' in strict mode (1:47)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 63, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 63 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 63, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 63 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 14 + }, + "identifierName": "hello" + }, + "name": "hello" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 17, + "end": 63, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 63 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 32, + "end": 61, + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 61 + } + }, + "expression": { + "type": "ObjectExpression", + "start": 33, + "end": 59, + "loc": { + "start": { + "line": 1, + "column": 33 + }, + "end": { + "line": 1, + "column": 59 + } + }, + "properties": [ + { + "type": "ObjectProperty", + "start": 35, + "end": 57, + "loc": { + "start": { + "line": 1, + "column": 35 + }, + "end": { + "line": 1, + "column": 57 + } + }, + "method": false, + "key": { + "type": "Identifier", + "start": 35, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 35 + }, + "end": { + "line": 1, + "column": 36 + }, + "identifierName": "s" + }, + "name": "s" + }, + "computed": false, + "shorthand": false, + "value": { + "type": "FunctionExpression", + "start": 38, + "end": 57, + "loc": { + "start": { + "line": 1, + "column": 38 + }, + "end": { + "line": 1, + "column": 57 + } + }, + "id": { + "type": "Identifier", + "start": 47, + "end": 51, + "loc": { + "start": { + "line": 1, + "column": 47 + }, + "end": { + "line": 1, + "column": 51 + }, + "identifierName": "eval" + }, + "name": "eval" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 54, + "end": 57, + "loc": { + "start": { + "line": 1, + "column": 54 + }, + "end": { + "line": 1, + "column": 57 + } + }, + "body": [], + "directives": [] + } + } + } + ], + "extra": { + "parenthesized": true, + "parenStart": 32 + } + } + } + ], + "directives": [ + { + "type": "Directive", + "start": 18, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 18, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "value": "use strict", + "extra": { + "raw": "'use strict'", + "rawValue": "use strict" + } + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/491/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/491/options.json deleted file mode 100644 index e29c7aee6091..000000000000 --- a/packages/babel-parser/test/fixtures/core/uncategorised/491/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Binding 'package' in strict mode (1:10)" -} diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/491/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/491/output.json new file mode 100644 index 000000000000..d6510094936e --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/uncategorised/491/output.json @@ -0,0 +1,161 @@ +{ + "type": "File", + "start": 0, + "end": 39, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 39 + } + }, + "errors": [ + "SyntaxError: Binding 'package' in strict mode (1:10)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 39, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 39 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 39, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 39 + } + }, + "expression": { + "type": "CallExpression", + "start": 0, + "end": 39, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 39 + } + }, + "callee": { + "type": "FunctionExpression", + "start": 1, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "id": { + "type": "Identifier", + "start": 10, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 17 + }, + "identifierName": "package" + }, + "name": "package" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 20, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 20 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "body": [], + "directives": [ + { + "type": "Directive", + "start": 21, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 21 + }, + "end": { + "line": 1, + "column": 34 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 21, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 21 + }, + "end": { + "line": 1, + "column": 33 + } + }, + "value": "use strict", + "extra": { + "raw": "'use strict'", + "rawValue": "use strict" + } + } + } + ] + }, + "extra": { + "parenthesized": true, + "parenStart": 0 + } + }, + "arguments": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/492/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/492/options.json deleted file mode 100644 index 43dc5662e1e5..000000000000 --- a/packages/babel-parser/test/fixtures/core/uncategorised/492/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Binding 'eval' in strict mode (1:48)" -} diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/492/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/492/output.json new file mode 100644 index 000000000000..98e096877880 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/uncategorised/492/output.json @@ -0,0 +1,292 @@ +{ + "type": "File", + "start": 0, + "end": 63, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 63 + } + }, + "errors": [ + "SyntaxError: Binding 'eval' in strict mode (1:48)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 63, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 63 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 63, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 63 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 14 + }, + "identifierName": "hello" + }, + "name": "hello" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 17, + "end": 63, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 63 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 32, + "end": 61, + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 61 + } + }, + "expression": { + "type": "ObjectExpression", + "start": 33, + "end": 59, + "loc": { + "start": { + "line": 1, + "column": 33 + }, + "end": { + "line": 1, + "column": 59 + } + }, + "properties": [ + { + "type": "ObjectProperty", + "start": 35, + "end": 40, + "loc": { + "start": { + "line": 1, + "column": 35 + }, + "end": { + "line": 1, + "column": 40 + } + }, + "method": false, + "key": { + "type": "Identifier", + "start": 35, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 35 + }, + "end": { + "line": 1, + "column": 36 + }, + "identifierName": "i" + }, + "name": "i" + }, + "computed": false, + "shorthand": false, + "value": { + "type": "NumericLiteral", + "start": 38, + "end": 40, + "loc": { + "start": { + "line": 1, + "column": 38 + }, + "end": { + "line": 1, + "column": 40 + } + }, + "extra": { + "rawValue": 10, + "raw": "10" + }, + "value": 10 + } + }, + { + "type": "ObjectMethod", + "start": 42, + "end": 57, + "loc": { + "start": { + "line": 1, + "column": 42 + }, + "end": { + "line": 1, + "column": 57 + } + }, + "method": false, + "key": { + "type": "Identifier", + "start": 46, + "end": 47, + "loc": { + "start": { + "line": 1, + "column": 46 + }, + "end": { + "line": 1, + "column": 47 + }, + "identifierName": "s" + }, + "name": "s" + }, + "computed": false, + "kind": "set", + "id": null, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "start": 48, + "end": 52, + "loc": { + "start": { + "line": 1, + "column": 48 + }, + "end": { + "line": 1, + "column": 52 + }, + "identifierName": "eval" + }, + "name": "eval" + } + ], + "body": { + "type": "BlockStatement", + "start": 54, + "end": 57, + "loc": { + "start": { + "line": 1, + "column": 54 + }, + "end": { + "line": 1, + "column": 57 + } + }, + "body": [], + "directives": [] + } + } + ], + "extra": { + "parenthesized": true, + "parenStart": 32 + } + } + } + ], + "directives": [ + { + "type": "Directive", + "start": 18, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 18, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "value": "use strict", + "extra": { + "raw": "'use strict'", + "rawValue": "use strict" + } + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/493/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/493/options.json deleted file mode 100644 index 439ffff53e89..000000000000 --- a/packages/babel-parser/test/fixtures/core/uncategorised/493/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Binding 'eval' in strict mode (1:41)" -} diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/493/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/493/output.json new file mode 100644 index 000000000000..f974d83f5a98 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/uncategorised/493/output.json @@ -0,0 +1,237 @@ +{ + "type": "File", + "start": 0, + "end": 56, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 56 + } + }, + "errors": [ + "SyntaxError: Binding 'eval' in strict mode (1:41)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 56, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 56 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 56, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 56 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 14 + }, + "identifierName": "hello" + }, + "name": "hello" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 17, + "end": 56, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 56 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 32, + "end": 54, + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 54 + } + }, + "expression": { + "type": "ObjectExpression", + "start": 33, + "end": 52, + "loc": { + "start": { + "line": 1, + "column": 33 + }, + "end": { + "line": 1, + "column": 52 + } + }, + "properties": [ + { + "type": "ObjectMethod", + "start": 35, + "end": 50, + "loc": { + "start": { + "line": 1, + "column": 35 + }, + "end": { + "line": 1, + "column": 50 + } + }, + "method": false, + "key": { + "type": "Identifier", + "start": 39, + "end": 40, + "loc": { + "start": { + "line": 1, + "column": 39 + }, + "end": { + "line": 1, + "column": 40 + }, + "identifierName": "s" + }, + "name": "s" + }, + "computed": false, + "kind": "set", + "id": null, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "start": 41, + "end": 45, + "loc": { + "start": { + "line": 1, + "column": 41 + }, + "end": { + "line": 1, + "column": 45 + }, + "identifierName": "eval" + }, + "name": "eval" + } + ], + "body": { + "type": "BlockStatement", + "start": 47, + "end": 50, + "loc": { + "start": { + "line": 1, + "column": 47 + }, + "end": { + "line": 1, + "column": 50 + } + }, + "body": [], + "directives": [] + } + } + ], + "extra": { + "parenthesized": true, + "parenStart": 32 + } + } + } + ], + "directives": [ + { + "type": "Directive", + "start": 18, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 18, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "value": "use strict", + "extra": { + "raw": "'use strict'", + "rawValue": "use strict" + } + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/494/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/494/options.json deleted file mode 100644 index 8b18a4ec3e5a..000000000000 --- a/packages/babel-parser/test/fixtures/core/uncategorised/494/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Binding 'eval' in strict mode (1:49)" -} diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/494/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/494/output.json new file mode 100644 index 000000000000..2993cf648835 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/uncategorised/494/output.json @@ -0,0 +1,268 @@ +{ + "type": "File", + "start": 0, + "end": 64, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 64 + } + }, + "errors": [ + "SyntaxError: Binding 'eval' in strict mode (1:49)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 64, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 64 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 64, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 64 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 14 + }, + "identifierName": "hello" + }, + "name": "hello" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 17, + "end": 64, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 64 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 32, + "end": 62, + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 62 + } + }, + "expression": { + "type": "ObjectExpression", + "start": 33, + "end": 60, + "loc": { + "start": { + "line": 1, + "column": 33 + }, + "end": { + "line": 1, + "column": 60 + } + }, + "properties": [ + { + "type": "ObjectProperty", + "start": 35, + "end": 58, + "loc": { + "start": { + "line": 1, + "column": 35 + }, + "end": { + "line": 1, + "column": 58 + } + }, + "method": false, + "key": { + "type": "Identifier", + "start": 35, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 35 + }, + "end": { + "line": 1, + "column": 36 + }, + "identifierName": "s" + }, + "name": "s" + }, + "computed": false, + "shorthand": false, + "value": { + "type": "FunctionExpression", + "start": 38, + "end": 58, + "loc": { + "start": { + "line": 1, + "column": 38 + }, + "end": { + "line": 1, + "column": 58 + } + }, + "id": { + "type": "Identifier", + "start": 47, + "end": 48, + "loc": { + "start": { + "line": 1, + "column": 47 + }, + "end": { + "line": 1, + "column": 48 + }, + "identifierName": "s" + }, + "name": "s" + }, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "start": 49, + "end": 53, + "loc": { + "start": { + "line": 1, + "column": 49 + }, + "end": { + "line": 1, + "column": 53 + }, + "identifierName": "eval" + }, + "name": "eval" + } + ], + "body": { + "type": "BlockStatement", + "start": 55, + "end": 58, + "loc": { + "start": { + "line": 1, + "column": 55 + }, + "end": { + "line": 1, + "column": 58 + } + }, + "body": [], + "directives": [] + } + } + } + ], + "extra": { + "parenthesized": true, + "parenStart": 32 + } + } + } + ], + "directives": [ + { + "type": "Directive", + "start": 18, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 18, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "value": "use strict", + "extra": { + "raw": "'use strict'", + "rawValue": "use strict" + } + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/495/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/495/options.json deleted file mode 100644 index 794c4864d4e5..000000000000 --- a/packages/babel-parser/test/fixtures/core/uncategorised/495/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Binding 'eval' in strict mode (1:15)" -} diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/495/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/495/output.json new file mode 100644 index 000000000000..4534376b270a --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/uncategorised/495/output.json @@ -0,0 +1,144 @@ +{ + "type": "File", + "start": 0, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "errors": [ + "SyntaxError: Binding 'eval' in strict mode (1:15)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 14 + }, + "identifierName": "hello" + }, + "name": "hello" + }, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "start": 15, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 19 + }, + "identifierName": "eval" + }, + "name": "eval" + } + ], + "body": { + "type": "BlockStatement", + "start": 21, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 21 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "body": [], + "directives": [ + { + "type": "Directive", + "start": 22, + "end": 35, + "loc": { + "start": { + "line": 1, + "column": 22 + }, + "end": { + "line": 1, + "column": 35 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 22, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 22 + }, + "end": { + "line": 1, + "column": 34 + } + }, + "value": "use strict", + "extra": { + "raw": "'use strict'", + "rawValue": "use strict" + } + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/496/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/496/options.json deleted file mode 100644 index 212d35fcb5fe..000000000000 --- a/packages/babel-parser/test/fixtures/core/uncategorised/496/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Binding 'arguments' in strict mode (1:15)" -} diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/496/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/496/output.json new file mode 100644 index 000000000000..cb41c2783446 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/uncategorised/496/output.json @@ -0,0 +1,144 @@ +{ + "type": "File", + "start": 0, + "end": 41, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 41 + } + }, + "errors": [ + "SyntaxError: Binding 'arguments' in strict mode (1:15)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 41, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 41 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 41, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 41 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 14 + }, + "identifierName": "hello" + }, + "name": "hello" + }, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "start": 15, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 24 + }, + "identifierName": "arguments" + }, + "name": "arguments" + } + ], + "body": { + "type": "BlockStatement", + "start": 26, + "end": 41, + "loc": { + "start": { + "line": 1, + "column": 26 + }, + "end": { + "line": 1, + "column": 41 + } + }, + "body": [], + "directives": [ + { + "type": "Directive", + "start": 27, + "end": 40, + "loc": { + "start": { + "line": 1, + "column": 27 + }, + "end": { + "line": 1, + "column": 40 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 27, + "end": 39, + "loc": { + "start": { + "line": 1, + "column": 27 + }, + "end": { + "line": 1, + "column": 39 + } + }, + "value": "use strict", + "extra": { + "raw": "'use strict'", + "rawValue": "use strict" + } + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/497/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/497/options.json deleted file mode 100644 index 43dc5662e1e5..000000000000 --- a/packages/babel-parser/test/fixtures/core/uncategorised/497/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Binding 'eval' in strict mode (1:48)" -} diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/497/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/497/output.json new file mode 100644 index 000000000000..d8df2c1c2d07 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/uncategorised/497/output.json @@ -0,0 +1,197 @@ +{ + "type": "File", + "start": 0, + "end": 58, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 58 + } + }, + "errors": [ + "SyntaxError: Binding 'eval' in strict mode (1:48)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 58, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 58 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 58, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 58 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 14 + }, + "identifierName": "hello" + }, + "name": "hello" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 17, + "end": 58, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 58 + } + }, + "body": [ + { + "type": "FunctionDeclaration", + "start": 33, + "end": 56, + "loc": { + "start": { + "line": 1, + "column": 33 + }, + "end": { + "line": 1, + "column": 56 + } + }, + "id": { + "type": "Identifier", + "start": 42, + "end": 47, + "loc": { + "start": { + "line": 1, + "column": 42 + }, + "end": { + "line": 1, + "column": 47 + }, + "identifierName": "inner" + }, + "name": "inner" + }, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "start": 48, + "end": 52, + "loc": { + "start": { + "line": 1, + "column": 48 + }, + "end": { + "line": 1, + "column": 52 + }, + "identifierName": "eval" + }, + "name": "eval" + } + ], + "body": { + "type": "BlockStatement", + "start": 54, + "end": 56, + "loc": { + "start": { + "line": 1, + "column": 54 + }, + "end": { + "line": 1, + "column": 56 + } + }, + "body": [], + "directives": [] + } + } + ], + "directives": [ + { + "type": "Directive", + "start": 19, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 19, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "value": "use strict", + "extra": { + "raw": "'use strict'", + "rawValue": "use strict" + } + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/498/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/498/options.json deleted file mode 100644 index 8370ba5c765f..000000000000 --- a/packages/babel-parser/test/fixtures/core/uncategorised/498/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Binding 'arguments' in strict mode (1:48)" -} diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/498/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/498/output.json new file mode 100644 index 000000000000..a2fc6cb4db0e --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/uncategorised/498/output.json @@ -0,0 +1,197 @@ +{ + "type": "File", + "start": 0, + "end": 63, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 63 + } + }, + "errors": [ + "SyntaxError: Binding 'arguments' in strict mode (1:48)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 63, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 63 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 63, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 63 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 14 + }, + "identifierName": "hello" + }, + "name": "hello" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 17, + "end": 63, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 63 + } + }, + "body": [ + { + "type": "FunctionDeclaration", + "start": 33, + "end": 61, + "loc": { + "start": { + "line": 1, + "column": 33 + }, + "end": { + "line": 1, + "column": 61 + } + }, + "id": { + "type": "Identifier", + "start": 42, + "end": 47, + "loc": { + "start": { + "line": 1, + "column": 42 + }, + "end": { + "line": 1, + "column": 47 + }, + "identifierName": "inner" + }, + "name": "inner" + }, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "start": 48, + "end": 57, + "loc": { + "start": { + "line": 1, + "column": 48 + }, + "end": { + "line": 1, + "column": 57 + }, + "identifierName": "arguments" + }, + "name": "arguments" + } + ], + "body": { + "type": "BlockStatement", + "start": 59, + "end": 61, + "loc": { + "start": { + "line": 1, + "column": 59 + }, + "end": { + "line": 1, + "column": 61 + } + }, + "body": [], + "directives": [] + } + } + ], + "directives": [ + { + "type": "Directive", + "start": 19, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 19, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "value": "use strict", + "extra": { + "raw": "'use strict'", + "rawValue": "use strict" + } + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/499/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/499/options.json deleted file mode 100644 index ae2bfab55c68..000000000000 --- a/packages/babel-parser/test/fixtures/core/uncategorised/499/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Octal literal in strict mode (1:35)" -} diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/499/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/499/output.json new file mode 100644 index 000000000000..1504ace4ac5d --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/uncategorised/499/output.json @@ -0,0 +1,162 @@ +{ + "type": "File", + "start": 0, + "end": 40, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 40 + } + }, + "errors": [ + "SyntaxError: Octal literal in strict mode (1:35)", + "SyntaxError: Octal literal in strict mode (1:35)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 40, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 40 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 40, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 40 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 14 + }, + "identifierName": "hello" + }, + "name": "hello" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 17, + "end": 40, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 40 + } + }, + "body": [], + "directives": [ + { + "type": "Directive", + "start": 19, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 19, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "value": "use strict", + "extra": { + "raw": "'use strict'", + "rawValue": "use strict" + } + } + }, + { + "type": "Directive", + "start": 33, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 33 + }, + "end": { + "line": 1, + "column": 38 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 33, + "end": 37, + "loc": { + "start": { + "line": 1, + "column": 33 + }, + "end": { + "line": 1, + "column": 37 + } + }, + "value": "\\1", + "extra": { + "raw": "\"\\1\"", + "rawValue": "\\1" + } + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/500/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/500/options.json deleted file mode 100644 index 45ca229c1e8e..000000000000 --- a/packages/babel-parser/test/fixtures/core/uncategorised/500/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Legacy octal literals are not allowed in strict mode (1:33)" -} diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/500/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/500/output.json new file mode 100644 index 000000000000..805c176e7856 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/uncategorised/500/output.json @@ -0,0 +1,163 @@ +{ + "type": "File", + "start": 0, + "end": 39, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 39 + } + }, + "errors": [ + "SyntaxError: Legacy octal literals are not allowed in strict mode (1:33)", + "SyntaxError: Legacy octal literals are not allowed in strict mode (1:33)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 39, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 39 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 39, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 39 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 14 + }, + "identifierName": "hello" + }, + "name": "hello" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 17, + "end": 39, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 39 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 33, + "end": 37, + "loc": { + "start": { + "line": 1, + "column": 33 + }, + "end": { + "line": 1, + "column": 37 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 33, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 33 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "extra": { + "rawValue": 17, + "raw": "021" + }, + "value": 17 + } + } + ], + "directives": [ + { + "type": "Directive", + "start": 19, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 19, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "value": "use strict", + "extra": { + "raw": "'use strict'", + "rawValue": "use strict" + } + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/501/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/501/options.json deleted file mode 100644 index 7e50b5f9165e..000000000000 --- a/packages/babel-parser/test/fixtures/core/uncategorised/501/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Octal literal in strict mode (1:38)" -} diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/501/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/501/output.json new file mode 100644 index 000000000000..f73cb42cd9cf --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/uncategorised/501/output.json @@ -0,0 +1,221 @@ +{ + "type": "File", + "start": 0, + "end": 50, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 50 + } + }, + "errors": [ + "SyntaxError: Octal literal in strict mode (1:38)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 50, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 50 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 50, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 50 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 14 + }, + "identifierName": "hello" + }, + "name": "hello" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 17, + "end": 50, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 50 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 33, + "end": 48, + "loc": { + "start": { + "line": 1, + "column": 33 + }, + "end": { + "line": 1, + "column": 48 + } + }, + "expression": { + "type": "ObjectExpression", + "start": 34, + "end": 46, + "loc": { + "start": { + "line": 1, + "column": 34 + }, + "end": { + "line": 1, + "column": 46 + } + }, + "properties": [ + { + "type": "ObjectProperty", + "start": 36, + "end": 44, + "loc": { + "start": { + "line": 1, + "column": 36 + }, + "end": { + "line": 1, + "column": 44 + } + }, + "method": false, + "key": { + "type": "StringLiteral", + "start": 36, + "end": 40, + "loc": { + "start": { + "line": 1, + "column": 36 + }, + "end": { + "line": 1, + "column": 40 + } + }, + "extra": { + "rawValue": "\u0001", + "raw": "\"\\1\"" + }, + "value": "\u0001" + }, + "computed": false, + "shorthand": false, + "value": { + "type": "NumericLiteral", + "start": 42, + "end": 44, + "loc": { + "start": { + "line": 1, + "column": 42 + }, + "end": { + "line": 1, + "column": 44 + } + }, + "extra": { + "rawValue": 42, + "raw": "42" + }, + "value": 42 + } + } + ], + "extra": { + "parenthesized": true, + "parenStart": 33 + } + } + } + ], + "directives": [ + { + "type": "Directive", + "start": 19, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 19, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "value": "use strict", + "extra": { + "raw": "'use strict'", + "rawValue": "use strict" + } + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/502/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/502/options.json deleted file mode 100644 index 8f6c8218f747..000000000000 --- a/packages/babel-parser/test/fixtures/core/uncategorised/502/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Legacy octal literals are not allowed in strict mode (1:36)" -} diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/502/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/502/output.json new file mode 100644 index 000000000000..5eb3bcef0b18 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/uncategorised/502/output.json @@ -0,0 +1,221 @@ +{ + "type": "File", + "start": 0, + "end": 49, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 49 + } + }, + "errors": [ + "SyntaxError: Legacy octal literals are not allowed in strict mode (1:36)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 49, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 49 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 49, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 49 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 14 + }, + "identifierName": "hello" + }, + "name": "hello" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 17, + "end": 49, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 49 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 33, + "end": 47, + "loc": { + "start": { + "line": 1, + "column": 33 + }, + "end": { + "line": 1, + "column": 47 + } + }, + "expression": { + "type": "ObjectExpression", + "start": 34, + "end": 45, + "loc": { + "start": { + "line": 1, + "column": 34 + }, + "end": { + "line": 1, + "column": 45 + } + }, + "properties": [ + { + "type": "ObjectProperty", + "start": 36, + "end": 43, + "loc": { + "start": { + "line": 1, + "column": 36 + }, + "end": { + "line": 1, + "column": 43 + } + }, + "method": false, + "key": { + "type": "NumericLiteral", + "start": 36, + "end": 39, + "loc": { + "start": { + "line": 1, + "column": 36 + }, + "end": { + "line": 1, + "column": 39 + } + }, + "extra": { + "rawValue": 17, + "raw": "021" + }, + "value": 17 + }, + "computed": false, + "shorthand": false, + "value": { + "type": "NumericLiteral", + "start": 41, + "end": 43, + "loc": { + "start": { + "line": 1, + "column": 41 + }, + "end": { + "line": 1, + "column": 43 + } + }, + "extra": { + "rawValue": 42, + "raw": "42" + }, + "value": 42 + } + } + ], + "extra": { + "parenthesized": true, + "parenStart": 33 + } + } + } + ], + "directives": [ + { + "type": "Directive", + "start": 19, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 19, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "value": "use strict", + "extra": { + "raw": "'use strict'", + "rawValue": "use strict" + } + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/503/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/503/options.json deleted file mode 100644 index 8389b2c726ca..000000000000 --- a/packages/babel-parser/test/fixtures/core/uncategorised/503/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Octal literal in strict mode (1:69)" -} diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/503/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/503/output.json new file mode 100644 index 000000000000..e52fa38ccf73 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/uncategorised/503/output.json @@ -0,0 +1,215 @@ +{ + "type": "File", + "start": 0, + "end": 76, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 76 + } + }, + "errors": [ + "SyntaxError: Octal literal in strict mode (1:69)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 76, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 76 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 76, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 76 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 14 + }, + "identifierName": "hello" + }, + "name": "hello" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 17, + "end": 76, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 76 + } + }, + "body": [ + { + "type": "FunctionDeclaration", + "start": 33, + "end": 74, + "loc": { + "start": { + "line": 1, + "column": 33 + }, + "end": { + "line": 1, + "column": 74 + } + }, + "id": { + "type": "Identifier", + "start": 42, + "end": 47, + "loc": { + "start": { + "line": 1, + "column": 42 + }, + "end": { + "line": 1, + "column": 47 + }, + "identifierName": "inner" + }, + "name": "inner" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 50, + "end": 74, + "loc": { + "start": { + "line": 1, + "column": 50 + }, + "end": { + "line": 1, + "column": 74 + } + }, + "body": [], + "directives": [ + { + "type": "Directive", + "start": 52, + "end": 72, + "loc": { + "start": { + "line": 1, + "column": 52 + }, + "end": { + "line": 1, + "column": 72 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 52, + "end": 71, + "loc": { + "start": { + "line": 1, + "column": 52 + }, + "end": { + "line": 1, + "column": 71 + } + }, + "value": "octal directive\\1", + "extra": { + "raw": "\"octal directive\\1\"", + "rawValue": "octal directive\\1" + } + } + } + ] + } + } + ], + "directives": [ + { + "type": "Directive", + "start": 19, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 19, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "value": "use strict", + "extra": { + "raw": "\"use strict\"", + "rawValue": "use strict" + } + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/504/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/504/options.json deleted file mode 100644 index 0641de45e29a..000000000000 --- a/packages/babel-parser/test/fixtures/core/uncategorised/504/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Unexpected reserved word 'implements' (1:37)" -} diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/504/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/504/output.json new file mode 100644 index 000000000000..2201ea3de8c6 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/uncategorised/504/output.json @@ -0,0 +1,178 @@ +{ + "type": "File", + "start": 0, + "end": 50, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 50 + } + }, + "errors": [ + "SyntaxError: Unexpected reserved word 'implements' (1:37)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 50, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 50 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 50, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 50 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 14 + }, + "identifierName": "hello" + }, + "name": "hello" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 17, + "end": 50, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 50 + } + }, + "body": [ + { + "type": "VariableDeclaration", + "start": 33, + "end": 48, + "loc": { + "start": { + "line": 1, + "column": 33 + }, + "end": { + "line": 1, + "column": 48 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 37, + "end": 47, + "loc": { + "start": { + "line": 1, + "column": 37 + }, + "end": { + "line": 1, + "column": 47 + } + }, + "id": { + "type": "Identifier", + "start": 37, + "end": 47, + "loc": { + "start": { + "line": 1, + "column": 37 + }, + "end": { + "line": 1, + "column": 47 + }, + "identifierName": "implements" + }, + "name": "implements" + }, + "init": null + } + ], + "kind": "var" + } + ], + "directives": [ + { + "type": "Directive", + "start": 19, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 19, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "value": "use strict", + "extra": { + "raw": "\"use strict\"", + "rawValue": "use strict" + } + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/505/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/505/options.json deleted file mode 100644 index 859238d0423f..000000000000 --- a/packages/babel-parser/test/fixtures/core/uncategorised/505/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Unexpected reserved word 'interface' (1:37)" -} diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/505/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/505/output.json new file mode 100644 index 000000000000..be76deabc7a1 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/uncategorised/505/output.json @@ -0,0 +1,178 @@ +{ + "type": "File", + "start": 0, + "end": 49, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 49 + } + }, + "errors": [ + "SyntaxError: Unexpected reserved word 'interface' (1:37)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 49, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 49 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 49, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 49 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 14 + }, + "identifierName": "hello" + }, + "name": "hello" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 17, + "end": 49, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 49 + } + }, + "body": [ + { + "type": "VariableDeclaration", + "start": 33, + "end": 47, + "loc": { + "start": { + "line": 1, + "column": 33 + }, + "end": { + "line": 1, + "column": 47 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 37, + "end": 46, + "loc": { + "start": { + "line": 1, + "column": 37 + }, + "end": { + "line": 1, + "column": 46 + } + }, + "id": { + "type": "Identifier", + "start": 37, + "end": 46, + "loc": { + "start": { + "line": 1, + "column": 37 + }, + "end": { + "line": 1, + "column": 46 + }, + "identifierName": "interface" + }, + "name": "interface" + }, + "init": null + } + ], + "kind": "var" + } + ], + "directives": [ + { + "type": "Directive", + "start": 19, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 19, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "value": "use strict", + "extra": { + "raw": "\"use strict\"", + "rawValue": "use strict" + } + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/506/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/506/options.json deleted file mode 100644 index 344c7075f4bf..000000000000 --- a/packages/babel-parser/test/fixtures/core/uncategorised/506/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Unexpected reserved word 'package' (1:37)" -} diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/506/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/506/output.json new file mode 100644 index 000000000000..414e229fac38 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/uncategorised/506/output.json @@ -0,0 +1,178 @@ +{ + "type": "File", + "start": 0, + "end": 47, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 47 + } + }, + "errors": [ + "SyntaxError: Unexpected reserved word 'package' (1:37)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 47, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 47 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 47, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 47 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 14 + }, + "identifierName": "hello" + }, + "name": "hello" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 17, + "end": 47, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 47 + } + }, + "body": [ + { + "type": "VariableDeclaration", + "start": 33, + "end": 45, + "loc": { + "start": { + "line": 1, + "column": 33 + }, + "end": { + "line": 1, + "column": 45 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 37, + "end": 44, + "loc": { + "start": { + "line": 1, + "column": 37 + }, + "end": { + "line": 1, + "column": 44 + } + }, + "id": { + "type": "Identifier", + "start": 37, + "end": 44, + "loc": { + "start": { + "line": 1, + "column": 37 + }, + "end": { + "line": 1, + "column": 44 + }, + "identifierName": "package" + }, + "name": "package" + }, + "init": null + } + ], + "kind": "var" + } + ], + "directives": [ + { + "type": "Directive", + "start": 19, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 19, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "value": "use strict", + "extra": { + "raw": "\"use strict\"", + "rawValue": "use strict" + } + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/507/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/507/options.json deleted file mode 100644 index 9fb9deaf9cba..000000000000 --- a/packages/babel-parser/test/fixtures/core/uncategorised/507/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Unexpected reserved word 'private' (1:37)" -} diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/507/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/507/output.json new file mode 100644 index 000000000000..32efcd46a632 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/uncategorised/507/output.json @@ -0,0 +1,178 @@ +{ + "type": "File", + "start": 0, + "end": 47, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 47 + } + }, + "errors": [ + "SyntaxError: Unexpected reserved word 'private' (1:37)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 47, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 47 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 47, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 47 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 14 + }, + "identifierName": "hello" + }, + "name": "hello" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 17, + "end": 47, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 47 + } + }, + "body": [ + { + "type": "VariableDeclaration", + "start": 33, + "end": 45, + "loc": { + "start": { + "line": 1, + "column": 33 + }, + "end": { + "line": 1, + "column": 45 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 37, + "end": 44, + "loc": { + "start": { + "line": 1, + "column": 37 + }, + "end": { + "line": 1, + "column": 44 + } + }, + "id": { + "type": "Identifier", + "start": 37, + "end": 44, + "loc": { + "start": { + "line": 1, + "column": 37 + }, + "end": { + "line": 1, + "column": 44 + }, + "identifierName": "private" + }, + "name": "private" + }, + "init": null + } + ], + "kind": "var" + } + ], + "directives": [ + { + "type": "Directive", + "start": 19, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 19, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "value": "use strict", + "extra": { + "raw": "\"use strict\"", + "rawValue": "use strict" + } + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/508/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/508/options.json deleted file mode 100644 index 292fb56f1cf3..000000000000 --- a/packages/babel-parser/test/fixtures/core/uncategorised/508/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Unexpected reserved word 'protected' (1:37)" -} diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/508/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/508/output.json new file mode 100644 index 000000000000..e3d3f255c253 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/uncategorised/508/output.json @@ -0,0 +1,178 @@ +{ + "type": "File", + "start": 0, + "end": 49, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 49 + } + }, + "errors": [ + "SyntaxError: Unexpected reserved word 'protected' (1:37)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 49, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 49 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 49, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 49 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 14 + }, + "identifierName": "hello" + }, + "name": "hello" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 17, + "end": 49, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 49 + } + }, + "body": [ + { + "type": "VariableDeclaration", + "start": 33, + "end": 47, + "loc": { + "start": { + "line": 1, + "column": 33 + }, + "end": { + "line": 1, + "column": 47 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 37, + "end": 46, + "loc": { + "start": { + "line": 1, + "column": 37 + }, + "end": { + "line": 1, + "column": 46 + } + }, + "id": { + "type": "Identifier", + "start": 37, + "end": 46, + "loc": { + "start": { + "line": 1, + "column": 37 + }, + "end": { + "line": 1, + "column": 46 + }, + "identifierName": "protected" + }, + "name": "protected" + }, + "init": null + } + ], + "kind": "var" + } + ], + "directives": [ + { + "type": "Directive", + "start": 19, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 19, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "value": "use strict", + "extra": { + "raw": "\"use strict\"", + "rawValue": "use strict" + } + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/509/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/509/options.json deleted file mode 100644 index d5f48446906a..000000000000 --- a/packages/babel-parser/test/fixtures/core/uncategorised/509/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Unexpected reserved word 'public' (1:37)" -} diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/509/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/509/output.json new file mode 100644 index 000000000000..2e801038c78d --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/uncategorised/509/output.json @@ -0,0 +1,178 @@ +{ + "type": "File", + "start": 0, + "end": 46, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 46 + } + }, + "errors": [ + "SyntaxError: Unexpected reserved word 'public' (1:37)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 46, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 46 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 46, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 46 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 14 + }, + "identifierName": "hello" + }, + "name": "hello" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 17, + "end": 46, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 46 + } + }, + "body": [ + { + "type": "VariableDeclaration", + "start": 33, + "end": 44, + "loc": { + "start": { + "line": 1, + "column": 33 + }, + "end": { + "line": 1, + "column": 44 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 37, + "end": 43, + "loc": { + "start": { + "line": 1, + "column": 37 + }, + "end": { + "line": 1, + "column": 43 + } + }, + "id": { + "type": "Identifier", + "start": 37, + "end": 43, + "loc": { + "start": { + "line": 1, + "column": 37 + }, + "end": { + "line": 1, + "column": 43 + }, + "identifierName": "public" + }, + "name": "public" + }, + "init": null + } + ], + "kind": "var" + } + ], + "directives": [ + { + "type": "Directive", + "start": 19, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 19, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "value": "use strict", + "extra": { + "raw": "\"use strict\"", + "rawValue": "use strict" + } + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/510/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/510/options.json deleted file mode 100644 index 0f41ff2e6f24..000000000000 --- a/packages/babel-parser/test/fixtures/core/uncategorised/510/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Unexpected reserved word 'static' (1:37)" -} diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/510/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/510/output.json new file mode 100644 index 000000000000..4ed420518d6d --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/uncategorised/510/output.json @@ -0,0 +1,178 @@ +{ + "type": "File", + "start": 0, + "end": 46, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 46 + } + }, + "errors": [ + "SyntaxError: Unexpected reserved word 'static' (1:37)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 46, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 46 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 46, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 46 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 14 + }, + "identifierName": "hello" + }, + "name": "hello" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 17, + "end": 46, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 46 + } + }, + "body": [ + { + "type": "VariableDeclaration", + "start": 33, + "end": 44, + "loc": { + "start": { + "line": 1, + "column": 33 + }, + "end": { + "line": 1, + "column": 44 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 37, + "end": 43, + "loc": { + "start": { + "line": 1, + "column": 37 + }, + "end": { + "line": 1, + "column": 43 + } + }, + "id": { + "type": "Identifier", + "start": 37, + "end": 43, + "loc": { + "start": { + "line": 1, + "column": 37 + }, + "end": { + "line": 1, + "column": 43 + }, + "identifierName": "static" + }, + "name": "static" + }, + "init": null + } + ], + "kind": "var" + } + ], + "directives": [ + { + "type": "Directive", + "start": 19, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 19, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "value": "use strict", + "extra": { + "raw": "\"use strict\"", + "rawValue": "use strict" + } + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/511/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/511/options.json deleted file mode 100644 index 78c799ec6a49..000000000000 --- a/packages/babel-parser/test/fixtures/core/uncategorised/511/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Binding 'static' in strict mode (1:15)" -} diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/511/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/511/output.json new file mode 100644 index 000000000000..ab669586dc27 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/uncategorised/511/output.json @@ -0,0 +1,144 @@ +{ + "type": "File", + "start": 0, + "end": 40, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 40 + } + }, + "errors": [ + "SyntaxError: Binding 'static' in strict mode (1:15)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 40, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 40 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 40, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 40 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 14 + }, + "identifierName": "hello" + }, + "name": "hello" + }, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "start": 15, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 21 + }, + "identifierName": "static" + }, + "name": "static" + } + ], + "body": { + "type": "BlockStatement", + "start": 23, + "end": 40, + "loc": { + "start": { + "line": 1, + "column": 23 + }, + "end": { + "line": 1, + "column": 40 + } + }, + "body": [], + "directives": [ + { + "type": "Directive", + "start": 25, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 25 + }, + "end": { + "line": 1, + "column": 38 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 25, + "end": 37, + "loc": { + "start": { + "line": 1, + "column": 25 + }, + "end": { + "line": 1, + "column": 37 + } + }, + "value": "use strict", + "extra": { + "raw": "\"use strict\"", + "rawValue": "use strict" + } + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/512/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/512/options.json deleted file mode 100644 index d4a2d92e5b45..000000000000 --- a/packages/babel-parser/test/fixtures/core/uncategorised/512/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Binding 'static' in strict mode (1:9)" -} diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/512/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/512/output.json new file mode 100644 index 000000000000..be76a2099b54 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/uncategorised/512/output.json @@ -0,0 +1,126 @@ +{ + "type": "File", + "start": 0, + "end": 35, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 35 + } + }, + "errors": [ + "SyntaxError: Binding 'static' in strict mode (1:9)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 35, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 35 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 35, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 35 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 15 + }, + "identifierName": "static" + }, + "name": "static" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 18, + "end": 35, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 35 + } + }, + "body": [], + "directives": [ + { + "type": "Directive", + "start": 20, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 20 + }, + "end": { + "line": 1, + "column": 33 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 20, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 20 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "value": "use strict", + "extra": { + "raw": "\"use strict\"", + "rawValue": "use strict" + } + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/513/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/513/options.json deleted file mode 100644 index 91bc36d3f360..000000000000 --- a/packages/babel-parser/test/fixtures/core/uncategorised/513/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Unexpected reserved word 'static' (1:23)" -} diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/513/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/513/output.json new file mode 100644 index 000000000000..c249f39209bf --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/uncategorised/513/output.json @@ -0,0 +1,126 @@ +{ + "type": "File", + "start": 0, + "end": 35, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 35 + } + }, + "errors": [ + "SyntaxError: Unexpected reserved word 'static' (1:23)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 35, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 35 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 14, + "end": 35, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 35 + } + }, + "id": { + "type": "Identifier", + "start": 23, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 23 + }, + "end": { + "line": 1, + "column": 29 + }, + "identifierName": "static" + }, + "name": "static" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 32, + "end": 35, + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 35 + } + }, + "body": [], + "directives": [] + } + } + ], + "directives": [ + { + "type": "Directive", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 0, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "value": "use strict", + "extra": { + "raw": "\"use strict\"", + "rawValue": "use strict" + } + } + } + ] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/514/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/514/options.json deleted file mode 100644 index 8b20b9a7df36..000000000000 --- a/packages/babel-parser/test/fixtures/core/uncategorised/514/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Argument name clash (1:14)" -} diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/514/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/514/output.json new file mode 100644 index 000000000000..f945eeb57491 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/uncategorised/514/output.json @@ -0,0 +1,161 @@ +{ + "type": "File", + "start": 0, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 34 + } + }, + "errors": [ + "SyntaxError: Argument name clash (1:14)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 34 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 34 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 10 + }, + "identifierName": "a" + }, + "name": "a" + }, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "start": 11, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 12 + }, + "identifierName": "t" + }, + "name": "t" + }, + { + "type": "Identifier", + "start": 14, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 15 + }, + "identifierName": "t" + }, + "name": "t" + } + ], + "body": { + "type": "BlockStatement", + "start": 17, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 34 + } + }, + "body": [], + "directives": [ + { + "type": "Directive", + "start": 19, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 19, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "value": "use strict", + "extra": { + "raw": "\"use strict\"", + "rawValue": "use strict" + } + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/515/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/515/options.json deleted file mode 100644 index 85fd3822f433..000000000000 --- a/packages/babel-parser/test/fixtures/core/uncategorised/515/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Binding 'eval' in strict mode (1:11)" -} diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/515/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/515/output.json new file mode 100644 index 000000000000..f2ff5d38de33 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/uncategorised/515/output.json @@ -0,0 +1,144 @@ +{ + "type": "File", + "start": 0, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 34 + } + }, + "errors": [ + "SyntaxError: Binding 'eval' in strict mode (1:11)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 34 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 34 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 10 + }, + "identifierName": "a" + }, + "name": "a" + }, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "start": 11, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 15 + }, + "identifierName": "eval" + }, + "name": "eval" + } + ], + "body": { + "type": "BlockStatement", + "start": 17, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 34 + } + }, + "body": [], + "directives": [ + { + "type": "Directive", + "start": 19, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 19, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "value": "use strict", + "extra": { + "raw": "\"use strict\"", + "rawValue": "use strict" + } + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/516/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/516/options.json deleted file mode 100644 index 604b5896c2c5..000000000000 --- a/packages/babel-parser/test/fixtures/core/uncategorised/516/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Binding 'package' in strict mode (1:11)" -} diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/516/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/516/output.json new file mode 100644 index 000000000000..2f734055a47a --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/uncategorised/516/output.json @@ -0,0 +1,144 @@ +{ + "type": "File", + "start": 0, + "end": 37, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 37 + } + }, + "errors": [ + "SyntaxError: Binding 'package' in strict mode (1:11)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 37, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 37 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 37, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 37 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 10 + }, + "identifierName": "a" + }, + "name": "a" + }, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "start": 11, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 18 + }, + "identifierName": "package" + }, + "name": "package" + } + ], + "body": { + "type": "BlockStatement", + "start": 20, + "end": 37, + "loc": { + "start": { + "line": 1, + "column": 20 + }, + "end": { + "line": 1, + "column": 37 + } + }, + "body": [], + "directives": [ + { + "type": "Directive", + "start": 22, + "end": 35, + "loc": { + "start": { + "line": 1, + "column": 22 + }, + "end": { + "line": 1, + "column": 35 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 22, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 22 + }, + "end": { + "line": 1, + "column": 34 + } + }, + "value": "use strict", + "extra": { + "raw": "\"use strict\"", + "rawValue": "use strict" + } + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/517/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/517/options.json deleted file mode 100644 index 9d2a58081596..000000000000 --- a/packages/babel-parser/test/fixtures/core/uncategorised/517/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Argument name clash (1:43)" -} diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/517/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/517/output.json new file mode 100644 index 000000000000..60ac3ce8c98c --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/uncategorised/517/output.json @@ -0,0 +1,229 @@ +{ + "type": "File", + "start": 0, + "end": 52, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 52 + } + }, + "errors": [ + "SyntaxError: Argument name clash (1:43)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 52, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 52 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 52, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 52 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 10 + }, + "identifierName": "a" + }, + "name": "a" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 13, + "end": 52, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 52 + } + }, + "body": [ + { + "type": "FunctionDeclaration", + "start": 29, + "end": 49, + "loc": { + "start": { + "line": 1, + "column": 29 + }, + "end": { + "line": 1, + "column": 49 + } + }, + "id": { + "type": "Identifier", + "start": 38, + "end": 39, + "loc": { + "start": { + "line": 1, + "column": 38 + }, + "end": { + "line": 1, + "column": 39 + }, + "identifierName": "b" + }, + "name": "b" + }, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "start": 40, + "end": 41, + "loc": { + "start": { + "line": 1, + "column": 40 + }, + "end": { + "line": 1, + "column": 41 + }, + "identifierName": "t" + }, + "name": "t" + }, + { + "type": "Identifier", + "start": 43, + "end": 44, + "loc": { + "start": { + "line": 1, + "column": 43 + }, + "end": { + "line": 1, + "column": 44 + }, + "identifierName": "t" + }, + "name": "t" + } + ], + "body": { + "type": "BlockStatement", + "start": 46, + "end": 49, + "loc": { + "start": { + "line": 1, + "column": 46 + }, + "end": { + "line": 1, + "column": 49 + } + }, + "body": [], + "directives": [] + } + }, + { + "type": "EmptyStatement", + "start": 49, + "end": 50, + "loc": { + "start": { + "line": 1, + "column": 49 + }, + "end": { + "line": 1, + "column": 50 + } + } + } + ], + "directives": [ + { + "type": "Directive", + "start": 15, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 28 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 15, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 27 + } + }, + "value": "use strict", + "extra": { + "raw": "\"use strict\"", + "rawValue": "use strict" + } + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/518/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/518/options.json deleted file mode 100644 index 61c3bbb5abe0..000000000000 --- a/packages/babel-parser/test/fixtures/core/uncategorised/518/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Argument name clash (1:15)" -} diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/518/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/518/output.json new file mode 100644 index 000000000000..766ec14c5a33 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/uncategorised/518/output.json @@ -0,0 +1,180 @@ +{ + "type": "File", + "start": 0, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "errors": [ + "SyntaxError: Argument name clash (1:15)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "expression": { + "type": "FunctionExpression", + "start": 1, + "end": 35, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 35 + } + }, + "id": { + "type": "Identifier", + "start": 10, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 11 + }, + "identifierName": "a" + }, + "name": "a" + }, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "start": 12, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 13 + }, + "identifierName": "t" + }, + "name": "t" + }, + { + "type": "Identifier", + "start": 15, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 16 + }, + "identifierName": "t" + }, + "name": "t" + } + ], + "body": { + "type": "BlockStatement", + "start": 18, + "end": 35, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 35 + } + }, + "body": [], + "directives": [ + { + "type": "Directive", + "start": 20, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 20 + }, + "end": { + "line": 1, + "column": 33 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 20, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 20 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "value": "use strict", + "extra": { + "raw": "\"use strict\"", + "rawValue": "use strict" + } + } + } + ] + }, + "extra": { + "parenthesized": true, + "parenStart": 0 + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/519/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/519/options.json deleted file mode 100644 index ae469fbd59da..000000000000 --- a/packages/babel-parser/test/fixtures/core/uncategorised/519/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Argument name clash (1:44)" -} diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/519/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/519/output.json new file mode 100644 index 000000000000..0f2e3c5dce01 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/uncategorised/519/output.json @@ -0,0 +1,233 @@ +{ + "type": "File", + "start": 0, + "end": 54, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 54 + } + }, + "errors": [ + "SyntaxError: Argument name clash (1:44)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 54, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 54 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 54, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 54 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 10 + }, + "identifierName": "a" + }, + "name": "a" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 13, + "end": 54, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 54 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 29, + "end": 52, + "loc": { + "start": { + "line": 1, + "column": 29 + }, + "end": { + "line": 1, + "column": 52 + } + }, + "expression": { + "type": "FunctionExpression", + "start": 30, + "end": 50, + "loc": { + "start": { + "line": 1, + "column": 30 + }, + "end": { + "line": 1, + "column": 50 + } + }, + "id": { + "type": "Identifier", + "start": 39, + "end": 40, + "loc": { + "start": { + "line": 1, + "column": 39 + }, + "end": { + "line": 1, + "column": 40 + }, + "identifierName": "b" + }, + "name": "b" + }, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "start": 41, + "end": 42, + "loc": { + "start": { + "line": 1, + "column": 41 + }, + "end": { + "line": 1, + "column": 42 + }, + "identifierName": "t" + }, + "name": "t" + }, + { + "type": "Identifier", + "start": 44, + "end": 45, + "loc": { + "start": { + "line": 1, + "column": 44 + }, + "end": { + "line": 1, + "column": 45 + }, + "identifierName": "t" + }, + "name": "t" + } + ], + "body": { + "type": "BlockStatement", + "start": 47, + "end": 50, + "loc": { + "start": { + "line": 1, + "column": 47 + }, + "end": { + "line": 1, + "column": 50 + } + }, + "body": [], + "directives": [] + }, + "extra": { + "parenthesized": true, + "parenStart": 29 + } + } + } + ], + "directives": [ + { + "type": "Directive", + "start": 15, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 28 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 15, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 27 + } + }, + "value": "use strict", + "extra": { + "raw": "\"use strict\"", + "rawValue": "use strict" + } + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/520/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/520/options.json deleted file mode 100644 index b60957f217a4..000000000000 --- a/packages/babel-parser/test/fixtures/core/uncategorised/520/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Binding 'eval' in strict mode (1:12)" -} diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/520/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/520/output.json new file mode 100644 index 000000000000..7945e482ca86 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/uncategorised/520/output.json @@ -0,0 +1,163 @@ +{ + "type": "File", + "start": 0, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "errors": [ + "SyntaxError: Binding 'eval' in strict mode (1:12)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "expression": { + "type": "FunctionExpression", + "start": 1, + "end": 35, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 35 + } + }, + "id": { + "type": "Identifier", + "start": 10, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 11 + }, + "identifierName": "a" + }, + "name": "a" + }, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "start": 12, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 16 + }, + "identifierName": "eval" + }, + "name": "eval" + } + ], + "body": { + "type": "BlockStatement", + "start": 18, + "end": 35, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 35 + } + }, + "body": [], + "directives": [ + { + "type": "Directive", + "start": 20, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 20 + }, + "end": { + "line": 1, + "column": 33 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 20, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 20 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "value": "use strict", + "extra": { + "raw": "\"use strict\"", + "rawValue": "use strict" + } + } + } + ] + }, + "extra": { + "parenthesized": true, + "parenStart": 0 + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/521/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/521/options.json deleted file mode 100644 index 62075401e782..000000000000 --- a/packages/babel-parser/test/fixtures/core/uncategorised/521/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Binding 'package' in strict mode (1:12)" -} diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/521/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/521/output.json new file mode 100644 index 000000000000..304b4237e9e7 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/uncategorised/521/output.json @@ -0,0 +1,163 @@ +{ + "type": "File", + "start": 0, + "end": 39, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 39 + } + }, + "errors": [ + "SyntaxError: Binding 'package' in strict mode (1:12)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 39, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 39 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 39, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 39 + } + }, + "expression": { + "type": "FunctionExpression", + "start": 1, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 38 + } + }, + "id": { + "type": "Identifier", + "start": 10, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 11 + }, + "identifierName": "a" + }, + "name": "a" + }, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "start": 12, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 19 + }, + "identifierName": "package" + }, + "name": "package" + } + ], + "body": { + "type": "BlockStatement", + "start": 21, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 21 + }, + "end": { + "line": 1, + "column": 38 + } + }, + "body": [], + "directives": [ + { + "type": "Directive", + "start": 23, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 23 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 23, + "end": 35, + "loc": { + "start": { + "line": 1, + "column": 23 + }, + "end": { + "line": 1, + "column": 35 + } + }, + "value": "use strict", + "extra": { + "raw": "\"use strict\"", + "rawValue": "use strict" + } + } + } + ] + }, + "extra": { + "parenthesized": true, + "parenStart": 0 + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/522/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/522/options.json deleted file mode 100644 index 0b443b9bacfa..000000000000 --- a/packages/babel-parser/test/fixtures/core/uncategorised/522/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Legacy octal literals are not allowed in strict mode (1:65)" -} diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/522/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/522/output.json new file mode 100644 index 000000000000..98d2e052715b --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/uncategorised/522/output.json @@ -0,0 +1,285 @@ +{ + "type": "File", + "start": 0, + "end": 69, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 69 + } + }, + "errors": [ + "SyntaxError: Legacy octal literals are not allowed in strict mode (1:65)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 69, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 69 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 13, + "end": 42, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 42 + } + }, + "id": { + "type": "Identifier", + "start": 22, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 22 + }, + "end": { + "line": 1, + "column": 25 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 27, + "end": 42, + "loc": { + "start": { + "line": 1, + "column": 27 + }, + "end": { + "line": 1, + "column": 42 + } + }, + "body": [], + "directives": [ + { + "type": "Directive", + "start": 28, + "end": 41, + "loc": { + "start": { + "line": 1, + "column": 28 + }, + "end": { + "line": 1, + "column": 41 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 28, + "end": 40, + "loc": { + "start": { + "line": 1, + "column": 28 + }, + "end": { + "line": 1, + "column": 40 + } + }, + "value": "use strict", + "extra": { + "raw": "\"use strict\"", + "rawValue": "use strict" + } + } + } + ] + } + }, + { + "type": "FunctionDeclaration", + "start": 42, + "end": 69, + "loc": { + "start": { + "line": 1, + "column": 42 + }, + "end": { + "line": 1, + "column": 69 + } + }, + "id": { + "type": "Identifier", + "start": 51, + "end": 54, + "loc": { + "start": { + "line": 1, + "column": 51 + }, + "end": { + "line": 1, + "column": 54 + }, + "identifierName": "bar" + }, + "name": "bar" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 56, + "end": 69, + "loc": { + "start": { + "line": 1, + "column": 56 + }, + "end": { + "line": 1, + "column": 69 + } + }, + "body": [ + { + "type": "VariableDeclaration", + "start": 57, + "end": 68, + "loc": { + "start": { + "line": 1, + "column": 57 + }, + "end": { + "line": 1, + "column": 68 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 61, + "end": 68, + "loc": { + "start": { + "line": 1, + "column": 61 + }, + "end": { + "line": 1, + "column": 68 + } + }, + "id": { + "type": "Identifier", + "start": 61, + "end": 62, + "loc": { + "start": { + "line": 1, + "column": 61 + }, + "end": { + "line": 1, + "column": 62 + }, + "identifierName": "v" + }, + "name": "v" + }, + "init": { + "type": "NumericLiteral", + "start": 65, + "end": 68, + "loc": { + "start": { + "line": 1, + "column": 65 + }, + "end": { + "line": 1, + "column": 68 + } + }, + "extra": { + "rawValue": 13, + "raw": "015" + }, + "value": 13 + } + } + ], + "kind": "var" + } + ], + "directives": [] + } + } + ], + "directives": [ + { + "type": "Directive", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 0, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "value": "use strict", + "extra": { + "raw": "\"use strict\"", + "rawValue": "use strict" + } + } + } + ] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/523/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/523/options.json deleted file mode 100644 index 60a9d5934bd2..000000000000 --- a/packages/babel-parser/test/fixtures/core/uncategorised/523/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Unexpected keyword 'this' (1:4)" -} diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/523/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/523/output.json new file mode 100644 index 000000000000..90808a26c8be --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/uncategorised/523/output.json @@ -0,0 +1,108 @@ +{ + "type": "File", + "start": 0, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "errors": [ + "SyntaxError: Unexpected keyword 'this' (1:4)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "VariableDeclaration", + "start": 0, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 4, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "id": { + "type": "Identifier", + "start": 4, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 8 + }, + "identifierName": "this" + }, + "name": "this" + }, + "init": { + "type": "NumericLiteral", + "start": 11, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "extra": { + "rawValue": 10, + "raw": "10" + }, + "value": 10 + } + } + ], + "kind": "var" + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/524/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/524/options.json deleted file mode 100644 index d07b41872ba6..000000000000 --- a/packages/babel-parser/test/fixtures/core/uncategorised/524/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Illegal newline after throw (1:5)" -} diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/524/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/524/output.json new file mode 100644 index 000000000000..55552e2994ca --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/uncategorised/524/output.json @@ -0,0 +1,73 @@ +{ + "type": "File", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 3 + } + }, + "errors": [ + "SyntaxError: Illegal newline after throw (1:5)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 3 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ThrowStatement", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 3 + } + }, + "argument": { + "type": "NumericLiteral", + "start": 6, + "end": 8, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 2 + } + }, + "extra": { + "rawValue": 10, + "raw": "10" + }, + "value": 10 + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/544/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/544/options.json deleted file mode 100644 index 37c243afff2a..000000000000 --- a/packages/babel-parser/test/fixtures/core/uncategorised/544/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Unexpected reserved word 'public' (2:8)" -} diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/544/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/544/output.json new file mode 100644 index 000000000000..d3b1ca7ae09c --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/uncategorised/544/output.json @@ -0,0 +1,212 @@ +{ + "type": "File", + "start": 0, + "end": 39, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 25 + } + }, + "errors": [ + "SyntaxError: Unexpected reserved word 'public' (2:8)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 39, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 25 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "VariableDeclaration", + "start": 14, + "end": 39, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 25 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 20, + "end": 38, + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 24 + } + }, + "id": { + "type": "ObjectPattern", + "start": 20, + "end": 30, + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 16 + } + }, + "properties": [ + { + "type": "ObjectProperty", + "start": 22, + "end": 28, + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 14 + } + }, + "method": false, + "key": { + "type": "Identifier", + "start": 22, + "end": 28, + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 14 + }, + "identifierName": "public" + }, + "name": "public" + }, + "computed": false, + "shorthand": true, + "value": { + "type": "Identifier", + "start": 22, + "end": 28, + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 14 + }, + "identifierName": "public" + }, + "name": "public" + }, + "extra": { + "shorthand": true + } + } + ] + }, + "init": { + "type": "CallExpression", + "start": 33, + "end": 38, + "loc": { + "start": { + "line": 2, + "column": 19 + }, + "end": { + "line": 2, + "column": 24 + } + }, + "callee": { + "type": "Identifier", + "start": 33, + "end": 36, + "loc": { + "start": { + "line": 2, + "column": 19 + }, + "end": { + "line": 2, + "column": 22 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "arguments": [] + } + } + ], + "kind": "const" + } + ], + "directives": [ + { + "type": "Directive", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 0, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "value": "use strict", + "extra": { + "raw": "\"use strict\"", + "rawValue": "use strict" + } + } + } + ] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/545/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/545/options.json index b09fdddc9d0a..54925950e059 100644 --- a/packages/babel-parser/test/fixtures/core/uncategorised/545/options.json +++ b/packages/babel-parser/test/fixtures/core/uncategorised/545/options.json @@ -1,4 +1,3 @@ { - "sourceType": "module", - "throws": "Unexpected reserved word 'public' (1:8)" -} + "sourceType": "module" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/545/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/545/output.json new file mode 100644 index 000000000000..34af0a196c39 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/uncategorised/545/output.json @@ -0,0 +1,176 @@ +{ + "type": "File", + "start": 0, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 25 + } + }, + "errors": [ + "SyntaxError: Unexpected reserved word 'public' (1:8)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 25 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "VariableDeclaration", + "start": 0, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 25 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 6, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "id": { + "type": "ObjectPattern", + "start": 6, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "properties": [ + { + "type": "ObjectProperty", + "start": 8, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "method": false, + "key": { + "type": "Identifier", + "start": 8, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 14 + }, + "identifierName": "public" + }, + "name": "public" + }, + "computed": false, + "shorthand": true, + "value": { + "type": "Identifier", + "start": 8, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 14 + }, + "identifierName": "public" + }, + "name": "public" + }, + "extra": { + "shorthand": true + } + } + ] + }, + "init": { + "type": "CallExpression", + "start": 19, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "callee": { + "type": "Identifier", + "start": 19, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 22 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "arguments": [] + } + } + ], + "kind": "const" + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/547/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/547/options.json deleted file mode 100644 index c2fb6377e80d..000000000000 --- a/packages/babel-parser/test/fixtures/core/uncategorised/547/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Unexpected reserved word 'arguments' (2:8)" -} diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/547/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/547/output.json new file mode 100644 index 000000000000..39ef331a20b1 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/uncategorised/547/output.json @@ -0,0 +1,213 @@ +{ + "type": "File", + "start": 0, + "end": 42, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 28 + } + }, + "errors": [ + "SyntaxError: Unexpected reserved word 'arguments' (2:8)", + "SyntaxError: Binding 'arguments' in strict mode (2:8)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 42, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 28 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "VariableDeclaration", + "start": 14, + "end": 42, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 28 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 20, + "end": 41, + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 27 + } + }, + "id": { + "type": "ObjectPattern", + "start": 20, + "end": 33, + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 19 + } + }, + "properties": [ + { + "type": "ObjectProperty", + "start": 22, + "end": 31, + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 17 + } + }, + "method": false, + "key": { + "type": "Identifier", + "start": 22, + "end": 31, + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 17 + }, + "identifierName": "arguments" + }, + "name": "arguments" + }, + "computed": false, + "shorthand": true, + "value": { + "type": "Identifier", + "start": 22, + "end": 31, + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 17 + }, + "identifierName": "arguments" + }, + "name": "arguments" + }, + "extra": { + "shorthand": true + } + } + ] + }, + "init": { + "type": "CallExpression", + "start": 36, + "end": 41, + "loc": { + "start": { + "line": 2, + "column": 22 + }, + "end": { + "line": 2, + "column": 27 + } + }, + "callee": { + "type": "Identifier", + "start": 36, + "end": 39, + "loc": { + "start": { + "line": 2, + "column": 22 + }, + "end": { + "line": 2, + "column": 25 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "arguments": [] + } + } + ], + "kind": "const" + } + ], + "directives": [ + { + "type": "Directive", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 0, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "value": "use strict", + "extra": { + "raw": "\"use strict\"", + "rawValue": "use strict" + } + } + } + ] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/548/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/548/options.json index 4183c2e22534..54925950e059 100644 --- a/packages/babel-parser/test/fixtures/core/uncategorised/548/options.json +++ b/packages/babel-parser/test/fixtures/core/uncategorised/548/options.json @@ -1,4 +1,3 @@ { - "sourceType": "module", - "throws": "Unexpected reserved word 'arguments' (1:8)" -} + "sourceType": "module" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/548/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/548/output.json new file mode 100644 index 000000000000..132483692bbd --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/uncategorised/548/output.json @@ -0,0 +1,177 @@ +{ + "type": "File", + "start": 0, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 28 + } + }, + "errors": [ + "SyntaxError: Unexpected reserved word 'arguments' (1:8)", + "SyntaxError: Binding 'arguments' in strict mode (1:8)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 28 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "VariableDeclaration", + "start": 0, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 28 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 6, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 27 + } + }, + "id": { + "type": "ObjectPattern", + "start": 6, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "properties": [ + { + "type": "ObjectProperty", + "start": 8, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "method": false, + "key": { + "type": "Identifier", + "start": 8, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 17 + }, + "identifierName": "arguments" + }, + "name": "arguments" + }, + "computed": false, + "shorthand": true, + "value": { + "type": "Identifier", + "start": 8, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 17 + }, + "identifierName": "arguments" + }, + "name": "arguments" + }, + "extra": { + "shorthand": true + } + } + ] + }, + "init": { + "type": "CallExpression", + "start": 22, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 22 + }, + "end": { + "line": 1, + "column": 27 + } + }, + "callee": { + "type": "Identifier", + "start": 22, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 22 + }, + "end": { + "line": 1, + "column": 25 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "arguments": [] + } + } + ], + "kind": "const" + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/550/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/550/options.json deleted file mode 100644 index 5cee88d901e4..000000000000 --- a/packages/babel-parser/test/fixtures/core/uncategorised/550/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Legacy octal literals are not allowed in strict mode (2:10)" -} diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/550/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/550/output.json new file mode 100644 index 000000000000..9b383cded8fd --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/uncategorised/550/output.json @@ -0,0 +1,144 @@ +{ + "type": "File", + "start": 0, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 13 + } + }, + "errors": [ + "SyntaxError: Legacy octal literals are not allowed in strict mode (2:10)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 13 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "VariableDeclaration", + "start": 14, + "end": 27, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 13 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 20, + "end": 26, + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 12 + } + }, + "id": { + "type": "Identifier", + "start": 20, + "end": 21, + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 7 + }, + "identifierName": "a" + }, + "name": "a" + }, + "init": { + "type": "NumericLiteral", + "start": 24, + "end": 26, + "loc": { + "start": { + "line": 2, + "column": 10 + }, + "end": { + "line": 2, + "column": 12 + } + }, + "extra": { + "rawValue": 7, + "raw": "07" + }, + "value": 7 + } + } + ], + "kind": "const" + } + ], + "directives": [ + { + "type": "Directive", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 0, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "value": "use strict", + "extra": { + "raw": "'use strict'", + "rawValue": "use strict" + } + } + } + ] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/552/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/552/options.json deleted file mode 100644 index 5cee88d901e4..000000000000 --- a/packages/babel-parser/test/fixtures/core/uncategorised/552/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Legacy octal literals are not allowed in strict mode (2:10)" -} diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/552/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/552/output.json new file mode 100644 index 000000000000..a7d3e10860a2 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/uncategorised/552/output.json @@ -0,0 +1,144 @@ +{ + "type": "File", + "start": 0, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 13 + } + }, + "errors": [ + "SyntaxError: Legacy octal literals are not allowed in strict mode (2:10)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 13 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "VariableDeclaration", + "start": 14, + "end": 27, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 13 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 20, + "end": 26, + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 12 + } + }, + "id": { + "type": "Identifier", + "start": 20, + "end": 21, + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 7 + }, + "identifierName": "a" + }, + "name": "a" + }, + "init": { + "type": "NumericLiteral", + "start": 24, + "end": 26, + "loc": { + "start": { + "line": 2, + "column": 10 + }, + "end": { + "line": 2, + "column": 12 + } + }, + "extra": { + "rawValue": 8, + "raw": "08" + }, + "value": 8 + } + } + ], + "kind": "const" + } + ], + "directives": [ + { + "type": "Directive", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 0, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "value": "use strict", + "extra": { + "raw": "'use strict'", + "rawValue": "use strict" + } + } + } + ] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/556/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/556/options.json index eff49cbfba64..6d24025b8674 100644 --- a/packages/babel-parser/test/fixtures/core/uncategorised/556/options.json +++ b/packages/babel-parser/test/fixtures/core/uncategorised/556/options.json @@ -1,4 +1,3 @@ { - "createParenthesizedExpressions": true, - "throws": "You're trying to assign to a parenthesized expression, eg. instead of `({a}) = 0` use `({a} = 0)` (1:1)" -} + "createParenthesizedExpressions": true +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/556/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/556/output.json new file mode 100644 index 000000000000..448578186a0a --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/uncategorised/556/output.json @@ -0,0 +1,228 @@ +{ + "type": "File", + "start": 0, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "errors": [ + "SyntaxError: You're trying to assign to a parenthesized expression, eg. instead of `({a}) = 0` use `({a} = 0)` (1:1)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "expression": { + "type": "AssignmentExpression", + "start": 0, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "operator": "=", + "left": { + "type": "ParenthesizedExpression", + "start": 0, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "expression": { + "type": "ObjectPattern", + "start": 1, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "properties": [ + { + "type": "ObjectProperty", + "start": 2, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 2 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "method": false, + "key": { + "type": "Identifier", + "start": 2, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 2 + }, + "end": { + "line": 1, + "column": 3 + }, + "identifierName": "x" + }, + "name": "x" + }, + "computed": false, + "shorthand": true, + "value": { + "type": "Identifier", + "start": 2, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 2 + }, + "end": { + "line": 1, + "column": 3 + }, + "identifierName": "x" + }, + "name": "x" + }, + "extra": { + "shorthand": true + } + } + ] + } + }, + "right": { + "type": "ObjectExpression", + "start": 8, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "properties": [ + { + "type": "ObjectProperty", + "start": 9, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "method": false, + "key": { + "type": "Identifier", + "start": 9, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 10 + }, + "identifierName": "x" + }, + "name": "x" + }, + "computed": false, + "shorthand": false, + "value": { + "type": "NumericLiteral", + "start": 12, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + } + } + ] + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/558/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/558/options.json index f37c4bc95c57..6d24025b8674 100644 --- a/packages/babel-parser/test/fixtures/core/uncategorised/558/options.json +++ b/packages/babel-parser/test/fixtures/core/uncategorised/558/options.json @@ -1,4 +1,3 @@ { - "createParenthesizedExpressions": true, - "throws": "You're trying to assign to a parenthesized expression, eg. instead of `([a]) = 0` use `([a] = 0)` (1:1)" -} + "createParenthesizedExpressions": true +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/558/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/558/output.json new file mode 100644 index 000000000000..e2a0d2a8ba52 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/uncategorised/558/output.json @@ -0,0 +1,134 @@ +{ + "type": "File", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "errors": [ + "SyntaxError: You're trying to assign to a parenthesized expression, eg. instead of `([a]) = 0` use `([a] = 0)` (1:1)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "expression": { + "type": "AssignmentExpression", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "operator": "=", + "left": { + "type": "ParenthesizedExpression", + "start": 0, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "expression": { + "type": "ArrayPattern", + "start": 1, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "elements": [ + { + "type": "Identifier", + "start": 2, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 2 + }, + "end": { + "line": 1, + "column": 3 + }, + "identifierName": "a" + }, + "name": "a" + } + ] + } + }, + "right": { + "type": "ArrayExpression", + "start": 8, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "elements": [] + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/array-rest-spread/comma-after-rest/options.json b/packages/babel-parser/test/fixtures/es2015/array-rest-spread/comma-after-rest/options.json deleted file mode 100644 index 7931fd924fcd..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/array-rest-spread/comma-after-rest/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Unexpected trailing comma after rest element (1:5)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/array-rest-spread/comma-after-rest/output.json b/packages/babel-parser/test/fixtures/es2015/array-rest-spread/comma-after-rest/output.json new file mode 100644 index 000000000000..3d5c2a07c806 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/array-rest-spread/comma-after-rest/output.json @@ -0,0 +1,137 @@ +{ + "type": "File", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "errors": [ + "SyntaxError: Unexpected trailing comma after rest element (1:5)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "expression": { + "type": "AssignmentExpression", + "start": 0, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "operator": "=", + "left": { + "type": "ArrayPattern", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "extra": { + "trailingComma": 5 + }, + "elements": [ + { + "type": "RestElement", + "start": 1, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "argument": { + "type": "Identifier", + "start": 4, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 5 + }, + "identifierName": "a" + }, + "name": "a" + } + } + ] + }, + "right": { + "type": "ArrayExpression", + "start": 10, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "elements": [] + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/array-rest-spread/comma-after-spread-for-in/options.json b/packages/babel-parser/test/fixtures/es2015/array-rest-spread/comma-after-spread-for-in/options.json deleted file mode 100644 index 0b0d3c532d1e..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/array-rest-spread/comma-after-spread-for-in/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Unexpected trailing comma after rest element (1:10)" -} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/array-rest-spread/comma-after-spread-for-in/output.json b/packages/babel-parser/test/fixtures/es2015/array-rest-spread/comma-after-spread-for-in/output.json new file mode 100644 index 000000000000..f97d7f0db889 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/array-rest-spread/comma-after-spread-for-in/output.json @@ -0,0 +1,136 @@ +{ + "type": "File", + "start": 0, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "errors": [ + "SyntaxError: Unexpected trailing comma after rest element (1:10)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ForInStatement", + "start": 0, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "left": { + "type": "ArrayPattern", + "start": 5, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "extra": { + "trailingComma": 10 + }, + "elements": [ + { + "type": "RestElement", + "start": 6, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "argument": { + "type": "Identifier", + "start": 9, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 10 + }, + "identifierName": "a" + }, + "name": "a" + } + } + ] + }, + "right": { + "type": "ArrayExpression", + "start": 16, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "elements": [] + }, + "body": { + "type": "EmptyStatement", + "start": 19, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 20 + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/array-rest-spread/comma-after-spread-nested/options.json b/packages/babel-parser/test/fixtures/es2015/array-rest-spread/comma-after-spread-nested/options.json deleted file mode 100644 index 95a846d785a8..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/array-rest-spread/comma-after-spread-nested/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Unexpected trailing comma after rest element (1:6)" -} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/array-rest-spread/comma-after-spread-nested/output.json b/packages/babel-parser/test/fixtures/es2015/array-rest-spread/comma-after-spread-nested/output.json new file mode 100644 index 000000000000..4cbc33abae7e --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/array-rest-spread/comma-after-spread-nested/output.json @@ -0,0 +1,154 @@ +{ + "type": "File", + "start": 0, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "errors": [ + "SyntaxError: Unexpected trailing comma after rest element (1:6)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "expression": { + "type": "AssignmentExpression", + "start": 0, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "operator": "=", + "left": { + "type": "ArrayPattern", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "elements": [ + { + "type": "ArrayPattern", + "start": 1, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "extra": { + "trailingComma": 6 + }, + "elements": [ + { + "type": "RestElement", + "start": 2, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 2 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "argument": { + "type": "Identifier", + "start": 5, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 6 + }, + "identifierName": "a" + }, + "name": "a" + } + } + ] + } + ] + }, + "right": { + "type": "ArrayExpression", + "start": 12, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "elements": [] + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/arrow-functions/comma-after-rest-param/options.json b/packages/babel-parser/test/fixtures/es2015/arrow-functions/comma-after-rest-param/options.json index 38fec89ef15c..5ed0b104c003 100644 --- a/packages/babel-parser/test/fixtures/es2015/arrow-functions/comma-after-rest-param/options.json +++ b/packages/babel-parser/test/fixtures/es2015/arrow-functions/comma-after-rest-param/options.json @@ -1,3 +1,3 @@ { - "throws": "Unexpected trailing comma after rest element (1:8)" -} + "throws": "Unexpected token, expected \")\" (1:8)" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/class-methods/direct-super-in-object-method/options.json b/packages/babel-parser/test/fixtures/es2015/class-methods/direct-super-in-object-method/options.json deleted file mode 100644 index 660e644cf6a5..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/class-methods/direct-super-in-object-method/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "super is only allowed in object methods and classes (4:13)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/class-methods/direct-super-in-object-method/output.json b/packages/babel-parser/test/fixtures/es2015/class-methods/direct-super-in-object-method/output.json new file mode 100644 index 000000000000..6a343317ea61 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/class-methods/direct-super-in-object-method/output.json @@ -0,0 +1,340 @@ +{ + "type": "File", + "start": 0, + "end": 87, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 7, + "column": 3 + } + }, + "errors": [ + "SyntaxError: super is only allowed in object methods and classes (4:13)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 87, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 7, + "column": 3 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 87, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 7, + "column": 3 + } + }, + "expression": { + "type": "CallExpression", + "start": 0, + "end": 86, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 7, + "column": 2 + } + }, + "callee": { + "type": "MemberExpression", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "object": { + "type": "Identifier", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + }, + "identifierName": "Object" + }, + "name": "Object" + }, + "property": { + "type": "Identifier", + "start": 7, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 13 + }, + "identifierName": "create" + }, + "name": "create" + }, + "computed": false + }, + "arguments": [ + { + "type": "ObjectExpression", + "start": 14, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "properties": [] + }, + { + "type": "ObjectExpression", + "start": 18, + "end": 85, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 7, + "column": 1 + } + }, + "properties": [ + { + "type": "ObjectProperty", + "start": 22, + "end": 83, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 6, + "column": 3 + } + }, + "method": false, + "key": { + "type": "Identifier", + "start": 22, + "end": 25, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 5 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "computed": false, + "shorthand": false, + "value": { + "type": "ObjectExpression", + "start": 27, + "end": 83, + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 6, + "column": 3 + } + }, + "properties": [ + { + "type": "ObjectProperty", + "start": 33, + "end": 79, + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 5, + "column": 5 + } + }, + "method": false, + "key": { + "type": "Identifier", + "start": 33, + "end": 36, + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 7 + }, + "identifierName": "get" + }, + "name": "get" + }, + "computed": false, + "shorthand": false, + "value": { + "type": "FunctionExpression", + "start": 38, + "end": 79, + "loc": { + "start": { + "line": 3, + "column": 9 + }, + "end": { + "line": 5, + "column": 5 + } + }, + "id": null, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 48, + "end": 79, + "loc": { + "start": { + "line": 3, + "column": 19 + }, + "end": { + "line": 5, + "column": 5 + } + }, + "body": [ + { + "type": "ReturnStatement", + "start": 56, + "end": 73, + "loc": { + "start": { + "line": 4, + "column": 6 + }, + "end": { + "line": 4, + "column": 23 + } + }, + "argument": { + "type": "MemberExpression", + "start": 63, + "end": 72, + "loc": { + "start": { + "line": 4, + "column": 13 + }, + "end": { + "line": 4, + "column": 22 + } + }, + "object": { + "type": "Super", + "start": 63, + "end": 68, + "loc": { + "start": { + "line": 4, + "column": 13 + }, + "end": { + "line": 4, + "column": 18 + } + } + }, + "property": { + "type": "Identifier", + "start": 69, + "end": 72, + "loc": { + "start": { + "line": 4, + "column": 19 + }, + "end": { + "line": 4, + "column": 22 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "computed": false + } + } + ], + "directives": [] + } + } + } + ] + } + } + ] + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/class-methods/direct-super-outside-constructor/options.json b/packages/babel-parser/test/fixtures/es2015/class-methods/direct-super-outside-constructor/options.json deleted file mode 100644 index 9461325c423a..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/class-methods/direct-super-outside-constructor/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "super() is only valid inside a class constructor of a subclass. Maybe a typo in the method name ('constructor') or not extending another class? (2:8)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/class-methods/direct-super-outside-constructor/output.json b/packages/babel-parser/test/fixtures/es2015/class-methods/direct-super-outside-constructor/output.json new file mode 100644 index 000000000000..65fe6001d2c6 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/class-methods/direct-super-outside-constructor/output.json @@ -0,0 +1,191 @@ +{ + "type": "File", + "start": 0, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "errors": [ + "SyntaxError: super() is only valid inside a class constructor of a subclass. Maybe a typo in the method name ('constructor') or not extending another class? (2:8)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ClassDeclaration", + "start": 0, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 6, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + }, + "identifierName": "A" + }, + "name": "A" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "start": 8, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "body": [ + { + "type": "ClassMethod", + "start": 12, + "end": 26, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 16 + } + }, + "static": false, + "key": { + "type": "Identifier", + "start": 12, + "end": 13, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 3 + }, + "identifierName": "x" + }, + "name": "x" + }, + "computed": false, + "kind": "method", + "id": null, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 17, + "end": 26, + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 2, + "column": 16 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 18, + "end": 25, + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 15 + } + }, + "expression": { + "type": "CallExpression", + "start": 18, + "end": 25, + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 15 + } + }, + "callee": { + "type": "Super", + "start": 18, + "end": 23, + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 13 + } + } + }, + "arguments": [] + } + } + ], + "directives": [] + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/class-methods/disallow-duplicate-method-params/options.json b/packages/babel-parser/test/fixtures/es2015/class-methods/disallow-duplicate-method-params/options.json deleted file mode 100644 index a848b7de671a..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/class-methods/disallow-duplicate-method-params/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Argument name clash (2:11)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/class-methods/disallow-duplicate-method-params/output.json b/packages/babel-parser/test/fixtures/es2015/class-methods/disallow-duplicate-method-params/output.json new file mode 100644 index 000000000000..328e55a13f5d --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/class-methods/disallow-duplicate-method-params/output.json @@ -0,0 +1,179 @@ +{ + "type": "File", + "start": 0, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "errors": [ + "SyntaxError: Argument name clash (2:11)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ClassDeclaration", + "start": 0, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 6, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 9 + }, + "identifierName": "Foo" + }, + "name": "Foo" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "start": 10, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "body": [ + { + "type": "ClassMethod", + "start": 16, + "end": 28, + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 16 + } + }, + "static": false, + "key": { + "type": "Identifier", + "start": 16, + "end": 19, + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 7 + }, + "identifierName": "bar" + }, + "name": "bar" + }, + "computed": false, + "kind": "method", + "id": null, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "start": 20, + "end": 21, + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 9 + }, + "identifierName": "a" + }, + "name": "a" + }, + { + "type": "Identifier", + "start": 23, + "end": 24, + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 12 + }, + "identifierName": "a" + }, + "name": "a" + } + ], + "body": { + "type": "BlockStatement", + "start": 26, + "end": 28, + "loc": { + "start": { + "line": 2, + "column": 14 + }, + "end": { + "line": 2, + "column": 16 + } + }, + "body": [], + "directives": [] + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/class-methods/disallow-static-generator-prototype/options.json b/packages/babel-parser/test/fixtures/es2015/class-methods/disallow-static-generator-prototype/options.json deleted file mode 100644 index 524ed587e113..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/class-methods/disallow-static-generator-prototype/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Classes may not have static property named prototype (2:10)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/class-methods/disallow-static-generator-prototype/output.json b/packages/babel-parser/test/fixtures/es2015/class-methods/disallow-static-generator-prototype/output.json new file mode 100644 index 000000000000..0ffcd2fd0520 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/class-methods/disallow-static-generator-prototype/output.json @@ -0,0 +1,144 @@ +{ + "type": "File", + "start": 0, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "errors": [ + "SyntaxError: Classes may not have static property named prototype (2:10)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ClassDeclaration", + "start": 0, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 6, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + }, + "identifierName": "A" + }, + "name": "A" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "start": 8, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "body": [ + { + "type": "ClassMethod", + "start": 12, + "end": 34, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 24 + } + }, + "static": true, + "kind": "method", + "key": { + "type": "Identifier", + "start": 20, + "end": 29, + "loc": { + "start": { + "line": 2, + "column": 10 + }, + "end": { + "line": 2, + "column": 19 + }, + "identifierName": "prototype" + }, + "name": "prototype" + }, + "computed": false, + "id": null, + "generator": true, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 32, + "end": 34, + "loc": { + "start": { + "line": 2, + "column": 22 + }, + "end": { + "line": 2, + "column": 24 + } + }, + "body": [], + "directives": [] + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/class-methods/disallow-static-prototype/options.json b/packages/babel-parser/test/fixtures/es2015/class-methods/disallow-static-prototype/options.json deleted file mode 100644 index f30c8a49abd3..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/class-methods/disallow-static-prototype/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Classes may not have static property named prototype (2:9)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/class-methods/disallow-static-prototype/output.json b/packages/babel-parser/test/fixtures/es2015/class-methods/disallow-static-prototype/output.json new file mode 100644 index 000000000000..f78f786f6aa9 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/class-methods/disallow-static-prototype/output.json @@ -0,0 +1,144 @@ +{ + "type": "File", + "start": 0, + "end": 35, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "errors": [ + "SyntaxError: Classes may not have static property named prototype (2:9)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 35, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ClassDeclaration", + "start": 0, + "end": 35, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 6, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + }, + "identifierName": "A" + }, + "name": "A" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "start": 8, + "end": 35, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "body": [ + { + "type": "ClassMethod", + "start": 12, + "end": 33, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 23 + } + }, + "static": true, + "key": { + "type": "Identifier", + "start": 19, + "end": 28, + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 18 + }, + "identifierName": "prototype" + }, + "name": "prototype" + }, + "computed": false, + "kind": "method", + "id": null, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 31, + "end": 33, + "loc": { + "start": { + "line": 2, + "column": 21 + }, + "end": { + "line": 2, + "column": 23 + } + }, + "body": [], + "directives": [] + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/class-methods/getter-signature/options.json b/packages/babel-parser/test/fixtures/es2015/class-methods/getter-signature/options.json deleted file mode 100644 index 65bc24a66fcd..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/class-methods/getter-signature/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "getter must not have any formal parameters (2:2)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/class-methods/getter-signature/output.json b/packages/babel-parser/test/fixtures/es2015/class-methods/getter-signature/output.json new file mode 100644 index 000000000000..1f5262e935f3 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/class-methods/getter-signature/output.json @@ -0,0 +1,162 @@ +{ + "type": "File", + "start": 0, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "errors": [ + "SyntaxError: getter must not have any formal parameters (2:2)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ClassDeclaration", + "start": 0, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 6, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + }, + "identifierName": "A" + }, + "name": "A" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "start": 8, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "body": [ + { + "type": "ClassMethod", + "start": 12, + "end": 29, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 19 + } + }, + "static": false, + "key": { + "type": "Identifier", + "start": 16, + "end": 20, + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 10 + }, + "identifierName": "prop" + }, + "name": "prop" + }, + "computed": false, + "kind": "get", + "id": null, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "start": 22, + "end": 25, + "loc": { + "start": { + "line": 2, + "column": 12 + }, + "end": { + "line": 2, + "column": 15 + }, + "identifierName": "arg" + }, + "name": "arg" + } + ], + "body": { + "type": "BlockStatement", + "start": 27, + "end": 29, + "loc": { + "start": { + "line": 2, + "column": 17 + }, + "end": { + "line": 2, + "column": 19 + } + }, + "body": [], + "directives": [] + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/class-methods/malformed-super-expression/options.json b/packages/babel-parser/test/fixtures/es2015/class-methods/malformed-super-expression/options.json deleted file mode 100644 index dc41f0b14b5a..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/class-methods/malformed-super-expression/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Unexpected token (3:10)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/class-methods/malformed-super-expression/output.json b/packages/babel-parser/test/fixtures/es2015/class-methods/malformed-super-expression/output.json new file mode 100644 index 000000000000..6ecafb90e3ab --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/class-methods/malformed-super-expression/output.json @@ -0,0 +1,211 @@ +{ + "type": "File", + "start": 0, + "end": 39, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 5, + "column": 1 + } + }, + "errors": [ + "SyntaxError: super can only be used with function calls (i.e. super()) or in property accesses (i.e. super.prop or super[prop]) (3:4)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 39, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 5, + "column": 1 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ClassDeclaration", + "start": 0, + "end": 39, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 5, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 6, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + }, + "identifierName": "A" + }, + "name": "A" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "start": 8, + "end": 39, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 5, + "column": 1 + } + }, + "body": [ + { + "type": "ClassMethod", + "start": 12, + "end": 37, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 4, + "column": 3 + } + }, + "static": false, + "key": { + "type": "Identifier", + "start": 12, + "end": 13, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 3 + }, + "identifierName": "x" + }, + "name": "x" + }, + "computed": false, + "kind": "method", + "id": null, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 17, + "end": 37, + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 4, + "column": 3 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 23, + "end": 33, + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 14 + } + }, + "expression": { + "type": "BinaryExpression", + "start": 23, + "end": 32, + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 13 + } + }, + "left": { + "type": "Super", + "start": 23, + "end": 28, + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 9 + } + } + }, + "operator": "-", + "right": { + "type": "NumericLiteral", + "start": 31, + "end": 32, + "loc": { + "start": { + "line": 3, + "column": 12 + }, + "end": { + "line": 3, + "column": 13 + } + }, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + } + } + } + ], + "directives": [] + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/class/extends-strict/options.json b/packages/babel-parser/test/fixtures/es2015/class/extends-strict/options.json deleted file mode 100644 index 09a1c52e4354..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/class/extends-strict/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "'with' in strict mode (2:2)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/class/extends-strict/output.json b/packages/babel-parser/test/fixtures/es2015/class/extends-strict/output.json new file mode 100644 index 000000000000..efd21a8e7118 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/class/extends-strict/output.json @@ -0,0 +1,237 @@ +{ + "type": "File", + "start": 0, + "end": 64, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 7 + } + }, + "errors": [ + "SyntaxError: 'with' in strict mode (2:2)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 64, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 7 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ClassDeclaration", + "start": 0, + "end": 64, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 7 + } + }, + "id": { + "type": "Identifier", + "start": 6, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + }, + "identifierName": "C" + }, + "name": "C" + }, + "superClass": { + "type": "CallExpression", + "start": 17, + "end": 60, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 4, + "column": 3 + } + }, + "callee": { + "type": "FunctionExpression", + "start": 17, + "end": 58, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 26, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 26 + }, + "end": { + "line": 1, + "column": 27 + }, + "identifierName": "B" + }, + "name": "B" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 30, + "end": 58, + "loc": { + "start": { + "line": 1, + "column": 30 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "body": [ + { + "type": "WithStatement", + "start": 34, + "end": 44, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 12 + } + }, + "object": { + "type": "ObjectExpression", + "start": 40, + "end": 42, + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 10 + } + }, + "properties": [] + }, + "body": { + "type": "EmptyStatement", + "start": 43, + "end": 44, + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 12 + } + } + } + }, + { + "type": "ReturnStatement", + "start": 47, + "end": 56, + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 3, + "column": 11 + } + }, + "argument": { + "type": "Identifier", + "start": 54, + "end": 55, + "loc": { + "start": { + "line": 3, + "column": 9 + }, + "end": { + "line": 3, + "column": 10 + }, + "identifierName": "B" + }, + "name": "B" + } + } + ], + "directives": [] + } + }, + "arguments": [], + "extra": { + "parenthesized": true, + "parenStart": 16 + } + }, + "body": { + "type": "ClassBody", + "start": 62, + "end": 64, + "loc": { + "start": { + "line": 4, + "column": 5 + }, + "end": { + "line": 4, + "column": 7 + } + }, + "body": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/destructuring/binding-this/input.js b/packages/babel-parser/test/fixtures/es2015/destructuring/binding-this/input.js index 11cebfa18894..42403a50ea26 100644 --- a/packages/babel-parser/test/fixtures/es2015/destructuring/binding-this/input.js +++ b/packages/babel-parser/test/fixtures/es2015/destructuring/binding-this/input.js @@ -1 +1 @@ -var { this }; +var { this } = {}; diff --git a/packages/babel-parser/test/fixtures/es2015/destructuring/binding-this/options.json b/packages/babel-parser/test/fixtures/es2015/destructuring/binding-this/options.json deleted file mode 100644 index 1b54b61689e7..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/destructuring/binding-this/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Unexpected keyword 'this' (1:6)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/destructuring/binding-this/output.json b/packages/babel-parser/test/fixtures/es2015/destructuring/binding-this/output.json new file mode 100644 index 000000000000..7d830d569103 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/destructuring/binding-this/output.json @@ -0,0 +1,159 @@ +{ + "type": "File", + "start": 0, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "errors": [ + "SyntaxError: Unexpected keyword 'this' (1:6)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "VariableDeclaration", + "start": 0, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 4, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "id": { + "type": "ObjectPattern", + "start": 4, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "properties": [ + { + "type": "ObjectProperty", + "start": 6, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "method": false, + "key": { + "type": "Identifier", + "start": 6, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 10 + }, + "identifierName": "this" + }, + "name": "this" + }, + "computed": false, + "shorthand": true, + "value": { + "type": "Identifier", + "start": 6, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 10 + }, + "identifierName": "this" + }, + "name": "this" + }, + "extra": { + "shorthand": true + } + } + ] + }, + "init": { + "type": "ObjectExpression", + "start": 15, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "properties": [] + } + } + ], + "kind": "var" + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/destructuring/error-operator-for-default/options.json b/packages/babel-parser/test/fixtures/es2015/destructuring/error-operator-for-default/options.json deleted file mode 100644 index f52857170baa..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/destructuring/error-operator-for-default/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Only '=' operator can be used for specifying default value. (1:3)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/destructuring/error-operator-for-default/output.json b/packages/babel-parser/test/fixtures/es2015/destructuring/error-operator-for-default/output.json new file mode 100644 index 000000000000..5a29fd6b5f7b --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/destructuring/error-operator-for-default/output.json @@ -0,0 +1,156 @@ +{ + "type": "File", + "start": 0, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "errors": [ + "SyntaxError: Only '=' operator can be used for specifying default value. (1:3)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "expression": { + "type": "AssignmentExpression", + "start": 1, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "operator": "=", + "left": { + "type": "ArrayPattern", + "start": 1, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "elements": [ + { + "type": "AssignmentPattern", + "start": 2, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 2 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "left": { + "type": "Identifier", + "start": 2, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 2 + }, + "end": { + "line": 1, + "column": 3 + }, + "identifierName": "a" + }, + "name": "a" + }, + "right": { + "type": "Identifier", + "start": 7, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 8 + }, + "identifierName": "a" + }, + "name": "a" + } + } + ] + }, + "right": { + "type": "Identifier", + "start": 12, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 13 + }, + "identifierName": "a" + }, + "name": "a" + }, + "extra": { + "parenthesized": true, + "parenStart": 0 + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/destructuring/parenthesized-lhs-array/options.json b/packages/babel-parser/test/fixtures/es2015/destructuring/parenthesized-lhs-array/options.json deleted file mode 100644 index dfcad1b5cbf0..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/destructuring/parenthesized-lhs-array/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "You're trying to assign to a parenthesized expression, eg. instead of `([a]) = 0` use `([a] = 0)` (1:1)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/destructuring/parenthesized-lhs-array/output.json b/packages/babel-parser/test/fixtures/es2015/destructuring/parenthesized-lhs-array/output.json new file mode 100644 index 000000000000..111c55cd65bd --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/destructuring/parenthesized-lhs-array/output.json @@ -0,0 +1,127 @@ +{ + "type": "File", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "errors": [ + "SyntaxError: You're trying to assign to a parenthesized expression, eg. instead of `([a]) = 0` use `([a] = 0)` (1:1)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "expression": { + "type": "AssignmentExpression", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "operator": "=", + "left": { + "type": "ArrayPattern", + "start": 1, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "elements": [ + { + "type": "Identifier", + "start": 2, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 2 + }, + "end": { + "line": 1, + "column": 3 + }, + "identifierName": "a" + }, + "name": "a" + } + ], + "extra": { + "parenthesized": true, + "parenStart": 0 + } + }, + "right": { + "type": "NumericLiteral", + "start": 8, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "extra": { + "rawValue": 2, + "raw": "2" + }, + "value": 2 + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/destructuring/parenthesized-lhs-object/options.json b/packages/babel-parser/test/fixtures/es2015/destructuring/parenthesized-lhs-object/options.json deleted file mode 100644 index d0fb48924093..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/destructuring/parenthesized-lhs-object/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "You're trying to assign to a parenthesized expression, eg. instead of `({a}) = 0` use `({a} = 0)` (1:1)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/destructuring/parenthesized-lhs-object/output.json b/packages/babel-parser/test/fixtures/es2015/destructuring/parenthesized-lhs-object/output.json new file mode 100644 index 000000000000..34adca287e3e --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/destructuring/parenthesized-lhs-object/output.json @@ -0,0 +1,165 @@ +{ + "type": "File", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "errors": [ + "SyntaxError: You're trying to assign to a parenthesized expression, eg. instead of `({a}) = 0` use `({a} = 0)` (1:1)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "expression": { + "type": "AssignmentExpression", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "operator": "=", + "left": { + "type": "ObjectPattern", + "start": 1, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "properties": [ + { + "type": "ObjectProperty", + "start": 2, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 2 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "method": false, + "key": { + "type": "Identifier", + "start": 2, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 2 + }, + "end": { + "line": 1, + "column": 3 + }, + "identifierName": "a" + }, + "name": "a" + }, + "computed": false, + "shorthand": true, + "value": { + "type": "Identifier", + "start": 2, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 2 + }, + "end": { + "line": 1, + "column": 3 + }, + "identifierName": "a" + }, + "name": "a" + }, + "extra": { + "shorthand": true + } + } + ], + "extra": { + "parenthesized": true, + "parenStart": 0 + } + }, + "right": { + "type": "NumericLiteral", + "start": 8, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "extra": { + "rawValue": 2, + "raw": "2" + }, + "value": 2 + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/for-in/bare-initializer/options.json b/packages/babel-parser/test/fixtures/es2015/for-in/bare-initializer/options.json deleted file mode 100644 index 2a64fa7c20ad..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/for-in/bare-initializer/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid left-hand side in for-loop (2:5)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/for-in/bare-initializer/output.json b/packages/babel-parser/test/fixtures/es2015/for-in/bare-initializer/output.json new file mode 100644 index 000000000000..bde13b8bdbda --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/for-in/bare-initializer/output.json @@ -0,0 +1,187 @@ +{ + "type": "File", + "start": 0, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 18 + } + }, + "errors": [ + "SyntaxError: Invalid left-hand side in for-loop (2:5)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 18 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "VariableDeclaration", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 4, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "id": { + "type": "Identifier", + "start": 4, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 5 + }, + "identifierName": "a" + }, + "name": "a" + }, + "init": null + } + ], + "kind": "var" + }, + { + "type": "ForInStatement", + "start": 7, + "end": 25, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 18 + } + }, + "left": { + "type": "AssignmentPattern", + "start": 12, + "end": 17, + "loc": { + "start": { + "line": 2, + "column": 5 + }, + "end": { + "line": 2, + "column": 10 + } + }, + "left": { + "type": "Identifier", + "start": 12, + "end": 13, + "loc": { + "start": { + "line": 2, + "column": 5 + }, + "end": { + "line": 2, + "column": 6 + }, + "identifierName": "a" + }, + "name": "a" + }, + "right": { + "type": "NumericLiteral", + "start": 16, + "end": 17, + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 10 + } + }, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + } + }, + "right": { + "type": "ObjectExpression", + "start": 21, + "end": 23, + "loc": { + "start": { + "line": 2, + "column": 14 + }, + "end": { + "line": 2, + "column": 16 + } + }, + "properties": [] + }, + "body": { + "type": "EmptyStatement", + "start": 24, + "end": 25, + "loc": { + "start": { + "line": 2, + "column": 17 + }, + "end": { + "line": 2, + "column": 18 + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/for-in/const-initializer/options.json b/packages/babel-parser/test/fixtures/es2015/for-in/const-initializer/options.json deleted file mode 100644 index 68677faac9b9..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/for-in/const-initializer/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "for-in loop variable declaration may not have an initializer (1:5)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/for-in/const-initializer/output.json b/packages/babel-parser/test/fixtures/es2015/for-in/const-initializer/output.json new file mode 100644 index 000000000000..b85f54f50027 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/for-in/const-initializer/output.json @@ -0,0 +1,154 @@ +{ + "type": "File", + "start": 0, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "errors": [ + "SyntaxError: for-in loop variable declaration may not have an initializer (1:5)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ForInStatement", + "start": 0, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "left": { + "type": "VariableDeclaration", + "start": 5, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 11, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "id": { + "type": "Identifier", + "start": 11, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 12 + }, + "identifierName": "a" + }, + "name": "a" + }, + "init": { + "type": "NumericLiteral", + "start": 15, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + } + } + ], + "kind": "const" + }, + "right": { + "type": "ObjectExpression", + "start": 20, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 20 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "properties": [] + }, + "body": { + "type": "EmptyStatement", + "start": 23, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 23 + }, + "end": { + "line": 1, + "column": 24 + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/for-in/let-initializer/options.json b/packages/babel-parser/test/fixtures/es2015/for-in/let-initializer/options.json deleted file mode 100644 index 68677faac9b9..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/for-in/let-initializer/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "for-in loop variable declaration may not have an initializer (1:5)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/for-in/let-initializer/output.json b/packages/babel-parser/test/fixtures/es2015/for-in/let-initializer/output.json new file mode 100644 index 000000000000..d890ea49e1da --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/for-in/let-initializer/output.json @@ -0,0 +1,154 @@ +{ + "type": "File", + "start": 0, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "errors": [ + "SyntaxError: for-in loop variable declaration may not have an initializer (1:5)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ForInStatement", + "start": 0, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "left": { + "type": "VariableDeclaration", + "start": 5, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 9, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 10 + }, + "identifierName": "a" + }, + "name": "a" + }, + "init": { + "type": "NumericLiteral", + "start": 13, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + } + } + ], + "kind": "let" + }, + "right": { + "type": "ObjectExpression", + "start": 18, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "properties": [] + }, + "body": { + "type": "EmptyStatement", + "start": 21, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 21 + }, + "end": { + "line": 1, + "column": 22 + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/for-in/strict-initializer/options.json b/packages/babel-parser/test/fixtures/es2015/for-in/strict-initializer/options.json deleted file mode 100644 index 1fa21b020d65..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/for-in/strict-initializer/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "for-in loop variable declaration may not have an initializer (2:5)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/for-in/strict-initializer/output.json b/packages/babel-parser/test/fixtures/es2015/for-in/strict-initializer/output.json new file mode 100644 index 000000000000..556eea44650d --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/for-in/strict-initializer/output.json @@ -0,0 +1,190 @@ +{ + "type": "File", + "start": 0, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 22 + } + }, + "errors": [ + "SyntaxError: for-in loop variable declaration may not have an initializer (2:5)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 22 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ForInStatement", + "start": 14, + "end": 36, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 22 + } + }, + "left": { + "type": "VariableDeclaration", + "start": 19, + "end": 28, + "loc": { + "start": { + "line": 2, + "column": 5 + }, + "end": { + "line": 2, + "column": 14 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 23, + "end": 28, + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 14 + } + }, + "id": { + "type": "Identifier", + "start": 23, + "end": 24, + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 10 + }, + "identifierName": "a" + }, + "name": "a" + }, + "init": { + "type": "NumericLiteral", + "start": 27, + "end": 28, + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 14 + } + }, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + } + } + ], + "kind": "var" + }, + "right": { + "type": "ObjectExpression", + "start": 32, + "end": 34, + "loc": { + "start": { + "line": 2, + "column": 18 + }, + "end": { + "line": 2, + "column": 20 + } + }, + "properties": [] + }, + "body": { + "type": "EmptyStatement", + "start": 35, + "end": 36, + "loc": { + "start": { + "line": 2, + "column": 21 + }, + "end": { + "line": 2, + "column": 22 + } + } + } + } + ], + "directives": [ + { + "type": "Directive", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 0, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "value": "use strict", + "extra": { + "raw": "'use strict'", + "rawValue": "use strict" + } + } + } + ] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/for-in/var-arraybindingpattern-initializer/options.json b/packages/babel-parser/test/fixtures/es2015/for-in/var-arraybindingpattern-initializer/options.json deleted file mode 100644 index 68677faac9b9..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/for-in/var-arraybindingpattern-initializer/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "for-in loop variable declaration may not have an initializer (1:5)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/for-in/var-arraybindingpattern-initializer/output.json b/packages/babel-parser/test/fixtures/es2015/for-in/var-arraybindingpattern-initializer/output.json new file mode 100644 index 000000000000..fbffb7c6994a --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/for-in/var-arraybindingpattern-initializer/output.json @@ -0,0 +1,171 @@ +{ + "type": "File", + "start": 0, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "errors": [ + "SyntaxError: for-in loop variable declaration may not have an initializer (1:5)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ForInStatement", + "start": 0, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "left": { + "type": "VariableDeclaration", + "start": 5, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 9, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "id": { + "type": "ArrayPattern", + "start": 9, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "elements": [ + { + "type": "Identifier", + "start": 10, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 11 + }, + "identifierName": "a" + }, + "name": "a" + } + ] + }, + "init": { + "type": "NumericLiteral", + "start": 15, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + } + } + ], + "kind": "var" + }, + "right": { + "type": "ObjectExpression", + "start": 20, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 20 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "properties": [] + }, + "body": { + "type": "EmptyStatement", + "start": 23, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 23 + }, + "end": { + "line": 1, + "column": 24 + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/for-in/var-objectbindingpattern-initializer/options.json b/packages/babel-parser/test/fixtures/es2015/for-in/var-objectbindingpattern-initializer/options.json deleted file mode 100644 index 68677faac9b9..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/for-in/var-objectbindingpattern-initializer/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "for-in loop variable declaration may not have an initializer (1:5)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/for-in/var-objectbindingpattern-initializer/output.json b/packages/babel-parser/test/fixtures/es2015/for-in/var-objectbindingpattern-initializer/output.json new file mode 100644 index 000000000000..0afdc7b4d271 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/for-in/var-objectbindingpattern-initializer/output.json @@ -0,0 +1,209 @@ +{ + "type": "File", + "start": 0, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "errors": [ + "SyntaxError: for-in loop variable declaration may not have an initializer (1:5)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ForInStatement", + "start": 0, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "left": { + "type": "VariableDeclaration", + "start": 5, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 9, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "id": { + "type": "ObjectPattern", + "start": 9, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "properties": [ + { + "type": "ObjectProperty", + "start": 10, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "method": false, + "key": { + "type": "Identifier", + "start": 10, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 11 + }, + "identifierName": "a" + }, + "name": "a" + }, + "computed": false, + "shorthand": true, + "value": { + "type": "Identifier", + "start": 10, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 11 + }, + "identifierName": "a" + }, + "name": "a" + }, + "extra": { + "shorthand": true + } + } + ] + }, + "init": { + "type": "NumericLiteral", + "start": 15, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + } + } + ], + "kind": "var" + }, + "right": { + "type": "ObjectExpression", + "start": 20, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 20 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "properties": [] + }, + "body": { + "type": "EmptyStatement", + "start": 23, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 23 + }, + "end": { + "line": 1, + "column": 24 + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/for-of/bare-initializer/options.json b/packages/babel-parser/test/fixtures/es2015/for-of/bare-initializer/options.json deleted file mode 100644 index 2a64fa7c20ad..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/for-of/bare-initializer/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid left-hand side in for-loop (2:5)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/for-of/bare-initializer/output.json b/packages/babel-parser/test/fixtures/es2015/for-of/bare-initializer/output.json new file mode 100644 index 000000000000..936a7b0183e3 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/for-of/bare-initializer/output.json @@ -0,0 +1,188 @@ +{ + "type": "File", + "start": 0, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 18 + } + }, + "errors": [ + "SyntaxError: Invalid left-hand side in for-loop (2:5)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 18 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "VariableDeclaration", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 4, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "id": { + "type": "Identifier", + "start": 4, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 5 + }, + "identifierName": "a" + }, + "name": "a" + }, + "init": null + } + ], + "kind": "var" + }, + { + "type": "ForOfStatement", + "start": 7, + "end": 25, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 18 + } + }, + "await": false, + "left": { + "type": "AssignmentPattern", + "start": 12, + "end": 17, + "loc": { + "start": { + "line": 2, + "column": 5 + }, + "end": { + "line": 2, + "column": 10 + } + }, + "left": { + "type": "Identifier", + "start": 12, + "end": 13, + "loc": { + "start": { + "line": 2, + "column": 5 + }, + "end": { + "line": 2, + "column": 6 + }, + "identifierName": "a" + }, + "name": "a" + }, + "right": { + "type": "NumericLiteral", + "start": 16, + "end": 17, + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 10 + } + }, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + } + }, + "right": { + "type": "ObjectExpression", + "start": 21, + "end": 23, + "loc": { + "start": { + "line": 2, + "column": 14 + }, + "end": { + "line": 2, + "column": 16 + } + }, + "properties": [] + }, + "body": { + "type": "EmptyStatement", + "start": 24, + "end": 25, + "loc": { + "start": { + "line": 2, + "column": 17 + }, + "end": { + "line": 2, + "column": 18 + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/generators/invalid-escape-yield/input.js b/packages/babel-parser/test/fixtures/es2015/generators/invalid-escape-yield/input.js index 521b91facbbc..8a89e37a1275 100644 --- a/packages/babel-parser/test/fixtures/es2015/generators/invalid-escape-yield/input.js +++ b/packages/babel-parser/test/fixtures/es2015/generators/invalid-escape-yield/input.js @@ -1 +1 @@ -(function* () { y\u0069eld 10 }) +(function* () { y\u0069eld; }) diff --git a/packages/babel-parser/test/fixtures/es2015/generators/invalid-escape-yield/options.json b/packages/babel-parser/test/fixtures/es2015/generators/invalid-escape-yield/options.json deleted file mode 100644 index 67305b830e87..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/generators/invalid-escape-yield/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Can not use 'yield' as identifier inside a generator (1:16)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/generators/invalid-escape-yield/output.json b/packages/babel-parser/test/fixtures/es2015/generators/invalid-escape-yield/output.json new file mode 100644 index 000000000000..6d1a2d6c3fce --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/generators/invalid-escape-yield/output.json @@ -0,0 +1,126 @@ +{ + "type": "File", + "start": 0, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "errors": [ + "SyntaxError: Can not use 'yield' as identifier inside a generator (1:16)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "expression": { + "type": "FunctionExpression", + "start": 1, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "id": null, + "generator": true, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 14, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 16, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 27 + } + }, + "expression": { + "type": "Identifier", + "start": 16, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 26 + }, + "identifierName": "yield" + }, + "name": "yield" + } + } + ], + "directives": [] + }, + "extra": { + "parenthesized": true, + "parenStart": 0 + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/generators/invalid-hanging/options.json b/packages/babel-parser/test/fixtures/es2015/generators/invalid-hanging/options.json deleted file mode 100644 index 8cdac51705a1..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/generators/invalid-hanging/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Generators can only be declared at the top level or inside a block (1:16)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/generators/invalid-hanging/output.json b/packages/babel-parser/test/fixtures/es2015/generators/invalid-hanging/output.json new file mode 100644 index 000000000000..0059c885f4d8 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/generators/invalid-hanging/output.json @@ -0,0 +1,126 @@ +{ + "type": "File", + "start": 0, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 25 + } + }, + "errors": [ + "SyntaxError: Generators can only be declared at the top level or inside a block (1:16)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 25 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "IfStatement", + "start": 0, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 25 + } + }, + "test": { + "type": "NumericLiteral", + "start": 4, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + }, + "consequent": { + "type": "FunctionDeclaration", + "start": 7, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 25 + } + }, + "id": { + "type": "Identifier", + "start": 17, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 20 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "generator": true, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 23, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 23 + }, + "end": { + "line": 1, + "column": 25 + } + }, + "body": [], + "directives": [] + } + }, + "alternate": null + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/identifiers/invalid-escape-seq-const/input.js b/packages/babel-parser/test/fixtures/es2015/identifiers/invalid-escape-seq-const/input.js index 7db67c0d2dc7..3ec83f02b2f4 100644 --- a/packages/babel-parser/test/fixtures/es2015/identifiers/invalid-escape-seq-const/input.js +++ b/packages/babel-parser/test/fixtures/es2015/identifiers/invalid-escape-seq-const/input.js @@ -1 +1,3 @@ var co\u{6e}st = 123; + +co\u{6e}st x = 2; diff --git a/packages/babel-parser/test/fixtures/es2015/identifiers/invalid-escape-seq-const/options.json b/packages/babel-parser/test/fixtures/es2015/identifiers/invalid-escape-seq-const/options.json deleted file mode 100644 index d6c0b22e3090..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/identifiers/invalid-escape-seq-const/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Escape sequence in keyword const (1:14)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/identifiers/invalid-escape-seq-const/output.json b/packages/babel-parser/test/fixtures/es2015/identifiers/invalid-escape-seq-const/output.json new file mode 100644 index 000000000000..f5d632c23ace --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/identifiers/invalid-escape-seq-const/output.json @@ -0,0 +1,180 @@ +{ + "type": "File", + "start": 0, + "end": 40, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 17 + } + }, + "errors": [ + "SyntaxError: Unexpected keyword 'const' (1:4)", + "SyntaxError: Escape sequence in keyword const (1:4)", + "SyntaxError: Escape sequence in keyword const (3:0)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 40, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 17 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "VariableDeclaration", + "start": 0, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 4, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "id": { + "type": "Identifier", + "start": 4, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 14 + }, + "identifierName": "const" + }, + "name": "const" + }, + "init": { + "type": "NumericLiteral", + "start": 17, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "extra": { + "rawValue": 123, + "raw": "123" + }, + "value": 123 + } + } + ], + "kind": "var" + }, + { + "type": "VariableDeclaration", + "start": 23, + "end": 40, + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 17 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 34, + "end": 39, + "loc": { + "start": { + "line": 3, + "column": 11 + }, + "end": { + "line": 3, + "column": 16 + } + }, + "id": { + "type": "Identifier", + "start": 34, + "end": 35, + "loc": { + "start": { + "line": 3, + "column": 11 + }, + "end": { + "line": 3, + "column": 12 + }, + "identifierName": "x" + }, + "name": "x" + }, + "init": { + "type": "NumericLiteral", + "start": 38, + "end": 39, + "loc": { + "start": { + "line": 3, + "column": 15 + }, + "end": { + "line": 3, + "column": 16 + } + }, + "extra": { + "rawValue": 2, + "raw": "2" + }, + "value": 2 + } + } + ], + "kind": "const" + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/identifiers/invalid-escape-seq-export/input.js b/packages/babel-parser/test/fixtures/es2015/identifiers/invalid-escape-seq-export/input.js index 2c49151ea912..c9bc4e4c28d9 100644 --- a/packages/babel-parser/test/fixtures/es2015/identifiers/invalid-escape-seq-export/input.js +++ b/packages/babel-parser/test/fixtures/es2015/identifiers/invalid-escape-seq-export/input.js @@ -1 +1,4 @@ var expor\u{74} = 123; + +var x; +expor\u{74} { x }; diff --git a/packages/babel-parser/test/fixtures/es2015/identifiers/invalid-escape-seq-export/options.json b/packages/babel-parser/test/fixtures/es2015/identifiers/invalid-escape-seq-export/options.json index 80870219d5cc..54925950e059 100644 --- a/packages/babel-parser/test/fixtures/es2015/identifiers/invalid-escape-seq-export/options.json +++ b/packages/babel-parser/test/fixtures/es2015/identifiers/invalid-escape-seq-export/options.json @@ -1,3 +1,3 @@ { - "throws": "Escape sequence in keyword export (1:15)" -} + "sourceType": "module" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/identifiers/invalid-escape-seq-export/output.json b/packages/babel-parser/test/fixtures/es2015/identifiers/invalid-escape-seq-export/output.json new file mode 100644 index 000000000000..236b7dc15afa --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/identifiers/invalid-escape-seq-export/output.json @@ -0,0 +1,229 @@ +{ + "type": "File", + "start": 0, + "end": 49, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 18 + } + }, + "errors": [ + "SyntaxError: Unexpected keyword 'export' (1:4)", + "SyntaxError: Escape sequence in keyword export (1:4)", + "SyntaxError: Escape sequence in keyword export (4:0)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 49, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 18 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "VariableDeclaration", + "start": 0, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 4, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "id": { + "type": "Identifier", + "start": 4, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 15 + }, + "identifierName": "export" + }, + "name": "export" + }, + "init": { + "type": "NumericLiteral", + "start": 18, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "extra": { + "rawValue": 123, + "raw": "123" + }, + "value": 123 + } + } + ], + "kind": "var" + }, + { + "type": "VariableDeclaration", + "start": 24, + "end": 30, + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 6 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 28, + "end": 29, + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 5 + } + }, + "id": { + "type": "Identifier", + "start": 28, + "end": 29, + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 5 + }, + "identifierName": "x" + }, + "name": "x" + }, + "init": null + } + ], + "kind": "var" + }, + { + "type": "ExportNamedDeclaration", + "start": 31, + "end": 49, + "loc": { + "start": { + "line": 4, + "column": 0 + }, + "end": { + "line": 4, + "column": 18 + } + }, + "specifiers": [ + { + "type": "ExportSpecifier", + "start": 45, + "end": 46, + "loc": { + "start": { + "line": 4, + "column": 14 + }, + "end": { + "line": 4, + "column": 15 + } + }, + "local": { + "type": "Identifier", + "start": 45, + "end": 46, + "loc": { + "start": { + "line": 4, + "column": 14 + }, + "end": { + "line": 4, + "column": 15 + }, + "identifierName": "x" + }, + "name": "x" + }, + "exported": { + "type": "Identifier", + "start": 45, + "end": 46, + "loc": { + "start": { + "line": 4, + "column": 14 + }, + "end": { + "line": 4, + "column": 15 + }, + "identifierName": "x" + }, + "name": "x" + } + } + ], + "source": null, + "declaration": null + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/identifiers/invalid-escape-seq-if/options.json b/packages/babel-parser/test/fixtures/es2015/identifiers/invalid-escape-seq-if/options.json deleted file mode 100644 index 52faf91d3656..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/identifiers/invalid-escape-seq-if/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Escape sequence in keyword if (1:12)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/identifiers/invalid-escape-seq-if/output.json b/packages/babel-parser/test/fixtures/es2015/identifiers/invalid-escape-seq-if/output.json new file mode 100644 index 000000000000..d95df678e8c4 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/identifiers/invalid-escape-seq-if/output.json @@ -0,0 +1,87 @@ +{ + "type": "File", + "start": 0, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "errors": [ + "SyntaxError: Escape sequence in keyword if (1:0)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "IfStatement", + "start": 0, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "test": { + "type": "BooleanLiteral", + "start": 14, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "value": true + }, + "consequent": { + "type": "BlockStatement", + "start": 20, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 20 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "body": [], + "directives": [] + }, + "alternate": null + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/identifiers/invalid-escape-seq-import/input.js b/packages/babel-parser/test/fixtures/es2015/identifiers/invalid-escape-seq-import/input.js index f23c79e20fb1..df174d0e56d1 100644 --- a/packages/babel-parser/test/fixtures/es2015/identifiers/invalid-escape-seq-import/input.js +++ b/packages/babel-parser/test/fixtures/es2015/identifiers/invalid-escape-seq-import/input.js @@ -1 +1,3 @@ var \u{69}\u{6d}\u{70}\u{6f}\u{72}\u{74} = 123; + +\u{69}\u{6d}\u{70}\u{6f}\u{72}\u{74} "x"; diff --git a/packages/babel-parser/test/fixtures/es2015/identifiers/invalid-escape-seq-import/options.json b/packages/babel-parser/test/fixtures/es2015/identifiers/invalid-escape-seq-import/options.json index 45763ffa389b..54925950e059 100644 --- a/packages/babel-parser/test/fixtures/es2015/identifiers/invalid-escape-seq-import/options.json +++ b/packages/babel-parser/test/fixtures/es2015/identifiers/invalid-escape-seq-import/options.json @@ -1,3 +1,3 @@ { - "throws": "Escape sequence in keyword import (1:40)" -} + "sourceType": "module" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/identifiers/invalid-escape-seq-import/output.json b/packages/babel-parser/test/fixtures/es2015/identifiers/invalid-escape-seq-import/output.json new file mode 100644 index 000000000000..8842ac412ce6 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/identifiers/invalid-escape-seq-import/output.json @@ -0,0 +1,146 @@ +{ + "type": "File", + "start": 0, + "end": 90, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 41 + } + }, + "errors": [ + "SyntaxError: Unexpected keyword 'import' (1:4)", + "SyntaxError: Escape sequence in keyword import (1:4)", + "SyntaxError: Escape sequence in keyword import (3:0)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 90, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 41 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "VariableDeclaration", + "start": 0, + "end": 47, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 47 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 4, + "end": 46, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 46 + } + }, + "id": { + "type": "Identifier", + "start": 4, + "end": 40, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 40 + }, + "identifierName": "import" + }, + "name": "import" + }, + "init": { + "type": "NumericLiteral", + "start": 43, + "end": 46, + "loc": { + "start": { + "line": 1, + "column": 43 + }, + "end": { + "line": 1, + "column": 46 + } + }, + "extra": { + "rawValue": 123, + "raw": "123" + }, + "value": 123 + } + } + ], + "kind": "var" + }, + { + "type": "ImportDeclaration", + "start": 49, + "end": 90, + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 41 + } + }, + "specifiers": [], + "source": { + "type": "StringLiteral", + "start": 86, + "end": 89, + "loc": { + "start": { + "line": 3, + "column": 37 + }, + "end": { + "line": 3, + "column": 40 + } + }, + "extra": { + "rawValue": "x", + "raw": "\"x\"" + }, + "value": "x" + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/identifiers/invalid-escape-seq-null/options.json b/packages/babel-parser/test/fixtures/es2015/identifiers/invalid-escape-seq-null/options.json deleted file mode 100644 index 34db9f6413ed..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/identifiers/invalid-escape-seq-null/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Escape sequence in keyword null (1:9)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/identifiers/invalid-escape-seq-null/output.json b/packages/babel-parser/test/fixtures/es2015/identifiers/invalid-escape-seq-null/output.json new file mode 100644 index 000000000000..17c1ae03468e --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/identifiers/invalid-escape-seq-null/output.json @@ -0,0 +1,68 @@ +{ + "type": "File", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "errors": [ + "SyntaxError: Escape sequence in keyword null (1:0)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "expression": { + "type": "NullLiteral", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/identifiers/invalid-escape-seq-true/options.json b/packages/babel-parser/test/fixtures/es2015/identifiers/invalid-escape-seq-true/options.json deleted file mode 100644 index c1c2620da097..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/identifiers/invalid-escape-seq-true/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Escape sequence in keyword true (1:9)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/identifiers/invalid-escape-seq-true/output.json b/packages/babel-parser/test/fixtures/es2015/identifiers/invalid-escape-seq-true/output.json new file mode 100644 index 000000000000..609a782c235a --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/identifiers/invalid-escape-seq-true/output.json @@ -0,0 +1,69 @@ +{ + "type": "File", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "errors": [ + "SyntaxError: Escape sequence in keyword true (1:0)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "expression": { + "type": "BooleanLiteral", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "value": true + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/let/let-as-identifier-strict-fail/options.json b/packages/babel-parser/test/fixtures/es2015/let/let-as-identifier-strict-fail/options.json deleted file mode 100644 index ab238c8bbff9..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/let/let-as-identifier-strict-fail/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Unexpected reserved word 'let' (2:0)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/let/let-as-identifier-strict-fail/output.json b/packages/babel-parser/test/fixtures/es2015/let/let-as-identifier-strict-fail/output.json new file mode 100644 index 000000000000..85fa32674b37 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/let/let-as-identifier-strict-fail/output.json @@ -0,0 +1,142 @@ +{ + "type": "File", + "start": 0, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 7 + } + }, + "errors": [ + "SyntaxError: Unexpected reserved word 'let' (2:0)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 7 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 14, + "end": 21, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 7 + } + }, + "expression": { + "type": "BinaryExpression", + "start": 14, + "end": 21, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 7 + } + }, + "left": { + "type": "Identifier", + "start": 14, + "end": 17, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 3 + }, + "identifierName": "let" + }, + "name": "let" + }, + "operator": "+", + "right": { + "type": "NumericLiteral", + "start": 20, + "end": 21, + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 7 + } + }, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + } + } + } + ], + "directives": [ + { + "type": "Directive", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 0, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "value": "use strict", + "extra": { + "raw": "\"use strict\"", + "rawValue": "use strict" + } + } + } + ] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/let/let-at-binding-list-fail-1/options.json b/packages/babel-parser/test/fixtures/es2015/let/let-at-binding-list-fail-1/options.json deleted file mode 100644 index 75f41b260f56..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/let/let-at-binding-list-fail-1/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "'let' is not allowed to be used as a name in 'let' or 'const' declarations. (1:6)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/let/let-at-binding-list-fail-1/output.json b/packages/babel-parser/test/fixtures/es2015/let/let-at-binding-list-fail-1/output.json new file mode 100644 index 000000000000..e6e2ced3bb0c --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/let/let-at-binding-list-fail-1/output.json @@ -0,0 +1,159 @@ +{ + "type": "File", + "start": 0, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "errors": [ + "SyntaxError: 'let' is not allowed to be used as a name in 'let' or 'const' declarations. (1:6)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "VariableDeclaration", + "start": 0, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 4, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "id": { + "type": "ObjectPattern", + "start": 4, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "properties": [ + { + "type": "ObjectProperty", + "start": 6, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "method": false, + "key": { + "type": "Identifier", + "start": 6, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 9 + }, + "identifierName": "let" + }, + "name": "let" + }, + "computed": false, + "shorthand": true, + "value": { + "type": "Identifier", + "start": 6, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 9 + }, + "identifierName": "let" + }, + "name": "let" + }, + "extra": { + "shorthand": true + } + } + ] + }, + "init": { + "type": "ObjectExpression", + "start": 14, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "properties": [] + } + } + ], + "kind": "let" + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/let/let-at-binding-list-fail-2/options.json b/packages/babel-parser/test/fixtures/es2015/let/let-at-binding-list-fail-2/options.json deleted file mode 100644 index 0a2459ae24fc..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/let/let-at-binding-list-fail-2/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "'let' is not allowed to be used as a name in 'let' or 'const' declarations. (1:8)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/let/let-at-binding-list-fail-2/output.json b/packages/babel-parser/test/fixtures/es2015/let/let-at-binding-list-fail-2/output.json new file mode 100644 index 000000000000..2c3d3871ec80 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/let/let-at-binding-list-fail-2/output.json @@ -0,0 +1,159 @@ +{ + "type": "File", + "start": 0, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "errors": [ + "SyntaxError: 'let' is not allowed to be used as a name in 'let' or 'const' declarations. (1:8)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "VariableDeclaration", + "start": 0, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 6, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "id": { + "type": "ObjectPattern", + "start": 6, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "properties": [ + { + "type": "ObjectProperty", + "start": 8, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "method": false, + "key": { + "type": "Identifier", + "start": 8, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 11 + }, + "identifierName": "let" + }, + "name": "let" + }, + "computed": false, + "shorthand": true, + "value": { + "type": "Identifier", + "start": 8, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 11 + }, + "identifierName": "let" + }, + "name": "let" + }, + "extra": { + "shorthand": true + } + } + ] + }, + "init": { + "type": "ObjectExpression", + "start": 16, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "properties": [] + } + } + ], + "kind": "const" + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/let/let-at-binding-list-fail-3/options.json b/packages/babel-parser/test/fixtures/es2015/let/let-at-binding-list-fail-3/options.json deleted file mode 100644 index 80b209cf3816..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/let/let-at-binding-list-fail-3/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "'let' is not allowed to be used as a name in 'let' or 'const' declarations. (1:5)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/let/let-at-binding-list-fail-3/output.json b/packages/babel-parser/test/fixtures/es2015/let/let-at-binding-list-fail-3/output.json new file mode 100644 index 000000000000..4354932c617c --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/let/let-at-binding-list-fail-3/output.json @@ -0,0 +1,121 @@ +{ + "type": "File", + "start": 0, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "errors": [ + "SyntaxError: 'let' is not allowed to be used as a name in 'let' or 'const' declarations. (1:5)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "VariableDeclaration", + "start": 0, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 4, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "id": { + "type": "ArrayPattern", + "start": 4, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "elements": [ + { + "type": "Identifier", + "start": 5, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 8 + }, + "identifierName": "let" + }, + "name": "let" + } + ] + }, + "init": { + "type": "ArrayExpression", + "start": 12, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "elements": [] + } + } + ], + "kind": "let" + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/let/let-at-binding-list-fail-4/options.json b/packages/babel-parser/test/fixtures/es2015/let/let-at-binding-list-fail-4/options.json deleted file mode 100644 index ccbcbd4b6bbc..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/let/let-at-binding-list-fail-4/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "'let' is not allowed to be used as a name in 'let' or 'const' declarations. (1:7)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/let/let-at-binding-list-fail-4/output.json b/packages/babel-parser/test/fixtures/es2015/let/let-at-binding-list-fail-4/output.json new file mode 100644 index 000000000000..720c37df7a15 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/let/let-at-binding-list-fail-4/output.json @@ -0,0 +1,121 @@ +{ + "type": "File", + "start": 0, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "errors": [ + "SyntaxError: 'let' is not allowed to be used as a name in 'let' or 'const' declarations. (1:7)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "VariableDeclaration", + "start": 0, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 6, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "id": { + "type": "ArrayPattern", + "start": 6, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "elements": [ + { + "type": "Identifier", + "start": 7, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 10 + }, + "identifierName": "let" + }, + "name": "let" + } + ] + }, + "init": { + "type": "ArrayExpression", + "start": 14, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "elements": [] + } + } + ], + "kind": "const" + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/let/let-at-binding-list-fail-5/options.json b/packages/babel-parser/test/fixtures/es2015/let/let-at-binding-list-fail-5/options.json deleted file mode 100644 index 6152a659dcca..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/let/let-at-binding-list-fail-5/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "'let' is not allowed to be used as a name in 'let' or 'const' declarations. (1:4)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/let/let-at-binding-list-fail-5/output.json b/packages/babel-parser/test/fixtures/es2015/let/let-at-binding-list-fail-5/output.json new file mode 100644 index 000000000000..93d70aa80f8b --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/let/let-at-binding-list-fail-5/output.json @@ -0,0 +1,89 @@ +{ + "type": "File", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "errors": [ + "SyntaxError: 'let' is not allowed to be used as a name in 'let' or 'const' declarations. (1:4)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "VariableDeclaration", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 4, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "id": { + "type": "Identifier", + "start": 4, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 7 + }, + "identifierName": "let" + }, + "name": "let" + }, + "init": null + } + ], + "kind": "let" + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/let/let-at-binding-list-fail-6/options.json b/packages/babel-parser/test/fixtures/es2015/let/let-at-binding-list-fail-6/options.json deleted file mode 100644 index 75f41b260f56..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/let/let-at-binding-list-fail-6/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "'let' is not allowed to be used as a name in 'let' or 'const' declarations. (1:6)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/let/let-at-binding-list-fail-6/output.json b/packages/babel-parser/test/fixtures/es2015/let/let-at-binding-list-fail-6/output.json new file mode 100644 index 000000000000..77846750f6ed --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/let/let-at-binding-list-fail-6/output.json @@ -0,0 +1,108 @@ +{ + "type": "File", + "start": 0, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "errors": [ + "SyntaxError: 'let' is not allowed to be used as a name in 'let' or 'const' declarations. (1:6)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "VariableDeclaration", + "start": 0, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 6, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "id": { + "type": "Identifier", + "start": 6, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 9 + }, + "identifierName": "let" + }, + "name": "let" + }, + "init": { + "type": "StringLiteral", + "start": 12, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "extra": { + "rawValue": "", + "raw": "''" + }, + "value": "" + } + } + ], + "kind": "const" + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/let/let-at-catch-block/options.json b/packages/babel-parser/test/fixtures/es2015/let/let-at-catch-block/options.json deleted file mode 100644 index 2c54a7452db9..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/let/let-at-catch-block/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "'let' is not allowed to be used as a name in 'let' or 'const' declarations. (2:6)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/let/let-at-catch-block/output.json b/packages/babel-parser/test/fixtures/es2015/let/let-at-catch-block/output.json new file mode 100644 index 000000000000..ecd45f67f5c5 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/let/let-at-catch-block/output.json @@ -0,0 +1,172 @@ +{ + "type": "File", + "start": 0, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "errors": [ + "SyntaxError: 'let' is not allowed to be used as a name in 'let' or 'const' declarations. (2:6)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "TryStatement", + "start": 0, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "block": { + "type": "BlockStatement", + "start": 4, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "body": [], + "directives": [] + }, + "handler": { + "type": "CatchClause", + "start": 7, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "param": { + "type": "Identifier", + "start": 14, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 17 + }, + "identifierName": "err" + }, + "name": "err" + }, + "body": { + "type": "BlockStatement", + "start": 19, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "body": [ + { + "type": "VariableDeclaration", + "start": 23, + "end": 31, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 10 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 27, + "end": 30, + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 9 + } + }, + "id": { + "type": "Identifier", + "start": 27, + "end": 30, + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 9 + }, + "identifierName": "let" + }, + "name": "let" + }, + "init": null + } + ], + "kind": "let" + } + ], + "directives": [] + } + }, + "finalizer": null + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/meta-properties/invalid-arrow-function/options.json b/packages/babel-parser/test/fixtures/es2015/meta-properties/invalid-arrow-function/options.json deleted file mode 100644 index 4931a93f395d..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/meta-properties/invalid-arrow-function/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "new.target can only be used in functions (2:2)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/meta-properties/invalid-arrow-function/output.json b/packages/babel-parser/test/fixtures/es2015/meta-properties/invalid-arrow-function/output.json new file mode 100644 index 000000000000..64d4a8d35758 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/meta-properties/invalid-arrow-function/output.json @@ -0,0 +1,189 @@ +{ + "type": "File", + "start": 0, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "errors": [ + "SyntaxError: new.target can only be used in functions (2:2)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "VariableDeclaration", + "start": 0, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 6, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 6, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + }, + "identifierName": "A" + }, + "name": "A" + }, + "init": { + "type": "ArrowFunctionExpression", + "start": 10, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "id": null, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 16, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 20, + "end": 31, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 13 + } + }, + "expression": { + "type": "MetaProperty", + "start": 20, + "end": 30, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 12 + } + }, + "meta": { + "type": "Identifier", + "start": 20, + "end": 23, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 5 + }, + "identifierName": "new" + }, + "name": "new" + }, + "property": { + "type": "Identifier", + "start": 24, + "end": 30, + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 12 + }, + "identifierName": "target" + }, + "name": "target" + } + } + } + ], + "directives": [] + } + } + } + ], + "kind": "const" + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/meta-properties/new-invalid-prop/input.js b/packages/babel-parser/test/fixtures/es2015/meta-properties/new-invalid-prop/input.js index d775807ddef1..1f159ebd65d2 100644 --- a/packages/babel-parser/test/fixtures/es2015/meta-properties/new-invalid-prop/input.js +++ b/packages/babel-parser/test/fixtures/es2015/meta-properties/new-invalid-prop/input.js @@ -1 +1,3 @@ -new.prop \ No newline at end of file +function f() { + new.prop +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/meta-properties/new-invalid-prop/options.json b/packages/babel-parser/test/fixtures/es2015/meta-properties/new-invalid-prop/options.json deleted file mode 100644 index 8a88f91714d0..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/meta-properties/new-invalid-prop/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "The only valid meta property for new is new.target (1:4)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/meta-properties/new-invalid-prop/output.json b/packages/babel-parser/test/fixtures/es2015/meta-properties/new-invalid-prop/output.json new file mode 100644 index 000000000000..214b3e5417fe --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/meta-properties/new-invalid-prop/output.json @@ -0,0 +1,155 @@ +{ + "type": "File", + "start": 0, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "errors": [ + "SyntaxError: The only valid meta property for new is new.target (2:6)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 10 + }, + "identifierName": "f" + }, + "name": "f" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 13, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 17, + "end": 25, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 10 + } + }, + "expression": { + "type": "MetaProperty", + "start": 17, + "end": 25, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 10 + } + }, + "meta": { + "type": "Identifier", + "start": 17, + "end": 20, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 5 + }, + "identifierName": "new" + }, + "name": "new" + }, + "property": { + "type": "Identifier", + "start": 21, + "end": 25, + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 10 + }, + "identifierName": "prop" + }, + "name": "prop" + } + } + } + ], + "directives": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/meta-properties/new-target-invalid-escaped-new/options.json b/packages/babel-parser/test/fixtures/es2015/meta-properties/new-target-invalid-escaped-new/options.json deleted file mode 100644 index 112b0adc3e61..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/meta-properties/new-target-invalid-escaped-new/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Escape sequence in keyword new (1:23)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/meta-properties/new-target-invalid-escaped-new/output.json b/packages/babel-parser/test/fixtures/es2015/meta-properties/new-target-invalid-escaped-new/output.json new file mode 100644 index 000000000000..1394b19bdb01 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/meta-properties/new-target-invalid-escaped-new/output.json @@ -0,0 +1,155 @@ +{ + "type": "File", + "start": 0, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 33 + } + }, + "errors": [ + "SyntaxError: Escape sequence in keyword new (1:15)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 33 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 33 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 10 + }, + "identifierName": "f" + }, + "name": "f" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 13, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 33 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 15, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "expression": { + "type": "MetaProperty", + "start": 15, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "meta": { + "type": "Identifier", + "start": 15, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 23 + }, + "identifierName": "new" + }, + "name": "new" + }, + "property": { + "type": "Identifier", + "start": 24, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 24 + }, + "end": { + "line": 1, + "column": 30 + }, + "identifierName": "target" + }, + "name": "target" + } + } + } + ], + "directives": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/meta-properties/new-target-invalid-escaped-target/options.json b/packages/babel-parser/test/fixtures/es2015/meta-properties/new-target-invalid-escaped-target/options.json deleted file mode 100644 index 09a27d63dba1..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/meta-properties/new-target-invalid-escaped-target/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "The only valid meta property for new is new.target (1:19)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/meta-properties/new-target-invalid-escaped-target/output.json b/packages/babel-parser/test/fixtures/es2015/meta-properties/new-target-invalid-escaped-target/output.json new file mode 100644 index 000000000000..2fa8e1dd5500 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/meta-properties/new-target-invalid-escaped-target/output.json @@ -0,0 +1,155 @@ +{ + "type": "File", + "start": 0, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 33 + } + }, + "errors": [ + "SyntaxError: The only valid meta property for new is new.target (1:19)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 33 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 33 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 10 + }, + "identifierName": "f" + }, + "name": "f" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 13, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 33 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 15, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "expression": { + "type": "MetaProperty", + "start": 15, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "meta": { + "type": "Identifier", + "start": 15, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 18 + }, + "identifierName": "new" + }, + "name": "new" + }, + "property": { + "type": "Identifier", + "start": 19, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 30 + }, + "identifierName": "target" + }, + "name": "target" + } + } + } + ], + "directives": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/meta-properties/new-target-invalid/options.json b/packages/babel-parser/test/fixtures/es2015/meta-properties/new-target-invalid/options.json deleted file mode 100644 index 092a825444ad..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/meta-properties/new-target-invalid/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "new.target can only be used in functions (1:0)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/meta-properties/new-target-invalid/output.json b/packages/babel-parser/test/fixtures/es2015/meta-properties/new-target-invalid/output.json new file mode 100644 index 000000000000..4283f53e7dea --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/meta-properties/new-target-invalid/output.json @@ -0,0 +1,102 @@ +{ + "type": "File", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "errors": [ + "SyntaxError: new.target can only be used in functions (1:0)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "expression": { + "type": "MetaProperty", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "meta": { + "type": "Identifier", + "start": 0, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 3 + }, + "identifierName": "new" + }, + "name": "new" + }, + "property": { + "type": "Identifier", + "start": 4, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 10 + }, + "identifierName": "target" + }, + "name": "target" + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-export-default-and-export-as-default/options.json b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-export-default-and-export-as-default/options.json index 275e6a57f95f..54925950e059 100644 --- a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-export-default-and-export-as-default/options.json +++ b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-export-default-and-export-as-default/options.json @@ -1,3 +1,3 @@ { - "throws": "Only one default export allowed per module. (2:9)" -} + "sourceType": "module" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-export-default-and-export-as-default/output.json b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-export-default-and-export-as-default/output.json new file mode 100644 index 000000000000..019d83e37ab4 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-export-default-and-export-as-default/output.json @@ -0,0 +1,173 @@ +{ + "type": "File", + "start": 0, + "end": 56, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 26 + } + }, + "errors": [ + "SyntaxError: Only one default export allowed per module. (2:9)", + "SyntaxError: Export 'foo' is not defined (2:9)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 56, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 26 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExportDefaultDeclaration", + "start": 0, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 28 + } + }, + "declaration": { + "type": "FunctionDeclaration", + "start": 15, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 28 + } + }, + "id": null, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 26, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 26 + }, + "end": { + "line": 1, + "column": 28 + } + }, + "body": [], + "directives": [] + } + } + }, + { + "type": "EmptyStatement", + "start": 28, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 28 + }, + "end": { + "line": 1, + "column": 29 + } + } + }, + { + "type": "ExportNamedDeclaration", + "start": 30, + "end": 56, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 26 + } + }, + "specifiers": [ + { + "type": "ExportSpecifier", + "start": 39, + "end": 53, + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 23 + } + }, + "local": { + "type": "Identifier", + "start": 39, + "end": 42, + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 12 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "exported": { + "type": "Identifier", + "start": 46, + "end": 53, + "loc": { + "start": { + "line": 2, + "column": 16 + }, + "end": { + "line": 2, + "column": 23 + }, + "identifierName": "default" + }, + "name": "default" + } + } + ], + "source": null, + "declaration": null + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-export-default/options.json b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-export-default/options.json index 1ec6a5168f14..54925950e059 100644 --- a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-export-default/options.json +++ b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-export-default/options.json @@ -1,3 +1,3 @@ { - "throws": "Only one default export allowed per module. (2:0)" -} + "sourceType": "module" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-export-default/output.json b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-export-default/output.json new file mode 100644 index 000000000000..d8e83bc56d6e --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-export-default/output.json @@ -0,0 +1,135 @@ +{ + "type": "File", + "start": 0, + "end": 48, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 29 + } + }, + "errors": [ + "SyntaxError: Only one default export allowed per module. (2:0)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 48, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 29 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExportDefaultDeclaration", + "start": 0, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "declaration": { + "type": "ObjectExpression", + "start": 15, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "properties": [] + } + }, + { + "type": "ExportDefaultDeclaration", + "start": 19, + "end": 47, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 28 + } + }, + "declaration": { + "type": "FunctionDeclaration", + "start": 34, + "end": 47, + "loc": { + "start": { + "line": 2, + "column": 15 + }, + "end": { + "line": 2, + "column": 28 + } + }, + "id": null, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 45, + "end": 47, + "loc": { + "start": { + "line": 2, + "column": 26 + }, + "end": { + "line": 2, + "column": 28 + } + }, + "body": [], + "directives": [] + } + } + }, + { + "type": "EmptyStatement", + "start": 47, + "end": 48, + "loc": { + "start": { + "line": 2, + "column": 28 + }, + "end": { + "line": 2, + "column": 29 + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-class-declaration/options.json b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-class-declaration/options.json index 3bdafe893282..54925950e059 100644 --- a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-class-declaration/options.json +++ b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-class-declaration/options.json @@ -1,3 +1,3 @@ { - "throws": "`Foo` has already been exported. Exported identifiers must be unique. (2:0)" -} + "sourceType": "module" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-class-declaration/output.json b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-class-declaration/output.json new file mode 100644 index 000000000000..cf1a59d2669e --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-class-declaration/output.json @@ -0,0 +1,187 @@ +{ + "type": "File", + "start": 0, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 20 + } + }, + "errors": [ + "SyntaxError: `Foo` has already been exported. Exported identifiers must be unique. (2:0)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 20 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExportNamedDeclaration", + "start": 0, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "specifiers": [ + { + "type": "ExportSpecifier", + "start": 9, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "local": { + "type": "Identifier", + "start": 9, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 12 + }, + "identifierName": "Foo" + }, + "name": "Foo" + }, + "exported": { + "type": "Identifier", + "start": 9, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 12 + }, + "identifierName": "Foo" + }, + "name": "Foo" + } + } + ], + "source": null, + "declaration": null + }, + { + "type": "ExportNamedDeclaration", + "start": 16, + "end": 35, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 19 + } + }, + "specifiers": [], + "source": null, + "declaration": { + "type": "ClassDeclaration", + "start": 23, + "end": 35, + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 2, + "column": 19 + } + }, + "id": { + "type": "Identifier", + "start": 29, + "end": 32, + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 16 + }, + "identifierName": "Foo" + }, + "name": "Foo" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "start": 33, + "end": 35, + "loc": { + "start": { + "line": 2, + "column": 17 + }, + "end": { + "line": 2, + "column": 19 + } + }, + "body": [] + } + } + }, + { + "type": "EmptyStatement", + "start": 35, + "end": 36, + "loc": { + "start": { + "line": 2, + "column": 19 + }, + "end": { + "line": 2, + "column": 20 + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring-assignment/options.json b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring-assignment/options.json index ea1f7f46f967..54925950e059 100644 --- a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring-assignment/options.json +++ b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring-assignment/options.json @@ -1,4 +1,3 @@ { - "sourceType": "module", - "throws": "`foo` has already been exported. Exported identifiers must be unique. (2:15)" -} + "sourceType": "module" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring-assignment/output.json b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring-assignment/output.json new file mode 100644 index 000000000000..ae3e358fbe8c --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring-assignment/output.json @@ -0,0 +1,280 @@ +{ + "type": "File", + "start": 0, + "end": 47, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 31 + } + }, + "errors": [ + "SyntaxError: `foo` has already been exported. Exported identifiers must be unique. (2:15)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 47, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 31 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExportNamedDeclaration", + "start": 0, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "specifiers": [ + { + "type": "ExportSpecifier", + "start": 9, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "local": { + "type": "Identifier", + "start": 9, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 12 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "exported": { + "type": "Identifier", + "start": 9, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 12 + }, + "identifierName": "foo" + }, + "name": "foo" + } + } + ], + "source": null, + "declaration": null + }, + { + "type": "ExportNamedDeclaration", + "start": 16, + "end": 47, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 31 + } + }, + "specifiers": [], + "source": null, + "declaration": { + "type": "VariableDeclaration", + "start": 23, + "end": 47, + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 2, + "column": 31 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 29, + "end": 46, + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 30 + } + }, + "id": { + "type": "ObjectPattern", + "start": 29, + "end": 40, + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 24 + } + }, + "properties": [ + { + "type": "ObjectProperty", + "start": 31, + "end": 38, + "loc": { + "start": { + "line": 2, + "column": 15 + }, + "end": { + "line": 2, + "column": 22 + } + }, + "method": false, + "key": { + "type": "Identifier", + "start": 31, + "end": 34, + "loc": { + "start": { + "line": 2, + "column": 15 + }, + "end": { + "line": 2, + "column": 18 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "computed": false, + "shorthand": true, + "value": { + "type": "AssignmentPattern", + "start": 31, + "end": 38, + "loc": { + "start": { + "line": 2, + "column": 15 + }, + "end": { + "line": 2, + "column": 22 + } + }, + "left": { + "type": "Identifier", + "start": 31, + "end": 34, + "loc": { + "start": { + "line": 2, + "column": 15 + }, + "end": { + "line": 2, + "column": 18 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "right": { + "type": "NumericLiteral", + "start": 37, + "end": 38, + "loc": { + "start": { + "line": 2, + "column": 21 + }, + "end": { + "line": 2, + "column": 22 + } + }, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + } + }, + "extra": { + "shorthand": true + } + } + ] + }, + "init": { + "type": "Identifier", + "start": 43, + "end": 46, + "loc": { + "start": { + "line": 2, + "column": 27 + }, + "end": { + "line": 2, + "column": 30 + }, + "identifierName": "bar" + }, + "name": "bar" + } + } + ], + "kind": "const" + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring10/options.json b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring10/options.json deleted file mode 100644 index 446a980f5409..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring10/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Identifier 'foo' has already been declared (2:20)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring10/output.json b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring10/output.json new file mode 100644 index 000000000000..ba018d66dfd9 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring10/output.json @@ -0,0 +1,331 @@ +{ + "type": "File", + "start": 0, + "end": 60, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 34 + } + }, + "errors": [ + "SyntaxError: Identifier 'foo' has already been declared (2:20)", + "SyntaxError: `foo` has already been exported. Exported identifiers must be unique. (2:20)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 60, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 34 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExportNamedDeclaration", + "start": 0, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "specifiers": [], + "source": null, + "declaration": { + "type": "FunctionDeclaration", + "start": 7, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "id": { + "type": "Identifier", + "start": 16, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 19 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 22, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 22 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "body": [], + "directives": [] + } + } + }, + { + "type": "EmptyStatement", + "start": 24, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 24 + }, + "end": { + "line": 1, + "column": 25 + } + } + }, + { + "type": "ExportNamedDeclaration", + "start": 26, + "end": 60, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 34 + } + }, + "specifiers": [], + "source": null, + "declaration": { + "type": "VariableDeclaration", + "start": 33, + "end": 60, + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 2, + "column": 34 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 39, + "end": 59, + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 33 + } + }, + "id": { + "type": "ObjectPattern", + "start": 39, + "end": 53, + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 27 + } + }, + "properties": [ + { + "type": "ObjectProperty", + "start": 41, + "end": 51, + "loc": { + "start": { + "line": 2, + "column": 15 + }, + "end": { + "line": 2, + "column": 25 + } + }, + "method": false, + "key": { + "type": "Identifier", + "start": 41, + "end": 42, + "loc": { + "start": { + "line": 2, + "column": 15 + }, + "end": { + "line": 2, + "column": 16 + }, + "identifierName": "a" + }, + "name": "a" + }, + "computed": false, + "shorthand": false, + "value": { + "type": "ArrayPattern", + "start": 44, + "end": 51, + "loc": { + "start": { + "line": 2, + "column": 18 + }, + "end": { + "line": 2, + "column": 25 + } + }, + "elements": [ + { + "type": "ObjectPattern", + "start": 45, + "end": 50, + "loc": { + "start": { + "line": 2, + "column": 19 + }, + "end": { + "line": 2, + "column": 24 + } + }, + "properties": [ + { + "type": "ObjectProperty", + "start": 46, + "end": 49, + "loc": { + "start": { + "line": 2, + "column": 20 + }, + "end": { + "line": 2, + "column": 23 + } + }, + "method": false, + "key": { + "type": "Identifier", + "start": 46, + "end": 49, + "loc": { + "start": { + "line": 2, + "column": 20 + }, + "end": { + "line": 2, + "column": 23 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "computed": false, + "shorthand": true, + "value": { + "type": "Identifier", + "start": 46, + "end": 49, + "loc": { + "start": { + "line": 2, + "column": 20 + }, + "end": { + "line": 2, + "column": 23 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "extra": { + "shorthand": true + } + } + ] + } + ] + } + } + ] + }, + "init": { + "type": "Identifier", + "start": 56, + "end": 59, + "loc": { + "start": { + "line": 2, + "column": 30 + }, + "end": { + "line": 2, + "column": 33 + }, + "identifierName": "bar" + }, + "name": "bar" + } + } + ], + "kind": "const" + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring11/options.json b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring11/options.json deleted file mode 100644 index 09b3fa97a0d1..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring11/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Identifier 'foo4' has already been declared (2:50)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring11/output.json b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring11/output.json new file mode 100644 index 000000000000..853a21053688 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring11/output.json @@ -0,0 +1,521 @@ +{ + "type": "File", + "start": 0, + "end": 96, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 69 + } + }, + "errors": [ + "SyntaxError: Identifier 'foo4' has already been declared (2:50)", + "SyntaxError: `foo4` has already been exported. Exported identifiers must be unique. (2:50)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 96, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 69 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExportNamedDeclaration", + "start": 0, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 25 + } + }, + "specifiers": [], + "source": null, + "declaration": { + "type": "FunctionDeclaration", + "start": 7, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 25 + } + }, + "id": { + "type": "Identifier", + "start": 16, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 20 + }, + "identifierName": "foo4" + }, + "name": "foo4" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 23, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 23 + }, + "end": { + "line": 1, + "column": 25 + } + }, + "body": [], + "directives": [] + } + } + }, + { + "type": "EmptyStatement", + "start": 25, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 25 + }, + "end": { + "line": 1, + "column": 26 + } + } + }, + { + "type": "ExportNamedDeclaration", + "start": 27, + "end": 96, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 69 + } + }, + "specifiers": [], + "source": null, + "declaration": { + "type": "VariableDeclaration", + "start": 34, + "end": 96, + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 2, + "column": 69 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 40, + "end": 95, + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 68 + } + }, + "id": { + "type": "ArrayPattern", + "start": 40, + "end": 89, + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 62 + } + }, + "elements": [ + { + "type": "ObjectPattern", + "start": 41, + "end": 88, + "loc": { + "start": { + "line": 2, + "column": 14 + }, + "end": { + "line": 2, + "column": 61 + } + }, + "properties": [ + { + "type": "ObjectProperty", + "start": 43, + "end": 55, + "loc": { + "start": { + "line": 2, + "column": 16 + }, + "end": { + "line": 2, + "column": 28 + } + }, + "method": false, + "key": { + "type": "Identifier", + "start": 43, + "end": 44, + "loc": { + "start": { + "line": 2, + "column": 16 + }, + "end": { + "line": 2, + "column": 17 + }, + "identifierName": "a" + }, + "name": "a" + }, + "computed": false, + "shorthand": false, + "value": { + "type": "ArrayPattern", + "start": 46, + "end": 55, + "loc": { + "start": { + "line": 2, + "column": 19 + }, + "end": { + "line": 2, + "column": 28 + } + }, + "elements": [ + { + "type": "ObjectPattern", + "start": 47, + "end": 54, + "loc": { + "start": { + "line": 2, + "column": 20 + }, + "end": { + "line": 2, + "column": 27 + } + }, + "properties": [ + { + "type": "ObjectProperty", + "start": 49, + "end": 52, + "loc": { + "start": { + "line": 2, + "column": 22 + }, + "end": { + "line": 2, + "column": 25 + } + }, + "method": false, + "key": { + "type": "Identifier", + "start": 49, + "end": 52, + "loc": { + "start": { + "line": 2, + "column": 22 + }, + "end": { + "line": 2, + "column": 25 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "computed": false, + "shorthand": true, + "value": { + "type": "Identifier", + "start": 49, + "end": 52, + "loc": { + "start": { + "line": 2, + "column": 22 + }, + "end": { + "line": 2, + "column": 25 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "extra": { + "shorthand": true + } + } + ] + } + ] + } + }, + { + "type": "ObjectProperty", + "start": 57, + "end": 86, + "loc": { + "start": { + "line": 2, + "column": 30 + }, + "end": { + "line": 2, + "column": 59 + } + }, + "method": false, + "key": { + "type": "Identifier", + "start": 57, + "end": 58, + "loc": { + "start": { + "line": 2, + "column": 30 + }, + "end": { + "line": 2, + "column": 31 + }, + "identifierName": "b" + }, + "name": "b" + }, + "computed": false, + "shorthand": false, + "value": { + "type": "ObjectPattern", + "start": 60, + "end": 86, + "loc": { + "start": { + "line": 2, + "column": 33 + }, + "end": { + "line": 2, + "column": 59 + } + }, + "properties": [ + { + "type": "ObjectProperty", + "start": 62, + "end": 84, + "loc": { + "start": { + "line": 2, + "column": 35 + }, + "end": { + "line": 2, + "column": 57 + } + }, + "method": false, + "key": { + "type": "Identifier", + "start": 62, + "end": 66, + "loc": { + "start": { + "line": 2, + "column": 35 + }, + "end": { + "line": 2, + "column": 39 + }, + "identifierName": "foo2" + }, + "name": "foo2" + }, + "computed": false, + "shorthand": false, + "value": { + "type": "ArrayPattern", + "start": 68, + "end": 84, + "loc": { + "start": { + "line": 2, + "column": 41 + }, + "end": { + "line": 2, + "column": 57 + } + }, + "elements": [ + { + "type": "ObjectPattern", + "start": 69, + "end": 83, + "loc": { + "start": { + "line": 2, + "column": 42 + }, + "end": { + "line": 2, + "column": 56 + } + }, + "properties": [ + { + "type": "ObjectProperty", + "start": 71, + "end": 81, + "loc": { + "start": { + "line": 2, + "column": 44 + }, + "end": { + "line": 2, + "column": 54 + } + }, + "method": false, + "key": { + "type": "Identifier", + "start": 71, + "end": 75, + "loc": { + "start": { + "line": 2, + "column": 44 + }, + "end": { + "line": 2, + "column": 48 + }, + "identifierName": "foo3" + }, + "name": "foo3" + }, + "computed": false, + "shorthand": false, + "value": { + "type": "Identifier", + "start": 77, + "end": 81, + "loc": { + "start": { + "line": 2, + "column": 50 + }, + "end": { + "line": 2, + "column": 54 + }, + "identifierName": "foo4" + }, + "name": "foo4" + } + } + ] + } + ] + } + } + ] + } + } + ] + } + ] + }, + "init": { + "type": "Identifier", + "start": 92, + "end": 95, + "loc": { + "start": { + "line": 2, + "column": 65 + }, + "end": { + "line": 2, + "column": 68 + }, + "identifierName": "bar" + }, + "name": "bar" + } + } + ], + "kind": "const" + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring12/options.json b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring12/options.json deleted file mode 100644 index 3a7173c837e3..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring12/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Identifier 'foo4' has already been declared (2:49)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring12/output.json b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring12/output.json new file mode 100644 index 000000000000..9100976f570c --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring12/output.json @@ -0,0 +1,504 @@ +{ + "type": "File", + "start": 0, + "end": 94, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 67 + } + }, + "errors": [ + "SyntaxError: Identifier 'foo4' has already been declared (2:49)", + "SyntaxError: `foo4` has already been exported. Exported identifiers must be unique. (2:49)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 94, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 67 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExportNamedDeclaration", + "start": 0, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 25 + } + }, + "specifiers": [], + "source": null, + "declaration": { + "type": "FunctionDeclaration", + "start": 7, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 25 + } + }, + "id": { + "type": "Identifier", + "start": 16, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 20 + }, + "identifierName": "foo4" + }, + "name": "foo4" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 23, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 23 + }, + "end": { + "line": 1, + "column": 25 + } + }, + "body": [], + "directives": [] + } + } + }, + { + "type": "EmptyStatement", + "start": 25, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 25 + }, + "end": { + "line": 1, + "column": 26 + } + } + }, + { + "type": "ExportNamedDeclaration", + "start": 27, + "end": 94, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 67 + } + }, + "specifiers": [], + "source": null, + "declaration": { + "type": "VariableDeclaration", + "start": 34, + "end": 94, + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 2, + "column": 67 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 40, + "end": 93, + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 66 + } + }, + "id": { + "type": "ObjectPattern", + "start": 40, + "end": 87, + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 60 + } + }, + "properties": [ + { + "type": "ObjectProperty", + "start": 42, + "end": 54, + "loc": { + "start": { + "line": 2, + "column": 15 + }, + "end": { + "line": 2, + "column": 27 + } + }, + "method": false, + "key": { + "type": "Identifier", + "start": 42, + "end": 43, + "loc": { + "start": { + "line": 2, + "column": 15 + }, + "end": { + "line": 2, + "column": 16 + }, + "identifierName": "a" + }, + "name": "a" + }, + "computed": false, + "shorthand": false, + "value": { + "type": "ArrayPattern", + "start": 45, + "end": 54, + "loc": { + "start": { + "line": 2, + "column": 18 + }, + "end": { + "line": 2, + "column": 27 + } + }, + "elements": [ + { + "type": "ObjectPattern", + "start": 46, + "end": 53, + "loc": { + "start": { + "line": 2, + "column": 19 + }, + "end": { + "line": 2, + "column": 26 + } + }, + "properties": [ + { + "type": "ObjectProperty", + "start": 48, + "end": 51, + "loc": { + "start": { + "line": 2, + "column": 21 + }, + "end": { + "line": 2, + "column": 24 + } + }, + "method": false, + "key": { + "type": "Identifier", + "start": 48, + "end": 51, + "loc": { + "start": { + "line": 2, + "column": 21 + }, + "end": { + "line": 2, + "column": 24 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "computed": false, + "shorthand": true, + "value": { + "type": "Identifier", + "start": 48, + "end": 51, + "loc": { + "start": { + "line": 2, + "column": 21 + }, + "end": { + "line": 2, + "column": 24 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "extra": { + "shorthand": true + } + } + ] + } + ] + } + }, + { + "type": "ObjectProperty", + "start": 56, + "end": 85, + "loc": { + "start": { + "line": 2, + "column": 29 + }, + "end": { + "line": 2, + "column": 58 + } + }, + "method": false, + "key": { + "type": "Identifier", + "start": 56, + "end": 57, + "loc": { + "start": { + "line": 2, + "column": 29 + }, + "end": { + "line": 2, + "column": 30 + }, + "identifierName": "b" + }, + "name": "b" + }, + "computed": false, + "shorthand": false, + "value": { + "type": "ObjectPattern", + "start": 59, + "end": 85, + "loc": { + "start": { + "line": 2, + "column": 32 + }, + "end": { + "line": 2, + "column": 58 + } + }, + "properties": [ + { + "type": "ObjectProperty", + "start": 61, + "end": 83, + "loc": { + "start": { + "line": 2, + "column": 34 + }, + "end": { + "line": 2, + "column": 56 + } + }, + "method": false, + "key": { + "type": "Identifier", + "start": 61, + "end": 65, + "loc": { + "start": { + "line": 2, + "column": 34 + }, + "end": { + "line": 2, + "column": 38 + }, + "identifierName": "foo2" + }, + "name": "foo2" + }, + "computed": false, + "shorthand": false, + "value": { + "type": "ArrayPattern", + "start": 67, + "end": 83, + "loc": { + "start": { + "line": 2, + "column": 40 + }, + "end": { + "line": 2, + "column": 56 + } + }, + "elements": [ + { + "type": "ObjectPattern", + "start": 68, + "end": 82, + "loc": { + "start": { + "line": 2, + "column": 41 + }, + "end": { + "line": 2, + "column": 55 + } + }, + "properties": [ + { + "type": "ObjectProperty", + "start": 70, + "end": 80, + "loc": { + "start": { + "line": 2, + "column": 43 + }, + "end": { + "line": 2, + "column": 53 + } + }, + "method": false, + "key": { + "type": "Identifier", + "start": 70, + "end": 74, + "loc": { + "start": { + "line": 2, + "column": 43 + }, + "end": { + "line": 2, + "column": 47 + }, + "identifierName": "foo3" + }, + "name": "foo3" + }, + "computed": false, + "shorthand": false, + "value": { + "type": "Identifier", + "start": 76, + "end": 80, + "loc": { + "start": { + "line": 2, + "column": 49 + }, + "end": { + "line": 2, + "column": 53 + }, + "identifierName": "foo4" + }, + "name": "foo4" + } + } + ] + } + ] + } + } + ] + } + } + ] + }, + "init": { + "type": "Identifier", + "start": 90, + "end": 93, + "loc": { + "start": { + "line": 2, + "column": 63 + }, + "end": { + "line": 2, + "column": 66 + }, + "identifierName": "bar" + }, + "name": "bar" + } + } + ], + "kind": "const" + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring13/options.json b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring13/options.json deleted file mode 100644 index d3fc42a61ba1..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring13/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Identifier 'foo4' has already been declared (2:58)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring13/output.json b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring13/output.json new file mode 100644 index 000000000000..63e32c488670 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring13/output.json @@ -0,0 +1,556 @@ +{ + "type": "File", + "start": 0, + "end": 103, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 76 + } + }, + "errors": [ + "SyntaxError: Identifier 'foo4' has already been declared (2:58)", + "SyntaxError: `foo4` has already been exported. Exported identifiers must be unique. (2:58)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 103, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 76 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExportNamedDeclaration", + "start": 0, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 25 + } + }, + "specifiers": [], + "source": null, + "declaration": { + "type": "FunctionDeclaration", + "start": 7, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 25 + } + }, + "id": { + "type": "Identifier", + "start": 16, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 20 + }, + "identifierName": "foo4" + }, + "name": "foo4" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 23, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 23 + }, + "end": { + "line": 1, + "column": 25 + } + }, + "body": [], + "directives": [] + } + } + }, + { + "type": "EmptyStatement", + "start": 25, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 25 + }, + "end": { + "line": 1, + "column": 26 + } + } + }, + { + "type": "ExportNamedDeclaration", + "start": 27, + "end": 103, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 76 + } + }, + "specifiers": [], + "source": null, + "declaration": { + "type": "VariableDeclaration", + "start": 34, + "end": 103, + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 2, + "column": 76 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 40, + "end": 102, + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 75 + } + }, + "id": { + "type": "ObjectPattern", + "start": 40, + "end": 96, + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 69 + } + }, + "properties": [ + { + "type": "ObjectProperty", + "start": 42, + "end": 60, + "loc": { + "start": { + "line": 2, + "column": 15 + }, + "end": { + "line": 2, + "column": 33 + } + }, + "method": false, + "key": { + "type": "Identifier", + "start": 42, + "end": 43, + "loc": { + "start": { + "line": 2, + "column": 15 + }, + "end": { + "line": 2, + "column": 16 + }, + "identifierName": "a" + }, + "name": "a" + }, + "computed": false, + "shorthand": false, + "value": { + "type": "ArrayPattern", + "start": 45, + "end": 60, + "loc": { + "start": { + "line": 2, + "column": 18 + }, + "end": { + "line": 2, + "column": 33 + } + }, + "elements": [ + { + "type": "ObjectPattern", + "start": 46, + "end": 59, + "loc": { + "start": { + "line": 2, + "column": 19 + }, + "end": { + "line": 2, + "column": 32 + } + }, + "properties": [ + { + "type": "ObjectProperty", + "start": 48, + "end": 57, + "loc": { + "start": { + "line": 2, + "column": 21 + }, + "end": { + "line": 2, + "column": 30 + } + }, + "method": false, + "key": { + "type": "Identifier", + "start": 48, + "end": 52, + "loc": { + "start": { + "line": 2, + "column": 21 + }, + "end": { + "line": 2, + "column": 25 + }, + "identifierName": "foo4" + }, + "name": "foo4" + }, + "computed": false, + "shorthand": false, + "value": { + "type": "Identifier", + "start": 54, + "end": 57, + "loc": { + "start": { + "line": 2, + "column": 27 + }, + "end": { + "line": 2, + "column": 30 + }, + "identifierName": "foo" + }, + "name": "foo" + } + } + ] + } + ] + } + }, + { + "type": "ObjectProperty", + "start": 62, + "end": 63, + "loc": { + "start": { + "line": 2, + "column": 35 + }, + "end": { + "line": 2, + "column": 36 + } + }, + "method": false, + "key": { + "type": "Identifier", + "start": 62, + "end": 63, + "loc": { + "start": { + "line": 2, + "column": 35 + }, + "end": { + "line": 2, + "column": 36 + }, + "identifierName": "b" + }, + "name": "b" + }, + "computed": false, + "shorthand": true, + "value": { + "type": "Identifier", + "start": 62, + "end": 63, + "loc": { + "start": { + "line": 2, + "column": 35 + }, + "end": { + "line": 2, + "column": 36 + }, + "identifierName": "b" + }, + "name": "b" + }, + "extra": { + "shorthand": true + } + }, + { + "type": "ObjectProperty", + "start": 65, + "end": 94, + "loc": { + "start": { + "line": 2, + "column": 38 + }, + "end": { + "line": 2, + "column": 67 + } + }, + "method": false, + "key": { + "type": "Identifier", + "start": 65, + "end": 66, + "loc": { + "start": { + "line": 2, + "column": 38 + }, + "end": { + "line": 2, + "column": 39 + }, + "identifierName": "c" + }, + "name": "c" + }, + "computed": false, + "shorthand": false, + "value": { + "type": "ObjectPattern", + "start": 68, + "end": 94, + "loc": { + "start": { + "line": 2, + "column": 41 + }, + "end": { + "line": 2, + "column": 67 + } + }, + "properties": [ + { + "type": "ObjectProperty", + "start": 70, + "end": 92, + "loc": { + "start": { + "line": 2, + "column": 43 + }, + "end": { + "line": 2, + "column": 65 + } + }, + "method": false, + "key": { + "type": "Identifier", + "start": 70, + "end": 74, + "loc": { + "start": { + "line": 2, + "column": 43 + }, + "end": { + "line": 2, + "column": 47 + }, + "identifierName": "foo2" + }, + "name": "foo2" + }, + "computed": false, + "shorthand": false, + "value": { + "type": "ArrayPattern", + "start": 76, + "end": 92, + "loc": { + "start": { + "line": 2, + "column": 49 + }, + "end": { + "line": 2, + "column": 65 + } + }, + "elements": [ + { + "type": "ObjectPattern", + "start": 77, + "end": 91, + "loc": { + "start": { + "line": 2, + "column": 50 + }, + "end": { + "line": 2, + "column": 64 + } + }, + "properties": [ + { + "type": "ObjectProperty", + "start": 79, + "end": 89, + "loc": { + "start": { + "line": 2, + "column": 52 + }, + "end": { + "line": 2, + "column": 62 + } + }, + "method": false, + "key": { + "type": "Identifier", + "start": 79, + "end": 83, + "loc": { + "start": { + "line": 2, + "column": 52 + }, + "end": { + "line": 2, + "column": 56 + }, + "identifierName": "foo3" + }, + "name": "foo3" + }, + "computed": false, + "shorthand": false, + "value": { + "type": "Identifier", + "start": 85, + "end": 89, + "loc": { + "start": { + "line": 2, + "column": 58 + }, + "end": { + "line": 2, + "column": 62 + }, + "identifierName": "foo4" + }, + "name": "foo4" + } + } + ] + } + ] + } + } + ] + } + } + ] + }, + "init": { + "type": "Identifier", + "start": 99, + "end": 102, + "loc": { + "start": { + "line": 2, + "column": 72 + }, + "end": { + "line": 2, + "column": 75 + }, + "identifierName": "bar" + }, + "name": "bar" + } + } + ], + "kind": "const" + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring14/options.json b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring14/options.json deleted file mode 100644 index 80640e0ce127..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring14/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Identifier 'foo' has already been declared (2:21)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring14/output.json b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring14/output.json new file mode 100644 index 000000000000..1d699b58133a --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring14/output.json @@ -0,0 +1,262 @@ +{ + "type": "File", + "start": 0, + "end": 55, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 33 + } + }, + "errors": [ + "SyntaxError: Identifier 'foo' has already been declared (2:21)", + "SyntaxError: `foo` has already been exported. Exported identifiers must be unique. (2:21)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 55, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 33 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExportNamedDeclaration", + "start": 0, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "specifiers": [], + "source": null, + "declaration": { + "type": "VariableDeclaration", + "start": 7, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 13, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "id": { + "type": "Identifier", + "start": 13, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 16 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "init": { + "type": "NumericLiteral", + "start": 19, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + } + } + ], + "kind": "const" + } + }, + { + "type": "ExportNamedDeclaration", + "start": 22, + "end": 55, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 33 + } + }, + "specifiers": [], + "source": null, + "declaration": { + "type": "VariableDeclaration", + "start": 29, + "end": 55, + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 2, + "column": 33 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 35, + "end": 54, + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 32 + } + }, + "id": { + "type": "ObjectPattern", + "start": 35, + "end": 48, + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 26 + } + }, + "properties": [ + { + "type": "ObjectProperty", + "start": 37, + "end": 46, + "loc": { + "start": { + "line": 2, + "column": 15 + }, + "end": { + "line": 2, + "column": 24 + } + }, + "method": false, + "key": { + "type": "Identifier", + "start": 37, + "end": 41, + "loc": { + "start": { + "line": 2, + "column": 15 + }, + "end": { + "line": 2, + "column": 19 + }, + "identifierName": "foo2" + }, + "name": "foo2" + }, + "computed": false, + "shorthand": false, + "value": { + "type": "Identifier", + "start": 43, + "end": 46, + "loc": { + "start": { + "line": 2, + "column": 21 + }, + "end": { + "line": 2, + "column": 24 + }, + "identifierName": "foo" + }, + "name": "foo" + } + } + ] + }, + "init": { + "type": "Identifier", + "start": 51, + "end": 54, + "loc": { + "start": { + "line": 2, + "column": 29 + }, + "end": { + "line": 2, + "column": 32 + }, + "identifierName": "bar" + }, + "name": "bar" + } + } + ], + "kind": "const" + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring15/options.json b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring15/options.json deleted file mode 100644 index ea3a9b62f493..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring15/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Identifier 'foo2' has already been declared (2:13)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring15/output.json b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring15/output.json new file mode 100644 index 000000000000..140798f03a2d --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring15/output.json @@ -0,0 +1,262 @@ +{ + "type": "File", + "start": 0, + "end": 56, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 22 + } + }, + "errors": [ + "SyntaxError: Identifier 'foo2' has already been declared (2:13)", + "SyntaxError: `foo2` has already been exported. Exported identifiers must be unique. (2:13)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 56, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 22 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExportNamedDeclaration", + "start": 0, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 33 + } + }, + "specifiers": [], + "source": null, + "declaration": { + "type": "VariableDeclaration", + "start": 7, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 33 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 13, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "id": { + "type": "ObjectPattern", + "start": 13, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "properties": [ + { + "type": "ObjectProperty", + "start": 15, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "method": false, + "key": { + "type": "Identifier", + "start": 15, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 18 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "computed": false, + "shorthand": false, + "value": { + "type": "Identifier", + "start": 20, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 20 + }, + "end": { + "line": 1, + "column": 24 + }, + "identifierName": "foo2" + }, + "name": "foo2" + } + } + ] + }, + "init": { + "type": "Identifier", + "start": 29, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 29 + }, + "end": { + "line": 1, + "column": 32 + }, + "identifierName": "bar" + }, + "name": "bar" + } + } + ], + "kind": "const" + } + }, + { + "type": "ExportNamedDeclaration", + "start": 34, + "end": 56, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 22 + } + }, + "specifiers": [], + "source": null, + "declaration": { + "type": "VariableDeclaration", + "start": 41, + "end": 56, + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 2, + "column": 22 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 47, + "end": 55, + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 21 + } + }, + "id": { + "type": "Identifier", + "start": 47, + "end": 51, + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 17 + }, + "identifierName": "foo2" + }, + "name": "foo2" + }, + "init": { + "type": "NumericLiteral", + "start": 54, + "end": 55, + "loc": { + "start": { + "line": 2, + "column": 20 + }, + "end": { + "line": 2, + "column": 21 + } + }, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + } + } + ], + "kind": "const" + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring16/options.json b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring16/options.json deleted file mode 100644 index 42c862ad273a..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring16/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Identifier 'foo' has already been declared (2:22)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring16/output.json b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring16/output.json new file mode 100644 index 000000000000..d51c3a34e349 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring16/output.json @@ -0,0 +1,259 @@ +{ + "type": "File", + "start": 0, + "end": 55, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 33 + } + }, + "errors": [ + "SyntaxError: Identifier 'foo' has already been declared (2:22)", + "SyntaxError: `foo` has already been exported. Exported identifiers must be unique. (2:22)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 55, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 33 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExportNamedDeclaration", + "start": 0, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "specifiers": [], + "source": null, + "declaration": { + "type": "VariableDeclaration", + "start": 7, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 13, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "id": { + "type": "Identifier", + "start": 13, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 16 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "init": { + "type": "NumericLiteral", + "start": 19, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + } + } + ], + "kind": "const" + } + }, + { + "type": "ExportNamedDeclaration", + "start": 22, + "end": 55, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 33 + } + }, + "specifiers": [], + "source": null, + "declaration": { + "type": "VariableDeclaration", + "start": 29, + "end": 55, + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 2, + "column": 33 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 35, + "end": 54, + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 32 + } + }, + "id": { + "type": "ArrayPattern", + "start": 35, + "end": 48, + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 26 + } + }, + "elements": [ + { + "type": "Identifier", + "start": 36, + "end": 39, + "loc": { + "start": { + "line": 2, + "column": 14 + }, + "end": { + "line": 2, + "column": 17 + }, + "identifierName": "bar" + }, + "name": "bar" + }, + { + "type": "RestElement", + "start": 41, + "end": 47, + "loc": { + "start": { + "line": 2, + "column": 19 + }, + "end": { + "line": 2, + "column": 25 + } + }, + "argument": { + "type": "Identifier", + "start": 44, + "end": 47, + "loc": { + "start": { + "line": 2, + "column": 22 + }, + "end": { + "line": 2, + "column": 25 + }, + "identifierName": "foo" + }, + "name": "foo" + } + } + ] + }, + "init": { + "type": "Identifier", + "start": 51, + "end": 54, + "loc": { + "start": { + "line": 2, + "column": 29 + }, + "end": { + "line": 2, + "column": 32 + }, + "identifierName": "baz" + }, + "name": "baz" + } + } + ], + "kind": "const" + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring17/options.json b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring17/options.json deleted file mode 100644 index 125c2618435d..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring17/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Identifier 'bar' has already been declared (2:13)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring17/output.json b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring17/output.json new file mode 100644 index 000000000000..5d56b3c37e96 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring17/output.json @@ -0,0 +1,259 @@ +{ + "type": "File", + "start": 0, + "end": 55, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 21 + } + }, + "errors": [ + "SyntaxError: Identifier 'bar' has already been declared (2:13)", + "SyntaxError: `bar` has already been exported. Exported identifiers must be unique. (2:13)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 55, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 21 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExportNamedDeclaration", + "start": 0, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 33 + } + }, + "specifiers": [], + "source": null, + "declaration": { + "type": "VariableDeclaration", + "start": 7, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 33 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 13, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "id": { + "type": "ArrayPattern", + "start": 13, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "elements": [ + { + "type": "Identifier", + "start": 14, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 17 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + { + "type": "RestElement", + "start": 19, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 25 + } + }, + "argument": { + "type": "Identifier", + "start": 22, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 22 + }, + "end": { + "line": 1, + "column": 25 + }, + "identifierName": "bar" + }, + "name": "bar" + } + } + ] + }, + "init": { + "type": "Identifier", + "start": 29, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 29 + }, + "end": { + "line": 1, + "column": 32 + }, + "identifierName": "baz" + }, + "name": "baz" + } + } + ], + "kind": "const" + } + }, + { + "type": "ExportNamedDeclaration", + "start": 34, + "end": 55, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 21 + } + }, + "specifiers": [], + "source": null, + "declaration": { + "type": "VariableDeclaration", + "start": 41, + "end": 55, + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 2, + "column": 21 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 47, + "end": 54, + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 20 + } + }, + "id": { + "type": "Identifier", + "start": 47, + "end": 50, + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 16 + }, + "identifierName": "bar" + }, + "name": "bar" + }, + "init": { + "type": "NumericLiteral", + "start": 53, + "end": 54, + "loc": { + "start": { + "line": 2, + "column": 19 + }, + "end": { + "line": 2, + "column": 20 + } + }, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + } + } + ], + "kind": "const" + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring18/options.json b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring18/options.json deleted file mode 100644 index bf345ea77127..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring18/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Identifier 'foo' has already been declared (2:28)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring18/output.json b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring18/output.json new file mode 100644 index 000000000000..0378d078ec4f --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring18/output.json @@ -0,0 +1,293 @@ +{ + "type": "File", + "start": 0, + "end": 62, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 40 + } + }, + "errors": [ + "SyntaxError: Identifier 'foo' has already been declared (2:28)", + "SyntaxError: `foo` has already been exported. Exported identifiers must be unique. (2:28)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 62, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 40 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExportNamedDeclaration", + "start": 0, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "specifiers": [], + "source": null, + "declaration": { + "type": "VariableDeclaration", + "start": 7, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 13, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "id": { + "type": "Identifier", + "start": 13, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 16 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "init": { + "type": "NumericLiteral", + "start": 19, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + } + } + ], + "kind": "const" + } + }, + { + "type": "ExportNamedDeclaration", + "start": 22, + "end": 62, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 40 + } + }, + "specifiers": [], + "source": null, + "declaration": { + "type": "VariableDeclaration", + "start": 29, + "end": 62, + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 2, + "column": 40 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 35, + "end": 61, + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 39 + } + }, + "id": { + "type": "ArrayPattern", + "start": 35, + "end": 55, + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 33 + } + }, + "elements": [ + { + "type": "Identifier", + "start": 36, + "end": 39, + "loc": { + "start": { + "line": 2, + "column": 14 + }, + "end": { + "line": 2, + "column": 17 + }, + "identifierName": "bar" + }, + "name": "bar" + }, + { + "type": "ArrayPattern", + "start": 41, + "end": 54, + "loc": { + "start": { + "line": 2, + "column": 19 + }, + "end": { + "line": 2, + "column": 32 + } + }, + "elements": [ + { + "type": "Identifier", + "start": 42, + "end": 45, + "loc": { + "start": { + "line": 2, + "column": 20 + }, + "end": { + "line": 2, + "column": 23 + }, + "identifierName": "baz" + }, + "name": "baz" + }, + { + "type": "RestElement", + "start": 47, + "end": 53, + "loc": { + "start": { + "line": 2, + "column": 25 + }, + "end": { + "line": 2, + "column": 31 + } + }, + "argument": { + "type": "Identifier", + "start": 50, + "end": 53, + "loc": { + "start": { + "line": 2, + "column": 28 + }, + "end": { + "line": 2, + "column": 31 + }, + "identifierName": "foo" + }, + "name": "foo" + } + } + ] + } + ] + }, + "init": { + "type": "Identifier", + "start": 58, + "end": 61, + "loc": { + "start": { + "line": 2, + "column": 36 + }, + "end": { + "line": 2, + "column": 39 + }, + "identifierName": "qux" + }, + "name": "qux" + } + } + ], + "kind": "const" + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring19/options.json b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring19/options.json deleted file mode 100644 index bf2483362193..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring19/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Identifier 'foo' has already been declared (2:29)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring19/output.json b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring19/output.json new file mode 100644 index 000000000000..e185b7f4186f --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring19/output.json @@ -0,0 +1,311 @@ +{ + "type": "File", + "start": 0, + "end": 64, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 42 + } + }, + "errors": [ + "SyntaxError: Identifier 'foo' has already been declared (2:29)", + "SyntaxError: `foo` has already been exported. Exported identifiers must be unique. (2:29)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 64, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 42 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExportNamedDeclaration", + "start": 0, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "specifiers": [], + "source": null, + "declaration": { + "type": "VariableDeclaration", + "start": 7, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 13, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "id": { + "type": "Identifier", + "start": 13, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 16 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "init": { + "type": "NumericLiteral", + "start": 19, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + } + } + ], + "kind": "const" + } + }, + { + "type": "ExportNamedDeclaration", + "start": 22, + "end": 64, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 42 + } + }, + "specifiers": [], + "source": null, + "declaration": { + "type": "VariableDeclaration", + "start": 29, + "end": 64, + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 2, + "column": 42 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 35, + "end": 63, + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 41 + } + }, + "id": { + "type": "ObjectPattern", + "start": 35, + "end": 57, + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 35 + } + }, + "properties": [ + { + "type": "ObjectProperty", + "start": 37, + "end": 55, + "loc": { + "start": { + "line": 2, + "column": 15 + }, + "end": { + "line": 2, + "column": 33 + } + }, + "method": false, + "key": { + "type": "Identifier", + "start": 37, + "end": 40, + "loc": { + "start": { + "line": 2, + "column": 15 + }, + "end": { + "line": 2, + "column": 18 + }, + "identifierName": "bar" + }, + "name": "bar" + }, + "computed": false, + "shorthand": false, + "value": { + "type": "ArrayPattern", + "start": 42, + "end": 55, + "loc": { + "start": { + "line": 2, + "column": 20 + }, + "end": { + "line": 2, + "column": 33 + } + }, + "elements": [ + { + "type": "Identifier", + "start": 43, + "end": 46, + "loc": { + "start": { + "line": 2, + "column": 21 + }, + "end": { + "line": 2, + "column": 24 + }, + "identifierName": "baz" + }, + "name": "baz" + }, + { + "type": "RestElement", + "start": 48, + "end": 54, + "loc": { + "start": { + "line": 2, + "column": 26 + }, + "end": { + "line": 2, + "column": 32 + } + }, + "argument": { + "type": "Identifier", + "start": 51, + "end": 54, + "loc": { + "start": { + "line": 2, + "column": 29 + }, + "end": { + "line": 2, + "column": 32 + }, + "identifierName": "foo" + }, + "name": "foo" + } + } + ] + } + } + ] + }, + "init": { + "type": "Identifier", + "start": 60, + "end": 63, + "loc": { + "start": { + "line": 2, + "column": 38 + }, + "end": { + "line": 2, + "column": 41 + }, + "identifierName": "qux" + }, + "name": "qux" + } + } + ], + "kind": "const" + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring2/options.json b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring2/options.json deleted file mode 100644 index 2cbe06c40914..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring2/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Identifier 'foo' has already been declared (2:15)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring2/output.json b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring2/output.json new file mode 100644 index 000000000000..8e8c195325fc --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring2/output.json @@ -0,0 +1,262 @@ +{ + "type": "File", + "start": 0, + "end": 53, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 27 + } + }, + "errors": [ + "SyntaxError: Identifier 'foo' has already been declared (2:15)", + "SyntaxError: `foo` has already been exported. Exported identifiers must be unique. (2:15)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 53, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 27 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExportNamedDeclaration", + "start": 0, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "specifiers": [], + "source": null, + "declaration": { + "type": "FunctionDeclaration", + "start": 7, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "id": { + "type": "Identifier", + "start": 16, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 19 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 22, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 22 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "body": [], + "directives": [] + } + } + }, + { + "type": "EmptyStatement", + "start": 24, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 24 + }, + "end": { + "line": 1, + "column": 25 + } + } + }, + { + "type": "ExportNamedDeclaration", + "start": 26, + "end": 53, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 27 + } + }, + "specifiers": [], + "source": null, + "declaration": { + "type": "VariableDeclaration", + "start": 33, + "end": 53, + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 2, + "column": 27 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 39, + "end": 52, + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 26 + } + }, + "id": { + "type": "ObjectPattern", + "start": 39, + "end": 46, + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 20 + } + }, + "properties": [ + { + "type": "ObjectProperty", + "start": 41, + "end": 44, + "loc": { + "start": { + "line": 2, + "column": 15 + }, + "end": { + "line": 2, + "column": 18 + } + }, + "method": false, + "key": { + "type": "Identifier", + "start": 41, + "end": 44, + "loc": { + "start": { + "line": 2, + "column": 15 + }, + "end": { + "line": 2, + "column": 18 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "computed": false, + "shorthand": true, + "value": { + "type": "Identifier", + "start": 41, + "end": 44, + "loc": { + "start": { + "line": 2, + "column": 15 + }, + "end": { + "line": 2, + "column": 18 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "extra": { + "shorthand": true + } + } + ] + }, + "init": { + "type": "Identifier", + "start": 49, + "end": 52, + "loc": { + "start": { + "line": 2, + "column": 23 + }, + "end": { + "line": 2, + "column": 26 + }, + "identifierName": "bar" + }, + "name": "bar" + } + } + ], + "kind": "const" + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring3/options.json b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring3/options.json deleted file mode 100644 index d36390356990..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring3/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Identifier 'foo' has already been declared (2:16)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring3/output.json b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring3/output.json new file mode 100644 index 000000000000..f862a6a420c6 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring3/output.json @@ -0,0 +1,262 @@ +{ + "type": "File", + "start": 0, + "end": 53, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 25 + } + }, + "errors": [ + "SyntaxError: Identifier 'foo' has already been declared (2:16)", + "SyntaxError: `foo` has already been exported. Exported identifiers must be unique. (2:0)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 53, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 25 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExportNamedDeclaration", + "start": 0, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 27 + } + }, + "specifiers": [], + "source": null, + "declaration": { + "type": "VariableDeclaration", + "start": 7, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 27 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 13, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "id": { + "type": "ObjectPattern", + "start": 13, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "properties": [ + { + "type": "ObjectProperty", + "start": 15, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "method": false, + "key": { + "type": "Identifier", + "start": 15, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 18 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "computed": false, + "shorthand": true, + "value": { + "type": "Identifier", + "start": 15, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 18 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "extra": { + "shorthand": true + } + } + ] + }, + "init": { + "type": "Identifier", + "start": 23, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 23 + }, + "end": { + "line": 1, + "column": 26 + }, + "identifierName": "bar" + }, + "name": "bar" + } + } + ], + "kind": "const" + } + }, + { + "type": "ExportNamedDeclaration", + "start": 28, + "end": 52, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 24 + } + }, + "specifiers": [], + "source": null, + "declaration": { + "type": "FunctionDeclaration", + "start": 35, + "end": 52, + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 2, + "column": 24 + } + }, + "id": { + "type": "Identifier", + "start": 44, + "end": 47, + "loc": { + "start": { + "line": 2, + "column": 16 + }, + "end": { + "line": 2, + "column": 19 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 50, + "end": 52, + "loc": { + "start": { + "line": 2, + "column": 22 + }, + "end": { + "line": 2, + "column": 24 + } + }, + "body": [], + "directives": [] + } + } + }, + { + "type": "EmptyStatement", + "start": 52, + "end": 53, + "loc": { + "start": { + "line": 2, + "column": 24 + }, + "end": { + "line": 2, + "column": 25 + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring4/options.json b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring4/options.json deleted file mode 100644 index 46358493589c..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring4/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Identifier 'foo' has already been declared (2:14)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring4/output.json b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring4/output.json new file mode 100644 index 000000000000..401baa93a85a --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring4/output.json @@ -0,0 +1,224 @@ +{ + "type": "File", + "start": 0, + "end": 51, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 25 + } + }, + "errors": [ + "SyntaxError: Identifier 'foo' has already been declared (2:14)", + "SyntaxError: `foo` has already been exported. Exported identifiers must be unique. (2:14)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 51, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 25 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExportNamedDeclaration", + "start": 0, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "specifiers": [], + "source": null, + "declaration": { + "type": "FunctionDeclaration", + "start": 7, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "id": { + "type": "Identifier", + "start": 16, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 19 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 22, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 22 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "body": [], + "directives": [] + } + } + }, + { + "type": "EmptyStatement", + "start": 24, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 24 + }, + "end": { + "line": 1, + "column": 25 + } + } + }, + { + "type": "ExportNamedDeclaration", + "start": 26, + "end": 51, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 25 + } + }, + "specifiers": [], + "source": null, + "declaration": { + "type": "VariableDeclaration", + "start": 33, + "end": 51, + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 2, + "column": 25 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 39, + "end": 50, + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 24 + } + }, + "id": { + "type": "ArrayPattern", + "start": 39, + "end": 44, + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 18 + } + }, + "elements": [ + { + "type": "Identifier", + "start": 40, + "end": 43, + "loc": { + "start": { + "line": 2, + "column": 14 + }, + "end": { + "line": 2, + "column": 17 + }, + "identifierName": "foo" + }, + "name": "foo" + } + ] + }, + "init": { + "type": "Identifier", + "start": 47, + "end": 50, + "loc": { + "start": { + "line": 2, + "column": 21 + }, + "end": { + "line": 2, + "column": 24 + }, + "identifierName": "bar" + }, + "name": "bar" + } + } + ], + "kind": "const" + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring5/options.json b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring5/options.json deleted file mode 100644 index d36390356990..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring5/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Identifier 'foo' has already been declared (2:16)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring5/output.json b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring5/output.json new file mode 100644 index 000000000000..39b035aada97 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring5/output.json @@ -0,0 +1,224 @@ +{ + "type": "File", + "start": 0, + "end": 51, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 25 + } + }, + "errors": [ + "SyntaxError: Identifier 'foo' has already been declared (2:16)", + "SyntaxError: `foo` has already been exported. Exported identifiers must be unique. (2:0)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 51, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 25 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExportNamedDeclaration", + "start": 0, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 25 + } + }, + "specifiers": [], + "source": null, + "declaration": { + "type": "VariableDeclaration", + "start": 7, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 25 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 13, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "id": { + "type": "ArrayPattern", + "start": 13, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "elements": [ + { + "type": "Identifier", + "start": 14, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 17 + }, + "identifierName": "foo" + }, + "name": "foo" + } + ] + }, + "init": { + "type": "Identifier", + "start": 21, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 21 + }, + "end": { + "line": 1, + "column": 24 + }, + "identifierName": "bar" + }, + "name": "bar" + } + } + ], + "kind": "const" + } + }, + { + "type": "ExportNamedDeclaration", + "start": 26, + "end": 50, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 24 + } + }, + "specifiers": [], + "source": null, + "declaration": { + "type": "FunctionDeclaration", + "start": 33, + "end": 50, + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 2, + "column": 24 + } + }, + "id": { + "type": "Identifier", + "start": 42, + "end": 45, + "loc": { + "start": { + "line": 2, + "column": 16 + }, + "end": { + "line": 2, + "column": 19 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 48, + "end": 50, + "loc": { + "start": { + "line": 2, + "column": 22 + }, + "end": { + "line": 2, + "column": 24 + } + }, + "body": [], + "directives": [] + } + } + }, + { + "type": "EmptyStatement", + "start": 50, + "end": 51, + "loc": { + "start": { + "line": 2, + "column": 24 + }, + "end": { + "line": 2, + "column": 25 + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring6/options.json b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring6/options.json deleted file mode 100644 index 46358493589c..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring6/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Identifier 'foo' has already been declared (2:14)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring6/output.json b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring6/output.json new file mode 100644 index 000000000000..d4856c9023d7 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring6/output.json @@ -0,0 +1,279 @@ +{ + "type": "File", + "start": 0, + "end": 54, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 26 + } + }, + "errors": [ + "SyntaxError: Identifier 'foo' has already been declared (2:14)", + "SyntaxError: `foo` has already been exported. Exported identifiers must be unique. (2:14)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 54, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 26 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExportNamedDeclaration", + "start": 0, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 27 + } + }, + "specifiers": [], + "source": null, + "declaration": { + "type": "VariableDeclaration", + "start": 7, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 27 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 13, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "id": { + "type": "ObjectPattern", + "start": 13, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "properties": [ + { + "type": "ObjectProperty", + "start": 15, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "method": false, + "key": { + "type": "Identifier", + "start": 15, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 18 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "computed": false, + "shorthand": true, + "value": { + "type": "Identifier", + "start": 15, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 18 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "extra": { + "shorthand": true + } + } + ] + }, + "init": { + "type": "Identifier", + "start": 23, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 23 + }, + "end": { + "line": 1, + "column": 26 + }, + "identifierName": "bar" + }, + "name": "bar" + } + } + ], + "kind": "const" + } + }, + { + "type": "ExportNamedDeclaration", + "start": 28, + "end": 54, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 26 + } + }, + "specifiers": [], + "source": null, + "declaration": { + "type": "VariableDeclaration", + "start": 35, + "end": 54, + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 2, + "column": 26 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 41, + "end": 53, + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 25 + } + }, + "id": { + "type": "ArrayPattern", + "start": 41, + "end": 46, + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 18 + } + }, + "elements": [ + { + "type": "Identifier", + "start": 42, + "end": 45, + "loc": { + "start": { + "line": 2, + "column": 14 + }, + "end": { + "line": 2, + "column": 17 + }, + "identifierName": "foo" + }, + "name": "foo" + } + ] + }, + "init": { + "type": "Identifier", + "start": 49, + "end": 53, + "loc": { + "start": { + "line": 2, + "column": 21 + }, + "end": { + "line": 2, + "column": 25 + }, + "identifierName": "bar2" + }, + "name": "bar2" + } + } + ], + "kind": "const" + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring7/options.json b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring7/options.json deleted file mode 100644 index 2cbe06c40914..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring7/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Identifier 'foo' has already been declared (2:15)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring7/output.json b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring7/output.json new file mode 100644 index 000000000000..3bfd361f5286 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring7/output.json @@ -0,0 +1,279 @@ +{ + "type": "File", + "start": 0, + "end": 54, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 28 + } + }, + "errors": [ + "SyntaxError: Identifier 'foo' has already been declared (2:15)", + "SyntaxError: `foo` has already been exported. Exported identifiers must be unique. (2:15)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 54, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 28 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExportNamedDeclaration", + "start": 0, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 25 + } + }, + "specifiers": [], + "source": null, + "declaration": { + "type": "VariableDeclaration", + "start": 7, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 25 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 13, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "id": { + "type": "ArrayPattern", + "start": 13, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "elements": [ + { + "type": "Identifier", + "start": 14, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 17 + }, + "identifierName": "foo" + }, + "name": "foo" + } + ] + }, + "init": { + "type": "Identifier", + "start": 21, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 21 + }, + "end": { + "line": 1, + "column": 24 + }, + "identifierName": "bar" + }, + "name": "bar" + } + } + ], + "kind": "const" + } + }, + { + "type": "ExportNamedDeclaration", + "start": 26, + "end": 54, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 28 + } + }, + "specifiers": [], + "source": null, + "declaration": { + "type": "VariableDeclaration", + "start": 33, + "end": 54, + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 2, + "column": 28 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 39, + "end": 53, + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 27 + } + }, + "id": { + "type": "ObjectPattern", + "start": 39, + "end": 46, + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 20 + } + }, + "properties": [ + { + "type": "ObjectProperty", + "start": 41, + "end": 44, + "loc": { + "start": { + "line": 2, + "column": 15 + }, + "end": { + "line": 2, + "column": 18 + } + }, + "method": false, + "key": { + "type": "Identifier", + "start": 41, + "end": 44, + "loc": { + "start": { + "line": 2, + "column": 15 + }, + "end": { + "line": 2, + "column": 18 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "computed": false, + "shorthand": true, + "value": { + "type": "Identifier", + "start": 41, + "end": 44, + "loc": { + "start": { + "line": 2, + "column": 15 + }, + "end": { + "line": 2, + "column": 18 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "extra": { + "shorthand": true + } + } + ] + }, + "init": { + "type": "Identifier", + "start": 49, + "end": 53, + "loc": { + "start": { + "line": 2, + "column": 23 + }, + "end": { + "line": 2, + "column": 27 + }, + "identifierName": "bar2" + }, + "name": "bar2" + } + } + ], + "kind": "const" + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring8/options.json b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring8/options.json deleted file mode 100644 index 982078d803c6..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring8/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Identifier 'Foo' has already been declared (2:15)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring8/output.json b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring8/output.json new file mode 100644 index 000000000000..5826aac519d7 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring8/output.json @@ -0,0 +1,259 @@ +{ + "type": "File", + "start": 0, + "end": 48, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 27 + } + }, + "errors": [ + "SyntaxError: Identifier 'Foo' has already been declared (2:15)", + "SyntaxError: `Foo` has already been exported. Exported identifiers must be unique. (2:15)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 48, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 27 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExportNamedDeclaration", + "start": 0, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "specifiers": [], + "source": null, + "declaration": { + "type": "ClassDeclaration", + "start": 7, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "id": { + "type": "Identifier", + "start": 13, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 16 + }, + "identifierName": "Foo" + }, + "name": "Foo" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "start": 17, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "body": [] + } + } + }, + { + "type": "EmptyStatement", + "start": 19, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 20 + } + } + }, + { + "type": "ExportNamedDeclaration", + "start": 21, + "end": 48, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 27 + } + }, + "specifiers": [], + "source": null, + "declaration": { + "type": "VariableDeclaration", + "start": 28, + "end": 48, + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 2, + "column": 27 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 34, + "end": 47, + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 26 + } + }, + "id": { + "type": "ObjectPattern", + "start": 34, + "end": 41, + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 20 + } + }, + "properties": [ + { + "type": "ObjectProperty", + "start": 36, + "end": 39, + "loc": { + "start": { + "line": 2, + "column": 15 + }, + "end": { + "line": 2, + "column": 18 + } + }, + "method": false, + "key": { + "type": "Identifier", + "start": 36, + "end": 39, + "loc": { + "start": { + "line": 2, + "column": 15 + }, + "end": { + "line": 2, + "column": 18 + }, + "identifierName": "Foo" + }, + "name": "Foo" + }, + "computed": false, + "shorthand": true, + "value": { + "type": "Identifier", + "start": 36, + "end": 39, + "loc": { + "start": { + "line": 2, + "column": 15 + }, + "end": { + "line": 2, + "column": 18 + }, + "identifierName": "Foo" + }, + "name": "Foo" + }, + "extra": { + "shorthand": true + } + } + ] + }, + "init": { + "type": "Identifier", + "start": 44, + "end": 47, + "loc": { + "start": { + "line": 2, + "column": 23 + }, + "end": { + "line": 2, + "column": 26 + }, + "identifierName": "bar" + }, + "name": "bar" + } + } + ], + "kind": "const" + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring9/options.json b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring9/options.json deleted file mode 100644 index f79b5469b1c0..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring9/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Identifier 'Foo' has already been declared (2:14)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring9/output.json b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring9/output.json new file mode 100644 index 000000000000..4ee921df359a --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring9/output.json @@ -0,0 +1,221 @@ +{ + "type": "File", + "start": 0, + "end": 46, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 25 + } + }, + "errors": [ + "SyntaxError: Identifier 'Foo' has already been declared (2:14)", + "SyntaxError: `Foo` has already been exported. Exported identifiers must be unique. (2:14)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 46, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 25 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExportNamedDeclaration", + "start": 0, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "specifiers": [], + "source": null, + "declaration": { + "type": "ClassDeclaration", + "start": 7, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "id": { + "type": "Identifier", + "start": 13, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 16 + }, + "identifierName": "Foo" + }, + "name": "Foo" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "start": 17, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "body": [] + } + } + }, + { + "type": "EmptyStatement", + "start": 19, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 20 + } + } + }, + { + "type": "ExportNamedDeclaration", + "start": 21, + "end": 46, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 25 + } + }, + "specifiers": [], + "source": null, + "declaration": { + "type": "VariableDeclaration", + "start": 28, + "end": 46, + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 2, + "column": 25 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 34, + "end": 45, + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 24 + } + }, + "id": { + "type": "ArrayPattern", + "start": 34, + "end": 39, + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 18 + } + }, + "elements": [ + { + "type": "Identifier", + "start": 35, + "end": 38, + "loc": { + "start": { + "line": 2, + "column": 14 + }, + "end": { + "line": 2, + "column": 17 + }, + "identifierName": "Foo" + }, + "name": "Foo" + } + ] + }, + "init": { + "type": "Identifier", + "start": 42, + "end": 45, + "loc": { + "start": { + "line": 2, + "column": 21 + }, + "end": { + "line": 2, + "column": 24 + }, + "identifierName": "bar" + }, + "name": "bar" + } + } + ], + "kind": "const" + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-function-declaration/options.json b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-function-declaration/options.json index 1923e4752336..54925950e059 100644 --- a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-function-declaration/options.json +++ b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-function-declaration/options.json @@ -1,3 +1,3 @@ { - "throws": "`foo` has already been exported. Exported identifiers must be unique. (2:0)" -} + "sourceType": "module" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-function-declaration/output.json b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-function-declaration/output.json new file mode 100644 index 000000000000..ac8f210f8ba9 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-function-declaration/output.json @@ -0,0 +1,190 @@ +{ + "type": "File", + "start": 0, + "end": 41, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 25 + } + }, + "errors": [ + "SyntaxError: `foo` has already been exported. Exported identifiers must be unique. (2:0)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 41, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 25 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExportNamedDeclaration", + "start": 0, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "specifiers": [ + { + "type": "ExportSpecifier", + "start": 9, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "local": { + "type": "Identifier", + "start": 9, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 12 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "exported": { + "type": "Identifier", + "start": 9, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 12 + }, + "identifierName": "foo" + }, + "name": "foo" + } + } + ], + "source": null, + "declaration": null + }, + { + "type": "ExportNamedDeclaration", + "start": 16, + "end": 40, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 24 + } + }, + "specifiers": [], + "source": null, + "declaration": { + "type": "FunctionDeclaration", + "start": 23, + "end": 40, + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 2, + "column": 24 + } + }, + "id": { + "type": "Identifier", + "start": 32, + "end": 35, + "loc": { + "start": { + "line": 2, + "column": 16 + }, + "end": { + "line": 2, + "column": 19 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 38, + "end": 40, + "loc": { + "start": { + "line": 2, + "column": 22 + }, + "end": { + "line": 2, + "column": 24 + } + }, + "body": [], + "directives": [] + } + } + }, + { + "type": "EmptyStatement", + "start": 40, + "end": 41, + "loc": { + "start": { + "line": 2, + "column": 24 + }, + "end": { + "line": 2, + "column": 25 + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-variable-declaration/options.json b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-variable-declaration/options.json index 9fdf7082da17..54925950e059 100644 --- a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-variable-declaration/options.json +++ b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-variable-declaration/options.json @@ -1,3 +1,3 @@ { - "throws": "`foo` has already been exported. Exported identifiers must be unique. (2:13)" -} + "sourceType": "module" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-variable-declaration/output.json b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-variable-declaration/output.json new file mode 100644 index 000000000000..981050ec6112 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-variable-declaration/output.json @@ -0,0 +1,190 @@ +{ + "type": "File", + "start": 0, + "end": 39, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 23 + } + }, + "errors": [ + "SyntaxError: `foo` has already been exported. Exported identifiers must be unique. (2:13)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 39, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 23 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExportNamedDeclaration", + "start": 0, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "specifiers": [ + { + "type": "ExportSpecifier", + "start": 9, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "local": { + "type": "Identifier", + "start": 9, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 12 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "exported": { + "type": "Identifier", + "start": 9, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 12 + }, + "identifierName": "foo" + }, + "name": "foo" + } + } + ], + "source": null, + "declaration": null + }, + { + "type": "ExportNamedDeclaration", + "start": 16, + "end": 39, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 23 + } + }, + "specifiers": [], + "source": null, + "declaration": { + "type": "VariableDeclaration", + "start": 23, + "end": 39, + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 2, + "column": 23 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 29, + "end": 38, + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 22 + } + }, + "id": { + "type": "Identifier", + "start": 29, + "end": 32, + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 16 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "init": { + "type": "Identifier", + "start": 35, + "end": 38, + "loc": { + "start": { + "line": 2, + "column": 19 + }, + "end": { + "line": 2, + "column": 22 + }, + "identifierName": "bar" + }, + "name": "bar" + } + } + ], + "kind": "const" + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export/options.json b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export/options.json index 9bb46f4778eb..54925950e059 100644 --- a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export/options.json +++ b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export/options.json @@ -1,3 +1,3 @@ { - "throws": "`foo` has already been exported. Exported identifiers must be unique. (2:9)" -} + "sourceType": "module" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export/output.json b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export/output.json new file mode 100644 index 000000000000..b6476d620353 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export/output.json @@ -0,0 +1,176 @@ +{ + "type": "File", + "start": 0, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 22 + } + }, + "errors": [ + "SyntaxError: `foo` has already been exported. Exported identifiers must be unique. (2:9)", + "SyntaxError: Export 'foo' is not defined (1:9)", + "SyntaxError: Export 'bar' is not defined (2:9)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 22 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExportNamedDeclaration", + "start": 0, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "specifiers": [ + { + "type": "ExportSpecifier", + "start": 9, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "local": { + "type": "Identifier", + "start": 9, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 12 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "exported": { + "type": "Identifier", + "start": 9, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 12 + }, + "identifierName": "foo" + }, + "name": "foo" + } + } + ], + "source": null, + "declaration": null + }, + { + "type": "ExportNamedDeclaration", + "start": 16, + "end": 38, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 22 + } + }, + "specifiers": [ + { + "type": "ExportSpecifier", + "start": 25, + "end": 35, + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 19 + } + }, + "local": { + "type": "Identifier", + "start": 25, + "end": 28, + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 12 + }, + "identifierName": "bar" + }, + "name": "bar" + }, + "exported": { + "type": "Identifier", + "start": 32, + "end": 35, + "loc": { + "start": { + "line": 2, + "column": 16 + }, + "end": { + "line": 2, + "column": 19 + }, + "identifierName": "foo" + }, + "name": "foo" + } + } + ], + "source": null, + "declaration": null + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/modules/import-invalid-keyword-flow/options.json b/packages/babel-parser/test/fixtures/es2015/modules/import-invalid-keyword-flow/options.json index 379fb1f86234..3c8ee8805e34 100644 --- a/packages/babel-parser/test/fixtures/es2015/modules/import-invalid-keyword-flow/options.json +++ b/packages/babel-parser/test/fixtures/es2015/modules/import-invalid-keyword-flow/options.json @@ -1,4 +1,6 @@ { - "plugins": ["flow"], - "throws": "Unexpected keyword 'default' (1:9)" -} + "sourceType": "module", + "plugins": [ + "flow" + ] +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/modules/import-invalid-keyword-flow/output.json b/packages/babel-parser/test/fixtures/es2015/modules/import-invalid-keyword-flow/output.json new file mode 100644 index 000000000000..d1f169eb7647 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/modules/import-invalid-keyword-flow/output.json @@ -0,0 +1,126 @@ +{ + "type": "File", + "start": 0, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "errors": [ + "SyntaxError: Unexpected keyword 'default' (1:9)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ImportDeclaration", + "start": 0, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "specifiers": [ + { + "type": "ImportSpecifier", + "start": 9, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "imported": { + "type": "Identifier", + "start": 9, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 16 + }, + "identifierName": "default" + }, + "name": "default" + }, + "importKind": null, + "local": { + "type": "Identifier", + "start": 9, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 16 + }, + "identifierName": "default" + }, + "name": "default" + } + } + ], + "importKind": "value", + "source": { + "type": "StringLiteral", + "start": 24, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 24 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "extra": { + "rawValue": "foo", + "raw": "\"foo\"" + }, + "value": "foo" + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/modules/import-invalid-keyword-typeof-flow/options.json b/packages/babel-parser/test/fixtures/es2015/modules/import-invalid-keyword-typeof-flow/options.json index cda01e8412c3..3c8ee8805e34 100644 --- a/packages/babel-parser/test/fixtures/es2015/modules/import-invalid-keyword-typeof-flow/options.json +++ b/packages/babel-parser/test/fixtures/es2015/modules/import-invalid-keyword-typeof-flow/options.json @@ -1,4 +1,6 @@ { - "plugins": ["flow"], - "throws": "Unexpected keyword 'typeof' (1:9)" -} + "sourceType": "module", + "plugins": [ + "flow" + ] +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/modules/import-invalid-keyword-typeof-flow/output.json b/packages/babel-parser/test/fixtures/es2015/modules/import-invalid-keyword-typeof-flow/output.json new file mode 100644 index 000000000000..62e2b403628d --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/modules/import-invalid-keyword-typeof-flow/output.json @@ -0,0 +1,126 @@ +{ + "type": "File", + "start": 0, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "errors": [ + "SyntaxError: Unexpected keyword 'typeof' (1:9)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ImportDeclaration", + "start": 0, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "specifiers": [ + { + "type": "ImportSpecifier", + "start": 9, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "imported": { + "type": "Identifier", + "start": 9, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 15 + }, + "identifierName": "typeof" + }, + "name": "typeof" + }, + "importKind": null, + "local": { + "type": "Identifier", + "start": 9, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 15 + }, + "identifierName": "typeof" + }, + "name": "typeof" + } + } + ], + "importKind": "value", + "source": { + "type": "StringLiteral", + "start": 23, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 23 + }, + "end": { + "line": 1, + "column": 28 + } + }, + "extra": { + "rawValue": "foo", + "raw": "\"foo\"" + }, + "value": "foo" + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/modules/import-invalid-keyword-typeof/options.json b/packages/babel-parser/test/fixtures/es2015/modules/import-invalid-keyword-typeof/options.json index a45cdb986dd1..54925950e059 100644 --- a/packages/babel-parser/test/fixtures/es2015/modules/import-invalid-keyword-typeof/options.json +++ b/packages/babel-parser/test/fixtures/es2015/modules/import-invalid-keyword-typeof/options.json @@ -1,3 +1,3 @@ { - "throws": "Unexpected keyword 'typeof' (1:9)" -} + "sourceType": "module" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/modules/import-invalid-keyword-typeof/output.json b/packages/babel-parser/test/fixtures/es2015/modules/import-invalid-keyword-typeof/output.json new file mode 100644 index 000000000000..cd60a3c49fe9 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/modules/import-invalid-keyword-typeof/output.json @@ -0,0 +1,124 @@ +{ + "type": "File", + "start": 0, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "errors": [ + "SyntaxError: Unexpected keyword 'typeof' (1:9)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ImportDeclaration", + "start": 0, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "specifiers": [ + { + "type": "ImportSpecifier", + "start": 9, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "imported": { + "type": "Identifier", + "start": 9, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 15 + }, + "identifierName": "typeof" + }, + "name": "typeof" + }, + "local": { + "type": "Identifier", + "start": 9, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 15 + }, + "identifierName": "typeof" + }, + "name": "typeof" + } + } + ], + "source": { + "type": "StringLiteral", + "start": 23, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 23 + }, + "end": { + "line": 1, + "column": 28 + } + }, + "extra": { + "rawValue": "foo", + "raw": "\"foo\"" + }, + "value": "foo" + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/modules/import-invalid-keyword/options.json b/packages/babel-parser/test/fixtures/es2015/modules/import-invalid-keyword/options.json index 2c6a46df3f6e..54925950e059 100644 --- a/packages/babel-parser/test/fixtures/es2015/modules/import-invalid-keyword/options.json +++ b/packages/babel-parser/test/fixtures/es2015/modules/import-invalid-keyword/options.json @@ -1,3 +1,3 @@ { - "throws": "Unexpected keyword 'debugger' (1:9)" -} + "sourceType": "module" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/modules/import-invalid-keyword/output.json b/packages/babel-parser/test/fixtures/es2015/modules/import-invalid-keyword/output.json new file mode 100644 index 000000000000..40242124c0c4 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/modules/import-invalid-keyword/output.json @@ -0,0 +1,124 @@ +{ + "type": "File", + "start": 0, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "errors": [ + "SyntaxError: Unexpected keyword 'debugger' (1:9)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ImportDeclaration", + "start": 0, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "specifiers": [ + { + "type": "ImportSpecifier", + "start": 9, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "imported": { + "type": "Identifier", + "start": 9, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 17 + }, + "identifierName": "debugger" + }, + "name": "debugger" + }, + "local": { + "type": "Identifier", + "start": 9, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 17 + }, + "identifierName": "debugger" + }, + "name": "debugger" + } + } + ], + "source": { + "type": "StringLiteral", + "start": 25, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 25 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "extra": { + "rawValue": "foo", + "raw": "\"foo\"" + }, + "value": "foo" + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/object/disallow-duplicate-method-params/options.json b/packages/babel-parser/test/fixtures/es2015/object/disallow-duplicate-method-params/options.json deleted file mode 100644 index a848b7de671a..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/object/disallow-duplicate-method-params/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Argument name clash (2:11)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/object/disallow-duplicate-method-params/output.json b/packages/babel-parser/test/fixtures/es2015/object/disallow-duplicate-method-params/output.json new file mode 100644 index 000000000000..b9fa1b56ec84 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/object/disallow-duplicate-method-params/output.json @@ -0,0 +1,165 @@ +{ + "type": "File", + "start": 0, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 2 + } + }, + "errors": [ + "SyntaxError: Argument name clash (2:11)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 2 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 2 + } + }, + "expression": { + "type": "ObjectExpression", + "start": 1, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "properties": [ + { + "type": "ObjectMethod", + "start": 7, + "end": 19, + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 16 + } + }, + "method": true, + "key": { + "type": "Identifier", + "start": 7, + "end": 10, + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 7 + }, + "identifierName": "bar" + }, + "name": "bar" + }, + "computed": false, + "kind": "method", + "id": null, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "start": 11, + "end": 12, + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 9 + }, + "identifierName": "a" + }, + "name": "a" + }, + { + "type": "Identifier", + "start": 14, + "end": 15, + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 12 + }, + "identifierName": "a" + }, + "name": "a" + } + ], + "body": { + "type": "BlockStatement", + "start": 17, + "end": 19, + "loc": { + "start": { + "line": 2, + "column": 14 + }, + "end": { + "line": 2, + "column": 16 + } + }, + "body": [], + "directives": [] + } + } + ], + "extra": { + "parenthesized": true, + "parenStart": 0 + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/regex/duplicate-flags/options.json b/packages/babel-parser/test/fixtures/es2015/regex/duplicate-flags/options.json deleted file mode 100644 index 86670c5168d0..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/regex/duplicate-flags/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Duplicate regular expression flag (1:6)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/regex/duplicate-flags/output.json b/packages/babel-parser/test/fixtures/es2015/regex/duplicate-flags/output.json new file mode 100644 index 000000000000..86ec306e13d1 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/regex/duplicate-flags/output.json @@ -0,0 +1,73 @@ +{ + "type": "File", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "errors": [ + "SyntaxError: Duplicate regular expression flag (1:6)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "expression": { + "type": "RegExpLiteral", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "extra": { + "raw": "/./gii" + }, + "pattern": ".", + "flags": "gii" + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/shorthand/1/options.json b/packages/babel-parser/test/fixtures/es2015/shorthand/1/options.json deleted file mode 100644 index eaa26955dc77..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/shorthand/1/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Unexpected keyword 'const' (1:11)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/shorthand/1/output.json b/packages/babel-parser/test/fixtures/es2015/shorthand/1/output.json new file mode 100644 index 000000000000..712caaafe1a1 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/shorthand/1/output.json @@ -0,0 +1,164 @@ +{ + "type": "File", + "start": 0, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "errors": [ + "SyntaxError: Unexpected keyword 'const' (1:11)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "VariableDeclaration", + "start": 0, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 4, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "id": { + "type": "Identifier", + "start": 4, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 5 + }, + "identifierName": "x" + }, + "name": "x" + }, + "init": { + "type": "ObjectExpression", + "start": 9, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "properties": [ + { + "type": "ObjectProperty", + "start": 11, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "method": false, + "key": { + "type": "Identifier", + "start": 11, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 16 + }, + "identifierName": "const" + }, + "name": "const" + }, + "computed": false, + "shorthand": true, + "value": { + "type": "Identifier", + "start": 11, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 16 + }, + "identifierName": "const" + }, + "name": "const" + }, + "extra": { + "shorthand": true + } + } + ], + "extra": { + "parenthesized": true, + "parenStart": 8 + } + } + } + ], + "kind": "var" + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/shorthand/2/options.json b/packages/babel-parser/test/fixtures/es2015/shorthand/2/options.json deleted file mode 100644 index be39a4451388..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/shorthand/2/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Unexpected keyword 'this' (1:8)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/shorthand/2/output.json b/packages/babel-parser/test/fixtures/es2015/shorthand/2/output.json new file mode 100644 index 000000000000..c91daf2f66d8 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/shorthand/2/output.json @@ -0,0 +1,240 @@ +{ + "type": "File", + "start": 0, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "errors": [ + "SyntaxError: Unexpected keyword 'this' (1:8)", + "SyntaxError: Unexpected keyword 'if' (1:14)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "expression": { + "type": "ObjectExpression", + "start": 1, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "properties": [ + { + "type": "ObjectProperty", + "start": 3, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "method": false, + "key": { + "type": "Identifier", + "start": 3, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 6 + }, + "identifierName": "get" + }, + "name": "get" + }, + "computed": false, + "shorthand": true, + "value": { + "type": "Identifier", + "start": 3, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 6 + }, + "identifierName": "get" + }, + "name": "get" + }, + "extra": { + "shorthand": true + } + }, + { + "type": "ObjectProperty", + "start": 8, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "method": false, + "key": { + "type": "Identifier", + "start": 8, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 12 + }, + "identifierName": "this" + }, + "name": "this" + }, + "computed": false, + "shorthand": true, + "value": { + "type": "Identifier", + "start": 8, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 12 + }, + "identifierName": "this" + }, + "name": "this" + }, + "extra": { + "shorthand": true + } + }, + { + "type": "ObjectProperty", + "start": 14, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "method": false, + "key": { + "type": "Identifier", + "start": 14, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 16 + }, + "identifierName": "if" + }, + "name": "if" + }, + "computed": false, + "shorthand": true, + "value": { + "type": "Identifier", + "start": 14, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 16 + }, + "identifierName": "if" + }, + "name": "if" + }, + "extra": { + "shorthand": true + } + } + ], + "extra": { + "parenthesized": true, + "parenStart": 0 + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/statements/label-invalid-const/options.json b/packages/babel-parser/test/fixtures/es2015/statements/label-invalid-const/options.json deleted file mode 100644 index a064a678e553..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/statements/label-invalid-const/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Lexical declaration cannot appear in a single-statement context (1:5)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/statements/label-invalid-const/output.json b/packages/babel-parser/test/fixtures/es2015/statements/label-invalid-const/output.json new file mode 100644 index 000000000000..b0dd4fe9c6d0 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/statements/label-invalid-const/output.json @@ -0,0 +1,135 @@ +{ + "type": "File", + "start": 0, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "errors": [ + "SyntaxError: Lexical declaration cannot appear in a single-statement context (1:5)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "LabeledStatement", + "start": 0, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "body": { + "type": "VariableDeclaration", + "start": 5, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 11, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "id": { + "type": "Identifier", + "start": 11, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 14 + }, + "identifierName": "bar" + }, + "name": "bar" + }, + "init": { + "type": "NullLiteral", + "start": 17, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 21 + } + } + } + } + ], + "kind": "const" + }, + "label": { + "type": "Identifier", + "start": 0, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 3 + }, + "identifierName": "foo" + }, + "name": "foo" + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/statements/label-invalid-func-async/options.json b/packages/babel-parser/test/fixtures/es2015/statements/label-invalid-func-async/options.json deleted file mode 100644 index 95aaacb458f8..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/statements/label-invalid-func-async/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Async functions can only be declared at the top level or inside a block (1:5)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/statements/label-invalid-func-async/output.json b/packages/babel-parser/test/fixtures/es2015/statements/label-invalid-func-async/output.json new file mode 100644 index 000000000000..31af7aa06caf --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/statements/label-invalid-func-async/output.json @@ -0,0 +1,122 @@ +{ + "type": "File", + "start": 0, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 28 + } + }, + "errors": [ + "SyntaxError: Async functions can only be declared at the top level or inside a block (1:5)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 28 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "LabeledStatement", + "start": 0, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 28 + } + }, + "body": { + "type": "FunctionDeclaration", + "start": 5, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 28 + } + }, + "id": { + "type": "Identifier", + "start": 20, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 20 + }, + "end": { + "line": 1, + "column": 23 + }, + "identifierName": "bar" + }, + "name": "bar" + }, + "generator": false, + "async": true, + "params": [], + "body": { + "type": "BlockStatement", + "start": 26, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 26 + }, + "end": { + "line": 1, + "column": 28 + } + }, + "body": [], + "directives": [] + } + }, + "label": { + "type": "Identifier", + "start": 0, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 3 + }, + "identifierName": "foo" + }, + "name": "foo" + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/statements/label-invalid-func-generator/options.json b/packages/babel-parser/test/fixtures/es2015/statements/label-invalid-func-generator/options.json deleted file mode 100644 index 3f6e90c7cd27..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/statements/label-invalid-func-generator/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Generators can only be declared at the top level or inside a block (1:13)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/statements/label-invalid-func-generator/output.json b/packages/babel-parser/test/fixtures/es2015/statements/label-invalid-func-generator/output.json new file mode 100644 index 000000000000..5dd39402a92b --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/statements/label-invalid-func-generator/output.json @@ -0,0 +1,122 @@ +{ + "type": "File", + "start": 0, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "errors": [ + "SyntaxError: Generators can only be declared at the top level or inside a block (1:13)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "LabeledStatement", + "start": 0, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "body": { + "type": "FunctionDeclaration", + "start": 5, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "id": { + "type": "Identifier", + "start": 15, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 18 + }, + "identifierName": "bar" + }, + "name": "bar" + }, + "generator": true, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 21, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 21 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "body": [], + "directives": [] + } + }, + "label": { + "type": "Identifier", + "start": 0, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 3 + }, + "identifierName": "foo" + }, + "name": "foo" + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/statements/label-invalid-func-strict/options.json b/packages/babel-parser/test/fixtures/es2015/statements/label-invalid-func-strict/options.json deleted file mode 100644 index 1eebe15c408e..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/statements/label-invalid-func-strict/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "In strict mode code, functions can only be declared at top level or inside a block (1:35)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/statements/label-invalid-func-strict/output.json b/packages/babel-parser/test/fixtures/es2015/statements/label-invalid-func-strict/output.json new file mode 100644 index 000000000000..782989ece4c8 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/statements/label-invalid-func-strict/output.json @@ -0,0 +1,211 @@ +{ + "type": "File", + "start": 0, + "end": 53, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 53 + } + }, + "errors": [ + "SyntaxError: In strict mode code, functions can only be declared at top level or inside a block (1:35)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 53, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 53 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 53, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 53 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 12 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 15, + "end": 53, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 53 + } + }, + "body": [ + { + "type": "LabeledStatement", + "start": 30, + "end": 52, + "loc": { + "start": { + "line": 1, + "column": 30 + }, + "end": { + "line": 1, + "column": 52 + } + }, + "body": { + "type": "FunctionDeclaration", + "start": 35, + "end": 52, + "loc": { + "start": { + "line": 1, + "column": 35 + }, + "end": { + "line": 1, + "column": 52 + } + }, + "id": { + "type": "Identifier", + "start": 44, + "end": 47, + "loc": { + "start": { + "line": 1, + "column": 44 + }, + "end": { + "line": 1, + "column": 47 + }, + "identifierName": "baz" + }, + "name": "baz" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 50, + "end": 52, + "loc": { + "start": { + "line": 1, + "column": 50 + }, + "end": { + "line": 1, + "column": 52 + } + }, + "body": [], + "directives": [] + } + }, + "label": { + "type": "Identifier", + "start": 30, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 30 + }, + "end": { + "line": 1, + "column": 33 + }, + "identifierName": "bar" + }, + "name": "bar" + } + } + ], + "directives": [ + { + "type": "Directive", + "start": 16, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 16, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 28 + } + }, + "value": "use strict", + "extra": { + "raw": "\"use strict\"", + "rawValue": "use strict" + } + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/109/options.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/109/options.json deleted file mode 100644 index 1fc5db8949ff..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/109/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "for-of loop variable declaration may not have an initializer (1:5)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/109/output.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/109/output.json new file mode 100644 index 000000000000..1bc303096308 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/109/output.json @@ -0,0 +1,207 @@ +{ + "type": "File", + "start": 0, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "errors": [ + "SyntaxError: for-of loop variable declaration may not have an initializer (1:5)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ForOfStatement", + "start": 0, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "await": false, + "left": { + "type": "VariableDeclaration", + "start": 5, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 9, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 10 + }, + "identifierName": "x" + }, + "name": "x" + }, + "init": { + "type": "NumericLiteral", + "start": 13, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "extra": { + "rawValue": 42, + "raw": "42" + }, + "value": 42 + } + } + ], + "kind": "var" + }, + "right": { + "type": "Identifier", + "start": 19, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 23 + }, + "identifierName": "list" + }, + "name": "list" + }, + "body": { + "type": "ExpressionStatement", + "start": 25, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 25 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "expression": { + "type": "CallExpression", + "start": 25, + "end": 35, + "loc": { + "start": { + "line": 1, + "column": 25 + }, + "end": { + "line": 1, + "column": 35 + } + }, + "callee": { + "type": "Identifier", + "start": 25, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 25 + }, + "end": { + "line": 1, + "column": 32 + }, + "identifierName": "process" + }, + "name": "process" + }, + "arguments": [ + { + "type": "Identifier", + "start": 33, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 33 + }, + "end": { + "line": 1, + "column": 34 + }, + "identifierName": "x" + }, + "name": "x" + } + ] + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/123/options.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/123/options.json deleted file mode 100644 index 42317f2b92ee..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/123/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "super() is only valid inside a class constructor of a subclass. Maybe a typo in the method name ('constructor') or not extending another class? (1:40)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/123/output.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/123/output.json new file mode 100644 index 000000000000..fcaa1ad31779 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/123/output.json @@ -0,0 +1,246 @@ +{ + "type": "File", + "start": 0, + "end": 51, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 51 + } + }, + "errors": [ + "SyntaxError: super() is only valid inside a class constructor of a subclass. Maybe a typo in the method name ('constructor') or not extending another class? (1:40)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 51, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 51 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 14, + "end": 51, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 51 + } + }, + "expression": { + "type": "ClassExpression", + "start": 15, + "end": 50, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 50 + } + }, + "id": { + "type": "Identifier", + "start": 21, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 21 + }, + "end": { + "line": 1, + "column": 22 + }, + "identifierName": "A" + }, + "name": "A" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "start": 23, + "end": 50, + "loc": { + "start": { + "line": 1, + "column": 23 + }, + "end": { + "line": 1, + "column": 50 + } + }, + "body": [ + { + "type": "ClassMethod", + "start": 24, + "end": 49, + "loc": { + "start": { + "line": 1, + "column": 24 + }, + "end": { + "line": 1, + "column": 49 + } + }, + "static": false, + "key": { + "type": "Identifier", + "start": 24, + "end": 35, + "loc": { + "start": { + "line": 1, + "column": 24 + }, + "end": { + "line": 1, + "column": 35 + }, + "identifierName": "constructor" + }, + "name": "constructor" + }, + "computed": false, + "kind": "constructor", + "id": null, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 38, + "end": 49, + "loc": { + "start": { + "line": 1, + "column": 38 + }, + "end": { + "line": 1, + "column": 49 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 40, + "end": 47, + "loc": { + "start": { + "line": 1, + "column": 40 + }, + "end": { + "line": 1, + "column": 47 + } + }, + "expression": { + "type": "CallExpression", + "start": 40, + "end": 47, + "loc": { + "start": { + "line": 1, + "column": 40 + }, + "end": { + "line": 1, + "column": 47 + } + }, + "callee": { + "type": "Super", + "start": 40, + "end": 45, + "loc": { + "start": { + "line": 1, + "column": 40 + }, + "end": { + "line": 1, + "column": 45 + } + } + }, + "arguments": [] + } + } + ], + "directives": [] + } + } + ] + }, + "extra": { + "parenthesized": true, + "parenStart": 14 + } + } + } + ], + "directives": [ + { + "type": "Directive", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 0, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "value": "use strict", + "extra": { + "raw": "\"use strict\"", + "rawValue": "use strict" + } + } + } + ] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/125/input.js b/packages/babel-parser/test/fixtures/es2015/uncategorised/125/input.js index a7bd428bbfce..83b8fa3b72d4 100644 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/125/input.js +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/125/input.js @@ -1 +1 @@ -class A { constructor() {} 'constructor'() } \ No newline at end of file +class A { constructor() {} 'constructor'() {} } \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/125/options.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/125/options.json deleted file mode 100644 index 09e50a3d71c3..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/125/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Duplicate constructor in the same class (1:27)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/125/output.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/125/output.json new file mode 100644 index 000000000000..d4cca9c08ac4 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/125/output.json @@ -0,0 +1,203 @@ +{ + "type": "File", + "start": 0, + "end": 47, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 47 + } + }, + "errors": [ + "SyntaxError: Duplicate constructor in the same class (1:27)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 47, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 47 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ClassDeclaration", + "start": 0, + "end": 47, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 47 + } + }, + "id": { + "type": "Identifier", + "start": 6, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + }, + "identifierName": "A" + }, + "name": "A" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "start": 8, + "end": 47, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 47 + } + }, + "body": [ + { + "type": "ClassMethod", + "start": 10, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "static": false, + "key": { + "type": "Identifier", + "start": 10, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 21 + }, + "identifierName": "constructor" + }, + "name": "constructor" + }, + "computed": false, + "kind": "constructor", + "id": null, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 24, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 24 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "body": [], + "directives": [] + } + }, + { + "type": "ClassMethod", + "start": 27, + "end": 45, + "loc": { + "start": { + "line": 1, + "column": 27 + }, + "end": { + "line": 1, + "column": 45 + } + }, + "static": false, + "key": { + "type": "StringLiteral", + "start": 27, + "end": 40, + "loc": { + "start": { + "line": 1, + "column": 27 + }, + "end": { + "line": 1, + "column": 40 + } + }, + "extra": { + "rawValue": "constructor", + "raw": "'constructor'" + }, + "value": "constructor" + }, + "computed": false, + "kind": "constructor", + "id": null, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 43, + "end": 45, + "loc": { + "start": { + "line": 1, + "column": 43 + }, + "end": { + "line": 1, + "column": 45 + } + }, + "body": [], + "directives": [] + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/126/options.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/126/options.json deleted file mode 100644 index 38e87b07044c..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/126/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Constructor can't have get/set modifier (1:14)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/126/output.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/126/output.json new file mode 100644 index 000000000000..b1c776635e95 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/126/output.json @@ -0,0 +1,144 @@ +{ + "type": "File", + "start": 0, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "errors": [ + "SyntaxError: Constructor can't have get/set modifier (1:14)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ClassDeclaration", + "start": 0, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "id": { + "type": "Identifier", + "start": 6, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + }, + "identifierName": "A" + }, + "name": "A" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "start": 8, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "body": [ + { + "type": "ClassMethod", + "start": 10, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "static": false, + "key": { + "type": "Identifier", + "start": 14, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 25 + }, + "identifierName": "constructor" + }, + "name": "constructor" + }, + "computed": false, + "kind": "get", + "id": null, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 28, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 28 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "body": [], + "directives": [] + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/127/options.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/127/options.json deleted file mode 100644 index becf560010f4..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/127/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Constructor can't be a generator (1:11)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/127/output.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/127/output.json new file mode 100644 index 000000000000..8eb2f5bd2f58 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/127/output.json @@ -0,0 +1,144 @@ +{ + "type": "File", + "start": 0, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "errors": [ + "SyntaxError: Constructor can't be a generator (1:11)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ClassDeclaration", + "start": 0, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "id": { + "type": "Identifier", + "start": 6, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + }, + "identifierName": "A" + }, + "name": "A" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "start": 8, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "body": [ + { + "type": "ClassMethod", + "start": 10, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 27 + } + }, + "static": false, + "kind": "method", + "key": { + "type": "Identifier", + "start": 11, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 22 + }, + "identifierName": "constructor" + }, + "name": "constructor" + }, + "computed": false, + "id": null, + "generator": true, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 25, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 25 + }, + "end": { + "line": 1, + "column": 27 + } + }, + "body": [], + "directives": [] + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/166/options.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/166/options.json deleted file mode 100644 index b25685c6eac5..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/166/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Argument name clash (1:16)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/166/output.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/166/output.json new file mode 100644 index 000000000000..62466668edcb --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/166/output.json @@ -0,0 +1,180 @@ +{ + "type": "File", + "start": 0, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "errors": [ + "SyntaxError: Argument name clash (1:16)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 10 + }, + "identifierName": "x" + }, + "name": "x" + }, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "start": 11, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 12 + }, + "identifierName": "a" + }, + "name": "a" + }, + { + "type": "ObjectPattern", + "start": 14, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "properties": [ + { + "type": "ObjectProperty", + "start": 16, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "method": false, + "key": { + "type": "Identifier", + "start": 16, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 17 + }, + "identifierName": "a" + }, + "name": "a" + }, + "computed": false, + "shorthand": true, + "value": { + "type": "Identifier", + "start": 16, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 17 + }, + "identifierName": "a" + }, + "name": "a" + }, + "extra": { + "shorthand": true + } + } + ] + } + ], + "body": { + "type": "BlockStatement", + "start": 20, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 20 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "body": [], + "directives": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/198/options.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/198/options.json deleted file mode 100644 index 3f09c36a5f1c..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/198/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Expected number in radix 8 (1:2)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/198/output.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/198/output.json new file mode 100644 index 000000000000..12a024fb2c03 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/198/output.json @@ -0,0 +1,73 @@ +{ + "type": "File", + "start": 0, + "end": 2, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 2 + } + }, + "errors": [ + "SyntaxError: Expected number in radix 8 (1:2)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 2, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 2 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 2, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 2 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 0, + "end": 2, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 2 + } + }, + "extra": { + "rawValue": null, + "raw": "0o" + }, + "value": null + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/200/options.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/200/options.json deleted file mode 100644 index 3f09c36a5f1c..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/200/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Expected number in radix 8 (1:2)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/200/output.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/200/output.json new file mode 100644 index 000000000000..4b91f320f950 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/200/output.json @@ -0,0 +1,73 @@ +{ + "type": "File", + "start": 0, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "errors": [ + "SyntaxError: Expected number in radix 8 (1:2)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 0, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "extra": { + "rawValue": 0, + "raw": "0o9" + }, + "value": 0 + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/201/options.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/201/options.json deleted file mode 100644 index d52d9cfac4bc..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/201/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Unexpected token, expected \";\" (1:3)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/201/output.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/201/output.json new file mode 100644 index 000000000000..9978c5342ef3 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/201/output.json @@ -0,0 +1,73 @@ +{ + "type": "File", + "start": 0, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "errors": [ + "SyntaxError: Expected number in radix 8 (1:3)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 0, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "extra": { + "rawValue": 8, + "raw": "0o18" + }, + "value": 8 + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/202/options.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/202/options.json deleted file mode 100644 index 3f09c36a5f1c..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/202/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Expected number in radix 8 (1:2)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/202/output.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/202/output.json new file mode 100644 index 000000000000..5d2ed2d91388 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/202/output.json @@ -0,0 +1,73 @@ +{ + "type": "File", + "start": 0, + "end": 2, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 2 + } + }, + "errors": [ + "SyntaxError: Expected number in radix 8 (1:2)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 2, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 2 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 2, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 2 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 0, + "end": 2, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 2 + } + }, + "extra": { + "rawValue": null, + "raw": "0O" + }, + "value": null + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/204/options.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/204/options.json deleted file mode 100644 index 3f09c36a5f1c..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/204/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Expected number in radix 8 (1:2)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/204/output.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/204/output.json new file mode 100644 index 000000000000..af4105738ef8 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/204/output.json @@ -0,0 +1,73 @@ +{ + "type": "File", + "start": 0, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "errors": [ + "SyntaxError: Expected number in radix 8 (1:2)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 0, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "extra": { + "rawValue": 0, + "raw": "0O9" + }, + "value": 0 + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/205/options.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/205/options.json deleted file mode 100644 index d52d9cfac4bc..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/205/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Unexpected token, expected \";\" (1:3)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/205/output.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/205/output.json new file mode 100644 index 000000000000..617cc13b6615 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/205/output.json @@ -0,0 +1,73 @@ +{ + "type": "File", + "start": 0, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "errors": [ + "SyntaxError: Expected number in radix 8 (1:3)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 0, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "extra": { + "rawValue": 8, + "raw": "0O18" + }, + "value": 8 + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/206/options.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/206/options.json deleted file mode 100644 index 40dc3da9a8f4..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/206/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Expected number in radix 2 (1:2)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/206/output.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/206/output.json new file mode 100644 index 000000000000..0688a297c669 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/206/output.json @@ -0,0 +1,73 @@ +{ + "type": "File", + "start": 0, + "end": 2, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 2 + } + }, + "errors": [ + "SyntaxError: Expected number in radix 2 (1:2)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 2, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 2 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 2, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 2 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 0, + "end": 2, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 2 + } + }, + "extra": { + "rawValue": null, + "raw": "0b" + }, + "value": null + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/208/options.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/208/options.json deleted file mode 100644 index 40dc3da9a8f4..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/208/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Expected number in radix 2 (1:2)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/208/output.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/208/output.json new file mode 100644 index 000000000000..7281fb745a17 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/208/output.json @@ -0,0 +1,73 @@ +{ + "type": "File", + "start": 0, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "errors": [ + "SyntaxError: Expected number in radix 2 (1:2)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 0, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "extra": { + "rawValue": 0, + "raw": "0b9" + }, + "value": 0 + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/209/options.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/209/options.json deleted file mode 100644 index d52d9cfac4bc..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/209/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Unexpected token, expected \";\" (1:3)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/209/output.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/209/output.json new file mode 100644 index 000000000000..25d711669b8b --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/209/output.json @@ -0,0 +1,73 @@ +{ + "type": "File", + "start": 0, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "errors": [ + "SyntaxError: Expected number in radix 2 (1:3)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 0, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "extra": { + "rawValue": 2, + "raw": "0b18" + }, + "value": 2 + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/210/options.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/210/options.json deleted file mode 100644 index d52d9cfac4bc..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/210/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Unexpected token, expected \";\" (1:3)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/210/output.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/210/output.json new file mode 100644 index 000000000000..379e9db894c0 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/210/output.json @@ -0,0 +1,73 @@ +{ + "type": "File", + "start": 0, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "errors": [ + "SyntaxError: Expected number in radix 2 (1:3)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 0, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "extra": { + "rawValue": 2, + "raw": "0b12" + }, + "value": 2 + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/211/options.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/211/options.json deleted file mode 100644 index 40dc3da9a8f4..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/211/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Expected number in radix 2 (1:2)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/211/output.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/211/output.json new file mode 100644 index 000000000000..c87719ade97e --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/211/output.json @@ -0,0 +1,73 @@ +{ + "type": "File", + "start": 0, + "end": 2, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 2 + } + }, + "errors": [ + "SyntaxError: Expected number in radix 2 (1:2)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 2, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 2 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 2, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 2 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 0, + "end": 2, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 2 + } + }, + "extra": { + "rawValue": null, + "raw": "0B" + }, + "value": null + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/213/options.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/213/options.json deleted file mode 100644 index 40dc3da9a8f4..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/213/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Expected number in radix 2 (1:2)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/213/output.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/213/output.json new file mode 100644 index 000000000000..e82ab6ace61a --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/213/output.json @@ -0,0 +1,73 @@ +{ + "type": "File", + "start": 0, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "errors": [ + "SyntaxError: Expected number in radix 2 (1:2)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 0, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "extra": { + "rawValue": 0, + "raw": "0B9" + }, + "value": 0 + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/214/options.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/214/options.json deleted file mode 100644 index d52d9cfac4bc..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/214/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Unexpected token, expected \";\" (1:3)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/214/output.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/214/output.json new file mode 100644 index 000000000000..3726afdc10d4 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/214/output.json @@ -0,0 +1,73 @@ +{ + "type": "File", + "start": 0, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "errors": [ + "SyntaxError: Expected number in radix 2 (1:3)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 0, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "extra": { + "rawValue": 2, + "raw": "0B18" + }, + "value": 2 + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/215/options.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/215/options.json deleted file mode 100644 index d52d9cfac4bc..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/215/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Unexpected token, expected \";\" (1:3)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/215/output.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/215/output.json new file mode 100644 index 000000000000..402fcffc9e54 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/215/output.json @@ -0,0 +1,73 @@ +{ + "type": "File", + "start": 0, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "errors": [ + "SyntaxError: Expected number in radix 2 (1:3)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 0, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "extra": { + "rawValue": 2, + "raw": "0B12" + }, + "value": 2 + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/216/options.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/216/options.json index 77b813987217..8dfd231d943b 100644 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/216/options.json +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/216/options.json @@ -1,3 +1,3 @@ { - "throws": "Code point out of bounds (1:4)" -} + "throws": "Invalid code point 1114112" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/217/options.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/217/options.json deleted file mode 100644 index efaa7d304ccc..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/217/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Bad character escape sequence (1:4)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/217/output.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/217/output.json new file mode 100644 index 000000000000..6052cbe571f5 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/217/output.json @@ -0,0 +1,73 @@ +{ + "type": "File", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "errors": [ + "SyntaxError: Bad character escape sequence (1:4)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [], + "directives": [ + { + "type": "Directive", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "value": "\\u{}", + "extra": { + "raw": "\"\\u{}\"", + "rawValue": "\\u{}" + } + } + } + ] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/218/options.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/218/options.json deleted file mode 100644 index efaa7d304ccc..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/218/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Bad character escape sequence (1:4)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/218/output.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/218/output.json new file mode 100644 index 000000000000..781e807d0c94 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/218/output.json @@ -0,0 +1,73 @@ +{ + "type": "File", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "errors": [ + "SyntaxError: Bad character escape sequence (1:4)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [], + "directives": [ + { + "type": "Directive", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "value": "\\u{FFFF", + "extra": { + "raw": "\"\\u{FFFF\"", + "rawValue": "\\u{FFFF" + } + } + } + ] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/219/options.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/219/options.json deleted file mode 100644 index efaa7d304ccc..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/219/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Bad character escape sequence (1:4)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/219/output.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/219/output.json new file mode 100644 index 000000000000..fcf4254c7a65 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/219/output.json @@ -0,0 +1,73 @@ +{ + "type": "File", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "errors": [ + "SyntaxError: Bad character escape sequence (1:4)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [], + "directives": [ + { + "type": "Directive", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "value": "\\u{FFZ}", + "extra": { + "raw": "\"\\u{FFZ}\"", + "rawValue": "\\u{FFZ}" + } + } + } + ] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/220/options.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/220/options.json deleted file mode 100644 index 6010e96ed144..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/220/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid left-hand side in assignment expression (1:0)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/220/output.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/220/output.json new file mode 100644 index 000000000000..51d63380296a --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/220/output.json @@ -0,0 +1,120 @@ +{ + "type": "File", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "errors": [ + "SyntaxError: Invalid left-hand side in assignment expression (1:0)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "expression": { + "type": "AssignmentExpression", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "operator": "+=", + "left": { + "type": "ArrayExpression", + "start": 0, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "elements": [ + { + "type": "Identifier", + "start": 1, + "end": 2, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 2 + }, + "identifierName": "v" + }, + "name": "v" + } + ] + }, + "right": { + "type": "Identifier", + "start": 7, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 10 + }, + "identifierName": "ary" + }, + "name": "ary" + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/221/options.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/221/options.json deleted file mode 100644 index 7c5f08eb9ba6..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/221/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid left-hand side in assignment expression (1:1)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/221/output.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/221/output.json new file mode 100644 index 000000000000..58fa4ffd7fb9 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/221/output.json @@ -0,0 +1,126 @@ +{ + "type": "File", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "errors": [ + "SyntaxError: Invalid left-hand side in array destructuring pattern (1:1)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "expression": { + "type": "AssignmentExpression", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "operator": "=", + "left": { + "type": "ArrayPattern", + "start": 0, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "elements": [ + { + "type": "NumericLiteral", + "start": 1, + "end": 2, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 2 + } + }, + "extra": { + "rawValue": 2, + "raw": "2" + }, + "value": 2 + } + ] + }, + "right": { + "type": "NumericLiteral", + "start": 6, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "extra": { + "rawValue": 42, + "raw": "42" + }, + "value": 42 + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/222/input.js b/packages/babel-parser/test/fixtures/es2015/uncategorised/222/input.js index 67f4e9ae35f3..2e33b3f144ba 100644 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/222/input.js +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/222/input.js @@ -1 +1 @@ -({ obj:20 }) = 42 \ No newline at end of file +({ obj:20 } = 42) \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/222/options.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/222/options.json deleted file mode 100644 index e6630c3da3e8..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/222/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid left-hand side in object destructuring pattern (1:7)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/222/output.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/222/output.json new file mode 100644 index 000000000000..e758dffee7fa --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/222/output.json @@ -0,0 +1,165 @@ +{ + "type": "File", + "start": 0, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "errors": [ + "SyntaxError: Invalid left-hand side in object destructuring pattern (1:7)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "expression": { + "type": "AssignmentExpression", + "start": 1, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "operator": "=", + "left": { + "type": "ObjectPattern", + "start": 1, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "properties": [ + { + "type": "ObjectProperty", + "start": 3, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "method": false, + "key": { + "type": "Identifier", + "start": 3, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 6 + }, + "identifierName": "obj" + }, + "name": "obj" + }, + "computed": false, + "shorthand": false, + "value": { + "type": "NumericLiteral", + "start": 7, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "extra": { + "rawValue": 20, + "raw": "20" + }, + "value": 20 + } + } + ] + }, + "right": { + "type": "NumericLiteral", + "start": 14, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "extra": { + "rawValue": 42, + "raw": "42" + }, + "value": 42 + }, + "extra": { + "parenthesized": true, + "parenStart": 0 + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/223/input.js b/packages/babel-parser/test/fixtures/es2015/uncategorised/223/input.js index 6c808fb17ea6..7cf8d0fb9429 100644 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/223/input.js +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/223/input.js @@ -1 +1 @@ -( { get x() {} } ) = 0 \ No newline at end of file +( { get x() {} } = 0 ) \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/223/options.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/223/options.json deleted file mode 100644 index da1e10744904..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/223/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Object pattern can't contain getter or setter (1:8)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/223/output.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/223/output.json new file mode 100644 index 000000000000..426006b7cdfb --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/223/output.json @@ -0,0 +1,166 @@ +{ + "type": "File", + "start": 0, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "errors": [ + "SyntaxError: Object pattern can't contain getter or setter (1:8)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "expression": { + "type": "AssignmentExpression", + "start": 2, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 2 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "operator": "=", + "left": { + "type": "ObjectPattern", + "start": 2, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 2 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "properties": [ + { + "type": "ObjectMethod", + "start": 4, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "method": false, + "key": { + "type": "Identifier", + "start": 8, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 9 + }, + "identifierName": "x" + }, + "name": "x" + }, + "computed": false, + "kind": "get", + "id": null, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 12, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "body": [], + "directives": [] + } + } + ] + }, + "right": { + "type": "NumericLiteral", + "start": 19, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + }, + "extra": { + "parenthesized": true, + "parenStart": 0 + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/226/options.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/226/options.json deleted file mode 100644 index 74c1a72d5030..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/226/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Unexpected keyword 'default' (1:9)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/226/output.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/226/output.json new file mode 100644 index 000000000000..c725f1875b33 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/226/output.json @@ -0,0 +1,90 @@ +{ + "type": "File", + "start": 0, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "errors": [ + "SyntaxError: Unexpected keyword 'default' (1:9)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 16 + }, + "identifierName": "default" + }, + "name": "default" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 19, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "body": [], + "directives": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/227/options.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/227/options.json deleted file mode 100644 index 3f171f03c70c..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/227/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Binding 'eval' in strict mode (1:44)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/227/output.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/227/output.json new file mode 100644 index 000000000000..2a794ddc885e --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/227/output.json @@ -0,0 +1,292 @@ +{ + "type": "File", + "start": 0, + "end": 59, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 59 + } + }, + "errors": [ + "SyntaxError: Binding 'eval' in strict mode (1:44)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 59, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 59 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 59, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 59 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 14 + }, + "identifierName": "hello" + }, + "name": "hello" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 17, + "end": 59, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 59 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 32, + "end": 57, + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 57 + } + }, + "expression": { + "type": "ObjectExpression", + "start": 33, + "end": 55, + "loc": { + "start": { + "line": 1, + "column": 33 + }, + "end": { + "line": 1, + "column": 55 + } + }, + "properties": [ + { + "type": "ObjectProperty", + "start": 35, + "end": 40, + "loc": { + "start": { + "line": 1, + "column": 35 + }, + "end": { + "line": 1, + "column": 40 + } + }, + "method": false, + "key": { + "type": "Identifier", + "start": 35, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 35 + }, + "end": { + "line": 1, + "column": 36 + }, + "identifierName": "i" + }, + "name": "i" + }, + "computed": false, + "shorthand": false, + "value": { + "type": "NumericLiteral", + "start": 38, + "end": 40, + "loc": { + "start": { + "line": 1, + "column": 38 + }, + "end": { + "line": 1, + "column": 40 + } + }, + "extra": { + "rawValue": 10, + "raw": "10" + }, + "value": 10 + } + }, + { + "type": "ObjectMethod", + "start": 42, + "end": 53, + "loc": { + "start": { + "line": 1, + "column": 42 + }, + "end": { + "line": 1, + "column": 53 + } + }, + "method": true, + "key": { + "type": "Identifier", + "start": 42, + "end": 43, + "loc": { + "start": { + "line": 1, + "column": 42 + }, + "end": { + "line": 1, + "column": 43 + }, + "identifierName": "s" + }, + "name": "s" + }, + "computed": false, + "kind": "method", + "id": null, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "start": 44, + "end": 48, + "loc": { + "start": { + "line": 1, + "column": 44 + }, + "end": { + "line": 1, + "column": 48 + }, + "identifierName": "eval" + }, + "name": "eval" + } + ], + "body": { + "type": "BlockStatement", + "start": 50, + "end": 53, + "loc": { + "start": { + "line": 1, + "column": 50 + }, + "end": { + "line": 1, + "column": 53 + } + }, + "body": [], + "directives": [] + } + } + ], + "extra": { + "parenthesized": true, + "parenStart": 32 + } + } + } + ], + "directives": [ + { + "type": "Directive", + "start": 18, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 18, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "value": "use strict", + "extra": { + "raw": "'use strict'", + "rawValue": "use strict" + } + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/228/options.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/228/options.json deleted file mode 100644 index a33dde469094..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/228/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Argument name clash (1:37)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/228/output.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/228/output.json new file mode 100644 index 000000000000..73e7c59a8b68 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/228/output.json @@ -0,0 +1,254 @@ +{ + "type": "File", + "start": 0, + "end": 49, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 49 + } + }, + "errors": [ + "SyntaxError: Argument name clash (1:37)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 49, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 49 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 49, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 49 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 10 + }, + "identifierName": "a" + }, + "name": "a" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 13, + "end": 49, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 49 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 29, + "end": 47, + "loc": { + "start": { + "line": 1, + "column": 29 + }, + "end": { + "line": 1, + "column": 47 + } + }, + "expression": { + "type": "ObjectExpression", + "start": 30, + "end": 45, + "loc": { + "start": { + "line": 1, + "column": 30 + }, + "end": { + "line": 1, + "column": 45 + } + }, + "properties": [ + { + "type": "ObjectMethod", + "start": 32, + "end": 43, + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 43 + } + }, + "method": true, + "key": { + "type": "Identifier", + "start": 32, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 33 + }, + "identifierName": "b" + }, + "name": "b" + }, + "computed": false, + "kind": "method", + "id": null, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "start": 34, + "end": 35, + "loc": { + "start": { + "line": 1, + "column": 34 + }, + "end": { + "line": 1, + "column": 35 + }, + "identifierName": "t" + }, + "name": "t" + }, + { + "type": "Identifier", + "start": 37, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 37 + }, + "end": { + "line": 1, + "column": 38 + }, + "identifierName": "t" + }, + "name": "t" + } + ], + "body": { + "type": "BlockStatement", + "start": 40, + "end": 43, + "loc": { + "start": { + "line": 1, + "column": 40 + }, + "end": { + "line": 1, + "column": 43 + } + }, + "body": [], + "directives": [] + } + } + ], + "extra": { + "parenthesized": true, + "parenStart": 29 + } + } + } + ], + "directives": [ + { + "type": "Directive", + "start": 15, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 28 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 15, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 27 + } + }, + "value": "use strict", + "extra": { + "raw": "\"use strict\"", + "rawValue": "use strict" + } + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/229/options.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/229/options.json deleted file mode 100644 index 5c79fd4f4ff2..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/229/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Unexpected keyword 'super' (1:4)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/229/output.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/229/output.json new file mode 100644 index 000000000000..c129c3fce1d1 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/229/output.json @@ -0,0 +1,89 @@ +{ + "type": "File", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "errors": [ + "SyntaxError: Unexpected keyword 'super' (1:4)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "VariableDeclaration", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 4, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "id": { + "type": "Identifier", + "start": 4, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 9 + }, + "identifierName": "super" + }, + "name": "super" + }, + "init": null + } + ], + "kind": "var" + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/230/options.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/230/options.json deleted file mode 100644 index 8a17d90eba69..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/230/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Unexpected keyword 'default' (1:4)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/230/output.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/230/output.json new file mode 100644 index 000000000000..e901e11e9473 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/230/output.json @@ -0,0 +1,89 @@ +{ + "type": "File", + "start": 0, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "errors": [ + "SyntaxError: Unexpected keyword 'default' (1:4)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "VariableDeclaration", + "start": 0, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 4, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "id": { + "type": "Identifier", + "start": 4, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 11 + }, + "identifierName": "default" + }, + "name": "default" + }, + "init": null + } + ], + "kind": "var" + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/231/options.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/231/options.json deleted file mode 100644 index 8a17d90eba69..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/231/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Unexpected keyword 'default' (1:4)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/231/output.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/231/output.json new file mode 100644 index 000000000000..635346ad81de --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/231/output.json @@ -0,0 +1,89 @@ +{ + "type": "File", + "start": 0, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "errors": [ + "SyntaxError: Unexpected keyword 'default' (1:4)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "VariableDeclaration", + "start": 0, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 4, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "id": { + "type": "Identifier", + "start": 4, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 11 + }, + "identifierName": "default" + }, + "name": "default" + }, + "init": null + } + ], + "kind": "let" + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/232/input.js b/packages/babel-parser/test/fixtures/es2015/uncategorised/232/input.js index 49ff0434557a..5b6b54d778e4 100644 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/232/input.js +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/232/input.js @@ -1 +1 @@ -const default \ No newline at end of file +const default = 2 \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/232/options.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/232/options.json deleted file mode 100644 index d91e2a5bbc25..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/232/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Unexpected keyword 'default' (1:6)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/232/output.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/232/output.json new file mode 100644 index 000000000000..760cb15ffdeb --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/232/output.json @@ -0,0 +1,108 @@ +{ + "type": "File", + "start": 0, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "errors": [ + "SyntaxError: Unexpected keyword 'default' (1:6)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "VariableDeclaration", + "start": 0, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 6, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "id": { + "type": "Identifier", + "start": 6, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 13 + }, + "identifierName": "default" + }, + "name": "default" + }, + "init": { + "type": "NumericLiteral", + "start": 16, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "extra": { + "rawValue": 2, + "raw": "2" + }, + "value": 2 + } + } + ], + "kind": "const" + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/233/input.js b/packages/babel-parser/test/fixtures/es2015/uncategorised/233/input.js index 40ac1e2b4639..7afe6af895a0 100644 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/233/input.js +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/233/input.js @@ -1 +1 @@ -"use strict"; ({ v: eval }) = obj \ No newline at end of file +"use strict"; ({ v: eval } = obj) \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/233/options.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/233/options.json deleted file mode 100644 index 084570ac7584..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/233/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Assigning to 'eval' in strict mode (1:20)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/233/output.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/233/output.json new file mode 100644 index 000000000000..bd58e38aa176 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/233/output.json @@ -0,0 +1,195 @@ +{ + "type": "File", + "start": 0, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 33 + } + }, + "errors": [ + "SyntaxError: Assigning to 'eval' in strict mode (1:20)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 33 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 14, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 33 + } + }, + "expression": { + "type": "AssignmentExpression", + "start": 15, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "operator": "=", + "left": { + "type": "ObjectPattern", + "start": 15, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "properties": [ + { + "type": "ObjectProperty", + "start": 17, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "method": false, + "key": { + "type": "Identifier", + "start": 17, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 18 + }, + "identifierName": "v" + }, + "name": "v" + }, + "computed": false, + "shorthand": false, + "value": { + "type": "Identifier", + "start": 20, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 20 + }, + "end": { + "line": 1, + "column": 24 + }, + "identifierName": "eval" + }, + "name": "eval" + } + } + ] + }, + "right": { + "type": "Identifier", + "start": 29, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 29 + }, + "end": { + "line": 1, + "column": 32 + }, + "identifierName": "obj" + }, + "name": "obj" + }, + "extra": { + "parenthesized": true, + "parenStart": 14 + } + } + } + ], + "directives": [ + { + "type": "Directive", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 0, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "value": "use strict", + "extra": { + "raw": "\"use strict\"", + "rawValue": "use strict" + } + } + } + ] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/234/input.js b/packages/babel-parser/test/fixtures/es2015/uncategorised/234/input.js index cb924f3bb153..2e399474efe9 100644 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/234/input.js +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/234/input.js @@ -1 +1 @@ -"use strict"; ({ v: arguments }) = obj \ No newline at end of file +"use strict"; ({ v: arguments } = obj) \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/234/options.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/234/options.json deleted file mode 100644 index bfa460f59bbd..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/234/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Assigning to 'arguments' in strict mode (1:20)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/234/output.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/234/output.json new file mode 100644 index 000000000000..60d3496c8663 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/234/output.json @@ -0,0 +1,195 @@ +{ + "type": "File", + "start": 0, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 38 + } + }, + "errors": [ + "SyntaxError: Assigning to 'arguments' in strict mode (1:20)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 38 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 14, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 38 + } + }, + "expression": { + "type": "AssignmentExpression", + "start": 15, + "end": 37, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 37 + } + }, + "operator": "=", + "left": { + "type": "ObjectPattern", + "start": 15, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "properties": [ + { + "type": "ObjectProperty", + "start": 17, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "method": false, + "key": { + "type": "Identifier", + "start": 17, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 18 + }, + "identifierName": "v" + }, + "name": "v" + }, + "computed": false, + "shorthand": false, + "value": { + "type": "Identifier", + "start": 20, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 20 + }, + "end": { + "line": 1, + "column": 29 + }, + "identifierName": "arguments" + }, + "name": "arguments" + } + } + ] + }, + "right": { + "type": "Identifier", + "start": 34, + "end": 37, + "loc": { + "start": { + "line": 1, + "column": 34 + }, + "end": { + "line": 1, + "column": 37 + }, + "identifierName": "obj" + }, + "name": "obj" + }, + "extra": { + "parenthesized": true, + "parenStart": 14 + } + } + } + ], + "directives": [ + { + "type": "Directive", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 0, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "value": "use strict", + "extra": { + "raw": "\"use strict\"", + "rawValue": "use strict" + } + } + } + ] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/235/options.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/235/options.json deleted file mode 100644 index 68677faac9b9..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/235/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "for-in loop variable declaration may not have an initializer (1:5)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/235/output.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/235/output.json new file mode 100644 index 000000000000..f42607bf0849 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/235/output.json @@ -0,0 +1,206 @@ +{ + "type": "File", + "start": 0, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "errors": [ + "SyntaxError: for-in loop variable declaration may not have an initializer (1:5)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ForInStatement", + "start": 0, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "left": { + "type": "VariableDeclaration", + "start": 5, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 9, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 10 + }, + "identifierName": "x" + }, + "name": "x" + }, + "init": { + "type": "NumericLiteral", + "start": 13, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "extra": { + "rawValue": 42, + "raw": "42" + }, + "value": 42 + } + } + ], + "kind": "let" + }, + "right": { + "type": "Identifier", + "start": 19, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 23 + }, + "identifierName": "list" + }, + "name": "list" + }, + "body": { + "type": "ExpressionStatement", + "start": 25, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 25 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "expression": { + "type": "CallExpression", + "start": 25, + "end": 35, + "loc": { + "start": { + "line": 1, + "column": 25 + }, + "end": { + "line": 1, + "column": 35 + } + }, + "callee": { + "type": "Identifier", + "start": 25, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 25 + }, + "end": { + "line": 1, + "column": 32 + }, + "identifierName": "process" + }, + "name": "process" + }, + "arguments": [ + { + "type": "Identifier", + "start": 33, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 33 + }, + "end": { + "line": 1, + "column": 34 + }, + "identifierName": "x" + }, + "name": "x" + } + ] + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/236/options.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/236/options.json deleted file mode 100644 index 1fc5db8949ff..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/236/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "for-of loop variable declaration may not have an initializer (1:5)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/236/output.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/236/output.json new file mode 100644 index 000000000000..1679566d43da --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/236/output.json @@ -0,0 +1,207 @@ +{ + "type": "File", + "start": 0, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "errors": [ + "SyntaxError: for-of loop variable declaration may not have an initializer (1:5)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ForOfStatement", + "start": 0, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "await": false, + "left": { + "type": "VariableDeclaration", + "start": 5, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 9, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 10 + }, + "identifierName": "x" + }, + "name": "x" + }, + "init": { + "type": "NumericLiteral", + "start": 13, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "extra": { + "rawValue": 42, + "raw": "42" + }, + "value": 42 + } + } + ], + "kind": "let" + }, + "right": { + "type": "Identifier", + "start": 19, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 23 + }, + "identifierName": "list" + }, + "name": "list" + }, + "body": { + "type": "ExpressionStatement", + "start": 25, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 25 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "expression": { + "type": "CallExpression", + "start": 25, + "end": 35, + "loc": { + "start": { + "line": 1, + "column": 25 + }, + "end": { + "line": 1, + "column": 35 + } + }, + "callee": { + "type": "Identifier", + "start": 25, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 25 + }, + "end": { + "line": 1, + "column": 32 + }, + "identifierName": "process" + }, + "name": "process" + }, + "arguments": [ + { + "type": "Identifier", + "start": 33, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 33 + }, + "end": { + "line": 1, + "column": 34 + }, + "identifierName": "x" + }, + "name": "x" + } + ] + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/242/options.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/242/options.json deleted file mode 100644 index 92845f5f2081..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/242/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Assigning to 'eval' in strict mode (1:15)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/242/output.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/242/output.json new file mode 100644 index 000000000000..3731ec6d7b75 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/242/output.json @@ -0,0 +1,182 @@ +{ + "type": "File", + "start": 0, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "errors": [ + "SyntaxError: Assigning to 'eval' in strict mode (1:15)", + "SyntaxError: Binding 'eval' in strict mode (1:15)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 14, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "expression": { + "type": "ArrowFunctionExpression", + "start": 14, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "id": null, + "generator": false, + "async": false, + "params": [ + { + "type": "AssignmentPattern", + "start": 15, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "left": { + "type": "Identifier", + "start": 15, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 19 + }, + "identifierName": "eval" + }, + "name": "eval" + }, + "right": { + "type": "NumericLiteral", + "start": 22, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 22 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "extra": { + "rawValue": 10, + "raw": "10" + }, + "value": 10 + } + } + ], + "body": { + "type": "NumericLiteral", + "start": 29, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 29 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "extra": { + "rawValue": 42, + "raw": "42" + }, + "value": 42 + } + } + } + ], + "directives": [ + { + "type": "Directive", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 0, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "value": "use strict", + "extra": { + "raw": "\"use strict\"", + "rawValue": "use strict" + } + } + } + ] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/243/options.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/243/options.json deleted file mode 100644 index ad54c428a2f9..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/243/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Binding 'eval' in strict mode (1:14)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/243/output.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/243/output.json new file mode 100644 index 000000000000..dbffe6547ab5 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/243/output.json @@ -0,0 +1,146 @@ +{ + "type": "File", + "start": 0, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "errors": [ + "SyntaxError: Binding 'eval' in strict mode (1:14)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 14, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "expression": { + "type": "ArrowFunctionExpression", + "start": 14, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "id": null, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "start": 14, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 18 + }, + "identifierName": "eval" + }, + "name": "eval" + } + ], + "body": { + "type": "NumericLiteral", + "start": 22, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 22 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "extra": { + "rawValue": 42, + "raw": "42" + }, + "value": 42 + } + } + } + ], + "directives": [ + { + "type": "Directive", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 0, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "value": "use strict", + "extra": { + "raw": "\"use strict\"", + "rawValue": "use strict" + } + } + } + ] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/244/options.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/244/options.json deleted file mode 100644 index bfa08eae293e..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/244/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Binding 'arguments' in strict mode (1:14)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/244/output.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/244/output.json new file mode 100644 index 000000000000..1b3ed15f002e --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/244/output.json @@ -0,0 +1,146 @@ +{ + "type": "File", + "start": 0, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "errors": [ + "SyntaxError: Binding 'arguments' in strict mode (1:14)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 14, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "expression": { + "type": "ArrowFunctionExpression", + "start": 14, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "id": null, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "start": 14, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 23 + }, + "identifierName": "arguments" + }, + "name": "arguments" + } + ], + "body": { + "type": "NumericLiteral", + "start": 27, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 27 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "extra": { + "rawValue": 42, + "raw": "42" + }, + "value": 42 + } + } + } + ], + "directives": [ + { + "type": "Directive", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 0, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "value": "use strict", + "extra": { + "raw": "\"use strict\"", + "rawValue": "use strict" + } + } + } + ] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/245/options.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/245/options.json deleted file mode 100644 index 794c4864d4e5..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/245/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Binding 'eval' in strict mode (1:15)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/245/output.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/245/output.json new file mode 100644 index 000000000000..6b7ae83c0ad2 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/245/output.json @@ -0,0 +1,163 @@ +{ + "type": "File", + "start": 0, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "errors": [ + "SyntaxError: Binding 'eval' in strict mode (1:15)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 14, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "expression": { + "type": "ArrowFunctionExpression", + "start": 14, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "id": null, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "start": 15, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 19 + }, + "identifierName": "eval" + }, + "name": "eval" + }, + { + "type": "Identifier", + "start": 21, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 21 + }, + "end": { + "line": 1, + "column": 22 + }, + "identifierName": "a" + }, + "name": "a" + } + ], + "body": { + "type": "NumericLiteral", + "start": 27, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 27 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "extra": { + "rawValue": 42, + "raw": "42" + }, + "value": 42 + } + } + } + ], + "directives": [ + { + "type": "Directive", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 0, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "value": "use strict", + "extra": { + "raw": "\"use strict\"", + "rawValue": "use strict" + } + } + } + ] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/246/options.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/246/options.json deleted file mode 100644 index 212d35fcb5fe..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/246/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Binding 'arguments' in strict mode (1:15)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/246/output.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/246/output.json new file mode 100644 index 000000000000..c681755fb108 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/246/output.json @@ -0,0 +1,163 @@ +{ + "type": "File", + "start": 0, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 34 + } + }, + "errors": [ + "SyntaxError: Binding 'arguments' in strict mode (1:15)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 34 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 14, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 34 + } + }, + "expression": { + "type": "ArrowFunctionExpression", + "start": 14, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 34 + } + }, + "id": null, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "start": 15, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 24 + }, + "identifierName": "arguments" + }, + "name": "arguments" + }, + { + "type": "Identifier", + "start": 26, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 26 + }, + "end": { + "line": 1, + "column": 27 + }, + "identifierName": "a" + }, + "name": "a" + } + ], + "body": { + "type": "NumericLiteral", + "start": 32, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 34 + } + }, + "extra": { + "rawValue": 42, + "raw": "42" + }, + "value": 42 + } + } + } + ], + "directives": [ + { + "type": "Directive", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 0, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "value": "use strict", + "extra": { + "raw": "\"use strict\"", + "rawValue": "use strict" + } + } + } + ] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/247/options.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/247/options.json deleted file mode 100644 index 794c4864d4e5..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/247/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Binding 'eval' in strict mode (1:15)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/247/output.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/247/output.json new file mode 100644 index 000000000000..b8b375182e2c --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/247/output.json @@ -0,0 +1,198 @@ +{ + "type": "File", + "start": 0, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 34 + } + }, + "errors": [ + "SyntaxError: Binding 'eval' in strict mode (1:15)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 34 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 14, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 34 + } + }, + "expression": { + "type": "ArrowFunctionExpression", + "start": 14, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 34 + } + }, + "id": null, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "start": 15, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 19 + }, + "identifierName": "eval" + }, + "name": "eval" + }, + { + "type": "AssignmentPattern", + "start": 21, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 21 + }, + "end": { + "line": 1, + "column": 27 + } + }, + "left": { + "type": "Identifier", + "start": 21, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 21 + }, + "end": { + "line": 1, + "column": 22 + }, + "identifierName": "a" + }, + "name": "a" + }, + "right": { + "type": "NumericLiteral", + "start": 25, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 25 + }, + "end": { + "line": 1, + "column": 27 + } + }, + "extra": { + "rawValue": 10, + "raw": "10" + }, + "value": 10 + } + } + ], + "body": { + "type": "NumericLiteral", + "start": 32, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 34 + } + }, + "extra": { + "rawValue": 42, + "raw": "42" + }, + "value": 42 + } + } + } + ], + "directives": [ + { + "type": "Directive", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 0, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "value": "use strict", + "extra": { + "raw": "\"use strict\"", + "rawValue": "use strict" + } + } + } + ] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/248/options.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/248/options.json deleted file mode 100644 index b99fd35222b1..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/248/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Argument name clash (1:18)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/248/output.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/248/output.json new file mode 100644 index 000000000000..3a5f60bdddea --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/248/output.json @@ -0,0 +1,163 @@ +{ + "type": "File", + "start": 0, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "errors": [ + "SyntaxError: Argument name clash (1:18)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 14, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "expression": { + "type": "ArrowFunctionExpression", + "start": 14, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "id": null, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "start": 15, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 16 + }, + "identifierName": "a" + }, + "name": "a" + }, + { + "type": "Identifier", + "start": 18, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 19 + }, + "identifierName": "a" + }, + "name": "a" + } + ], + "body": { + "type": "NumericLiteral", + "start": 24, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 24 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "extra": { + "rawValue": 42, + "raw": "42" + }, + "value": 42 + } + } + } + ], + "directives": [ + { + "type": "Directive", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 0, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "value": "use strict", + "extra": { + "raw": "\"use strict\"", + "rawValue": "use strict" + } + } + } + ] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/249/options.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/249/options.json deleted file mode 100644 index 79a05e62290e..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/249/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Legacy octal literals are not allowed in strict mode (1:21)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/249/output.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/249/output.json new file mode 100644 index 000000000000..18c0889f74b8 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/249/output.json @@ -0,0 +1,146 @@ +{ + "type": "File", + "start": 0, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "errors": [ + "SyntaxError: Legacy octal literals are not allowed in strict mode (1:21)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 14, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "expression": { + "type": "ArrowFunctionExpression", + "start": 14, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "id": null, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "start": 15, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 16 + }, + "identifierName": "a" + }, + "name": "a" + } + ], + "body": { + "type": "NumericLiteral", + "start": 21, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 21 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "extra": { + "rawValue": 0, + "raw": "00" + }, + "value": 0 + } + } + } + ], + "directives": [ + { + "type": "Directive", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 0, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "value": "use strict", + "extra": { + "raw": "\"use strict\"", + "rawValue": "use strict" + } + } + } + ] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/251/options.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/251/options.json deleted file mode 100644 index 99ffc0de0153..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/251/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid left-hand side in arrow function parameters (1:1)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/251/output.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/251/output.json new file mode 100644 index 000000000000..a7c444dfbcdc --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/251/output.json @@ -0,0 +1,113 @@ +{ + "type": "File", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "errors": [ + "SyntaxError: Binding invalid left-hand side in function parameter list (1:1)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "expression": { + "type": "ArrowFunctionExpression", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "id": null, + "generator": false, + "async": false, + "params": [ + { + "type": "NumericLiteral", + "start": 1, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "extra": { + "rawValue": 10, + "raw": "10" + }, + "value": 10 + } + ], + "body": { + "type": "NumericLiteral", + "start": 8, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "extra": { + "rawValue": 0, + "raw": "00" + }, + "value": 0 + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/252/options.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/252/options.json deleted file mode 100644 index 99ffc0de0153..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/252/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid left-hand side in arrow function parameters (1:1)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/252/output.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/252/output.json new file mode 100644 index 000000000000..2d80f047d283 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/252/output.json @@ -0,0 +1,134 @@ +{ + "type": "File", + "start": 0, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "errors": [ + "SyntaxError: Binding invalid left-hand side in function parameter list (1:1)", + "SyntaxError: Binding invalid left-hand side in function parameter list (1:5)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "expression": { + "type": "ArrowFunctionExpression", + "start": 0, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "id": null, + "generator": false, + "async": false, + "params": [ + { + "type": "NumericLiteral", + "start": 1, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "extra": { + "rawValue": 10, + "raw": "10" + }, + "value": 10 + }, + { + "type": "NumericLiteral", + "start": 5, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "extra": { + "rawValue": 20, + "raw": "20" + }, + "value": 20 + } + ], + "body": { + "type": "NumericLiteral", + "start": 12, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "extra": { + "rawValue": 0, + "raw": "00" + }, + "value": 0 + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/280/options.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/280/options.json deleted file mode 100644 index 5cbee309bd50..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/280/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Argument name clash (1:30)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/280/output.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/280/output.json new file mode 100644 index 000000000000..299c0dabdaa1 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/280/output.json @@ -0,0 +1,216 @@ +{ + "type": "File", + "start": 0, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "errors": [ + "SyntaxError: Argument name clash (1:30)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 14, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "id": { + "type": "Identifier", + "start": 23, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 23 + }, + "end": { + "line": 1, + "column": 24 + }, + "identifierName": "x" + }, + "name": "x" + }, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "start": 25, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 25 + }, + "end": { + "line": 1, + "column": 26 + }, + "identifierName": "a" + }, + "name": "a" + }, + { + "type": "ObjectPattern", + "start": 28, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 28 + }, + "end": { + "line": 1, + "column": 33 + } + }, + "properties": [ + { + "type": "ObjectProperty", + "start": 30, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 30 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "method": false, + "key": { + "type": "Identifier", + "start": 30, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 30 + }, + "end": { + "line": 1, + "column": 31 + }, + "identifierName": "a" + }, + "name": "a" + }, + "computed": false, + "shorthand": true, + "value": { + "type": "Identifier", + "start": 30, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 30 + }, + "end": { + "line": 1, + "column": 31 + }, + "identifierName": "a" + }, + "name": "a" + }, + "extra": { + "shorthand": true + } + } + ] + } + ], + "body": { + "type": "BlockStatement", + "start": 34, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 34 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "body": [], + "directives": [] + } + } + ], + "directives": [ + { + "type": "Directive", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 0, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "value": "use strict", + "extra": { + "raw": "\"use strict\"", + "rawValue": "use strict" + } + } + } + ] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/281/options.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/281/options.json deleted file mode 100644 index 8dba9882c0dc..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/281/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Argument name clash (1:47)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/281/output.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/281/output.json new file mode 100644 index 000000000000..50b6eca3fddd --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/281/output.json @@ -0,0 +1,392 @@ +{ + "type": "File", + "start": 0, + "end": 56, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 56 + } + }, + "errors": [ + "SyntaxError: Argument name clash (1:47)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 56, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 56 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 14, + "end": 56, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 56 + } + }, + "id": { + "type": "Identifier", + "start": 23, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 23 + }, + "end": { + "line": 1, + "column": 24 + }, + "identifierName": "x" + }, + "name": "x" + }, + "generator": false, + "async": false, + "params": [ + { + "type": "ObjectPattern", + "start": 25, + "end": 37, + "loc": { + "start": { + "line": 1, + "column": 25 + }, + "end": { + "line": 1, + "column": 37 + } + }, + "properties": [ + { + "type": "ObjectProperty", + "start": 27, + "end": 35, + "loc": { + "start": { + "line": 1, + "column": 27 + }, + "end": { + "line": 1, + "column": 35 + } + }, + "method": false, + "key": { + "type": "Identifier", + "start": 27, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 27 + }, + "end": { + "line": 1, + "column": 28 + }, + "identifierName": "b" + }, + "name": "b" + }, + "computed": false, + "shorthand": false, + "value": { + "type": "ObjectPattern", + "start": 30, + "end": 35, + "loc": { + "start": { + "line": 1, + "column": 30 + }, + "end": { + "line": 1, + "column": 35 + } + }, + "properties": [ + { + "type": "ObjectProperty", + "start": 32, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 33 + } + }, + "method": false, + "key": { + "type": "Identifier", + "start": 32, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 33 + }, + "identifierName": "a" + }, + "name": "a" + }, + "computed": false, + "shorthand": true, + "value": { + "type": "Identifier", + "start": 32, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 33 + }, + "identifierName": "a" + }, + "name": "a" + }, + "extra": { + "shorthand": true + } + } + ] + } + } + ] + }, + { + "type": "ArrayPattern", + "start": 39, + "end": 53, + "loc": { + "start": { + "line": 1, + "column": 39 + }, + "end": { + "line": 1, + "column": 53 + } + }, + "elements": [ + { + "type": "ObjectPattern", + "start": 40, + "end": 52, + "loc": { + "start": { + "line": 1, + "column": 40 + }, + "end": { + "line": 1, + "column": 52 + } + }, + "properties": [ + { + "type": "ObjectProperty", + "start": 42, + "end": 50, + "loc": { + "start": { + "line": 1, + "column": 42 + }, + "end": { + "line": 1, + "column": 50 + } + }, + "method": false, + "key": { + "type": "Identifier", + "start": 42, + "end": 43, + "loc": { + "start": { + "line": 1, + "column": 42 + }, + "end": { + "line": 1, + "column": 43 + }, + "identifierName": "b" + }, + "name": "b" + }, + "computed": false, + "shorthand": false, + "value": { + "type": "ObjectPattern", + "start": 45, + "end": 50, + "loc": { + "start": { + "line": 1, + "column": 45 + }, + "end": { + "line": 1, + "column": 50 + } + }, + "properties": [ + { + "type": "ObjectProperty", + "start": 47, + "end": 48, + "loc": { + "start": { + "line": 1, + "column": 47 + }, + "end": { + "line": 1, + "column": 48 + } + }, + "method": false, + "key": { + "type": "Identifier", + "start": 47, + "end": 48, + "loc": { + "start": { + "line": 1, + "column": 47 + }, + "end": { + "line": 1, + "column": 48 + }, + "identifierName": "a" + }, + "name": "a" + }, + "computed": false, + "shorthand": true, + "value": { + "type": "Identifier", + "start": 47, + "end": 48, + "loc": { + "start": { + "line": 1, + "column": 47 + }, + "end": { + "line": 1, + "column": 48 + }, + "identifierName": "a" + }, + "name": "a" + }, + "extra": { + "shorthand": true + } + } + ] + } + } + ] + } + ] + } + ], + "body": { + "type": "BlockStatement", + "start": 54, + "end": 56, + "loc": { + "start": { + "line": 1, + "column": 54 + }, + "end": { + "line": 1, + "column": 56 + } + }, + "body": [], + "directives": [] + } + } + ], + "directives": [ + { + "type": "Directive", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 0, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "value": "use strict", + "extra": { + "raw": "\"use strict\"", + "rawValue": "use strict" + } + } + } + ] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/284/options.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/284/options.json deleted file mode 100644 index 71f5061aff9a..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/284/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid left-hand side in arrow function parameters (1:3)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/284/output.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/284/output.json new file mode 100644 index 000000000000..68f6ccb7cefc --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/284/output.json @@ -0,0 +1,127 @@ +{ + "type": "File", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "errors": [ + "SyntaxError: Binding invalid left-hand side in array destructuring pattern (1:3)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "expression": { + "type": "ArrowFunctionExpression", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "id": null, + "generator": false, + "async": false, + "params": [ + { + "type": "ArrayPattern", + "start": 1, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "elements": [ + { + "type": "NumericLiteral", + "start": 3, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "extra": { + "rawValue": 5, + "raw": "5" + }, + "value": 5 + } + ] + } + ], + "body": { + "type": "BlockStatement", + "start": 11, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "body": [], + "directives": [] + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/289/options.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/289/options.json deleted file mode 100644 index a8f0b3c33031..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/289/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Binding 'eval' in strict mode (1:5)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/289/output.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/289/output.json new file mode 100644 index 000000000000..db0bdfa5417b --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/289/output.json @@ -0,0 +1,184 @@ +{ + "type": "File", + "start": 0, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "errors": [ + "SyntaxError: Binding 'eval' in strict mode (1:5)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "expression": { + "type": "ObjectExpression", + "start": 1, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "properties": [ + { + "type": "ObjectMethod", + "start": 3, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 28 + } + }, + "method": true, + "key": { + "type": "Identifier", + "start": 3, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 4 + }, + "identifierName": "t" + }, + "name": "t" + }, + "computed": false, + "kind": "method", + "id": null, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "start": 5, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 9 + }, + "identifierName": "eval" + }, + "name": "eval" + } + ], + "body": { + "type": "BlockStatement", + "start": 11, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 28 + } + }, + "body": [], + "directives": [ + { + "type": "Directive", + "start": 13, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 13, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 25 + } + }, + "value": "use strict", + "extra": { + "raw": "\"use strict\"", + "rawValue": "use strict" + } + } + } + ] + } + } + ], + "extra": { + "parenthesized": true, + "parenStart": 0 + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/290/options.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/290/options.json deleted file mode 100644 index 473cd470d4f1..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/290/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid escape sequence in template (1:23)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/290/output.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/290/output.json new file mode 100644 index 000000000000..34fe89ec4c5a --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/290/output.json @@ -0,0 +1,165 @@ +{ + "type": "File", + "start": 0, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 27 + } + }, + "errors": [ + "SyntaxError: Invalid escape sequence in template (1:23)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 27 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 14, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 27 + } + }, + "expression": { + "type": "TemplateLiteral", + "start": 14, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "expressions": [ + { + "type": "Identifier", + "start": 17, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 21 + }, + "identifierName": "test" + }, + "name": "test" + } + ], + "quasis": [ + { + "type": "TemplateElement", + "start": 15, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "value": { + "raw": "", + "cooked": "" + }, + "tail": false + }, + { + "type": "TemplateElement", + "start": 22, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 22 + }, + "end": { + "line": 1, + "column": 25 + } + }, + "value": { + "raw": "\\02", + "cooked": null + }, + "tail": true + } + ] + } + } + ], + "directives": [ + { + "type": "Directive", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 0, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "value": "use strict", + "extra": { + "raw": "\"use strict\"", + "rawValue": "use strict" + } + } + } + ] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/291/options.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/291/options.json deleted file mode 100644 index ae24fbee33c8..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/291/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "'import' and 'export' may only appear at the top level (1:7)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/291/output.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/291/output.json new file mode 100644 index 000000000000..42655f4b978c --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/291/output.json @@ -0,0 +1,111 @@ +{ + "type": "File", + "start": 0, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "errors": [ + "SyntaxError: 'import' and 'export' may only appear at the top level (1:7)", + "SyntaxError: 'import' and 'export' may appear only with 'sourceType: \"module\"' (1:7)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "IfStatement", + "start": 0, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "test": { + "type": "NumericLiteral", + "start": 4, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + }, + "consequent": { + "type": "ImportDeclaration", + "start": 7, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "specifiers": [], + "source": { + "type": "StringLiteral", + "start": 14, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "extra": { + "rawValue": "acorn", + "raw": "\"acorn\"" + }, + "value": "acorn" + } + }, + "alternate": null + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/296/options.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/296/options.json deleted file mode 100644 index 794c4864d4e5..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/296/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Binding 'eval' in strict mode (1:15)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/296/output.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/296/output.json new file mode 100644 index 000000000000..49e0835c1bfc --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/296/output.json @@ -0,0 +1,146 @@ +{ + "type": "File", + "start": 0, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "errors": [ + "SyntaxError: Binding 'eval' in strict mode (1:15)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 14, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "expression": { + "type": "ArrowFunctionExpression", + "start": 14, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "id": null, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "start": 15, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 19 + }, + "identifierName": "eval" + }, + "name": "eval" + } + ], + "body": { + "type": "NumericLiteral", + "start": 24, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 24 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "extra": { + "rawValue": 42, + "raw": "42" + }, + "value": 42 + } + } + } + ], + "directives": [ + { + "type": "Directive", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 0, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "value": "use strict", + "extra": { + "raw": "\"use strict\"", + "rawValue": "use strict" + } + } + } + ] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/297/options.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/297/options.json deleted file mode 100644 index cc2bef2a9a34..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/297/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Binding 'eval' in strict mode (1:1)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/297/output.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/297/output.json new file mode 100644 index 000000000000..85866aeddd23 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/297/output.json @@ -0,0 +1,179 @@ +{ + "type": "File", + "start": 0, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "errors": [ + "SyntaxError: Binding 'eval' in strict mode (1:1)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "expression": { + "type": "ArrowFunctionExpression", + "start": 0, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "id": null, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "start": 1, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 5 + }, + "identifierName": "eval" + }, + "name": "eval" + } + ], + "body": { + "type": "BlockStatement", + "start": 10, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 26, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 26 + }, + "end": { + "line": 1, + "column": 28 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 26, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 26 + }, + "end": { + "line": 1, + "column": 28 + } + }, + "extra": { + "rawValue": 42, + "raw": "42" + }, + "value": 42 + } + } + ], + "directives": [ + { + "type": "Directive", + "start": 12, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 25 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 12, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "value": "use strict", + "extra": { + "raw": "\"use strict\"", + "rawValue": "use strict" + } + } + } + ] + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/298/options.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/298/options.json deleted file mode 100644 index 49d27a1476b0..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/298/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Object pattern can't contain getter or setter (1:7)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/298/output.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/298/output.json new file mode 100644 index 000000000000..fd0a014544e3 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/298/output.json @@ -0,0 +1,166 @@ +{ + "type": "File", + "start": 0, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "errors": [ + "SyntaxError: Object pattern can't contain getter or setter (1:7)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "expression": { + "type": "ArrowFunctionExpression", + "start": 0, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "id": null, + "generator": false, + "async": false, + "params": [ + { + "type": "ObjectPattern", + "start": 1, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "properties": [ + { + "type": "ObjectMethod", + "start": 3, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "method": false, + "key": { + "type": "Identifier", + "start": 7, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 11 + }, + "identifierName": "test" + }, + "name": "test" + }, + "computed": false, + "kind": "get", + "id": null, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 14, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "body": [], + "directives": [] + } + } + ] + } + ], + "body": { + "type": "NumericLiteral", + "start": 24, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 24 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "extra": { + "rawValue": 42, + "raw": "42" + }, + "value": 42 + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/324/options.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/324/options.json deleted file mode 100644 index d921abda8ff6..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/324/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Complex binding patterns require an initialization value (1:7)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/324/output.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/324/output.json new file mode 100644 index 000000000000..09ca9d8754be --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/324/output.json @@ -0,0 +1,106 @@ +{ + "type": "File", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "errors": [ + "SyntaxError: Complex binding patterns require an initialization value (1:7)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "VariableDeclaration", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 4, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "id": { + "type": "ArrayPattern", + "start": 4, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "elements": [ + { + "type": "Identifier", + "start": 5, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 6 + }, + "identifierName": "x" + }, + "name": "x" + } + ] + }, + "init": null + } + ], + "kind": "let" + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/325/options.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/325/options.json deleted file mode 100644 index d921abda8ff6..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/325/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Complex binding patterns require an initialization value (1:7)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/325/output.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/325/output.json new file mode 100644 index 000000000000..6d0d7ab1d050 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/325/output.json @@ -0,0 +1,106 @@ +{ + "type": "File", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "errors": [ + "SyntaxError: Complex binding patterns require an initialization value (1:7)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "VariableDeclaration", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 4, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "id": { + "type": "ArrayPattern", + "start": 4, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "elements": [ + { + "type": "Identifier", + "start": 5, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 6 + }, + "identifierName": "x" + }, + "name": "x" + } + ] + }, + "init": null + } + ], + "kind": "var" + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/329/options.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/329/options.json deleted file mode 100644 index 97818d2eea7e..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/329/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Lexical declaration cannot appear in a single-statement context (1:9)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/329/output.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/329/output.json new file mode 100644 index 000000000000..9b5c4b8b1857 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/329/output.json @@ -0,0 +1,126 @@ +{ + "type": "File", + "start": 0, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "errors": [ + "SyntaxError: Lexical declaration cannot appear in a single-statement context (1:9)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ForStatement", + "start": 0, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "init": null, + "test": null, + "update": null, + "body": { + "type": "VariableDeclaration", + "start": 9, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 15, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "id": { + "type": "Identifier", + "start": 15, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 16 + }, + "identifierName": "x" + }, + "name": "x" + }, + "init": { + "type": "NumericLiteral", + "start": 19, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "extra": { + "rawValue": 10, + "raw": "10" + }, + "value": 10 + } + } + ], + "kind": "const" + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/332/options.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/332/options.json deleted file mode 100644 index 5718d0551359..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/332/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Assigning to 'eval' in strict mode (1:18)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/332/output.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/332/output.json new file mode 100644 index 000000000000..cc9bdf3e164e --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/332/output.json @@ -0,0 +1,171 @@ +{ + "type": "File", + "start": 0, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "errors": [ + "SyntaxError: Assigning to 'eval' in strict mode (1:18)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 14, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "expression": { + "type": "AssignmentExpression", + "start": 14, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "operator": "=", + "left": { + "type": "ArrayPattern", + "start": 14, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "elements": [ + { + "type": "RestElement", + "start": 15, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "argument": { + "type": "Identifier", + "start": 18, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 22 + }, + "identifierName": "eval" + }, + "name": "eval" + } + } + ] + }, + "right": { + "type": "Identifier", + "start": 26, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 26 + }, + "end": { + "line": 1, + "column": 29 + }, + "identifierName": "arr" + }, + "name": "arr" + } + } + } + ], + "directives": [ + { + "type": "Directive", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 0, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "value": "use strict", + "extra": { + "raw": "'use strict'", + "rawValue": "use strict" + } + } + } + ] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/333/options.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/333/options.json deleted file mode 100644 index 567e40541c5b..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/333/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Unexpected reserved word 'eval' (1:16)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/333/output.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/333/output.json new file mode 100644 index 000000000000..5d9acaecea9b --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/333/output.json @@ -0,0 +1,231 @@ +{ + "type": "File", + "start": 0, + "end": 39, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 39 + } + }, + "errors": [ + "SyntaxError: Unexpected reserved word 'eval' (1:16)", + "SyntaxError: Assigning to 'eval' in strict mode (1:16)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 39, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 39 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 14, + "end": 39, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 39 + } + }, + "expression": { + "type": "AssignmentExpression", + "start": 15, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 38 + } + }, + "operator": "=", + "left": { + "type": "ObjectPattern", + "start": 15, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "properties": [ + { + "type": "ObjectProperty", + "start": 16, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "method": false, + "key": { + "type": "Identifier", + "start": 16, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 20 + }, + "identifierName": "eval" + }, + "name": "eval" + }, + "computed": false, + "shorthand": true, + "value": { + "type": "AssignmentPattern", + "start": 16, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "left": { + "type": "Identifier", + "start": 16, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 20 + }, + "identifierName": "eval" + }, + "name": "eval" + }, + "right": { + "type": "Identifier", + "start": 23, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 23 + }, + "end": { + "line": 1, + "column": 31 + }, + "identifierName": "defValue" + }, + "name": "defValue" + } + }, + "extra": { + "shorthand": true + } + } + ] + }, + "right": { + "type": "Identifier", + "start": 35, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 35 + }, + "end": { + "line": 1, + "column": 38 + }, + "identifierName": "obj" + }, + "name": "obj" + }, + "extra": { + "parenthesized": true, + "parenStart": 14 + } + } + } + ], + "directives": [ + { + "type": "Directive", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 0, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "value": "use strict", + "extra": { + "raw": "'use strict'", + "rawValue": "use strict" + } + } + } + ] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/334/options.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/334/options.json index e31fbe3a64b9..54925950e059 100644 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/334/options.json +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/334/options.json @@ -1,4 +1,3 @@ { - "sourceType": "module", - "throws": "Assigning to 'eval' in strict mode (1:4)" -} + "sourceType": "module" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/334/output.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/334/output.json new file mode 100644 index 000000000000..a1414d86bbf6 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/334/output.json @@ -0,0 +1,135 @@ +{ + "type": "File", + "start": 0, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "errors": [ + "SyntaxError: Assigning to 'eval' in strict mode (1:4)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "expression": { + "type": "AssignmentExpression", + "start": 0, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "operator": "=", + "left": { + "type": "ArrayPattern", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "elements": [ + { + "type": "RestElement", + "start": 1, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "argument": { + "type": "Identifier", + "start": 4, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 8 + }, + "identifierName": "eval" + }, + "name": "eval" + } + } + ] + }, + "right": { + "type": "Identifier", + "start": 12, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 15 + }, + "identifierName": "arr" + }, + "name": "arr" + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/339/options.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/339/options.json deleted file mode 100644 index fd4da953a419..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/339/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid escape sequence in template (1:2)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/339/output.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/339/output.json new file mode 100644 index 000000000000..86383c01feb1 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/339/output.json @@ -0,0 +1,91 @@ +{ + "type": "File", + "start": 0, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "errors": [ + "SyntaxError: Invalid escape sequence in template (1:2)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "expression": { + "type": "TemplateLiteral", + "start": 0, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "expressions": [], + "quasis": [ + { + "type": "TemplateElement", + "start": 1, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "value": { + "raw": "\\07", + "cooked": null + }, + "tail": true + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/344/options.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/344/options.json deleted file mode 100644 index ad3fdc7d73f7..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/344/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "super is only allowed in object methods and classes (1:0)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/344/output.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/344/output.json new file mode 100644 index 000000000000..ee3b4cb3552b --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/344/output.json @@ -0,0 +1,69 @@ +{ + "type": "File", + "start": 0, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "errors": [ + "SyntaxError: super is only allowed in object methods and classes (1:0)", + "SyntaxError: super can only be used with function calls (i.e. super()) or in property accesses (i.e. super.prop or super[prop]) (1:0)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "expression": { + "type": "Super", + "start": 0, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/347/options.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/347/options.json deleted file mode 100644 index 9a137564eed4..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/347/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "setter must have exactly one formal parameter (1:10)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/347/output.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/347/output.json new file mode 100644 index 000000000000..31975621dcf1 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/347/output.json @@ -0,0 +1,179 @@ +{ + "type": "File", + "start": 0, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "errors": [ + "SyntaxError: setter must have exactly one formal parameter (1:10)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ClassDeclaration", + "start": 0, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "id": { + "type": "Identifier", + "start": 6, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + }, + "identifierName": "A" + }, + "name": "A" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "start": 8, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "body": [ + { + "type": "ClassMethod", + "start": 10, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 27 + } + }, + "static": false, + "key": { + "type": "Identifier", + "start": 14, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 18 + }, + "identifierName": "prop" + }, + "name": "prop" + }, + "computed": false, + "kind": "set", + "id": null, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "start": 19, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 20 + }, + "identifierName": "x" + }, + "name": "x" + }, + { + "type": "Identifier", + "start": 22, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 22 + }, + "end": { + "line": 1, + "column": 23 + }, + "identifierName": "y" + }, + "name": "y" + } + ], + "body": { + "type": "BlockStatement", + "start": 25, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 25 + }, + "end": { + "line": 1, + "column": 27 + } + }, + "body": [], + "directives": [] + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/348/options.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/348/options.json deleted file mode 100644 index c1ac8e1d138d..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/348/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Redefinition of __proto__ property (1:17)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/348/output.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/348/output.json new file mode 100644 index 000000000000..49d20172fcc8 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/348/output.json @@ -0,0 +1,184 @@ +{ + "type": "File", + "start": 0, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "errors": [ + "SyntaxError: Redefinition of __proto__ property (1:17)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "expression": { + "type": "ObjectExpression", + "start": 1, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "properties": [ + { + "type": "ObjectProperty", + "start": 3, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "method": false, + "key": { + "type": "Identifier", + "start": 3, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 12 + }, + "identifierName": "__proto__" + }, + "name": "__proto__" + }, + "computed": false, + "shorthand": false, + "value": { + "type": "NumericLiteral", + "start": 14, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + } + }, + { + "type": "ObjectProperty", + "start": 17, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "method": false, + "key": { + "type": "Identifier", + "start": 17, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 26 + }, + "identifierName": "__proto__" + }, + "name": "__proto__" + }, + "computed": false, + "shorthand": false, + "value": { + "type": "NumericLiteral", + "start": 28, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 28 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "extra": { + "rawValue": 2, + "raw": "2" + }, + "value": 2 + } + } + ], + "extra": { + "parenthesized": true, + "parenStart": 0 + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/349/options.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/349/options.json deleted file mode 100644 index 0d3bc321ef03..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/349/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Redefinition of __proto__ property (1:19)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/349/output.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/349/output.json new file mode 100644 index 000000000000..ba254dda4d93 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/349/output.json @@ -0,0 +1,187 @@ +{ + "type": "File", + "start": 0, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 34 + } + }, + "errors": [ + "SyntaxError: Redefinition of __proto__ property (1:19)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 34 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 34 + } + }, + "expression": { + "type": "ObjectExpression", + "start": 1, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 33 + } + }, + "properties": [ + { + "type": "ObjectProperty", + "start": 3, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "method": false, + "key": { + "type": "StringLiteral", + "start": 3, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "extra": { + "rawValue": "__proto__", + "raw": "'__proto__'" + }, + "value": "__proto__" + }, + "computed": false, + "shorthand": false, + "value": { + "type": "NumericLiteral", + "start": 16, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + } + }, + { + "type": "ObjectProperty", + "start": 19, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "method": false, + "key": { + "type": "Identifier", + "start": 19, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 28 + }, + "identifierName": "__proto__" + }, + "name": "__proto__" + }, + "computed": false, + "shorthand": false, + "value": { + "type": "NumericLiteral", + "start": 30, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 30 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "extra": { + "rawValue": 2, + "raw": "2" + }, + "value": 2 + } + } + ], + "extra": { + "parenthesized": true, + "parenStart": 0 + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/357/options.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/357/options.json index c148ada0c73a..54925950e059 100644 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/357/options.json +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/357/options.json @@ -1,4 +1,3 @@ { - "sourceType": "module", - "throws": "Can not use keyword 'await' outside an async function (1:0)" -} + "sourceType": "module" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/357/output.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/357/output.json new file mode 100644 index 000000000000..b5f573a72f13 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/357/output.json @@ -0,0 +1,119 @@ +{ + "type": "File", + "start": 0, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "errors": [ + "SyntaxError: Can not use keyword 'await' outside an async function (1:0)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "expression": { + "type": "AssignmentExpression", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "operator": "=", + "left": { + "type": "Identifier", + "start": 0, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + }, + "identifierName": "await" + }, + "name": "await" + }, + "right": { + "type": "CallExpression", + "start": 8, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "callee": { + "type": "Identifier", + "start": 8, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 11 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "arguments": [] + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/359/options.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/359/options.json index fa250ba921b1..54925950e059 100644 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/359/options.json +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/359/options.json @@ -1,4 +1,3 @@ { - "sourceType": "module", - "throws": "Can not use keyword 'await' outside an async function (1:6)" -} + "sourceType": "module" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/359/output.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/359/output.json new file mode 100644 index 000000000000..cc297fab6b9f --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/359/output.json @@ -0,0 +1,121 @@ +{ + "type": "File", + "start": 0, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "errors": [ + "SyntaxError: Can not use keyword 'await' outside an async function (1:6)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "VariableDeclaration", + "start": 0, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 6, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "id": { + "type": "Identifier", + "start": 6, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 11 + }, + "identifierName": "await" + }, + "name": "await" + }, + "init": { + "type": "CallExpression", + "start": 14, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "callee": { + "type": "Identifier", + "start": 14, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 17 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "arguments": [] + } + } + ], + "kind": "const" + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/361/options.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/361/options.json index fd81c5071d1d..54925950e059 100644 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/361/options.json +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/361/options.json @@ -1,4 +1,3 @@ { - "sourceType": "module", - "throws": "Can not use keyword 'await' outside an async function (1:8)" -} + "sourceType": "module" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/361/output.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/361/output.json new file mode 100644 index 000000000000..1bbb6a10ec2c --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/361/output.json @@ -0,0 +1,176 @@ +{ + "type": "File", + "start": 0, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "errors": [ + "SyntaxError: Can not use keyword 'await' outside an async function (1:8)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "VariableDeclaration", + "start": 0, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 6, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "id": { + "type": "ObjectPattern", + "start": 6, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "properties": [ + { + "type": "ObjectProperty", + "start": 8, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "method": false, + "key": { + "type": "Identifier", + "start": 8, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 13 + }, + "identifierName": "await" + }, + "name": "await" + }, + "computed": false, + "shorthand": true, + "value": { + "type": "Identifier", + "start": 8, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 13 + }, + "identifierName": "await" + }, + "name": "await" + }, + "extra": { + "shorthand": true + } + } + ] + }, + "init": { + "type": "CallExpression", + "start": 18, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "callee": { + "type": "Identifier", + "start": 18, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 21 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "arguments": [] + } + } + ], + "kind": "const" + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/363/options.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/363/options.json index a72d4ab0ff7f..54925950e059 100644 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/363/options.json +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/363/options.json @@ -1,4 +1,3 @@ { - "sourceType": "module", - "throws": "Can not use keyword 'await' outside an async function (1:15)" -} + "sourceType": "module" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/363/output.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/363/output.json new file mode 100644 index 000000000000..8734398fed74 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/363/output.json @@ -0,0 +1,163 @@ +{ + "type": "File", + "start": 0, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "errors": [ + "SyntaxError: Can not use keyword 'await' outside an async function (1:15)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 12 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "generator": false, + "async": false, + "params": [ + { + "type": "ObjectPattern", + "start": 13, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "properties": [ + { + "type": "ObjectProperty", + "start": 15, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "method": false, + "key": { + "type": "Identifier", + "start": 15, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 20 + }, + "identifierName": "await" + }, + "name": "await" + }, + "computed": false, + "shorthand": true, + "value": { + "type": "Identifier", + "start": 15, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 20 + }, + "identifierName": "await" + }, + "name": "await" + }, + "extra": { + "shorthand": true + } + } + ] + } + ], + "body": { + "type": "BlockStatement", + "start": 24, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 24 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "body": [], + "directives": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/365/options.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/365/options.json index 18d9310bd147..54925950e059 100644 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/365/options.json +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/365/options.json @@ -1,4 +1,3 @@ { - "sourceType": "module", - "throws": "Can not use keyword 'await' outside an async function (1:9)" -} + "sourceType": "module" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/365/output.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/365/output.json new file mode 100644 index 000000000000..9f69841ee631 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/365/output.json @@ -0,0 +1,90 @@ +{ + "type": "File", + "start": 0, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "errors": [ + "SyntaxError: Can not use keyword 'await' outside an async function (1:9)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 14 + }, + "identifierName": "await" + }, + "name": "await" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 17, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "body": [], + "directives": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/367/options.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/367/options.json index fa250ba921b1..54925950e059 100644 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/367/options.json +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/367/options.json @@ -1,4 +1,3 @@ { - "sourceType": "module", - "throws": "Can not use keyword 'await' outside an async function (1:6)" -} + "sourceType": "module" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/367/output.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/367/output.json new file mode 100644 index 000000000000..12f2a4f35608 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/367/output.json @@ -0,0 +1,87 @@ +{ + "type": "File", + "start": 0, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "errors": [ + "SyntaxError: Can not use keyword 'await' outside an async function (1:6)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ClassDeclaration", + "start": 0, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "id": { + "type": "Identifier", + "start": 6, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 11 + }, + "identifierName": "await" + }, + "name": "await" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "start": 12, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "body": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/368/options.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/368/options.json index 8e557dcc53af..53135cabff8f 100644 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/368/options.json +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/368/options.json @@ -1,4 +1,3 @@ { - "sourceType": "script", - "throws": "Unexpected reserved word 'enum' (1:0)" -} + "sourceType": "script" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/368/output.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/368/output.json new file mode 100644 index 000000000000..db0bfd7b2d15 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/368/output.json @@ -0,0 +1,119 @@ +{ + "type": "File", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "errors": [ + "SyntaxError: Unexpected reserved word 'enum' (1:0)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "expression": { + "type": "AssignmentExpression", + "start": 0, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "operator": "=", + "left": { + "type": "Identifier", + "start": 0, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 4 + }, + "identifierName": "enum" + }, + "name": "enum" + }, + "right": { + "type": "CallExpression", + "start": 7, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "callee": { + "type": "Identifier", + "start": 7, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 10 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "arguments": [] + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/369/options.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/369/options.json index 9ef8cae21e3e..54925950e059 100644 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/369/options.json +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/369/options.json @@ -1,4 +1,3 @@ { - "sourceType": "module", - "throws": "Unexpected reserved word 'enum' (1:0)" -} + "sourceType": "module" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/369/output.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/369/output.json new file mode 100644 index 000000000000..7f7235704637 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/369/output.json @@ -0,0 +1,119 @@ +{ + "type": "File", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "errors": [ + "SyntaxError: Unexpected reserved word 'enum' (1:0)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "expression": { + "type": "AssignmentExpression", + "start": 0, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "operator": "=", + "left": { + "type": "Identifier", + "start": 0, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 4 + }, + "identifierName": "enum" + }, + "name": "enum" + }, + "right": { + "type": "CallExpression", + "start": 7, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "callee": { + "type": "Identifier", + "start": 7, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 10 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "arguments": [] + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/37/options.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/37/options.json deleted file mode 100644 index 401518851fb6..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/37/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid left-hand side in arrow function parameters (1:2)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/37/output.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/37/output.json new file mode 100644 index 000000000000..074d84652acc --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/37/output.json @@ -0,0 +1,160 @@ +{ + "type": "File", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "errors": [ + "SyntaxError: Binding member expression (1:2)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "expression": { + "type": "ArrowFunctionExpression", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "id": null, + "generator": false, + "async": false, + "params": [ + { + "type": "ArrayPattern", + "start": 1, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "elements": [ + { + "type": "MemberExpression", + "start": 2, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 2 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "object": { + "type": "Identifier", + "start": 2, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 2 + }, + "end": { + "line": 1, + "column": 3 + }, + "identifierName": "a" + }, + "name": "a" + }, + "property": { + "type": "Identifier", + "start": 4, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 5 + }, + "identifierName": "a" + }, + "name": "a" + }, + "computed": false + } + ] + } + ], + "body": { + "type": "NumericLiteral", + "start": 11, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "extra": { + "rawValue": 42, + "raw": "42" + }, + "value": 42 + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/370/options.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/370/options.json index 55bc1ec84f4a..53135cabff8f 100644 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/370/options.json +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/370/options.json @@ -1,4 +1,3 @@ { - "sourceType": "script", - "throws": "Unexpected reserved word 'enum' (1:6)" -} + "sourceType": "script" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/370/output.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/370/output.json new file mode 100644 index 000000000000..6f19d31ea58f --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/370/output.json @@ -0,0 +1,121 @@ +{ + "type": "File", + "start": 0, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "errors": [ + "SyntaxError: Unexpected reserved word 'enum' (1:6)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "VariableDeclaration", + "start": 0, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 6, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "id": { + "type": "Identifier", + "start": 6, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 10 + }, + "identifierName": "enum" + }, + "name": "enum" + }, + "init": { + "type": "CallExpression", + "start": 13, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "callee": { + "type": "Identifier", + "start": 13, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 16 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "arguments": [] + } + } + ], + "kind": "const" + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/371/options.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/371/options.json index e6801417951e..54925950e059 100644 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/371/options.json +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/371/options.json @@ -1,4 +1,3 @@ { - "sourceType": "module", - "throws": "Unexpected reserved word 'enum' (1:6)" -} + "sourceType": "module" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/371/output.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/371/output.json new file mode 100644 index 000000000000..c6e70262550d --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/371/output.json @@ -0,0 +1,121 @@ +{ + "type": "File", + "start": 0, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "errors": [ + "SyntaxError: Unexpected reserved word 'enum' (1:6)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "VariableDeclaration", + "start": 0, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 6, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "id": { + "type": "Identifier", + "start": 6, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 10 + }, + "identifierName": "enum" + }, + "name": "enum" + }, + "init": { + "type": "CallExpression", + "start": 13, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "callee": { + "type": "Identifier", + "start": 13, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 16 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "arguments": [] + } + } + ], + "kind": "const" + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/372/options.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/372/options.json index 3ef9cf1c71bb..53135cabff8f 100644 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/372/options.json +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/372/options.json @@ -1,4 +1,3 @@ { - "sourceType": "script", - "throws": "Unexpected reserved word 'enum' (1:8)" -} + "sourceType": "script" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/372/output.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/372/output.json new file mode 100644 index 000000000000..7da63dd7a987 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/372/output.json @@ -0,0 +1,176 @@ +{ + "type": "File", + "start": 0, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "errors": [ + "SyntaxError: Unexpected reserved word 'enum' (1:8)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "VariableDeclaration", + "start": 0, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 6, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "id": { + "type": "ObjectPattern", + "start": 6, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "properties": [ + { + "type": "ObjectProperty", + "start": 8, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "method": false, + "key": { + "type": "Identifier", + "start": 8, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 12 + }, + "identifierName": "enum" + }, + "name": "enum" + }, + "computed": false, + "shorthand": true, + "value": { + "type": "Identifier", + "start": 8, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 12 + }, + "identifierName": "enum" + }, + "name": "enum" + }, + "extra": { + "shorthand": true + } + } + ] + }, + "init": { + "type": "CallExpression", + "start": 17, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "callee": { + "type": "Identifier", + "start": 17, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 20 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "arguments": [] + } + } + ], + "kind": "const" + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/373/options.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/373/options.json index 91d0958e3d0b..54925950e059 100644 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/373/options.json +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/373/options.json @@ -1,4 +1,3 @@ { - "sourceType": "module", - "throws": "Unexpected reserved word 'enum' (1:8)" -} + "sourceType": "module" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/373/output.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/373/output.json new file mode 100644 index 000000000000..f906a9f99eba --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/373/output.json @@ -0,0 +1,176 @@ +{ + "type": "File", + "start": 0, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "errors": [ + "SyntaxError: Unexpected reserved word 'enum' (1:8)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "VariableDeclaration", + "start": 0, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 6, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "id": { + "type": "ObjectPattern", + "start": 6, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "properties": [ + { + "type": "ObjectProperty", + "start": 8, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "method": false, + "key": { + "type": "Identifier", + "start": 8, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 12 + }, + "identifierName": "enum" + }, + "name": "enum" + }, + "computed": false, + "shorthand": true, + "value": { + "type": "Identifier", + "start": 8, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 12 + }, + "identifierName": "enum" + }, + "name": "enum" + }, + "extra": { + "shorthand": true + } + } + ] + }, + "init": { + "type": "CallExpression", + "start": 17, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "callee": { + "type": "Identifier", + "start": 17, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 20 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "arguments": [] + } + } + ], + "kind": "const" + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/374/options.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/374/options.json index be1d10ebd92c..53135cabff8f 100644 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/374/options.json +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/374/options.json @@ -1,4 +1,3 @@ { - "sourceType": "script", - "throws": "Unexpected reserved word 'enum' (1:15)" -} + "sourceType": "script" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/374/output.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/374/output.json new file mode 100644 index 000000000000..339a9b1d9aef --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/374/output.json @@ -0,0 +1,163 @@ +{ + "type": "File", + "start": 0, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 25 + } + }, + "errors": [ + "SyntaxError: Unexpected reserved word 'enum' (1:15)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 25 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 25 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 12 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "generator": false, + "async": false, + "params": [ + { + "type": "ObjectPattern", + "start": 13, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "properties": [ + { + "type": "ObjectProperty", + "start": 15, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "method": false, + "key": { + "type": "Identifier", + "start": 15, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 19 + }, + "identifierName": "enum" + }, + "name": "enum" + }, + "computed": false, + "shorthand": true, + "value": { + "type": "Identifier", + "start": 15, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 19 + }, + "identifierName": "enum" + }, + "name": "enum" + }, + "extra": { + "shorthand": true + } + } + ] + } + ], + "body": { + "type": "BlockStatement", + "start": 23, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 23 + }, + "end": { + "line": 1, + "column": 25 + } + }, + "body": [], + "directives": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/375/options.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/375/options.json index f3a107c75be7..54925950e059 100644 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/375/options.json +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/375/options.json @@ -1,4 +1,3 @@ { - "sourceType": "module", - "throws": "Unexpected reserved word 'enum' (1:15)" -} + "sourceType": "module" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/375/output.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/375/output.json new file mode 100644 index 000000000000..9ad60d6cf403 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/375/output.json @@ -0,0 +1,163 @@ +{ + "type": "File", + "start": 0, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 25 + } + }, + "errors": [ + "SyntaxError: Unexpected reserved word 'enum' (1:15)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 25 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 25 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 12 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "generator": false, + "async": false, + "params": [ + { + "type": "ObjectPattern", + "start": 13, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "properties": [ + { + "type": "ObjectProperty", + "start": 15, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "method": false, + "key": { + "type": "Identifier", + "start": 15, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 19 + }, + "identifierName": "enum" + }, + "name": "enum" + }, + "computed": false, + "shorthand": true, + "value": { + "type": "Identifier", + "start": 15, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 19 + }, + "identifierName": "enum" + }, + "name": "enum" + }, + "extra": { + "shorthand": true + } + } + ] + } + ], + "body": { + "type": "BlockStatement", + "start": 23, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 23 + }, + "end": { + "line": 1, + "column": 25 + } + }, + "body": [], + "directives": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/376/options.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/376/options.json index de270bbb0542..53135cabff8f 100644 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/376/options.json +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/376/options.json @@ -1,4 +1,3 @@ { - "sourceType": "script", - "throws": "Unexpected reserved word 'enum' (1:9)" -} + "sourceType": "script" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/376/output.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/376/output.json new file mode 100644 index 000000000000..ed7ac1e2953c --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/376/output.json @@ -0,0 +1,90 @@ +{ + "type": "File", + "start": 0, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "errors": [ + "SyntaxError: Unexpected reserved word 'enum' (1:9)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 13 + }, + "identifierName": "enum" + }, + "name": "enum" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 16, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "body": [], + "directives": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/377/options.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/377/options.json index 27f9ea278f30..54925950e059 100644 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/377/options.json +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/377/options.json @@ -1,4 +1,3 @@ { - "sourceType": "module", - "throws": "Unexpected reserved word 'enum' (1:9)" -} + "sourceType": "module" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/377/output.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/377/output.json new file mode 100644 index 000000000000..7a06864215ea --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/377/output.json @@ -0,0 +1,90 @@ +{ + "type": "File", + "start": 0, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "errors": [ + "SyntaxError: Unexpected reserved word 'enum' (1:9)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 13 + }, + "identifierName": "enum" + }, + "name": "enum" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 16, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "body": [], + "directives": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/378/options.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/378/options.json index 55bc1ec84f4a..53135cabff8f 100644 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/378/options.json +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/378/options.json @@ -1,4 +1,3 @@ { - "sourceType": "script", - "throws": "Unexpected reserved word 'enum' (1:6)" -} + "sourceType": "script" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/378/output.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/378/output.json new file mode 100644 index 000000000000..04f287aef702 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/378/output.json @@ -0,0 +1,87 @@ +{ + "type": "File", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "errors": [ + "SyntaxError: Unexpected reserved word 'enum' (1:6)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ClassDeclaration", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "id": { + "type": "Identifier", + "start": 6, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 10 + }, + "identifierName": "enum" + }, + "name": "enum" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "start": 11, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "body": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/379/options.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/379/options.json index e6801417951e..54925950e059 100644 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/379/options.json +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/379/options.json @@ -1,4 +1,3 @@ { - "sourceType": "module", - "throws": "Unexpected reserved word 'enum' (1:6)" -} + "sourceType": "module" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/379/output.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/379/output.json new file mode 100644 index 000000000000..0619ba17f596 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/379/output.json @@ -0,0 +1,87 @@ +{ + "type": "File", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "errors": [ + "SyntaxError: Unexpected reserved word 'enum' (1:6)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ClassDeclaration", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "id": { + "type": "Identifier", + "start": 6, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 10 + }, + "identifierName": "enum" + }, + "name": "enum" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "start": 11, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "body": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/395/options.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/395/options.json index db72a6af957d..6d24025b8674 100644 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/395/options.json +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/395/options.json @@ -1,4 +1,3 @@ { - "createParenthesizedExpressions": true, - "throws": "Invalid left-hand side in arrow function parameters (1:2)" -} + "createParenthesizedExpressions": true +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/395/output.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/395/output.json new file mode 100644 index 000000000000..074d84652acc --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/395/output.json @@ -0,0 +1,160 @@ +{ + "type": "File", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "errors": [ + "SyntaxError: Binding member expression (1:2)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "expression": { + "type": "ArrowFunctionExpression", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "id": null, + "generator": false, + "async": false, + "params": [ + { + "type": "ArrayPattern", + "start": 1, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "elements": [ + { + "type": "MemberExpression", + "start": 2, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 2 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "object": { + "type": "Identifier", + "start": 2, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 2 + }, + "end": { + "line": 1, + "column": 3 + }, + "identifierName": "a" + }, + "name": "a" + }, + "property": { + "type": "Identifier", + "start": 4, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 5 + }, + "identifierName": "a" + }, + "name": "a" + }, + "computed": false + } + ] + } + ], + "body": { + "type": "NumericLiteral", + "start": 11, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "extra": { + "rawValue": 42, + "raw": "42" + }, + "value": 42 + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/yield/function-name-function-declaration-inside-generator/options.json b/packages/babel-parser/test/fixtures/es2015/yield/function-name-function-declaration-inside-generator/options.json deleted file mode 100644 index 37d7f62549c6..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/yield/function-name-function-declaration-inside-generator/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Can not use 'yield' as identifier inside a generator (2:11)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/yield/function-name-function-declaration-inside-generator/output.json b/packages/babel-parser/test/fixtures/es2015/yield/function-name-function-declaration-inside-generator/output.json new file mode 100644 index 000000000000..a545b4a024b1 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/yield/function-name-function-declaration-inside-generator/output.json @@ -0,0 +1,143 @@ +{ + "type": "File", + "start": 0, + "end": 40, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "errors": [ + "SyntaxError: Can not use 'yield' as identifier inside a generator (2:11)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 40, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 40, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 10, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 12 + }, + "identifierName": "fn" + }, + "name": "fn" + }, + "generator": true, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 15, + "end": 40, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "body": [ + { + "type": "FunctionDeclaration", + "start": 19, + "end": 38, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 21 + } + }, + "id": { + "type": "Identifier", + "start": 28, + "end": 33, + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 16 + }, + "identifierName": "yield" + }, + "name": "yield" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 36, + "end": 38, + "loc": { + "start": { + "line": 2, + "column": 19 + }, + "end": { + "line": 2, + "column": 21 + } + }, + "body": [], + "directives": [] + } + } + ], + "directives": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/yield/function-name-generator-expression/options.json b/packages/babel-parser/test/fixtures/es2015/yield/function-name-generator-expression/options.json deleted file mode 100644 index 72f8d0e0e4c3..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/yield/function-name-generator-expression/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Can not use 'yield' as identifier inside a generator (1:11)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/yield/function-name-generator-expression/output.json b/packages/babel-parser/test/fixtures/es2015/yield/function-name-generator-expression/output.json new file mode 100644 index 000000000000..39554296d4c3 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/yield/function-name-generator-expression/output.json @@ -0,0 +1,122 @@ +{ + "type": "File", + "start": 0, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "errors": [ + "SyntaxError: Can not use 'yield' as identifier inside a generator (1:11)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "expression": { + "type": "UnaryExpression", + "start": 0, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "operator": "+", + "prefix": true, + "argument": { + "type": "FunctionExpression", + "start": 1, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "id": { + "type": "Identifier", + "start": 11, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 16 + }, + "identifierName": "yield" + }, + "name": "yield" + }, + "generator": true, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 19, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "body": [], + "directives": [] + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/yield/function-name-strict-body/options.json b/packages/babel-parser/test/fixtures/es2015/yield/function-name-strict-body/options.json deleted file mode 100644 index e55b18eb4f07..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/yield/function-name-strict-body/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Binding 'yield' in strict mode (1:9)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/yield/function-name-strict-body/output.json b/packages/babel-parser/test/fixtures/es2015/yield/function-name-strict-body/output.json new file mode 100644 index 000000000000..1a8500a416fb --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/yield/function-name-strict-body/output.json @@ -0,0 +1,126 @@ +{ + "type": "File", + "start": 0, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 34 + } + }, + "errors": [ + "SyntaxError: Binding 'yield' in strict mode (1:9)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 34 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 34 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 14 + }, + "identifierName": "yield" + }, + "name": "yield" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 17, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 34 + } + }, + "body": [], + "directives": [ + { + "type": "Directive", + "start": 19, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 19, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "value": "use strict", + "extra": { + "raw": "\"use strict\"", + "rawValue": "use strict" + } + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/yield/function-name-strict/options.json b/packages/babel-parser/test/fixtures/es2015/yield/function-name-strict/options.json deleted file mode 100644 index 320734ea2ef7..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/yield/function-name-strict/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Unexpected reserved word 'yield' (2:9)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/yield/function-name-strict/output.json b/packages/babel-parser/test/fixtures/es2015/yield/function-name-strict/output.json new file mode 100644 index 000000000000..19d96b67a349 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/yield/function-name-strict/output.json @@ -0,0 +1,126 @@ +{ + "type": "File", + "start": 0, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 19 + } + }, + "errors": [ + "SyntaxError: Unexpected reserved word 'yield' (2:9)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 19 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 14, + "end": 33, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 19 + } + }, + "id": { + "type": "Identifier", + "start": 23, + "end": 28, + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 14 + }, + "identifierName": "yield" + }, + "name": "yield" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 31, + "end": 33, + "loc": { + "start": { + "line": 2, + "column": 17 + }, + "end": { + "line": 2, + "column": 19 + } + }, + "body": [], + "directives": [] + } + } + ], + "directives": [ + { + "type": "Directive", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 0, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "value": "use strict", + "extra": { + "raw": "\"use strict\"", + "rawValue": "use strict" + } + } + } + ] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/yield/in-class-heritage/options.json b/packages/babel-parser/test/fixtures/es2015/yield/in-class-heritage/options.json index e817f30acb5c..23c503c046ad 100644 --- a/packages/babel-parser/test/fixtures/es2015/yield/in-class-heritage/options.json +++ b/packages/babel-parser/test/fixtures/es2015/yield/in-class-heritage/options.json @@ -1,3 +1,3 @@ { - "throws": "Unexpected reserved word 'yield' (1:16)" -} + "throws": "Unexpected token, expected \"{\" (1:22)" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/yield/in-iterator-stmt/options.json b/packages/babel-parser/test/fixtures/es2015/yield/in-iterator-stmt/options.json index ad46a65e5082..589316ba5b14 100644 --- a/packages/babel-parser/test/fixtures/es2015/yield/in-iterator-stmt/options.json +++ b/packages/babel-parser/test/fixtures/es2015/yield/in-iterator-stmt/options.json @@ -1,3 +1,3 @@ { - "throws": "Invalid left-hand side in for-in statement (2:7)" -} + "throws": "Unexpected token, expected \")\" (2:21)" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/yield/parameter-default-inside-arrow-inside-generator-1/options.json b/packages/babel-parser/test/fixtures/es2015/yield/parameter-default-inside-arrow-inside-generator-1/options.json deleted file mode 100644 index 75b3f62fdacb..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/yield/parameter-default-inside-arrow-inside-generator-1/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Yield cannot be used as name inside a generator function (2:7)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/yield/parameter-default-inside-arrow-inside-generator-1/output.json b/packages/babel-parser/test/fixtures/es2015/yield/parameter-default-inside-arrow-inside-generator-1/output.json new file mode 100644 index 000000000000..6639d749ab68 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/yield/parameter-default-inside-arrow-inside-generator-1/output.json @@ -0,0 +1,192 @@ +{ + "type": "File", + "start": 0, + "end": 39, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "errors": [ + "SyntaxError: Yield cannot be used as name inside a generator function (2:7)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 39, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 39, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 10, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 12 + }, + "identifierName": "fn" + }, + "name": "fn" + }, + "generator": true, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 15, + "end": 39, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 19, + "end": 37, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 20 + } + }, + "expression": { + "type": "ArrowFunctionExpression", + "start": 19, + "end": 36, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 19 + } + }, + "id": null, + "generator": false, + "async": false, + "params": [ + { + "type": "AssignmentPattern", + "start": 20, + "end": 29, + "loc": { + "start": { + "line": 2, + "column": 3 + }, + "end": { + "line": 2, + "column": 12 + } + }, + "left": { + "type": "Identifier", + "start": 20, + "end": 21, + "loc": { + "start": { + "line": 2, + "column": 3 + }, + "end": { + "line": 2, + "column": 4 + }, + "identifierName": "x" + }, + "name": "x" + }, + "right": { + "type": "YieldExpression", + "start": 24, + "end": 29, + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 2, + "column": 12 + } + }, + "delegate": false, + "argument": null + } + } + ], + "body": { + "type": "BlockStatement", + "start": 34, + "end": 36, + "loc": { + "start": { + "line": 2, + "column": 17 + }, + "end": { + "line": 2, + "column": 19 + } + }, + "body": [], + "directives": [] + } + } + } + ], + "directives": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/yield/parameter-default-inside-arrow-inside-generator-2/options.json b/packages/babel-parser/test/fixtures/es2015/yield/parameter-default-inside-arrow-inside-generator-2/options.json deleted file mode 100644 index 9d35f54190c8..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/yield/parameter-default-inside-arrow-inside-generator-2/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Yield cannot be used as name inside a generator function (2:15)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/yield/parameter-default-inside-arrow-inside-generator-2/output.json b/packages/babel-parser/test/fixtures/es2015/yield/parameter-default-inside-arrow-inside-generator-2/output.json new file mode 100644 index 000000000000..b029ca9f0ce9 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/yield/parameter-default-inside-arrow-inside-generator-2/output.json @@ -0,0 +1,331 @@ +{ + "type": "File", + "start": 0, + "end": 53, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "errors": [ + "SyntaxError: Yield cannot be used as name inside a generator function (2:15)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 53, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 53, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 10, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 12 + }, + "identifierName": "fn" + }, + "name": "fn" + }, + "generator": true, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 15, + "end": 53, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 19, + "end": 51, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 34 + } + }, + "expression": { + "type": "ArrowFunctionExpression", + "start": 19, + "end": 50, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 33 + } + }, + "id": null, + "generator": false, + "async": false, + "params": [ + { + "type": "AssignmentPattern", + "start": 20, + "end": 43, + "loc": { + "start": { + "line": 2, + "column": 3 + }, + "end": { + "line": 2, + "column": 26 + } + }, + "left": { + "type": "Identifier", + "start": 20, + "end": 21, + "loc": { + "start": { + "line": 2, + "column": 3 + }, + "end": { + "line": 2, + "column": 4 + }, + "identifierName": "x" + }, + "name": "x" + }, + "right": { + "type": "BinaryExpression", + "start": 24, + "end": 43, + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 2, + "column": 26 + } + }, + "left": { + "type": "NumericLiteral", + "start": 24, + "end": 25, + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 2, + "column": 8 + } + }, + "extra": { + "rawValue": 3, + "raw": "3" + }, + "value": 3 + }, + "operator": "+", + "right": { + "type": "BinaryExpression", + "start": 28, + "end": 43, + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 26 + } + }, + "left": { + "type": "CallExpression", + "start": 28, + "end": 38, + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 21 + } + }, + "callee": { + "type": "MemberExpression", + "start": 28, + "end": 31, + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 14 + } + }, + "object": { + "type": "Identifier", + "start": 28, + "end": 29, + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 12 + }, + "identifierName": "a" + }, + "name": "a" + }, + "property": { + "type": "Identifier", + "start": 30, + "end": 31, + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 14 + }, + "identifierName": "b" + }, + "name": "b" + }, + "computed": false + }, + "arguments": [ + { + "type": "YieldExpression", + "start": 32, + "end": 37, + "loc": { + "start": { + "line": 2, + "column": 15 + }, + "end": { + "line": 2, + "column": 20 + } + }, + "delegate": false, + "argument": null + } + ] + }, + "operator": "**", + "right": { + "type": "NumericLiteral", + "start": 42, + "end": 43, + "loc": { + "start": { + "line": 2, + "column": 25 + }, + "end": { + "line": 2, + "column": 26 + } + }, + "extra": { + "rawValue": 2, + "raw": "2" + }, + "value": 2 + } + } + } + } + ], + "body": { + "type": "BlockStatement", + "start": 48, + "end": 50, + "loc": { + "start": { + "line": 2, + "column": 31 + }, + "end": { + "line": 2, + "column": 33 + } + }, + "body": [], + "directives": [] + } + } + } + ], + "directives": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/yield/parameter-default-inside-arrow-inside-generator-3/options.json b/packages/babel-parser/test/fixtures/es2015/yield/parameter-default-inside-arrow-inside-generator-3/options.json deleted file mode 100644 index 75b3f62fdacb..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/yield/parameter-default-inside-arrow-inside-generator-3/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Yield cannot be used as name inside a generator function (2:7)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/yield/parameter-default-inside-arrow-inside-generator-3/output.json b/packages/babel-parser/test/fixtures/es2015/yield/parameter-default-inside-arrow-inside-generator-3/output.json new file mode 100644 index 000000000000..7ce61876e0a8 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/yield/parameter-default-inside-arrow-inside-generator-3/output.json @@ -0,0 +1,208 @@ +{ + "type": "File", + "start": 0, + "end": 42, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "errors": [ + "SyntaxError: Yield cannot be used as name inside a generator function (2:7)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 42, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 42, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 10, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 12 + }, + "identifierName": "fn" + }, + "name": "fn" + }, + "generator": true, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 15, + "end": 42, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 19, + "end": 40, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 23 + } + }, + "expression": { + "type": "ArrowFunctionExpression", + "start": 19, + "end": 39, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 22 + } + }, + "id": null, + "generator": false, + "async": false, + "params": [ + { + "type": "AssignmentPattern", + "start": 20, + "end": 32, + "loc": { + "start": { + "line": 2, + "column": 3 + }, + "end": { + "line": 2, + "column": 15 + } + }, + "left": { + "type": "Identifier", + "start": 20, + "end": 21, + "loc": { + "start": { + "line": 2, + "column": 3 + }, + "end": { + "line": 2, + "column": 4 + }, + "identifierName": "x" + }, + "name": "x" + }, + "right": { + "type": "YieldExpression", + "start": 24, + "end": 32, + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 2, + "column": 15 + } + }, + "delegate": false, + "argument": { + "type": "Identifier", + "start": 30, + "end": 32, + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 15 + }, + "identifierName": "fn" + }, + "name": "fn" + } + } + } + ], + "body": { + "type": "BlockStatement", + "start": 37, + "end": 39, + "loc": { + "start": { + "line": 2, + "column": 20 + }, + "end": { + "line": 2, + "column": 22 + } + }, + "body": [], + "directives": [] + } + } + } + ], + "directives": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/yield/parameter-default-inside-arrow-inside-generator-4/options.json b/packages/babel-parser/test/fixtures/es2015/yield/parameter-default-inside-arrow-inside-generator-4/options.json deleted file mode 100644 index b3ac060855bb..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/yield/parameter-default-inside-arrow-inside-generator-4/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Yield cannot be used as name inside a generator function (2:17)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/yield/parameter-default-inside-arrow-inside-generator-4/output.json b/packages/babel-parser/test/fixtures/es2015/yield/parameter-default-inside-arrow-inside-generator-4/output.json new file mode 100644 index 000000000000..e88af5b40a30 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/yield/parameter-default-inside-arrow-inside-generator-4/output.json @@ -0,0 +1,261 @@ +{ + "type": "File", + "start": 0, + "end": 49, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "errors": [ + "SyntaxError: Yield cannot be used as name inside a generator function (2:17)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 49, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 49, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 10, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 12 + }, + "identifierName": "fn" + }, + "name": "fn" + }, + "generator": true, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 15, + "end": 49, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 19, + "end": 47, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 30 + } + }, + "expression": { + "type": "ArrowFunctionExpression", + "start": 19, + "end": 46, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 29 + } + }, + "id": null, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "start": 20, + "end": 21, + "loc": { + "start": { + "line": 2, + "column": 3 + }, + "end": { + "line": 2, + "column": 4 + }, + "identifierName": "a" + }, + "name": "a" + }, + { + "type": "AssignmentPattern", + "start": 23, + "end": 28, + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 11 + } + }, + "left": { + "type": "Identifier", + "start": 23, + "end": 24, + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 7 + }, + "identifierName": "b" + }, + "name": "b" + }, + "right": { + "type": "NumericLiteral", + "start": 27, + "end": 28, + "loc": { + "start": { + "line": 2, + "column": 10 + }, + "end": { + "line": 2, + "column": 11 + } + }, + "extra": { + "rawValue": 3, + "raw": "3" + }, + "value": 3 + } + }, + { + "type": "AssignmentPattern", + "start": 30, + "end": 39, + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 22 + } + }, + "left": { + "type": "Identifier", + "start": 30, + "end": 31, + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 14 + }, + "identifierName": "x" + }, + "name": "x" + }, + "right": { + "type": "YieldExpression", + "start": 34, + "end": 39, + "loc": { + "start": { + "line": 2, + "column": 17 + }, + "end": { + "line": 2, + "column": 22 + } + }, + "delegate": false, + "argument": null + } + } + ], + "body": { + "type": "BlockStatement", + "start": 44, + "end": 46, + "loc": { + "start": { + "line": 2, + "column": 27 + }, + "end": { + "line": 2, + "column": 29 + } + }, + "body": [], + "directives": [] + } + } + } + ], + "directives": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/yield/parameter-default-inside-arrow-inside-generator-5/options.json b/packages/babel-parser/test/fixtures/es2015/yield/parameter-default-inside-arrow-inside-generator-5/options.json deleted file mode 100644 index 379c08c57e90..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/yield/parameter-default-inside-arrow-inside-generator-5/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Yield cannot be used as name inside a generator function (2:8)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/yield/parameter-default-inside-arrow-inside-generator-5/output.json b/packages/babel-parser/test/fixtures/es2015/yield/parameter-default-inside-arrow-inside-generator-5/output.json new file mode 100644 index 000000000000..30bb59f8c609 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/yield/parameter-default-inside-arrow-inside-generator-5/output.json @@ -0,0 +1,230 @@ +{ + "type": "File", + "start": 0, + "end": 47, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "errors": [ + "SyntaxError: Yield cannot be used as name inside a generator function (2:8)", + "SyntaxError: Binding invalid left-hand side in function parameter list (2:8)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 47, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 47, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 10, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 12 + }, + "identifierName": "fn" + }, + "name": "fn" + }, + "generator": true, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 15, + "end": 47, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 19, + "end": 45, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 28 + } + }, + "expression": { + "type": "ArrowFunctionExpression", + "start": 19, + "end": 44, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 27 + } + }, + "id": null, + "generator": false, + "async": false, + "params": [ + { + "type": "AssignmentPattern", + "start": 20, + "end": 37, + "loc": { + "start": { + "line": 2, + "column": 3 + }, + "end": { + "line": 2, + "column": 20 + } + }, + "left": { + "type": "Identifier", + "start": 20, + "end": 21, + "loc": { + "start": { + "line": 2, + "column": 3 + }, + "end": { + "line": 2, + "column": 4 + }, + "identifierName": "x" + }, + "name": "x" + }, + "right": { + "type": "ArrowFunctionExpression", + "start": 24, + "end": 37, + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 2, + "column": 20 + } + }, + "id": null, + "generator": false, + "async": false, + "params": [ + { + "type": "YieldExpression", + "start": 25, + "end": 30, + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 13 + } + }, + "delegate": false, + "argument": null + } + ], + "body": { + "type": "BlockStatement", + "start": 35, + "end": 37, + "loc": { + "start": { + "line": 2, + "column": 18 + }, + "end": { + "line": 2, + "column": 20 + } + }, + "body": [], + "directives": [] + } + } + } + ], + "body": { + "type": "BlockStatement", + "start": 42, + "end": 44, + "loc": { + "start": { + "line": 2, + "column": 25 + }, + "end": { + "line": 2, + "column": 27 + } + }, + "body": [], + "directives": [] + } + } + } + ], + "directives": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/yield/parameter-default-inside-arrow-inside-generator-6/options.json b/packages/babel-parser/test/fixtures/es2015/yield/parameter-default-inside-arrow-inside-generator-6/options.json deleted file mode 100644 index 379c08c57e90..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/yield/parameter-default-inside-arrow-inside-generator-6/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Yield cannot be used as name inside a generator function (2:8)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/yield/parameter-default-inside-arrow-inside-generator-6/output.json b/packages/babel-parser/test/fixtures/es2015/yield/parameter-default-inside-arrow-inside-generator-6/output.json new file mode 100644 index 000000000000..ce92441a5734 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/yield/parameter-default-inside-arrow-inside-generator-6/output.json @@ -0,0 +1,196 @@ +{ + "type": "File", + "start": 0, + "end": 41, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "errors": [ + "SyntaxError: Yield cannot be used as name inside a generator function (2:8)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 41, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 41, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 10, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 12 + }, + "identifierName": "fn" + }, + "name": "fn" + }, + "generator": true, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 15, + "end": 41, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 19, + "end": 39, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 22 + } + }, + "expression": { + "type": "ArrowFunctionExpression", + "start": 19, + "end": 38, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 21 + } + }, + "id": null, + "generator": false, + "async": false, + "params": [ + { + "type": "AssignmentPattern", + "start": 20, + "end": 31, + "loc": { + "start": { + "line": 2, + "column": 3 + }, + "end": { + "line": 2, + "column": 14 + } + }, + "left": { + "type": "Identifier", + "start": 20, + "end": 21, + "loc": { + "start": { + "line": 2, + "column": 3 + }, + "end": { + "line": 2, + "column": 4 + }, + "identifierName": "x" + }, + "name": "x" + }, + "right": { + "type": "YieldExpression", + "start": 25, + "end": 30, + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 13 + } + }, + "delegate": false, + "argument": null, + "extra": { + "parenthesized": true, + "parenStart": 24 + } + } + } + ], + "body": { + "type": "BlockStatement", + "start": 36, + "end": 38, + "loc": { + "start": { + "line": 2, + "column": 19 + }, + "end": { + "line": 2, + "column": 21 + } + }, + "body": [], + "directives": [] + } + } + } + ], + "directives": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/yield/parameter-default-inside-generator-method/options.json b/packages/babel-parser/test/fixtures/es2015/yield/parameter-default-inside-generator-method/options.json deleted file mode 100644 index 6f5bd40fe357..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/yield/parameter-default-inside-generator-method/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "yield is not allowed in generator parameters (1:15)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/yield/parameter-default-inside-generator-method/output.json b/packages/babel-parser/test/fixtures/es2015/yield/parameter-default-inside-generator-method/output.json new file mode 100644 index 000000000000..a2234a6938db --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/yield/parameter-default-inside-generator-method/output.json @@ -0,0 +1,180 @@ +{ + "type": "File", + "start": 0, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 27 + } + }, + "errors": [ + "SyntaxError: yield is not allowed in generator parameters (1:15)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 27 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 27 + } + }, + "expression": { + "type": "ObjectExpression", + "start": 1, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "properties": [ + { + "type": "ObjectMethod", + "start": 3, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "method": true, + "key": { + "type": "Identifier", + "start": 4, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 10 + }, + "identifierName": "method" + }, + "name": "method" + }, + "computed": false, + "kind": "method", + "id": null, + "generator": true, + "async": false, + "params": [ + { + "type": "AssignmentPattern", + "start": 11, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "left": { + "type": "Identifier", + "start": 11, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 12 + }, + "identifierName": "x" + }, + "name": "x" + }, + "right": { + "type": "YieldExpression", + "start": 15, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "delegate": false, + "argument": null + } + } + ], + "body": { + "type": "BlockStatement", + "start": 22, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 22 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "body": [], + "directives": [] + } + } + ], + "extra": { + "parenthesized": true, + "parenStart": 0 + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/yield/parameter-default-inside-generator/options.json b/packages/babel-parser/test/fixtures/es2015/yield/parameter-default-inside-generator/options.json deleted file mode 100644 index dd9a684ef928..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/yield/parameter-default-inside-generator/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "yield is not allowed in generator parameters (1:17)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/yield/parameter-default-inside-generator/output.json b/packages/babel-parser/test/fixtures/es2015/yield/parameter-default-inside-generator/output.json new file mode 100644 index 000000000000..b21c88bc4f9f --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/yield/parameter-default-inside-generator/output.json @@ -0,0 +1,140 @@ +{ + "type": "File", + "start": 0, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "errors": [ + "SyntaxError: yield is not allowed in generator parameters (1:17)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "id": { + "type": "Identifier", + "start": 10, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 12 + }, + "identifierName": "fn" + }, + "name": "fn" + }, + "generator": true, + "async": false, + "params": [ + { + "type": "AssignmentPattern", + "start": 13, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "left": { + "type": "Identifier", + "start": 13, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 14 + }, + "identifierName": "x" + }, + "name": "x" + }, + "right": { + "type": "YieldExpression", + "start": 17, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "delegate": false, + "argument": null + } + } + ], + "body": { + "type": "BlockStatement", + "start": 24, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 24 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "body": [], + "directives": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/yield/parameter-default-strict/options.json b/packages/babel-parser/test/fixtures/es2015/yield/parameter-default-strict/options.json deleted file mode 100644 index ecc179f974cb..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/yield/parameter-default-strict/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Unexpected reserved word 'yield' (2:16)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/yield/parameter-default-strict/output.json b/packages/babel-parser/test/fixtures/es2015/yield/parameter-default-strict/output.json new file mode 100644 index 000000000000..e051b9ac1378 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/yield/parameter-default-strict/output.json @@ -0,0 +1,176 @@ +{ + "type": "File", + "start": 0, + "end": 39, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 25 + } + }, + "errors": [ + "SyntaxError: Unexpected reserved word 'yield' (2:16)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 39, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 25 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 14, + "end": 39, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 25 + } + }, + "id": { + "type": "Identifier", + "start": 23, + "end": 25, + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 11 + }, + "identifierName": "fn" + }, + "name": "fn" + }, + "generator": false, + "async": false, + "params": [ + { + "type": "AssignmentPattern", + "start": 26, + "end": 35, + "loc": { + "start": { + "line": 2, + "column": 12 + }, + "end": { + "line": 2, + "column": 21 + } + }, + "left": { + "type": "Identifier", + "start": 26, + "end": 27, + "loc": { + "start": { + "line": 2, + "column": 12 + }, + "end": { + "line": 2, + "column": 13 + }, + "identifierName": "x" + }, + "name": "x" + }, + "right": { + "type": "Identifier", + "start": 30, + "end": 35, + "loc": { + "start": { + "line": 2, + "column": 16 + }, + "end": { + "line": 2, + "column": 21 + }, + "identifierName": "yield" + }, + "name": "yield" + } + } + ], + "body": { + "type": "BlockStatement", + "start": 37, + "end": 39, + "loc": { + "start": { + "line": 2, + "column": 23 + }, + "end": { + "line": 2, + "column": 25 + } + }, + "body": [], + "directives": [] + } + } + ], + "directives": [ + { + "type": "Directive", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 0, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "value": "use strict", + "extra": { + "raw": "\"use strict\"", + "rawValue": "use strict" + } + } + } + ] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/yield/parameter-name-arrow-inside-generator-1/options.json b/packages/babel-parser/test/fixtures/es2015/yield/parameter-name-arrow-inside-generator-1/options.json deleted file mode 100644 index b566d4944c2c..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/yield/parameter-name-arrow-inside-generator-1/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Yield cannot be used as name inside a generator function (2:3)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/yield/parameter-name-arrow-inside-generator-1/output.json b/packages/babel-parser/test/fixtures/es2015/yield/parameter-name-arrow-inside-generator-1/output.json new file mode 100644 index 000000000000..1bec942c71ac --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/yield/parameter-name-arrow-inside-generator-1/output.json @@ -0,0 +1,161 @@ +{ + "type": "File", + "start": 0, + "end": 35, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "errors": [ + "SyntaxError: Yield cannot be used as name inside a generator function (2:3)", + "SyntaxError: Binding invalid left-hand side in function parameter list (2:3)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 35, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 35, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 10, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 12 + }, + "identifierName": "fn" + }, + "name": "fn" + }, + "generator": true, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 15, + "end": 35, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 19, + "end": 33, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 16 + } + }, + "expression": { + "type": "ArrowFunctionExpression", + "start": 19, + "end": 32, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 15 + } + }, + "id": null, + "generator": false, + "async": false, + "params": [ + { + "type": "YieldExpression", + "start": 20, + "end": 25, + "loc": { + "start": { + "line": 2, + "column": 3 + }, + "end": { + "line": 2, + "column": 8 + } + }, + "delegate": false, + "argument": null + } + ], + "body": { + "type": "BlockStatement", + "start": 30, + "end": 32, + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 15 + } + }, + "body": [], + "directives": [] + } + } + } + ], + "directives": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/yield/parameter-name-arrow-inside-generator-2/options.json b/packages/babel-parser/test/fixtures/es2015/yield/parameter-name-arrow-inside-generator-2/options.json deleted file mode 100644 index b566d4944c2c..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/yield/parameter-name-arrow-inside-generator-2/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Yield cannot be used as name inside a generator function (2:3)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/yield/parameter-name-arrow-inside-generator-2/output.json b/packages/babel-parser/test/fixtures/es2015/yield/parameter-name-arrow-inside-generator-2/output.json new file mode 100644 index 000000000000..3c16beba8cdf --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/yield/parameter-name-arrow-inside-generator-2/output.json @@ -0,0 +1,177 @@ +{ + "type": "File", + "start": 0, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "errors": [ + "SyntaxError: Yield cannot be used as name inside a generator function (2:3)", + "SyntaxError: Binding invalid left-hand side in function parameter list (2:3)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 10, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 12 + }, + "identifierName": "fn" + }, + "name": "fn" + }, + "generator": true, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 15, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 19, + "end": 36, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 19 + } + }, + "expression": { + "type": "ArrowFunctionExpression", + "start": 19, + "end": 35, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 18 + } + }, + "id": null, + "generator": false, + "async": false, + "params": [ + { + "type": "YieldExpression", + "start": 20, + "end": 28, + "loc": { + "start": { + "line": 2, + "column": 3 + }, + "end": { + "line": 2, + "column": 11 + } + }, + "delegate": false, + "argument": { + "type": "Identifier", + "start": 26, + "end": 28, + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 11 + }, + "identifierName": "fn" + }, + "name": "fn" + } + } + ], + "body": { + "type": "BlockStatement", + "start": 33, + "end": 35, + "loc": { + "start": { + "line": 2, + "column": 16 + }, + "end": { + "line": 2, + "column": 18 + } + }, + "body": [], + "directives": [] + } + } + } + ], + "directives": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/yield/parameter-name-arrow-inside-generator-3/options.json b/packages/babel-parser/test/fixtures/es2015/yield/parameter-name-arrow-inside-generator-3/options.json deleted file mode 100644 index 479a9a79f900..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/yield/parameter-name-arrow-inside-generator-3/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Yield cannot be used as name inside a generator function (2:9)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/yield/parameter-name-arrow-inside-generator-3/output.json b/packages/babel-parser/test/fixtures/es2015/yield/parameter-name-arrow-inside-generator-3/output.json new file mode 100644 index 000000000000..18209649f3a6 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/yield/parameter-name-arrow-inside-generator-3/output.json @@ -0,0 +1,195 @@ +{ + "type": "File", + "start": 0, + "end": 41, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "errors": [ + "SyntaxError: Yield cannot be used as name inside a generator function (2:9)", + "SyntaxError: Binding invalid left-hand side in function parameter list (2:9)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 41, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 41, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 10, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 12 + }, + "identifierName": "fn" + }, + "name": "fn" + }, + "generator": true, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 15, + "end": 41, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 19, + "end": 39, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 22 + } + }, + "expression": { + "type": "ArrowFunctionExpression", + "start": 19, + "end": 38, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 21 + } + }, + "id": null, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "start": 20, + "end": 21, + "loc": { + "start": { + "line": 2, + "column": 3 + }, + "end": { + "line": 2, + "column": 4 + }, + "identifierName": "a" + }, + "name": "a" + }, + { + "type": "Identifier", + "start": 23, + "end": 24, + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 7 + }, + "identifierName": "b" + }, + "name": "b" + }, + { + "type": "YieldExpression", + "start": 26, + "end": 31, + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 14 + } + }, + "delegate": false, + "argument": null + } + ], + "body": { + "type": "BlockStatement", + "start": 36, + "end": 38, + "loc": { + "start": { + "line": 2, + "column": 19 + }, + "end": { + "line": 2, + "column": 21 + } + }, + "body": [], + "directives": [] + } + } + } + ], + "directives": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/yield/parameter-name-generator-method/options.json b/packages/babel-parser/test/fixtures/es2015/yield/parameter-name-generator-method/options.json deleted file mode 100644 index 72f8d0e0e4c3..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/yield/parameter-name-generator-method/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Can not use 'yield' as identifier inside a generator (1:11)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/yield/parameter-name-generator-method/output.json b/packages/babel-parser/test/fixtures/es2015/yield/parameter-name-generator-method/output.json new file mode 100644 index 000000000000..2a15b906e992 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/yield/parameter-name-generator-method/output.json @@ -0,0 +1,148 @@ +{ + "type": "File", + "start": 0, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "errors": [ + "SyntaxError: Can not use 'yield' as identifier inside a generator (1:11)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "expression": { + "type": "ObjectExpression", + "start": 1, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "properties": [ + { + "type": "ObjectMethod", + "start": 3, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "method": true, + "key": { + "type": "Identifier", + "start": 4, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 10 + }, + "identifierName": "method" + }, + "name": "method" + }, + "computed": false, + "kind": "method", + "id": null, + "generator": true, + "async": false, + "params": [ + { + "type": "Identifier", + "start": 11, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 16 + }, + "identifierName": "yield" + }, + "name": "yield" + } + ], + "body": { + "type": "BlockStatement", + "start": 18, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "body": [], + "directives": [] + } + } + ], + "extra": { + "parenthesized": true, + "parenStart": 0 + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/yield/parameter-name-generator/options.json b/packages/babel-parser/test/fixtures/es2015/yield/parameter-name-generator/options.json deleted file mode 100644 index dcab4205d32f..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/yield/parameter-name-generator/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Can not use 'yield' as identifier inside a generator (1:13)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/yield/parameter-name-generator/output.json b/packages/babel-parser/test/fixtures/es2015/yield/parameter-name-generator/output.json new file mode 100644 index 000000000000..a8a1424ee419 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/yield/parameter-name-generator/output.json @@ -0,0 +1,108 @@ +{ + "type": "File", + "start": 0, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "errors": [ + "SyntaxError: Can not use 'yield' as identifier inside a generator (1:13)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "id": { + "type": "Identifier", + "start": 10, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 12 + }, + "identifierName": "fn" + }, + "name": "fn" + }, + "generator": true, + "async": false, + "params": [ + { + "type": "Identifier", + "start": 13, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 18 + }, + "identifierName": "yield" + }, + "name": "yield" + } + ], + "body": { + "type": "BlockStatement", + "start": 20, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 20 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "body": [], + "directives": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/yield/parameter-name-strict-body/options.json b/packages/babel-parser/test/fixtures/es2015/yield/parameter-name-strict-body/options.json deleted file mode 100644 index 0329a317f084..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/yield/parameter-name-strict-body/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Binding 'yield' in strict mode (1:12)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/yield/parameter-name-strict-body/output.json b/packages/babel-parser/test/fixtures/es2015/yield/parameter-name-strict-body/output.json new file mode 100644 index 000000000000..ad17fc3ec47d --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/yield/parameter-name-strict-body/output.json @@ -0,0 +1,144 @@ +{ + "type": "File", + "start": 0, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "errors": [ + "SyntaxError: Binding 'yield' in strict mode (1:12)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 11 + }, + "identifierName": "fn" + }, + "name": "fn" + }, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "start": 12, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 17 + }, + "identifierName": "yield" + }, + "name": "yield" + } + ], + "body": { + "type": "BlockStatement", + "start": 19, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "body": [], + "directives": [ + { + "type": "Directive", + "start": 21, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 21 + }, + "end": { + "line": 1, + "column": 34 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 21, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 21 + }, + "end": { + "line": 1, + "column": 33 + } + }, + "value": "use strict", + "extra": { + "raw": "\"use strict\"", + "rawValue": "use strict" + } + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/yield/parameter-name-strict/options.json b/packages/babel-parser/test/fixtures/es2015/yield/parameter-name-strict/options.json deleted file mode 100644 index 75bdf3d53d6e..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/yield/parameter-name-strict/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Unexpected reserved word 'yield' (2:12)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/yield/parameter-name-strict/output.json b/packages/babel-parser/test/fixtures/es2015/yield/parameter-name-strict/output.json new file mode 100644 index 000000000000..ac0ac6a92f89 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/yield/parameter-name-strict/output.json @@ -0,0 +1,144 @@ +{ + "type": "File", + "start": 0, + "end": 35, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 21 + } + }, + "errors": [ + "SyntaxError: Unexpected reserved word 'yield' (2:12)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 35, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 21 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 14, + "end": 35, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 21 + } + }, + "id": { + "type": "Identifier", + "start": 23, + "end": 25, + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 11 + }, + "identifierName": "fn" + }, + "name": "fn" + }, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "start": 26, + "end": 31, + "loc": { + "start": { + "line": 2, + "column": 12 + }, + "end": { + "line": 2, + "column": 17 + }, + "identifierName": "yield" + }, + "name": "yield" + } + ], + "body": { + "type": "BlockStatement", + "start": 33, + "end": 35, + "loc": { + "start": { + "line": 2, + "column": 19 + }, + "end": { + "line": 2, + "column": 21 + } + }, + "body": [], + "directives": [] + } + } + ], + "directives": [ + { + "type": "Directive", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 0, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "value": "use strict", + "extra": { + "raw": "\"use strict\"", + "rawValue": "use strict" + } + } + } + ] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/yield/yield-star-parameter-default-inside-generator/options.json b/packages/babel-parser/test/fixtures/es2015/yield/yield-star-parameter-default-inside-generator/options.json deleted file mode 100644 index dd9a684ef928..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/yield/yield-star-parameter-default-inside-generator/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "yield is not allowed in generator parameters (1:17)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/yield/yield-star-parameter-default-inside-generator/output.json b/packages/babel-parser/test/fixtures/es2015/yield/yield-star-parameter-default-inside-generator/output.json new file mode 100644 index 000000000000..77a0a58b8e3b --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/yield/yield-star-parameter-default-inside-generator/output.json @@ -0,0 +1,157 @@ +{ + "type": "File", + "start": 0, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 33 + } + }, + "errors": [ + "SyntaxError: yield is not allowed in generator parameters (1:17)", + "SyntaxError: yield is not allowed in generator parameters (1:24)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 33 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 33 + } + }, + "id": { + "type": "Identifier", + "start": 10, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 12 + }, + "identifierName": "fn" + }, + "name": "fn" + }, + "generator": true, + "async": false, + "params": [ + { + "type": "AssignmentPattern", + "start": 13, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "left": { + "type": "Identifier", + "start": 13, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 14 + }, + "identifierName": "x" + }, + "name": "x" + }, + "right": { + "type": "YieldExpression", + "start": 17, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "delegate": true, + "argument": { + "type": "YieldExpression", + "start": 24, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 24 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "delegate": false, + "argument": null + } + } + } + ], + "body": { + "type": "BlockStatement", + "start": 31, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 31 + }, + "end": { + "line": 1, + "column": 33 + } + }, + "body": [], + "directives": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2016/exponentiation-operator/10/options.json b/packages/babel-parser/test/fixtures/es2016/exponentiation-operator/10/options.json deleted file mode 100644 index 2c624e8cec70..000000000000 --- a/packages/babel-parser/test/fixtures/es2016/exponentiation-operator/10/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Illegal expression. Wrap left hand side or entire exponentiation in parentheses. (1:1)" -} diff --git a/packages/babel-parser/test/fixtures/es2016/exponentiation-operator/10/output.json b/packages/babel-parser/test/fixtures/es2016/exponentiation-operator/10/output.json new file mode 100644 index 000000000000..99a1c0eac6e6 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2016/exponentiation-operator/10/output.json @@ -0,0 +1,126 @@ +{ + "type": "File", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "errors": [ + "SyntaxError: Illegal expression. Wrap left hand side or entire exponentiation in parentheses. (1:1)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "expression": { + "type": "BinaryExpression", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "left": { + "type": "UnaryExpression", + "start": 0, + "end": 2, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 2 + } + }, + "operator": "-", + "prefix": true, + "argument": { + "type": "NumericLiteral", + "start": 1, + "end": 2, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 2 + } + }, + "extra": { + "rawValue": 5, + "raw": "5" + }, + "value": 5 + } + }, + "operator": "**", + "right": { + "type": "NumericLiteral", + "start": 6, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "extra": { + "rawValue": 6, + "raw": "6" + }, + "value": 6 + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2016/exponentiation-operator/11/options.json b/packages/babel-parser/test/fixtures/es2016/exponentiation-operator/11/options.json deleted file mode 100644 index f04c5c035abb..000000000000 --- a/packages/babel-parser/test/fixtures/es2016/exponentiation-operator/11/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Illegal expression. Wrap left hand side or entire exponentiation in parentheses. (1:2)" -} diff --git a/packages/babel-parser/test/fixtures/es2016/exponentiation-operator/11/output.json b/packages/babel-parser/test/fixtures/es2016/exponentiation-operator/11/output.json new file mode 100644 index 000000000000..8bfc60ddbdbc --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2016/exponentiation-operator/11/output.json @@ -0,0 +1,128 @@ +{ + "type": "File", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "errors": [ + "SyntaxError: Illegal expression. Wrap left hand side or entire exponentiation in parentheses. (1:2)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "expression": { + "type": "BinaryExpression", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "left": { + "type": "UnaryExpression", + "start": 0, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "operator": "-", + "prefix": true, + "argument": { + "type": "NumericLiteral", + "start": 2, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 2 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "extra": { + "rawValue": 5, + "raw": "5", + "parenthesized": true, + "parenStart": 1 + }, + "value": 5 + } + }, + "operator": "**", + "right": { + "type": "NumericLiteral", + "start": 8, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "extra": { + "rawValue": 6, + "raw": "6" + }, + "value": 6 + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2016/exponentiation-operator/12/options.json b/packages/babel-parser/test/fixtures/es2016/exponentiation-operator/12/options.json deleted file mode 100644 index f04c5c035abb..000000000000 --- a/packages/babel-parser/test/fixtures/es2016/exponentiation-operator/12/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Illegal expression. Wrap left hand side or entire exponentiation in parentheses. (1:2)" -} diff --git a/packages/babel-parser/test/fixtures/es2016/exponentiation-operator/12/output.json b/packages/babel-parser/test/fixtures/es2016/exponentiation-operator/12/output.json new file mode 100644 index 000000000000..1a7be0b48b55 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2016/exponentiation-operator/12/output.json @@ -0,0 +1,130 @@ +{ + "type": "File", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "errors": [ + "SyntaxError: Illegal expression. Wrap left hand side or entire exponentiation in parentheses. (1:2)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "expression": { + "type": "BinaryExpression", + "start": 1, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "left": { + "type": "UnaryExpression", + "start": 1, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "operator": "-", + "prefix": true, + "argument": { + "type": "NumericLiteral", + "start": 2, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 2 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "extra": { + "rawValue": 5, + "raw": "5" + }, + "value": 5 + } + }, + "operator": "**", + "right": { + "type": "NumericLiteral", + "start": 7, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "extra": { + "rawValue": 6, + "raw": "6" + }, + "value": 6 + }, + "extra": { + "parenthesized": true, + "parenStart": 0 + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2016/exponentiation-operator/15/options.json b/packages/babel-parser/test/fixtures/es2016/exponentiation-operator/15/options.json index c694133bf2b1..6d24025b8674 100644 --- a/packages/babel-parser/test/fixtures/es2016/exponentiation-operator/15/options.json +++ b/packages/babel-parser/test/fixtures/es2016/exponentiation-operator/15/options.json @@ -1,4 +1,3 @@ { - "createParenthesizedExpressions": true, - "throws": "Illegal expression. Wrap left hand side or entire exponentiation in parentheses. (1:1)" -} + "createParenthesizedExpressions": true +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2016/exponentiation-operator/15/output.json b/packages/babel-parser/test/fixtures/es2016/exponentiation-operator/15/output.json new file mode 100644 index 000000000000..56e0b17f480e --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2016/exponentiation-operator/15/output.json @@ -0,0 +1,141 @@ +{ + "type": "File", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "errors": [ + "SyntaxError: Illegal expression. Wrap left hand side or entire exponentiation in parentheses. (1:1)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "expression": { + "type": "BinaryExpression", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "left": { + "type": "UnaryExpression", + "start": 0, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "operator": "-", + "prefix": true, + "argument": { + "type": "ParenthesizedExpression", + "start": 1, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 2, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 2 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "extra": { + "rawValue": 5, + "raw": "5" + }, + "value": 5 + } + } + }, + "operator": "**", + "right": { + "type": "NumericLiteral", + "start": 8, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "extra": { + "rawValue": 6, + "raw": "6" + }, + "value": 6 + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2016/exponentiation-operator/16/options.json b/packages/babel-parser/test/fixtures/es2016/exponentiation-operator/16/options.json index 19687fbe197a..6d24025b8674 100644 --- a/packages/babel-parser/test/fixtures/es2016/exponentiation-operator/16/options.json +++ b/packages/babel-parser/test/fixtures/es2016/exponentiation-operator/16/options.json @@ -1,4 +1,3 @@ { - "createParenthesizedExpressions": true, - "throws": "Illegal expression. Wrap left hand side or entire exponentiation in parentheses. (1:2)" -} + "createParenthesizedExpressions": true +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2016/exponentiation-operator/16/output.json b/packages/babel-parser/test/fixtures/es2016/exponentiation-operator/16/output.json new file mode 100644 index 000000000000..5fd8ad0e4fbd --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2016/exponentiation-operator/16/output.json @@ -0,0 +1,141 @@ +{ + "type": "File", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "errors": [ + "SyntaxError: Illegal expression. Wrap left hand side or entire exponentiation in parentheses. (1:2)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "expression": { + "type": "ParenthesizedExpression", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "expression": { + "type": "BinaryExpression", + "start": 1, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "left": { + "type": "UnaryExpression", + "start": 1, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "operator": "-", + "prefix": true, + "argument": { + "type": "NumericLiteral", + "start": 2, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 2 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "extra": { + "rawValue": 5, + "raw": "5" + }, + "value": 5 + } + }, + "operator": "**", + "right": { + "type": "NumericLiteral", + "start": 7, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "extra": { + "rawValue": 6, + "raw": "6" + }, + "value": 6 + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/array-pattern-default/options.json b/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/array-pattern-default/options.json deleted file mode 100644 index 12b18792fcc4..000000000000 --- a/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/array-pattern-default/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Illegal 'use strict' directive in function with non-simple parameter list (1:0)" -} diff --git a/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/array-pattern-default/output.json b/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/array-pattern-default/output.json new file mode 100644 index 000000000000..5c66e79b6581 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/array-pattern-default/output.json @@ -0,0 +1,209 @@ +{ + "type": "File", + "start": 0, + "end": 57, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "errors": [ + "SyntaxError: Illegal 'use strict' directive in function with non-simple parameter list (1:0)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 57, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 57, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 10 + }, + "identifierName": "a" + }, + "name": "a" + }, + "generator": false, + "async": false, + "params": [ + { + "type": "AssignmentPattern", + "start": 11, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "left": { + "type": "ArrayPattern", + "start": 11, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "elements": [ + { + "type": "Identifier", + "start": 13, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 20 + }, + "identifierName": "option1" + }, + "name": "option1" + }, + { + "type": "Identifier", + "start": 22, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 22 + }, + "end": { + "line": 1, + "column": 29 + }, + "identifierName": "option2" + }, + "name": "option2" + } + ] + }, + "right": { + "type": "ArrayExpression", + "start": 34, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 34 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "elements": [] + } + } + ], + "body": { + "type": "BlockStatement", + "start": 38, + "end": 57, + "loc": { + "start": { + "line": 1, + "column": 38 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "body": [], + "directives": [ + { + "type": "Directive", + "start": 42, + "end": 55, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 15 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 42, + "end": 54, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 14 + } + }, + "value": "use strict", + "extra": { + "raw": "\"use strict\"", + "rawValue": "use strict" + } + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/array-pattern/options.json b/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/array-pattern/options.json deleted file mode 100644 index 12b18792fcc4..000000000000 --- a/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/array-pattern/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Illegal 'use strict' directive in function with non-simple parameter list (1:0)" -} diff --git a/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/array-pattern/output.json b/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/array-pattern/output.json new file mode 100644 index 000000000000..21f903177a3d --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/array-pattern/output.json @@ -0,0 +1,178 @@ +{ + "type": "File", + "start": 0, + "end": 52, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "errors": [ + "SyntaxError: Illegal 'use strict' directive in function with non-simple parameter list (1:0)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 52, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 52, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 10 + }, + "identifierName": "a" + }, + "name": "a" + }, + "generator": false, + "async": false, + "params": [ + { + "type": "ArrayPattern", + "start": 11, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "elements": [ + { + "type": "Identifier", + "start": 13, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 20 + }, + "identifierName": "option1" + }, + "name": "option1" + }, + { + "type": "Identifier", + "start": 22, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 22 + }, + "end": { + "line": 1, + "column": 29 + }, + "identifierName": "option2" + }, + "name": "option2" + } + ] + } + ], + "body": { + "type": "BlockStatement", + "start": 33, + "end": 52, + "loc": { + "start": { + "line": 1, + "column": 33 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "body": [], + "directives": [ + { + "type": "Directive", + "start": 37, + "end": 50, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 15 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 37, + "end": 49, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 14 + } + }, + "value": "use strict", + "extra": { + "raw": "\"use strict\"", + "rawValue": "use strict" + } + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/arrow-function/options.json b/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/arrow-function/options.json deleted file mode 100644 index 089b542c3704..000000000000 --- a/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/arrow-function/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Illegal 'use strict' directive in function with non-simple parameter list (1:8)" -} diff --git a/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/arrow-function/output.json b/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/arrow-function/output.json new file mode 100644 index 000000000000..c63422a6be79 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/arrow-function/output.json @@ -0,0 +1,209 @@ +{ + "type": "File", + "start": 0, + "end": 46, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 2 + } + }, + "errors": [ + "SyntaxError: Illegal 'use strict' directive in function with non-simple parameter list (1:8)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 46, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 2 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "VariableDeclaration", + "start": 0, + "end": 46, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 2 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 4, + "end": 45, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 4, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 5 + }, + "identifierName": "a" + }, + "name": "a" + }, + "init": { + "type": "ArrowFunctionExpression", + "start": 8, + "end": 45, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "id": null, + "generator": false, + "async": false, + "params": [ + { + "type": "AssignmentPattern", + "start": 9, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "left": { + "type": "Identifier", + "start": 9, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 16 + }, + "identifierName": "options" + }, + "name": "options" + }, + "right": { + "type": "ObjectExpression", + "start": 19, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "properties": [] + } + } + ], + "body": { + "type": "BlockStatement", + "start": 26, + "end": 45, + "loc": { + "start": { + "line": 1, + "column": 26 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "body": [], + "directives": [ + { + "type": "Directive", + "start": 30, + "end": 43, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 15 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 30, + "end": 42, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 14 + } + }, + "value": "use strict", + "extra": { + "raw": "\"use strict\"", + "rawValue": "use strict" + } + } + } + ] + } + } + } + ], + "kind": "var" + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/async-arrow-function/options.json b/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/async-arrow-function/options.json deleted file mode 100644 index 089b542c3704..000000000000 --- a/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/async-arrow-function/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Illegal 'use strict' directive in function with non-simple parameter list (1:8)" -} diff --git a/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/async-arrow-function/output.json b/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/async-arrow-function/output.json new file mode 100644 index 000000000000..6183a084c384 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/async-arrow-function/output.json @@ -0,0 +1,209 @@ +{ + "type": "File", + "start": 0, + "end": 52, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 2 + } + }, + "errors": [ + "SyntaxError: Illegal 'use strict' directive in function with non-simple parameter list (1:8)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 52, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 2 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "VariableDeclaration", + "start": 0, + "end": 52, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 2 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 4, + "end": 51, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 4, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 5 + }, + "identifierName": "a" + }, + "name": "a" + }, + "init": { + "type": "ArrowFunctionExpression", + "start": 8, + "end": 51, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "id": null, + "generator": false, + "async": true, + "params": [ + { + "type": "AssignmentPattern", + "start": 15, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 27 + } + }, + "left": { + "type": "Identifier", + "start": 15, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 22 + }, + "identifierName": "options" + }, + "name": "options" + }, + "right": { + "type": "ObjectExpression", + "start": 25, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 25 + }, + "end": { + "line": 1, + "column": 27 + } + }, + "properties": [] + } + } + ], + "body": { + "type": "BlockStatement", + "start": 32, + "end": 51, + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "body": [], + "directives": [ + { + "type": "Directive", + "start": 36, + "end": 49, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 15 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 36, + "end": 48, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 14 + } + }, + "value": "use strict", + "extra": { + "raw": "\"use strict\"", + "rawValue": "use strict" + } + } + } + ] + } + } + } + ], + "kind": "var" + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/async-function/options.json b/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/async-function/options.json deleted file mode 100644 index 12b18792fcc4..000000000000 --- a/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/async-function/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Illegal 'use strict' directive in function with non-simple parameter list (1:0)" -} diff --git a/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/async-function/output.json b/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/async-function/output.json new file mode 100644 index 000000000000..324b53bc26ec --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/async-function/output.json @@ -0,0 +1,175 @@ +{ + "type": "File", + "start": 0, + "end": 50, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "errors": [ + "SyntaxError: Illegal 'use strict' directive in function with non-simple parameter list (1:0)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 50, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 50, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 15, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 16 + }, + "identifierName": "a" + }, + "name": "a" + }, + "generator": false, + "async": true, + "params": [ + { + "type": "AssignmentPattern", + "start": 17, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "left": { + "type": "Identifier", + "start": 17, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 24 + }, + "identifierName": "options" + }, + "name": "options" + }, + "right": { + "type": "ObjectExpression", + "start": 27, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 27 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "properties": [] + } + } + ], + "body": { + "type": "BlockStatement", + "start": 31, + "end": 50, + "loc": { + "start": { + "line": 1, + "column": 31 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "body": [], + "directives": [ + { + "type": "Directive", + "start": 35, + "end": 48, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 15 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 35, + "end": 47, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 14 + } + }, + "value": "use strict", + "extra": { + "raw": "\"use strict\"", + "rawValue": "use strict" + } + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/default/options.json b/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/default/options.json deleted file mode 100644 index 12b18792fcc4..000000000000 --- a/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/default/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Illegal 'use strict' directive in function with non-simple parameter list (1:0)" -} diff --git a/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/default/output.json b/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/default/output.json new file mode 100644 index 000000000000..f40df83751ba --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/default/output.json @@ -0,0 +1,175 @@ +{ + "type": "File", + "start": 0, + "end": 44, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "errors": [ + "SyntaxError: Illegal 'use strict' directive in function with non-simple parameter list (1:0)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 44, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 44, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 10 + }, + "identifierName": "a" + }, + "name": "a" + }, + "generator": false, + "async": false, + "params": [ + { + "type": "AssignmentPattern", + "start": 11, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "left": { + "type": "Identifier", + "start": 11, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 18 + }, + "identifierName": "options" + }, + "name": "options" + }, + "right": { + "type": "ObjectExpression", + "start": 21, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 21 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "properties": [] + } + } + ], + "body": { + "type": "BlockStatement", + "start": 25, + "end": 44, + "loc": { + "start": { + "line": 1, + "column": 25 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "body": [], + "directives": [ + { + "type": "Directive", + "start": 29, + "end": 42, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 15 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 29, + "end": 41, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 14 + } + }, + "value": "use strict", + "extra": { + "raw": "\"use strict\"", + "rawValue": "use strict" + } + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/generator-function/options.json b/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/generator-function/options.json deleted file mode 100644 index 12b18792fcc4..000000000000 --- a/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/generator-function/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Illegal 'use strict' directive in function with non-simple parameter list (1:0)" -} diff --git a/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/generator-function/output.json b/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/generator-function/output.json new file mode 100644 index 000000000000..4d433d4b0bc1 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/generator-function/output.json @@ -0,0 +1,175 @@ +{ + "type": "File", + "start": 0, + "end": 45, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "errors": [ + "SyntaxError: Illegal 'use strict' directive in function with non-simple parameter list (1:0)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 45, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 45, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 10, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 11 + }, + "identifierName": "a" + }, + "name": "a" + }, + "generator": true, + "async": false, + "params": [ + { + "type": "AssignmentPattern", + "start": 12, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "left": { + "type": "Identifier", + "start": 12, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 19 + }, + "identifierName": "options" + }, + "name": "options" + }, + "right": { + "type": "ObjectExpression", + "start": 22, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 22 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "properties": [] + } + } + ], + "body": { + "type": "BlockStatement", + "start": 26, + "end": 45, + "loc": { + "start": { + "line": 1, + "column": 26 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "body": [], + "directives": [ + { + "type": "Directive", + "start": 30, + "end": 43, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 15 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 30, + "end": 42, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 14 + } + }, + "value": "use strict", + "extra": { + "raw": "\"use strict\"", + "rawValue": "use strict" + } + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/generator-method/options.json b/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/generator-method/options.json deleted file mode 100644 index 9908b496fd2a..000000000000 --- a/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/generator-method/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Illegal 'use strict' directive in function with non-simple parameter list (2:5)" -} diff --git a/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/generator-method/output.json b/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/generator-method/output.json new file mode 100644 index 000000000000..393540b1fa01 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/generator-method/output.json @@ -0,0 +1,246 @@ +{ + "type": "File", + "start": 0, + "end": 58, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 5, + "column": 2 + } + }, + "errors": [ + "SyntaxError: Illegal 'use strict' directive in function with non-simple parameter list (2:5)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 58, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 5, + "column": 2 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "VariableDeclaration", + "start": 0, + "end": 58, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 5, + "column": 2 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 4, + "end": 57, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 5, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 4, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 7 + }, + "identifierName": "obj" + }, + "name": "obj" + }, + "init": { + "type": "ObjectExpression", + "start": 10, + "end": 57, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 5, + "column": 1 + } + }, + "properties": [ + { + "type": "ObjectMethod", + "start": 14, + "end": 55, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 4, + "column": 3 + } + }, + "method": true, + "key": { + "type": "Identifier", + "start": 16, + "end": 17, + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 5 + }, + "identifierName": "a" + }, + "name": "a" + }, + "computed": false, + "kind": "method", + "id": null, + "generator": true, + "async": false, + "params": [ + { + "type": "AssignmentPattern", + "start": 18, + "end": 30, + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 18 + } + }, + "left": { + "type": "Identifier", + "start": 18, + "end": 25, + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 13 + }, + "identifierName": "options" + }, + "name": "options" + }, + "right": { + "type": "ObjectExpression", + "start": 28, + "end": 30, + "loc": { + "start": { + "line": 2, + "column": 16 + }, + "end": { + "line": 2, + "column": 18 + } + }, + "properties": [] + } + } + ], + "body": { + "type": "BlockStatement", + "start": 32, + "end": 55, + "loc": { + "start": { + "line": 2, + "column": 20 + }, + "end": { + "line": 4, + "column": 3 + } + }, + "body": [], + "directives": [ + { + "type": "Directive", + "start": 38, + "end": 51, + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 17 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 38, + "end": 50, + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 16 + } + }, + "value": "use strict", + "extra": { + "raw": "\"use strict\"", + "rawValue": "use strict" + } + } + } + ] + } + } + ] + } + } + ], + "kind": "var" + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/method/options.json b/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/method/options.json deleted file mode 100644 index 5d0e394f2b9d..000000000000 --- a/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/method/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Illegal 'use strict' directive in function with non-simple parameter list (2:3)" -} diff --git a/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/method/output.json b/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/method/output.json new file mode 100644 index 000000000000..99d18df924f2 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/method/output.json @@ -0,0 +1,246 @@ +{ + "type": "File", + "start": 0, + "end": 56, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 5, + "column": 2 + } + }, + "errors": [ + "SyntaxError: Illegal 'use strict' directive in function with non-simple parameter list (2:3)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 56, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 5, + "column": 2 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "VariableDeclaration", + "start": 0, + "end": 56, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 5, + "column": 2 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 4, + "end": 55, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 5, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 4, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 7 + }, + "identifierName": "obj" + }, + "name": "obj" + }, + "init": { + "type": "ObjectExpression", + "start": 10, + "end": 55, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 5, + "column": 1 + } + }, + "properties": [ + { + "type": "ObjectMethod", + "start": 14, + "end": 53, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 4, + "column": 3 + } + }, + "method": true, + "key": { + "type": "Identifier", + "start": 14, + "end": 15, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 3 + }, + "identifierName": "a" + }, + "name": "a" + }, + "computed": false, + "kind": "method", + "id": null, + "generator": false, + "async": false, + "params": [ + { + "type": "AssignmentPattern", + "start": 16, + "end": 28, + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 16 + } + }, + "left": { + "type": "Identifier", + "start": 16, + "end": 23, + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 11 + }, + "identifierName": "options" + }, + "name": "options" + }, + "right": { + "type": "ObjectExpression", + "start": 26, + "end": 28, + "loc": { + "start": { + "line": 2, + "column": 14 + }, + "end": { + "line": 2, + "column": 16 + } + }, + "properties": [] + } + } + ], + "body": { + "type": "BlockStatement", + "start": 30, + "end": 53, + "loc": { + "start": { + "line": 2, + "column": 18 + }, + "end": { + "line": 4, + "column": 3 + } + }, + "body": [], + "directives": [ + { + "type": "Directive", + "start": 36, + "end": 49, + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 17 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 36, + "end": 48, + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 16 + } + }, + "value": "use strict", + "extra": { + "raw": "\"use strict\"", + "rawValue": "use strict" + } + } + } + ] + } + } + ] + } + } + ], + "kind": "var" + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/object-pattern-default/options.json b/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/object-pattern-default/options.json deleted file mode 100644 index 12b18792fcc4..000000000000 --- a/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/object-pattern-default/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Illegal 'use strict' directive in function with non-simple parameter list (1:0)" -} diff --git a/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/object-pattern-default/output.json b/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/object-pattern-default/output.json new file mode 100644 index 000000000000..f6c0442d811a --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/object-pattern-default/output.json @@ -0,0 +1,285 @@ +{ + "type": "File", + "start": 0, + "end": 57, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "errors": [ + "SyntaxError: Illegal 'use strict' directive in function with non-simple parameter list (1:0)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 57, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 57, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 10 + }, + "identifierName": "a" + }, + "name": "a" + }, + "generator": false, + "async": false, + "params": [ + { + "type": "AssignmentPattern", + "start": 11, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "left": { + "type": "ObjectPattern", + "start": 11, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "properties": [ + { + "type": "ObjectProperty", + "start": 13, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "method": false, + "key": { + "type": "Identifier", + "start": 13, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 20 + }, + "identifierName": "option1" + }, + "name": "option1" + }, + "computed": false, + "shorthand": true, + "value": { + "type": "Identifier", + "start": 13, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 20 + }, + "identifierName": "option1" + }, + "name": "option1" + }, + "extra": { + "shorthand": true + } + }, + { + "type": "ObjectProperty", + "start": 22, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 22 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "method": false, + "key": { + "type": "Identifier", + "start": 22, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 22 + }, + "end": { + "line": 1, + "column": 29 + }, + "identifierName": "option2" + }, + "name": "option2" + }, + "computed": false, + "shorthand": true, + "value": { + "type": "Identifier", + "start": 22, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 22 + }, + "end": { + "line": 1, + "column": 29 + }, + "identifierName": "option2" + }, + "name": "option2" + }, + "extra": { + "shorthand": true + } + } + ] + }, + "right": { + "type": "ObjectExpression", + "start": 34, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 34 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "properties": [] + } + } + ], + "body": { + "type": "BlockStatement", + "start": 38, + "end": 57, + "loc": { + "start": { + "line": 1, + "column": 38 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "body": [], + "directives": [ + { + "type": "Directive", + "start": 42, + "end": 55, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 15 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 42, + "end": 54, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 14 + } + }, + "value": "use strict", + "extra": { + "raw": "\"use strict\"", + "rawValue": "use strict" + } + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/object-pattern/options.json b/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/object-pattern/options.json deleted file mode 100644 index 12b18792fcc4..000000000000 --- a/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/object-pattern/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Illegal 'use strict' directive in function with non-simple parameter list (1:0)" -} diff --git a/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/object-pattern/output.json b/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/object-pattern/output.json new file mode 100644 index 000000000000..2089ba375f3e --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/object-pattern/output.json @@ -0,0 +1,254 @@ +{ + "type": "File", + "start": 0, + "end": 52, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "errors": [ + "SyntaxError: Illegal 'use strict' directive in function with non-simple parameter list (1:0)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 52, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 52, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 10 + }, + "identifierName": "a" + }, + "name": "a" + }, + "generator": false, + "async": false, + "params": [ + { + "type": "ObjectPattern", + "start": 11, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "properties": [ + { + "type": "ObjectProperty", + "start": 13, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "method": false, + "key": { + "type": "Identifier", + "start": 13, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 20 + }, + "identifierName": "option1" + }, + "name": "option1" + }, + "computed": false, + "shorthand": true, + "value": { + "type": "Identifier", + "start": 13, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 20 + }, + "identifierName": "option1" + }, + "name": "option1" + }, + "extra": { + "shorthand": true + } + }, + { + "type": "ObjectProperty", + "start": 22, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 22 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "method": false, + "key": { + "type": "Identifier", + "start": 22, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 22 + }, + "end": { + "line": 1, + "column": 29 + }, + "identifierName": "option2" + }, + "name": "option2" + }, + "computed": false, + "shorthand": true, + "value": { + "type": "Identifier", + "start": 22, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 22 + }, + "end": { + "line": 1, + "column": 29 + }, + "identifierName": "option2" + }, + "name": "option2" + }, + "extra": { + "shorthand": true + } + } + ] + } + ], + "body": { + "type": "BlockStatement", + "start": 33, + "end": 52, + "loc": { + "start": { + "line": 1, + "column": 33 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "body": [], + "directives": [ + { + "type": "Directive", + "start": 37, + "end": 50, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 15 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 37, + "end": 49, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 14 + } + }, + "value": "use strict", + "extra": { + "raw": "\"use strict\"", + "rawValue": "use strict" + } + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/rest/options.json b/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/rest/options.json deleted file mode 100644 index 12b18792fcc4..000000000000 --- a/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/rest/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Illegal 'use strict' directive in function with non-simple parameter list (1:0)" -} diff --git a/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/rest/output.json b/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/rest/output.json new file mode 100644 index 000000000000..9c23ba0225c7 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/rest/output.json @@ -0,0 +1,159 @@ +{ + "type": "File", + "start": 0, + "end": 42, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "errors": [ + "SyntaxError: Illegal 'use strict' directive in function with non-simple parameter list (1:0)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 42, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 42, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 10 + }, + "identifierName": "a" + }, + "name": "a" + }, + "generator": false, + "async": false, + "params": [ + { + "type": "RestElement", + "start": 11, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "argument": { + "type": "Identifier", + "start": 14, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 21 + }, + "identifierName": "options" + }, + "name": "options" + } + } + ], + "body": { + "type": "BlockStatement", + "start": 23, + "end": 42, + "loc": { + "start": { + "line": 1, + "column": 23 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "body": [], + "directives": [ + { + "type": "Directive", + "start": 27, + "end": 40, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 15 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 27, + "end": 39, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 14 + } + }, + "value": "use strict", + "extra": { + "raw": "\"use strict\"", + "rawValue": "use strict" + } + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2017/async-functions/2/options.json b/packages/babel-parser/test/fixtures/es2017/async-functions/2/options.json deleted file mode 100644 index c6f19067ee66..000000000000 --- a/packages/babel-parser/test/fixtures/es2017/async-functions/2/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "await* has been removed from the async functions proposal. Use Promise.all() instead. (2:2)" -} diff --git a/packages/babel-parser/test/fixtures/es2017/async-functions/2/output.json b/packages/babel-parser/test/fixtures/es2017/async-functions/2/output.json new file mode 100644 index 000000000000..d6708279fdcb --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2017/async-functions/2/output.json @@ -0,0 +1,154 @@ +{ + "type": "File", + "start": 0, + "end": 40, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "errors": [ + "SyntaxError: await* has been removed from the async functions proposal. Use Promise.all() instead. (2:2)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 40, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 40, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 15, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 18 + }, + "identifierName": "bar" + }, + "name": "bar" + }, + "generator": false, + "async": true, + "params": [], + "body": { + "type": "BlockStatement", + "start": 21, + "end": 40, + "loc": { + "start": { + "line": 1, + "column": 21 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 25, + "end": 38, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 15 + } + }, + "expression": { + "type": "AwaitExpression", + "start": 25, + "end": 37, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 14 + } + }, + "argument": { + "type": "CallExpression", + "start": 32, + "end": 37, + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 14 + } + }, + "callee": { + "type": "Identifier", + "start": 32, + "end": 35, + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 12 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "arguments": [] + } + } + } + ], + "directives": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2017/async-functions/await-async-function-expression-name/options.json b/packages/babel-parser/test/fixtures/es2017/async-functions/await-async-function-expression-name/options.json deleted file mode 100644 index 022428647fee..000000000000 --- a/packages/babel-parser/test/fixtures/es2017/async-functions/await-async-function-expression-name/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Can not use 'await' as identifier inside an async function (1:16)" -} diff --git a/packages/babel-parser/test/fixtures/es2017/async-functions/await-async-function-expression-name/output.json b/packages/babel-parser/test/fixtures/es2017/async-functions/await-async-function-expression-name/output.json new file mode 100644 index 000000000000..34fa5d9a8d4f --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2017/async-functions/await-async-function-expression-name/output.json @@ -0,0 +1,109 @@ +{ + "type": "File", + "start": 0, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 28 + } + }, + "errors": [ + "SyntaxError: Can not use 'await' as identifier inside an async function (1:16)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 28 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 28 + } + }, + "expression": { + "type": "FunctionExpression", + "start": 1, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "id": { + "type": "Identifier", + "start": 16, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 21 + }, + "identifierName": "await" + }, + "name": "await" + }, + "generator": false, + "async": true, + "params": [], + "body": { + "type": "BlockStatement", + "start": 24, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 24 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "body": [], + "directives": [] + }, + "extra": { + "parenthesized": true, + "parenStart": 0 + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2017/async-functions/await-binding-inside-arrow-params-inside-async-arrow-params/options.json b/packages/babel-parser/test/fixtures/es2017/async-functions/await-binding-inside-arrow-params-inside-async-arrow-params/options.json deleted file mode 100644 index c066100759e2..000000000000 --- a/packages/babel-parser/test/fixtures/es2017/async-functions/await-binding-inside-arrow-params-inside-async-arrow-params/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Await cannot be used as name inside an async function (1:20)" -} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2017/async-functions/await-binding-inside-arrow-params-inside-async-arrow-params/output.json b/packages/babel-parser/test/fixtures/es2017/async-functions/await-binding-inside-arrow-params-inside-async-arrow-params/output.json new file mode 100644 index 000000000000..c9a8709666e7 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2017/async-functions/await-binding-inside-arrow-params-inside-async-arrow-params/output.json @@ -0,0 +1,231 @@ +{ + "type": "File", + "start": 0, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "errors": [ + "SyntaxError: Await cannot be used as name inside an async function (1:20)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "expression": { + "type": "ArrowFunctionExpression", + "start": 0, + "end": 35, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 35 + } + }, + "id": null, + "generator": false, + "async": true, + "params": [ + { + "type": "AssignmentPattern", + "start": 7, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 28 + } + }, + "left": { + "type": "Identifier", + "start": 7, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 8 + }, + "identifierName": "a" + }, + "name": "a" + }, + "right": { + "type": "ArrowFunctionExpression", + "start": 11, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 28 + } + }, + "id": null, + "generator": false, + "async": false, + "params": [ + { + "type": "ObjectPattern", + "start": 12, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "properties": [ + { + "type": "ObjectProperty", + "start": 14, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "method": false, + "key": { + "type": "Identifier", + "start": 14, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 19 + }, + "identifierName": "await" + }, + "name": "await" + }, + "computed": false, + "shorthand": true, + "value": { + "type": "Identifier", + "start": 14, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 19 + }, + "identifierName": "await" + }, + "name": "await" + }, + "extra": { + "shorthand": true + } + } + ] + } + ], + "body": { + "type": "BlockStatement", + "start": 26, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 26 + }, + "end": { + "line": 1, + "column": 28 + } + }, + "body": [], + "directives": [] + } + } + } + ], + "body": { + "type": "BlockStatement", + "start": 33, + "end": 35, + "loc": { + "start": { + "line": 1, + "column": 33 + }, + "end": { + "line": 1, + "column": 35 + } + }, + "body": [], + "directives": [] + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2017/async-functions/await-function-declaration-name-inside-async-function/options.json b/packages/babel-parser/test/fixtures/es2017/async-functions/await-function-declaration-name-inside-async-function/options.json deleted file mode 100644 index d45274982dc1..000000000000 --- a/packages/babel-parser/test/fixtures/es2017/async-functions/await-function-declaration-name-inside-async-function/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Can not use 'await' as identifier inside an async function (2:11)" -} diff --git a/packages/babel-parser/test/fixtures/es2017/async-functions/await-function-declaration-name-inside-async-function/output.json b/packages/babel-parser/test/fixtures/es2017/async-functions/await-function-declaration-name-inside-async-function/output.json new file mode 100644 index 000000000000..3d543c665be5 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2017/async-functions/await-function-declaration-name-inside-async-function/output.json @@ -0,0 +1,143 @@ +{ + "type": "File", + "start": 0, + "end": 46, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "errors": [ + "SyntaxError: Can not use 'await' as identifier inside an async function (2:11)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 46, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 46, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 15, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 18 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "generator": false, + "async": true, + "params": [], + "body": { + "type": "BlockStatement", + "start": 21, + "end": 46, + "loc": { + "start": { + "line": 1, + "column": 21 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "body": [ + { + "type": "FunctionDeclaration", + "start": 25, + "end": 44, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 21 + } + }, + "id": { + "type": "Identifier", + "start": 34, + "end": 39, + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 16 + }, + "identifierName": "await" + }, + "name": "await" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 42, + "end": 44, + "loc": { + "start": { + "line": 2, + "column": 19 + }, + "end": { + "line": 2, + "column": 21 + } + }, + "body": [], + "directives": [] + } + } + ], + "directives": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2017/async-functions/await-inside-arguments-of-async-call-inside-parameters-of-async-arrow-function/options.json b/packages/babel-parser/test/fixtures/es2017/async-functions/await-inside-arguments-of-async-call-inside-parameters-of-async-arrow-function/options.json deleted file mode 100644 index 9a4cb65743b5..000000000000 --- a/packages/babel-parser/test/fixtures/es2017/async-functions/await-inside-arguments-of-async-call-inside-parameters-of-async-arrow-function/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Await cannot be used as name inside an async function (2:23)" -} diff --git a/packages/babel-parser/test/fixtures/es2017/async-functions/await-inside-arguments-of-async-call-inside-parameters-of-async-arrow-function/output.json b/packages/babel-parser/test/fixtures/es2017/async-functions/await-inside-arguments-of-async-call-inside-parameters-of-async-arrow-function/output.json new file mode 100644 index 000000000000..281c41288873 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2017/async-functions/await-inside-arguments-of-async-call-inside-parameters-of-async-arrow-function/output.json @@ -0,0 +1,277 @@ +{ + "type": "File", + "start": 0, + "end": 63, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "errors": [ + "SyntaxError: Await cannot be used as name inside an async function (2:23)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 63, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 63, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 15, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 17 + }, + "identifierName": "fn" + }, + "name": "fn" + }, + "generator": false, + "async": true, + "params": [], + "body": { + "type": "BlockStatement", + "start": 20, + "end": 63, + "loc": { + "start": { + "line": 1, + "column": 20 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 24, + "end": 61, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 39 + } + }, + "expression": { + "type": "ArrowFunctionExpression", + "start": 24, + "end": 60, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 38 + } + }, + "id": null, + "generator": false, + "async": true, + "params": [ + { + "type": "AssignmentPattern", + "start": 31, + "end": 53, + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 31 + } + }, + "left": { + "type": "Identifier", + "start": 31, + "end": 32, + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 10 + }, + "identifierName": "x" + }, + "name": "x" + }, + "right": { + "type": "CallExpression", + "start": 35, + "end": 53, + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 31 + } + }, + "callee": { + "type": "Identifier", + "start": 35, + "end": 40, + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 18 + }, + "identifierName": "async" + }, + "name": "async" + }, + "arguments": [ + { + "type": "AssignmentExpression", + "start": 41, + "end": 52, + "loc": { + "start": { + "line": 2, + "column": 19 + }, + "end": { + "line": 2, + "column": 30 + } + }, + "operator": "=", + "left": { + "type": "Identifier", + "start": 41, + "end": 42, + "loc": { + "start": { + "line": 2, + "column": 19 + }, + "end": { + "line": 2, + "column": 20 + }, + "identifierName": "y" + }, + "name": "y" + }, + "right": { + "type": "AwaitExpression", + "start": 45, + "end": 52, + "loc": { + "start": { + "line": 2, + "column": 23 + }, + "end": { + "line": 2, + "column": 30 + } + }, + "argument": { + "type": "NumericLiteral", + "start": 51, + "end": 52, + "loc": { + "start": { + "line": 2, + "column": 29 + }, + "end": { + "line": 2, + "column": 30 + } + }, + "extra": { + "rawValue": 2, + "raw": "2" + }, + "value": 2 + } + } + } + ] + } + } + ], + "body": { + "type": "BlockStatement", + "start": 58, + "end": 60, + "loc": { + "start": { + "line": 2, + "column": 36 + }, + "end": { + "line": 2, + "column": 38 + } + }, + "body": [], + "directives": [] + } + } + } + ], + "directives": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2017/async-functions/await-inside-parameters-of-nested-arrow-function/options.json b/packages/babel-parser/test/fixtures/es2017/async-functions/await-inside-parameters-of-nested-arrow-function/options.json deleted file mode 100644 index 7cec39290c2a..000000000000 --- a/packages/babel-parser/test/fixtures/es2017/async-functions/await-inside-parameters-of-nested-arrow-function/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Await cannot be used as name inside an async function (2:7)" -} diff --git a/packages/babel-parser/test/fixtures/es2017/async-functions/await-inside-parameters-of-nested-arrow-function/output.json b/packages/babel-parser/test/fixtures/es2017/async-functions/await-inside-parameters-of-nested-arrow-function/output.json new file mode 100644 index 000000000000..329e0670c59a --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2017/async-functions/await-inside-parameters-of-nested-arrow-function/output.json @@ -0,0 +1,210 @@ +{ + "type": "File", + "start": 0, + "end": 46, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "errors": [ + "SyntaxError: Await cannot be used as name inside an async function (2:7)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 46, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 46, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 15, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 17 + }, + "identifierName": "fn" + }, + "name": "fn" + }, + "generator": false, + "async": true, + "params": [], + "body": { + "type": "BlockStatement", + "start": 20, + "end": 46, + "loc": { + "start": { + "line": 1, + "column": 20 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 24, + "end": 44, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 22 + } + }, + "expression": { + "type": "ArrowFunctionExpression", + "start": 24, + "end": 43, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 21 + } + }, + "id": null, + "generator": false, + "async": false, + "params": [ + { + "type": "AssignmentPattern", + "start": 25, + "end": 36, + "loc": { + "start": { + "line": 2, + "column": 3 + }, + "end": { + "line": 2, + "column": 14 + } + }, + "left": { + "type": "Identifier", + "start": 25, + "end": 26, + "loc": { + "start": { + "line": 2, + "column": 3 + }, + "end": { + "line": 2, + "column": 4 + }, + "identifierName": "x" + }, + "name": "x" + }, + "right": { + "type": "AwaitExpression", + "start": 29, + "end": 36, + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 2, + "column": 14 + } + }, + "argument": { + "type": "NumericLiteral", + "start": 35, + "end": 36, + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 14 + } + }, + "extra": { + "rawValue": 2, + "raw": "2" + }, + "value": 2 + } + } + } + ], + "body": { + "type": "BlockStatement", + "start": 41, + "end": 43, + "loc": { + "start": { + "line": 2, + "column": 19 + }, + "end": { + "line": 2, + "column": 21 + } + }, + "body": [], + "directives": [] + } + } + } + ], + "directives": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2017/async-functions/await-inside-parameters-of-nested-async-arrow-function/options.json b/packages/babel-parser/test/fixtures/es2017/async-functions/await-inside-parameters-of-nested-async-arrow-function/options.json deleted file mode 100644 index b45bba7cab4a..000000000000 --- a/packages/babel-parser/test/fixtures/es2017/async-functions/await-inside-parameters-of-nested-async-arrow-function/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Await cannot be used as name inside an async function (2:13)" -} diff --git a/packages/babel-parser/test/fixtures/es2017/async-functions/await-inside-parameters-of-nested-async-arrow-function/output.json b/packages/babel-parser/test/fixtures/es2017/async-functions/await-inside-parameters-of-nested-async-arrow-function/output.json new file mode 100644 index 000000000000..39796387c784 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2017/async-functions/await-inside-parameters-of-nested-async-arrow-function/output.json @@ -0,0 +1,210 @@ +{ + "type": "File", + "start": 0, + "end": 52, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "errors": [ + "SyntaxError: Await cannot be used as name inside an async function (2:13)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 52, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 52, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 15, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 17 + }, + "identifierName": "fn" + }, + "name": "fn" + }, + "generator": false, + "async": true, + "params": [], + "body": { + "type": "BlockStatement", + "start": 20, + "end": 52, + "loc": { + "start": { + "line": 1, + "column": 20 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 24, + "end": 50, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 28 + } + }, + "expression": { + "type": "ArrowFunctionExpression", + "start": 24, + "end": 49, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 27 + } + }, + "id": null, + "generator": false, + "async": true, + "params": [ + { + "type": "AssignmentPattern", + "start": 31, + "end": 42, + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 20 + } + }, + "left": { + "type": "Identifier", + "start": 31, + "end": 32, + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 10 + }, + "identifierName": "x" + }, + "name": "x" + }, + "right": { + "type": "AwaitExpression", + "start": 35, + "end": 42, + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 20 + } + }, + "argument": { + "type": "NumericLiteral", + "start": 41, + "end": 42, + "loc": { + "start": { + "line": 2, + "column": 19 + }, + "end": { + "line": 2, + "column": 20 + } + }, + "extra": { + "rawValue": 2, + "raw": "2" + }, + "value": 2 + } + } + } + ], + "body": { + "type": "BlockStatement", + "start": 47, + "end": 49, + "loc": { + "start": { + "line": 2, + "column": 25 + }, + "end": { + "line": 2, + "column": 27 + } + }, + "body": [], + "directives": [] + } + } + } + ], + "directives": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2017/async-functions/await-inside-parameters/options.json b/packages/babel-parser/test/fixtures/es2017/async-functions/await-inside-parameters/options.json deleted file mode 100644 index f4af75f31164..000000000000 --- a/packages/babel-parser/test/fixtures/es2017/async-functions/await-inside-parameters/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "await is not allowed in async function parameters (1:22)" -} diff --git a/packages/babel-parser/test/fixtures/es2017/async-functions/await-inside-parameters/output.json b/packages/babel-parser/test/fixtures/es2017/async-functions/await-inside-parameters/output.json new file mode 100644 index 000000000000..be635254c883 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2017/async-functions/await-inside-parameters/output.json @@ -0,0 +1,158 @@ +{ + "type": "File", + "start": 0, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 33 + } + }, + "errors": [ + "SyntaxError: await is not allowed in async function parameters (1:22)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 33 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 33 + } + }, + "id": { + "type": "Identifier", + "start": 15, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 17 + }, + "identifierName": "fn" + }, + "name": "fn" + }, + "generator": false, + "async": true, + "params": [ + { + "type": "AssignmentPattern", + "start": 18, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "left": { + "type": "Identifier", + "start": 18, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 19 + }, + "identifierName": "x" + }, + "name": "x" + }, + "right": { + "type": "AwaitExpression", + "start": 22, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 22 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "argument": { + "type": "NumericLiteral", + "start": 28, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 28 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "extra": { + "rawValue": 2, + "raw": "2" + }, + "value": 2 + } + } + } + ], + "body": { + "type": "BlockStatement", + "start": 31, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 31 + }, + "end": { + "line": 1, + "column": 33 + } + }, + "body": [], + "directives": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2017/async-functions/invalid-escape-await/options.json b/packages/babel-parser/test/fixtures/es2017/async-functions/invalid-escape-await/options.json index 9e964f0047f8..1780992b49c5 100644 --- a/packages/babel-parser/test/fixtures/es2017/async-functions/invalid-escape-await/options.json +++ b/packages/babel-parser/test/fixtures/es2017/async-functions/invalid-escape-await/options.json @@ -1,3 +1,3 @@ { - "throws": "Can not use 'await' as identifier inside an async function (1:20)" -} + "throws": "Unexpected token, expected \";\" (1:31)" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2017/async-functions/invalid-inside-loop/options.json b/packages/babel-parser/test/fixtures/es2017/async-functions/invalid-inside-loop/options.json deleted file mode 100644 index 4bcd823e98be..000000000000 --- a/packages/babel-parser/test/fixtures/es2017/async-functions/invalid-inside-loop/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Async functions can only be declared at the top level or inside a block (1:10)" -} diff --git a/packages/babel-parser/test/fixtures/es2017/async-functions/invalid-inside-loop/output.json b/packages/babel-parser/test/fixtures/es2017/async-functions/invalid-inside-loop/output.json new file mode 100644 index 000000000000..e4933140f380 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2017/async-functions/invalid-inside-loop/output.json @@ -0,0 +1,125 @@ +{ + "type": "File", + "start": 0, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "errors": [ + "SyntaxError: Async functions can only be declared at the top level or inside a block (1:10)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "WhileStatement", + "start": 0, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "test": { + "type": "NumericLiteral", + "start": 7, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + }, + "body": { + "type": "FunctionDeclaration", + "start": 10, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "id": { + "type": "Identifier", + "start": 25, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 25 + }, + "end": { + "line": 1, + "column": 28 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "generator": false, + "async": true, + "params": [], + "body": { + "type": "BlockStatement", + "start": 30, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 30 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "body": [], + "directives": [] + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2017/async-functions/no-constructor/options.json b/packages/babel-parser/test/fixtures/es2017/async-functions/no-constructor/options.json deleted file mode 100644 index 49a2f478c663..000000000000 --- a/packages/babel-parser/test/fixtures/es2017/async-functions/no-constructor/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Constructor can't be an async function (2:8)" -} diff --git a/packages/babel-parser/test/fixtures/es2017/async-functions/no-constructor/output.json b/packages/babel-parser/test/fixtures/es2017/async-functions/no-constructor/output.json new file mode 100644 index 000000000000..8a46002d51c7 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2017/async-functions/no-constructor/output.json @@ -0,0 +1,144 @@ +{ + "type": "File", + "start": 0, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "errors": [ + "SyntaxError: Constructor can't be an async function (2:8)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ClassDeclaration", + "start": 0, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 6, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + }, + "identifierName": "A" + }, + "name": "A" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "start": 8, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "body": [ + { + "type": "ClassMethod", + "start": 12, + "end": 34, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 24 + } + }, + "static": false, + "key": { + "type": "Identifier", + "start": 18, + "end": 29, + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 19 + }, + "identifierName": "constructor" + }, + "name": "constructor" + }, + "computed": false, + "kind": "method", + "id": null, + "generator": false, + "async": true, + "params": [], + "body": { + "type": "BlockStatement", + "start": 32, + "end": 34, + "loc": { + "start": { + "line": 2, + "column": 22 + }, + "end": { + "line": 2, + "column": 24 + } + }, + "body": [], + "directives": [] + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2017/async-functions/params-invalid-rest-trailing-comma/options.json b/packages/babel-parser/test/fixtures/es2017/async-functions/params-invalid-rest-trailing-comma/options.json deleted file mode 100644 index bc7331763bfa..000000000000 --- a/packages/babel-parser/test/fixtures/es2017/async-functions/params-invalid-rest-trailing-comma/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Unexpected trailing comma after rest element (1:11)" -} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2017/async-functions/params-invalid-rest-trailing-comma/output.json b/packages/babel-parser/test/fixtures/es2017/async-functions/params-invalid-rest-trailing-comma/output.json new file mode 100644 index 000000000000..009f7252316f --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2017/async-functions/params-invalid-rest-trailing-comma/output.json @@ -0,0 +1,122 @@ +{ + "type": "File", + "start": 0, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "errors": [ + "SyntaxError: Unexpected trailing comma after rest element (1:11)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "expression": { + "type": "ArrowFunctionExpression", + "start": 0, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "id": null, + "generator": false, + "async": true, + "params": [ + { + "type": "RestElement", + "start": 7, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "argument": { + "type": "Identifier", + "start": 10, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 11 + }, + "identifierName": "a" + }, + "name": "a" + } + } + ], + "body": { + "type": "BlockStatement", + "start": 17, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "body": [], + "directives": [] + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2018/object-rest-spread/11/options.json b/packages/babel-parser/test/fixtures/es2018/object-rest-spread/11/options.json index 6dad74eebd16..54925950e059 100644 --- a/packages/babel-parser/test/fixtures/es2018/object-rest-spread/11/options.json +++ b/packages/babel-parser/test/fixtures/es2018/object-rest-spread/11/options.json @@ -1,4 +1,3 @@ { - "sourceType": "module", - "throws": "Identifier 'foo' has already been declared (2:23)" -} + "sourceType": "module" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2018/object-rest-spread/11/output.json b/packages/babel-parser/test/fixtures/es2018/object-rest-spread/11/output.json new file mode 100644 index 000000000000..8e0284f73c05 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2018/object-rest-spread/11/output.json @@ -0,0 +1,297 @@ +{ + "type": "File", + "start": 0, + "end": 57, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 35 + } + }, + "errors": [ + "SyntaxError: Identifier 'foo' has already been declared (2:23)", + "SyntaxError: `foo` has already been exported. Exported identifiers must be unique. (2:23)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 57, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 35 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExportNamedDeclaration", + "start": 0, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "specifiers": [], + "source": null, + "declaration": { + "type": "VariableDeclaration", + "start": 7, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 13, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "id": { + "type": "Identifier", + "start": 13, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 16 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "init": { + "type": "NumericLiteral", + "start": 19, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + } + } + ], + "kind": "const" + } + }, + { + "type": "ExportNamedDeclaration", + "start": 22, + "end": 57, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 35 + } + }, + "specifiers": [], + "source": null, + "declaration": { + "type": "VariableDeclaration", + "start": 29, + "end": 57, + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 2, + "column": 35 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 35, + "end": 56, + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 34 + } + }, + "id": { + "type": "ObjectPattern", + "start": 35, + "end": 50, + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 28 + } + }, + "properties": [ + { + "type": "ObjectProperty", + "start": 37, + "end": 40, + "loc": { + "start": { + "line": 2, + "column": 15 + }, + "end": { + "line": 2, + "column": 18 + } + }, + "method": false, + "key": { + "type": "Identifier", + "start": 37, + "end": 40, + "loc": { + "start": { + "line": 2, + "column": 15 + }, + "end": { + "line": 2, + "column": 18 + }, + "identifierName": "bar" + }, + "name": "bar" + }, + "computed": false, + "shorthand": true, + "value": { + "type": "Identifier", + "start": 37, + "end": 40, + "loc": { + "start": { + "line": 2, + "column": 15 + }, + "end": { + "line": 2, + "column": 18 + }, + "identifierName": "bar" + }, + "name": "bar" + }, + "extra": { + "shorthand": true + } + }, + { + "type": "RestElement", + "start": 42, + "end": 48, + "loc": { + "start": { + "line": 2, + "column": 20 + }, + "end": { + "line": 2, + "column": 26 + } + }, + "argument": { + "type": "Identifier", + "start": 45, + "end": 48, + "loc": { + "start": { + "line": 2, + "column": 23 + }, + "end": { + "line": 2, + "column": 26 + }, + "identifierName": "foo" + }, + "name": "foo" + } + } + ] + }, + "init": { + "type": "Identifier", + "start": 53, + "end": 56, + "loc": { + "start": { + "line": 2, + "column": 31 + }, + "end": { + "line": 2, + "column": 34 + }, + "identifierName": "baz" + }, + "name": "baz" + } + } + ], + "kind": "const" + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2018/object-rest-spread/12/options.json b/packages/babel-parser/test/fixtures/es2018/object-rest-spread/12/options.json index 165223a448a3..54925950e059 100644 --- a/packages/babel-parser/test/fixtures/es2018/object-rest-spread/12/options.json +++ b/packages/babel-parser/test/fixtures/es2018/object-rest-spread/12/options.json @@ -1,4 +1,3 @@ { - "sourceType": "module", - "throws": "Identifier 'bar' has already been declared (2:13)" -} + "sourceType": "module" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2018/object-rest-spread/12/output.json b/packages/babel-parser/test/fixtures/es2018/object-rest-spread/12/output.json new file mode 100644 index 000000000000..dd11a6812a7b --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2018/object-rest-spread/12/output.json @@ -0,0 +1,297 @@ +{ + "type": "File", + "start": 0, + "end": 57, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 21 + } + }, + "errors": [ + "SyntaxError: Identifier 'bar' has already been declared (2:13)", + "SyntaxError: `bar` has already been exported. Exported identifiers must be unique. (2:13)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 57, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 21 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExportNamedDeclaration", + "start": 0, + "end": 35, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 35 + } + }, + "specifiers": [], + "source": null, + "declaration": { + "type": "VariableDeclaration", + "start": 7, + "end": 35, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 35 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 13, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 34 + } + }, + "id": { + "type": "ObjectPattern", + "start": 13, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 28 + } + }, + "properties": [ + { + "type": "ObjectProperty", + "start": 15, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "method": false, + "key": { + "type": "Identifier", + "start": 15, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 18 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "computed": false, + "shorthand": true, + "value": { + "type": "Identifier", + "start": 15, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 18 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "extra": { + "shorthand": true + } + }, + { + "type": "RestElement", + "start": 20, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 20 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "argument": { + "type": "Identifier", + "start": 23, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 23 + }, + "end": { + "line": 1, + "column": 26 + }, + "identifierName": "bar" + }, + "name": "bar" + } + } + ] + }, + "init": { + "type": "Identifier", + "start": 31, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 31 + }, + "end": { + "line": 1, + "column": 34 + }, + "identifierName": "baz" + }, + "name": "baz" + } + } + ], + "kind": "const" + } + }, + { + "type": "ExportNamedDeclaration", + "start": 36, + "end": 57, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 21 + } + }, + "specifiers": [], + "source": null, + "declaration": { + "type": "VariableDeclaration", + "start": 43, + "end": 57, + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 2, + "column": 21 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 49, + "end": 56, + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 20 + } + }, + "id": { + "type": "Identifier", + "start": 49, + "end": 52, + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 16 + }, + "identifierName": "bar" + }, + "name": "bar" + }, + "init": { + "type": "NumericLiteral", + "start": 55, + "end": 56, + "loc": { + "start": { + "line": 2, + "column": 19 + }, + "end": { + "line": 2, + "column": 20 + } + }, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + } + } + ], + "kind": "const" + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2018/object-rest-spread/13/options.json b/packages/babel-parser/test/fixtures/es2018/object-rest-spread/13/options.json index 68df28e41c41..54925950e059 100644 --- a/packages/babel-parser/test/fixtures/es2018/object-rest-spread/13/options.json +++ b/packages/babel-parser/test/fixtures/es2018/object-rest-spread/13/options.json @@ -1,4 +1,3 @@ { - "sourceType": "module", - "throws": "Identifier 'foo' has already been declared (2:30)" -} + "sourceType": "module" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2018/object-rest-spread/13/output.json b/packages/babel-parser/test/fixtures/es2018/object-rest-spread/13/output.json new file mode 100644 index 000000000000..a591bf90155e --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2018/object-rest-spread/13/output.json @@ -0,0 +1,349 @@ +{ + "type": "File", + "start": 0, + "end": 66, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 44 + } + }, + "errors": [ + "SyntaxError: Identifier 'foo' has already been declared (2:30)", + "SyntaxError: `foo` has already been exported. Exported identifiers must be unique. (2:30)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 66, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 44 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExportNamedDeclaration", + "start": 0, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "specifiers": [], + "source": null, + "declaration": { + "type": "VariableDeclaration", + "start": 7, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 13, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "id": { + "type": "Identifier", + "start": 13, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 16 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "init": { + "type": "NumericLiteral", + "start": 19, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + } + } + ], + "kind": "const" + } + }, + { + "type": "ExportNamedDeclaration", + "start": 22, + "end": 66, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 44 + } + }, + "specifiers": [], + "source": null, + "declaration": { + "type": "VariableDeclaration", + "start": 29, + "end": 66, + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 2, + "column": 44 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 35, + "end": 65, + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 43 + } + }, + "id": { + "type": "ObjectPattern", + "start": 35, + "end": 59, + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 37 + } + }, + "properties": [ + { + "type": "ObjectProperty", + "start": 37, + "end": 57, + "loc": { + "start": { + "line": 2, + "column": 15 + }, + "end": { + "line": 2, + "column": 35 + } + }, + "method": false, + "key": { + "type": "Identifier", + "start": 37, + "end": 40, + "loc": { + "start": { + "line": 2, + "column": 15 + }, + "end": { + "line": 2, + "column": 18 + }, + "identifierName": "bar" + }, + "name": "bar" + }, + "computed": false, + "shorthand": false, + "value": { + "type": "ObjectPattern", + "start": 42, + "end": 57, + "loc": { + "start": { + "line": 2, + "column": 20 + }, + "end": { + "line": 2, + "column": 35 + } + }, + "properties": [ + { + "type": "ObjectProperty", + "start": 44, + "end": 47, + "loc": { + "start": { + "line": 2, + "column": 22 + }, + "end": { + "line": 2, + "column": 25 + } + }, + "method": false, + "key": { + "type": "Identifier", + "start": 44, + "end": 47, + "loc": { + "start": { + "line": 2, + "column": 22 + }, + "end": { + "line": 2, + "column": 25 + }, + "identifierName": "baz" + }, + "name": "baz" + }, + "computed": false, + "shorthand": true, + "value": { + "type": "Identifier", + "start": 44, + "end": 47, + "loc": { + "start": { + "line": 2, + "column": 22 + }, + "end": { + "line": 2, + "column": 25 + }, + "identifierName": "baz" + }, + "name": "baz" + }, + "extra": { + "shorthand": true + } + }, + { + "type": "RestElement", + "start": 49, + "end": 55, + "loc": { + "start": { + "line": 2, + "column": 27 + }, + "end": { + "line": 2, + "column": 33 + } + }, + "argument": { + "type": "Identifier", + "start": 52, + "end": 55, + "loc": { + "start": { + "line": 2, + "column": 30 + }, + "end": { + "line": 2, + "column": 33 + }, + "identifierName": "foo" + }, + "name": "foo" + } + } + ] + } + } + ] + }, + "init": { + "type": "Identifier", + "start": 62, + "end": 65, + "loc": { + "start": { + "line": 2, + "column": 40 + }, + "end": { + "line": 2, + "column": 43 + }, + "identifierName": "qux" + }, + "name": "qux" + } + } + ], + "kind": "const" + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2018/object-rest-spread/14/options.json b/packages/babel-parser/test/fixtures/es2018/object-rest-spread/14/options.json index 280073b140f0..54925950e059 100644 --- a/packages/babel-parser/test/fixtures/es2018/object-rest-spread/14/options.json +++ b/packages/babel-parser/test/fixtures/es2018/object-rest-spread/14/options.json @@ -1,4 +1,3 @@ { - "sourceType": "module", - "throws": "Identifier 'foo' has already been declared (2:29)" -} + "sourceType": "module" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2018/object-rest-spread/14/output.json b/packages/babel-parser/test/fixtures/es2018/object-rest-spread/14/output.json new file mode 100644 index 000000000000..d092e82a47c3 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2018/object-rest-spread/14/output.json @@ -0,0 +1,331 @@ +{ + "type": "File", + "start": 0, + "end": 64, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 42 + } + }, + "errors": [ + "SyntaxError: Identifier 'foo' has already been declared (2:29)", + "SyntaxError: `foo` has already been exported. Exported identifiers must be unique. (2:29)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 64, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 42 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExportNamedDeclaration", + "start": 0, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "specifiers": [], + "source": null, + "declaration": { + "type": "VariableDeclaration", + "start": 7, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 13, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "id": { + "type": "Identifier", + "start": 13, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 16 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "init": { + "type": "NumericLiteral", + "start": 19, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + } + } + ], + "kind": "const" + } + }, + { + "type": "ExportNamedDeclaration", + "start": 22, + "end": 64, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 42 + } + }, + "specifiers": [], + "source": null, + "declaration": { + "type": "VariableDeclaration", + "start": 29, + "end": 64, + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 2, + "column": 42 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 35, + "end": 63, + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 41 + } + }, + "id": { + "type": "ArrayPattern", + "start": 35, + "end": 57, + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 35 + } + }, + "elements": [ + { + "type": "Identifier", + "start": 36, + "end": 39, + "loc": { + "start": { + "line": 2, + "column": 14 + }, + "end": { + "line": 2, + "column": 17 + }, + "identifierName": "bar" + }, + "name": "bar" + }, + { + "type": "ObjectPattern", + "start": 41, + "end": 56, + "loc": { + "start": { + "line": 2, + "column": 19 + }, + "end": { + "line": 2, + "column": 34 + } + }, + "properties": [ + { + "type": "ObjectProperty", + "start": 43, + "end": 46, + "loc": { + "start": { + "line": 2, + "column": 21 + }, + "end": { + "line": 2, + "column": 24 + } + }, + "method": false, + "key": { + "type": "Identifier", + "start": 43, + "end": 46, + "loc": { + "start": { + "line": 2, + "column": 21 + }, + "end": { + "line": 2, + "column": 24 + }, + "identifierName": "baz" + }, + "name": "baz" + }, + "computed": false, + "shorthand": true, + "value": { + "type": "Identifier", + "start": 43, + "end": 46, + "loc": { + "start": { + "line": 2, + "column": 21 + }, + "end": { + "line": 2, + "column": 24 + }, + "identifierName": "baz" + }, + "name": "baz" + }, + "extra": { + "shorthand": true + } + }, + { + "type": "RestElement", + "start": 48, + "end": 54, + "loc": { + "start": { + "line": 2, + "column": 26 + }, + "end": { + "line": 2, + "column": 32 + } + }, + "argument": { + "type": "Identifier", + "start": 51, + "end": 54, + "loc": { + "start": { + "line": 2, + "column": 29 + }, + "end": { + "line": 2, + "column": 32 + }, + "identifierName": "foo" + }, + "name": "foo" + } + } + ] + } + ] + }, + "init": { + "type": "Identifier", + "start": 60, + "end": 63, + "loc": { + "start": { + "line": 2, + "column": 38 + }, + "end": { + "line": 2, + "column": 41 + }, + "identifierName": "qux" + }, + "name": "qux" + } + } + ], + "kind": "const" + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2018/object-rest-spread/15/options.json b/packages/babel-parser/test/fixtures/es2018/object-rest-spread/15/options.json index 68df28e41c41..54925950e059 100644 --- a/packages/babel-parser/test/fixtures/es2018/object-rest-spread/15/options.json +++ b/packages/babel-parser/test/fixtures/es2018/object-rest-spread/15/options.json @@ -1,4 +1,3 @@ { - "sourceType": "module", - "throws": "Identifier 'foo' has already been declared (2:30)" -} + "sourceType": "module" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2018/object-rest-spread/15/output.json b/packages/babel-parser/test/fixtures/es2018/object-rest-spread/15/output.json new file mode 100644 index 000000000000..a35595b31013 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2018/object-rest-spread/15/output.json @@ -0,0 +1,348 @@ +{ + "type": "File", + "start": 0, + "end": 66, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 44 + } + }, + "errors": [ + "SyntaxError: Identifier 'foo' has already been declared (2:30)", + "SyntaxError: `foo` has already been exported. Exported identifiers must be unique. (2:30)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 66, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 44 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExportNamedDeclaration", + "start": 0, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "specifiers": [], + "source": null, + "declaration": { + "type": "VariableDeclaration", + "start": 7, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 13, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "id": { + "type": "Identifier", + "start": 13, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 16 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "init": { + "type": "NumericLiteral", + "start": 19, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + } + } + ], + "kind": "const" + } + }, + { + "type": "ExportNamedDeclaration", + "start": 22, + "end": 66, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 44 + } + }, + "specifiers": [], + "source": null, + "declaration": { + "type": "VariableDeclaration", + "start": 29, + "end": 66, + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 2, + "column": 44 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 35, + "end": 65, + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 43 + } + }, + "id": { + "type": "ArrayPattern", + "start": 35, + "end": 59, + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 37 + } + }, + "elements": [ + { + "type": "Identifier", + "start": 36, + "end": 39, + "loc": { + "start": { + "line": 2, + "column": 14 + }, + "end": { + "line": 2, + "column": 17 + }, + "identifierName": "bar" + }, + "name": "bar" + }, + { + "type": "ArrayPattern", + "start": 41, + "end": 58, + "loc": { + "start": { + "line": 2, + "column": 19 + }, + "end": { + "line": 2, + "column": 36 + } + }, + "elements": [ + { + "type": "ObjectPattern", + "start": 42, + "end": 57, + "loc": { + "start": { + "line": 2, + "column": 20 + }, + "end": { + "line": 2, + "column": 35 + } + }, + "properties": [ + { + "type": "ObjectProperty", + "start": 44, + "end": 47, + "loc": { + "start": { + "line": 2, + "column": 22 + }, + "end": { + "line": 2, + "column": 25 + } + }, + "method": false, + "key": { + "type": "Identifier", + "start": 44, + "end": 47, + "loc": { + "start": { + "line": 2, + "column": 22 + }, + "end": { + "line": 2, + "column": 25 + }, + "identifierName": "baz" + }, + "name": "baz" + }, + "computed": false, + "shorthand": true, + "value": { + "type": "Identifier", + "start": 44, + "end": 47, + "loc": { + "start": { + "line": 2, + "column": 22 + }, + "end": { + "line": 2, + "column": 25 + }, + "identifierName": "baz" + }, + "name": "baz" + }, + "extra": { + "shorthand": true + } + }, + { + "type": "RestElement", + "start": 49, + "end": 55, + "loc": { + "start": { + "line": 2, + "column": 27 + }, + "end": { + "line": 2, + "column": 33 + } + }, + "argument": { + "type": "Identifier", + "start": 52, + "end": 55, + "loc": { + "start": { + "line": 2, + "column": 30 + }, + "end": { + "line": 2, + "column": 33 + }, + "identifierName": "foo" + }, + "name": "foo" + } + } + ] + } + ] + } + ] + }, + "init": { + "type": "Identifier", + "start": 62, + "end": 65, + "loc": { + "start": { + "line": 2, + "column": 40 + }, + "end": { + "line": 2, + "column": 43 + }, + "identifierName": "qux" + }, + "name": "qux" + } + } + ], + "kind": "const" + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2018/object-rest-spread/18/options.json b/packages/babel-parser/test/fixtures/es2018/object-rest-spread/18/options.json deleted file mode 100644 index b447c590ab2c..000000000000 --- a/packages/babel-parser/test/fixtures/es2018/object-rest-spread/18/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid rest operator's argument (1:5)" -} diff --git a/packages/babel-parser/test/fixtures/es2018/object-rest-spread/18/output.json b/packages/babel-parser/test/fixtures/es2018/object-rest-spread/18/output.json new file mode 100644 index 000000000000..9a9ef9274914 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2018/object-rest-spread/18/output.json @@ -0,0 +1,137 @@ +{ + "type": "File", + "start": 0, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "errors": [ + "SyntaxError: Invalid rest operator's argument (1:5)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "expression": { + "type": "AssignmentExpression", + "start": 1, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "operator": "=", + "left": { + "type": "ObjectPattern", + "start": 1, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "properties": [ + { + "type": "RestElement", + "start": 2, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 2 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "argument": { + "type": "ObjectPattern", + "start": 5, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "properties": [] + } + } + ] + }, + "right": { + "type": "ObjectExpression", + "start": 11, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "properties": [] + }, + "extra": { + "parenthesized": true, + "parenStart": 0 + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2018/object-rest-spread/21/options.json b/packages/babel-parser/test/fixtures/es2018/object-rest-spread/21/options.json deleted file mode 100644 index b447c590ab2c..000000000000 --- a/packages/babel-parser/test/fixtures/es2018/object-rest-spread/21/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid rest operator's argument (1:5)" -} diff --git a/packages/babel-parser/test/fixtures/es2018/object-rest-spread/21/output.json b/packages/babel-parser/test/fixtures/es2018/object-rest-spread/21/output.json new file mode 100644 index 000000000000..09b6d303c4ac --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2018/object-rest-spread/21/output.json @@ -0,0 +1,173 @@ +{ + "type": "File", + "start": 0, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "errors": [ + "SyntaxError: Invalid rest operator's argument (1:5)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "expression": { + "type": "AssignmentExpression", + "start": 1, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "operator": "=", + "left": { + "type": "ObjectPattern", + "start": 1, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "properties": [ + { + "type": "RestElement", + "start": 2, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 2 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "argument": { + "type": "AssignmentPattern", + "start": 5, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "left": { + "type": "Identifier", + "start": 5, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 6 + }, + "identifierName": "x" + }, + "name": "x" + }, + "right": { + "type": "NumericLiteral", + "start": 9, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + } + } + } + ] + }, + "right": { + "type": "ObjectExpression", + "start": 14, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "properties": [] + }, + "extra": { + "parenthesized": true, + "parenStart": 0 + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2018/object-rest-spread/24/options.json b/packages/babel-parser/test/fixtures/es2018/object-rest-spread/24/options.json deleted file mode 100644 index b447c590ab2c..000000000000 --- a/packages/babel-parser/test/fixtures/es2018/object-rest-spread/24/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid rest operator's argument (1:5)" -} diff --git a/packages/babel-parser/test/fixtures/es2018/object-rest-spread/24/output.json b/packages/babel-parser/test/fixtures/es2018/object-rest-spread/24/output.json new file mode 100644 index 000000000000..2f80e2925775 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2018/object-rest-spread/24/output.json @@ -0,0 +1,137 @@ +{ + "type": "File", + "start": 0, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "errors": [ + "SyntaxError: Invalid rest operator's argument (1:5)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "expression": { + "type": "AssignmentExpression", + "start": 1, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "operator": "=", + "left": { + "type": "ObjectPattern", + "start": 1, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "properties": [ + { + "type": "RestElement", + "start": 2, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 2 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "argument": { + "type": "ArrayPattern", + "start": 5, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "elements": [] + } + } + ] + }, + "right": { + "type": "ObjectExpression", + "start": 11, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "properties": [] + }, + "extra": { + "parenthesized": true, + "parenStart": 0 + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2018/object-rest-spread/8/options.json b/packages/babel-parser/test/fixtures/es2018/object-rest-spread/8/options.json deleted file mode 100644 index c44d69275adb..000000000000 --- a/packages/babel-parser/test/fixtures/es2018/object-rest-spread/8/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Unexpected trailing comma after rest element (1:16)" -} diff --git a/packages/babel-parser/test/fixtures/es2018/object-rest-spread/8/output.json b/packages/babel-parser/test/fixtures/es2018/object-rest-spread/8/output.json new file mode 100644 index 000000000000..c7ff07e0d0df --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2018/object-rest-spread/8/output.json @@ -0,0 +1,250 @@ +{ + "type": "File", + "start": 0, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "errors": [ + "SyntaxError: Unexpected trailing comma after rest element (1:16)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "VariableDeclaration", + "start": 0, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 4, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 25 + } + }, + "id": { + "type": "ObjectPattern", + "start": 4, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "properties": [ + { + "type": "ObjectProperty", + "start": 6, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "method": false, + "key": { + "type": "Identifier", + "start": 6, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + }, + "identifierName": "x" + }, + "name": "x" + }, + "computed": false, + "shorthand": true, + "value": { + "type": "Identifier", + "start": 6, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + }, + "identifierName": "x" + }, + "name": "x" + }, + "extra": { + "shorthand": true + } + }, + { + "type": "ObjectProperty", + "start": 9, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "method": false, + "key": { + "type": "Identifier", + "start": 9, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 10 + }, + "identifierName": "y" + }, + "name": "y" + }, + "computed": false, + "shorthand": true, + "value": { + "type": "Identifier", + "start": 9, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 10 + }, + "identifierName": "y" + }, + "name": "y" + }, + "extra": { + "shorthand": true + } + }, + { + "type": "RestElement", + "start": 12, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "argument": { + "type": "Identifier", + "start": 15, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 16 + }, + "identifierName": "z" + }, + "name": "z" + } + } + ], + "extra": { + "trailingComma": 16 + } + }, + "init": { + "type": "Identifier", + "start": 22, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 22 + }, + "end": { + "line": 1, + "column": 25 + }, + "identifierName": "obj" + }, + "name": "obj" + } + } + ], + "kind": "let" + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/export-extensions/ns-and-named/input.js b/packages/babel-parser/test/fixtures/es2020/export-ns-from/ns-and-named/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/export-extensions/ns-and-named/input.js rename to packages/babel-parser/test/fixtures/es2020/export-ns-from/ns-and-named/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/export-extensions/ns-and-named/output.json b/packages/babel-parser/test/fixtures/es2020/export-ns-from/ns-and-named/output.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/export-extensions/ns-and-named/output.json rename to packages/babel-parser/test/fixtures/es2020/export-ns-from/ns-and-named/output.json diff --git a/packages/babel-parser/test/fixtures/experimental/export-extensions/ns-default/input.js b/packages/babel-parser/test/fixtures/es2020/export-ns-from/ns-default/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/export-extensions/ns-default/input.js rename to packages/babel-parser/test/fixtures/es2020/export-ns-from/ns-default/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/export-extensions/ns-default/output.json b/packages/babel-parser/test/fixtures/es2020/export-ns-from/ns-default/output.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/export-extensions/ns-default/output.json rename to packages/babel-parser/test/fixtures/es2020/export-ns-from/ns-default/output.json diff --git a/packages/babel-parser/test/fixtures/experimental/_no-plugin/export-namespace/input.js b/packages/babel-parser/test/fixtures/es2020/export-ns-from/ns/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/_no-plugin/export-namespace/input.js rename to packages/babel-parser/test/fixtures/es2020/export-ns-from/ns/input.js diff --git a/packages/babel-parser/test/fixtures/experimental/export-extensions/ns/output.json b/packages/babel-parser/test/fixtures/es2020/export-ns-from/ns/output.json similarity index 100% rename from packages/babel-parser/test/fixtures/experimental/export-extensions/ns/output.json rename to packages/babel-parser/test/fixtures/es2020/export-ns-from/ns/output.json diff --git a/packages/babel-parser/test/fixtures/es2020/export-ns-from/options.json b/packages/babel-parser/test/fixtures/es2020/export-ns-from/options.json new file mode 100644 index 000000000000..2104ca43283f --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2020/export-ns-from/options.json @@ -0,0 +1,3 @@ +{ + "sourceType": "module" +} diff --git a/packages/babel-parser/test/fixtures/esprima/declaration-function/dupe-param/options.json b/packages/babel-parser/test/fixtures/esprima/declaration-function/dupe-param/options.json deleted file mode 100644 index 8b20b9a7df36..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/declaration-function/dupe-param/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Argument name clash (1:14)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/declaration-function/dupe-param/output.json b/packages/babel-parser/test/fixtures/esprima/declaration-function/dupe-param/output.json new file mode 100644 index 000000000000..aa4301697cf8 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/declaration-function/dupe-param/output.json @@ -0,0 +1,161 @@ +{ + "type": "File", + "start": 0, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "errors": [ + "SyntaxError: Argument name clash (1:14)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 10 + }, + "identifierName": "a" + }, + "name": "a" + }, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "start": 11, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 12 + }, + "identifierName": "x" + }, + "name": "x" + }, + { + "type": "Identifier", + "start": 14, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 15 + }, + "identifierName": "x" + }, + "name": "x" + } + ], + "body": { + "type": "BlockStatement", + "start": 17, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "body": [], + "directives": [ + { + "type": "Directive", + "start": 18, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 18, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "value": "use strict", + "extra": { + "raw": "'use strict'", + "rawValue": "use strict" + } + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-array-binding-pattern/invalid-dup-param/options.json b/packages/babel-parser/test/fixtures/esprima/es2015-array-binding-pattern/invalid-dup-param/options.json deleted file mode 100644 index a4a6e207d28c..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/es2015-array-binding-pattern/invalid-dup-param/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Argument name clash (1:11)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-array-binding-pattern/invalid-dup-param/output.json b/packages/babel-parser/test/fixtures/esprima/es2015-array-binding-pattern/invalid-dup-param/output.json new file mode 100644 index 000000000000..09552b591b3f --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/es2015-array-binding-pattern/invalid-dup-param/output.json @@ -0,0 +1,193 @@ +{ + "type": "File", + "start": 0, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "errors": [ + "SyntaxError: Argument name clash (1:11)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "expression": { + "type": "ArrowFunctionExpression", + "start": 0, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "id": null, + "generator": false, + "async": false, + "params": [ + { + "type": "ArrayPattern", + "start": 1, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "elements": [ + { + "type": "Identifier", + "start": 2, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 2 + }, + "end": { + "line": 1, + "column": 3 + }, + "identifierName": "a" + }, + "name": "a" + }, + { + "type": "ArrayPattern", + "start": 4, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "elements": [ + { + "type": "Identifier", + "start": 5, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 6 + }, + "identifierName": "b" + }, + "name": "b" + } + ] + }, + { + "type": "RestElement", + "start": 8, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "argument": { + "type": "Identifier", + "start": 11, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 12 + }, + "identifierName": "b" + }, + "name": "b" + } + } + ] + } + ], + "body": { + "type": "NumericLiteral", + "start": 16, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-array-pattern/dupe-param-1/options.json b/packages/babel-parser/test/fixtures/esprima/es2015-array-pattern/dupe-param-1/options.json deleted file mode 100644 index 49e8d8e86314..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/es2015-array-pattern/dupe-param-1/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Argument name clash (2:14)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-array-pattern/dupe-param-1/output.json b/packages/babel-parser/test/fixtures/esprima/es2015-array-pattern/dupe-param-1/output.json new file mode 100644 index 000000000000..57442d5cb4fd --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/es2015-array-pattern/dupe-param-1/output.json @@ -0,0 +1,178 @@ +{ + "type": "File", + "start": 0, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 20 + } + }, + "errors": [ + "SyntaxError: Argument name clash (2:14)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 20 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 14, + "end": 34, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 20 + } + }, + "id": { + "type": "Identifier", + "start": 23, + "end": 24, + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 10 + }, + "identifierName": "a" + }, + "name": "a" + }, + "generator": false, + "async": false, + "params": [ + { + "type": "ArrayPattern", + "start": 25, + "end": 30, + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 16 + } + }, + "elements": [ + { + "type": "Identifier", + "start": 26, + "end": 27, + "loc": { + "start": { + "line": 2, + "column": 12 + }, + "end": { + "line": 2, + "column": 13 + }, + "identifierName": "a" + }, + "name": "a" + }, + { + "type": "Identifier", + "start": 28, + "end": 29, + "loc": { + "start": { + "line": 2, + "column": 14 + }, + "end": { + "line": 2, + "column": 15 + }, + "identifierName": "a" + }, + "name": "a" + } + ] + } + ], + "body": { + "type": "BlockStatement", + "start": 31, + "end": 34, + "loc": { + "start": { + "line": 2, + "column": 17 + }, + "end": { + "line": 2, + "column": 20 + } + }, + "body": [], + "directives": [] + } + } + ], + "directives": [ + { + "type": "Directive", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 0, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "value": "use strict", + "extra": { + "raw": "\"use strict\"", + "rawValue": "use strict" + } + } + } + ] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-array-pattern/dupe-param-2/options.json b/packages/babel-parser/test/fixtures/esprima/es2015-array-pattern/dupe-param-2/options.json deleted file mode 100644 index 3829082a4878..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/es2015-array-pattern/dupe-param-2/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Argument name clash (2:17)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-array-pattern/dupe-param-2/output.json b/packages/babel-parser/test/fixtures/esprima/es2015-array-pattern/dupe-param-2/output.json new file mode 100644 index 000000000000..4242da8e09f7 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/es2015-array-pattern/dupe-param-2/output.json @@ -0,0 +1,193 @@ +{ + "type": "File", + "start": 0, + "end": 37, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 23 + } + }, + "errors": [ + "SyntaxError: Argument name clash (2:17)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 37, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 23 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 14, + "end": 37, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 23 + } + }, + "id": { + "type": "Identifier", + "start": 23, + "end": 24, + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 10 + }, + "identifierName": "a" + }, + "name": "a" + }, + "generator": false, + "async": false, + "params": [ + { + "type": "ArrayPattern", + "start": 25, + "end": 33, + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 19 + } + }, + "elements": [ + { + "type": "Identifier", + "start": 26, + "end": 27, + "loc": { + "start": { + "line": 2, + "column": 12 + }, + "end": { + "line": 2, + "column": 13 + }, + "identifierName": "a" + }, + "name": "a" + }, + { + "type": "RestElement", + "start": 28, + "end": 32, + "loc": { + "start": { + "line": 2, + "column": 14 + }, + "end": { + "line": 2, + "column": 18 + } + }, + "argument": { + "type": "Identifier", + "start": 31, + "end": 32, + "loc": { + "start": { + "line": 2, + "column": 17 + }, + "end": { + "line": 2, + "column": 18 + }, + "identifierName": "a" + }, + "name": "a" + } + } + ] + } + ], + "body": { + "type": "BlockStatement", + "start": 34, + "end": 37, + "loc": { + "start": { + "line": 2, + "column": 20 + }, + "end": { + "line": 2, + "column": 23 + } + }, + "body": [], + "directives": [] + } + } + ], + "directives": [ + { + "type": "Directive", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 0, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "value": "use strict", + "extra": { + "raw": "\"use strict\"", + "rawValue": "use strict" + } + } + } + ] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-array-pattern/dupe-param-3/options.json b/packages/babel-parser/test/fixtures/esprima/es2015-array-pattern/dupe-param-3/options.json deleted file mode 100644 index 782073313a19..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/es2015-array-pattern/dupe-param-3/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Argument name clash (2:19)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-array-pattern/dupe-param-3/output.json b/packages/babel-parser/test/fixtures/esprima/es2015-array-pattern/dupe-param-3/output.json new file mode 100644 index 000000000000..00b0c28f58c6 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/es2015-array-pattern/dupe-param-3/output.json @@ -0,0 +1,248 @@ +{ + "type": "File", + "start": 0, + "end": 39, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 25 + } + }, + "errors": [ + "SyntaxError: Argument name clash (2:19)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 39, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 25 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 14, + "end": 39, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 25 + } + }, + "id": { + "type": "Identifier", + "start": 23, + "end": 24, + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 10 + }, + "identifierName": "a" + }, + "name": "a" + }, + "generator": false, + "async": false, + "params": [ + { + "type": "ArrayPattern", + "start": 25, + "end": 35, + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 21 + } + }, + "elements": [ + { + "type": "ObjectPattern", + "start": 26, + "end": 29, + "loc": { + "start": { + "line": 2, + "column": 12 + }, + "end": { + "line": 2, + "column": 15 + } + }, + "properties": [ + { + "type": "ObjectProperty", + "start": 27, + "end": 28, + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 14 + } + }, + "method": false, + "key": { + "type": "Identifier", + "start": 27, + "end": 28, + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 14 + }, + "identifierName": "a" + }, + "name": "a" + }, + "computed": false, + "shorthand": true, + "value": { + "type": "Identifier", + "start": 27, + "end": 28, + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 14 + }, + "identifierName": "a" + }, + "name": "a" + }, + "extra": { + "shorthand": true + } + } + ] + }, + { + "type": "RestElement", + "start": 30, + "end": 34, + "loc": { + "start": { + "line": 2, + "column": 16 + }, + "end": { + "line": 2, + "column": 20 + } + }, + "argument": { + "type": "Identifier", + "start": 33, + "end": 34, + "loc": { + "start": { + "line": 2, + "column": 19 + }, + "end": { + "line": 2, + "column": 20 + }, + "identifierName": "a" + }, + "name": "a" + } + } + ] + } + ], + "body": { + "type": "BlockStatement", + "start": 36, + "end": 39, + "loc": { + "start": { + "line": 2, + "column": 22 + }, + "end": { + "line": 2, + "column": 25 + } + }, + "body": [], + "directives": [] + } + } + ], + "directives": [ + { + "type": "Directive", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 0, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "value": "use strict", + "extra": { + "raw": "\"use strict\"", + "rawValue": "use strict" + } + } + } + ] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-arrow-function/complex-rest-in-arrow-not-allowed/options.json b/packages/babel-parser/test/fixtures/esprima/es2015-arrow-function/complex-rest-in-arrow-not-allowed/options.json deleted file mode 100644 index fd74c5228531..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/es2015-arrow-function/complex-rest-in-arrow-not-allowed/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Argument name clash (1:7)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-arrow-function/complex-rest-in-arrow-not-allowed/output.json b/packages/babel-parser/test/fixtures/esprima/es2015-arrow-function/complex-rest-in-arrow-not-allowed/output.json new file mode 100644 index 000000000000..34fec649661b --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/es2015-arrow-function/complex-rest-in-arrow-not-allowed/output.json @@ -0,0 +1,159 @@ +{ + "type": "File", + "start": 0, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "errors": [ + "SyntaxError: Argument name clash (1:7)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "expression": { + "type": "ArrowFunctionExpression", + "start": 0, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "id": null, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "start": 1, + "end": 2, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 2 + }, + "identifierName": "a" + }, + "name": "a" + }, + { + "type": "RestElement", + "start": 3, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "argument": { + "type": "ArrayPattern", + "start": 6, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "elements": [ + { + "type": "Identifier", + "start": 7, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 8 + }, + "identifierName": "a" + }, + "name": "a" + } + ] + } + } + ], + "body": { + "type": "NumericLiteral", + "start": 14, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-arrow-function/invalid-duplicated-params/options.json b/packages/babel-parser/test/fixtures/esprima/es2015-arrow-function/invalid-duplicated-params/options.json deleted file mode 100644 index 368006ae58bd..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/es2015-arrow-function/invalid-duplicated-params/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Argument name clash (1:4)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-arrow-function/invalid-duplicated-params/output.json b/packages/babel-parser/test/fixtures/esprima/es2015-arrow-function/invalid-duplicated-params/output.json new file mode 100644 index 000000000000..5456b40fe86d --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/es2015-arrow-function/invalid-duplicated-params/output.json @@ -0,0 +1,124 @@ +{ + "type": "File", + "start": 0, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "errors": [ + "SyntaxError: Argument name clash (1:4)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "expression": { + "type": "ArrowFunctionExpression", + "start": 0, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "id": null, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "start": 1, + "end": 2, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 2 + }, + "identifierName": "x" + }, + "name": "x" + }, + { + "type": "Identifier", + "start": 4, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 5 + }, + "identifierName": "x" + }, + "name": "x" + } + ], + "body": { + "type": "Identifier", + "start": 10, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 11 + }, + "identifierName": "y" + }, + "name": "y" + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-arrow-function/invalid-param-strict-mode/options.json b/packages/babel-parser/test/fixtures/esprima/es2015-arrow-function/invalid-param-strict-mode/options.json deleted file mode 100644 index 8f5ca9d5da67..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/es2015-arrow-function/invalid-param-strict-mode/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Binding 'eval' in strict mode (1:0)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-arrow-function/invalid-param-strict-mode/output.json b/packages/babel-parser/test/fixtures/esprima/es2015-arrow-function/invalid-param-strict-mode/output.json new file mode 100644 index 000000000000..1daa964b52b1 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/es2015-arrow-function/invalid-param-strict-mode/output.json @@ -0,0 +1,143 @@ +{ + "type": "File", + "start": 0, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "errors": [ + "SyntaxError: Binding 'eval' in strict mode (1:0)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "expression": { + "type": "ArrowFunctionExpression", + "start": 0, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "id": null, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "start": 0, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 4 + }, + "identifierName": "eval" + }, + "name": "eval" + } + ], + "body": { + "type": "BlockStatement", + "start": 8, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "body": [], + "directives": [ + { + "type": "Directive", + "start": 9, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 9, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "value": "use strict", + "extra": { + "raw": "\"use strict\"", + "rawValue": "use strict" + } + } + } + ] + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-arrow-function/object-binding-pattern-invalid-member-expr/options.json b/packages/babel-parser/test/fixtures/esprima/es2015-arrow-function/object-binding-pattern-invalid-member-expr/options.json deleted file mode 100644 index bf0f292caad2..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/es2015-arrow-function/object-binding-pattern-invalid-member-expr/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid left-hand side in object destructuring pattern (1:4)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-arrow-function/object-binding-pattern-invalid-member-expr/output.json b/packages/babel-parser/test/fixtures/esprima/es2015-arrow-function/object-binding-pattern-invalid-member-expr/output.json new file mode 100644 index 000000000000..9e8858777646 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/es2015-arrow-function/object-binding-pattern-invalid-member-expr/output.json @@ -0,0 +1,198 @@ +{ + "type": "File", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "errors": [ + "SyntaxError: Binding member expression (1:4)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "expression": { + "type": "ArrowFunctionExpression", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "id": null, + "generator": false, + "async": false, + "params": [ + { + "type": "ObjectPattern", + "start": 1, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "properties": [ + { + "type": "ObjectProperty", + "start": 2, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 2 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "method": false, + "key": { + "type": "Identifier", + "start": 2, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 2 + }, + "end": { + "line": 1, + "column": 3 + }, + "identifierName": "a" + }, + "name": "a" + }, + "computed": false, + "shorthand": false, + "value": { + "type": "MemberExpression", + "start": 4, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "object": { + "type": "Identifier", + "start": 4, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 5 + }, + "identifierName": "b" + }, + "name": "b" + }, + "property": { + "type": "NumericLiteral", + "start": 6, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + }, + "computed": true + } + } + ] + } + ], + "body": { + "type": "NumericLiteral", + "start": 12, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-arrow-function/object-binding-pattern-invalid-method-in-pattern/options.json b/packages/babel-parser/test/fixtures/esprima/es2015-arrow-function/object-binding-pattern-invalid-method-in-pattern/options.json deleted file mode 100644 index 559cc4e11a41..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/es2015-arrow-function/object-binding-pattern-invalid-method-in-pattern/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Object pattern can't contain getter or setter (1:6)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-arrow-function/object-binding-pattern-invalid-method-in-pattern/output.json b/packages/babel-parser/test/fixtures/esprima/es2015-arrow-function/object-binding-pattern-invalid-method-in-pattern/output.json new file mode 100644 index 000000000000..d391e09c2dfe --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/es2015-arrow-function/object-binding-pattern-invalid-method-in-pattern/output.json @@ -0,0 +1,166 @@ +{ + "type": "File", + "start": 0, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "errors": [ + "SyntaxError: Object pattern can't contain getter or setter (1:6)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "expression": { + "type": "ArrowFunctionExpression", + "start": 0, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "id": null, + "generator": false, + "async": false, + "params": [ + { + "type": "ObjectPattern", + "start": 1, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "properties": [ + { + "type": "ObjectMethod", + "start": 2, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 2 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "method": false, + "key": { + "type": "Identifier", + "start": 6, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + }, + "identifierName": "a" + }, + "name": "a" + }, + "computed": false, + "kind": "get", + "id": null, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 9, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "body": [], + "directives": [] + } + } + ] + } + ], + "body": { + "type": "NumericLiteral", + "start": 17, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-arrow-function/object-binding-pattern-invalid-nested-param/options.json b/packages/babel-parser/test/fixtures/esprima/es2015-arrow-function/object-binding-pattern-invalid-nested-param/options.json deleted file mode 100644 index 30f209db8f07..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/es2015-arrow-function/object-binding-pattern-invalid-nested-param/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid left-hand side in object destructuring pattern (1:24)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-arrow-function/object-binding-pattern-invalid-nested-param/output.json b/packages/babel-parser/test/fixtures/esprima/es2015-arrow-function/object-binding-pattern-invalid-nested-param/output.json new file mode 100644 index 000000000000..a0f4f6168da6 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/es2015-arrow-function/object-binding-pattern-invalid-nested-param/output.json @@ -0,0 +1,538 @@ +{ + "type": "File", + "start": 0, + "end": 54, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 54 + } + }, + "errors": [ + "SyntaxError: Binding member expression (1:24)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 54, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 54 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 54, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 54 + } + }, + "expression": { + "type": "ArrowFunctionExpression", + "start": 0, + "end": 53, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 53 + } + }, + "id": null, + "generator": false, + "async": false, + "params": [ + { + "type": "ArrayPattern", + "start": 1, + "end": 49, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 49 + } + }, + "elements": [ + { + "type": "ArrayPattern", + "start": 2, + "end": 48, + "loc": { + "start": { + "line": 1, + "column": 2 + }, + "end": { + "line": 1, + "column": 48 + } + }, + "elements": [ + { + "type": "ArrayPattern", + "start": 3, + "end": 47, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 47 + } + }, + "elements": [ + { + "type": "ArrayPattern", + "start": 4, + "end": 46, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 46 + } + }, + "elements": [ + { + "type": "ArrayPattern", + "start": 5, + "end": 45, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 45 + } + }, + "elements": [ + { + "type": "ArrayPattern", + "start": 6, + "end": 44, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 44 + } + }, + "elements": [ + { + "type": "ArrayPattern", + "start": 7, + "end": 43, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 43 + } + }, + "elements": [ + { + "type": "ArrayPattern", + "start": 8, + "end": 42, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 42 + } + }, + "elements": [ + { + "type": "ArrayPattern", + "start": 9, + "end": 41, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 41 + } + }, + "elements": [ + { + "type": "ArrayPattern", + "start": 10, + "end": 40, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 40 + } + }, + "elements": [ + { + "type": "ArrayPattern", + "start": 11, + "end": 39, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 39 + } + }, + "elements": [ + { + "type": "ArrayPattern", + "start": 12, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 38 + } + }, + "elements": [ + { + "type": "ArrayPattern", + "start": 13, + "end": 37, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 37 + } + }, + "elements": [ + { + "type": "ArrayPattern", + "start": 14, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "elements": [ + { + "type": "ArrayPattern", + "start": 15, + "end": 35, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 35 + } + }, + "elements": [ + { + "type": "ArrayPattern", + "start": 16, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 34 + } + }, + "elements": [ + { + "type": "ArrayPattern", + "start": 17, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 33 + } + }, + "elements": [ + { + "type": "ArrayPattern", + "start": 18, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "elements": [ + { + "type": "ArrayPattern", + "start": 19, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "elements": [ + { + "type": "ArrayPattern", + "start": 20, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 20 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "elements": [ + { + "type": "ObjectPattern", + "start": 21, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 21 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "properties": [ + { + "type": "ObjectProperty", + "start": 22, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 22 + }, + "end": { + "line": 1, + "column": 28 + } + }, + "method": false, + "key": { + "type": "Identifier", + "start": 22, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 22 + }, + "end": { + "line": 1, + "column": 23 + }, + "identifierName": "a" + }, + "name": "a" + }, + "computed": false, + "shorthand": false, + "value": { + "type": "MemberExpression", + "start": 24, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 24 + }, + "end": { + "line": 1, + "column": 28 + } + }, + "object": { + "type": "Identifier", + "start": 24, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 24 + }, + "end": { + "line": 1, + "column": 25 + }, + "identifierName": "b" + }, + "name": "b" + }, + "property": { + "type": "NumericLiteral", + "start": 26, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 26 + }, + "end": { + "line": 1, + "column": 27 + } + }, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + }, + "computed": true + } + } + ] + } + ] + } + ] + } + ] + } + ] + } + ] + } + ] + } + ] + } + ] + } + ] + } + ] + } + ] + } + ] + } + ] + } + ] + } + ] + } + ] + } + ] + } + ] + } + ] + } + ] + } + ], + "body": { + "type": "NumericLiteral", + "start": 52, + "end": 53, + "loc": { + "start": { + "line": 1, + "column": 52 + }, + "end": { + "line": 1, + "column": 53 + } + }, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-destructuring-assignment-object-pattern/invalid-lhs-01/options.json b/packages/babel-parser/test/fixtures/esprima/es2015-destructuring-assignment-object-pattern/invalid-lhs-01/options.json deleted file mode 100644 index bf0f292caad2..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/es2015-destructuring-assignment-object-pattern/invalid-lhs-01/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid left-hand side in object destructuring pattern (1:4)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-destructuring-assignment-object-pattern/invalid-lhs-01/output.json b/packages/babel-parser/test/fixtures/esprima/es2015-destructuring-assignment-object-pattern/invalid-lhs-01/output.json new file mode 100644 index 000000000000..b71ec1a70153 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/es2015-destructuring-assignment-object-pattern/invalid-lhs-01/output.json @@ -0,0 +1,160 @@ +{ + "type": "File", + "start": 0, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "errors": [ + "SyntaxError: Invalid left-hand side in object destructuring pattern (1:4)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "expression": { + "type": "AssignmentExpression", + "start": 1, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "operator": "=", + "left": { + "type": "ObjectPattern", + "start": 1, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "properties": [ + { + "type": "ObjectProperty", + "start": 2, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 2 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "method": false, + "key": { + "type": "Identifier", + "start": 2, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 2 + }, + "end": { + "line": 1, + "column": 3 + }, + "identifierName": "a" + }, + "name": "a" + }, + "computed": false, + "shorthand": false, + "value": { + "type": "ThisExpression", + "start": 4, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 8 + } + } + } + } + ] + }, + "right": { + "type": "NumericLiteral", + "start": 10, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + }, + "extra": { + "parenthesized": true, + "parenStart": 0 + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-destructuring-assignment-object-pattern/invalid-lhs-02/options.json b/packages/babel-parser/test/fixtures/esprima/es2015-destructuring-assignment-object-pattern/invalid-lhs-02/options.json deleted file mode 100644 index 2cfe61cdc033..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/es2015-destructuring-assignment-object-pattern/invalid-lhs-02/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid left-hand side in object destructuring pattern (1:5)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-destructuring-assignment-object-pattern/invalid-lhs-02/output.json b/packages/babel-parser/test/fixtures/esprima/es2015-destructuring-assignment-object-pattern/invalid-lhs-02/output.json new file mode 100644 index 000000000000..0282d2b2a59c --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/es2015-destructuring-assignment-object-pattern/invalid-lhs-02/output.json @@ -0,0 +1,160 @@ +{ + "type": "File", + "start": 0, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "errors": [ + "SyntaxError: Invalid left-hand side in object destructuring pattern (1:5)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "expression": { + "type": "AssignmentExpression", + "start": 1, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "operator": "=", + "left": { + "type": "ObjectPattern", + "start": 1, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "properties": [ + { + "type": "ObjectProperty", + "start": 2, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 2 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "method": false, + "key": { + "type": "Identifier", + "start": 2, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 2 + }, + "end": { + "line": 1, + "column": 3 + }, + "identifierName": "a" + }, + "name": "a" + }, + "computed": false, + "shorthand": false, + "value": { + "type": "ThisExpression", + "start": 5, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 9 + } + } + } + } + ] + }, + "right": { + "type": "NumericLiteral", + "start": 13, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + }, + "extra": { + "parenthesized": true, + "parenStart": 0 + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-destructuring-assignment-object-pattern/invalid-pattern-with-method/input.js b/packages/babel-parser/test/fixtures/esprima/es2015-destructuring-assignment-object-pattern/invalid-pattern-with-method/input.js index 1dcb7ce683e6..dd21753e3550 100644 --- a/packages/babel-parser/test/fixtures/esprima/es2015-destructuring-assignment-object-pattern/invalid-pattern-with-method/input.js +++ b/packages/babel-parser/test/fixtures/esprima/es2015-destructuring-assignment-object-pattern/invalid-pattern-with-method/input.js @@ -1 +1 @@ -({a(){}})=0 +({a(){}}=0) diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-destructuring-assignment-object-pattern/invalid-pattern-with-method/options.json b/packages/babel-parser/test/fixtures/esprima/es2015-destructuring-assignment-object-pattern/invalid-pattern-with-method/options.json deleted file mode 100644 index 081535f854c6..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/es2015-destructuring-assignment-object-pattern/invalid-pattern-with-method/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Object pattern can't contain methods (1:2)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-destructuring-assignment-object-pattern/invalid-pattern-with-method/output.json b/packages/babel-parser/test/fixtures/esprima/es2015-destructuring-assignment-object-pattern/invalid-pattern-with-method/output.json new file mode 100644 index 000000000000..4f63aa8f3c12 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/es2015-destructuring-assignment-object-pattern/invalid-pattern-with-method/output.json @@ -0,0 +1,166 @@ +{ + "type": "File", + "start": 0, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "errors": [ + "SyntaxError: Object pattern can't contain methods (1:2)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "expression": { + "type": "AssignmentExpression", + "start": 1, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "operator": "=", + "left": { + "type": "ObjectPattern", + "start": 1, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "properties": [ + { + "type": "ObjectMethod", + "start": 2, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 2 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "method": true, + "key": { + "type": "Identifier", + "start": 2, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 2 + }, + "end": { + "line": 1, + "column": 3 + }, + "identifierName": "a" + }, + "name": "a" + }, + "computed": false, + "kind": "method", + "id": null, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 5, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "body": [], + "directives": [] + } + } + ] + }, + "right": { + "type": "NumericLiteral", + "start": 9, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + }, + "extra": { + "parenthesized": true, + "parenStart": 0 + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-destructuring-assignment/invalid-group-assignment/options.json b/packages/babel-parser/test/fixtures/esprima/es2015-destructuring-assignment/invalid-group-assignment/options.json deleted file mode 100644 index 7c5f08eb9ba6..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/es2015-destructuring-assignment/invalid-group-assignment/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid left-hand side in assignment expression (1:1)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-destructuring-assignment/invalid-group-assignment/output.json b/packages/babel-parser/test/fixtures/esprima/es2015-destructuring-assignment/invalid-group-assignment/output.json new file mode 100644 index 000000000000..a6616604e7dd --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/es2015-destructuring-assignment/invalid-group-assignment/output.json @@ -0,0 +1,179 @@ +{ + "type": "File", + "start": 0, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "errors": [ + "SyntaxError: Invalid left-hand side in assignment expression (1:1)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "expression": { + "type": "AssignmentExpression", + "start": 0, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "operator": "=", + "left": { + "type": "SequenceExpression", + "start": 1, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "expressions": [ + { + "type": "Identifier", + "start": 1, + "end": 2, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 2 + }, + "identifierName": "a" + }, + "name": "a" + }, + { + "type": "Identifier", + "start": 3, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 4 + }, + "identifierName": "b" + }, + "name": "b" + } + ], + "extra": { + "parenthesized": true, + "parenStart": 0 + } + }, + "right": { + "type": "SequenceExpression", + "start": 7, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "expressions": [ + { + "type": "Identifier", + "start": 7, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 8 + }, + "identifierName": "c" + }, + "name": "c" + }, + { + "type": "Identifier", + "start": 9, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 10 + }, + "identifierName": "d" + }, + "name": "d" + } + ], + "extra": { + "parenthesized": true, + "parenStart": 6 + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-export-declaration/invalid-export-named-default/options.json b/packages/babel-parser/test/fixtures/esprima/es2015-export-declaration/invalid-export-named-default/options.json index 9371e19769ce..54925950e059 100644 --- a/packages/babel-parser/test/fixtures/esprima/es2015-export-declaration/invalid-export-named-default/options.json +++ b/packages/babel-parser/test/fixtures/esprima/es2015-export-declaration/invalid-export-named-default/options.json @@ -1,4 +1,3 @@ { - "sourceType": "module", - "throws": "Unexpected keyword 'default' (1:8)" -} + "sourceType": "module" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-export-declaration/invalid-export-named-default/output.json b/packages/babel-parser/test/fixtures/esprima/es2015-export-declaration/invalid-export-named-default/output.json new file mode 100644 index 000000000000..0b3a95c25658 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/es2015-export-declaration/invalid-export-named-default/output.json @@ -0,0 +1,107 @@ +{ + "type": "File", + "start": 0, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "errors": [ + "SyntaxError: Unexpected keyword 'default' (1:8)", + "SyntaxError: Export 'default' is not defined (1:8)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExportNamedDeclaration", + "start": 0, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "specifiers": [ + { + "type": "ExportSpecifier", + "start": 8, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "local": { + "type": "Identifier", + "start": 8, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 15 + }, + "identifierName": "default" + }, + "name": "default" + }, + "exported": { + "type": "Identifier", + "start": 8, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 15 + }, + "identifierName": "default" + }, + "name": "default" + } + } + ], + "source": null, + "declaration": null + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-for-of/invalid-const-init/options.json b/packages/babel-parser/test/fixtures/esprima/es2015-for-of/invalid-const-init/options.json deleted file mode 100644 index 1fc5db8949ff..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/es2015-for-of/invalid-const-init/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "for-of loop variable declaration may not have an initializer (1:5)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-for-of/invalid-const-init/output.json b/packages/babel-parser/test/fixtures/esprima/es2015-for-of/invalid-const-init/output.json new file mode 100644 index 000000000000..9addc13c958b --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/es2015-for-of/invalid-const-init/output.json @@ -0,0 +1,156 @@ +{ + "type": "File", + "start": 0, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "errors": [ + "SyntaxError: for-of loop variable declaration may not have an initializer (1:5)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ForOfStatement", + "start": 0, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "await": false, + "left": { + "type": "VariableDeclaration", + "start": 5, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 11, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "id": { + "type": "Identifier", + "start": 11, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 12 + }, + "identifierName": "x" + }, + "name": "x" + }, + "init": { + "type": "NumericLiteral", + "start": 15, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + } + } + ], + "kind": "const" + }, + "right": { + "type": "Identifier", + "start": 20, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 20 + }, + "end": { + "line": 1, + "column": 21 + }, + "identifierName": "y" + }, + "name": "y" + }, + "body": { + "type": "EmptyStatement", + "start": 22, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 22 + }, + "end": { + "line": 1, + "column": 23 + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-for-of/invalid-let-init/options.json b/packages/babel-parser/test/fixtures/esprima/es2015-for-of/invalid-let-init/options.json deleted file mode 100644 index 1fc5db8949ff..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/es2015-for-of/invalid-let-init/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "for-of loop variable declaration may not have an initializer (1:5)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-for-of/invalid-let-init/output.json b/packages/babel-parser/test/fixtures/esprima/es2015-for-of/invalid-let-init/output.json new file mode 100644 index 000000000000..e7720b34974c --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/es2015-for-of/invalid-let-init/output.json @@ -0,0 +1,156 @@ +{ + "type": "File", + "start": 0, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "errors": [ + "SyntaxError: for-of loop variable declaration may not have an initializer (1:5)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ForOfStatement", + "start": 0, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "await": false, + "left": { + "type": "VariableDeclaration", + "start": 5, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 9, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 10 + }, + "identifierName": "x" + }, + "name": "x" + }, + "init": { + "type": "NumericLiteral", + "start": 13, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + } + } + ], + "kind": "let" + }, + "right": { + "type": "Identifier", + "start": 18, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 19 + }, + "identifierName": "y" + }, + "name": "y" + }, + "body": { + "type": "EmptyStatement", + "start": 20, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 20 + }, + "end": { + "line": 1, + "column": 21 + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-for-of/invalid-lhs-init/options.json b/packages/babel-parser/test/fixtures/esprima/es2015-for-of/invalid-lhs-init/options.json deleted file mode 100644 index a4dd545935e8..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/es2015-for-of/invalid-lhs-init/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid left-hand side in for-of statement (1:5)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-for-of/invalid-lhs-init/output.json b/packages/babel-parser/test/fixtures/esprima/es2015-for-of/invalid-lhs-init/output.json new file mode 100644 index 000000000000..bdb80af26d26 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/es2015-for-of/invalid-lhs-init/output.json @@ -0,0 +1,101 @@ +{ + "type": "File", + "start": 0, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "errors": [ + "SyntaxError: Invalid left-hand side in for-of statement (1:5)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ForOfStatement", + "start": 0, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "await": false, + "left": { + "type": "ThisExpression", + "start": 5, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 9 + } + } + }, + "right": { + "type": "Identifier", + "start": 13, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 17 + }, + "identifierName": "that" + }, + "name": "that" + }, + "body": { + "type": "EmptyStatement", + "start": 18, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 19 + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-for-of/invalid-var-init/options.json b/packages/babel-parser/test/fixtures/esprima/es2015-for-of/invalid-var-init/options.json deleted file mode 100644 index 1fc5db8949ff..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/es2015-for-of/invalid-var-init/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "for-of loop variable declaration may not have an initializer (1:5)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-for-of/invalid-var-init/output.json b/packages/babel-parser/test/fixtures/esprima/es2015-for-of/invalid-var-init/output.json new file mode 100644 index 000000000000..5c95e7b34186 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/es2015-for-of/invalid-var-init/output.json @@ -0,0 +1,156 @@ +{ + "type": "File", + "start": 0, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "errors": [ + "SyntaxError: for-of loop variable declaration may not have an initializer (1:5)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ForOfStatement", + "start": 0, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "await": false, + "left": { + "type": "VariableDeclaration", + "start": 5, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 9, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 10 + }, + "identifierName": "x" + }, + "name": "x" + }, + "init": { + "type": "NumericLiteral", + "start": 13, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + } + } + ], + "kind": "var" + }, + "right": { + "type": "Identifier", + "start": 18, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 19 + }, + "identifierName": "y" + }, + "name": "y" + }, + "body": { + "type": "EmptyStatement", + "start": 20, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 20 + }, + "end": { + "line": 1, + "column": 21 + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-identifier/invalid_escaped_surrogate_pairs/options.json b/packages/babel-parser/test/fixtures/esprima/es2015-identifier/invalid_escaped_surrogate_pairs/options.json deleted file mode 100644 index df97a8ee679f..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/es2015-identifier/invalid_escaped_surrogate_pairs/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid Unicode escape (1:4)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-identifier/invalid_escaped_surrogate_pairs/output.json b/packages/babel-parser/test/fixtures/esprima/es2015-identifier/invalid_escaped_surrogate_pairs/output.json new file mode 100644 index 000000000000..111d8eb97b43 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/es2015-identifier/invalid_escaped_surrogate_pairs/output.json @@ -0,0 +1,90 @@ +{ + "type": "File", + "start": 0, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "errors": [ + "SyntaxError: Invalid Unicode escape (1:4)", + "SyntaxError: Invalid Unicode escape (1:10)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "VariableDeclaration", + "start": 0, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 4, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "id": { + "type": "Identifier", + "start": 4, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 16 + }, + "identifierName": "𞸀" + }, + "name": "𞸀" + }, + "init": null + } + ], + "kind": "var" + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-identifier/invalid_expression_await/options.json b/packages/babel-parser/test/fixtures/esprima/es2015-identifier/invalid_expression_await/options.json deleted file mode 100644 index afbed324e92a..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/es2015-identifier/invalid_expression_await/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "'import' and 'export' may appear only with 'sourceType: \"module\"' (1:0)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-identifier/invalid_expression_await/output.json b/packages/babel-parser/test/fixtures/esprima/es2015-identifier/invalid_expression_await/output.json new file mode 100644 index 000000000000..a6d558c93efe --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/es2015-identifier/invalid_expression_await/output.json @@ -0,0 +1,158 @@ +{ + "type": "File", + "start": 0, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "errors": [ + "SyntaxError: 'import' and 'export' may appear only with 'sourceType: \"module\"' (1:0)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExportNamedDeclaration", + "start": 0, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "specifiers": [], + "source": null, + "declaration": { + "type": "VariableDeclaration", + "start": 7, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 11, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "id": { + "type": "Identifier", + "start": 11, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 17 + }, + "identifierName": "answer" + }, + "name": "answer" + }, + "init": { + "type": "BinaryExpression", + "start": 20, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 20 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "left": { + "type": "Identifier", + "start": 20, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 20 + }, + "end": { + "line": 1, + "column": 25 + }, + "identifierName": "await" + }, + "name": "await" + }, + "operator": "+", + "right": { + "type": "NumericLiteral", + "start": 28, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 28 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + } + } + } + ], + "kind": "var" + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-identifier/invalid_var_await/options.json b/packages/babel-parser/test/fixtures/esprima/es2015-identifier/invalid_var_await/options.json deleted file mode 100644 index afbed324e92a..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/es2015-identifier/invalid_var_await/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "'import' and 'export' may appear only with 'sourceType: \"module\"' (1:0)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-identifier/invalid_var_await/output.json b/packages/babel-parser/test/fixtures/esprima/es2015-identifier/invalid_var_await/output.json new file mode 100644 index 000000000000..514e8e0f0abe --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/es2015-identifier/invalid_var_await/output.json @@ -0,0 +1,106 @@ +{ + "type": "File", + "start": 0, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "errors": [ + "SyntaxError: 'import' and 'export' may appear only with 'sourceType: \"module\"' (1:0)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExportNamedDeclaration", + "start": 0, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "specifiers": [], + "source": null, + "declaration": { + "type": "VariableDeclaration", + "start": 7, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 11, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "id": { + "type": "Identifier", + "start": 11, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 16 + }, + "identifierName": "await" + }, + "name": "await" + }, + "init": null + } + ], + "kind": "var" + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-lexical-declaration/invalid_complex_binding_without_init/options.json b/packages/babel-parser/test/fixtures/esprima/es2015-lexical-declaration/invalid_complex_binding_without_init/options.json deleted file mode 100644 index 57893e4eee56..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/es2015-lexical-declaration/invalid_complex_binding_without_init/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Complex binding patterns require an initialization value (1:6)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-lexical-declaration/invalid_complex_binding_without_init/output.json b/packages/babel-parser/test/fixtures/esprima/es2015-lexical-declaration/invalid_complex_binding_without_init/output.json new file mode 100644 index 000000000000..fe814362c2c8 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/es2015-lexical-declaration/invalid_complex_binding_without_init/output.json @@ -0,0 +1,88 @@ +{ + "type": "File", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "errors": [ + "SyntaxError: Complex binding patterns require an initialization value (1:6)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "VariableDeclaration", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 4, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "id": { + "type": "ArrayPattern", + "start": 4, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "elements": [] + }, + "init": null + } + ], + "kind": "let" + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-lexical-declaration/invalid_const_forin/options.json b/packages/babel-parser/test/fixtures/esprima/es2015-lexical-declaration/invalid_const_forin/options.json deleted file mode 100644 index 68677faac9b9..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/es2015-lexical-declaration/invalid_const_forin/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "for-in loop variable declaration may not have an initializer (1:5)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-lexical-declaration/invalid_const_forin/output.json b/packages/babel-parser/test/fixtures/esprima/es2015-lexical-declaration/invalid_const_forin/output.json new file mode 100644 index 000000000000..f2fe5561bb8d --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/es2015-lexical-declaration/invalid_const_forin/output.json @@ -0,0 +1,157 @@ +{ + "type": "File", + "start": 0, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "errors": [ + "SyntaxError: for-in loop variable declaration may not have an initializer (1:5)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ForInStatement", + "start": 0, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "left": { + "type": "VariableDeclaration", + "start": 5, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 11, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "id": { + "type": "Identifier", + "start": 11, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 12 + }, + "identifierName": "x" + }, + "name": "x" + }, + "init": { + "type": "NumericLiteral", + "start": 15, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + } + } + ], + "kind": "const" + }, + "right": { + "type": "Identifier", + "start": 20, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 20 + }, + "end": { + "line": 1, + "column": 21 + }, + "identifierName": "y" + }, + "name": "y" + }, + "body": { + "type": "BlockStatement", + "start": 22, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 22 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "body": [], + "directives": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-lexical-declaration/invalid_let_forin/options.json b/packages/babel-parser/test/fixtures/esprima/es2015-lexical-declaration/invalid_let_forin/options.json deleted file mode 100644 index 68677faac9b9..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/es2015-lexical-declaration/invalid_let_forin/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "for-in loop variable declaration may not have an initializer (1:5)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-lexical-declaration/invalid_let_forin/output.json b/packages/babel-parser/test/fixtures/esprima/es2015-lexical-declaration/invalid_let_forin/output.json new file mode 100644 index 000000000000..3a3a8f1230c5 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/es2015-lexical-declaration/invalid_let_forin/output.json @@ -0,0 +1,157 @@ +{ + "type": "File", + "start": 0, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "errors": [ + "SyntaxError: for-in loop variable declaration may not have an initializer (1:5)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ForInStatement", + "start": 0, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "left": { + "type": "VariableDeclaration", + "start": 5, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 9, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 10 + }, + "identifierName": "x" + }, + "name": "x" + }, + "init": { + "type": "NumericLiteral", + "start": 13, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + } + } + ], + "kind": "let" + }, + "right": { + "type": "Identifier", + "start": 18, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 19 + }, + "identifierName": "y" + }, + "name": "y" + }, + "body": { + "type": "BlockStatement", + "start": 20, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 20 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "body": [], + "directives": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-meta-property/invalid-new-target/options.json b/packages/babel-parser/test/fixtures/esprima/es2015-meta-property/invalid-new-target/options.json deleted file mode 100644 index a8a536e737f3..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/es2015-meta-property/invalid-new-target/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "new.target can only be used in functions (1:8)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-meta-property/invalid-new-target/output.json b/packages/babel-parser/test/fixtures/esprima/es2015-meta-property/invalid-new-target/output.json new file mode 100644 index 000000000000..e02e90a31d33 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/es2015-meta-property/invalid-new-target/output.json @@ -0,0 +1,137 @@ +{ + "type": "File", + "start": 0, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "errors": [ + "SyntaxError: new.target can only be used in functions (1:8)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "VariableDeclaration", + "start": 0, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 4, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "id": { + "type": "Identifier", + "start": 4, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 5 + }, + "identifierName": "x" + }, + "name": "x" + }, + "init": { + "type": "MetaProperty", + "start": 8, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "meta": { + "type": "Identifier", + "start": 8, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 11 + }, + "identifierName": "new" + }, + "name": "new" + }, + "property": { + "type": "Identifier", + "start": 12, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 18 + }, + "identifierName": "target" + }, + "name": "target" + } + } + } + ], + "kind": "var" + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-meta-property/unknown-property/options.json b/packages/babel-parser/test/fixtures/esprima/es2015-meta-property/unknown-property/options.json deleted file mode 100644 index f1d291c3e468..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/es2015-meta-property/unknown-property/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "The only valid meta property for new is new.target (1:25)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-meta-property/unknown-property/output.json b/packages/babel-parser/test/fixtures/esprima/es2015-meta-property/unknown-property/output.json new file mode 100644 index 000000000000..4bcbca3b0d36 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/es2015-meta-property/unknown-property/output.json @@ -0,0 +1,189 @@ +{ + "type": "File", + "start": 0, + "end": 44, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 44 + } + }, + "errors": [ + "SyntaxError: The only valid meta property for new is new.target (1:25)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 44, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 44 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "VariableDeclaration", + "start": 0, + "end": 44, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 44 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 4, + "end": 44, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 44 + } + }, + "id": { + "type": "Identifier", + "start": 4, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 5 + }, + "identifierName": "f" + }, + "name": "f" + }, + "init": { + "type": "FunctionExpression", + "start": 8, + "end": 44, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 44 + } + }, + "id": null, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 19, + "end": 44, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 44 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 21, + "end": 42, + "loc": { + "start": { + "line": 1, + "column": 21 + }, + "end": { + "line": 1, + "column": 42 + } + }, + "expression": { + "type": "MetaProperty", + "start": 21, + "end": 41, + "loc": { + "start": { + "line": 1, + "column": 21 + }, + "end": { + "line": 1, + "column": 41 + } + }, + "meta": { + "type": "Identifier", + "start": 21, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 21 + }, + "end": { + "line": 1, + "column": 24 + }, + "identifierName": "new" + }, + "name": "new" + }, + "property": { + "type": "Identifier", + "start": 25, + "end": 41, + "loc": { + "start": { + "line": 1, + "column": 25 + }, + "end": { + "line": 1, + "column": 41 + }, + "identifierName": "unknown_property" + }, + "name": "unknown_property" + } + } + } + ], + "directives": [] + } + } + } + ], + "kind": "var" + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/invalid-proto-getter-literal-identifier/options.json b/packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/invalid-proto-getter-literal-identifier/options.json deleted file mode 100644 index de857a114a82..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/invalid-proto-getter-literal-identifier/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Redefinition of __proto__ property (1:39)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/invalid-proto-getter-literal-identifier/output.json b/packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/invalid-proto-getter-literal-identifier/output.json new file mode 100644 index 000000000000..8316c5f97f85 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/invalid-proto-getter-literal-identifier/output.json @@ -0,0 +1,234 @@ +{ + "type": "File", + "start": 0, + "end": 58, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 58 + } + }, + "errors": [ + "SyntaxError: Redefinition of __proto__ property (1:39)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 58, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 58 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 58, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 58 + } + }, + "expression": { + "type": "ObjectExpression", + "start": 1, + "end": 57, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 57 + } + }, + "properties": [ + { + "type": "ObjectMethod", + "start": 3, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "method": false, + "key": { + "type": "Identifier", + "start": 7, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 14 + }, + "identifierName": "__proto" + }, + "name": "__proto" + }, + "computed": false, + "kind": "get", + "id": null, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 16, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "body": [], + "directives": [] + } + }, + { + "type": "ObjectProperty", + "start": 20, + "end": 37, + "loc": { + "start": { + "line": 1, + "column": 20 + }, + "end": { + "line": 1, + "column": 37 + } + }, + "method": false, + "key": { + "type": "StringLiteral", + "start": 20, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 20 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "extra": { + "rawValue": "__proto__", + "raw": "\"__proto__\"" + }, + "value": "__proto__" + }, + "computed": false, + "shorthand": false, + "value": { + "type": "NullLiteral", + "start": 33, + "end": 37, + "loc": { + "start": { + "line": 1, + "column": 33 + }, + "end": { + "line": 1, + "column": 37 + } + } + } + }, + { + "type": "ObjectProperty", + "start": 39, + "end": 54, + "loc": { + "start": { + "line": 1, + "column": 39 + }, + "end": { + "line": 1, + "column": 54 + } + }, + "method": false, + "key": { + "type": "Identifier", + "start": 39, + "end": 48, + "loc": { + "start": { + "line": 1, + "column": 39 + }, + "end": { + "line": 1, + "column": 48 + }, + "identifierName": "__proto__" + }, + "name": "__proto__" + }, + "computed": false, + "shorthand": false, + "value": { + "type": "NullLiteral", + "start": 50, + "end": 54, + "loc": { + "start": { + "line": 1, + "column": 50 + }, + "end": { + "line": 1, + "column": 54 + } + } + } + } + ], + "extra": { + "trailingComma": 54, + "parenthesized": true, + "parenStart": 0 + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/invalid-proto-identifier-literal/options.json b/packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/invalid-proto-identifier-literal/options.json deleted file mode 100644 index 5c966843f4fa..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/invalid-proto-identifier-literal/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Redefinition of __proto__ property (1:20)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/invalid-proto-identifier-literal/output.json b/packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/invalid-proto-identifier-literal/output.json new file mode 100644 index 000000000000..5e3da9129e41 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/invalid-proto-identifier-literal/output.json @@ -0,0 +1,177 @@ +{ + "type": "File", + "start": 0, + "end": 40, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 40 + } + }, + "errors": [ + "SyntaxError: Redefinition of __proto__ property (1:20)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 40, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 40 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 40, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 40 + } + }, + "expression": { + "type": "ObjectExpression", + "start": 1, + "end": 39, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 39 + } + }, + "properties": [ + { + "type": "ObjectProperty", + "start": 3, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "method": false, + "key": { + "type": "Identifier", + "start": 3, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 12 + }, + "identifierName": "__proto__" + }, + "name": "__proto__" + }, + "computed": false, + "shorthand": false, + "value": { + "type": "NullLiteral", + "start": 14, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 18 + } + } + } + }, + { + "type": "ObjectProperty", + "start": 20, + "end": 37, + "loc": { + "start": { + "line": 1, + "column": 20 + }, + "end": { + "line": 1, + "column": 37 + } + }, + "method": false, + "key": { + "type": "StringLiteral", + "start": 20, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 20 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "extra": { + "rawValue": "__proto__", + "raw": "\"__proto__\"" + }, + "value": "__proto__" + }, + "computed": false, + "shorthand": false, + "value": { + "type": "NullLiteral", + "start": 33, + "end": 37, + "loc": { + "start": { + "line": 1, + "column": 33 + }, + "end": { + "line": 1, + "column": 37 + } + } + } + } + ], + "extra": { + "parenthesized": true, + "parenStart": 0 + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/invalid-proto-identifiers/options.json b/packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/invalid-proto-identifiers/options.json deleted file mode 100644 index 5c966843f4fa..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/invalid-proto-identifiers/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Redefinition of __proto__ property (1:20)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/invalid-proto-identifiers/output.json b/packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/invalid-proto-identifiers/output.json new file mode 100644 index 000000000000..f0884a922d47 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/invalid-proto-identifiers/output.json @@ -0,0 +1,174 @@ +{ + "type": "File", + "start": 0, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 38 + } + }, + "errors": [ + "SyntaxError: Redefinition of __proto__ property (1:20)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 38 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 38 + } + }, + "expression": { + "type": "ObjectExpression", + "start": 1, + "end": 37, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 37 + } + }, + "properties": [ + { + "type": "ObjectProperty", + "start": 3, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "method": false, + "key": { + "type": "Identifier", + "start": 3, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 12 + }, + "identifierName": "__proto__" + }, + "name": "__proto__" + }, + "computed": false, + "shorthand": false, + "value": { + "type": "NullLiteral", + "start": 14, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 18 + } + } + } + }, + { + "type": "ObjectProperty", + "start": 20, + "end": 35, + "loc": { + "start": { + "line": 1, + "column": 20 + }, + "end": { + "line": 1, + "column": 35 + } + }, + "method": false, + "key": { + "type": "Identifier", + "start": 20, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 20 + }, + "end": { + "line": 1, + "column": 29 + }, + "identifierName": "__proto__" + }, + "name": "__proto__" + }, + "computed": false, + "shorthand": false, + "value": { + "type": "NullLiteral", + "start": 31, + "end": 35, + "loc": { + "start": { + "line": 1, + "column": 31 + }, + "end": { + "line": 1, + "column": 35 + } + } + } + } + ], + "extra": { + "parenthesized": true, + "parenStart": 0 + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/invalid-proto-literal-identifier/options.json b/packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/invalid-proto-literal-identifier/options.json deleted file mode 100644 index e19950ad14df..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/invalid-proto-literal-identifier/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Redefinition of __proto__ property (1:22)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/invalid-proto-literal-identifier/output.json b/packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/invalid-proto-literal-identifier/output.json new file mode 100644 index 000000000000..7b8c0af8927c --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/invalid-proto-literal-identifier/output.json @@ -0,0 +1,177 @@ +{ + "type": "File", + "start": 0, + "end": 40, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 40 + } + }, + "errors": [ + "SyntaxError: Redefinition of __proto__ property (1:22)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 40, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 40 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 40, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 40 + } + }, + "expression": { + "type": "ObjectExpression", + "start": 1, + "end": 39, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 39 + } + }, + "properties": [ + { + "type": "ObjectProperty", + "start": 3, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "method": false, + "key": { + "type": "StringLiteral", + "start": 3, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "extra": { + "rawValue": "__proto__", + "raw": "\"__proto__\"" + }, + "value": "__proto__" + }, + "computed": false, + "shorthand": false, + "value": { + "type": "NullLiteral", + "start": 16, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 20 + } + } + } + }, + { + "type": "ObjectProperty", + "start": 22, + "end": 37, + "loc": { + "start": { + "line": 1, + "column": 22 + }, + "end": { + "line": 1, + "column": 37 + } + }, + "method": false, + "key": { + "type": "Identifier", + "start": 22, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 22 + }, + "end": { + "line": 1, + "column": 31 + }, + "identifierName": "__proto__" + }, + "name": "__proto__" + }, + "computed": false, + "shorthand": false, + "value": { + "type": "NullLiteral", + "start": 33, + "end": 37, + "loc": { + "start": { + "line": 1, + "column": 33 + }, + "end": { + "line": 1, + "column": 37 + } + } + } + } + ], + "extra": { + "parenthesized": true, + "parenStart": 0 + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/invalid-proto-literals/options.json b/packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/invalid-proto-literals/options.json deleted file mode 100644 index e19950ad14df..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/invalid-proto-literals/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Redefinition of __proto__ property (1:22)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/invalid-proto-literals/output.json b/packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/invalid-proto-literals/output.json new file mode 100644 index 000000000000..a9e0e52b80af --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/invalid-proto-literals/output.json @@ -0,0 +1,180 @@ +{ + "type": "File", + "start": 0, + "end": 42, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 42 + } + }, + "errors": [ + "SyntaxError: Redefinition of __proto__ property (1:22)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 42, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 42 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 42, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 42 + } + }, + "expression": { + "type": "ObjectExpression", + "start": 1, + "end": 41, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 41 + } + }, + "properties": [ + { + "type": "ObjectProperty", + "start": 3, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "method": false, + "key": { + "type": "StringLiteral", + "start": 3, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "extra": { + "rawValue": "__proto__", + "raw": "\"__proto__\"" + }, + "value": "__proto__" + }, + "computed": false, + "shorthand": false, + "value": { + "type": "NullLiteral", + "start": 16, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 20 + } + } + } + }, + { + "type": "ObjectProperty", + "start": 22, + "end": 39, + "loc": { + "start": { + "line": 1, + "column": 22 + }, + "end": { + "line": 1, + "column": 39 + } + }, + "method": false, + "key": { + "type": "StringLiteral", + "start": 22, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 22 + }, + "end": { + "line": 1, + "column": 33 + } + }, + "extra": { + "rawValue": "__proto__", + "raw": "'__proto__'" + }, + "value": "__proto__" + }, + "computed": false, + "shorthand": false, + "value": { + "type": "NullLiteral", + "start": 35, + "end": 39, + "loc": { + "start": { + "line": 1, + "column": 35 + }, + "end": { + "line": 1, + "column": 39 + } + } + } + } + ], + "extra": { + "parenthesized": true, + "parenStart": 0 + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/invalid-proto-setter-literal-identifier/options.json b/packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/invalid-proto-setter-literal-identifier/options.json deleted file mode 100644 index f364ee918462..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/invalid-proto-setter-literal-identifier/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Redefinition of __proto__ property (1:42)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/invalid-proto-setter-literal-identifier/output.json b/packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/invalid-proto-setter-literal-identifier/output.json new file mode 100644 index 000000000000..1a77efa6deef --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/invalid-proto-setter-literal-identifier/output.json @@ -0,0 +1,252 @@ +{ + "type": "File", + "start": 0, + "end": 61, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 61 + } + }, + "errors": [ + "SyntaxError: Redefinition of __proto__ property (1:42)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 61, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 61 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 61, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 61 + } + }, + "expression": { + "type": "ObjectExpression", + "start": 1, + "end": 60, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 60 + } + }, + "properties": [ + { + "type": "ObjectMethod", + "start": 3, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "method": false, + "key": { + "type": "Identifier", + "start": 7, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 16 + }, + "identifierName": "__proto__" + }, + "name": "__proto__" + }, + "computed": false, + "kind": "set", + "id": null, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "start": 17, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 18 + }, + "identifierName": "x" + }, + "name": "x" + } + ], + "body": { + "type": "BlockStatement", + "start": 19, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "body": [], + "directives": [] + } + }, + { + "type": "ObjectProperty", + "start": 23, + "end": 40, + "loc": { + "start": { + "line": 1, + "column": 23 + }, + "end": { + "line": 1, + "column": 40 + } + }, + "method": false, + "key": { + "type": "StringLiteral", + "start": 23, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 23 + }, + "end": { + "line": 1, + "column": 34 + } + }, + "extra": { + "rawValue": "__proto__", + "raw": "\"__proto__\"" + }, + "value": "__proto__" + }, + "computed": false, + "shorthand": false, + "value": { + "type": "NullLiteral", + "start": 36, + "end": 40, + "loc": { + "start": { + "line": 1, + "column": 36 + }, + "end": { + "line": 1, + "column": 40 + } + } + } + }, + { + "type": "ObjectProperty", + "start": 42, + "end": 57, + "loc": { + "start": { + "line": 1, + "column": 42 + }, + "end": { + "line": 1, + "column": 57 + } + }, + "method": false, + "key": { + "type": "Identifier", + "start": 42, + "end": 51, + "loc": { + "start": { + "line": 1, + "column": 42 + }, + "end": { + "line": 1, + "column": 51 + }, + "identifierName": "__proto__" + }, + "name": "__proto__" + }, + "computed": false, + "shorthand": false, + "value": { + "type": "NullLiteral", + "start": 53, + "end": 57, + "loc": { + "start": { + "line": 1, + "column": 53 + }, + "end": { + "line": 1, + "column": 57 + } + } + } + } + ], + "extra": { + "trailingComma": 57, + "parenthesized": true, + "parenStart": 0 + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-super-property/invalid_super_not_inside_function/options.json b/packages/babel-parser/test/fixtures/esprima/es2015-super-property/invalid_super_not_inside_function/options.json deleted file mode 100644 index cf468e48541b..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/es2015-super-property/invalid_super_not_inside_function/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "super is only allowed in object methods and classes (1:8)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-super-property/invalid_super_not_inside_function/output.json b/packages/babel-parser/test/fixtures/esprima/es2015-super-property/invalid_super_not_inside_function/output.json new file mode 100644 index 000000000000..94b7917cd389 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/es2015-super-property/invalid_super_not_inside_function/output.json @@ -0,0 +1,119 @@ +{ + "type": "File", + "start": 0, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "errors": [ + "SyntaxError: super() is only valid inside a class constructor of a subclass. Maybe a typo in the method name ('constructor') or not extending another class? (1:8)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "VariableDeclaration", + "start": 0, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 4, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "id": { + "type": "Identifier", + "start": 4, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 5 + }, + "identifierName": "x" + }, + "name": "x" + }, + "init": { + "type": "CallExpression", + "start": 8, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "callee": { + "type": "Super", + "start": 8, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 13 + } + } + }, + "arguments": [] + } + } + ], + "kind": "var" + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-template-literals/invalid-escape/options.json b/packages/babel-parser/test/fixtures/esprima/es2015-template-literals/invalid-escape/options.json deleted file mode 100644 index fd4da953a419..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/es2015-template-literals/invalid-escape/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid escape sequence in template (1:2)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-template-literals/invalid-escape/output.json b/packages/babel-parser/test/fixtures/esprima/es2015-template-literals/invalid-escape/output.json new file mode 100644 index 000000000000..3f3cd6596907 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/es2015-template-literals/invalid-escape/output.json @@ -0,0 +1,91 @@ +{ + "type": "File", + "start": 0, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "errors": [ + "SyntaxError: Invalid escape sequence in template (1:2)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "expression": { + "type": "TemplateLiteral", + "start": 0, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "expressions": [], + "quasis": [ + { + "type": "TemplateElement", + "start": 1, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "value": { + "raw": "\\1", + "cooked": null + }, + "tail": true + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-generator-arrow-default/options.json b/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-generator-arrow-default/options.json deleted file mode 100644 index f81e206da65d..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-generator-arrow-default/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Yield cannot be used as name inside a generator function (1:21)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-generator-arrow-default/output.json b/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-generator-arrow-default/output.json new file mode 100644 index 000000000000..93f29667086b --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-generator-arrow-default/output.json @@ -0,0 +1,211 @@ +{ + "type": "File", + "start": 0, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 38 + } + }, + "errors": [ + "SyntaxError: Yield cannot be used as name inside a generator function (1:21)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 38 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 38 + } + }, + "id": { + "type": "Identifier", + "start": 10, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 11 + }, + "identifierName": "g" + }, + "name": "g" + }, + "generator": true, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 14, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 38 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 16, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "expression": { + "type": "ArrowFunctionExpression", + "start": 16, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "id": null, + "generator": false, + "async": false, + "params": [ + { + "type": "AssignmentPattern", + "start": 17, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "left": { + "type": "Identifier", + "start": 17, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 18 + }, + "identifierName": "x" + }, + "name": "x" + }, + "right": { + "type": "YieldExpression", + "start": 21, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 21 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "delegate": false, + "argument": { + "type": "NumericLiteral", + "start": 27, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 27 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "extra": { + "rawValue": 42, + "raw": "42" + }, + "value": 42 + } + } + } + ], + "body": { + "type": "BlockStatement", + "start": 34, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 34 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "body": [], + "directives": [] + } + } + } + ], + "directives": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-generator-arrow-parameter/options.json b/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-generator-arrow-parameter/options.json deleted file mode 100644 index efa8ac523c48..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-generator-arrow-parameter/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Yield cannot be used as name inside a generator function (1:16)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-generator-arrow-parameter/output.json b/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-generator-arrow-parameter/output.json new file mode 100644 index 000000000000..dfdc04d3c48b --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-generator-arrow-parameter/output.json @@ -0,0 +1,164 @@ +{ + "type": "File", + "start": 0, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "errors": [ + "SyntaxError: Yield cannot be used as name inside a generator function (1:16)", + "SyntaxError: Binding invalid left-hand side in function parameter list (1:16)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "id": { + "type": "Identifier", + "start": 10, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 11 + }, + "identifierName": "g" + }, + "name": "g" + }, + "generator": true, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 13, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 15, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 28 + } + }, + "expression": { + "type": "ArrowFunctionExpression", + "start": 15, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 28 + } + }, + "id": null, + "generator": false, + "async": false, + "params": [ + { + "type": "YieldExpression", + "start": 16, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "delegate": false, + "argument": null + } + ], + "body": { + "type": "NumericLiteral", + "start": 26, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 26 + }, + "end": { + "line": 1, + "column": 28 + } + }, + "extra": { + "rawValue": 42, + "raw": "42" + }, + "value": 42 + } + } + } + ], + "directives": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-generator-arrow-parameters/options.json b/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-generator-arrow-parameters/options.json deleted file mode 100644 index 185008241333..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-generator-arrow-parameters/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Yield cannot be used as name inside a generator function (1:25)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-generator-arrow-parameters/output.json b/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-generator-arrow-parameters/output.json new file mode 100644 index 000000000000..6bf7ee0d6108 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-generator-arrow-parameters/output.json @@ -0,0 +1,215 @@ +{ + "type": "File", + "start": 0, + "end": 39, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 39 + } + }, + "errors": [ + "SyntaxError: Yield cannot be used as name inside a generator function (1:25)", + "SyntaxError: Binding invalid left-hand side in function parameter list (1:25)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 39, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 39 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 39, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 39 + } + }, + "id": { + "type": "Identifier", + "start": 10, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 11 + }, + "identifierName": "g" + }, + "name": "g" + }, + "generator": true, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 13, + "end": 39, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 39 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 15, + "end": 37, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 37 + } + }, + "expression": { + "type": "ArrowFunctionExpression", + "start": 15, + "end": 37, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 37 + } + }, + "id": null, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "start": 16, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 17 + }, + "identifierName": "a" + }, + "name": "a" + }, + { + "type": "Identifier", + "start": 19, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 20 + }, + "identifierName": "b" + }, + "name": "b" + }, + { + "type": "Identifier", + "start": 22, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 22 + }, + "end": { + "line": 1, + "column": 23 + }, + "identifierName": "c" + }, + "name": "c" + }, + { + "type": "YieldExpression", + "start": 25, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 25 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "delegate": false, + "argument": null + } + ], + "body": { + "type": "NumericLiteral", + "start": 35, + "end": 37, + "loc": { + "start": { + "line": 1, + "column": 35 + }, + "end": { + "line": 1, + "column": 37 + } + }, + "extra": { + "rawValue": 42, + "raw": "42" + }, + "value": 42 + } + } + } + ], + "directives": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-generator-catch/options.json b/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-generator-catch/options.json deleted file mode 100644 index 8c287a1d5b36..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-generator-catch/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Can not use 'yield' as identifier inside a generator (1:30)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-generator-catch/output.json b/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-generator-catch/output.json new file mode 100644 index 000000000000..638788f4405b --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-generator-catch/output.json @@ -0,0 +1,173 @@ +{ + "type": "File", + "start": 0, + "end": 41, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 41 + } + }, + "errors": [ + "SyntaxError: Can not use 'yield' as identifier inside a generator (1:30)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 41, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 41 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 41, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 41 + } + }, + "id": { + "type": "Identifier", + "start": 10, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 11 + }, + "identifierName": "g" + }, + "name": "g" + }, + "generator": true, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 14, + "end": 41, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 41 + } + }, + "body": [ + { + "type": "TryStatement", + "start": 16, + "end": 39, + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 39 + } + }, + "block": { + "type": "BlockStatement", + "start": 20, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 20 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "body": [], + "directives": [] + }, + "handler": { + "type": "CatchClause", + "start": 23, + "end": 39, + "loc": { + "start": { + "line": 1, + "column": 23 + }, + "end": { + "line": 1, + "column": 39 + } + }, + "param": { + "type": "Identifier", + "start": 30, + "end": 35, + "loc": { + "start": { + "line": 1, + "column": 30 + }, + "end": { + "line": 1, + "column": 35 + }, + "identifierName": "yield" + }, + "name": "yield" + }, + "body": { + "type": "BlockStatement", + "start": 37, + "end": 39, + "loc": { + "start": { + "line": 1, + "column": 37 + }, + "end": { + "line": 1, + "column": 39 + } + }, + "body": [], + "directives": [] + } + }, + "finalizer": null + } + ], + "directives": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-generator-declaration/options.json b/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-generator-declaration/options.json deleted file mode 100644 index 3ceff8546d37..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-generator-declaration/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Can not use 'yield' as identifier inside a generator (1:26)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-generator-declaration/output.json b/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-generator-declaration/output.json new file mode 100644 index 000000000000..30846cf74293 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-generator-declaration/output.json @@ -0,0 +1,143 @@ +{ + "type": "File", + "start": 0, + "end": 37, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 37 + } + }, + "errors": [ + "SyntaxError: Can not use 'yield' as identifier inside a generator (1:26)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 37, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 37 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 37, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 37 + } + }, + "id": { + "type": "Identifier", + "start": 10, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 11 + }, + "identifierName": "g" + }, + "name": "g" + }, + "generator": true, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 14, + "end": 37, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 37 + } + }, + "body": [ + { + "type": "FunctionDeclaration", + "start": 16, + "end": 35, + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 35 + } + }, + "id": { + "type": "Identifier", + "start": 26, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 26 + }, + "end": { + "line": 1, + "column": 31 + }, + "identifierName": "yield" + }, + "name": "yield" + }, + "generator": true, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 33, + "end": 35, + "loc": { + "start": { + "line": 1, + "column": 33 + }, + "end": { + "line": 1, + "column": 35 + } + }, + "body": [], + "directives": [] + } + } + ], + "directives": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-generator-export-default/options.json b/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-generator-export-default/options.json index 23a96f285fe4..54925950e059 100644 --- a/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-generator-export-default/options.json +++ b/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-generator-export-default/options.json @@ -1,4 +1,3 @@ { - "sourceType": "module", - "throws": "Unexpected reserved word 'yield' (1:25)" -} + "sourceType": "module" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-generator-export-default/output.json b/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-generator-export-default/output.json new file mode 100644 index 000000000000..273c4fcdf066 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-generator-export-default/output.json @@ -0,0 +1,105 @@ +{ + "type": "File", + "start": 0, + "end": 35, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 35 + } + }, + "errors": [ + "SyntaxError: Unexpected reserved word 'yield' (1:25)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 35, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 35 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExportDefaultDeclaration", + "start": 0, + "end": 35, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 35 + } + }, + "declaration": { + "type": "FunctionDeclaration", + "start": 15, + "end": 35, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 35 + } + }, + "id": { + "type": "Identifier", + "start": 25, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 25 + }, + "end": { + "line": 1, + "column": 30 + }, + "identifierName": "yield" + }, + "name": "yield" + }, + "generator": true, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 33, + "end": 35, + "loc": { + "start": { + "line": 1, + "column": 33 + }, + "end": { + "line": 1, + "column": 35 + } + }, + "body": [], + "directives": [] + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-generator-expression-name/options.json b/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-generator-expression-name/options.json deleted file mode 100644 index c32eaf81f281..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-generator-expression-name/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Can not use 'yield' as identifier inside a generator (1:10)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-generator-expression-name/output.json b/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-generator-expression-name/output.json new file mode 100644 index 000000000000..0eca9154c92a --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-generator-expression-name/output.json @@ -0,0 +1,109 @@ +{ + "type": "File", + "start": 0, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "errors": [ + "SyntaxError: Can not use 'yield' as identifier inside a generator (1:10)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "expression": { + "type": "FunctionExpression", + "start": 1, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "id": { + "type": "Identifier", + "start": 10, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 15 + }, + "identifierName": "yield" + }, + "name": "yield" + }, + "generator": true, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 17, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "body": [], + "directives": [] + }, + "extra": { + "parenthesized": true, + "parenStart": 0 + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-generator-expression-parameter/options.json b/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-generator-expression-parameter/options.json deleted file mode 100644 index 28b734910647..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-generator-expression-parameter/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Can not use 'yield' as identifier inside a generator (1:12)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-generator-expression-parameter/output.json b/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-generator-expression-parameter/output.json new file mode 100644 index 000000000000..dbee42bd9873 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-generator-expression-parameter/output.json @@ -0,0 +1,111 @@ +{ + "type": "File", + "start": 0, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "errors": [ + "SyntaxError: Can not use 'yield' as identifier inside a generator (1:12)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "expression": { + "type": "FunctionExpression", + "start": 1, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "id": null, + "generator": true, + "async": false, + "params": [ + { + "type": "Identifier", + "start": 12, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 17 + }, + "identifierName": "yield" + }, + "name": "yield" + } + ], + "body": { + "type": "BlockStatement", + "start": 18, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "body": [], + "directives": [] + }, + "extra": { + "parenthesized": true, + "parenStart": 0 + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-generator-expression-rest/options.json b/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-generator-expression-rest/options.json deleted file mode 100644 index aef4d7f4f9a2..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-generator-expression-rest/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Can not use 'yield' as identifier inside a generator (1:18)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-generator-expression-rest/output.json b/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-generator-expression-rest/output.json new file mode 100644 index 000000000000..74eaaceb9832 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-generator-expression-rest/output.json @@ -0,0 +1,143 @@ +{ + "type": "File", + "start": 0, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 27 + } + }, + "errors": [ + "SyntaxError: Can not use 'yield' as identifier inside a generator (1:18)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 27 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 27 + } + }, + "expression": { + "type": "FunctionExpression", + "start": 1, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "id": null, + "generator": true, + "async": false, + "params": [ + { + "type": "Identifier", + "start": 12, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 13 + }, + "identifierName": "x" + }, + "name": "x" + }, + { + "type": "RestElement", + "start": 15, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "argument": { + "type": "Identifier", + "start": 18, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 23 + }, + "identifierName": "yield" + }, + "name": "yield" + } + } + ], + "body": { + "type": "BlockStatement", + "start": 24, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 24 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "body": [], + "directives": [] + }, + "extra": { + "parenthesized": true, + "parenStart": 0 + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-generator-function-declaration/options.json b/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-generator-function-declaration/options.json deleted file mode 100644 index 6993832643f1..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-generator-function-declaration/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Can not use 'yield' as identifier inside a generator (1:25)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-generator-function-declaration/output.json b/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-generator-function-declaration/output.json new file mode 100644 index 000000000000..ec55ac771815 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-generator-function-declaration/output.json @@ -0,0 +1,143 @@ +{ + "type": "File", + "start": 0, + "end": 37, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 37 + } + }, + "errors": [ + "SyntaxError: Can not use 'yield' as identifier inside a generator (1:25)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 37, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 37 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 37, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 37 + } + }, + "id": { + "type": "Identifier", + "start": 10, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 11 + }, + "identifierName": "g" + }, + "name": "g" + }, + "generator": true, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 14, + "end": 37, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 37 + } + }, + "body": [ + { + "type": "FunctionDeclaration", + "start": 16, + "end": 35, + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 35 + } + }, + "id": { + "type": "Identifier", + "start": 25, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 25 + }, + "end": { + "line": 1, + "column": 30 + }, + "identifierName": "yield" + }, + "name": "yield" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 33, + "end": 35, + "loc": { + "start": { + "line": 1, + "column": 33 + }, + "end": { + "line": 1, + "column": 35 + } + }, + "body": [], + "directives": [] + } + } + ], + "directives": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-generator-lexical-declaration/options.json b/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-generator-lexical-declaration/options.json deleted file mode 100644 index ad818f81f136..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-generator-lexical-declaration/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Can not use 'yield' as identifier inside a generator (1:20)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-generator-lexical-declaration/output.json b/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-generator-lexical-declaration/output.json new file mode 100644 index 000000000000..e07b84fedd4d --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-generator-lexical-declaration/output.json @@ -0,0 +1,142 @@ +{ + "type": "File", + "start": 0, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 28 + } + }, + "errors": [ + "SyntaxError: Can not use 'yield' as identifier inside a generator (1:20)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 28 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 28 + } + }, + "id": { + "type": "Identifier", + "start": 10, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 11 + }, + "identifierName": "g" + }, + "name": "g" + }, + "generator": true, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 14, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 28 + } + }, + "body": [ + { + "type": "VariableDeclaration", + "start": 16, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 20, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 20 + }, + "end": { + "line": 1, + "column": 25 + } + }, + "id": { + "type": "Identifier", + "start": 20, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 20 + }, + "end": { + "line": 1, + "column": 25 + }, + "identifierName": "yield" + }, + "name": "yield" + }, + "init": null + } + ], + "kind": "let" + } + ], + "directives": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-generator-parameter/options.json b/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-generator-parameter/options.json deleted file mode 100644 index 28b734910647..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-generator-parameter/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Can not use 'yield' as identifier inside a generator (1:12)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-generator-parameter/output.json b/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-generator-parameter/output.json new file mode 100644 index 000000000000..91b76a6f9351 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-generator-parameter/output.json @@ -0,0 +1,108 @@ +{ + "type": "File", + "start": 0, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "errors": [ + "SyntaxError: Can not use 'yield' as identifier inside a generator (1:12)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "id": { + "type": "Identifier", + "start": 10, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 11 + }, + "identifierName": "g" + }, + "name": "g" + }, + "generator": true, + "async": false, + "params": [ + { + "type": "Identifier", + "start": 12, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 17 + }, + "identifierName": "yield" + }, + "name": "yield" + } + ], + "body": { + "type": "BlockStatement", + "start": 18, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "body": [], + "directives": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-generator-rest/options.json b/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-generator-rest/options.json deleted file mode 100644 index c811689d9abd..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-generator-rest/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Can not use 'yield' as identifier inside a generator (1:24)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-generator-rest/output.json b/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-generator-rest/output.json new file mode 100644 index 000000000000..0b1e59c7ab58 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-generator-rest/output.json @@ -0,0 +1,174 @@ +{ + "type": "File", + "start": 0, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "errors": [ + "SyntaxError: Can not use 'yield' as identifier inside a generator (1:24)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "id": { + "type": "Identifier", + "start": 10, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 11 + }, + "identifierName": "g" + }, + "name": "g" + }, + "generator": true, + "async": false, + "params": [ + { + "type": "Identifier", + "start": 12, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 13 + }, + "identifierName": "a" + }, + "name": "a" + }, + { + "type": "Identifier", + "start": 15, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 16 + }, + "identifierName": "b" + }, + "name": "b" + }, + { + "type": "Identifier", + "start": 18, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 19 + }, + "identifierName": "c" + }, + "name": "c" + }, + { + "type": "RestElement", + "start": 21, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 21 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "argument": { + "type": "Identifier", + "start": 24, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 24 + }, + "end": { + "line": 1, + "column": 29 + }, + "identifierName": "yield" + }, + "name": "yield" + } + } + ], + "body": { + "type": "BlockStatement", + "start": 30, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 30 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "body": [], + "directives": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-generator-strict-function-expression/options.json b/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-generator-strict-function-expression/options.json deleted file mode 100644 index 865e081676d6..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-generator-strict-function-expression/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Unexpected reserved word 'yield' (1:46)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-generator-strict-function-expression/output.json b/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-generator-strict-function-expression/output.json new file mode 100644 index 000000000000..b1b8b4f0880d --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-generator-strict-function-expression/output.json @@ -0,0 +1,229 @@ +{ + "type": "File", + "start": 0, + "end": 58, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 58 + } + }, + "errors": [ + "SyntaxError: Unexpected reserved word 'yield' (1:46)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 58, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 58 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 14, + "end": 58, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 58 + } + }, + "id": { + "type": "Identifier", + "start": 24, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 24 + }, + "end": { + "line": 1, + "column": 25 + }, + "identifierName": "g" + }, + "name": "g" + }, + "generator": true, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 27, + "end": 58, + "loc": { + "start": { + "line": 1, + "column": 27 + }, + "end": { + "line": 1, + "column": 58 + } + }, + "body": [ + { + "type": "VariableDeclaration", + "start": 29, + "end": 56, + "loc": { + "start": { + "line": 1, + "column": 29 + }, + "end": { + "line": 1, + "column": 56 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 33, + "end": 55, + "loc": { + "start": { + "line": 1, + "column": 33 + }, + "end": { + "line": 1, + "column": 55 + } + }, + "id": { + "type": "Identifier", + "start": 33, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 33 + }, + "end": { + "line": 1, + "column": 34 + }, + "identifierName": "y" + }, + "name": "y" + }, + "init": { + "type": "FunctionExpression", + "start": 37, + "end": 55, + "loc": { + "start": { + "line": 1, + "column": 37 + }, + "end": { + "line": 1, + "column": 55 + } + }, + "id": { + "type": "Identifier", + "start": 46, + "end": 51, + "loc": { + "start": { + "line": 1, + "column": 46 + }, + "end": { + "line": 1, + "column": 51 + }, + "identifierName": "yield" + }, + "name": "yield" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 53, + "end": 55, + "loc": { + "start": { + "line": 1, + "column": 53 + }, + "end": { + "line": 1, + "column": 55 + } + }, + "body": [], + "directives": [] + } + } + } + ], + "kind": "var" + } + ], + "directives": [] + } + } + ], + "directives": [ + { + "type": "Directive", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 0, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "value": "use strict", + "extra": { + "raw": "\"use strict\"", + "rawValue": "use strict" + } + } + } + ] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-generator-strict-function-parameter/options.json b/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-generator-strict-function-parameter/options.json deleted file mode 100644 index 21348af52377..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-generator-strict-function-parameter/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Unexpected reserved word 'yield' (1:47)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-generator-strict-function-parameter/output.json b/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-generator-strict-function-parameter/output.json new file mode 100644 index 000000000000..40d206249a26 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-generator-strict-function-parameter/output.json @@ -0,0 +1,231 @@ +{ + "type": "File", + "start": 0, + "end": 58, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 58 + } + }, + "errors": [ + "SyntaxError: Unexpected reserved word 'yield' (1:47)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 58, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 58 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 14, + "end": 58, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 58 + } + }, + "id": { + "type": "Identifier", + "start": 24, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 24 + }, + "end": { + "line": 1, + "column": 25 + }, + "identifierName": "g" + }, + "name": "g" + }, + "generator": true, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 28, + "end": 58, + "loc": { + "start": { + "line": 1, + "column": 28 + }, + "end": { + "line": 1, + "column": 58 + } + }, + "body": [ + { + "type": "VariableDeclaration", + "start": 30, + "end": 56, + "loc": { + "start": { + "line": 1, + "column": 30 + }, + "end": { + "line": 1, + "column": 56 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 34, + "end": 56, + "loc": { + "start": { + "line": 1, + "column": 34 + }, + "end": { + "line": 1, + "column": 56 + } + }, + "id": { + "type": "Identifier", + "start": 34, + "end": 35, + "loc": { + "start": { + "line": 1, + "column": 34 + }, + "end": { + "line": 1, + "column": 35 + }, + "identifierName": "z" + }, + "name": "z" + }, + "init": { + "type": "FunctionExpression", + "start": 38, + "end": 56, + "loc": { + "start": { + "line": 1, + "column": 38 + }, + "end": { + "line": 1, + "column": 56 + } + }, + "id": null, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "start": 47, + "end": 52, + "loc": { + "start": { + "line": 1, + "column": 47 + }, + "end": { + "line": 1, + "column": 52 + }, + "identifierName": "yield" + }, + "name": "yield" + } + ], + "body": { + "type": "BlockStatement", + "start": 54, + "end": 56, + "loc": { + "start": { + "line": 1, + "column": 54 + }, + "end": { + "line": 1, + "column": 56 + } + }, + "body": [], + "directives": [] + } + } + } + ], + "kind": "var" + } + ], + "directives": [] + } + } + ], + "directives": [ + { + "type": "Directive", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 0, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "value": "use strict", + "extra": { + "raw": "\"use strict\"", + "rawValue": "use strict" + } + } + } + ] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-generator-variable-declaration/options.json b/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-generator-variable-declaration/options.json deleted file mode 100644 index ad818f81f136..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-generator-variable-declaration/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Can not use 'yield' as identifier inside a generator (1:20)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-generator-variable-declaration/output.json b/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-generator-variable-declaration/output.json new file mode 100644 index 000000000000..770c2246fabb --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-generator-variable-declaration/output.json @@ -0,0 +1,142 @@ +{ + "type": "File", + "start": 0, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 28 + } + }, + "errors": [ + "SyntaxError: Can not use 'yield' as identifier inside a generator (1:20)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 28 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 28 + } + }, + "id": { + "type": "Identifier", + "start": 10, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 11 + }, + "identifierName": "g" + }, + "name": "g" + }, + "generator": true, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 14, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 28 + } + }, + "body": [ + { + "type": "VariableDeclaration", + "start": 16, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 20, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 20 + }, + "end": { + "line": 1, + "column": 25 + } + }, + "id": { + "type": "Identifier", + "start": 20, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 20 + }, + "end": { + "line": 1, + "column": 25 + }, + "identifierName": "yield" + }, + "name": "yield" + }, + "init": null + } + ], + "kind": "var" + } + ], + "directives": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-strict-array-pattern/options.json b/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-strict-array-pattern/options.json deleted file mode 100644 index e817f30acb5c..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-strict-array-pattern/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Unexpected reserved word 'yield' (1:16)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-strict-array-pattern/output.json b/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-strict-array-pattern/output.json new file mode 100644 index 000000000000..4a0cd5664566 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-strict-array-pattern/output.json @@ -0,0 +1,160 @@ +{ + "type": "File", + "start": 0, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 27 + } + }, + "errors": [ + "SyntaxError: Unexpected reserved word 'yield' (1:16)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 27 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 14, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 27 + } + }, + "expression": { + "type": "AssignmentExpression", + "start": 15, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "operator": "=", + "left": { + "type": "ArrayPattern", + "start": 15, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "elements": [ + { + "type": "Identifier", + "start": 16, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 21 + }, + "identifierName": "yield" + }, + "name": "yield" + } + ] + }, + "right": { + "type": "Identifier", + "start": 25, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 25 + }, + "end": { + "line": 1, + "column": 26 + }, + "identifierName": "x" + }, + "name": "x" + }, + "extra": { + "parenthesized": true, + "parenStart": 14 + } + } + } + ], + "directives": [ + { + "type": "Directive", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 0, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "value": "use strict", + "extra": { + "raw": "\"use strict\"", + "rawValue": "use strict" + } + } + } + ] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-strict-arrow-parameter-default/options.json b/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-strict-arrow-parameter-default/options.json deleted file mode 100644 index e80b46c31b86..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-strict-arrow-parameter-default/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Unexpected reserved word 'yield' (1:19)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-strict-arrow-parameter-default/output.json b/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-strict-arrow-parameter-default/output.json new file mode 100644 index 000000000000..b6b507c9e6cb --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-strict-arrow-parameter-default/output.json @@ -0,0 +1,175 @@ +{ + "type": "File", + "start": 0, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "errors": [ + "SyntaxError: Unexpected reserved word 'yield' (1:19)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 14, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "expression": { + "type": "ArrowFunctionExpression", + "start": 14, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "id": null, + "generator": false, + "async": false, + "params": [ + { + "type": "AssignmentPattern", + "start": 15, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "left": { + "type": "Identifier", + "start": 15, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 16 + }, + "identifierName": "x" + }, + "name": "x" + }, + "right": { + "type": "Identifier", + "start": 19, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 24 + }, + "identifierName": "yield" + }, + "name": "yield" + } + } + ], + "body": { + "type": "BlockStatement", + "start": 29, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 29 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "body": [], + "directives": [] + } + } + } + ], + "directives": [ + { + "type": "Directive", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 0, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "value": "use strict", + "extra": { + "raw": "\"use strict\"", + "rawValue": "use strict" + } + } + } + ] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-strict-arrow-parameter-name/options.json b/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-strict-arrow-parameter-name/options.json deleted file mode 100644 index 27b38d28f986..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-strict-arrow-parameter-name/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Unexpected reserved word 'yield' (1:15)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-strict-arrow-parameter-name/output.json b/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-strict-arrow-parameter-name/output.json new file mode 100644 index 000000000000..3c5b82bd6c7b --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-strict-arrow-parameter-name/output.json @@ -0,0 +1,146 @@ +{ + "type": "File", + "start": 0, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 27 + } + }, + "errors": [ + "SyntaxError: Unexpected reserved word 'yield' (1:15)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 27 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 14, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 27 + } + }, + "expression": { + "type": "ArrowFunctionExpression", + "start": 14, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 27 + } + }, + "id": null, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "start": 15, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 20 + }, + "identifierName": "yield" + }, + "name": "yield" + } + ], + "body": { + "type": "NumericLiteral", + "start": 25, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 25 + }, + "end": { + "line": 1, + "column": 27 + } + }, + "extra": { + "rawValue": 42, + "raw": "42" + }, + "value": 42 + } + } + } + ], + "directives": [ + { + "type": "Directive", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 0, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "value": "use strict", + "extra": { + "raw": "\"use strict\"", + "rawValue": "use strict" + } + } + } + ] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-strict-binding-element/options.json b/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-strict-binding-element/options.json deleted file mode 100644 index 5d111aab9319..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-strict-binding-element/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Unexpected reserved word 'yield' (1:23)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-strict-binding-element/output.json b/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-strict-binding-element/output.json new file mode 100644 index 000000000000..06d787bb4992 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-strict-binding-element/output.json @@ -0,0 +1,193 @@ +{ + "type": "File", + "start": 0, + "end": 37, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 37 + } + }, + "errors": [ + "SyntaxError: Unexpected reserved word 'yield' (1:23)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 37, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 37 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "VariableDeclaration", + "start": 14, + "end": 37, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 37 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 18, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "id": { + "type": "ObjectPattern", + "start": 18, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "properties": [ + { + "type": "ObjectProperty", + "start": 20, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 20 + }, + "end": { + "line": 1, + "column": 28 + } + }, + "method": false, + "key": { + "type": "Identifier", + "start": 20, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 20 + }, + "end": { + "line": 1, + "column": 21 + }, + "identifierName": "x" + }, + "name": "x" + }, + "computed": false, + "shorthand": false, + "value": { + "type": "Identifier", + "start": 23, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 23 + }, + "end": { + "line": 1, + "column": 28 + }, + "identifierName": "yield" + }, + "name": "yield" + } + } + ] + }, + "init": { + "type": "Identifier", + "start": 33, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 33 + }, + "end": { + "line": 1, + "column": 36 + }, + "identifierName": "foo" + }, + "name": "foo" + } + } + ], + "kind": "var" + } + ], + "directives": [ + { + "type": "Directive", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 0, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "value": "use strict", + "extra": { + "raw": "\"use strict\"", + "rawValue": "use strict" + } + } + } + ] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-strict-catch-parameter/options.json b/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-strict-catch-parameter/options.json deleted file mode 100644 index 01aca4591cea..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-strict-catch-parameter/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Unexpected reserved word 'yield' (1:28)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-strict-catch-parameter/output.json b/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-strict-catch-parameter/output.json new file mode 100644 index 000000000000..2b7952b2afe7 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-strict-catch-parameter/output.json @@ -0,0 +1,156 @@ +{ + "type": "File", + "start": 0, + "end": 37, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 37 + } + }, + "errors": [ + "SyntaxError: Unexpected reserved word 'yield' (1:28)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 37, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 37 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "TryStatement", + "start": 14, + "end": 37, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 37 + } + }, + "block": { + "type": "BlockStatement", + "start": 18, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "body": [], + "directives": [] + }, + "handler": { + "type": "CatchClause", + "start": 21, + "end": 37, + "loc": { + "start": { + "line": 1, + "column": 21 + }, + "end": { + "line": 1, + "column": 37 + } + }, + "param": { + "type": "Identifier", + "start": 28, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 28 + }, + "end": { + "line": 1, + "column": 33 + }, + "identifierName": "yield" + }, + "name": "yield" + }, + "body": { + "type": "BlockStatement", + "start": 35, + "end": 37, + "loc": { + "start": { + "line": 1, + "column": 35 + }, + "end": { + "line": 1, + "column": 37 + } + }, + "body": [], + "directives": [] + } + }, + "finalizer": null + } + ], + "directives": [ + { + "type": "Directive", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 0, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "value": "use strict", + "extra": { + "raw": "\"use strict\"", + "rawValue": "use strict" + } + } + } + ] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-strict-formal-parameter/options.json b/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-strict-formal-parameter/options.json deleted file mode 100644 index a4a677fb3136..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-strict-formal-parameter/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Unexpected reserved word 'yield' (1:25)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-strict-formal-parameter/output.json b/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-strict-formal-parameter/output.json new file mode 100644 index 000000000000..f936dc48abf9 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-strict-formal-parameter/output.json @@ -0,0 +1,144 @@ +{ + "type": "File", + "start": 0, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 34 + } + }, + "errors": [ + "SyntaxError: Unexpected reserved word 'yield' (1:25)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 34 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 14, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 34 + } + }, + "id": { + "type": "Identifier", + "start": 23, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 23 + }, + "end": { + "line": 1, + "column": 24 + }, + "identifierName": "f" + }, + "name": "f" + }, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "start": 25, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 25 + }, + "end": { + "line": 1, + "column": 30 + }, + "identifierName": "yield" + }, + "name": "yield" + } + ], + "body": { + "type": "BlockStatement", + "start": 32, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 34 + } + }, + "body": [], + "directives": [] + } + } + ], + "directives": [ + { + "type": "Directive", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 0, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "value": "use strict", + "extra": { + "raw": "\"use strict\"", + "rawValue": "use strict" + } + } + } + ] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-strict-function-declaration/options.json b/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-strict-function-declaration/options.json deleted file mode 100644 index e55b18eb4f07..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-strict-function-declaration/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Binding 'yield' in strict mode (1:9)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-strict-function-declaration/output.json b/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-strict-function-declaration/output.json new file mode 100644 index 000000000000..7f270919a446 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-strict-function-declaration/output.json @@ -0,0 +1,126 @@ +{ + "type": "File", + "start": 0, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 33 + } + }, + "errors": [ + "SyntaxError: Binding 'yield' in strict mode (1:9)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 33 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 33 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 14 + }, + "identifierName": "yield" + }, + "name": "yield" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 16, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 33 + } + }, + "body": [], + "directives": [ + { + "type": "Directive", + "start": 18, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 18, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "value": "use strict", + "extra": { + "raw": "\"use strict\"", + "rawValue": "use strict" + } + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-strict-function-expression/options.json b/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-strict-function-expression/options.json deleted file mode 100644 index 8928b8977517..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-strict-function-expression/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Binding 'yield' in strict mode (1:10)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-strict-function-expression/output.json b/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-strict-function-expression/output.json new file mode 100644 index 000000000000..d65f41baceea --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-strict-function-expression/output.json @@ -0,0 +1,145 @@ +{ + "type": "File", + "start": 0, + "end": 35, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 35 + } + }, + "errors": [ + "SyntaxError: Binding 'yield' in strict mode (1:10)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 35, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 35 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 35, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 35 + } + }, + "expression": { + "type": "FunctionExpression", + "start": 1, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 34 + } + }, + "id": { + "type": "Identifier", + "start": 10, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 15 + }, + "identifierName": "yield" + }, + "name": "yield" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 17, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 34 + } + }, + "body": [], + "directives": [ + { + "type": "Directive", + "start": 19, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 19, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "value": "use strict", + "extra": { + "raw": "\"use strict\"", + "rawValue": "use strict" + } + } + } + ] + }, + "extra": { + "parenthesized": true, + "parenStart": 0 + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-strict-identifier/options.json b/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-strict-identifier/options.json deleted file mode 100644 index 412431249548..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-strict-identifier/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Unexpected reserved word 'yield' (1:29)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-strict-identifier/output.json b/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-strict-identifier/output.json new file mode 100644 index 000000000000..0d4e30957667 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-strict-identifier/output.json @@ -0,0 +1,159 @@ +{ + "type": "File", + "start": 0, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "errors": [ + "SyntaxError: Unexpected reserved word 'yield' (1:29)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 14, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "id": { + "type": "Identifier", + "start": 23, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 23 + }, + "end": { + "line": 1, + "column": 24 + }, + "identifierName": "f" + }, + "name": "f" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 27, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 27 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 29, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 29 + }, + "end": { + "line": 1, + "column": 34 + } + }, + "expression": { + "type": "Identifier", + "start": 29, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 29 + }, + "end": { + "line": 1, + "column": 34 + }, + "identifierName": "yield" + }, + "name": "yield" + } + } + ], + "directives": [] + } + } + ], + "directives": [ + { + "type": "Directive", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 0, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "value": "use strict", + "extra": { + "raw": "\"use strict\"", + "rawValue": "use strict" + } + } + } + ] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-strict-lexical-declaration/options.json b/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-strict-lexical-declaration/options.json deleted file mode 100644 index 53a8921cb309..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-strict-lexical-declaration/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Unexpected reserved word 'yield' (1:18)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-strict-lexical-declaration/output.json b/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-strict-lexical-declaration/output.json new file mode 100644 index 000000000000..71c86eec827d --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-strict-lexical-declaration/output.json @@ -0,0 +1,144 @@ +{ + "type": "File", + "start": 0, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "errors": [ + "SyntaxError: Unexpected reserved word 'yield' (1:18)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "VariableDeclaration", + "start": 14, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 18, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 28 + } + }, + "id": { + "type": "Identifier", + "start": 18, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 23 + }, + "identifierName": "yield" + }, + "name": "yield" + }, + "init": { + "type": "NumericLiteral", + "start": 26, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 26 + }, + "end": { + "line": 1, + "column": 28 + } + }, + "extra": { + "rawValue": 42, + "raw": "42" + }, + "value": 42 + } + } + ], + "kind": "let" + } + ], + "directives": [ + { + "type": "Directive", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 0, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "value": "use strict", + "extra": { + "raw": "\"use strict\"", + "rawValue": "use strict" + } + } + } + ] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-strict-rest-parameter/options.json b/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-strict-rest-parameter/options.json deleted file mode 100644 index 01aca4591cea..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-strict-rest-parameter/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Unexpected reserved word 'yield' (1:28)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-strict-rest-parameter/output.json b/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-strict-rest-parameter/output.json new file mode 100644 index 000000000000..d246bfc86e6e --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-strict-rest-parameter/output.json @@ -0,0 +1,159 @@ +{ + "type": "File", + "start": 0, + "end": 37, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 37 + } + }, + "errors": [ + "SyntaxError: Unexpected reserved word 'yield' (1:28)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 37, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 37 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 14, + "end": 37, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 37 + } + }, + "id": { + "type": "Identifier", + "start": 23, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 23 + }, + "end": { + "line": 1, + "column": 24 + }, + "identifierName": "f" + }, + "name": "f" + }, + "generator": false, + "async": false, + "params": [ + { + "type": "RestElement", + "start": 25, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 25 + }, + "end": { + "line": 1, + "column": 33 + } + }, + "argument": { + "type": "Identifier", + "start": 28, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 28 + }, + "end": { + "line": 1, + "column": 33 + }, + "identifierName": "yield" + }, + "name": "yield" + } + } + ], + "body": { + "type": "BlockStatement", + "start": 35, + "end": 37, + "loc": { + "start": { + "line": 1, + "column": 35 + }, + "end": { + "line": 1, + "column": 37 + } + }, + "body": [], + "directives": [] + } + } + ], + "directives": [ + { + "type": "Directive", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 0, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "value": "use strict", + "extra": { + "raw": "\"use strict\"", + "rawValue": "use strict" + } + } + } + ] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-strict-variable-declaration/options.json b/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-strict-variable-declaration/options.json deleted file mode 100644 index 53a8921cb309..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-strict-variable-declaration/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Unexpected reserved word 'yield' (1:18)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-strict-variable-declaration/output.json b/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-strict-variable-declaration/output.json new file mode 100644 index 000000000000..0561e522bd7b --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/es2015-yield/invalid-yield-strict-variable-declaration/output.json @@ -0,0 +1,125 @@ +{ + "type": "File", + "start": 0, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "errors": [ + "SyntaxError: Unexpected reserved word 'yield' (1:18)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "VariableDeclaration", + "start": 14, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 18, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "id": { + "type": "Identifier", + "start": 18, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 23 + }, + "identifierName": "yield" + }, + "name": "yield" + }, + "init": null + } + ], + "kind": "var" + } + ], + "directives": [ + { + "type": "Directive", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 0, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "value": "use strict", + "extra": { + "raw": "\"use strict\"", + "rawValue": "use strict" + } + } + } + ] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-yield/yield-generator-arrow-default/options.json b/packages/babel-parser/test/fixtures/esprima/es2015-yield/yield-generator-arrow-default/options.json deleted file mode 100644 index f81e206da65d..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/es2015-yield/yield-generator-arrow-default/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Yield cannot be used as name inside a generator function (1:21)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-yield/yield-generator-arrow-default/output.json b/packages/babel-parser/test/fixtures/esprima/es2015-yield/yield-generator-arrow-default/output.json new file mode 100644 index 000000000000..c26b779c0207 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/es2015-yield/yield-generator-arrow-default/output.json @@ -0,0 +1,192 @@ +{ + "type": "File", + "start": 0, + "end": 35, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 35 + } + }, + "errors": [ + "SyntaxError: Yield cannot be used as name inside a generator function (1:21)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 35, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 35 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 35, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 35 + } + }, + "id": { + "type": "Identifier", + "start": 10, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 11 + }, + "identifierName": "g" + }, + "name": "g" + }, + "generator": true, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 14, + "end": 35, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 35 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 16, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 33 + } + }, + "expression": { + "type": "ArrowFunctionExpression", + "start": 16, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 33 + } + }, + "id": null, + "generator": false, + "async": false, + "params": [ + { + "type": "AssignmentPattern", + "start": 17, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "left": { + "type": "Identifier", + "start": 17, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 18 + }, + "identifierName": "x" + }, + "name": "x" + }, + "right": { + "type": "YieldExpression", + "start": 21, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 21 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "delegate": false, + "argument": null + } + } + ], + "body": { + "type": "BlockStatement", + "start": 31, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 31 + }, + "end": { + "line": 1, + "column": 33 + } + }, + "body": [], + "directives": [] + } + } + } + ], + "directives": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/expression-primary-array/migrated_0012/input.js b/packages/babel-parser/test/fixtures/esprima/expression-primary-array/migrated_0012/input.js index 79581f8529b7..cbd842119b94 100755 --- a/packages/babel-parser/test/fixtures/esprima/expression-primary-array/migrated_0012/input.js +++ b/packages/babel-parser/test/fixtures/esprima/expression-primary-array/migrated_0012/input.js @@ -1 +1 @@ -\u2163\u2161\u200A=\u2009[] +\u2163\u2161\u200A diff --git a/packages/babel-parser/test/fixtures/esprima/expression-primary-array/migrated_0012/options.json b/packages/babel-parser/test/fixtures/esprima/expression-primary-array/migrated_0012/options.json deleted file mode 100644 index abe9f835b84b..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/expression-primary-array/migrated_0012/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid Unicode escape (1:12)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/expression-primary-array/migrated_0012/output.json b/packages/babel-parser/test/fixtures/esprima/expression-primary-array/migrated_0012/output.json new file mode 100644 index 000000000000..ea30bc6a3013 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/expression-primary-array/migrated_0012/output.json @@ -0,0 +1,70 @@ +{ + "type": "File", + "start": 0, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "errors": [ + "SyntaxError: Invalid Unicode escape (1:12)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "expression": { + "type": "Identifier", + "start": 0, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 18 + }, + "identifierName": "ⅣⅡ " + }, + "name": "ⅣⅡ " + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/GH-1106-00/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/GH-1106-00/options.json deleted file mode 100644 index 8e0dce66eff8..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/GH-1106-00/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Bad character escape sequence (1:3)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/GH-1106-00/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/GH-1106-00/output.json new file mode 100644 index 000000000000..30ad8a2a0533 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/GH-1106-00/output.json @@ -0,0 +1,73 @@ +{ + "type": "File", + "start": 0, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "errors": [ + "SyntaxError: Bad character escape sequence (1:3)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [], + "directives": [ + { + "type": "Directive", + "start": 0, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 0, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "value": "\\x", + "extra": { + "raw": "\"\\x\"", + "rawValue": "\\x" + } + } + } + ] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/GH-1106-01/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/GH-1106-01/options.json deleted file mode 100644 index 8e0dce66eff8..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/GH-1106-01/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Bad character escape sequence (1:3)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/GH-1106-01/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/GH-1106-01/output.json new file mode 100644 index 000000000000..91bb0ab97d98 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/GH-1106-01/output.json @@ -0,0 +1,73 @@ +{ + "type": "File", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "errors": [ + "SyntaxError: Bad character escape sequence (1:3)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [], + "directives": [ + { + "type": "Directive", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 0, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "value": "\\x0", + "extra": { + "raw": "\"\\x0\"", + "rawValue": "\\x0" + } + } + } + ] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/GH-1106-02/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/GH-1106-02/options.json deleted file mode 100644 index 8e0dce66eff8..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/GH-1106-02/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Bad character escape sequence (1:3)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/GH-1106-02/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/GH-1106-02/output.json new file mode 100644 index 000000000000..422caf2f1ecf --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/GH-1106-02/output.json @@ -0,0 +1,73 @@ +{ + "type": "File", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "errors": [ + "SyntaxError: Bad character escape sequence (1:3)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [], + "directives": [ + { + "type": "Directive", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 0, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "value": "\\xx", + "extra": { + "raw": "\"\\xx\"", + "rawValue": "\\xx" + } + } + } + ] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/GH-1106-03/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/GH-1106-03/options.json deleted file mode 100644 index 8e0dce66eff8..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/GH-1106-03/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Bad character escape sequence (1:3)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/GH-1106-03/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/GH-1106-03/output.json new file mode 100644 index 000000000000..a00ba8fc772c --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/GH-1106-03/output.json @@ -0,0 +1,73 @@ +{ + "type": "File", + "start": 0, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "errors": [ + "SyntaxError: Bad character escape sequence (1:3)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [], + "directives": [ + { + "type": "Directive", + "start": 0, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 0, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "value": "\\u", + "extra": { + "raw": "\"\\u\"", + "rawValue": "\\u" + } + } + } + ] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/GH-1106-04/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/GH-1106-04/options.json deleted file mode 100644 index 8e0dce66eff8..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/GH-1106-04/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Bad character escape sequence (1:3)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/GH-1106-04/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/GH-1106-04/output.json new file mode 100644 index 000000000000..4158fada8f7f --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/GH-1106-04/output.json @@ -0,0 +1,73 @@ +{ + "type": "File", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "errors": [ + "SyntaxError: Bad character escape sequence (1:3)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [], + "directives": [ + { + "type": "Directive", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 0, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "value": "\\u0", + "extra": { + "raw": "\"\\u0\"", + "rawValue": "\\u0" + } + } + } + ] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/GH-1106-05/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/GH-1106-05/options.json deleted file mode 100644 index 8e0dce66eff8..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/GH-1106-05/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Bad character escape sequence (1:3)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/GH-1106-05/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/GH-1106-05/output.json new file mode 100644 index 000000000000..b36764ece66c --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/GH-1106-05/output.json @@ -0,0 +1,73 @@ +{ + "type": "File", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "errors": [ + "SyntaxError: Bad character escape sequence (1:3)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [], + "directives": [ + { + "type": "Directive", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 0, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "value": "\\ux", + "extra": { + "raw": "\"\\ux\"", + "rawValue": "\\ux" + } + } + } + ] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/GH-1106-06/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/GH-1106-06/options.json deleted file mode 100644 index 8e0dce66eff8..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/GH-1106-06/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Bad character escape sequence (1:3)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/GH-1106-06/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/GH-1106-06/output.json new file mode 100644 index 000000000000..b24d044db414 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/GH-1106-06/output.json @@ -0,0 +1,73 @@ +{ + "type": "File", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "errors": [ + "SyntaxError: Bad character escape sequence (1:3)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [], + "directives": [ + { + "type": "Directive", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "value": "\\u00", + "extra": { + "raw": "\"\\u00\"", + "rawValue": "\\u00" + } + } + } + ] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/GH-1106-07/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/GH-1106-07/options.json deleted file mode 100644 index 8e0dce66eff8..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/GH-1106-07/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Bad character escape sequence (1:3)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/GH-1106-07/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/GH-1106-07/output.json new file mode 100644 index 000000000000..eb3f631398dc --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/GH-1106-07/output.json @@ -0,0 +1,73 @@ +{ + "type": "File", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "errors": [ + "SyntaxError: Bad character escape sequence (1:3)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [], + "directives": [ + { + "type": "Directive", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "value": "\\u000", + "extra": { + "raw": "\"\\u000\"", + "rawValue": "\\u000" + } + } + } + ] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0002/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0002/options.json index 91bb1eef0c0d..aa61ff56c2b3 100644 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0002/options.json +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0002/options.json @@ -1,3 +1,3 @@ { - "throws": "Invalid number (1:0)" -} + "throws": "Identifier directly after number (1:2)" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0004/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0004/options.json deleted file mode 100644 index 91bb1eef0c0d..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0004/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid number (1:0)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0004/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0004/output.json new file mode 100644 index 000000000000..284fac8c4357 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0004/output.json @@ -0,0 +1,73 @@ +{ + "type": "File", + "start": 0, + "end": 2, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 2 + } + }, + "errors": [ + "SyntaxError: Invalid number (1:0)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 2, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 2 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 2, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 2 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 0, + "end": 2, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 2 + } + }, + "extra": { + "rawValue": 3, + "raw": "3e" + }, + "value": 3 + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0005/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0005/options.json deleted file mode 100644 index 91bb1eef0c0d..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0005/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid number (1:0)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0005/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0005/output.json new file mode 100644 index 000000000000..6b6e666b00ca --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0005/output.json @@ -0,0 +1,73 @@ +{ + "type": "File", + "start": 0, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "errors": [ + "SyntaxError: Invalid number (1:0)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 0, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "extra": { + "rawValue": 3, + "raw": "3e+" + }, + "value": 3 + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0006/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0006/options.json deleted file mode 100644 index 91bb1eef0c0d..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0006/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid number (1:0)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0006/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0006/output.json new file mode 100644 index 000000000000..b52b27d1ef37 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0006/output.json @@ -0,0 +1,73 @@ +{ + "type": "File", + "start": 0, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "errors": [ + "SyntaxError: Invalid number (1:0)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 0, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "extra": { + "rawValue": 3, + "raw": "3e-" + }, + "value": 3 + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0009/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0009/options.json deleted file mode 100644 index 1a0693338eee..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0009/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Expected number in radix 16 (1:2)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0009/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0009/output.json new file mode 100644 index 000000000000..ffcb3680fd0b --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0009/output.json @@ -0,0 +1,73 @@ +{ + "type": "File", + "start": 0, + "end": 2, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 2 + } + }, + "errors": [ + "SyntaxError: Expected number in radix 16 (1:2)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 2, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 2 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 2, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 2 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 0, + "end": 2, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 2 + } + }, + "extra": { + "rawValue": null, + "raw": "0x" + }, + "value": null + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0012/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0012/options.json deleted file mode 100644 index 3f09c36a5f1c..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0012/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Expected number in radix 8 (1:2)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0012/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0012/output.json new file mode 100644 index 000000000000..12a024fb2c03 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0012/output.json @@ -0,0 +1,73 @@ +{ + "type": "File", + "start": 0, + "end": 2, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 2 + } + }, + "errors": [ + "SyntaxError: Expected number in radix 8 (1:2)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 2, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 2 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 2, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 2 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 0, + "end": 2, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 2 + } + }, + "extra": { + "rawValue": null, + "raw": "0o" + }, + "value": null + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0013/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0013/options.json deleted file mode 100644 index 3f09c36a5f1c..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0013/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Expected number in radix 8 (1:2)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0013/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0013/output.json new file mode 100644 index 000000000000..5d2ed2d91388 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0013/output.json @@ -0,0 +1,73 @@ +{ + "type": "File", + "start": 0, + "end": 2, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 2 + } + }, + "errors": [ + "SyntaxError: Expected number in radix 8 (1:2)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 2, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 2 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 2, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 2 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 0, + "end": 2, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 2 + } + }, + "extra": { + "rawValue": null, + "raw": "0O" + }, + "value": null + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0014/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0014/options.json deleted file mode 100644 index 3f09c36a5f1c..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0014/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Expected number in radix 8 (1:2)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0014/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0014/output.json new file mode 100644 index 000000000000..4b91f320f950 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0014/output.json @@ -0,0 +1,73 @@ +{ + "type": "File", + "start": 0, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "errors": [ + "SyntaxError: Expected number in radix 8 (1:2)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 0, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "extra": { + "rawValue": 0, + "raw": "0o9" + }, + "value": 0 + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0015/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0015/options.json deleted file mode 100644 index d52d9cfac4bc..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0015/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Unexpected token, expected \";\" (1:3)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0015/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0015/output.json new file mode 100644 index 000000000000..9978c5342ef3 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0015/output.json @@ -0,0 +1,73 @@ +{ + "type": "File", + "start": 0, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "errors": [ + "SyntaxError: Expected number in radix 8 (1:3)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 0, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "extra": { + "rawValue": 8, + "raw": "0o18" + }, + "value": 8 + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0017/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0017/options.json deleted file mode 100644 index 40dc3da9a8f4..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0017/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Expected number in radix 2 (1:2)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0017/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0017/output.json new file mode 100644 index 000000000000..0688a297c669 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0017/output.json @@ -0,0 +1,73 @@ +{ + "type": "File", + "start": 0, + "end": 2, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 2 + } + }, + "errors": [ + "SyntaxError: Expected number in radix 2 (1:2)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 2, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 2 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 2, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 2 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 0, + "end": 2, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 2 + } + }, + "extra": { + "rawValue": null, + "raw": "0b" + }, + "value": null + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0019/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0019/options.json deleted file mode 100644 index 40dc3da9a8f4..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0019/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Expected number in radix 2 (1:2)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0019/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0019/output.json new file mode 100644 index 000000000000..7281fb745a17 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0019/output.json @@ -0,0 +1,73 @@ +{ + "type": "File", + "start": 0, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "errors": [ + "SyntaxError: Expected number in radix 2 (1:2)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 0, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "extra": { + "rawValue": 0, + "raw": "0b9" + }, + "value": 0 + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0020/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0020/options.json deleted file mode 100644 index d52d9cfac4bc..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0020/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Unexpected token, expected \";\" (1:3)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0020/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0020/output.json new file mode 100644 index 000000000000..25d711669b8b --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0020/output.json @@ -0,0 +1,73 @@ +{ + "type": "File", + "start": 0, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "errors": [ + "SyntaxError: Expected number in radix 2 (1:3)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 0, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "extra": { + "rawValue": 2, + "raw": "0b18" + }, + "value": 2 + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0021/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0021/options.json deleted file mode 100644 index d52d9cfac4bc..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0021/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Unexpected token, expected \";\" (1:3)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0021/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0021/output.json new file mode 100644 index 000000000000..379e9db894c0 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0021/output.json @@ -0,0 +1,73 @@ +{ + "type": "File", + "start": 0, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "errors": [ + "SyntaxError: Expected number in radix 2 (1:3)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 0, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "extra": { + "rawValue": 2, + "raw": "0b12" + }, + "value": 2 + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0022/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0022/options.json deleted file mode 100644 index 40dc3da9a8f4..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0022/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Expected number in radix 2 (1:2)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0022/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0022/output.json new file mode 100644 index 000000000000..c87719ade97e --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0022/output.json @@ -0,0 +1,73 @@ +{ + "type": "File", + "start": 0, + "end": 2, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 2 + } + }, + "errors": [ + "SyntaxError: Expected number in radix 2 (1:2)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 2, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 2 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 2, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 2 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 0, + "end": 2, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 2 + } + }, + "extra": { + "rawValue": null, + "raw": "0B" + }, + "value": null + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0024/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0024/options.json deleted file mode 100644 index 40dc3da9a8f4..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0024/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Expected number in radix 2 (1:2)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0024/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0024/output.json new file mode 100644 index 000000000000..e82ab6ace61a --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0024/output.json @@ -0,0 +1,73 @@ +{ + "type": "File", + "start": 0, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "errors": [ + "SyntaxError: Expected number in radix 2 (1:2)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 0, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "extra": { + "rawValue": 0, + "raw": "0B9" + }, + "value": 0 + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0025/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0025/options.json deleted file mode 100644 index d52d9cfac4bc..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0025/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Unexpected token, expected \";\" (1:3)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0025/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0025/output.json new file mode 100644 index 000000000000..3726afdc10d4 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0025/output.json @@ -0,0 +1,73 @@ +{ + "type": "File", + "start": 0, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "errors": [ + "SyntaxError: Expected number in radix 2 (1:3)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 0, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "extra": { + "rawValue": 2, + "raw": "0B18" + }, + "value": 2 + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0026/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0026/options.json deleted file mode 100644 index d52d9cfac4bc..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0026/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Unexpected token, expected \";\" (1:3)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0026/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0026/output.json new file mode 100644 index 000000000000..402fcffc9e54 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0026/output.json @@ -0,0 +1,73 @@ +{ + "type": "File", + "start": 0, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "errors": [ + "SyntaxError: Expected number in radix 2 (1:3)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 0, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "extra": { + "rawValue": 2, + "raw": "0B12" + }, + "value": 2 + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0027/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0027/options.json deleted file mode 100644 index 3f09c36a5f1c..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0027/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Expected number in radix 8 (1:2)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0027/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0027/output.json new file mode 100644 index 000000000000..af4105738ef8 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0027/output.json @@ -0,0 +1,73 @@ +{ + "type": "File", + "start": 0, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "errors": [ + "SyntaxError: Expected number in radix 8 (1:2)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 0, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "extra": { + "rawValue": 0, + "raw": "0O9" + }, + "value": 0 + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0028/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0028/options.json deleted file mode 100644 index d52d9cfac4bc..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0028/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Unexpected token, expected \";\" (1:3)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0028/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0028/output.json new file mode 100644 index 000000000000..617cc13b6615 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0028/output.json @@ -0,0 +1,73 @@ +{ + "type": "File", + "start": 0, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "errors": [ + "SyntaxError: Expected number in radix 8 (1:3)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 0, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "extra": { + "rawValue": 8, + "raw": "0O18" + }, + "value": 8 + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0032/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0032/options.json deleted file mode 100644 index 18c53b997b56..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0032/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Expecting Unicode escape sequence \\uXXXX (1:2)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0032/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0032/output.json new file mode 100644 index 000000000000..fbb1d3b5d554 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0032/output.json @@ -0,0 +1,70 @@ +{ + "type": "File", + "start": 0, + "end": 2, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 2 + } + }, + "errors": [ + "SyntaxError: Expecting Unicode escape sequence \\uXXXX (1:2)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 2, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 2 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 2, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 2 + } + }, + "expression": { + "type": "Identifier", + "start": 0, + "end": 2, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 2 + }, + "identifierName": "xx\\" + }, + "name": "xx\\" + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0033/input.js b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0033/input.js index fff580f2044f..0d9e932087f0 100644 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0033/input.js +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0033/input.js @@ -1 +1 @@ -x\\u005c +x\u005c diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0033/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0033/options.json deleted file mode 100644 index 18c53b997b56..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0033/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Expecting Unicode escape sequence \\uXXXX (1:2)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0033/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0033/output.json new file mode 100644 index 000000000000..fae32b78cde4 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0033/output.json @@ -0,0 +1,70 @@ +{ + "type": "File", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "errors": [ + "SyntaxError: Invalid Unicode escape (1:1)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "expression": { + "type": "Identifier", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + }, + "identifierName": "x\\" + }, + "name": "x\\" + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0034/input.js b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0034/input.js index 17112246786b..2999f29197cd 100644 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0034/input.js +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0034/input.js @@ -1 +1 @@ -x\\u002a +x\u002a diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0034/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0034/options.json deleted file mode 100644 index 18c53b997b56..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0034/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Expecting Unicode escape sequence \\uXXXX (1:2)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0034/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0034/output.json new file mode 100644 index 000000000000..37312f42ce97 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0034/output.json @@ -0,0 +1,70 @@ +{ + "type": "File", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "errors": [ + "SyntaxError: Invalid Unicode escape (1:1)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "expression": { + "type": "Identifier", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + }, + "identifierName": "x*" + }, + "name": "x*" + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0036/input.js b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0036/input.js index 3177052a225a..9cfc5e1cb357 100644 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0036/input.js +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0036/input.js @@ -1 +1 @@ -a\\u +a\u diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0036/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0036/options.json deleted file mode 100644 index 18c53b997b56..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0036/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Expecting Unicode escape sequence \\uXXXX (1:2)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0036/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0036/output.json new file mode 100644 index 000000000000..3fa5e0bfd57d --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0036/output.json @@ -0,0 +1,70 @@ +{ + "type": "File", + "start": 0, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "errors": [ + "SyntaxError: Bad character escape sequence (1:3)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "expression": { + "type": "Identifier", + "start": 0, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 3 + }, + "identifierName": "a" + }, + "name": "a" + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0037/input.js b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0037/input.js index d56d7c190d02..fa959cc0ecce 100644 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0037/input.js +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0037/input.js @@ -1 +1 @@ -\\ua +\ua diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0037/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0037/options.json deleted file mode 100644 index 381fd12ce2d0..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0037/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Expecting Unicode escape sequence \\uXXXX (1:1)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0037/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0037/output.json new file mode 100644 index 000000000000..be5c03381dd1 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0037/output.json @@ -0,0 +1,70 @@ +{ + "type": "File", + "start": 0, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "errors": [ + "SyntaxError: Bad character escape sequence (1:2)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "expression": { + "type": "Identifier", + "start": 0, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 3 + }, + "identifierName": "" + }, + "name": "" + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0041/input.js b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0041/input.js index 9a2dc1767685..7f54fa707500 100644 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0041/input.js +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0041/input.js @@ -1 +1 @@ -var x = /[a-z]/\\ux +var x = /[a-z]/\ux diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0041/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0041/options.json deleted file mode 100644 index adf556b0a352..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0041/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid regular expression flag (1:16)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0041/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0041/output.json new file mode 100644 index 000000000000..68d637a98170 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0041/output.json @@ -0,0 +1,109 @@ +{ + "type": "File", + "start": 0, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "errors": [ + "SyntaxError: Invalid regular expression flag (1:16)", + "SyntaxError: Invalid regular expression flag (1:18)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "VariableDeclaration", + "start": 0, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 4, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "id": { + "type": "Identifier", + "start": 4, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 5 + }, + "identifierName": "x" + }, + "name": "x" + }, + "init": { + "type": "RegExpLiteral", + "start": 8, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "extra": { + "raw": "/[a-z]/\\ux" + }, + "pattern": "[a-z]", + "flags": "\\ux" + } + } + ], + "kind": "var" + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0042/input.js b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0042/input.js index fdbf86f1d023..e8f66bb867d1 100644 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0042/input.js +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0042/input.js @@ -1 +1 @@ -var x = /[a-z\n]/\\ux +var x = /[a-z\n]/\ux diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0042/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0042/options.json deleted file mode 100644 index eae3757f4451..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0042/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid regular expression flag (1:18)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0042/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0042/output.json new file mode 100644 index 000000000000..c4e889cefe20 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0042/output.json @@ -0,0 +1,109 @@ +{ + "type": "File", + "start": 0, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "errors": [ + "SyntaxError: Invalid regular expression flag (1:18)", + "SyntaxError: Invalid regular expression flag (1:20)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "VariableDeclaration", + "start": 0, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 4, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "id": { + "type": "Identifier", + "start": 4, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 5 + }, + "identifierName": "x" + }, + "name": "x" + }, + "init": { + "type": "RegExpLiteral", + "start": 8, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "extra": { + "raw": "/[a-z\\n]/\\ux" + }, + "pattern": "[a-z\\n]", + "flags": "\\ux" + } + } + ], + "kind": "var" + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0043/input.js b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0043/input.js index e2a2d371e229..9a2dc1767685 100644 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0043/input.js +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0043/input.js @@ -1 +1 @@ -var x = /[a-z]/\\\\ux +var x = /[a-z]/\\ux diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0043/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0043/options.json deleted file mode 100644 index adf556b0a352..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0043/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid regular expression flag (1:16)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0043/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0043/output.json new file mode 100644 index 000000000000..76ef6d90fe84 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0043/output.json @@ -0,0 +1,110 @@ +{ + "type": "File", + "start": 0, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "errors": [ + "SyntaxError: Invalid regular expression flag (1:16)", + "SyntaxError: Invalid regular expression flag (1:17)", + "SyntaxError: Invalid regular expression flag (1:19)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "VariableDeclaration", + "start": 0, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 4, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "id": { + "type": "Identifier", + "start": 4, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 5 + }, + "identifierName": "x" + }, + "name": "x" + }, + "init": { + "type": "RegExpLiteral", + "start": 8, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "extra": { + "raw": "/[a-z]/\\\\ux" + }, + "pattern": "[a-z]", + "flags": "\\\\ux" + } + } + ], + "kind": "var" + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0044/input.js b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0044/input.js index fc48dffd74dc..405b48568aa8 100644 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0044/input.js +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0044/input.js @@ -1 +1 @@ -var x = /[P QR]/\\\\u0067 +var x = /[P QR]/\\u0067 diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0044/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0044/options.json deleted file mode 100644 index 080cb0eaaa8a..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0044/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid regular expression flag (1:17)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0044/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0044/output.json new file mode 100644 index 000000000000..430d18e24eac --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0044/output.json @@ -0,0 +1,113 @@ +{ + "type": "File", + "start": 0, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "errors": [ + "SyntaxError: Invalid regular expression flag (1:17)", + "SyntaxError: Invalid regular expression flag (1:18)", + "SyntaxError: Invalid regular expression flag (1:20)", + "SyntaxError: Invalid regular expression flag (1:21)", + "SyntaxError: Invalid regular expression flag (1:22)", + "SyntaxError: Invalid regular expression flag (1:23)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "VariableDeclaration", + "start": 0, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 4, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "id": { + "type": "Identifier", + "start": 4, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 5 + }, + "identifierName": "x" + }, + "name": "x" + }, + "init": { + "type": "RegExpLiteral", + "start": 8, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "extra": { + "raw": "/[P QR]/\\\\u0067" + }, + "pattern": "[P QR]", + "flags": "\\\\u0067" + } + } + ], + "kind": "var" + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0045/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0045/options.json deleted file mode 100644 index 6010e96ed144..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0045/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid left-hand side in assignment expression (1:0)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0045/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0045/output.json new file mode 100644 index 000000000000..99a3e74a04af --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0045/output.json @@ -0,0 +1,109 @@ +{ + "type": "File", + "start": 0, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "errors": [ + "SyntaxError: Invalid left-hand side in assignment expression (1:0)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "expression": { + "type": "AssignmentExpression", + "start": 0, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "operator": "=", + "left": { + "type": "NumericLiteral", + "start": 0, + "end": 1, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 1 + } + }, + "extra": { + "rawValue": 3, + "raw": "3" + }, + "value": 3 + }, + "right": { + "type": "NumericLiteral", + "start": 4, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "extra": { + "rawValue": 4, + "raw": "4" + }, + "value": 4 + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0046/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0046/options.json deleted file mode 100644 index 6010e96ed144..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0046/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid left-hand side in assignment expression (1:0)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0046/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0046/output.json new file mode 100644 index 000000000000..8770df4abba7 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0046/output.json @@ -0,0 +1,122 @@ +{ + "type": "File", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "errors": [ + "SyntaxError: Invalid left-hand side in assignment expression (1:0)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "expression": { + "type": "AssignmentExpression", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "operator": "=", + "left": { + "type": "CallExpression", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "callee": { + "type": "Identifier", + "start": 0, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 4 + }, + "identifierName": "func" + }, + "name": "func" + }, + "arguments": [] + }, + "right": { + "type": "NumericLiteral", + "start": 9, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "extra": { + "rawValue": 4, + "raw": "4" + }, + "value": 4 + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0047/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0047/options.json deleted file mode 100644 index 7c5f08eb9ba6..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0047/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid left-hand side in assignment expression (1:1)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0047/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0047/output.json new file mode 100644 index 000000000000..42614106f157 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0047/output.json @@ -0,0 +1,149 @@ +{ + "type": "File", + "start": 0, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "errors": [ + "SyntaxError: Invalid left-hand side in assignment expression (1:1)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "expression": { + "type": "AssignmentExpression", + "start": 0, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "operator": "=", + "left": { + "type": "BinaryExpression", + "start": 1, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "left": { + "type": "NumericLiteral", + "start": 1, + "end": 2, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 2 + } + }, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + }, + "operator": "+", + "right": { + "type": "NumericLiteral", + "start": 5, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + }, + "extra": { + "parenthesized": true, + "parenStart": 0 + } + }, + "right": { + "type": "NumericLiteral", + "start": 10, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "extra": { + "rawValue": 10, + "raw": "10" + }, + "value": 10 + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0048/input.js b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0048/input.js index 2bbf7ac4d47c..1d1226dada02 100644 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0048/input.js +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0048/input.js @@ -1 +1 @@ -\\u{110000} +\u{110000} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0048/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0048/options.json index 381fd12ce2d0..8dfd231d943b 100644 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0048/options.json +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0048/options.json @@ -1,3 +1,3 @@ { - "throws": "Expecting Unicode escape sequence \\uXXXX (1:1)" -} + "throws": "Invalid code point 1114112" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0049/input.js b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0049/input.js index 9943cc7906a5..aabe8d74272e 100644 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0049/input.js +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0049/input.js @@ -1 +1 @@ -\\u{} +\u{} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0049/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0049/options.json deleted file mode 100644 index 381fd12ce2d0..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0049/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Expecting Unicode escape sequence \\uXXXX (1:1)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0049/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0049/output.json new file mode 100644 index 000000000000..9d206b4f8475 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0049/output.json @@ -0,0 +1,70 @@ +{ + "type": "File", + "start": 0, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "errors": [ + "SyntaxError: Bad character escape sequence (1:3)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "expression": { + "type": "Identifier", + "start": 0, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 4 + }, + "identifierName": "" + }, + "name": "" + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0050/input.js b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0050/input.js index 5d4f24cb8271..170edba55da6 100644 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0050/input.js +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0050/input.js @@ -1 +1 @@ -\\u{FFFF +\u{FFFF diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0050/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0050/options.json deleted file mode 100644 index 381fd12ce2d0..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0050/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Expecting Unicode escape sequence \\uXXXX (1:1)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0050/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0050/output.json new file mode 100644 index 000000000000..252665de0e5e --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0050/output.json @@ -0,0 +1,70 @@ +{ + "type": "File", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "errors": [ + "SyntaxError: Bad character escape sequence (1:3)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "expression": { + "type": "Identifier", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + }, + "identifierName": "FFF" + }, + "name": "FFF" + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0051/input.js b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0051/input.js index 11e05c81c1e8..0c65088d077b 100644 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0051/input.js +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0051/input.js @@ -1 +1 @@ -\\u{FFZ} +\u{FFZ} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0051/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0051/options.json deleted file mode 100644 index 381fd12ce2d0..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0051/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Expecting Unicode escape sequence \\uXXXX (1:1)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0051/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0051/output.json new file mode 100644 index 000000000000..2c27554ffa56 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0051/output.json @@ -0,0 +1,70 @@ +{ + "type": "File", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "errors": [ + "SyntaxError: Bad character escape sequence (1:3)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "expression": { + "type": "Identifier", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + }, + "identifierName": "" + }, + "name": "" + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0052/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0052/options.json deleted file mode 100644 index c09dac1301de..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0052/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid left-hand side in postfix operation (1:0)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0052/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0052/output.json new file mode 100644 index 000000000000..ce2cb3d23d67 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0052/output.json @@ -0,0 +1,90 @@ +{ + "type": "File", + "start": 0, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "errors": [ + "SyntaxError: Invalid left-hand side in postfix operation (1:0)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "expression": { + "type": "UpdateExpression", + "start": 0, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "operator": "++", + "prefix": false, + "argument": { + "type": "NumericLiteral", + "start": 0, + "end": 1, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 1 + } + }, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0053/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0053/options.json deleted file mode 100644 index c09dac1301de..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0053/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid left-hand side in postfix operation (1:0)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0053/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0053/output.json new file mode 100644 index 000000000000..57d55fec0b5d --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0053/output.json @@ -0,0 +1,90 @@ +{ + "type": "File", + "start": 0, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "errors": [ + "SyntaxError: Invalid left-hand side in postfix operation (1:0)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "expression": { + "type": "UpdateExpression", + "start": 0, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "operator": "--", + "prefix": false, + "argument": { + "type": "NumericLiteral", + "start": 0, + "end": 1, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 1 + } + }, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0054/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0054/options.json deleted file mode 100644 index 515e441e8ea7..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0054/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid left-hand side in prefix operation (1:2)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0054/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0054/output.json new file mode 100644 index 000000000000..9a7a240c5b4a --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0054/output.json @@ -0,0 +1,90 @@ +{ + "type": "File", + "start": 0, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "errors": [ + "SyntaxError: Invalid left-hand side in prefix operation (1:2)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "expression": { + "type": "UpdateExpression", + "start": 0, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "operator": "++", + "prefix": true, + "argument": { + "type": "NumericLiteral", + "start": 2, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 2 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0055/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0055/options.json deleted file mode 100644 index 515e441e8ea7..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0055/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid left-hand side in prefix operation (1:2)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0055/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0055/output.json new file mode 100644 index 000000000000..85107220dae5 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0055/output.json @@ -0,0 +1,90 @@ +{ + "type": "File", + "start": 0, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "errors": [ + "SyntaxError: Invalid left-hand side in prefix operation (1:2)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "expression": { + "type": "UpdateExpression", + "start": 0, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "operator": "--", + "prefix": true, + "argument": { + "type": "NumericLiteral", + "start": 2, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 2 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0056/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0056/options.json deleted file mode 100644 index f8560a7de9d6..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0056/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid left-hand side in for-in statement (1:5)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0056/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0056/output.json new file mode 100644 index 000000000000..f9e5df01e76a --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0056/output.json @@ -0,0 +1,196 @@ +{ + "type": "File", + "start": 0, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "errors": [ + "SyntaxError: Invalid left-hand side in for-in statement (1:5)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ForInStatement", + "start": 0, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "left": { + "type": "BinaryExpression", + "start": 5, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "left": { + "type": "NumericLiteral", + "start": 5, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + }, + "operator": "+", + "right": { + "type": "NumericLiteral", + "start": 9, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + }, + "extra": { + "parenthesized": true, + "parenStart": 4 + } + }, + "right": { + "type": "Identifier", + "start": 15, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 19 + }, + "identifierName": "list" + }, + "name": "list" + }, + "body": { + "type": "ExpressionStatement", + "start": 21, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 21 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "expression": { + "type": "CallExpression", + "start": 21, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 21 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "callee": { + "type": "Identifier", + "start": 21, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 21 + }, + "end": { + "line": 1, + "column": 28 + }, + "identifierName": "process" + }, + "name": "process" + }, + "arguments": [ + { + "type": "Identifier", + "start": 29, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 29 + }, + "end": { + "line": 1, + "column": 30 + }, + "identifierName": "x" + }, + "name": "x" + } + ] + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0064/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0064/options.json deleted file mode 100644 index 2b91be8d5115..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0064/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Unexpected keyword 'if' (1:4)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0064/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0064/output.json new file mode 100644 index 000000000000..ac910291b748 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0064/output.json @@ -0,0 +1,108 @@ +{ + "type": "File", + "start": 0, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "errors": [ + "SyntaxError: Unexpected keyword 'if' (1:4)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "VariableDeclaration", + "start": 0, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 4, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "id": { + "type": "Identifier", + "start": 4, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 6 + }, + "identifierName": "if" + }, + "name": "if" + }, + "init": { + "type": "NumericLiteral", + "start": 9, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "extra": { + "rawValue": 42, + "raw": "42" + }, + "value": 42 + } + } + ], + "kind": "var" + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0066/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0066/options.json deleted file mode 100644 index 6010e96ed144..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0066/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid left-hand side in assignment expression (1:0)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0066/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0066/output.json new file mode 100644 index 000000000000..56547ff7be13 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0066/output.json @@ -0,0 +1,142 @@ +{ + "type": "File", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "errors": [ + "SyntaxError: Invalid left-hand side in assignment expression (1:0)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "expression": { + "type": "AssignmentExpression", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "operator": "=", + "left": { + "type": "BinaryExpression", + "start": 0, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "left": { + "type": "Identifier", + "start": 0, + "end": 1, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 1 + }, + "identifierName": "i" + }, + "name": "i" + }, + "operator": "+", + "right": { + "type": "NumericLiteral", + "start": 4, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "extra": { + "rawValue": 2, + "raw": "2" + }, + "value": 2 + } + }, + "right": { + "type": "NumericLiteral", + "start": 8, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "extra": { + "rawValue": 42, + "raw": "42" + }, + "value": 42 + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0067/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0067/options.json deleted file mode 100644 index 6010e96ed144..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0067/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid left-hand side in assignment expression (1:0)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0067/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0067/output.json new file mode 100644 index 000000000000..ece139488ea0 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0067/output.json @@ -0,0 +1,123 @@ +{ + "type": "File", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "errors": [ + "SyntaxError: Invalid left-hand side in assignment expression (1:0)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "expression": { + "type": "AssignmentExpression", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "operator": "=", + "left": { + "type": "UnaryExpression", + "start": 0, + "end": 2, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 2 + } + }, + "operator": "+", + "prefix": true, + "argument": { + "type": "Identifier", + "start": 1, + "end": 2, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 2 + }, + "identifierName": "i" + }, + "name": "i" + } + }, + "right": { + "type": "NumericLiteral", + "start": 5, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "extra": { + "rawValue": 42, + "raw": "42" + }, + "value": 42 + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0075/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0075/options.json index aa55ec4f840f..5a02a61446d2 100644 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0075/options.json +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0075/options.json @@ -1,3 +1,5 @@ { - "throws": "setter must have exactly one formal parameter (1:3)" -} + "plugins": [ + "estree" + ] +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0075/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0075/output.json new file mode 100644 index 000000000000..b0ad15758245 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0075/output.json @@ -0,0 +1,145 @@ +{ + "type": "File", + "start": 0, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "errors": [ + "SyntaxError: setter must have exactly one formal parameter (1:3)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "expression": { + "type": "ObjectExpression", + "start": 1, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "properties": [ + { + "type": "Property", + "start": 3, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "method": false, + "key": { + "type": "Identifier", + "start": 7, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 8 + }, + "identifierName": "s" + }, + "name": "s" + }, + "computed": false, + "kind": "set", + "value": { + "type": "FunctionExpression", + "start": 8, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "id": null, + "generator": false, + "async": false, + "expression": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 11, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "body": [] + } + }, + "shorthand": false + } + ], + "extra": { + "parenthesized": true, + "parenStart": 0 + } + } + } + ] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0087/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0087/options.json deleted file mode 100644 index 92845f5f2081..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0087/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Assigning to 'eval' in strict mode (1:15)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0087/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0087/output.json new file mode 100644 index 000000000000..3731ec6d7b75 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0087/output.json @@ -0,0 +1,182 @@ +{ + "type": "File", + "start": 0, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "errors": [ + "SyntaxError: Assigning to 'eval' in strict mode (1:15)", + "SyntaxError: Binding 'eval' in strict mode (1:15)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 14, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "expression": { + "type": "ArrowFunctionExpression", + "start": 14, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "id": null, + "generator": false, + "async": false, + "params": [ + { + "type": "AssignmentPattern", + "start": 15, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "left": { + "type": "Identifier", + "start": 15, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 19 + }, + "identifierName": "eval" + }, + "name": "eval" + }, + "right": { + "type": "NumericLiteral", + "start": 22, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 22 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "extra": { + "rawValue": 10, + "raw": "10" + }, + "value": 10 + } + } + ], + "body": { + "type": "NumericLiteral", + "start": 29, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 29 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "extra": { + "rawValue": 42, + "raw": "42" + }, + "value": 42 + } + } + } + ], + "directives": [ + { + "type": "Directive", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 0, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "value": "use strict", + "extra": { + "raw": "\"use strict\"", + "rawValue": "use strict" + } + } + } + ] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0088/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0088/options.json deleted file mode 100644 index ad54c428a2f9..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0088/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Binding 'eval' in strict mode (1:14)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0088/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0088/output.json new file mode 100644 index 000000000000..dbffe6547ab5 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0088/output.json @@ -0,0 +1,146 @@ +{ + "type": "File", + "start": 0, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "errors": [ + "SyntaxError: Binding 'eval' in strict mode (1:14)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 14, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "expression": { + "type": "ArrowFunctionExpression", + "start": 14, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "id": null, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "start": 14, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 18 + }, + "identifierName": "eval" + }, + "name": "eval" + } + ], + "body": { + "type": "NumericLiteral", + "start": 22, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 22 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "extra": { + "rawValue": 42, + "raw": "42" + }, + "value": 42 + } + } + } + ], + "directives": [ + { + "type": "Directive", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 0, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "value": "use strict", + "extra": { + "raw": "\"use strict\"", + "rawValue": "use strict" + } + } + } + ] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0089/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0089/options.json deleted file mode 100644 index bfa08eae293e..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0089/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Binding 'arguments' in strict mode (1:14)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0089/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0089/output.json new file mode 100644 index 000000000000..1b3ed15f002e --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0089/output.json @@ -0,0 +1,146 @@ +{ + "type": "File", + "start": 0, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "errors": [ + "SyntaxError: Binding 'arguments' in strict mode (1:14)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 14, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "expression": { + "type": "ArrowFunctionExpression", + "start": 14, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "id": null, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "start": 14, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 23 + }, + "identifierName": "arguments" + }, + "name": "arguments" + } + ], + "body": { + "type": "NumericLiteral", + "start": 27, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 27 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "extra": { + "rawValue": 42, + "raw": "42" + }, + "value": 42 + } + } + } + ], + "directives": [ + { + "type": "Directive", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 0, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "value": "use strict", + "extra": { + "raw": "\"use strict\"", + "rawValue": "use strict" + } + } + } + ] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0090/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0090/options.json deleted file mode 100644 index 794c4864d4e5..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0090/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Binding 'eval' in strict mode (1:15)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0090/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0090/output.json new file mode 100644 index 000000000000..6b7ae83c0ad2 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0090/output.json @@ -0,0 +1,163 @@ +{ + "type": "File", + "start": 0, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "errors": [ + "SyntaxError: Binding 'eval' in strict mode (1:15)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 14, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "expression": { + "type": "ArrowFunctionExpression", + "start": 14, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "id": null, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "start": 15, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 19 + }, + "identifierName": "eval" + }, + "name": "eval" + }, + { + "type": "Identifier", + "start": 21, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 21 + }, + "end": { + "line": 1, + "column": 22 + }, + "identifierName": "a" + }, + "name": "a" + } + ], + "body": { + "type": "NumericLiteral", + "start": 27, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 27 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "extra": { + "rawValue": 42, + "raw": "42" + }, + "value": 42 + } + } + } + ], + "directives": [ + { + "type": "Directive", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 0, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "value": "use strict", + "extra": { + "raw": "\"use strict\"", + "rawValue": "use strict" + } + } + } + ] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0091/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0091/options.json deleted file mode 100644 index 212d35fcb5fe..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0091/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Binding 'arguments' in strict mode (1:15)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0091/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0091/output.json new file mode 100644 index 000000000000..c681755fb108 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0091/output.json @@ -0,0 +1,163 @@ +{ + "type": "File", + "start": 0, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 34 + } + }, + "errors": [ + "SyntaxError: Binding 'arguments' in strict mode (1:15)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 34 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 14, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 34 + } + }, + "expression": { + "type": "ArrowFunctionExpression", + "start": 14, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 34 + } + }, + "id": null, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "start": 15, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 24 + }, + "identifierName": "arguments" + }, + "name": "arguments" + }, + { + "type": "Identifier", + "start": 26, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 26 + }, + "end": { + "line": 1, + "column": 27 + }, + "identifierName": "a" + }, + "name": "a" + } + ], + "body": { + "type": "NumericLiteral", + "start": 32, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 34 + } + }, + "extra": { + "rawValue": 42, + "raw": "42" + }, + "value": 42 + } + } + } + ], + "directives": [ + { + "type": "Directive", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 0, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "value": "use strict", + "extra": { + "raw": "\"use strict\"", + "rawValue": "use strict" + } + } + } + ] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0092/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0092/options.json deleted file mode 100644 index 368006ae58bd..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0092/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Argument name clash (1:4)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0092/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0092/output.json new file mode 100644 index 000000000000..78da40f6d8c7 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0092/output.json @@ -0,0 +1,127 @@ +{ + "type": "File", + "start": 0, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "errors": [ + "SyntaxError: Argument name clash (1:4)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "expression": { + "type": "ArrowFunctionExpression", + "start": 0, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "id": null, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "start": 1, + "end": 2, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 2 + }, + "identifierName": "a" + }, + "name": "a" + }, + { + "type": "Identifier", + "start": 4, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 5 + }, + "identifierName": "a" + }, + "name": "a" + } + ], + "body": { + "type": "NumericLiteral", + "start": 10, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "extra": { + "rawValue": 42, + "raw": "42" + }, + "value": 42 + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0093/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0093/options.json deleted file mode 100644 index b99fd35222b1..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0093/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Argument name clash (1:18)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0093/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0093/output.json new file mode 100644 index 000000000000..3a5f60bdddea --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0093/output.json @@ -0,0 +1,163 @@ +{ + "type": "File", + "start": 0, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "errors": [ + "SyntaxError: Argument name clash (1:18)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 14, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "expression": { + "type": "ArrowFunctionExpression", + "start": 14, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "id": null, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "start": 15, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 16 + }, + "identifierName": "a" + }, + "name": "a" + }, + { + "type": "Identifier", + "start": 18, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 19 + }, + "identifierName": "a" + }, + "name": "a" + } + ], + "body": { + "type": "NumericLiteral", + "start": 24, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 24 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "extra": { + "rawValue": 42, + "raw": "42" + }, + "value": 42 + } + } + } + ], + "directives": [ + { + "type": "Directive", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 0, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "value": "use strict", + "extra": { + "raw": "\"use strict\"", + "rawValue": "use strict" + } + } + } + ] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0094/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0094/options.json deleted file mode 100644 index 79a05e62290e..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0094/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Legacy octal literals are not allowed in strict mode (1:21)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0094/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0094/output.json new file mode 100644 index 000000000000..18c0889f74b8 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0094/output.json @@ -0,0 +1,146 @@ +{ + "type": "File", + "start": 0, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "errors": [ + "SyntaxError: Legacy octal literals are not allowed in strict mode (1:21)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 14, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "expression": { + "type": "ArrowFunctionExpression", + "start": 14, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "id": null, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "start": 15, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 16 + }, + "identifierName": "a" + }, + "name": "a" + } + ], + "body": { + "type": "NumericLiteral", + "start": 21, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 21 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "extra": { + "rawValue": 0, + "raw": "00" + }, + "value": 0 + } + } + } + ], + "directives": [ + { + "type": "Directive", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 0, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "value": "use strict", + "extra": { + "raw": "\"use strict\"", + "rawValue": "use strict" + } + } + } + ] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0098/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0098/options.json deleted file mode 100644 index 99ffc0de0153..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0098/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid left-hand side in arrow function parameters (1:1)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0098/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0098/output.json new file mode 100644 index 000000000000..a7c444dfbcdc --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0098/output.json @@ -0,0 +1,113 @@ +{ + "type": "File", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "errors": [ + "SyntaxError: Binding invalid left-hand side in function parameter list (1:1)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "expression": { + "type": "ArrowFunctionExpression", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "id": null, + "generator": false, + "async": false, + "params": [ + { + "type": "NumericLiteral", + "start": 1, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "extra": { + "rawValue": 10, + "raw": "10" + }, + "value": 10 + } + ], + "body": { + "type": "NumericLiteral", + "start": 8, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "extra": { + "rawValue": 0, + "raw": "00" + }, + "value": 0 + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0099/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0099/options.json deleted file mode 100644 index 99ffc0de0153..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0099/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid left-hand side in arrow function parameters (1:1)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0099/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0099/output.json new file mode 100644 index 000000000000..2d80f047d283 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0099/output.json @@ -0,0 +1,134 @@ +{ + "type": "File", + "start": 0, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "errors": [ + "SyntaxError: Binding invalid left-hand side in function parameter list (1:1)", + "SyntaxError: Binding invalid left-hand side in function parameter list (1:5)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "expression": { + "type": "ArrowFunctionExpression", + "start": 0, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "id": null, + "generator": false, + "async": false, + "params": [ + { + "type": "NumericLiteral", + "start": 1, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "extra": { + "rawValue": 10, + "raw": "10" + }, + "value": 10 + }, + { + "type": "NumericLiteral", + "start": 5, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "extra": { + "rawValue": 20, + "raw": "20" + }, + "value": 20 + } + ], + "body": { + "type": "NumericLiteral", + "start": 12, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "extra": { + "rawValue": 0, + "raw": "00" + }, + "value": 0 + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0100/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0100/options.json deleted file mode 100644 index 794c4864d4e5..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0100/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Binding 'eval' in strict mode (1:15)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0100/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0100/output.json new file mode 100644 index 000000000000..49e0835c1bfc --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0100/output.json @@ -0,0 +1,146 @@ +{ + "type": "File", + "start": 0, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "errors": [ + "SyntaxError: Binding 'eval' in strict mode (1:15)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 14, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "expression": { + "type": "ArrowFunctionExpression", + "start": 14, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "id": null, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "start": 15, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 19 + }, + "identifierName": "eval" + }, + "name": "eval" + } + ], + "body": { + "type": "NumericLiteral", + "start": 24, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 24 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "extra": { + "rawValue": 42, + "raw": "42" + }, + "value": 42 + } + } + } + ], + "directives": [ + { + "type": "Directive", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 0, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "value": "use strict", + "extra": { + "raw": "\"use strict\"", + "rawValue": "use strict" + } + } + } + ] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0101/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0101/options.json deleted file mode 100644 index cc2bef2a9a34..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0101/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Binding 'eval' in strict mode (1:1)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0101/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0101/output.json new file mode 100644 index 000000000000..85866aeddd23 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0101/output.json @@ -0,0 +1,179 @@ +{ + "type": "File", + "start": 0, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "errors": [ + "SyntaxError: Binding 'eval' in strict mode (1:1)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "expression": { + "type": "ArrowFunctionExpression", + "start": 0, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "id": null, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "start": 1, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 5 + }, + "identifierName": "eval" + }, + "name": "eval" + } + ], + "body": { + "type": "BlockStatement", + "start": 10, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 26, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 26 + }, + "end": { + "line": 1, + "column": 28 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 26, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 26 + }, + "end": { + "line": 1, + "column": 28 + } + }, + "extra": { + "rawValue": 42, + "raw": "42" + }, + "value": 42 + } + } + ], + "directives": [ + { + "type": "Directive", + "start": 12, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 25 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 12, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "value": "use strict", + "extra": { + "raw": "\"use strict\"", + "rawValue": "use strict" + } + } + } + ] + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0116/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0116/options.json deleted file mode 100644 index 701f9fe8f27a..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0116/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Unsyntactic break (1:0)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0116/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0116/output.json new file mode 100644 index 000000000000..d3a105c584dd --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0116/output.json @@ -0,0 +1,54 @@ +{ + "type": "File", + "start": 0, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "errors": [ + "SyntaxError: Unsyntactic break (1:0)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "BreakStatement", + "start": 0, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "label": null + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0118/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0118/options.json deleted file mode 100644 index de66853a7a3d..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0118/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Unsyntactic continue (1:0)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0118/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0118/output.json new file mode 100644 index 000000000000..c32c5b089115 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0118/output.json @@ -0,0 +1,54 @@ +{ + "type": "File", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "errors": [ + "SyntaxError: Unsyntactic continue (1:0)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ContinueStatement", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "label": null + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0125/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0125/options.json deleted file mode 100644 index f8560a7de9d6..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0125/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid left-hand side in for-in statement (1:5)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0125/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0125/output.json new file mode 100644 index 000000000000..3844a4d151a7 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0125/output.json @@ -0,0 +1,137 @@ +{ + "type": "File", + "start": 0, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "errors": [ + "SyntaxError: Invalid left-hand side in for-in statement (1:5)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ForInStatement", + "start": 0, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "left": { + "type": "BinaryExpression", + "start": 5, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "left": { + "type": "Identifier", + "start": 5, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 6 + }, + "identifierName": "i" + }, + "name": "i" + }, + "operator": "+", + "right": { + "type": "NumericLiteral", + "start": 9, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + } + }, + "right": { + "type": "ObjectExpression", + "start": 14, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "properties": [] + }, + "body": { + "type": "EmptyStatement", + "start": 17, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 18 + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0126/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0126/options.json deleted file mode 100644 index f8560a7de9d6..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0126/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid left-hand side in for-in statement (1:5)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0126/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0126/output.json new file mode 100644 index 000000000000..9d008175f644 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0126/output.json @@ -0,0 +1,118 @@ +{ + "type": "File", + "start": 0, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "errors": [ + "SyntaxError: Invalid left-hand side in for-in statement (1:5)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ForInStatement", + "start": 0, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "left": { + "type": "UnaryExpression", + "start": 5, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "operator": "+", + "prefix": true, + "argument": { + "type": "Identifier", + "start": 6, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + }, + "identifierName": "i" + }, + "name": "i" + } + }, + "right": { + "type": "ObjectExpression", + "start": 11, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "properties": [] + }, + "body": { + "type": "EmptyStatement", + "start": 14, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 15 + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0133/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0133/options.json deleted file mode 100644 index 429d96ca3f9a..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0133/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Missing catch or finally clause (1:0)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0133/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0133/output.json new file mode 100644 index 000000000000..3d2ee0555b85 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0133/output.json @@ -0,0 +1,72 @@ +{ + "type": "File", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "errors": [ + "SyntaxError: Missing catch or finally clause (1:0)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "TryStatement", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "block": { + "type": "BlockStatement", + "start": 4, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "body": [], + "directives": [] + }, + "handler": null, + "finalizer": null + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0137/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0137/options.json deleted file mode 100644 index 82bcfe621c49..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0137/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid Unicode escape (1:0)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0137/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0137/output.json new file mode 100644 index 000000000000..237da8c03a78 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0137/output.json @@ -0,0 +1,106 @@ +{ + "type": "File", + "start": 0, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "errors": [ + "SyntaxError: Invalid Unicode escape (1:0)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "expression": { + "type": "AssignmentExpression", + "start": 0, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "operator": "=", + "left": { + "type": "Identifier", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + }, + "identifierName": "‿" + }, + "name": "‿" + }, + "right": { + "type": "NumericLiteral", + "start": 9, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "extra": { + "rawValue": 10, + "raw": "10" + }, + "value": 10 + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0142/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0142/options.json deleted file mode 100644 index 97818d2eea7e..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0142/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Lexical declaration cannot appear in a single-statement context (1:9)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0142/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0142/output.json new file mode 100644 index 000000000000..c273b86361e0 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0142/output.json @@ -0,0 +1,140 @@ +{ + "type": "File", + "start": 0, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "errors": [ + "SyntaxError: Lexical declaration cannot appear in a single-statement context (1:9)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "IfStatement", + "start": 0, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "test": { + "type": "BooleanLiteral", + "start": 3, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "value": true + }, + "consequent": { + "type": "VariableDeclaration", + "start": 9, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 15, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "id": { + "type": "Identifier", + "start": 15, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 16 + }, + "identifierName": "a" + }, + "name": "a" + }, + "init": { + "type": "NumericLiteral", + "start": 19, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + } + } + ], + "kind": "const" + }, + "alternate": null + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0143/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0143/options.json deleted file mode 100644 index aadfa63716c2..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0143/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Multiple default clauses (1:22)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0143/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0143/output.json new file mode 100644 index 000000000000..c90c4eefdc6f --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0143/output.json @@ -0,0 +1,106 @@ +{ + "type": "File", + "start": 0, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "errors": [ + "SyntaxError: Multiple default clauses (1:22)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "SwitchStatement", + "start": 0, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "discriminant": { + "type": "Identifier", + "start": 8, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 9 + }, + "identifierName": "c" + }, + "name": "c" + }, + "cases": [ + { + "type": "SwitchCase", + "start": 13, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "consequent": [], + "test": null + }, + { + "type": "SwitchCase", + "start": 22, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 22 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "consequent": [], + "test": null + } + ] + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0162/input.js b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0162/input.js index adcf3cef4357..57ddad2aec5d 100644 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0162/input.js +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0162/input.js @@ -1 +1 @@ -\\ +\ diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0162/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0162/options.json deleted file mode 100644 index 381fd12ce2d0..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0162/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Expecting Unicode escape sequence \\uXXXX (1:1)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0162/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0162/output.json new file mode 100644 index 000000000000..8644ccf99c0e --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0162/output.json @@ -0,0 +1,70 @@ +{ + "type": "File", + "start": 0, + "end": 1, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 1 + } + }, + "errors": [ + "SyntaxError: Expecting Unicode escape sequence \\uXXXX (1:1)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 1, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 1 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 1, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 1 + } + }, + "expression": { + "type": "Identifier", + "start": 0, + "end": 1, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 1 + }, + "identifierName": "\\" + }, + "name": "\\" + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0163/input.js b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0163/input.js index b9e12b2eff54..65bd7cf67b3f 100644 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0163/input.js +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0163/input.js @@ -1 +1 @@ -\\u005c +\u005c diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0163/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0163/options.json deleted file mode 100644 index 381fd12ce2d0..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0163/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Expecting Unicode escape sequence \\uXXXX (1:1)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0163/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0163/output.json new file mode 100644 index 000000000000..d44909ca998a --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0163/output.json @@ -0,0 +1,70 @@ +{ + "type": "File", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "errors": [ + "SyntaxError: Invalid Unicode escape (1:0)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "expression": { + "type": "Identifier", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + }, + "identifierName": "\\" + }, + "name": "\\" + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0164/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0164/options.json deleted file mode 100644 index 381fd12ce2d0..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0164/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Expecting Unicode escape sequence \\uXXXX (1:1)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0164/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0164/output.json new file mode 100644 index 000000000000..38cc0c05b021 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0164/output.json @@ -0,0 +1,70 @@ +{ + "type": "File", + "start": 0, + "end": 2, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 2 + } + }, + "errors": [ + "SyntaxError: Expecting Unicode escape sequence \\uXXXX (1:1)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 2, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 2 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 2, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 2 + } + }, + "expression": { + "type": "Identifier", + "start": 0, + "end": 2, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 2 + }, + "identifierName": "\\x" + }, + "name": "\\x" + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0165/input.js b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0165/input.js index a6e819ccd18b..ecb0a859c956 100644 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0165/input.js +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0165/input.js @@ -1 +1 @@ -\\u0000 +\u0000 diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0165/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0165/options.json deleted file mode 100644 index 381fd12ce2d0..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0165/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Expecting Unicode escape sequence \\uXXXX (1:1)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0165/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0165/output.json new file mode 100644 index 000000000000..380e6ec698ef --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0165/output.json @@ -0,0 +1,70 @@ +{ + "type": "File", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "errors": [ + "SyntaxError: Invalid Unicode escape (1:0)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "expression": { + "type": "Identifier", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + }, + "identifierName": "\u0000" + }, + "name": "\u0000" + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0166/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0166/options.json deleted file mode 100644 index 82bcfe621c49..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0166/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid Unicode escape (1:0)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0166/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0166/output.json new file mode 100644 index 000000000000..d528d79e32d4 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0166/output.json @@ -0,0 +1,102 @@ +{ + "type": "File", + "start": 0, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "errors": [ + "SyntaxError: Invalid Unicode escape (1:0)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "expression": { + "type": "AssignmentExpression", + "start": 0, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "operator": "=", + "left": { + "type": "Identifier", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + }, + "identifierName": "‌" + }, + "name": "‌" + }, + "right": { + "type": "ArrayExpression", + "start": 9, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "elements": [] + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0167/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0167/options.json deleted file mode 100644 index 82bcfe621c49..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0167/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid Unicode escape (1:0)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0167/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0167/output.json new file mode 100644 index 000000000000..91544094b698 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0167/output.json @@ -0,0 +1,102 @@ +{ + "type": "File", + "start": 0, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "errors": [ + "SyntaxError: Invalid Unicode escape (1:0)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "expression": { + "type": "AssignmentExpression", + "start": 0, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "operator": "=", + "left": { + "type": "Identifier", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + }, + "identifierName": "‍" + }, + "name": "‍" + }, + "right": { + "type": "ArrayExpression", + "start": 9, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "elements": [] + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0169/input.js b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0169/input.js index 2775e915bb92..1ef32f79a66e 100644 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0169/input.js +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0169/input.js @@ -1 +1 @@ -"\\u +"\u diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0171/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0171/options.json deleted file mode 100644 index f9d29c7f328c..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0171/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "'return' outside of function (1:0)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0171/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0171/output.json new file mode 100644 index 000000000000..e43da2374537 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0171/output.json @@ -0,0 +1,54 @@ +{ + "type": "File", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "errors": [ + "SyntaxError: 'return' outside of function (1:0)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ReturnStatement", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "argument": null + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0172/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0172/options.json deleted file mode 100644 index 701f9fe8f27a..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0172/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Unsyntactic break (1:0)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0172/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0172/output.json new file mode 100644 index 000000000000..d3a105c584dd --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0172/output.json @@ -0,0 +1,54 @@ +{ + "type": "File", + "start": 0, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "errors": [ + "SyntaxError: Unsyntactic break (1:0)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "BreakStatement", + "start": 0, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "label": null + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0173/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0173/options.json deleted file mode 100644 index de66853a7a3d..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0173/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Unsyntactic continue (1:0)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0173/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0173/output.json new file mode 100644 index 000000000000..c32c5b089115 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0173/output.json @@ -0,0 +1,54 @@ +{ + "type": "File", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "errors": [ + "SyntaxError: Unsyntactic continue (1:0)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ContinueStatement", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "label": null + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0174/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0174/options.json deleted file mode 100644 index c726e8fa98e4..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0174/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Unsyntactic continue (1:22)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0174/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0174/output.json new file mode 100644 index 000000000000..b83145faf5ab --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0174/output.json @@ -0,0 +1,106 @@ +{ + "type": "File", + "start": 0, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 33 + } + }, + "errors": [ + "SyntaxError: Unsyntactic continue (1:22)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 33 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "SwitchStatement", + "start": 0, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 33 + } + }, + "discriminant": { + "type": "Identifier", + "start": 8, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 9 + }, + "identifierName": "x" + }, + "name": "x" + }, + "cases": [ + { + "type": "SwitchCase", + "start": 13, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "consequent": [ + { + "type": "ContinueStatement", + "start": 22, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 22 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "label": null + } + ], + "test": null + } + ] + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0176/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0176/options.json deleted file mode 100644 index 070e662e80d4..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0176/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Unsyntactic break (1:15)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0176/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0176/output.json new file mode 100644 index 000000000000..a7c8d4f9a0ca --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0176/output.json @@ -0,0 +1,119 @@ +{ + "type": "File", + "start": 0, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 25 + } + }, + "errors": [ + "SyntaxError: Unsyntactic break (1:15)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 25 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "WhileStatement", + "start": 0, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 25 + } + }, + "test": { + "type": "BooleanLiteral", + "start": 7, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "value": true + }, + "body": { + "type": "BlockStatement", + "start": 13, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 25 + } + }, + "body": [ + { + "type": "BreakStatement", + "start": 15, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "label": { + "type": "Identifier", + "start": 21, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 21 + }, + "end": { + "line": 1, + "column": 22 + }, + "identifierName": "x" + }, + "name": "x" + } + } + ], + "directives": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0177/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0177/options.json deleted file mode 100644 index 2a2e15787aa7..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0177/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Unsyntactic continue (1:15)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0177/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0177/output.json new file mode 100644 index 000000000000..2f1c8737b22e --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0177/output.json @@ -0,0 +1,119 @@ +{ + "type": "File", + "start": 0, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 28 + } + }, + "errors": [ + "SyntaxError: Unsyntactic continue (1:15)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 28 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "WhileStatement", + "start": 0, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 28 + } + }, + "test": { + "type": "BooleanLiteral", + "start": 7, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "value": true + }, + "body": { + "type": "BlockStatement", + "start": 13, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 28 + } + }, + "body": [ + { + "type": "ContinueStatement", + "start": 15, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "label": { + "type": "Identifier", + "start": 24, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 24 + }, + "end": { + "line": 1, + "column": 25 + }, + "identifierName": "x" + }, + "name": "x" + } + } + ], + "directives": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0178/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0178/options.json deleted file mode 100644 index 464af80a1561..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0178/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Unsyntactic break (1:33)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0178/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0178/output.json new file mode 100644 index 000000000000..7337acd3e8fd --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0178/output.json @@ -0,0 +1,207 @@ +{ + "type": "File", + "start": 0, + "end": 47, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 47 + } + }, + "errors": [ + "SyntaxError: Unsyntactic break (1:33)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 47, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 47 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "LabeledStatement", + "start": 0, + "end": 47, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 47 + } + }, + "body": { + "type": "WhileStatement", + "start": 3, + "end": 47, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 47 + } + }, + "test": { + "type": "BooleanLiteral", + "start": 10, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "value": true + }, + "body": { + "type": "BlockStatement", + "start": 16, + "end": 47, + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 47 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 18, + "end": 45, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 45 + } + }, + "expression": { + "type": "FunctionExpression", + "start": 19, + "end": 43, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 43 + } + }, + "id": null, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 31, + "end": 43, + "loc": { + "start": { + "line": 1, + "column": 31 + }, + "end": { + "line": 1, + "column": 43 + } + }, + "body": [ + { + "type": "BreakStatement", + "start": 33, + "end": 41, + "loc": { + "start": { + "line": 1, + "column": 33 + }, + "end": { + "line": 1, + "column": 41 + } + }, + "label": { + "type": "Identifier", + "start": 39, + "end": 40, + "loc": { + "start": { + "line": 1, + "column": 39 + }, + "end": { + "line": 1, + "column": 40 + }, + "identifierName": "x" + }, + "name": "x" + } + } + ], + "directives": [] + }, + "extra": { + "parenthesized": true, + "parenStart": 18 + } + } + } + ], + "directives": [] + } + }, + "label": { + "type": "Identifier", + "start": 0, + "end": 1, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 1 + }, + "identifierName": "x" + }, + "name": "x" + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0179/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0179/options.json deleted file mode 100644 index a056cb50e190..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0179/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Unsyntactic continue (1:33)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0179/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0179/output.json new file mode 100644 index 000000000000..18bc9b977ca7 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0179/output.json @@ -0,0 +1,207 @@ +{ + "type": "File", + "start": 0, + "end": 50, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 50 + } + }, + "errors": [ + "SyntaxError: Unsyntactic continue (1:33)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 50, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 50 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "LabeledStatement", + "start": 0, + "end": 50, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 50 + } + }, + "body": { + "type": "WhileStatement", + "start": 3, + "end": 50, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 50 + } + }, + "test": { + "type": "BooleanLiteral", + "start": 10, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "value": true + }, + "body": { + "type": "BlockStatement", + "start": 16, + "end": 50, + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 50 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 18, + "end": 48, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 48 + } + }, + "expression": { + "type": "FunctionExpression", + "start": 19, + "end": 46, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 46 + } + }, + "id": null, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 31, + "end": 46, + "loc": { + "start": { + "line": 1, + "column": 31 + }, + "end": { + "line": 1, + "column": 46 + } + }, + "body": [ + { + "type": "ContinueStatement", + "start": 33, + "end": 44, + "loc": { + "start": { + "line": 1, + "column": 33 + }, + "end": { + "line": 1, + "column": 44 + } + }, + "label": { + "type": "Identifier", + "start": 42, + "end": 43, + "loc": { + "start": { + "line": 1, + "column": 42 + }, + "end": { + "line": 1, + "column": 43 + }, + "identifierName": "x" + }, + "name": "x" + } + } + ], + "directives": [] + }, + "extra": { + "parenthesized": true, + "parenStart": 18 + } + } + } + ], + "directives": [] + } + }, + "label": { + "type": "Identifier", + "start": 0, + "end": 1, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 1 + }, + "identifierName": "x" + }, + "name": "x" + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0180/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0180/options.json deleted file mode 100644 index 464af80a1561..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0180/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Unsyntactic break (1:33)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0180/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0180/output.json new file mode 100644 index 000000000000..59ae007d6fba --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0180/output.json @@ -0,0 +1,191 @@ +{ + "type": "File", + "start": 0, + "end": 45, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 45 + } + }, + "errors": [ + "SyntaxError: Unsyntactic break (1:33)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 45, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 45 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "LabeledStatement", + "start": 0, + "end": 45, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 45 + } + }, + "body": { + "type": "WhileStatement", + "start": 3, + "end": 45, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 45 + } + }, + "test": { + "type": "BooleanLiteral", + "start": 10, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "value": true + }, + "body": { + "type": "BlockStatement", + "start": 16, + "end": 45, + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 45 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 18, + "end": 43, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 43 + } + }, + "expression": { + "type": "FunctionExpression", + "start": 19, + "end": 41, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 41 + } + }, + "id": null, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 31, + "end": 41, + "loc": { + "start": { + "line": 1, + "column": 31 + }, + "end": { + "line": 1, + "column": 41 + } + }, + "body": [ + { + "type": "BreakStatement", + "start": 33, + "end": 39, + "loc": { + "start": { + "line": 1, + "column": 33 + }, + "end": { + "line": 1, + "column": 39 + } + }, + "label": null + } + ], + "directives": [] + }, + "extra": { + "parenthesized": true, + "parenStart": 18 + } + } + } + ], + "directives": [] + } + }, + "label": { + "type": "Identifier", + "start": 0, + "end": 1, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 1 + }, + "identifierName": "x" + }, + "name": "x" + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0181/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0181/options.json deleted file mode 100644 index a056cb50e190..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0181/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Unsyntactic continue (1:33)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0181/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0181/output.json new file mode 100644 index 000000000000..d26e37b08031 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0181/output.json @@ -0,0 +1,191 @@ +{ + "type": "File", + "start": 0, + "end": 48, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 48 + } + }, + "errors": [ + "SyntaxError: Unsyntactic continue (1:33)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 48, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 48 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "LabeledStatement", + "start": 0, + "end": 48, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 48 + } + }, + "body": { + "type": "WhileStatement", + "start": 3, + "end": 48, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 48 + } + }, + "test": { + "type": "BooleanLiteral", + "start": 10, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "value": true + }, + "body": { + "type": "BlockStatement", + "start": 16, + "end": 48, + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 48 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 18, + "end": 46, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 46 + } + }, + "expression": { + "type": "FunctionExpression", + "start": 19, + "end": 44, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 44 + } + }, + "id": null, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 31, + "end": 44, + "loc": { + "start": { + "line": 1, + "column": 31 + }, + "end": { + "line": 1, + "column": 44 + } + }, + "body": [ + { + "type": "ContinueStatement", + "start": 33, + "end": 42, + "loc": { + "start": { + "line": 1, + "column": 33 + }, + "end": { + "line": 1, + "column": 42 + } + }, + "label": null + } + ], + "directives": [] + }, + "extra": { + "parenthesized": true, + "parenStart": 18 + } + } + } + ], + "directives": [] + } + }, + "label": { + "type": "Identifier", + "start": 0, + "end": 1, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 1 + }, + "identifierName": "x" + }, + "name": "x" + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0182/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0182/options.json deleted file mode 100644 index da7f2590db0b..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0182/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Label 'x' is already declared (1:18)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0182/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0182/output.json new file mode 100644 index 000000000000..3025d6bfbf72 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0182/output.json @@ -0,0 +1,199 @@ +{ + "type": "File", + "start": 0, + "end": 39, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 39 + } + }, + "errors": [ + "SyntaxError: Label 'x' is already declared (1:18)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 39, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 39 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "LabeledStatement", + "start": 0, + "end": 39, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 39 + } + }, + "body": { + "type": "WhileStatement", + "start": 3, + "end": 39, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 39 + } + }, + "test": { + "type": "BooleanLiteral", + "start": 10, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "value": true + }, + "body": { + "type": "BlockStatement", + "start": 16, + "end": 39, + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 39 + } + }, + "body": [ + { + "type": "LabeledStatement", + "start": 18, + "end": 37, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 37 + } + }, + "body": { + "type": "WhileStatement", + "start": 21, + "end": 37, + "loc": { + "start": { + "line": 1, + "column": 21 + }, + "end": { + "line": 1, + "column": 37 + } + }, + "test": { + "type": "BooleanLiteral", + "start": 28, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 28 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "value": true + }, + "body": { + "type": "BlockStatement", + "start": 34, + "end": 37, + "loc": { + "start": { + "line": 1, + "column": 34 + }, + "end": { + "line": 1, + "column": 37 + } + }, + "body": [], + "directives": [] + } + }, + "label": { + "type": "Identifier", + "start": 18, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 19 + }, + "identifierName": "x" + }, + "name": "x" + } + } + ], + "directives": [] + } + }, + "label": { + "type": "Identifier", + "start": 0, + "end": 1, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 1 + }, + "identifierName": "x" + }, + "name": "x" + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0183/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0183/options.json deleted file mode 100644 index 1517e1719333..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0183/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Deleting local variable in strict mode (1:29)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0183/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0183/output.json new file mode 100644 index 000000000000..f22f0efb0609 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0183/output.json @@ -0,0 +1,195 @@ +{ + "type": "File", + "start": 0, + "end": 43, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 43 + } + }, + "errors": [ + "SyntaxError: Deleting local variable in strict mode (1:29)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 43, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 43 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 43, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 43 + } + }, + "expression": { + "type": "CallExpression", + "start": 1, + "end": 42, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 42 + } + }, + "callee": { + "type": "FunctionExpression", + "start": 1, + "end": 40, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 40 + } + }, + "id": null, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 13, + "end": 40, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 40 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 29, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 29 + }, + "end": { + "line": 1, + "column": 38 + } + }, + "expression": { + "type": "UnaryExpression", + "start": 29, + "end": 37, + "loc": { + "start": { + "line": 1, + "column": 29 + }, + "end": { + "line": 1, + "column": 37 + } + }, + "operator": "delete", + "prefix": true, + "argument": { + "type": "Identifier", + "start": 36, + "end": 37, + "loc": { + "start": { + "line": 1, + "column": 36 + }, + "end": { + "line": 1, + "column": 37 + }, + "identifierName": "i" + }, + "name": "i" + } + } + } + ], + "directives": [ + { + "type": "Directive", + "start": 15, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 28 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 15, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 27 + } + }, + "value": "use strict", + "extra": { + "raw": "'use strict'", + "rawValue": "use strict" + } + } + } + ] + } + }, + "arguments": [], + "extra": { + "parenthesized": true, + "parenStart": 0 + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0184/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0184/options.json deleted file mode 100644 index 31b4c6d2a040..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0184/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "'with' in strict mode (1:29)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0184/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0184/output.json new file mode 100644 index 000000000000..1567b18881d6 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0184/output.json @@ -0,0 +1,193 @@ +{ + "type": "File", + "start": 0, + "end": 43, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 43 + } + }, + "errors": [ + "SyntaxError: 'with' in strict mode (1:29)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 43, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 43 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 43, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 43 + } + }, + "expression": { + "type": "CallExpression", + "start": 1, + "end": 42, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 42 + } + }, + "callee": { + "type": "FunctionExpression", + "start": 1, + "end": 40, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 40 + } + }, + "id": null, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 13, + "end": 40, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 40 + } + }, + "body": [ + { + "type": "WithStatement", + "start": 29, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 29 + }, + "end": { + "line": 1, + "column": 38 + } + }, + "object": { + "type": "Identifier", + "start": 35, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 35 + }, + "end": { + "line": 1, + "column": 36 + }, + "identifierName": "i" + }, + "name": "i" + }, + "body": { + "type": "EmptyStatement", + "start": 37, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 37 + }, + "end": { + "line": 1, + "column": 38 + } + } + } + } + ], + "directives": [ + { + "type": "Directive", + "start": 15, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 28 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 15, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 27 + } + }, + "value": "use strict", + "extra": { + "raw": "'use strict'", + "rawValue": "use strict" + } + } + } + ] + } + }, + "arguments": [], + "extra": { + "parenthesized": true, + "parenStart": 0 + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0185/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0185/options.json deleted file mode 100644 index dfbf1f6d0d1c..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0185/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Binding 'eval' in strict mode (1:36)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0185/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0185/output.json new file mode 100644 index 000000000000..7598b7431e9f --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0185/output.json @@ -0,0 +1,197 @@ +{ + "type": "File", + "start": 0, + "end": 48, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 48 + } + }, + "errors": [ + "SyntaxError: Binding 'eval' in strict mode (1:36)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 48, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 48 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 48, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 48 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 14 + }, + "identifierName": "hello" + }, + "name": "hello" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 17, + "end": 48, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 48 + } + }, + "body": [ + { + "type": "VariableDeclaration", + "start": 32, + "end": 46, + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 46 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 36, + "end": 45, + "loc": { + "start": { + "line": 1, + "column": 36 + }, + "end": { + "line": 1, + "column": 45 + } + }, + "id": { + "type": "Identifier", + "start": 36, + "end": 40, + "loc": { + "start": { + "line": 1, + "column": 36 + }, + "end": { + "line": 1, + "column": 40 + }, + "identifierName": "eval" + }, + "name": "eval" + }, + "init": { + "type": "NumericLiteral", + "start": 43, + "end": 45, + "loc": { + "start": { + "line": 1, + "column": 43 + }, + "end": { + "line": 1, + "column": 45 + } + }, + "extra": { + "rawValue": 10, + "raw": "10" + }, + "value": 10 + } + } + ], + "kind": "var" + } + ], + "directives": [ + { + "type": "Directive", + "start": 18, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 18, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "value": "use strict", + "extra": { + "raw": "'use strict'", + "rawValue": "use strict" + } + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0186/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0186/options.json deleted file mode 100644 index b74dfcf59199..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0186/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Binding 'arguments' in strict mode (1:36)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0186/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0186/output.json new file mode 100644 index 000000000000..7101109189a2 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0186/output.json @@ -0,0 +1,197 @@ +{ + "type": "File", + "start": 0, + "end": 53, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 53 + } + }, + "errors": [ + "SyntaxError: Binding 'arguments' in strict mode (1:36)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 53, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 53 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 53, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 53 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 14 + }, + "identifierName": "hello" + }, + "name": "hello" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 17, + "end": 53, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 53 + } + }, + "body": [ + { + "type": "VariableDeclaration", + "start": 32, + "end": 51, + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 51 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 36, + "end": 50, + "loc": { + "start": { + "line": 1, + "column": 36 + }, + "end": { + "line": 1, + "column": 50 + } + }, + "id": { + "type": "Identifier", + "start": 36, + "end": 45, + "loc": { + "start": { + "line": 1, + "column": 36 + }, + "end": { + "line": 1, + "column": 45 + }, + "identifierName": "arguments" + }, + "name": "arguments" + }, + "init": { + "type": "NumericLiteral", + "start": 48, + "end": 50, + "loc": { + "start": { + "line": 1, + "column": 48 + }, + "end": { + "line": 1, + "column": 50 + } + }, + "extra": { + "rawValue": 10, + "raw": "10" + }, + "value": 10 + } + } + ], + "kind": "var" + } + ], + "directives": [ + { + "type": "Directive", + "start": 18, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 18, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "value": "use strict", + "extra": { + "raw": "'use strict'", + "rawValue": "use strict" + } + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0187/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0187/options.json deleted file mode 100644 index e95a2d7f7535..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0187/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Binding 'eval' in strict mode (1:47)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0187/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0187/output.json new file mode 100644 index 000000000000..dd5fca85f2e5 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0187/output.json @@ -0,0 +1,209 @@ +{ + "type": "File", + "start": 0, + "end": 58, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 58 + } + }, + "errors": [ + "SyntaxError: Binding 'eval' in strict mode (1:47)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 58, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 58 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 58, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 58 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 14 + }, + "identifierName": "hello" + }, + "name": "hello" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 17, + "end": 58, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 58 + } + }, + "body": [ + { + "type": "TryStatement", + "start": 32, + "end": 56, + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 56 + } + }, + "block": { + "type": "BlockStatement", + "start": 36, + "end": 39, + "loc": { + "start": { + "line": 1, + "column": 36 + }, + "end": { + "line": 1, + "column": 39 + } + }, + "body": [], + "directives": [] + }, + "handler": { + "type": "CatchClause", + "start": 40, + "end": 56, + "loc": { + "start": { + "line": 1, + "column": 40 + }, + "end": { + "line": 1, + "column": 56 + } + }, + "param": { + "type": "Identifier", + "start": 47, + "end": 51, + "loc": { + "start": { + "line": 1, + "column": 47 + }, + "end": { + "line": 1, + "column": 51 + }, + "identifierName": "eval" + }, + "name": "eval" + }, + "body": { + "type": "BlockStatement", + "start": 53, + "end": 56, + "loc": { + "start": { + "line": 1, + "column": 53 + }, + "end": { + "line": 1, + "column": 56 + } + }, + "body": [], + "directives": [] + } + }, + "finalizer": null + } + ], + "directives": [ + { + "type": "Directive", + "start": 18, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 18, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "value": "use strict", + "extra": { + "raw": "'use strict'", + "rawValue": "use strict" + } + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0188/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0188/options.json deleted file mode 100644 index 14d96617b4b6..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0188/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Binding 'arguments' in strict mode (1:47)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0188/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0188/output.json new file mode 100644 index 000000000000..3b89f63424e2 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0188/output.json @@ -0,0 +1,209 @@ +{ + "type": "File", + "start": 0, + "end": 63, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 63 + } + }, + "errors": [ + "SyntaxError: Binding 'arguments' in strict mode (1:47)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 63, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 63 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 63, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 63 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 14 + }, + "identifierName": "hello" + }, + "name": "hello" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 17, + "end": 63, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 63 + } + }, + "body": [ + { + "type": "TryStatement", + "start": 32, + "end": 61, + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 61 + } + }, + "block": { + "type": "BlockStatement", + "start": 36, + "end": 39, + "loc": { + "start": { + "line": 1, + "column": 36 + }, + "end": { + "line": 1, + "column": 39 + } + }, + "body": [], + "directives": [] + }, + "handler": { + "type": "CatchClause", + "start": 40, + "end": 61, + "loc": { + "start": { + "line": 1, + "column": 40 + }, + "end": { + "line": 1, + "column": 61 + } + }, + "param": { + "type": "Identifier", + "start": 47, + "end": 56, + "loc": { + "start": { + "line": 1, + "column": 47 + }, + "end": { + "line": 1, + "column": 56 + }, + "identifierName": "arguments" + }, + "name": "arguments" + }, + "body": { + "type": "BlockStatement", + "start": 58, + "end": 61, + "loc": { + "start": { + "line": 1, + "column": 58 + }, + "end": { + "line": 1, + "column": 61 + } + }, + "body": [], + "directives": [] + } + }, + "finalizer": null + } + ], + "directives": [ + { + "type": "Directive", + "start": 18, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 18, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "value": "use strict", + "extra": { + "raw": "'use strict'", + "rawValue": "use strict" + } + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0189/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0189/options.json deleted file mode 100644 index 6faa5d0476c3..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0189/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Assigning to 'eval' in strict mode (1:32)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0189/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0189/output.json new file mode 100644 index 000000000000..2973f3517639 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0189/output.json @@ -0,0 +1,195 @@ +{ + "type": "File", + "start": 0, + "end": 44, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 44 + } + }, + "errors": [ + "SyntaxError: Assigning to 'eval' in strict mode (1:32)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 44, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 44 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 44, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 44 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 14 + }, + "identifierName": "hello" + }, + "name": "hello" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 17, + "end": 44, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 44 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 32, + "end": 42, + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 42 + } + }, + "expression": { + "type": "AssignmentExpression", + "start": 32, + "end": 41, + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 41 + } + }, + "operator": "=", + "left": { + "type": "Identifier", + "start": 32, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 36 + }, + "identifierName": "eval" + }, + "name": "eval" + }, + "right": { + "type": "NumericLiteral", + "start": 39, + "end": 41, + "loc": { + "start": { + "line": 1, + "column": 39 + }, + "end": { + "line": 1, + "column": 41 + } + }, + "extra": { + "rawValue": 10, + "raw": "10" + }, + "value": 10 + } + } + } + ], + "directives": [ + { + "type": "Directive", + "start": 18, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 18, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "value": "use strict", + "extra": { + "raw": "'use strict'", + "rawValue": "use strict" + } + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0190/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0190/options.json deleted file mode 100644 index 2f502104f7d4..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0190/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Assigning to 'arguments' in strict mode (1:32)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0190/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0190/output.json new file mode 100644 index 000000000000..e328a1e98ef9 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0190/output.json @@ -0,0 +1,195 @@ +{ + "type": "File", + "start": 0, + "end": 49, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 49 + } + }, + "errors": [ + "SyntaxError: Assigning to 'arguments' in strict mode (1:32)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 49, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 49 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 49, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 49 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 14 + }, + "identifierName": "hello" + }, + "name": "hello" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 17, + "end": 49, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 49 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 32, + "end": 47, + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 47 + } + }, + "expression": { + "type": "AssignmentExpression", + "start": 32, + "end": 46, + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 46 + } + }, + "operator": "=", + "left": { + "type": "Identifier", + "start": 32, + "end": 41, + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 41 + }, + "identifierName": "arguments" + }, + "name": "arguments" + }, + "right": { + "type": "NumericLiteral", + "start": 44, + "end": 46, + "loc": { + "start": { + "line": 1, + "column": 44 + }, + "end": { + "line": 1, + "column": 46 + } + }, + "extra": { + "rawValue": 10, + "raw": "10" + }, + "value": 10 + } + } + } + ], + "directives": [ + { + "type": "Directive", + "start": 18, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 18, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "value": "use strict", + "extra": { + "raw": "'use strict'", + "rawValue": "use strict" + } + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0191/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0191/options.json deleted file mode 100644 index 0964911894d9..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0191/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Assigning to 'eval' in strict mode (1:34)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0191/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0191/output.json new file mode 100644 index 000000000000..95091e65367d --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0191/output.json @@ -0,0 +1,176 @@ +{ + "type": "File", + "start": 0, + "end": 41, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 41 + } + }, + "errors": [ + "SyntaxError: Assigning to 'eval' in strict mode (1:34)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 41, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 41 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 41, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 41 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 14 + }, + "identifierName": "hello" + }, + "name": "hello" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 17, + "end": 41, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 41 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 32, + "end": 39, + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 39 + } + }, + "expression": { + "type": "UpdateExpression", + "start": 32, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 38 + } + }, + "operator": "++", + "prefix": true, + "argument": { + "type": "Identifier", + "start": 34, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 34 + }, + "end": { + "line": 1, + "column": 38 + }, + "identifierName": "eval" + }, + "name": "eval" + } + } + } + ], + "directives": [ + { + "type": "Directive", + "start": 18, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 18, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "value": "use strict", + "extra": { + "raw": "'use strict'", + "rawValue": "use strict" + } + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0192/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0192/options.json deleted file mode 100644 index 0964911894d9..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0192/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Assigning to 'eval' in strict mode (1:34)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0192/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0192/output.json new file mode 100644 index 000000000000..8473055a411c --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0192/output.json @@ -0,0 +1,176 @@ +{ + "type": "File", + "start": 0, + "end": 41, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 41 + } + }, + "errors": [ + "SyntaxError: Assigning to 'eval' in strict mode (1:34)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 41, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 41 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 41, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 41 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 14 + }, + "identifierName": "hello" + }, + "name": "hello" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 17, + "end": 41, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 41 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 32, + "end": 39, + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 39 + } + }, + "expression": { + "type": "UpdateExpression", + "start": 32, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 38 + } + }, + "operator": "--", + "prefix": true, + "argument": { + "type": "Identifier", + "start": 34, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 34 + }, + "end": { + "line": 1, + "column": 38 + }, + "identifierName": "eval" + }, + "name": "eval" + } + } + } + ], + "directives": [ + { + "type": "Directive", + "start": 18, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 18, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "value": "use strict", + "extra": { + "raw": "'use strict'", + "rawValue": "use strict" + } + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0193/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0193/options.json deleted file mode 100644 index ba5ef9dd55cc..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0193/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Assigning to 'arguments' in strict mode (1:34)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0193/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0193/output.json new file mode 100644 index 000000000000..c9974932443e --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0193/output.json @@ -0,0 +1,176 @@ +{ + "type": "File", + "start": 0, + "end": 46, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 46 + } + }, + "errors": [ + "SyntaxError: Assigning to 'arguments' in strict mode (1:34)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 46, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 46 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 46, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 46 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 14 + }, + "identifierName": "hello" + }, + "name": "hello" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 17, + "end": 46, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 46 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 32, + "end": 44, + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 44 + } + }, + "expression": { + "type": "UpdateExpression", + "start": 32, + "end": 43, + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 43 + } + }, + "operator": "++", + "prefix": true, + "argument": { + "type": "Identifier", + "start": 34, + "end": 43, + "loc": { + "start": { + "line": 1, + "column": 34 + }, + "end": { + "line": 1, + "column": 43 + }, + "identifierName": "arguments" + }, + "name": "arguments" + } + } + } + ], + "directives": [ + { + "type": "Directive", + "start": 18, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 18, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "value": "use strict", + "extra": { + "raw": "'use strict'", + "rawValue": "use strict" + } + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0194/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0194/options.json deleted file mode 100644 index ba5ef9dd55cc..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0194/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Assigning to 'arguments' in strict mode (1:34)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0194/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0194/output.json new file mode 100644 index 000000000000..cf31420c53a0 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0194/output.json @@ -0,0 +1,176 @@ +{ + "type": "File", + "start": 0, + "end": 46, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 46 + } + }, + "errors": [ + "SyntaxError: Assigning to 'arguments' in strict mode (1:34)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 46, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 46 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 46, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 46 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 14 + }, + "identifierName": "hello" + }, + "name": "hello" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 17, + "end": 46, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 46 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 32, + "end": 44, + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 44 + } + }, + "expression": { + "type": "UpdateExpression", + "start": 32, + "end": 43, + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 43 + } + }, + "operator": "--", + "prefix": true, + "argument": { + "type": "Identifier", + "start": 34, + "end": 43, + "loc": { + "start": { + "line": 1, + "column": 34 + }, + "end": { + "line": 1, + "column": 43 + }, + "identifierName": "arguments" + }, + "name": "arguments" + } + } + } + ], + "directives": [ + { + "type": "Directive", + "start": 18, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 18, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "value": "use strict", + "extra": { + "raw": "'use strict'", + "rawValue": "use strict" + } + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0195/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0195/options.json deleted file mode 100644 index 6faa5d0476c3..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0195/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Assigning to 'eval' in strict mode (1:32)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0195/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0195/output.json new file mode 100644 index 000000000000..59618c91e2ca --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0195/output.json @@ -0,0 +1,176 @@ +{ + "type": "File", + "start": 0, + "end": 41, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 41 + } + }, + "errors": [ + "SyntaxError: Assigning to 'eval' in strict mode (1:32)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 41, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 41 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 41, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 41 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 14 + }, + "identifierName": "hello" + }, + "name": "hello" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 17, + "end": 41, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 41 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 32, + "end": 39, + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 39 + } + }, + "expression": { + "type": "UpdateExpression", + "start": 32, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 38 + } + }, + "operator": "++", + "prefix": false, + "argument": { + "type": "Identifier", + "start": 32, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 36 + }, + "identifierName": "eval" + }, + "name": "eval" + } + } + } + ], + "directives": [ + { + "type": "Directive", + "start": 18, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 18, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "value": "use strict", + "extra": { + "raw": "'use strict'", + "rawValue": "use strict" + } + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0196/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0196/options.json deleted file mode 100644 index 6faa5d0476c3..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0196/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Assigning to 'eval' in strict mode (1:32)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0196/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0196/output.json new file mode 100644 index 000000000000..0b6b047c7b58 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0196/output.json @@ -0,0 +1,176 @@ +{ + "type": "File", + "start": 0, + "end": 41, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 41 + } + }, + "errors": [ + "SyntaxError: Assigning to 'eval' in strict mode (1:32)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 41, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 41 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 41, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 41 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 14 + }, + "identifierName": "hello" + }, + "name": "hello" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 17, + "end": 41, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 41 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 32, + "end": 39, + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 39 + } + }, + "expression": { + "type": "UpdateExpression", + "start": 32, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 38 + } + }, + "operator": "--", + "prefix": false, + "argument": { + "type": "Identifier", + "start": 32, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 36 + }, + "identifierName": "eval" + }, + "name": "eval" + } + } + } + ], + "directives": [ + { + "type": "Directive", + "start": 18, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 18, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "value": "use strict", + "extra": { + "raw": "'use strict'", + "rawValue": "use strict" + } + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0197/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0197/options.json deleted file mode 100644 index 2f502104f7d4..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0197/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Assigning to 'arguments' in strict mode (1:32)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0197/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0197/output.json new file mode 100644 index 000000000000..64f2c09fd91e --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0197/output.json @@ -0,0 +1,176 @@ +{ + "type": "File", + "start": 0, + "end": 46, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 46 + } + }, + "errors": [ + "SyntaxError: Assigning to 'arguments' in strict mode (1:32)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 46, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 46 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 46, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 46 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 14 + }, + "identifierName": "hello" + }, + "name": "hello" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 17, + "end": 46, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 46 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 32, + "end": 44, + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 44 + } + }, + "expression": { + "type": "UpdateExpression", + "start": 32, + "end": 43, + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 43 + } + }, + "operator": "++", + "prefix": false, + "argument": { + "type": "Identifier", + "start": 32, + "end": 41, + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 41 + }, + "identifierName": "arguments" + }, + "name": "arguments" + } + } + } + ], + "directives": [ + { + "type": "Directive", + "start": 18, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 18, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "value": "use strict", + "extra": { + "raw": "'use strict'", + "rawValue": "use strict" + } + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0198/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0198/options.json deleted file mode 100644 index 2f502104f7d4..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0198/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Assigning to 'arguments' in strict mode (1:32)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0198/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0198/output.json new file mode 100644 index 000000000000..34c1b59c4e79 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0198/output.json @@ -0,0 +1,176 @@ +{ + "type": "File", + "start": 0, + "end": 46, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 46 + } + }, + "errors": [ + "SyntaxError: Assigning to 'arguments' in strict mode (1:32)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 46, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 46 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 46, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 46 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 14 + }, + "identifierName": "hello" + }, + "name": "hello" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 17, + "end": 46, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 46 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 32, + "end": 44, + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 44 + } + }, + "expression": { + "type": "UpdateExpression", + "start": 32, + "end": 43, + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 43 + } + }, + "operator": "--", + "prefix": false, + "argument": { + "type": "Identifier", + "start": 32, + "end": 41, + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 41 + }, + "identifierName": "arguments" + }, + "name": "arguments" + } + } + } + ], + "directives": [ + { + "type": "Directive", + "start": 18, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 18, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "value": "use strict", + "extra": { + "raw": "'use strict'", + "rawValue": "use strict" + } + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0199/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0199/options.json deleted file mode 100644 index 439ffff53e89..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0199/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Binding 'eval' in strict mode (1:41)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0199/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0199/output.json new file mode 100644 index 000000000000..35af060b7c6e --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0199/output.json @@ -0,0 +1,179 @@ +{ + "type": "File", + "start": 0, + "end": 53, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 53 + } + }, + "errors": [ + "SyntaxError: Binding 'eval' in strict mode (1:41)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 53, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 53 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 53, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 53 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 14 + }, + "identifierName": "hello" + }, + "name": "hello" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 17, + "end": 53, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 53 + } + }, + "body": [ + { + "type": "FunctionDeclaration", + "start": 32, + "end": 51, + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 51 + } + }, + "id": { + "type": "Identifier", + "start": 41, + "end": 45, + "loc": { + "start": { + "line": 1, + "column": 41 + }, + "end": { + "line": 1, + "column": 45 + }, + "identifierName": "eval" + }, + "name": "eval" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 48, + "end": 51, + "loc": { + "start": { + "line": 1, + "column": 48 + }, + "end": { + "line": 1, + "column": 51 + } + }, + "body": [], + "directives": [] + } + } + ], + "directives": [ + { + "type": "Directive", + "start": 18, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 18, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "value": "use strict", + "extra": { + "raw": "'use strict'", + "rawValue": "use strict" + } + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0200/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0200/options.json deleted file mode 100644 index ad15b27f9b9a..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0200/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Binding 'arguments' in strict mode (1:41)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0200/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0200/output.json new file mode 100644 index 000000000000..7419ba446dc9 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0200/output.json @@ -0,0 +1,179 @@ +{ + "type": "File", + "start": 0, + "end": 58, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 58 + } + }, + "errors": [ + "SyntaxError: Binding 'arguments' in strict mode (1:41)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 58, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 58 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 58, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 58 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 14 + }, + "identifierName": "hello" + }, + "name": "hello" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 17, + "end": 58, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 58 + } + }, + "body": [ + { + "type": "FunctionDeclaration", + "start": 32, + "end": 56, + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 56 + } + }, + "id": { + "type": "Identifier", + "start": 41, + "end": 50, + "loc": { + "start": { + "line": 1, + "column": 41 + }, + "end": { + "line": 1, + "column": 50 + }, + "identifierName": "arguments" + }, + "name": "arguments" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 53, + "end": 56, + "loc": { + "start": { + "line": 1, + "column": 53 + }, + "end": { + "line": 1, + "column": 56 + } + }, + "body": [], + "directives": [] + } + } + ], + "directives": [ + { + "type": "Directive", + "start": 18, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 18, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "value": "use strict", + "extra": { + "raw": "'use strict'", + "rawValue": "use strict" + } + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0201/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0201/options.json deleted file mode 100644 index 1eb91299eb1b..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0201/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Binding 'eval' in strict mode (1:9)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0201/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0201/output.json new file mode 100644 index 000000000000..ede15490b692 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0201/output.json @@ -0,0 +1,126 @@ +{ + "type": "File", + "start": 0, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "errors": [ + "SyntaxError: Binding 'eval' in strict mode (1:9)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 13 + }, + "identifierName": "eval" + }, + "name": "eval" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 16, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "body": [], + "directives": [ + { + "type": "Directive", + "start": 17, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 17, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "value": "use strict", + "extra": { + "raw": "'use strict'", + "rawValue": "use strict" + } + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0202/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0202/options.json deleted file mode 100644 index c903c1205ce8..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0202/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Binding 'arguments' in strict mode (1:9)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0202/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0202/output.json new file mode 100644 index 000000000000..aeccd1a07ed9 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0202/output.json @@ -0,0 +1,126 @@ +{ + "type": "File", + "start": 0, + "end": 37, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 37 + } + }, + "errors": [ + "SyntaxError: Binding 'arguments' in strict mode (1:9)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 37, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 37 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 37, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 37 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 18 + }, + "identifierName": "arguments" + }, + "name": "arguments" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 21, + "end": 37, + "loc": { + "start": { + "line": 1, + "column": 21 + }, + "end": { + "line": 1, + "column": 37 + } + }, + "body": [], + "directives": [ + { + "type": "Directive", + "start": 22, + "end": 35, + "loc": { + "start": { + "line": 1, + "column": 22 + }, + "end": { + "line": 1, + "column": 35 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 22, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 22 + }, + "end": { + "line": 1, + "column": 34 + } + }, + "value": "use strict", + "extra": { + "raw": "'use strict'", + "rawValue": "use strict" + } + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0203/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0203/options.json deleted file mode 100644 index 884ab94e3403..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0203/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Binding 'eval' in strict mode (1:42)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0203/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0203/output.json new file mode 100644 index 000000000000..4e8af9c85d04 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0203/output.json @@ -0,0 +1,214 @@ +{ + "type": "File", + "start": 0, + "end": 57, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 57 + } + }, + "errors": [ + "SyntaxError: Binding 'eval' in strict mode (1:42)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 57, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 57 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 57, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 57 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 14 + }, + "identifierName": "hello" + }, + "name": "hello" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 17, + "end": 57, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 57 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 32, + "end": 55, + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 55 + } + }, + "expression": { + "type": "CallExpression", + "start": 33, + "end": 54, + "loc": { + "start": { + "line": 1, + "column": 33 + }, + "end": { + "line": 1, + "column": 54 + } + }, + "callee": { + "type": "FunctionExpression", + "start": 33, + "end": 52, + "loc": { + "start": { + "line": 1, + "column": 33 + }, + "end": { + "line": 1, + "column": 52 + } + }, + "id": { + "type": "Identifier", + "start": 42, + "end": 46, + "loc": { + "start": { + "line": 1, + "column": 42 + }, + "end": { + "line": 1, + "column": 46 + }, + "identifierName": "eval" + }, + "name": "eval" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 49, + "end": 52, + "loc": { + "start": { + "line": 1, + "column": 49 + }, + "end": { + "line": 1, + "column": 52 + } + }, + "body": [], + "directives": [] + } + }, + "arguments": [], + "extra": { + "parenthesized": true, + "parenStart": 32 + } + } + } + ], + "directives": [ + { + "type": "Directive", + "start": 18, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 18, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "value": "use strict", + "extra": { + "raw": "'use strict'", + "rawValue": "use strict" + } + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0204/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0204/options.json deleted file mode 100644 index 58a98e4ca953..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0204/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Binding 'arguments' in strict mode (1:42)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0204/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0204/output.json new file mode 100644 index 000000000000..49a2e0086f28 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0204/output.json @@ -0,0 +1,214 @@ +{ + "type": "File", + "start": 0, + "end": 62, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 62 + } + }, + "errors": [ + "SyntaxError: Binding 'arguments' in strict mode (1:42)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 62, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 62 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 62, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 62 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 14 + }, + "identifierName": "hello" + }, + "name": "hello" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 17, + "end": 62, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 62 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 32, + "end": 60, + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 60 + } + }, + "expression": { + "type": "CallExpression", + "start": 33, + "end": 59, + "loc": { + "start": { + "line": 1, + "column": 33 + }, + "end": { + "line": 1, + "column": 59 + } + }, + "callee": { + "type": "FunctionExpression", + "start": 33, + "end": 57, + "loc": { + "start": { + "line": 1, + "column": 33 + }, + "end": { + "line": 1, + "column": 57 + } + }, + "id": { + "type": "Identifier", + "start": 42, + "end": 51, + "loc": { + "start": { + "line": 1, + "column": 42 + }, + "end": { + "line": 1, + "column": 51 + }, + "identifierName": "arguments" + }, + "name": "arguments" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 54, + "end": 57, + "loc": { + "start": { + "line": 1, + "column": 54 + }, + "end": { + "line": 1, + "column": 57 + } + }, + "body": [], + "directives": [] + } + }, + "arguments": [], + "extra": { + "parenthesized": true, + "parenStart": 32 + } + } + } + ], + "directives": [ + { + "type": "Directive", + "start": 18, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 18, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "value": "use strict", + "extra": { + "raw": "'use strict'", + "rawValue": "use strict" + } + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0205/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0205/options.json deleted file mode 100644 index aa44c4aafa4d..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0205/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Binding 'eval' in strict mode (1:10)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0205/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0205/output.json new file mode 100644 index 000000000000..6d1387258a3e --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0205/output.json @@ -0,0 +1,161 @@ +{ + "type": "File", + "start": 0, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "errors": [ + "SyntaxError: Binding 'eval' in strict mode (1:10)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "expression": { + "type": "CallExpression", + "start": 0, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "callee": { + "type": "FunctionExpression", + "start": 1, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 33 + } + }, + "id": { + "type": "Identifier", + "start": 10, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 14 + }, + "identifierName": "eval" + }, + "name": "eval" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 17, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 33 + } + }, + "body": [], + "directives": [ + { + "type": "Directive", + "start": 18, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 18, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "value": "use strict", + "extra": { + "raw": "'use strict'", + "rawValue": "use strict" + } + } + } + ] + }, + "extra": { + "parenthesized": true, + "parenStart": 0 + } + }, + "arguments": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0206/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0206/options.json deleted file mode 100644 index 59ccf8eb8209..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0206/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Binding 'arguments' in strict mode (1:10)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0206/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0206/output.json new file mode 100644 index 000000000000..d3b5c3628386 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0206/output.json @@ -0,0 +1,161 @@ +{ + "type": "File", + "start": 0, + "end": 41, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 41 + } + }, + "errors": [ + "SyntaxError: Binding 'arguments' in strict mode (1:10)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 41, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 41 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 41, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 41 + } + }, + "expression": { + "type": "CallExpression", + "start": 0, + "end": 41, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 41 + } + }, + "callee": { + "type": "FunctionExpression", + "start": 1, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 38 + } + }, + "id": { + "type": "Identifier", + "start": 10, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 19 + }, + "identifierName": "arguments" + }, + "name": "arguments" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 22, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 22 + }, + "end": { + "line": 1, + "column": 38 + } + }, + "body": [], + "directives": [ + { + "type": "Directive", + "start": 23, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 23 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 23, + "end": 35, + "loc": { + "start": { + "line": 1, + "column": 23 + }, + "end": { + "line": 1, + "column": 35 + } + }, + "value": "use strict", + "extra": { + "raw": "'use strict'", + "rawValue": "use strict" + } + } + } + ] + }, + "extra": { + "parenthesized": true, + "parenStart": 0 + } + }, + "arguments": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0207/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0207/options.json deleted file mode 100644 index e95a2d7f7535..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0207/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Binding 'eval' in strict mode (1:47)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0207/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0207/output.json new file mode 100644 index 000000000000..d0eb8e29b2a1 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0207/output.json @@ -0,0 +1,250 @@ +{ + "type": "File", + "start": 0, + "end": 63, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 63 + } + }, + "errors": [ + "SyntaxError: Binding 'eval' in strict mode (1:47)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 63, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 63 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 63, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 63 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 14 + }, + "identifierName": "hello" + }, + "name": "hello" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 17, + "end": 63, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 63 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 32, + "end": 61, + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 61 + } + }, + "expression": { + "type": "ObjectExpression", + "start": 33, + "end": 59, + "loc": { + "start": { + "line": 1, + "column": 33 + }, + "end": { + "line": 1, + "column": 59 + } + }, + "properties": [ + { + "type": "ObjectProperty", + "start": 35, + "end": 57, + "loc": { + "start": { + "line": 1, + "column": 35 + }, + "end": { + "line": 1, + "column": 57 + } + }, + "method": false, + "key": { + "type": "Identifier", + "start": 35, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 35 + }, + "end": { + "line": 1, + "column": 36 + }, + "identifierName": "s" + }, + "name": "s" + }, + "computed": false, + "shorthand": false, + "value": { + "type": "FunctionExpression", + "start": 38, + "end": 57, + "loc": { + "start": { + "line": 1, + "column": 38 + }, + "end": { + "line": 1, + "column": 57 + } + }, + "id": { + "type": "Identifier", + "start": 47, + "end": 51, + "loc": { + "start": { + "line": 1, + "column": 47 + }, + "end": { + "line": 1, + "column": 51 + }, + "identifierName": "eval" + }, + "name": "eval" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 54, + "end": 57, + "loc": { + "start": { + "line": 1, + "column": 54 + }, + "end": { + "line": 1, + "column": 57 + } + }, + "body": [], + "directives": [] + } + } + } + ], + "extra": { + "parenthesized": true, + "parenStart": 32 + } + } + } + ], + "directives": [ + { + "type": "Directive", + "start": 18, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 18, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "value": "use strict", + "extra": { + "raw": "'use strict'", + "rawValue": "use strict" + } + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0208/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0208/options.json deleted file mode 100644 index e29c7aee6091..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0208/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Binding 'package' in strict mode (1:10)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0208/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0208/output.json new file mode 100644 index 000000000000..d6510094936e --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0208/output.json @@ -0,0 +1,161 @@ +{ + "type": "File", + "start": 0, + "end": 39, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 39 + } + }, + "errors": [ + "SyntaxError: Binding 'package' in strict mode (1:10)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 39, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 39 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 39, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 39 + } + }, + "expression": { + "type": "CallExpression", + "start": 0, + "end": 39, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 39 + } + }, + "callee": { + "type": "FunctionExpression", + "start": 1, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "id": { + "type": "Identifier", + "start": 10, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 17 + }, + "identifierName": "package" + }, + "name": "package" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 20, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 20 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "body": [], + "directives": [ + { + "type": "Directive", + "start": 21, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 21 + }, + "end": { + "line": 1, + "column": 34 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 21, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 21 + }, + "end": { + "line": 1, + "column": 33 + } + }, + "value": "use strict", + "extra": { + "raw": "'use strict'", + "rawValue": "use strict" + } + } + } + ] + }, + "extra": { + "parenthesized": true, + "parenStart": 0 + } + }, + "arguments": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0209/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0209/options.json deleted file mode 100644 index 43dc5662e1e5..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0209/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Binding 'eval' in strict mode (1:48)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0209/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0209/output.json new file mode 100644 index 000000000000..98e096877880 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0209/output.json @@ -0,0 +1,292 @@ +{ + "type": "File", + "start": 0, + "end": 63, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 63 + } + }, + "errors": [ + "SyntaxError: Binding 'eval' in strict mode (1:48)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 63, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 63 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 63, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 63 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 14 + }, + "identifierName": "hello" + }, + "name": "hello" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 17, + "end": 63, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 63 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 32, + "end": 61, + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 61 + } + }, + "expression": { + "type": "ObjectExpression", + "start": 33, + "end": 59, + "loc": { + "start": { + "line": 1, + "column": 33 + }, + "end": { + "line": 1, + "column": 59 + } + }, + "properties": [ + { + "type": "ObjectProperty", + "start": 35, + "end": 40, + "loc": { + "start": { + "line": 1, + "column": 35 + }, + "end": { + "line": 1, + "column": 40 + } + }, + "method": false, + "key": { + "type": "Identifier", + "start": 35, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 35 + }, + "end": { + "line": 1, + "column": 36 + }, + "identifierName": "i" + }, + "name": "i" + }, + "computed": false, + "shorthand": false, + "value": { + "type": "NumericLiteral", + "start": 38, + "end": 40, + "loc": { + "start": { + "line": 1, + "column": 38 + }, + "end": { + "line": 1, + "column": 40 + } + }, + "extra": { + "rawValue": 10, + "raw": "10" + }, + "value": 10 + } + }, + { + "type": "ObjectMethod", + "start": 42, + "end": 57, + "loc": { + "start": { + "line": 1, + "column": 42 + }, + "end": { + "line": 1, + "column": 57 + } + }, + "method": false, + "key": { + "type": "Identifier", + "start": 46, + "end": 47, + "loc": { + "start": { + "line": 1, + "column": 46 + }, + "end": { + "line": 1, + "column": 47 + }, + "identifierName": "s" + }, + "name": "s" + }, + "computed": false, + "kind": "set", + "id": null, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "start": 48, + "end": 52, + "loc": { + "start": { + "line": 1, + "column": 48 + }, + "end": { + "line": 1, + "column": 52 + }, + "identifierName": "eval" + }, + "name": "eval" + } + ], + "body": { + "type": "BlockStatement", + "start": 54, + "end": 57, + "loc": { + "start": { + "line": 1, + "column": 54 + }, + "end": { + "line": 1, + "column": 57 + } + }, + "body": [], + "directives": [] + } + } + ], + "extra": { + "parenthesized": true, + "parenStart": 32 + } + } + } + ], + "directives": [ + { + "type": "Directive", + "start": 18, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 18, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "value": "use strict", + "extra": { + "raw": "'use strict'", + "rawValue": "use strict" + } + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0210/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0210/options.json deleted file mode 100644 index 439ffff53e89..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0210/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Binding 'eval' in strict mode (1:41)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0210/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0210/output.json new file mode 100644 index 000000000000..f974d83f5a98 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0210/output.json @@ -0,0 +1,237 @@ +{ + "type": "File", + "start": 0, + "end": 56, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 56 + } + }, + "errors": [ + "SyntaxError: Binding 'eval' in strict mode (1:41)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 56, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 56 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 56, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 56 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 14 + }, + "identifierName": "hello" + }, + "name": "hello" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 17, + "end": 56, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 56 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 32, + "end": 54, + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 54 + } + }, + "expression": { + "type": "ObjectExpression", + "start": 33, + "end": 52, + "loc": { + "start": { + "line": 1, + "column": 33 + }, + "end": { + "line": 1, + "column": 52 + } + }, + "properties": [ + { + "type": "ObjectMethod", + "start": 35, + "end": 50, + "loc": { + "start": { + "line": 1, + "column": 35 + }, + "end": { + "line": 1, + "column": 50 + } + }, + "method": false, + "key": { + "type": "Identifier", + "start": 39, + "end": 40, + "loc": { + "start": { + "line": 1, + "column": 39 + }, + "end": { + "line": 1, + "column": 40 + }, + "identifierName": "s" + }, + "name": "s" + }, + "computed": false, + "kind": "set", + "id": null, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "start": 41, + "end": 45, + "loc": { + "start": { + "line": 1, + "column": 41 + }, + "end": { + "line": 1, + "column": 45 + }, + "identifierName": "eval" + }, + "name": "eval" + } + ], + "body": { + "type": "BlockStatement", + "start": 47, + "end": 50, + "loc": { + "start": { + "line": 1, + "column": 47 + }, + "end": { + "line": 1, + "column": 50 + } + }, + "body": [], + "directives": [] + } + } + ], + "extra": { + "parenthesized": true, + "parenStart": 32 + } + } + } + ], + "directives": [ + { + "type": "Directive", + "start": 18, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 18, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "value": "use strict", + "extra": { + "raw": "'use strict'", + "rawValue": "use strict" + } + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0211/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0211/options.json deleted file mode 100644 index 8b18a4ec3e5a..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0211/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Binding 'eval' in strict mode (1:49)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0211/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0211/output.json new file mode 100644 index 000000000000..2993cf648835 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0211/output.json @@ -0,0 +1,268 @@ +{ + "type": "File", + "start": 0, + "end": 64, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 64 + } + }, + "errors": [ + "SyntaxError: Binding 'eval' in strict mode (1:49)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 64, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 64 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 64, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 64 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 14 + }, + "identifierName": "hello" + }, + "name": "hello" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 17, + "end": 64, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 64 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 32, + "end": 62, + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 62 + } + }, + "expression": { + "type": "ObjectExpression", + "start": 33, + "end": 60, + "loc": { + "start": { + "line": 1, + "column": 33 + }, + "end": { + "line": 1, + "column": 60 + } + }, + "properties": [ + { + "type": "ObjectProperty", + "start": 35, + "end": 58, + "loc": { + "start": { + "line": 1, + "column": 35 + }, + "end": { + "line": 1, + "column": 58 + } + }, + "method": false, + "key": { + "type": "Identifier", + "start": 35, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 35 + }, + "end": { + "line": 1, + "column": 36 + }, + "identifierName": "s" + }, + "name": "s" + }, + "computed": false, + "shorthand": false, + "value": { + "type": "FunctionExpression", + "start": 38, + "end": 58, + "loc": { + "start": { + "line": 1, + "column": 38 + }, + "end": { + "line": 1, + "column": 58 + } + }, + "id": { + "type": "Identifier", + "start": 47, + "end": 48, + "loc": { + "start": { + "line": 1, + "column": 47 + }, + "end": { + "line": 1, + "column": 48 + }, + "identifierName": "s" + }, + "name": "s" + }, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "start": 49, + "end": 53, + "loc": { + "start": { + "line": 1, + "column": 49 + }, + "end": { + "line": 1, + "column": 53 + }, + "identifierName": "eval" + }, + "name": "eval" + } + ], + "body": { + "type": "BlockStatement", + "start": 55, + "end": 58, + "loc": { + "start": { + "line": 1, + "column": 55 + }, + "end": { + "line": 1, + "column": 58 + } + }, + "body": [], + "directives": [] + } + } + } + ], + "extra": { + "parenthesized": true, + "parenStart": 32 + } + } + } + ], + "directives": [ + { + "type": "Directive", + "start": 18, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 18, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "value": "use strict", + "extra": { + "raw": "'use strict'", + "rawValue": "use strict" + } + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0212/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0212/options.json deleted file mode 100644 index 794c4864d4e5..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0212/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Binding 'eval' in strict mode (1:15)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0212/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0212/output.json new file mode 100644 index 000000000000..4534376b270a --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0212/output.json @@ -0,0 +1,144 @@ +{ + "type": "File", + "start": 0, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "errors": [ + "SyntaxError: Binding 'eval' in strict mode (1:15)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 14 + }, + "identifierName": "hello" + }, + "name": "hello" + }, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "start": 15, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 19 + }, + "identifierName": "eval" + }, + "name": "eval" + } + ], + "body": { + "type": "BlockStatement", + "start": 21, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 21 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "body": [], + "directives": [ + { + "type": "Directive", + "start": 22, + "end": 35, + "loc": { + "start": { + "line": 1, + "column": 22 + }, + "end": { + "line": 1, + "column": 35 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 22, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 22 + }, + "end": { + "line": 1, + "column": 34 + } + }, + "value": "use strict", + "extra": { + "raw": "'use strict'", + "rawValue": "use strict" + } + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0213/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0213/options.json deleted file mode 100644 index 212d35fcb5fe..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0213/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Binding 'arguments' in strict mode (1:15)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0213/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0213/output.json new file mode 100644 index 000000000000..cb41c2783446 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0213/output.json @@ -0,0 +1,144 @@ +{ + "type": "File", + "start": 0, + "end": 41, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 41 + } + }, + "errors": [ + "SyntaxError: Binding 'arguments' in strict mode (1:15)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 41, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 41 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 41, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 41 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 14 + }, + "identifierName": "hello" + }, + "name": "hello" + }, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "start": 15, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 24 + }, + "identifierName": "arguments" + }, + "name": "arguments" + } + ], + "body": { + "type": "BlockStatement", + "start": 26, + "end": 41, + "loc": { + "start": { + "line": 1, + "column": 26 + }, + "end": { + "line": 1, + "column": 41 + } + }, + "body": [], + "directives": [ + { + "type": "Directive", + "start": 27, + "end": 40, + "loc": { + "start": { + "line": 1, + "column": 27 + }, + "end": { + "line": 1, + "column": 40 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 27, + "end": 39, + "loc": { + "start": { + "line": 1, + "column": 27 + }, + "end": { + "line": 1, + "column": 39 + } + }, + "value": "use strict", + "extra": { + "raw": "'use strict'", + "rawValue": "use strict" + } + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0214/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0214/options.json deleted file mode 100644 index 43dc5662e1e5..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0214/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Binding 'eval' in strict mode (1:48)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0214/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0214/output.json new file mode 100644 index 000000000000..d8df2c1c2d07 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0214/output.json @@ -0,0 +1,197 @@ +{ + "type": "File", + "start": 0, + "end": 58, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 58 + } + }, + "errors": [ + "SyntaxError: Binding 'eval' in strict mode (1:48)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 58, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 58 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 58, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 58 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 14 + }, + "identifierName": "hello" + }, + "name": "hello" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 17, + "end": 58, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 58 + } + }, + "body": [ + { + "type": "FunctionDeclaration", + "start": 33, + "end": 56, + "loc": { + "start": { + "line": 1, + "column": 33 + }, + "end": { + "line": 1, + "column": 56 + } + }, + "id": { + "type": "Identifier", + "start": 42, + "end": 47, + "loc": { + "start": { + "line": 1, + "column": 42 + }, + "end": { + "line": 1, + "column": 47 + }, + "identifierName": "inner" + }, + "name": "inner" + }, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "start": 48, + "end": 52, + "loc": { + "start": { + "line": 1, + "column": 48 + }, + "end": { + "line": 1, + "column": 52 + }, + "identifierName": "eval" + }, + "name": "eval" + } + ], + "body": { + "type": "BlockStatement", + "start": 54, + "end": 56, + "loc": { + "start": { + "line": 1, + "column": 54 + }, + "end": { + "line": 1, + "column": 56 + } + }, + "body": [], + "directives": [] + } + } + ], + "directives": [ + { + "type": "Directive", + "start": 19, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 19, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "value": "use strict", + "extra": { + "raw": "'use strict'", + "rawValue": "use strict" + } + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0215/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0215/options.json deleted file mode 100644 index 8370ba5c765f..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0215/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Binding 'arguments' in strict mode (1:48)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0215/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0215/output.json new file mode 100644 index 000000000000..a2fc6cb4db0e --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0215/output.json @@ -0,0 +1,197 @@ +{ + "type": "File", + "start": 0, + "end": 63, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 63 + } + }, + "errors": [ + "SyntaxError: Binding 'arguments' in strict mode (1:48)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 63, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 63 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 63, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 63 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 14 + }, + "identifierName": "hello" + }, + "name": "hello" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 17, + "end": 63, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 63 + } + }, + "body": [ + { + "type": "FunctionDeclaration", + "start": 33, + "end": 61, + "loc": { + "start": { + "line": 1, + "column": 33 + }, + "end": { + "line": 1, + "column": 61 + } + }, + "id": { + "type": "Identifier", + "start": 42, + "end": 47, + "loc": { + "start": { + "line": 1, + "column": 42 + }, + "end": { + "line": 1, + "column": 47 + }, + "identifierName": "inner" + }, + "name": "inner" + }, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "start": 48, + "end": 57, + "loc": { + "start": { + "line": 1, + "column": 48 + }, + "end": { + "line": 1, + "column": 57 + }, + "identifierName": "arguments" + }, + "name": "arguments" + } + ], + "body": { + "type": "BlockStatement", + "start": 59, + "end": 61, + "loc": { + "start": { + "line": 1, + "column": 59 + }, + "end": { + "line": 1, + "column": 61 + } + }, + "body": [], + "directives": [] + } + } + ], + "directives": [ + { + "type": "Directive", + "start": 19, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 19, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "value": "use strict", + "extra": { + "raw": "'use strict'", + "rawValue": "use strict" + } + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0216/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0216/options.json deleted file mode 100644 index 61a5834b639e..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0216/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Octal literal in strict mode (1:2)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0216/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0216/output.json new file mode 100644 index 000000000000..48c8fda845ba --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0216/output.json @@ -0,0 +1,108 @@ +{ + "type": "File", + "start": 0, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "errors": [ + "SyntaxError: Octal literal in strict mode (1:2)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [], + "directives": [ + { + "type": "Directive", + "start": 0, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 0, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "value": "\\1", + "extra": { + "raw": "\"\\1\"", + "rawValue": "\\1" + } + } + }, + { + "type": "Directive", + "start": 6, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 6, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "value": "use strict", + "extra": { + "raw": "'use strict'", + "rawValue": "use strict" + } + } + } + ] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0217/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0217/options.json deleted file mode 100644 index ae2bfab55c68..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0217/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Octal literal in strict mode (1:35)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0217/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0217/output.json new file mode 100644 index 000000000000..1504ace4ac5d --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0217/output.json @@ -0,0 +1,162 @@ +{ + "type": "File", + "start": 0, + "end": 40, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 40 + } + }, + "errors": [ + "SyntaxError: Octal literal in strict mode (1:35)", + "SyntaxError: Octal literal in strict mode (1:35)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 40, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 40 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 40, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 40 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 14 + }, + "identifierName": "hello" + }, + "name": "hello" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 17, + "end": 40, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 40 + } + }, + "body": [], + "directives": [ + { + "type": "Directive", + "start": 19, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 19, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "value": "use strict", + "extra": { + "raw": "'use strict'", + "rawValue": "use strict" + } + } + }, + { + "type": "Directive", + "start": 33, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 33 + }, + "end": { + "line": 1, + "column": 38 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 33, + "end": 37, + "loc": { + "start": { + "line": 1, + "column": 33 + }, + "end": { + "line": 1, + "column": 37 + } + }, + "value": "\\1", + "extra": { + "raw": "\"\\1\"", + "rawValue": "\\1" + } + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0218/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0218/options.json deleted file mode 100644 index 45ca229c1e8e..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0218/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Legacy octal literals are not allowed in strict mode (1:33)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0218/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0218/output.json new file mode 100644 index 000000000000..805c176e7856 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0218/output.json @@ -0,0 +1,163 @@ +{ + "type": "File", + "start": 0, + "end": 39, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 39 + } + }, + "errors": [ + "SyntaxError: Legacy octal literals are not allowed in strict mode (1:33)", + "SyntaxError: Legacy octal literals are not allowed in strict mode (1:33)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 39, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 39 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 39, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 39 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 14 + }, + "identifierName": "hello" + }, + "name": "hello" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 17, + "end": 39, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 39 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 33, + "end": 37, + "loc": { + "start": { + "line": 1, + "column": 33 + }, + "end": { + "line": 1, + "column": 37 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 33, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 33 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "extra": { + "rawValue": 17, + "raw": "021" + }, + "value": 17 + } + } + ], + "directives": [ + { + "type": "Directive", + "start": 19, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 19, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "value": "use strict", + "extra": { + "raw": "'use strict'", + "rawValue": "use strict" + } + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0219/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0219/options.json deleted file mode 100644 index 7e50b5f9165e..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0219/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Octal literal in strict mode (1:38)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0219/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0219/output.json new file mode 100644 index 000000000000..f73cb42cd9cf --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0219/output.json @@ -0,0 +1,221 @@ +{ + "type": "File", + "start": 0, + "end": 50, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 50 + } + }, + "errors": [ + "SyntaxError: Octal literal in strict mode (1:38)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 50, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 50 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 50, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 50 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 14 + }, + "identifierName": "hello" + }, + "name": "hello" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 17, + "end": 50, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 50 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 33, + "end": 48, + "loc": { + "start": { + "line": 1, + "column": 33 + }, + "end": { + "line": 1, + "column": 48 + } + }, + "expression": { + "type": "ObjectExpression", + "start": 34, + "end": 46, + "loc": { + "start": { + "line": 1, + "column": 34 + }, + "end": { + "line": 1, + "column": 46 + } + }, + "properties": [ + { + "type": "ObjectProperty", + "start": 36, + "end": 44, + "loc": { + "start": { + "line": 1, + "column": 36 + }, + "end": { + "line": 1, + "column": 44 + } + }, + "method": false, + "key": { + "type": "StringLiteral", + "start": 36, + "end": 40, + "loc": { + "start": { + "line": 1, + "column": 36 + }, + "end": { + "line": 1, + "column": 40 + } + }, + "extra": { + "rawValue": "\u0001", + "raw": "\"\\1\"" + }, + "value": "\u0001" + }, + "computed": false, + "shorthand": false, + "value": { + "type": "NumericLiteral", + "start": 42, + "end": 44, + "loc": { + "start": { + "line": 1, + "column": 42 + }, + "end": { + "line": 1, + "column": 44 + } + }, + "extra": { + "rawValue": 42, + "raw": "42" + }, + "value": 42 + } + } + ], + "extra": { + "parenthesized": true, + "parenStart": 33 + } + } + } + ], + "directives": [ + { + "type": "Directive", + "start": 19, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 19, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "value": "use strict", + "extra": { + "raw": "'use strict'", + "rawValue": "use strict" + } + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0220/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0220/options.json deleted file mode 100644 index 8f6c8218f747..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0220/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Legacy octal literals are not allowed in strict mode (1:36)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0220/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0220/output.json new file mode 100644 index 000000000000..5eb3bcef0b18 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0220/output.json @@ -0,0 +1,221 @@ +{ + "type": "File", + "start": 0, + "end": 49, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 49 + } + }, + "errors": [ + "SyntaxError: Legacy octal literals are not allowed in strict mode (1:36)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 49, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 49 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 49, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 49 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 14 + }, + "identifierName": "hello" + }, + "name": "hello" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 17, + "end": 49, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 49 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 33, + "end": 47, + "loc": { + "start": { + "line": 1, + "column": 33 + }, + "end": { + "line": 1, + "column": 47 + } + }, + "expression": { + "type": "ObjectExpression", + "start": 34, + "end": 45, + "loc": { + "start": { + "line": 1, + "column": 34 + }, + "end": { + "line": 1, + "column": 45 + } + }, + "properties": [ + { + "type": "ObjectProperty", + "start": 36, + "end": 43, + "loc": { + "start": { + "line": 1, + "column": 36 + }, + "end": { + "line": 1, + "column": 43 + } + }, + "method": false, + "key": { + "type": "NumericLiteral", + "start": 36, + "end": 39, + "loc": { + "start": { + "line": 1, + "column": 36 + }, + "end": { + "line": 1, + "column": 39 + } + }, + "extra": { + "rawValue": 17, + "raw": "021" + }, + "value": 17 + }, + "computed": false, + "shorthand": false, + "value": { + "type": "NumericLiteral", + "start": 41, + "end": 43, + "loc": { + "start": { + "line": 1, + "column": 41 + }, + "end": { + "line": 1, + "column": 43 + } + }, + "extra": { + "rawValue": 42, + "raw": "42" + }, + "value": 42 + } + } + ], + "extra": { + "parenthesized": true, + "parenStart": 33 + } + } + } + ], + "directives": [ + { + "type": "Directive", + "start": 19, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 19, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "value": "use strict", + "extra": { + "raw": "'use strict'", + "rawValue": "use strict" + } + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0221/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0221/options.json deleted file mode 100644 index d094fe0284b1..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0221/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Octal literal in strict mode (1:36)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0221/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0221/output.json new file mode 100644 index 000000000000..374201e48c95 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0221/output.json @@ -0,0 +1,161 @@ +{ + "type": "File", + "start": 0, + "end": 55, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 55 + } + }, + "errors": [ + "SyntaxError: Octal literal in strict mode (1:36)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 55, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 55 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 55, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 55 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 14 + }, + "identifierName": "hello" + }, + "name": "hello" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 17, + "end": 55, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 55 + } + }, + "body": [], + "directives": [ + { + "type": "Directive", + "start": 19, + "end": 39, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 39 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 19, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 38 + } + }, + "value": "octal directive\\1", + "extra": { + "raw": "\"octal directive\\1\"", + "rawValue": "octal directive\\1" + } + } + }, + { + "type": "Directive", + "start": 40, + "end": 53, + "loc": { + "start": { + "line": 1, + "column": 40 + }, + "end": { + "line": 1, + "column": 53 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 40, + "end": 52, + "loc": { + "start": { + "line": 1, + "column": 40 + }, + "end": { + "line": 1, + "column": 52 + } + }, + "value": "use strict", + "extra": { + "raw": "\"use strict\"", + "rawValue": "use strict" + } + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0222/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0222/options.json deleted file mode 100644 index d094fe0284b1..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0222/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Octal literal in strict mode (1:36)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0222/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0222/output.json new file mode 100644 index 000000000000..1c7a53167a1c --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0222/output.json @@ -0,0 +1,197 @@ +{ + "type": "File", + "start": 0, + "end": 76, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 76 + } + }, + "errors": [ + "SyntaxError: Octal literal in strict mode (1:36)", + "SyntaxError: Octal literal in strict mode (1:57)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 76, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 76 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 76, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 76 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 14 + }, + "identifierName": "hello" + }, + "name": "hello" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 17, + "end": 76, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 76 + } + }, + "body": [], + "directives": [ + { + "type": "Directive", + "start": 19, + "end": 39, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 39 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 19, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 38 + } + }, + "value": "octal directive\\1", + "extra": { + "raw": "\"octal directive\\1\"", + "rawValue": "octal directive\\1" + } + } + }, + { + "type": "Directive", + "start": 40, + "end": 60, + "loc": { + "start": { + "line": 1, + "column": 40 + }, + "end": { + "line": 1, + "column": 60 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 40, + "end": 59, + "loc": { + "start": { + "line": 1, + "column": 40 + }, + "end": { + "line": 1, + "column": 59 + } + }, + "value": "octal directive\\2", + "extra": { + "raw": "\"octal directive\\2\"", + "rawValue": "octal directive\\2" + } + } + }, + { + "type": "Directive", + "start": 61, + "end": 74, + "loc": { + "start": { + "line": 1, + "column": 61 + }, + "end": { + "line": 1, + "column": 74 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 61, + "end": 73, + "loc": { + "start": { + "line": 1, + "column": 61 + }, + "end": { + "line": 1, + "column": 73 + } + }, + "value": "use strict", + "extra": { + "raw": "\"use strict\"", + "rawValue": "use strict" + } + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0223/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0223/options.json deleted file mode 100644 index 8389b2c726ca..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0223/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Octal literal in strict mode (1:69)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0223/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0223/output.json new file mode 100644 index 000000000000..e52fa38ccf73 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0223/output.json @@ -0,0 +1,215 @@ +{ + "type": "File", + "start": 0, + "end": 76, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 76 + } + }, + "errors": [ + "SyntaxError: Octal literal in strict mode (1:69)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 76, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 76 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 76, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 76 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 14 + }, + "identifierName": "hello" + }, + "name": "hello" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 17, + "end": 76, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 76 + } + }, + "body": [ + { + "type": "FunctionDeclaration", + "start": 33, + "end": 74, + "loc": { + "start": { + "line": 1, + "column": 33 + }, + "end": { + "line": 1, + "column": 74 + } + }, + "id": { + "type": "Identifier", + "start": 42, + "end": 47, + "loc": { + "start": { + "line": 1, + "column": 42 + }, + "end": { + "line": 1, + "column": 47 + }, + "identifierName": "inner" + }, + "name": "inner" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 50, + "end": 74, + "loc": { + "start": { + "line": 1, + "column": 50 + }, + "end": { + "line": 1, + "column": 74 + } + }, + "body": [], + "directives": [ + { + "type": "Directive", + "start": 52, + "end": 72, + "loc": { + "start": { + "line": 1, + "column": 52 + }, + "end": { + "line": 1, + "column": 72 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 52, + "end": 71, + "loc": { + "start": { + "line": 1, + "column": 52 + }, + "end": { + "line": 1, + "column": 71 + } + }, + "value": "octal directive\\1", + "extra": { + "raw": "\"octal directive\\1\"", + "rawValue": "octal directive\\1" + } + } + } + ] + } + } + ], + "directives": [ + { + "type": "Directive", + "start": 19, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 19, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "value": "use strict", + "extra": { + "raw": "\"use strict\"", + "rawValue": "use strict" + } + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0224/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0224/options.json deleted file mode 100644 index 0641de45e29a..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0224/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Unexpected reserved word 'implements' (1:37)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0224/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0224/output.json new file mode 100644 index 000000000000..2201ea3de8c6 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0224/output.json @@ -0,0 +1,178 @@ +{ + "type": "File", + "start": 0, + "end": 50, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 50 + } + }, + "errors": [ + "SyntaxError: Unexpected reserved word 'implements' (1:37)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 50, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 50 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 50, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 50 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 14 + }, + "identifierName": "hello" + }, + "name": "hello" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 17, + "end": 50, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 50 + } + }, + "body": [ + { + "type": "VariableDeclaration", + "start": 33, + "end": 48, + "loc": { + "start": { + "line": 1, + "column": 33 + }, + "end": { + "line": 1, + "column": 48 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 37, + "end": 47, + "loc": { + "start": { + "line": 1, + "column": 37 + }, + "end": { + "line": 1, + "column": 47 + } + }, + "id": { + "type": "Identifier", + "start": 37, + "end": 47, + "loc": { + "start": { + "line": 1, + "column": 37 + }, + "end": { + "line": 1, + "column": 47 + }, + "identifierName": "implements" + }, + "name": "implements" + }, + "init": null + } + ], + "kind": "var" + } + ], + "directives": [ + { + "type": "Directive", + "start": 19, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 19, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "value": "use strict", + "extra": { + "raw": "\"use strict\"", + "rawValue": "use strict" + } + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0225/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0225/options.json deleted file mode 100644 index 859238d0423f..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0225/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Unexpected reserved word 'interface' (1:37)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0225/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0225/output.json new file mode 100644 index 000000000000..be76deabc7a1 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0225/output.json @@ -0,0 +1,178 @@ +{ + "type": "File", + "start": 0, + "end": 49, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 49 + } + }, + "errors": [ + "SyntaxError: Unexpected reserved word 'interface' (1:37)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 49, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 49 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 49, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 49 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 14 + }, + "identifierName": "hello" + }, + "name": "hello" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 17, + "end": 49, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 49 + } + }, + "body": [ + { + "type": "VariableDeclaration", + "start": 33, + "end": 47, + "loc": { + "start": { + "line": 1, + "column": 33 + }, + "end": { + "line": 1, + "column": 47 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 37, + "end": 46, + "loc": { + "start": { + "line": 1, + "column": 37 + }, + "end": { + "line": 1, + "column": 46 + } + }, + "id": { + "type": "Identifier", + "start": 37, + "end": 46, + "loc": { + "start": { + "line": 1, + "column": 37 + }, + "end": { + "line": 1, + "column": 46 + }, + "identifierName": "interface" + }, + "name": "interface" + }, + "init": null + } + ], + "kind": "var" + } + ], + "directives": [ + { + "type": "Directive", + "start": 19, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 19, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "value": "use strict", + "extra": { + "raw": "\"use strict\"", + "rawValue": "use strict" + } + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0226/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0226/options.json deleted file mode 100644 index 344c7075f4bf..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0226/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Unexpected reserved word 'package' (1:37)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0226/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0226/output.json new file mode 100644 index 000000000000..414e229fac38 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0226/output.json @@ -0,0 +1,178 @@ +{ + "type": "File", + "start": 0, + "end": 47, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 47 + } + }, + "errors": [ + "SyntaxError: Unexpected reserved word 'package' (1:37)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 47, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 47 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 47, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 47 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 14 + }, + "identifierName": "hello" + }, + "name": "hello" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 17, + "end": 47, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 47 + } + }, + "body": [ + { + "type": "VariableDeclaration", + "start": 33, + "end": 45, + "loc": { + "start": { + "line": 1, + "column": 33 + }, + "end": { + "line": 1, + "column": 45 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 37, + "end": 44, + "loc": { + "start": { + "line": 1, + "column": 37 + }, + "end": { + "line": 1, + "column": 44 + } + }, + "id": { + "type": "Identifier", + "start": 37, + "end": 44, + "loc": { + "start": { + "line": 1, + "column": 37 + }, + "end": { + "line": 1, + "column": 44 + }, + "identifierName": "package" + }, + "name": "package" + }, + "init": null + } + ], + "kind": "var" + } + ], + "directives": [ + { + "type": "Directive", + "start": 19, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 19, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "value": "use strict", + "extra": { + "raw": "\"use strict\"", + "rawValue": "use strict" + } + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0227/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0227/options.json deleted file mode 100644 index 9fb9deaf9cba..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0227/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Unexpected reserved word 'private' (1:37)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0227/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0227/output.json new file mode 100644 index 000000000000..32efcd46a632 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0227/output.json @@ -0,0 +1,178 @@ +{ + "type": "File", + "start": 0, + "end": 47, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 47 + } + }, + "errors": [ + "SyntaxError: Unexpected reserved word 'private' (1:37)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 47, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 47 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 47, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 47 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 14 + }, + "identifierName": "hello" + }, + "name": "hello" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 17, + "end": 47, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 47 + } + }, + "body": [ + { + "type": "VariableDeclaration", + "start": 33, + "end": 45, + "loc": { + "start": { + "line": 1, + "column": 33 + }, + "end": { + "line": 1, + "column": 45 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 37, + "end": 44, + "loc": { + "start": { + "line": 1, + "column": 37 + }, + "end": { + "line": 1, + "column": 44 + } + }, + "id": { + "type": "Identifier", + "start": 37, + "end": 44, + "loc": { + "start": { + "line": 1, + "column": 37 + }, + "end": { + "line": 1, + "column": 44 + }, + "identifierName": "private" + }, + "name": "private" + }, + "init": null + } + ], + "kind": "var" + } + ], + "directives": [ + { + "type": "Directive", + "start": 19, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 19, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "value": "use strict", + "extra": { + "raw": "\"use strict\"", + "rawValue": "use strict" + } + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0228/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0228/options.json deleted file mode 100644 index 292fb56f1cf3..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0228/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Unexpected reserved word 'protected' (1:37)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0228/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0228/output.json new file mode 100644 index 000000000000..e3d3f255c253 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0228/output.json @@ -0,0 +1,178 @@ +{ + "type": "File", + "start": 0, + "end": 49, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 49 + } + }, + "errors": [ + "SyntaxError: Unexpected reserved word 'protected' (1:37)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 49, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 49 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 49, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 49 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 14 + }, + "identifierName": "hello" + }, + "name": "hello" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 17, + "end": 49, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 49 + } + }, + "body": [ + { + "type": "VariableDeclaration", + "start": 33, + "end": 47, + "loc": { + "start": { + "line": 1, + "column": 33 + }, + "end": { + "line": 1, + "column": 47 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 37, + "end": 46, + "loc": { + "start": { + "line": 1, + "column": 37 + }, + "end": { + "line": 1, + "column": 46 + } + }, + "id": { + "type": "Identifier", + "start": 37, + "end": 46, + "loc": { + "start": { + "line": 1, + "column": 37 + }, + "end": { + "line": 1, + "column": 46 + }, + "identifierName": "protected" + }, + "name": "protected" + }, + "init": null + } + ], + "kind": "var" + } + ], + "directives": [ + { + "type": "Directive", + "start": 19, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 19, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "value": "use strict", + "extra": { + "raw": "\"use strict\"", + "rawValue": "use strict" + } + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0229/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0229/options.json deleted file mode 100644 index d5f48446906a..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0229/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Unexpected reserved word 'public' (1:37)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0229/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0229/output.json new file mode 100644 index 000000000000..2e801038c78d --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0229/output.json @@ -0,0 +1,178 @@ +{ + "type": "File", + "start": 0, + "end": 46, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 46 + } + }, + "errors": [ + "SyntaxError: Unexpected reserved word 'public' (1:37)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 46, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 46 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 46, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 46 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 14 + }, + "identifierName": "hello" + }, + "name": "hello" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 17, + "end": 46, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 46 + } + }, + "body": [ + { + "type": "VariableDeclaration", + "start": 33, + "end": 44, + "loc": { + "start": { + "line": 1, + "column": 33 + }, + "end": { + "line": 1, + "column": 44 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 37, + "end": 43, + "loc": { + "start": { + "line": 1, + "column": 37 + }, + "end": { + "line": 1, + "column": 43 + } + }, + "id": { + "type": "Identifier", + "start": 37, + "end": 43, + "loc": { + "start": { + "line": 1, + "column": 37 + }, + "end": { + "line": 1, + "column": 43 + }, + "identifierName": "public" + }, + "name": "public" + }, + "init": null + } + ], + "kind": "var" + } + ], + "directives": [ + { + "type": "Directive", + "start": 19, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 19, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "value": "use strict", + "extra": { + "raw": "\"use strict\"", + "rawValue": "use strict" + } + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0230/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0230/options.json deleted file mode 100644 index 0f41ff2e6f24..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0230/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Unexpected reserved word 'static' (1:37)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0230/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0230/output.json new file mode 100644 index 000000000000..4ed420518d6d --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0230/output.json @@ -0,0 +1,178 @@ +{ + "type": "File", + "start": 0, + "end": 46, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 46 + } + }, + "errors": [ + "SyntaxError: Unexpected reserved word 'static' (1:37)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 46, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 46 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 46, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 46 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 14 + }, + "identifierName": "hello" + }, + "name": "hello" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 17, + "end": 46, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 46 + } + }, + "body": [ + { + "type": "VariableDeclaration", + "start": 33, + "end": 44, + "loc": { + "start": { + "line": 1, + "column": 33 + }, + "end": { + "line": 1, + "column": 44 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 37, + "end": 43, + "loc": { + "start": { + "line": 1, + "column": 37 + }, + "end": { + "line": 1, + "column": 43 + } + }, + "id": { + "type": "Identifier", + "start": 37, + "end": 43, + "loc": { + "start": { + "line": 1, + "column": 37 + }, + "end": { + "line": 1, + "column": 43 + }, + "identifierName": "static" + }, + "name": "static" + }, + "init": null + } + ], + "kind": "var" + } + ], + "directives": [ + { + "type": "Directive", + "start": 19, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 19, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "value": "use strict", + "extra": { + "raw": "\"use strict\"", + "rawValue": "use strict" + } + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0231/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0231/options.json deleted file mode 100644 index 6ab197f35dc9..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0231/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Unexpected reserved word 'yield' (1:37)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0231/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0231/output.json new file mode 100644 index 000000000000..55dc17f91beb --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0231/output.json @@ -0,0 +1,178 @@ +{ + "type": "File", + "start": 0, + "end": 45, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 45 + } + }, + "errors": [ + "SyntaxError: Unexpected reserved word 'yield' (1:37)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 45, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 45 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 45, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 45 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 14 + }, + "identifierName": "hello" + }, + "name": "hello" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 17, + "end": 45, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 45 + } + }, + "body": [ + { + "type": "VariableDeclaration", + "start": 33, + "end": 43, + "loc": { + "start": { + "line": 1, + "column": 33 + }, + "end": { + "line": 1, + "column": 43 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 37, + "end": 42, + "loc": { + "start": { + "line": 1, + "column": 37 + }, + "end": { + "line": 1, + "column": 42 + } + }, + "id": { + "type": "Identifier", + "start": 37, + "end": 42, + "loc": { + "start": { + "line": 1, + "column": 37 + }, + "end": { + "line": 1, + "column": 42 + }, + "identifierName": "yield" + }, + "name": "yield" + }, + "init": null + } + ], + "kind": "var" + } + ], + "directives": [ + { + "type": "Directive", + "start": 19, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 19, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "value": "use strict", + "extra": { + "raw": "\"use strict\"", + "rawValue": "use strict" + } + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0232/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0232/options.json deleted file mode 100644 index d2f3cbc2e116..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0232/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Unexpected reserved word 'let' (1:37)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0232/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0232/output.json new file mode 100644 index 000000000000..3b946aeb3223 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0232/output.json @@ -0,0 +1,178 @@ +{ + "type": "File", + "start": 0, + "end": 43, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 43 + } + }, + "errors": [ + "SyntaxError: Unexpected reserved word 'let' (1:37)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 43, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 43 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 43, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 43 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 14 + }, + "identifierName": "hello" + }, + "name": "hello" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 17, + "end": 43, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 43 + } + }, + "body": [ + { + "type": "VariableDeclaration", + "start": 33, + "end": 41, + "loc": { + "start": { + "line": 1, + "column": 33 + }, + "end": { + "line": 1, + "column": 41 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 37, + "end": 40, + "loc": { + "start": { + "line": 1, + "column": 37 + }, + "end": { + "line": 1, + "column": 40 + } + }, + "id": { + "type": "Identifier", + "start": 37, + "end": 40, + "loc": { + "start": { + "line": 1, + "column": 37 + }, + "end": { + "line": 1, + "column": 40 + }, + "identifierName": "let" + }, + "name": "let" + }, + "init": null + } + ], + "kind": "var" + } + ], + "directives": [ + { + "type": "Directive", + "start": 19, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 19, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "value": "use strict", + "extra": { + "raw": "\"use strict\"", + "rawValue": "use strict" + } + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0233/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0233/options.json deleted file mode 100644 index 78c799ec6a49..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0233/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Binding 'static' in strict mode (1:15)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0233/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0233/output.json new file mode 100644 index 000000000000..ab669586dc27 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0233/output.json @@ -0,0 +1,144 @@ +{ + "type": "File", + "start": 0, + "end": 40, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 40 + } + }, + "errors": [ + "SyntaxError: Binding 'static' in strict mode (1:15)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 40, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 40 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 40, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 40 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 14 + }, + "identifierName": "hello" + }, + "name": "hello" + }, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "start": 15, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 21 + }, + "identifierName": "static" + }, + "name": "static" + } + ], + "body": { + "type": "BlockStatement", + "start": 23, + "end": 40, + "loc": { + "start": { + "line": 1, + "column": 23 + }, + "end": { + "line": 1, + "column": 40 + } + }, + "body": [], + "directives": [ + { + "type": "Directive", + "start": 25, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 25 + }, + "end": { + "line": 1, + "column": 38 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 25, + "end": 37, + "loc": { + "start": { + "line": 1, + "column": 25 + }, + "end": { + "line": 1, + "column": 37 + } + }, + "value": "use strict", + "extra": { + "raw": "\"use strict\"", + "rawValue": "use strict" + } + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0234/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0234/options.json deleted file mode 100644 index d4a2d92e5b45..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0234/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Binding 'static' in strict mode (1:9)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0234/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0234/output.json new file mode 100644 index 000000000000..be76a2099b54 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0234/output.json @@ -0,0 +1,126 @@ +{ + "type": "File", + "start": 0, + "end": 35, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 35 + } + }, + "errors": [ + "SyntaxError: Binding 'static' in strict mode (1:9)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 35, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 35 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 35, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 35 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 15 + }, + "identifierName": "static" + }, + "name": "static" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 18, + "end": 35, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 35 + } + }, + "body": [], + "directives": [ + { + "type": "Directive", + "start": 20, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 20 + }, + "end": { + "line": 1, + "column": 33 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 20, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 20 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "value": "use strict", + "extra": { + "raw": "\"use strict\"", + "rawValue": "use strict" + } + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0235/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0235/options.json deleted file mode 100644 index 1eb91299eb1b..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0235/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Binding 'eval' in strict mode (1:9)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0235/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0235/output.json new file mode 100644 index 000000000000..df217b6af2bc --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0235/output.json @@ -0,0 +1,144 @@ +{ + "type": "File", + "start": 0, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 34 + } + }, + "errors": [ + "SyntaxError: Binding 'eval' in strict mode (1:9)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 34 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 34 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 13 + }, + "identifierName": "eval" + }, + "name": "eval" + }, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "start": 14, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 15 + }, + "identifierName": "a" + }, + "name": "a" + } + ], + "body": { + "type": "BlockStatement", + "start": 17, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 34 + } + }, + "body": [], + "directives": [ + { + "type": "Directive", + "start": 19, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 19, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "value": "use strict", + "extra": { + "raw": "\"use strict\"", + "rawValue": "use strict" + } + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0236/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0236/options.json deleted file mode 100644 index c903c1205ce8..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0236/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Binding 'arguments' in strict mode (1:9)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0236/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0236/output.json new file mode 100644 index 000000000000..0de7c6ba2ac0 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0236/output.json @@ -0,0 +1,144 @@ +{ + "type": "File", + "start": 0, + "end": 39, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 39 + } + }, + "errors": [ + "SyntaxError: Binding 'arguments' in strict mode (1:9)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 39, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 39 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 39, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 39 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 18 + }, + "identifierName": "arguments" + }, + "name": "arguments" + }, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "start": 19, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 20 + }, + "identifierName": "a" + }, + "name": "a" + } + ], + "body": { + "type": "BlockStatement", + "start": 22, + "end": 39, + "loc": { + "start": { + "line": 1, + "column": 22 + }, + "end": { + "line": 1, + "column": 39 + } + }, + "body": [], + "directives": [ + { + "type": "Directive", + "start": 24, + "end": 37, + "loc": { + "start": { + "line": 1, + "column": 24 + }, + "end": { + "line": 1, + "column": 37 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 24, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 24 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "value": "use strict", + "extra": { + "raw": "\"use strict\"", + "rawValue": "use strict" + } + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0239/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0239/options.json deleted file mode 100644 index 91bc36d3f360..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0239/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Unexpected reserved word 'static' (1:23)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0239/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0239/output.json new file mode 100644 index 000000000000..c249f39209bf --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0239/output.json @@ -0,0 +1,126 @@ +{ + "type": "File", + "start": 0, + "end": 35, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 35 + } + }, + "errors": [ + "SyntaxError: Unexpected reserved word 'static' (1:23)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 35, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 35 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 14, + "end": 35, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 35 + } + }, + "id": { + "type": "Identifier", + "start": 23, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 23 + }, + "end": { + "line": 1, + "column": 29 + }, + "identifierName": "static" + }, + "name": "static" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 32, + "end": 35, + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 35 + } + }, + "body": [], + "directives": [] + } + } + ], + "directives": [ + { + "type": "Directive", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 0, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "value": "use strict", + "extra": { + "raw": "\"use strict\"", + "rawValue": "use strict" + } + } + } + ] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0240/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0240/options.json deleted file mode 100644 index 8b20b9a7df36..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0240/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Argument name clash (1:14)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0240/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0240/output.json new file mode 100644 index 000000000000..f945eeb57491 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0240/output.json @@ -0,0 +1,161 @@ +{ + "type": "File", + "start": 0, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 34 + } + }, + "errors": [ + "SyntaxError: Argument name clash (1:14)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 34 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 34 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 10 + }, + "identifierName": "a" + }, + "name": "a" + }, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "start": 11, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 12 + }, + "identifierName": "t" + }, + "name": "t" + }, + { + "type": "Identifier", + "start": 14, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 15 + }, + "identifierName": "t" + }, + "name": "t" + } + ], + "body": { + "type": "BlockStatement", + "start": 17, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 34 + } + }, + "body": [], + "directives": [ + { + "type": "Directive", + "start": 19, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 19, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "value": "use strict", + "extra": { + "raw": "\"use strict\"", + "rawValue": "use strict" + } + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0241/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0241/options.json deleted file mode 100644 index 85fd3822f433..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0241/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Binding 'eval' in strict mode (1:11)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0241/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0241/output.json new file mode 100644 index 000000000000..f2ff5d38de33 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0241/output.json @@ -0,0 +1,144 @@ +{ + "type": "File", + "start": 0, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 34 + } + }, + "errors": [ + "SyntaxError: Binding 'eval' in strict mode (1:11)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 34 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 34 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 10 + }, + "identifierName": "a" + }, + "name": "a" + }, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "start": 11, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 15 + }, + "identifierName": "eval" + }, + "name": "eval" + } + ], + "body": { + "type": "BlockStatement", + "start": 17, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 34 + } + }, + "body": [], + "directives": [ + { + "type": "Directive", + "start": 19, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 19, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "value": "use strict", + "extra": { + "raw": "\"use strict\"", + "rawValue": "use strict" + } + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0242/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0242/options.json deleted file mode 100644 index 604b5896c2c5..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0242/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Binding 'package' in strict mode (1:11)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0242/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0242/output.json new file mode 100644 index 000000000000..2f734055a47a --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0242/output.json @@ -0,0 +1,144 @@ +{ + "type": "File", + "start": 0, + "end": 37, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 37 + } + }, + "errors": [ + "SyntaxError: Binding 'package' in strict mode (1:11)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 37, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 37 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 37, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 37 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 10 + }, + "identifierName": "a" + }, + "name": "a" + }, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "start": 11, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 18 + }, + "identifierName": "package" + }, + "name": "package" + } + ], + "body": { + "type": "BlockStatement", + "start": 20, + "end": 37, + "loc": { + "start": { + "line": 1, + "column": 20 + }, + "end": { + "line": 1, + "column": 37 + } + }, + "body": [], + "directives": [ + { + "type": "Directive", + "start": 22, + "end": 35, + "loc": { + "start": { + "line": 1, + "column": 22 + }, + "end": { + "line": 1, + "column": 35 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 22, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 22 + }, + "end": { + "line": 1, + "column": 34 + } + }, + "value": "use strict", + "extra": { + "raw": "\"use strict\"", + "rawValue": "use strict" + } + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0243/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0243/options.json deleted file mode 100644 index 9d2a58081596..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0243/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Argument name clash (1:43)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0243/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0243/output.json new file mode 100644 index 000000000000..60ac3ce8c98c --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0243/output.json @@ -0,0 +1,229 @@ +{ + "type": "File", + "start": 0, + "end": 52, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 52 + } + }, + "errors": [ + "SyntaxError: Argument name clash (1:43)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 52, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 52 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 52, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 52 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 10 + }, + "identifierName": "a" + }, + "name": "a" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 13, + "end": 52, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 52 + } + }, + "body": [ + { + "type": "FunctionDeclaration", + "start": 29, + "end": 49, + "loc": { + "start": { + "line": 1, + "column": 29 + }, + "end": { + "line": 1, + "column": 49 + } + }, + "id": { + "type": "Identifier", + "start": 38, + "end": 39, + "loc": { + "start": { + "line": 1, + "column": 38 + }, + "end": { + "line": 1, + "column": 39 + }, + "identifierName": "b" + }, + "name": "b" + }, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "start": 40, + "end": 41, + "loc": { + "start": { + "line": 1, + "column": 40 + }, + "end": { + "line": 1, + "column": 41 + }, + "identifierName": "t" + }, + "name": "t" + }, + { + "type": "Identifier", + "start": 43, + "end": 44, + "loc": { + "start": { + "line": 1, + "column": 43 + }, + "end": { + "line": 1, + "column": 44 + }, + "identifierName": "t" + }, + "name": "t" + } + ], + "body": { + "type": "BlockStatement", + "start": 46, + "end": 49, + "loc": { + "start": { + "line": 1, + "column": 46 + }, + "end": { + "line": 1, + "column": 49 + } + }, + "body": [], + "directives": [] + } + }, + { + "type": "EmptyStatement", + "start": 49, + "end": 50, + "loc": { + "start": { + "line": 1, + "column": 49 + }, + "end": { + "line": 1, + "column": 50 + } + } + } + ], + "directives": [ + { + "type": "Directive", + "start": 15, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 28 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 15, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 27 + } + }, + "value": "use strict", + "extra": { + "raw": "\"use strict\"", + "rawValue": "use strict" + } + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0244/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0244/options.json deleted file mode 100644 index 61c3bbb5abe0..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0244/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Argument name clash (1:15)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0244/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0244/output.json new file mode 100644 index 000000000000..766ec14c5a33 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0244/output.json @@ -0,0 +1,180 @@ +{ + "type": "File", + "start": 0, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "errors": [ + "SyntaxError: Argument name clash (1:15)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "expression": { + "type": "FunctionExpression", + "start": 1, + "end": 35, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 35 + } + }, + "id": { + "type": "Identifier", + "start": 10, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 11 + }, + "identifierName": "a" + }, + "name": "a" + }, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "start": 12, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 13 + }, + "identifierName": "t" + }, + "name": "t" + }, + { + "type": "Identifier", + "start": 15, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 16 + }, + "identifierName": "t" + }, + "name": "t" + } + ], + "body": { + "type": "BlockStatement", + "start": 18, + "end": 35, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 35 + } + }, + "body": [], + "directives": [ + { + "type": "Directive", + "start": 20, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 20 + }, + "end": { + "line": 1, + "column": 33 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 20, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 20 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "value": "use strict", + "extra": { + "raw": "\"use strict\"", + "rawValue": "use strict" + } + } + } + ] + }, + "extra": { + "parenthesized": true, + "parenStart": 0 + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0245/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0245/options.json deleted file mode 100644 index ae469fbd59da..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0245/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Argument name clash (1:44)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0245/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0245/output.json new file mode 100644 index 000000000000..0f2e3c5dce01 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0245/output.json @@ -0,0 +1,233 @@ +{ + "type": "File", + "start": 0, + "end": 54, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 54 + } + }, + "errors": [ + "SyntaxError: Argument name clash (1:44)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 54, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 54 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 54, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 54 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 10 + }, + "identifierName": "a" + }, + "name": "a" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 13, + "end": 54, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 54 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 29, + "end": 52, + "loc": { + "start": { + "line": 1, + "column": 29 + }, + "end": { + "line": 1, + "column": 52 + } + }, + "expression": { + "type": "FunctionExpression", + "start": 30, + "end": 50, + "loc": { + "start": { + "line": 1, + "column": 30 + }, + "end": { + "line": 1, + "column": 50 + } + }, + "id": { + "type": "Identifier", + "start": 39, + "end": 40, + "loc": { + "start": { + "line": 1, + "column": 39 + }, + "end": { + "line": 1, + "column": 40 + }, + "identifierName": "b" + }, + "name": "b" + }, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "start": 41, + "end": 42, + "loc": { + "start": { + "line": 1, + "column": 41 + }, + "end": { + "line": 1, + "column": 42 + }, + "identifierName": "t" + }, + "name": "t" + }, + { + "type": "Identifier", + "start": 44, + "end": 45, + "loc": { + "start": { + "line": 1, + "column": 44 + }, + "end": { + "line": 1, + "column": 45 + }, + "identifierName": "t" + }, + "name": "t" + } + ], + "body": { + "type": "BlockStatement", + "start": 47, + "end": 50, + "loc": { + "start": { + "line": 1, + "column": 47 + }, + "end": { + "line": 1, + "column": 50 + } + }, + "body": [], + "directives": [] + }, + "extra": { + "parenthesized": true, + "parenStart": 29 + } + } + } + ], + "directives": [ + { + "type": "Directive", + "start": 15, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 28 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 15, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 27 + } + }, + "value": "use strict", + "extra": { + "raw": "\"use strict\"", + "rawValue": "use strict" + } + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0246/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0246/options.json deleted file mode 100644 index b60957f217a4..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0246/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Binding 'eval' in strict mode (1:12)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0246/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0246/output.json new file mode 100644 index 000000000000..7945e482ca86 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0246/output.json @@ -0,0 +1,163 @@ +{ + "type": "File", + "start": 0, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "errors": [ + "SyntaxError: Binding 'eval' in strict mode (1:12)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "expression": { + "type": "FunctionExpression", + "start": 1, + "end": 35, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 35 + } + }, + "id": { + "type": "Identifier", + "start": 10, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 11 + }, + "identifierName": "a" + }, + "name": "a" + }, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "start": 12, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 16 + }, + "identifierName": "eval" + }, + "name": "eval" + } + ], + "body": { + "type": "BlockStatement", + "start": 18, + "end": 35, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 35 + } + }, + "body": [], + "directives": [ + { + "type": "Directive", + "start": 20, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 20 + }, + "end": { + "line": 1, + "column": 33 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 20, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 20 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "value": "use strict", + "extra": { + "raw": "\"use strict\"", + "rawValue": "use strict" + } + } + } + ] + }, + "extra": { + "parenthesized": true, + "parenStart": 0 + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0247/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0247/options.json deleted file mode 100644 index 62075401e782..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0247/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Binding 'package' in strict mode (1:12)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0247/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0247/output.json new file mode 100644 index 000000000000..304b4237e9e7 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0247/output.json @@ -0,0 +1,163 @@ +{ + "type": "File", + "start": 0, + "end": 39, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 39 + } + }, + "errors": [ + "SyntaxError: Binding 'package' in strict mode (1:12)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 39, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 39 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 39, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 39 + } + }, + "expression": { + "type": "FunctionExpression", + "start": 1, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 38 + } + }, + "id": { + "type": "Identifier", + "start": 10, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 11 + }, + "identifierName": "a" + }, + "name": "a" + }, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "start": 12, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 19 + }, + "identifierName": "package" + }, + "name": "package" + } + ], + "body": { + "type": "BlockStatement", + "start": 21, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 21 + }, + "end": { + "line": 1, + "column": 38 + } + }, + "body": [], + "directives": [ + { + "type": "Directive", + "start": 23, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 23 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 23, + "end": 35, + "loc": { + "start": { + "line": 1, + "column": 23 + }, + "end": { + "line": 1, + "column": 35 + } + }, + "value": "use strict", + "extra": { + "raw": "\"use strict\"", + "rawValue": "use strict" + } + } + } + ] + }, + "extra": { + "parenthesized": true, + "parenStart": 0 + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0248/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0248/options.json deleted file mode 100644 index cb5abd9f7401..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0248/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Label '__proto__' is already declared (1:11)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0248/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0248/output.json new file mode 100644 index 000000000000..2b1e638019cc --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0248/output.json @@ -0,0 +1,137 @@ +{ + "type": "File", + "start": 0, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 25 + } + }, + "errors": [ + "SyntaxError: Label '__proto__' is already declared (1:11)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 25 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "LabeledStatement", + "start": 0, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 25 + } + }, + "body": { + "type": "LabeledStatement", + "start": 11, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 25 + } + }, + "body": { + "type": "ExpressionStatement", + "start": 22, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 22 + }, + "end": { + "line": 1, + "column": 25 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 22, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 22 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "extra": { + "rawValue": 42, + "raw": "42" + }, + "value": 42 + } + }, + "label": { + "type": "Identifier", + "start": 11, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 20 + }, + "identifierName": "__proto__" + }, + "name": "__proto__" + } + }, + "label": { + "type": "Identifier", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + }, + "identifierName": "__proto__" + }, + "name": "__proto__" + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0249/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0249/options.json deleted file mode 100644 index 505798d5a203..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0249/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Argument name clash (1:36)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0249/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0249/output.json new file mode 100644 index 000000000000..45d9e76d63b8 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0249/output.json @@ -0,0 +1,161 @@ +{ + "type": "File", + "start": 0, + "end": 50, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 50 + } + }, + "errors": [ + "SyntaxError: Argument name clash (1:36)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 50, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 50 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 14, + "end": 50, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 50 + } + }, + "id": { + "type": "Identifier", + "start": 23, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 23 + }, + "end": { + "line": 1, + "column": 24 + }, + "identifierName": "t" + }, + "name": "t" + }, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "start": 25, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 25 + }, + "end": { + "line": 1, + "column": 34 + }, + "identifierName": "__proto__" + }, + "name": "__proto__" + }, + { + "type": "Identifier", + "start": 36, + "end": 45, + "loc": { + "start": { + "line": 1, + "column": 36 + }, + "end": { + "line": 1, + "column": 45 + }, + "identifierName": "__proto__" + }, + "name": "__proto__" + } + ], + "body": { + "type": "BlockStatement", + "start": 47, + "end": 50, + "loc": { + "start": { + "line": 1, + "column": 47 + }, + "end": { + "line": 1, + "column": 50 + } + }, + "body": [], + "directives": [] + } + } + ], + "directives": [ + { + "type": "Directive", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 0, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "value": "use strict", + "extra": { + "raw": "\"use strict\"", + "rawValue": "use strict" + } + } + } + ] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0250/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0250/options.json deleted file mode 100644 index 8e9b9f585996..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0250/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Redefinition of __proto__ property (1:21)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0250/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0250/output.json new file mode 100644 index 000000000000..6c9cf3db90bb --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0250/output.json @@ -0,0 +1,213 @@ +{ + "type": "File", + "start": 0, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "errors": [ + "SyntaxError: Redefinition of __proto__ property (1:21)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "expression": { + "type": "AssignmentExpression", + "start": 0, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "operator": "=", + "left": { + "type": "Identifier", + "start": 0, + "end": 1, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 1 + }, + "identifierName": "x" + }, + "name": "x" + }, + "right": { + "type": "ObjectExpression", + "start": 4, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "properties": [ + { + "type": "ObjectProperty", + "start": 6, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "method": false, + "key": { + "type": "Identifier", + "start": 6, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 15 + }, + "identifierName": "__proto__" + }, + "name": "__proto__" + }, + "computed": false, + "shorthand": false, + "value": { + "type": "NumericLiteral", + "start": 17, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "extra": { + "rawValue": 42, + "raw": "42" + }, + "value": 42 + } + }, + { + "type": "ObjectProperty", + "start": 21, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 21 + }, + "end": { + "line": 1, + "column": 34 + } + }, + "method": false, + "key": { + "type": "Identifier", + "start": 21, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 21 + }, + "end": { + "line": 1, + "column": 30 + }, + "identifierName": "__proto__" + }, + "name": "__proto__" + }, + "computed": false, + "shorthand": false, + "value": { + "type": "NumericLiteral", + "start": 32, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 34 + } + }, + "extra": { + "rawValue": 43, + "raw": "43" + }, + "value": 43 + } + } + ] + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0270/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0270/options.json deleted file mode 100644 index 8df109cb3c33..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0270/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Classes may not have static property named prototype (1:16)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0270/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0270/output.json new file mode 100644 index 000000000000..3c3b792e5b9b --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0270/output.json @@ -0,0 +1,144 @@ +{ + "type": "File", + "start": 0, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "errors": [ + "SyntaxError: Classes may not have static property named prototype (1:16)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ClassDeclaration", + "start": 0, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "id": { + "type": "Identifier", + "start": 6, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + }, + "identifierName": "A" + }, + "name": "A" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "start": 8, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "body": [ + { + "type": "ClassMethod", + "start": 9, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "static": true, + "key": { + "type": "Identifier", + "start": 16, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 25 + }, + "identifierName": "prototype" + }, + "name": "prototype" + }, + "computed": false, + "kind": "method", + "id": null, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 27, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 27 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "body": [], + "directives": [] + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0271/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0271/options.json deleted file mode 100644 index 8df109cb3c33..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0271/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Classes may not have static property named prototype (1:16)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0271/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0271/output.json new file mode 100644 index 000000000000..0c00e7e06841 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0271/output.json @@ -0,0 +1,147 @@ +{ + "type": "File", + "start": 0, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "errors": [ + "SyntaxError: Classes may not have static property named prototype (1:16)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ClassDeclaration", + "start": 0, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "id": { + "type": "Identifier", + "start": 6, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + }, + "identifierName": "A" + }, + "name": "A" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "start": 8, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "body": [ + { + "type": "ClassMethod", + "start": 9, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "static": true, + "key": { + "type": "StringLiteral", + "start": 16, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 27 + } + }, + "extra": { + "rawValue": "prototype", + "raw": "\"prototype\"" + }, + "value": "prototype" + }, + "computed": false, + "kind": "method", + "id": null, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 29, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 29 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "body": [], + "directives": [] + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0272/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0272/options.json deleted file mode 100644 index f4b1d256a4ab..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0272/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Constructor can't have get/set modifier (1:13)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0272/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0272/output.json new file mode 100644 index 000000000000..d583a2ec1119 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0272/output.json @@ -0,0 +1,144 @@ +{ + "type": "File", + "start": 0, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "errors": [ + "SyntaxError: Constructor can't have get/set modifier (1:13)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ClassDeclaration", + "start": 0, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "id": { + "type": "Identifier", + "start": 6, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + }, + "identifierName": "A" + }, + "name": "A" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "start": 8, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "body": [ + { + "type": "ClassMethod", + "start": 9, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 28 + } + }, + "static": false, + "key": { + "type": "Identifier", + "start": 13, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 24 + }, + "identifierName": "constructor" + }, + "name": "constructor" + }, + "computed": false, + "kind": "get", + "id": null, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 26, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 26 + }, + "end": { + "line": 1, + "column": 28 + } + }, + "body": [], + "directives": [] + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0273/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0273/options.json deleted file mode 100644 index f4b1d256a4ab..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0273/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Constructor can't have get/set modifier (1:13)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0273/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0273/output.json new file mode 100644 index 000000000000..532d8ebe70a8 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0273/output.json @@ -0,0 +1,162 @@ +{ + "type": "File", + "start": 0, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "errors": [ + "SyntaxError: Constructor can't have get/set modifier (1:13)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ClassDeclaration", + "start": 0, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "id": { + "type": "Identifier", + "start": 6, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + }, + "identifierName": "A" + }, + "name": "A" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "start": 8, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "body": [ + { + "type": "ClassMethod", + "start": 9, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "static": false, + "key": { + "type": "Identifier", + "start": 13, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 24 + }, + "identifierName": "constructor" + }, + "name": "constructor" + }, + "computed": false, + "kind": "set", + "id": null, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "start": 25, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 25 + }, + "end": { + "line": 1, + "column": 26 + }, + "identifierName": "m" + }, + "name": "m" + } + ], + "body": { + "type": "BlockStatement", + "start": 27, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 27 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "body": [], + "directives": [] + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0274/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0274/options.json deleted file mode 100644 index 4d892adceff9..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0274/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Duplicate constructor in the same class (1:25)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0274/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0274/output.json new file mode 100644 index 000000000000..4337adcf6eb6 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0274/output.json @@ -0,0 +1,203 @@ +{ + "type": "File", + "start": 0, + "end": 43, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 43 + } + }, + "errors": [ + "SyntaxError: Duplicate constructor in the same class (1:25)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 43, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 43 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ClassDeclaration", + "start": 0, + "end": 43, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 43 + } + }, + "id": { + "type": "Identifier", + "start": 6, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + }, + "identifierName": "A" + }, + "name": "A" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "start": 8, + "end": 43, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 43 + } + }, + "body": [ + { + "type": "ClassMethod", + "start": 9, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "static": false, + "key": { + "type": "Identifier", + "start": 9, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 20 + }, + "identifierName": "constructor" + }, + "name": "constructor" + }, + "computed": false, + "kind": "constructor", + "id": null, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 22, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 22 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "body": [], + "directives": [] + } + }, + { + "type": "ClassMethod", + "start": 25, + "end": 42, + "loc": { + "start": { + "line": 1, + "column": 25 + }, + "end": { + "line": 1, + "column": 42 + } + }, + "static": false, + "key": { + "type": "StringLiteral", + "start": 25, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 25 + }, + "end": { + "line": 1, + "column": 38 + } + }, + "extra": { + "rawValue": "constructor", + "raw": "\"constructor\"" + }, + "value": "constructor" + }, + "computed": false, + "kind": "constructor", + "id": null, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 40, + "end": 42, + "loc": { + "start": { + "line": 1, + "column": 40 + }, + "end": { + "line": 1, + "column": 42 + } + }, + "body": [], + "directives": [] + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0277/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0277/options.json deleted file mode 100644 index aef7f56007e9..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0277/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Unexpected reserved word 'enum' (1:11)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0277/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0277/output.json new file mode 100644 index 000000000000..df10adea166e --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0277/output.json @@ -0,0 +1,162 @@ +{ + "type": "File", + "start": 0, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "errors": [ + "SyntaxError: Unexpected reserved word 'enum' (1:11)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ClassDeclaration", + "start": 0, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "id": { + "type": "Identifier", + "start": 6, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + }, + "identifierName": "A" + }, + "name": "A" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "start": 8, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "body": [ + { + "type": "ClassMethod", + "start": 9, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "static": false, + "key": { + "type": "Identifier", + "start": 9, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 10 + }, + "identifierName": "a" + }, + "name": "a" + }, + "computed": false, + "kind": "method", + "id": null, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "start": 11, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 15 + }, + "identifierName": "enum" + }, + "name": "enum" + } + ], + "body": { + "type": "BlockStatement", + "start": 16, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "body": [], + "directives": [] + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0278/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0278/options.json deleted file mode 100644 index 757b207f0ef2..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0278/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Unexpected reserved word 'static' (1:17)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0278/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0278/output.json new file mode 100644 index 000000000000..275b0d3ee35a --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0278/output.json @@ -0,0 +1,144 @@ +{ + "type": "File", + "start": 0, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "errors": [ + "SyntaxError: Unexpected reserved word 'static' (1:17)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ClassDeclaration", + "start": 0, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "id": { + "type": "Identifier", + "start": 6, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + }, + "identifierName": "A" + }, + "name": "A" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "start": 8, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "body": [ + { + "type": "ClassMethod", + "start": 9, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 28 + } + }, + "static": true, + "computed": true, + "key": { + "type": "Identifier", + "start": 17, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 23 + }, + "identifierName": "static" + }, + "name": "static" + }, + "kind": "method", + "id": null, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 26, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 26 + }, + "end": { + "line": 1, + "column": 28 + } + }, + "body": [], + "directives": [] + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/rest-parameter/invalid-setter-rest/options.json b/packages/babel-parser/test/fixtures/esprima/rest-parameter/invalid-setter-rest/options.json deleted file mode 100644 index 0006fbf98e5c..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/rest-parameter/invalid-setter-rest/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "setter function argument must not be a rest parameter (1:6)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/rest-parameter/invalid-setter-rest/output.json b/packages/babel-parser/test/fixtures/esprima/rest-parameter/invalid-setter-rest/output.json new file mode 100644 index 000000000000..30ec6b3832e2 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/rest-parameter/invalid-setter-rest/output.json @@ -0,0 +1,192 @@ +{ + "type": "File", + "start": 0, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "errors": [ + "SyntaxError: setter function argument must not be a rest parameter (1:6)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "expression": { + "type": "AssignmentExpression", + "start": 0, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "operator": "=", + "left": { + "type": "Identifier", + "start": 0, + "end": 1, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 1 + }, + "identifierName": "x" + }, + "name": "x" + }, + "right": { + "type": "ObjectExpression", + "start": 4, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "properties": [ + { + "type": "ObjectMethod", + "start": 6, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "method": false, + "key": { + "type": "Identifier", + "start": 10, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 11 + }, + "identifierName": "f" + }, + "name": "f" + }, + "computed": false, + "kind": "set", + "id": null, + "generator": false, + "async": false, + "params": [ + { + "type": "RestElement", + "start": 12, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "argument": { + "type": "Identifier", + "start": 15, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 16 + }, + "identifierName": "y" + }, + "name": "y" + } + } + ], + "body": { + "type": "BlockStatement", + "start": 18, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "body": [], + "directives": [] + } + } + ] + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/statement-expression/migrated_0002/options.json b/packages/babel-parser/test/fixtures/esprima/statement-expression/migrated_0002/options.json deleted file mode 100644 index 381fd12ce2d0..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/statement-expression/migrated_0002/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Expecting Unicode escape sequence \\uXXXX (1:1)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/statement-expression/migrated_0002/output.json b/packages/babel-parser/test/fixtures/esprima/statement-expression/migrated_0002/output.json new file mode 100644 index 000000000000..e418d699ca2c --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/statement-expression/migrated_0002/output.json @@ -0,0 +1,70 @@ +{ + "type": "File", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "errors": [ + "SyntaxError: Expecting Unicode escape sequence \\uXXXX (1:1)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "expression": { + "type": "Identifier", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + }, + "identifierName": "\\a" + }, + "name": "\\a" + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/statement-expression/migrated_0003/options.json b/packages/babel-parser/test/fixtures/esprima/statement-expression/migrated_0003/options.json deleted file mode 100644 index 18c53b997b56..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/statement-expression/migrated_0003/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Expecting Unicode escape sequence \\uXXXX (1:2)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/statement-expression/migrated_0003/output.json b/packages/babel-parser/test/fixtures/esprima/statement-expression/migrated_0003/output.json new file mode 100644 index 000000000000..6f022e5637c6 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/statement-expression/migrated_0003/output.json @@ -0,0 +1,70 @@ +{ + "type": "File", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "errors": [ + "SyntaxError: Expecting Unicode escape sequence \\uXXXX (1:2)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "expression": { + "type": "Identifier", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + }, + "identifierName": "aa\\a" + }, + "name": "aa\\a" + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/statement-expression/migrated_0004/options.json b/packages/babel-parser/test/fixtures/esprima/statement-expression/migrated_0004/options.json deleted file mode 100644 index 381fd12ce2d0..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/statement-expression/migrated_0004/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Expecting Unicode escape sequence \\uXXXX (1:1)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/statement-expression/migrated_0004/output.json b/packages/babel-parser/test/fixtures/esprima/statement-expression/migrated_0004/output.json new file mode 100644 index 000000000000..c0f511826127 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/statement-expression/migrated_0004/output.json @@ -0,0 +1,70 @@ +{ + "type": "File", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "errors": [ + "SyntaxError: Expecting Unicode escape sequence \\uXXXX (1:1)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "expression": { + "type": "Identifier", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + }, + "identifierName": "\\aa" + }, + "name": "\\aa" + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/statement-expression/migrated_0005/options.json b/packages/babel-parser/test/fixtures/esprima/statement-expression/migrated_0005/options.json deleted file mode 100644 index 381fd12ce2d0..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/statement-expression/migrated_0005/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Expecting Unicode escape sequence \\uXXXX (1:1)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/statement-expression/migrated_0005/output.json b/packages/babel-parser/test/fixtures/esprima/statement-expression/migrated_0005/output.json new file mode 100644 index 000000000000..c0f511826127 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/statement-expression/migrated_0005/output.json @@ -0,0 +1,70 @@ +{ + "type": "File", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "errors": [ + "SyntaxError: Expecting Unicode escape sequence \\uXXXX (1:1)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "expression": { + "type": "Identifier", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + }, + "identifierName": "\\aa" + }, + "name": "\\aa" + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/statement-variable/complex-pattern-requires-init/options.json b/packages/babel-parser/test/fixtures/esprima/statement-variable/complex-pattern-requires-init/options.json deleted file mode 100644 index 57893e4eee56..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/statement-variable/complex-pattern-requires-init/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Complex binding patterns require an initialization value (1:6)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/statement-variable/complex-pattern-requires-init/output.json b/packages/babel-parser/test/fixtures/esprima/statement-variable/complex-pattern-requires-init/output.json new file mode 100644 index 000000000000..8c9fa87e494e --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/statement-variable/complex-pattern-requires-init/output.json @@ -0,0 +1,88 @@ +{ + "type": "File", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "errors": [ + "SyntaxError: Complex binding patterns require an initialization value (1:6)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "VariableDeclaration", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 4, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "id": { + "type": "ArrayPattern", + "start": 4, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "elements": [] + }, + "init": null + } + ], + "kind": "var" + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/_no-plugin/export-namespace/options.json b/packages/babel-parser/test/fixtures/experimental/_no-plugin/export-namespace/options.json deleted file mode 100644 index b8b7c829daad..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/_no-plugin/export-namespace/options.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "throws": "This experimental syntax requires enabling the parser plugin: 'exportNamespaceFrom' (1:9)", - "plugins": [] -} diff --git a/packages/babel-parser/test/fixtures/experimental/bigint/invalid-decimal/options.json b/packages/babel-parser/test/fixtures/experimental/bigint/invalid-decimal/options.json deleted file mode 100644 index a1fd77a3341e..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/bigint/invalid-decimal/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid BigIntLiteral (1:0)" } diff --git a/packages/babel-parser/test/fixtures/experimental/bigint/invalid-decimal/output.json b/packages/babel-parser/test/fixtures/experimental/bigint/invalid-decimal/output.json new file mode 100644 index 000000000000..26cbd0245288 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/bigint/invalid-decimal/output.json @@ -0,0 +1,73 @@ +{ + "type": "File", + "start": 0, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "errors": [ + "SyntaxError: Invalid BigIntLiteral (1:0)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "expression": { + "type": "BigIntLiteral", + "start": 0, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "extra": { + "rawValue": "1.0", + "raw": "1.0n" + }, + "value": "1.0" + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/bigint/invalid-e/options.json b/packages/babel-parser/test/fixtures/experimental/bigint/invalid-e/options.json deleted file mode 100644 index a1fd77a3341e..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/bigint/invalid-e/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid BigIntLiteral (1:0)" } diff --git a/packages/babel-parser/test/fixtures/experimental/bigint/invalid-e/output.json b/packages/babel-parser/test/fixtures/experimental/bigint/invalid-e/output.json new file mode 100644 index 000000000000..527c53215960 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/bigint/invalid-e/output.json @@ -0,0 +1,73 @@ +{ + "type": "File", + "start": 0, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "errors": [ + "SyntaxError: Invalid BigIntLiteral (1:0)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "expression": { + "type": "BigIntLiteral", + "start": 0, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "extra": { + "rawValue": "2e9", + "raw": "2e9n" + }, + "value": "2e9" + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/bigint/invalid-non-octal-decimal-int/options.json b/packages/babel-parser/test/fixtures/experimental/bigint/invalid-non-octal-decimal-int/options.json index a1fd77a3341e..8078d8f00dad 100644 --- a/packages/babel-parser/test/fixtures/experimental/bigint/invalid-non-octal-decimal-int/options.json +++ b/packages/babel-parser/test/fixtures/experimental/bigint/invalid-non-octal-decimal-int/options.json @@ -1 +1,5 @@ -{ "throws": "Invalid BigIntLiteral (1:0)" } +{ + "plugins": [ + "bigInt" + ] +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/bigint/invalid-non-octal-decimal-int/output.json b/packages/babel-parser/test/fixtures/experimental/bigint/invalid-non-octal-decimal-int/output.json new file mode 100644 index 000000000000..86220085cd71 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/bigint/invalid-non-octal-decimal-int/output.json @@ -0,0 +1,73 @@ +{ + "type": "File", + "start": 0, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "errors": [ + "SyntaxError: Invalid BigIntLiteral (1:0)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "expression": { + "type": "BigIntLiteral", + "start": 0, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "extra": { + "rawValue": "089", + "raw": "089n" + }, + "value": "089" + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/bigint/invalid-octal-legacy/options.json b/packages/babel-parser/test/fixtures/experimental/bigint/invalid-octal-legacy/options.json deleted file mode 100644 index a1fd77a3341e..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/bigint/invalid-octal-legacy/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid BigIntLiteral (1:0)" } diff --git a/packages/babel-parser/test/fixtures/experimental/bigint/invalid-octal-legacy/output.json b/packages/babel-parser/test/fixtures/experimental/bigint/invalid-octal-legacy/output.json new file mode 100644 index 000000000000..baa4133652f9 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/bigint/invalid-octal-legacy/output.json @@ -0,0 +1,73 @@ +{ + "type": "File", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "errors": [ + "SyntaxError: Invalid BigIntLiteral (1:0)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "expression": { + "type": "BigIntLiteral", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "extra": { + "rawValue": "016432", + "raw": "016432n" + }, + "value": "016432" + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/class-private-methods/failure-name-constructor/options.json b/packages/babel-parser/test/fixtures/experimental/class-private-methods/failure-name-constructor/options.json index d702f4db972b..a6ccef275874 100644 --- a/packages/babel-parser/test/fixtures/experimental/class-private-methods/failure-name-constructor/options.json +++ b/packages/babel-parser/test/fixtures/experimental/class-private-methods/failure-name-constructor/options.json @@ -1,4 +1,5 @@ { - "throws": "Classes may not have a private field named '#constructor' (2:2)", - "plugins": ["classPrivateMethods"] -} + "plugins": [ + "classPrivateMethods" + ] +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/class-private-methods/failure-name-constructor/output.json b/packages/babel-parser/test/fixtures/experimental/class-private-methods/failure-name-constructor/output.json new file mode 100644 index 000000000000..342fc174b592 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/class-private-methods/failure-name-constructor/output.json @@ -0,0 +1,158 @@ +{ + "type": "File", + "start": 0, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "errors": [ + "SyntaxError: Classes may not have a private field named '#constructor' (2:2)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ClassDeclaration", + "start": 0, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 6, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 9 + }, + "identifierName": "Foo" + }, + "name": "Foo" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "start": 10, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "body": [ + { + "type": "ClassPrivateMethod", + "start": 14, + "end": 31, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 19 + } + }, + "static": false, + "key": { + "type": "PrivateName", + "start": 14, + "end": 26, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 14 + } + }, + "id": { + "type": "Identifier", + "start": 15, + "end": 26, + "loc": { + "start": { + "line": 2, + "column": 3 + }, + "end": { + "line": 2, + "column": 14 + }, + "identifierName": "constructor" + }, + "name": "constructor" + } + }, + "kind": "method", + "id": null, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 29, + "end": 31, + "loc": { + "start": { + "line": 2, + "column": 17 + }, + "end": { + "line": 2, + "column": 19 + } + }, + "body": [], + "directives": [] + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/class-private-methods/failure-spaces/options.json b/packages/babel-parser/test/fixtures/experimental/class-private-methods/failure-spaces/options.json index 9914950b66fe..8d265ec66c23 100644 --- a/packages/babel-parser/test/fixtures/experimental/class-private-methods/failure-spaces/options.json +++ b/packages/babel-parser/test/fixtures/experimental/class-private-methods/failure-spaces/options.json @@ -1,4 +1,3 @@ { - "throws": "Unexpected space between # and identifier (2:3)", "plugins": ["classPrivateMethods"] } diff --git a/packages/babel-parser/test/fixtures/experimental/class-private-methods/failure-spaces/output.json b/packages/babel-parser/test/fixtures/experimental/class-private-methods/failure-spaces/output.json new file mode 100644 index 000000000000..e126bf7fb5fb --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/class-private-methods/failure-spaces/output.json @@ -0,0 +1,207 @@ +{ + "type": "File", + "start": 0, + "end": 60, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 5, + "column": 1 + } + }, + "errors": [ + "SyntaxError: Unexpected space between # and identifier (2:3)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 60, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 5, + "column": 1 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ClassDeclaration", + "start": 0, + "end": 60, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 5, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 6, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 12 + }, + "identifierName": "Spaces" + }, + "name": "Spaces" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "start": 13, + "end": 60, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 5, + "column": 1 + } + }, + "body": [ + { + "type": "ClassPrivateMethod", + "start": 17, + "end": 58, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 4, + "column": 3 + } + }, + "static": false, + "key": { + "type": "PrivateName", + "start": 17, + "end": 31, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 16 + } + }, + "id": { + "type": "Identifier", + "start": 20, + "end": 31, + "loc": { + "start": { + "line": 2, + "column": 5 + }, + "end": { + "line": 2, + "column": 16 + }, + "identifierName": "wrongSpaces" + }, + "name": "wrongSpaces" + } + }, + "kind": "method", + "id": null, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 34, + "end": 58, + "loc": { + "start": { + "line": 2, + "column": 19 + }, + "end": { + "line": 4, + "column": 3 + } + }, + "body": [ + { + "type": "ReturnStatement", + "start": 40, + "end": 54, + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 18 + } + }, + "argument": { + "type": "CallExpression", + "start": 47, + "end": 53, + "loc": { + "start": { + "line": 3, + "column": 11 + }, + "end": { + "line": 3, + "column": 17 + } + }, + "callee": { + "type": "Identifier", + "start": 47, + "end": 51, + "loc": { + "start": { + "line": 3, + "column": 11 + }, + "end": { + "line": 3, + "column": 15 + }, + "identifierName": "fail" + }, + "name": "fail" + }, + "arguments": [] + } + } + ], + "directives": [] + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/class-private-properties/failure-delete-private-property/options.json b/packages/babel-parser/test/fixtures/experimental/class-private-properties/failure-delete-private-property/options.json index e9f18e93d1d5..1ca5069a3a2f 100644 --- a/packages/babel-parser/test/fixtures/experimental/class-private-properties/failure-delete-private-property/options.json +++ b/packages/babel-parser/test/fixtures/experimental/class-private-properties/failure-delete-private-property/options.json @@ -1,4 +1,5 @@ { - "throws": "Deleting a private field is not allowed (4:4)", - "plugins": ["classPrivateProperties"] -} + "plugins": [ + "classPrivateProperties" + ] +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/class-private-properties/failure-delete-private-property/output.json b/packages/babel-parser/test/fixtures/experimental/class-private-properties/failure-delete-private-property/output.json new file mode 100644 index 000000000000..1f5d18e55096 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/class-private-properties/failure-delete-private-property/output.json @@ -0,0 +1,289 @@ +{ + "type": "File", + "start": 0, + "end": 61, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 6, + "column": 1 + } + }, + "errors": [ + "SyntaxError: Deleting a private field is not allowed (4:4)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 61, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 6, + "column": 1 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ClassDeclaration", + "start": 0, + "end": 61, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 6, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 6, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 9 + }, + "identifierName": "Foo" + }, + "name": "Foo" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "start": 10, + "end": 61, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 6, + "column": 1 + } + }, + "body": [ + { + "type": "ClassPrivateProperty", + "start": 14, + "end": 17, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 5 + } + }, + "static": false, + "key": { + "type": "PrivateName", + "start": 14, + "end": 16, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 4 + } + }, + "id": { + "type": "Identifier", + "start": 15, + "end": 16, + "loc": { + "start": { + "line": 2, + "column": 3 + }, + "end": { + "line": 2, + "column": 4 + }, + "identifierName": "x" + }, + "name": "x" + } + }, + "value": null + }, + { + "type": "ClassMethod", + "start": 20, + "end": 59, + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 5, + "column": 3 + } + }, + "static": false, + "key": { + "type": "Identifier", + "start": 20, + "end": 31, + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 3, + "column": 13 + }, + "identifierName": "constructor" + }, + "name": "constructor" + }, + "computed": false, + "kind": "constructor", + "id": null, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 34, + "end": 59, + "loc": { + "start": { + "line": 3, + "column": 16 + }, + "end": { + "line": 5, + "column": 3 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 40, + "end": 55, + "loc": { + "start": { + "line": 4, + "column": 4 + }, + "end": { + "line": 4, + "column": 19 + } + }, + "expression": { + "type": "UnaryExpression", + "start": 40, + "end": 54, + "loc": { + "start": { + "line": 4, + "column": 4 + }, + "end": { + "line": 4, + "column": 18 + } + }, + "operator": "delete", + "prefix": true, + "argument": { + "type": "MemberExpression", + "start": 47, + "end": 54, + "loc": { + "start": { + "line": 4, + "column": 11 + }, + "end": { + "line": 4, + "column": 18 + } + }, + "object": { + "type": "ThisExpression", + "start": 47, + "end": 51, + "loc": { + "start": { + "line": 4, + "column": 11 + }, + "end": { + "line": 4, + "column": 15 + } + } + }, + "property": { + "type": "PrivateName", + "start": 52, + "end": 54, + "loc": { + "start": { + "line": 4, + "column": 16 + }, + "end": { + "line": 4, + "column": 18 + } + }, + "id": { + "type": "Identifier", + "start": 53, + "end": 54, + "loc": { + "start": { + "line": 4, + "column": 17 + }, + "end": { + "line": 4, + "column": 18 + }, + "identifierName": "x" + }, + "name": "x" + } + }, + "computed": false + } + } + } + ], + "directives": [] + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/class-private-properties/failure-name-constructor/options.json b/packages/babel-parser/test/fixtures/experimental/class-private-properties/failure-name-constructor/options.json index 51343aac3b23..1ca5069a3a2f 100644 --- a/packages/babel-parser/test/fixtures/experimental/class-private-properties/failure-name-constructor/options.json +++ b/packages/babel-parser/test/fixtures/experimental/class-private-properties/failure-name-constructor/options.json @@ -1,4 +1,5 @@ { - "throws": "Classes may not have a private field named '#constructor' (2:2)", - "plugins": ["classPrivateProperties"] -} + "plugins": [ + "classPrivateProperties" + ] +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/class-private-properties/failure-name-constructor/output.json b/packages/babel-parser/test/fixtures/experimental/class-private-properties/failure-name-constructor/output.json new file mode 100644 index 000000000000..1f4da38f9f9f --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/class-private-properties/failure-name-constructor/output.json @@ -0,0 +1,137 @@ +{ + "type": "File", + "start": 0, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "errors": [ + "SyntaxError: Classes may not have a private field named '#constructor' (2:2)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ClassDeclaration", + "start": 0, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 6, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 9 + }, + "identifierName": "Foo" + }, + "name": "Foo" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "start": 10, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "body": [ + { + "type": "ClassPrivateProperty", + "start": 14, + "end": 27, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 15 + } + }, + "static": false, + "key": { + "type": "PrivateName", + "start": 14, + "end": 26, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 14 + } + }, + "id": { + "type": "Identifier", + "start": 15, + "end": 26, + "loc": { + "start": { + "line": 2, + "column": 3 + }, + "end": { + "line": 2, + "column": 14 + }, + "identifierName": "constructor" + }, + "name": "constructor" + } + }, + "value": null + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/class-private-properties/failure-spaces/options.json b/packages/babel-parser/test/fixtures/experimental/class-private-properties/failure-spaces/options.json index 9914950b66fe..f26e916957c8 100644 --- a/packages/babel-parser/test/fixtures/experimental/class-private-properties/failure-spaces/options.json +++ b/packages/babel-parser/test/fixtures/experimental/class-private-properties/failure-spaces/options.json @@ -1,4 +1,3 @@ { - "throws": "Unexpected space between # and identifier (2:3)", - "plugins": ["classPrivateMethods"] + "plugins": ["classPrivateProperties"] } diff --git a/packages/babel-parser/test/fixtures/experimental/class-private-properties/failure-spaces/output.json b/packages/babel-parser/test/fixtures/experimental/class-private-properties/failure-spaces/output.json new file mode 100644 index 000000000000..34003e4e9209 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/class-private-properties/failure-spaces/output.json @@ -0,0 +1,137 @@ +{ + "type": "File", + "start": 0, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "errors": [ + "SyntaxError: Unexpected space between # and identifier (2:3)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ClassDeclaration", + "start": 0, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 6, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 12 + }, + "identifierName": "Spaces" + }, + "name": "Spaces" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "start": 13, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "body": [ + { + "type": "ClassPrivateProperty", + "start": 17, + "end": 32, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 17 + } + }, + "static": false, + "key": { + "type": "PrivateName", + "start": 17, + "end": 31, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 16 + } + }, + "id": { + "type": "Identifier", + "start": 20, + "end": 31, + "loc": { + "start": { + "line": 2, + "column": 5 + }, + "end": { + "line": 2, + "column": 16 + }, + "identifierName": "wrongSpaces" + }, + "name": "wrongSpaces" + } + }, + "value": null + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/class-private-properties/super-call/options.json b/packages/babel-parser/test/fixtures/experimental/class-private-properties/super-call/options.json index 2154c844bfd7..1ca5069a3a2f 100644 --- a/packages/babel-parser/test/fixtures/experimental/class-private-properties/super-call/options.json +++ b/packages/babel-parser/test/fixtures/experimental/class-private-properties/super-call/options.json @@ -1,4 +1,5 @@ { - "plugins": ["classPrivateProperties"], - "throws": "super() is only valid inside a class constructor of a subclass. Maybe a typo in the method name ('constructor') or not extending another class? (4:13)" -} + "plugins": [ + "classPrivateProperties" + ] +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/class-private-properties/super-call/output.json b/packages/babel-parser/test/fixtures/experimental/class-private-properties/super-call/output.json new file mode 100644 index 000000000000..26e00894a7a7 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/class-private-properties/super-call/output.json @@ -0,0 +1,306 @@ +{ + "type": "File", + "start": 0, + "end": 95, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 7, + "column": 1 + } + }, + "errors": [ + "SyntaxError: super() is only valid inside a class constructor of a subclass. Maybe a typo in the method name ('constructor') or not extending another class? (4:13)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 95, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 7, + "column": 1 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ClassDeclaration", + "start": 0, + "end": 95, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 7, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 6, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + }, + "identifierName": "A" + }, + "name": "A" + }, + "superClass": { + "type": "Identifier", + "start": 16, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 17 + }, + "identifierName": "B" + }, + "name": "B" + }, + "body": { + "type": "ClassBody", + "start": 18, + "end": 95, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 7, + "column": 1 + } + }, + "body": [ + { + "type": "ClassMethod", + "start": 22, + "end": 93, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 6, + "column": 3 + } + }, + "static": false, + "key": { + "type": "Identifier", + "start": 22, + "end": 33, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 13 + }, + "identifierName": "constructor" + }, + "name": "constructor" + }, + "computed": false, + "kind": "constructor", + "id": null, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 36, + "end": 93, + "loc": { + "start": { + "line": 2, + "column": 16 + }, + "end": { + "line": 6, + "column": 3 + } + }, + "body": [ + { + "type": "ClassDeclaration", + "start": 42, + "end": 89, + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 5, + "column": 5 + } + }, + "id": { + "type": "Identifier", + "start": 48, + "end": 49, + "loc": { + "start": { + "line": 3, + "column": 10 + }, + "end": { + "line": 3, + "column": 11 + }, + "identifierName": "C" + }, + "name": "C" + }, + "superClass": { + "type": "Identifier", + "start": 58, + "end": 59, + "loc": { + "start": { + "line": 3, + "column": 20 + }, + "end": { + "line": 3, + "column": 21 + }, + "identifierName": "D" + }, + "name": "D" + }, + "body": { + "type": "ClassBody", + "start": 60, + "end": 89, + "loc": { + "start": { + "line": 3, + "column": 22 + }, + "end": { + "line": 5, + "column": 5 + } + }, + "body": [ + { + "type": "ClassPrivateProperty", + "start": 68, + "end": 83, + "loc": { + "start": { + "line": 4, + "column": 6 + }, + "end": { + "line": 4, + "column": 21 + } + }, + "static": false, + "key": { + "type": "PrivateName", + "start": 68, + "end": 72, + "loc": { + "start": { + "line": 4, + "column": 6 + }, + "end": { + "line": 4, + "column": 10 + } + }, + "id": { + "type": "Identifier", + "start": 69, + "end": 72, + "loc": { + "start": { + "line": 4, + "column": 7 + }, + "end": { + "line": 4, + "column": 10 + }, + "identifierName": "foo" + }, + "name": "foo" + } + }, + "value": { + "type": "CallExpression", + "start": 75, + "end": 82, + "loc": { + "start": { + "line": 4, + "column": 13 + }, + "end": { + "line": 4, + "column": 20 + } + }, + "callee": { + "type": "Super", + "start": 75, + "end": 80, + "loc": { + "start": { + "line": 4, + "column": 13 + }, + "end": { + "line": 4, + "column": 18 + } + } + }, + "arguments": [] + } + } + ] + } + } + ], + "directives": [] + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/class-private-properties/super-private-member-access/options.json b/packages/babel-parser/test/fixtures/experimental/class-private-properties/super-private-member-access/options.json index 162c282e64a2..1ca5069a3a2f 100644 --- a/packages/babel-parser/test/fixtures/experimental/class-private-properties/super-private-member-access/options.json +++ b/packages/babel-parser/test/fixtures/experimental/class-private-properties/super-private-member-access/options.json @@ -1,6 +1,5 @@ { "plugins": [ "classPrivateProperties" - ], - "throws": "Private fields can't be accessed on super (5:4)" -} + ] +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/class-private-properties/super-private-member-access/output.json b/packages/babel-parser/test/fixtures/experimental/class-private-properties/super-private-member-access/output.json new file mode 100644 index 000000000000..bf5051685be7 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/class-private-properties/super-private-member-access/output.json @@ -0,0 +1,288 @@ +{ + "type": "File", + "start": 0, + "end": 59, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 7, + "column": 1 + } + }, + "errors": [ + "SyntaxError: Private fields can't be accessed on super (5:4)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 59, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 7, + "column": 1 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ClassDeclaration", + "start": 0, + "end": 59, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 7, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 6, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + }, + "identifierName": "A" + }, + "name": "A" + }, + "superClass": { + "type": "Identifier", + "start": 16, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 17 + }, + "identifierName": "B" + }, + "name": "B" + }, + "body": { + "type": "ClassBody", + "start": 18, + "end": 59, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 7, + "column": 1 + } + }, + "body": [ + { + "type": "ClassPrivateProperty", + "start": 22, + "end": 25, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 5 + } + }, + "static": false, + "key": { + "type": "PrivateName", + "start": 22, + "end": 24, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 4 + } + }, + "id": { + "type": "Identifier", + "start": 23, + "end": 24, + "loc": { + "start": { + "line": 2, + "column": 3 + }, + "end": { + "line": 2, + "column": 4 + }, + "identifierName": "x" + }, + "name": "x" + } + }, + "value": null + }, + { + "type": "ClassMethod", + "start": 29, + "end": 57, + "loc": { + "start": { + "line": 4, + "column": 2 + }, + "end": { + "line": 6, + "column": 3 + } + }, + "static": false, + "key": { + "type": "Identifier", + "start": 29, + "end": 35, + "loc": { + "start": { + "line": 4, + "column": 2 + }, + "end": { + "line": 4, + "column": 8 + }, + "identifierName": "method" + }, + "name": "method" + }, + "computed": false, + "kind": "method", + "id": null, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 38, + "end": 57, + "loc": { + "start": { + "line": 4, + "column": 11 + }, + "end": { + "line": 6, + "column": 3 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 44, + "end": 53, + "loc": { + "start": { + "line": 5, + "column": 4 + }, + "end": { + "line": 5, + "column": 13 + } + }, + "expression": { + "type": "MemberExpression", + "start": 44, + "end": 52, + "loc": { + "start": { + "line": 5, + "column": 4 + }, + "end": { + "line": 5, + "column": 12 + } + }, + "object": { + "type": "Super", + "start": 44, + "end": 49, + "loc": { + "start": { + "line": 5, + "column": 4 + }, + "end": { + "line": 5, + "column": 9 + } + } + }, + "property": { + "type": "PrivateName", + "start": 50, + "end": 52, + "loc": { + "start": { + "line": 5, + "column": 10 + }, + "end": { + "line": 5, + "column": 12 + } + }, + "id": { + "type": "Identifier", + "start": 51, + "end": 52, + "loc": { + "start": { + "line": 5, + "column": 11 + }, + "end": { + "line": 5, + "column": 12 + }, + "identifierName": "x" + }, + "name": "x" + } + }, + "computed": false + } + } + ], + "directives": [] + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/class-properties/arguments-in-arrow-function/options.json b/packages/babel-parser/test/fixtures/experimental/class-properties/arguments-in-arrow-function/options.json index a567b19a72cb..7f9944b56296 100644 --- a/packages/babel-parser/test/fixtures/experimental/class-properties/arguments-in-arrow-function/options.json +++ b/packages/babel-parser/test/fixtures/experimental/class-properties/arguments-in-arrow-function/options.json @@ -1,4 +1,5 @@ { - "plugins": ["classProperties"], - "throws": "'arguments' is not allowed in class field initializer (3:16)" -} + "plugins": [ + "classProperties" + ] +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/class-properties/arguments-in-arrow-function/output.json b/packages/babel-parser/test/fixtures/experimental/class-properties/arguments-in-arrow-function/output.json new file mode 100644 index 000000000000..7cd90e6e9021 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/class-properties/arguments-in-arrow-function/output.json @@ -0,0 +1,211 @@ +{ + "type": "File", + "start": 0, + "end": 60, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 5, + "column": 1 + } + }, + "errors": [ + "SyntaxError: 'arguments' is not allowed in class field initializer (3:16)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 60, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 5, + "column": 1 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 60, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 5, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 11 + }, + "identifierName": "fn" + }, + "name": "fn" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 14, + "end": 60, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 5, + "column": 1 + } + }, + "body": [ + { + "type": "ClassDeclaration", + "start": 18, + "end": 58, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 4, + "column": 3 + } + }, + "id": { + "type": "Identifier", + "start": 24, + "end": 25, + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 9 + }, + "identifierName": "A" + }, + "name": "A" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "start": 26, + "end": 58, + "loc": { + "start": { + "line": 2, + "column": 10 + }, + "end": { + "line": 4, + "column": 3 + } + }, + "body": [ + { + "type": "ClassProperty", + "start": 32, + "end": 54, + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 26 + } + }, + "static": false, + "key": { + "type": "Identifier", + "start": 32, + "end": 35, + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 7 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "computed": false, + "value": { + "type": "ArrowFunctionExpression", + "start": 38, + "end": 53, + "loc": { + "start": { + "line": 3, + "column": 10 + }, + "end": { + "line": 3, + "column": 25 + } + }, + "id": null, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "Identifier", + "start": 44, + "end": 53, + "loc": { + "start": { + "line": 3, + "column": 16 + }, + "end": { + "line": 3, + "column": 25 + }, + "identifierName": "arguments" + }, + "name": "arguments" + } + } + } + ] + } + } + ], + "directives": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/class-properties/arguments/options.json b/packages/babel-parser/test/fixtures/experimental/class-properties/arguments/options.json index e79a44db0bef..7f9944b56296 100644 --- a/packages/babel-parser/test/fixtures/experimental/class-properties/arguments/options.json +++ b/packages/babel-parser/test/fixtures/experimental/class-properties/arguments/options.json @@ -1,4 +1,5 @@ { - "plugins": ["classProperties"], - "throws": "'arguments' is not allowed in class field initializer (3:10)" -} + "plugins": [ + "classProperties" + ] +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/class-properties/arguments/output.json b/packages/babel-parser/test/fixtures/experimental/class-properties/arguments/output.json new file mode 100644 index 000000000000..f2522558f086 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/class-properties/arguments/output.json @@ -0,0 +1,192 @@ +{ + "type": "File", + "start": 0, + "end": 54, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 5, + "column": 1 + } + }, + "errors": [ + "SyntaxError: 'arguments' is not allowed in class field initializer (3:10)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 54, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 5, + "column": 1 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 54, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 5, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 11 + }, + "identifierName": "fn" + }, + "name": "fn" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 14, + "end": 54, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 5, + "column": 1 + } + }, + "body": [ + { + "type": "ClassDeclaration", + "start": 18, + "end": 52, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 4, + "column": 3 + } + }, + "id": { + "type": "Identifier", + "start": 24, + "end": 25, + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 9 + }, + "identifierName": "A" + }, + "name": "A" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "start": 26, + "end": 52, + "loc": { + "start": { + "line": 2, + "column": 10 + }, + "end": { + "line": 4, + "column": 3 + } + }, + "body": [ + { + "type": "ClassProperty", + "start": 32, + "end": 48, + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 20 + } + }, + "static": false, + "key": { + "type": "Identifier", + "start": 32, + "end": 35, + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 7 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "computed": false, + "value": { + "type": "Identifier", + "start": 38, + "end": 47, + "loc": { + "start": { + "line": 3, + "column": 10 + }, + "end": { + "line": 3, + "column": 19 + }, + "identifierName": "arguments" + }, + "name": "arguments" + } + } + ] + } + } + ], + "directives": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/class-properties/new-target-invalid/options.json b/packages/babel-parser/test/fixtures/experimental/class-properties/new-target-invalid/options.json index 8d36a47b9f64..7f9944b56296 100644 --- a/packages/babel-parser/test/fixtures/experimental/class-properties/new-target-invalid/options.json +++ b/packages/babel-parser/test/fixtures/experimental/class-properties/new-target-invalid/options.json @@ -1,4 +1,5 @@ { - "plugins": ["classProperties"], - "throws": "new.target can only be used in functions or class properties (1:8)" -} + "plugins": [ + "classProperties" + ] +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/class-properties/new-target-invalid/output.json b/packages/babel-parser/test/fixtures/experimental/class-properties/new-target-invalid/output.json new file mode 100644 index 000000000000..a44ee2efc222 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/class-properties/new-target-invalid/output.json @@ -0,0 +1,137 @@ +{ + "type": "File", + "start": 0, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "errors": [ + "SyntaxError: new.target can only be used in functions or class properties (1:8)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "VariableDeclaration", + "start": 0, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 4, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "id": { + "type": "Identifier", + "start": 4, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 5 + }, + "identifierName": "x" + }, + "name": "x" + }, + "init": { + "type": "MetaProperty", + "start": 8, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "meta": { + "type": "Identifier", + "start": 8, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 11 + }, + "identifierName": "new" + }, + "name": "new" + }, + "property": { + "type": "Identifier", + "start": 12, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 18 + }, + "identifierName": "target" + }, + "name": "target" + } + } + } + ], + "kind": "var" + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/class-properties/no-ctor-2/options.json b/packages/babel-parser/test/fixtures/experimental/class-properties/no-ctor-2/options.json index 5560d1052435..7c697d760098 100644 --- a/packages/babel-parser/test/fixtures/experimental/class-properties/no-ctor-2/options.json +++ b/packages/babel-parser/test/fixtures/experimental/class-properties/no-ctor-2/options.json @@ -1,4 +1,5 @@ { - "throws": "Classes may not have a field named 'constructor' (2:2)", - "plugins": ["classProperties"] + "plugins": [ + "classProperties" + ] } diff --git a/packages/babel-parser/test/fixtures/experimental/class-properties/no-ctor-2/output.json b/packages/babel-parser/test/fixtures/experimental/class-properties/no-ctor-2/output.json new file mode 100644 index 000000000000..0678d1917926 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/class-properties/no-ctor-2/output.json @@ -0,0 +1,179 @@ +{ + "type": "File", + "start": 0, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "errors": [ + "SyntaxError: Classes may not have a field named 'constructor' (2:2)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ClassDeclaration", + "start": 0, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 6, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 9 + }, + "identifierName": "Foo" + }, + "name": "Foo" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "start": 10, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "body": [ + { + "type": "ClassProperty", + "start": 14, + "end": 25, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 13 + } + }, + "static": false, + "key": { + "type": "Identifier", + "start": 14, + "end": 25, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 13 + }, + "identifierName": "constructor" + }, + "name": "constructor" + }, + "computed": false, + "value": null + }, + { + "type": "ClassMethod", + "start": 28, + "end": 34, + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 3, + "column": 8 + } + }, + "static": false, + "kind": "method", + "key": { + "type": "Identifier", + "start": 29, + "end": 30, + "loc": { + "start": { + "line": 3, + "column": 3 + }, + "end": { + "line": 3, + "column": 4 + }, + "identifierName": "x" + }, + "name": "x" + }, + "computed": false, + "id": null, + "generator": true, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 32, + "end": 34, + "loc": { + "start": { + "line": 3, + "column": 6 + }, + "end": { + "line": 3, + "column": 8 + } + }, + "body": [], + "directives": [] + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/class-properties/no-ctor/options.json b/packages/babel-parser/test/fixtures/experimental/class-properties/no-ctor/options.json index 5560d1052435..7c697d760098 100644 --- a/packages/babel-parser/test/fixtures/experimental/class-properties/no-ctor/options.json +++ b/packages/babel-parser/test/fixtures/experimental/class-properties/no-ctor/options.json @@ -1,4 +1,5 @@ { - "throws": "Classes may not have a field named 'constructor' (2:2)", - "plugins": ["classProperties"] + "plugins": [ + "classProperties" + ] } diff --git a/packages/babel-parser/test/fixtures/experimental/class-properties/no-ctor/output.json b/packages/babel-parser/test/fixtures/experimental/class-properties/no-ctor/output.json new file mode 100644 index 000000000000..2a969d61e76e --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/class-properties/no-ctor/output.json @@ -0,0 +1,123 @@ +{ + "type": "File", + "start": 0, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "errors": [ + "SyntaxError: Classes may not have a field named 'constructor' (2:2)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ClassDeclaration", + "start": 0, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 6, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 9 + }, + "identifierName": "Foo" + }, + "name": "Foo" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "start": 10, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "body": [ + { + "type": "ClassProperty", + "start": 14, + "end": 25, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 13 + } + }, + "static": false, + "key": { + "type": "Identifier", + "start": 14, + "end": 25, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 13 + }, + "identifierName": "constructor" + }, + "name": "constructor" + }, + "computed": false, + "value": null + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/class-properties/no-static-prototype-2/options.json b/packages/babel-parser/test/fixtures/experimental/class-properties/no-static-prototype-2/options.json index 5bde2716ebdd..7f9944b56296 100644 --- a/packages/babel-parser/test/fixtures/experimental/class-properties/no-static-prototype-2/options.json +++ b/packages/babel-parser/test/fixtures/experimental/class-properties/no-static-prototype-2/options.json @@ -1,4 +1,5 @@ { - "throws": "Classes may not have static property named prototype (2:9)", - "plugins": ["classProperties"] -} + "plugins": [ + "classProperties" + ] +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/class-properties/no-static-prototype-2/output.json b/packages/babel-parser/test/fixtures/experimental/class-properties/no-static-prototype-2/output.json new file mode 100644 index 000000000000..975df8dd8199 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/class-properties/no-static-prototype-2/output.json @@ -0,0 +1,179 @@ +{ + "type": "File", + "start": 0, + "end": 41, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "errors": [ + "SyntaxError: Classes may not have static property named prototype (2:9)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 41, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ClassDeclaration", + "start": 0, + "end": 41, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 6, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 9 + }, + "identifierName": "Foo" + }, + "name": "Foo" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "start": 10, + "end": 41, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "body": [ + { + "type": "ClassProperty", + "start": 14, + "end": 30, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 18 + } + }, + "static": true, + "key": { + "type": "Identifier", + "start": 21, + "end": 30, + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 18 + }, + "identifierName": "prototype" + }, + "name": "prototype" + }, + "computed": false, + "value": null + }, + { + "type": "ClassMethod", + "start": 33, + "end": 39, + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 3, + "column": 8 + } + }, + "static": false, + "kind": "method", + "key": { + "type": "Identifier", + "start": 34, + "end": 35, + "loc": { + "start": { + "line": 3, + "column": 3 + }, + "end": { + "line": 3, + "column": 4 + }, + "identifierName": "x" + }, + "name": "x" + }, + "computed": false, + "id": null, + "generator": true, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 37, + "end": 39, + "loc": { + "start": { + "line": 3, + "column": 6 + }, + "end": { + "line": 3, + "column": 8 + } + }, + "body": [], + "directives": [] + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/class-properties/no-static-prototype/options.json b/packages/babel-parser/test/fixtures/experimental/class-properties/no-static-prototype/options.json index 5bde2716ebdd..7f9944b56296 100644 --- a/packages/babel-parser/test/fixtures/experimental/class-properties/no-static-prototype/options.json +++ b/packages/babel-parser/test/fixtures/experimental/class-properties/no-static-prototype/options.json @@ -1,4 +1,5 @@ { - "throws": "Classes may not have static property named prototype (2:9)", - "plugins": ["classProperties"] -} + "plugins": [ + "classProperties" + ] +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/class-properties/no-static-prototype/output.json b/packages/babel-parser/test/fixtures/experimental/class-properties/no-static-prototype/output.json new file mode 100644 index 000000000000..fb3005664209 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/class-properties/no-static-prototype/output.json @@ -0,0 +1,123 @@ +{ + "type": "File", + "start": 0, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "errors": [ + "SyntaxError: Classes may not have static property named prototype (2:9)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ClassDeclaration", + "start": 0, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 6, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 9 + }, + "identifierName": "Foo" + }, + "name": "Foo" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "start": 10, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "body": [ + { + "type": "ClassProperty", + "start": 14, + "end": 30, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 18 + } + }, + "static": true, + "key": { + "type": "Identifier", + "start": 21, + "end": 30, + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 18 + }, + "identifierName": "prototype" + }, + "name": "prototype" + }, + "computed": false, + "value": null + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/class-properties/static-field-named-constructor/options.json b/packages/babel-parser/test/fixtures/experimental/class-properties/static-field-named-constructor/options.json index 36858dc626ae..7f9944b56296 100644 --- a/packages/babel-parser/test/fixtures/experimental/class-properties/static-field-named-constructor/options.json +++ b/packages/babel-parser/test/fixtures/experimental/class-properties/static-field-named-constructor/options.json @@ -1,4 +1,5 @@ { - "throws": "Classes may not have a field named 'constructor' (2:11)", - "plugins": ["classProperties"] -} + "plugins": [ + "classProperties" + ] +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/class-properties/static-field-named-constructor/output.json b/packages/babel-parser/test/fixtures/experimental/class-properties/static-field-named-constructor/output.json new file mode 100644 index 000000000000..74fd91c747c5 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/class-properties/static-field-named-constructor/output.json @@ -0,0 +1,123 @@ +{ + "type": "File", + "start": 0, + "end": 37, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "errors": [ + "SyntaxError: Classes may not have a field named 'constructor' (2:11)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 37, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ClassDeclaration", + "start": 0, + "end": 37, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 6, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 9 + }, + "identifierName": "Foo" + }, + "name": "Foo" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "start": 10, + "end": 37, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "body": [ + { + "type": "ClassProperty", + "start": 16, + "end": 35, + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 23 + } + }, + "static": true, + "key": { + "type": "Identifier", + "start": 23, + "end": 34, + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 22 + }, + "identifierName": "constructor" + }, + "name": "constructor" + }, + "computed": false, + "value": null + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/class-properties/super-call/options.json b/packages/babel-parser/test/fixtures/experimental/class-properties/super-call/options.json index e8d509e27740..7f9944b56296 100644 --- a/packages/babel-parser/test/fixtures/experimental/class-properties/super-call/options.json +++ b/packages/babel-parser/test/fixtures/experimental/class-properties/super-call/options.json @@ -1,4 +1,5 @@ { - "plugins": ["classProperties"], - "throws": "super() is only valid inside a class constructor of a subclass. Maybe a typo in the method name ('constructor') or not extending another class? (4:12)" -} + "plugins": [ + "classProperties" + ] +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/class-properties/super-call/output.json b/packages/babel-parser/test/fixtures/experimental/class-properties/super-call/output.json new file mode 100644 index 000000000000..987d1eef5055 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/class-properties/super-call/output.json @@ -0,0 +1,292 @@ +{ + "type": "File", + "start": 0, + "end": 94, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 7, + "column": 1 + } + }, + "errors": [ + "SyntaxError: super() is only valid inside a class constructor of a subclass. Maybe a typo in the method name ('constructor') or not extending another class? (4:12)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 94, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 7, + "column": 1 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ClassDeclaration", + "start": 0, + "end": 94, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 7, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 6, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + }, + "identifierName": "A" + }, + "name": "A" + }, + "superClass": { + "type": "Identifier", + "start": 16, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 17 + }, + "identifierName": "B" + }, + "name": "B" + }, + "body": { + "type": "ClassBody", + "start": 18, + "end": 94, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 7, + "column": 1 + } + }, + "body": [ + { + "type": "ClassMethod", + "start": 22, + "end": 92, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 6, + "column": 3 + } + }, + "static": false, + "key": { + "type": "Identifier", + "start": 22, + "end": 33, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 13 + }, + "identifierName": "constructor" + }, + "name": "constructor" + }, + "computed": false, + "kind": "constructor", + "id": null, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 36, + "end": 92, + "loc": { + "start": { + "line": 2, + "column": 16 + }, + "end": { + "line": 6, + "column": 3 + } + }, + "body": [ + { + "type": "ClassDeclaration", + "start": 42, + "end": 88, + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 5, + "column": 5 + } + }, + "id": { + "type": "Identifier", + "start": 48, + "end": 49, + "loc": { + "start": { + "line": 3, + "column": 10 + }, + "end": { + "line": 3, + "column": 11 + }, + "identifierName": "C" + }, + "name": "C" + }, + "superClass": { + "type": "Identifier", + "start": 58, + "end": 59, + "loc": { + "start": { + "line": 3, + "column": 20 + }, + "end": { + "line": 3, + "column": 21 + }, + "identifierName": "D" + }, + "name": "D" + }, + "body": { + "type": "ClassBody", + "start": 60, + "end": 88, + "loc": { + "start": { + "line": 3, + "column": 22 + }, + "end": { + "line": 5, + "column": 5 + } + }, + "body": [ + { + "type": "ClassProperty", + "start": 68, + "end": 82, + "loc": { + "start": { + "line": 4, + "column": 6 + }, + "end": { + "line": 4, + "column": 20 + } + }, + "static": false, + "key": { + "type": "Identifier", + "start": 68, + "end": 71, + "loc": { + "start": { + "line": 4, + "column": 6 + }, + "end": { + "line": 4, + "column": 9 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "computed": false, + "value": { + "type": "CallExpression", + "start": 74, + "end": 81, + "loc": { + "start": { + "line": 4, + "column": 12 + }, + "end": { + "line": 4, + "column": 19 + } + }, + "callee": { + "type": "Super", + "start": 74, + "end": 79, + "loc": { + "start": { + "line": 4, + "column": 12 + }, + "end": { + "line": 4, + "column": 17 + } + } + }, + "arguments": [] + } + } + ] + } + } + ], + "directives": [] + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/class-properties/super-inside-function/options.json b/packages/babel-parser/test/fixtures/experimental/class-properties/super-inside-function/options.json index 386c2968e7b0..7f9944b56296 100644 --- a/packages/babel-parser/test/fixtures/experimental/class-properties/super-inside-function/options.json +++ b/packages/babel-parser/test/fixtures/experimental/class-properties/super-inside-function/options.json @@ -1,4 +1,5 @@ { - "plugins": ["classProperties"], - "throws": "super is only allowed in object methods and classes (3:4)" -} + "plugins": [ + "classProperties" + ] +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/class-properties/super-inside-function/output.json b/packages/babel-parser/test/fixtures/experimental/class-properties/super-inside-function/output.json new file mode 100644 index 000000000000..b129c88406f6 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/class-properties/super-inside-function/output.json @@ -0,0 +1,254 @@ +{ + "type": "File", + "start": 0, + "end": 54, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 5, + "column": 1 + } + }, + "errors": [ + "SyntaxError: super is only allowed in object methods and classes (3:4)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 54, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 5, + "column": 1 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ClassDeclaration", + "start": 0, + "end": 54, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 5, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 6, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + }, + "identifierName": "A" + }, + "name": "A" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "start": 8, + "end": 54, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 5, + "column": 1 + } + }, + "body": [ + { + "type": "ClassProperty", + "start": 12, + "end": 52, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 4, + "column": 3 + } + }, + "static": false, + "key": { + "type": "Identifier", + "start": 12, + "end": 15, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 5 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "computed": false, + "value": { + "type": "FunctionExpression", + "start": 18, + "end": 52, + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 4, + "column": 3 + } + }, + "id": { + "type": "Identifier", + "start": 27, + "end": 29, + "loc": { + "start": { + "line": 2, + "column": 17 + }, + "end": { + "line": 2, + "column": 19 + }, + "identifierName": "fn" + }, + "name": "fn" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 32, + "end": 52, + "loc": { + "start": { + "line": 2, + "column": 22 + }, + "end": { + "line": 4, + "column": 3 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 38, + "end": 48, + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 14 + } + }, + "expression": { + "type": "CallExpression", + "start": 38, + "end": 47, + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 13 + } + }, + "callee": { + "type": "MemberExpression", + "start": 38, + "end": 45, + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 11 + } + }, + "object": { + "type": "Super", + "start": 38, + "end": 43, + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 9 + } + } + }, + "property": { + "type": "Identifier", + "start": 44, + "end": 45, + "loc": { + "start": { + "line": 3, + "column": 10 + }, + "end": { + "line": 3, + "column": 11 + }, + "identifierName": "x" + }, + "name": "x" + }, + "computed": false + }, + "arguments": [] + } + } + ], + "directives": [] + } + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/decorators-2/decoratorsBeforeExport-export-default-decorated-expression-without-parens/options.json b/packages/babel-parser/test/fixtures/experimental/decorators-2/decoratorsBeforeExport-export-default-decorated-expression-without-parens/options.json index 39592e4eb294..70c2c7a17676 100644 --- a/packages/babel-parser/test/fixtures/experimental/decorators-2/decoratorsBeforeExport-export-default-decorated-expression-without-parens/options.json +++ b/packages/babel-parser/test/fixtures/experimental/decorators-2/decoratorsBeforeExport-export-default-decorated-expression-without-parens/options.json @@ -1,5 +1,11 @@ { - "sourceType": "module", - "plugins": [["decorators", { "decoratorsBeforeExport": true }]], - "throws": "Decorators must be placed *before* the 'export' keyword. You can set the 'decoratorsBeforeExport' option to false to use the 'export @decorator class {}' syntax (1:15)" -} + "plugins": [ + [ + "decorators", + { + "decoratorsBeforeExport": true + } + ] + ], + "sourceType": "module" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/decorators-2/decoratorsBeforeExport-export-default-decorated-expression-without-parens/output.json b/packages/babel-parser/test/fixtures/experimental/decorators-2/decoratorsBeforeExport-export-default-decorated-expression-without-parens/output.json new file mode 100644 index 000000000000..2ac3ce6a5954 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/decorators-2/decoratorsBeforeExport-export-default-decorated-expression-without-parens/output.json @@ -0,0 +1,136 @@ +{ + "type": "File", + "start": 0, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 38 + } + }, + "errors": [ + "SyntaxError: Decorators must be placed *before* the 'export' keyword. You can set the 'decoratorsBeforeExport' option to false to use the 'export @decorator class {}' syntax (1:15)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 38 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExportDefaultDeclaration", + "start": 0, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 38 + } + }, + "declaration": { + "type": "ClassDeclaration", + "start": 15, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 38 + } + }, + "decorators": [ + { + "type": "Decorator", + "start": 15, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 25 + } + }, + "expression": { + "type": "Identifier", + "start": 16, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 25 + }, + "identifierName": "decorator" + }, + "name": "decorator" + } + } + ], + "id": { + "type": "Identifier", + "start": 32, + "end": 35, + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 35 + }, + "identifierName": "Foo" + }, + "name": "Foo" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "start": 36, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 36 + }, + "end": { + "line": 1, + "column": 38 + } + }, + "body": [] + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/decorators-2/no-class-method-parameter/options.json b/packages/babel-parser/test/fixtures/experimental/decorators-2/no-class-method-parameter/options.json deleted file mode 100644 index 7b4e6dc626ae..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/decorators-2/no-class-method-parameter/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Stage 2 decorators cannot be used to decorate parameters (2:14)" -} diff --git a/packages/babel-parser/test/fixtures/experimental/decorators-2/no-class-method-parameter/output.json b/packages/babel-parser/test/fixtures/experimental/decorators-2/no-class-method-parameter/output.json new file mode 100644 index 000000000000..9f8814a38f61 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/decorators-2/no-class-method-parameter/output.json @@ -0,0 +1,196 @@ +{ + "type": "File", + "start": 0, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "errors": [ + "SyntaxError: Stage 2 decorators cannot be used to decorate parameters (2:14)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ClassDeclaration", + "start": 0, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 6, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 9 + }, + "identifierName": "Foo" + }, + "name": "Foo" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "start": 10, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "body": [ + { + "type": "ClassMethod", + "start": 14, + "end": 36, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 24 + } + }, + "static": false, + "key": { + "type": "Identifier", + "start": 14, + "end": 25, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 13 + }, + "identifierName": "constructor" + }, + "name": "constructor" + }, + "computed": false, + "kind": "constructor", + "id": null, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "start": 31, + "end": 32, + "loc": { + "start": { + "line": 2, + "column": 19 + }, + "end": { + "line": 2, + "column": 20 + }, + "identifierName": "x" + }, + "name": "x", + "decorators": [ + { + "type": "Decorator", + "start": 26, + "end": 30, + "loc": { + "start": { + "line": 2, + "column": 14 + }, + "end": { + "line": 2, + "column": 18 + } + }, + "expression": { + "type": "Identifier", + "start": 27, + "end": 30, + "loc": { + "start": { + "line": 2, + "column": 15 + }, + "end": { + "line": 2, + "column": 18 + }, + "identifierName": "foo" + }, + "name": "foo" + } + } + ] + } + ], + "body": { + "type": "BlockStatement", + "start": 34, + "end": 36, + "loc": { + "start": { + "line": 2, + "column": 22 + }, + "end": { + "line": 2, + "column": 24 + } + }, + "body": [], + "directives": [] + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/decorators-2/no-constructor-decorators/options.json b/packages/babel-parser/test/fixtures/experimental/decorators-2/no-constructor-decorators/options.json deleted file mode 100644 index a26ed7cacb84..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/decorators-2/no-constructor-decorators/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "You can't attach decorators to a class constructor (2:2)" -} diff --git a/packages/babel-parser/test/fixtures/experimental/decorators-2/no-constructor-decorators/output.json b/packages/babel-parser/test/fixtures/experimental/decorators-2/no-constructor-decorators/output.json new file mode 100644 index 000000000000..084e74570676 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/decorators-2/no-constructor-decorators/output.json @@ -0,0 +1,178 @@ +{ + "type": "File", + "start": 0, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "errors": [ + "SyntaxError: Decorators can't be used with a constructor. Did you mean '@dec class { ... }'? (2:2)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ClassDeclaration", + "start": 0, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 6, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 9 + }, + "identifierName": "Foo" + }, + "name": "Foo" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "start": 10, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "body": [ + { + "type": "ClassMethod", + "start": 14, + "end": 36, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 3, + "column": 17 + } + }, + "decorators": [ + { + "type": "Decorator", + "start": 14, + "end": 18, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 6 + } + }, + "expression": { + "type": "Identifier", + "start": 15, + "end": 18, + "loc": { + "start": { + "line": 2, + "column": 3 + }, + "end": { + "line": 2, + "column": 6 + }, + "identifierName": "abc" + }, + "name": "abc" + } + } + ], + "static": false, + "key": { + "type": "Identifier", + "start": 21, + "end": 32, + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 3, + "column": 13 + }, + "identifierName": "constructor" + }, + "name": "constructor" + }, + "computed": false, + "kind": "constructor", + "id": null, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 34, + "end": 36, + "loc": { + "start": { + "line": 3, + "column": 15 + }, + "end": { + "line": 3, + "column": 17 + } + }, + "body": [], + "directives": [] + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/decorators-2/no-export-decorators-on-class/options.json b/packages/babel-parser/test/fixtures/experimental/decorators-2/no-export-decorators-on-class/options.json index cb54fc794402..2104ca43283f 100644 --- a/packages/babel-parser/test/fixtures/experimental/decorators-2/no-export-decorators-on-class/options.json +++ b/packages/babel-parser/test/fixtures/experimental/decorators-2/no-export-decorators-on-class/options.json @@ -1,4 +1,3 @@ { - "sourceType": "module", - "throws": "Using the export keyword between a decorator and a class is not allowed. Please use `export @dec class` instead. (2:0)" + "sourceType": "module" } diff --git a/packages/babel-parser/test/fixtures/experimental/decorators-2/no-export-decorators-on-class/output.json b/packages/babel-parser/test/fixtures/experimental/decorators-2/no-export-decorators-on-class/output.json new file mode 100644 index 000000000000..733e482e120a --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/decorators-2/no-export-decorators-on-class/output.json @@ -0,0 +1,120 @@ +{ + "type": "File", + "start": 0, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 23 + } + }, + "errors": [ + "SyntaxError: Using the export keyword between a decorator and a class is not allowed. Please use `export @dec class` instead. (2:0)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 23 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExportDefaultDeclaration", + "start": 5, + "end": 28, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 23 + } + }, + "declaration": { + "type": "ClassDeclaration", + "start": 0, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 23 + } + }, + "decorators": [ + { + "type": "Decorator", + "start": 0, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "expression": { + "type": "Identifier", + "start": 1, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 4 + }, + "identifierName": "foo" + }, + "name": "foo" + } + } + ], + "id": null, + "superClass": null, + "body": { + "type": "ClassBody", + "start": 26, + "end": 28, + "loc": { + "start": { + "line": 2, + "column": 21 + }, + "end": { + "line": 2, + "column": 23 + } + }, + "body": [] + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/decorators-2/no-function-parameters/options.json b/packages/babel-parser/test/fixtures/experimental/decorators-2/no-function-parameters/options.json deleted file mode 100644 index 6637fc7f8345..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/decorators-2/no-function-parameters/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Stage 2 decorators cannot be used to decorate parameters (1:14)" -} diff --git a/packages/babel-parser/test/fixtures/experimental/decorators-2/no-function-parameters/output.json b/packages/babel-parser/test/fixtures/experimental/decorators-2/no-function-parameters/output.json new file mode 100644 index 000000000000..ec6b85a88a6b --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/decorators-2/no-function-parameters/output.json @@ -0,0 +1,142 @@ +{ + "type": "File", + "start": 0, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "errors": [ + "SyntaxError: Stage 2 decorators cannot be used to decorate parameters (1:14)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 13 + }, + "identifierName": "func" + }, + "name": "func" + }, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "start": 19, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 20 + }, + "identifierName": "x" + }, + "name": "x", + "decorators": [ + { + "type": "Decorator", + "start": 14, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "expression": { + "type": "Identifier", + "start": 15, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 18 + }, + "identifierName": "foo" + }, + "name": "foo" + } + } + ] + } + ], + "body": { + "type": "BlockStatement", + "start": 22, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 22 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "body": [], + "directives": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/decorators-2/no-object-method-parameters/options.json b/packages/babel-parser/test/fixtures/experimental/decorators-2/no-object-method-parameters/options.json deleted file mode 100644 index b1730696933e..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/decorators-2/no-object-method-parameters/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Stage 2 decorators cannot be used to decorate parameters (2:9)" -} diff --git a/packages/babel-parser/test/fixtures/experimental/decorators-2/no-object-method-parameters/output.json b/packages/babel-parser/test/fixtures/experimental/decorators-2/no-object-method-parameters/output.json new file mode 100644 index 000000000000..2819428d5aef --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/decorators-2/no-object-method-parameters/output.json @@ -0,0 +1,213 @@ +{ + "type": "File", + "start": 0, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 2 + } + }, + "errors": [ + "SyntaxError: Stage 2 decorators cannot be used to decorate parameters (2:9)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 2 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "VariableDeclaration", + "start": 0, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 2 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 4, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 4, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 7 + }, + "identifierName": "obj" + }, + "name": "obj" + }, + "init": { + "type": "ObjectExpression", + "start": 10, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "properties": [ + { + "type": "ObjectMethod", + "start": 14, + "end": 31, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 19 + } + }, + "method": true, + "key": { + "type": "Identifier", + "start": 14, + "end": 20, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 8 + }, + "identifierName": "method" + }, + "name": "method" + }, + "computed": false, + "kind": "method", + "id": null, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "start": 26, + "end": 27, + "loc": { + "start": { + "line": 2, + "column": 14 + }, + "end": { + "line": 2, + "column": 15 + }, + "identifierName": "x" + }, + "name": "x", + "decorators": [ + { + "type": "Decorator", + "start": 21, + "end": 25, + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 13 + } + }, + "expression": { + "type": "Identifier", + "start": 22, + "end": 25, + "loc": { + "start": { + "line": 2, + "column": 10 + }, + "end": { + "line": 2, + "column": 13 + }, + "identifierName": "foo" + }, + "name": "foo" + } + } + ] + } + ], + "body": { + "type": "BlockStatement", + "start": 29, + "end": 31, + "loc": { + "start": { + "line": 2, + "column": 17 + }, + "end": { + "line": 2, + "column": 19 + } + }, + "body": [], + "directives": [] + } + } + ] + } + } + ], + "kind": "var" + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/decorators-2/no-object-methods/options.json b/packages/babel-parser/test/fixtures/experimental/decorators-2/no-object-methods/options.json index 7dd4ed9e2837..69639859c25e 100644 --- a/packages/babel-parser/test/fixtures/experimental/decorators-2/no-object-methods/options.json +++ b/packages/babel-parser/test/fixtures/experimental/decorators-2/no-object-methods/options.json @@ -1,3 +1,10 @@ { - "throws": "Stage 2 decorators disallow object literal property decorators (2:2)" -} + "plugins": [ + [ + "decorators", + { + "decoratorsBeforeExport": false + } + ] + ] +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/decorators-2/no-object-methods/output.json b/packages/babel-parser/test/fixtures/experimental/decorators-2/no-object-methods/output.json new file mode 100644 index 000000000000..e50713954be0 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/decorators-2/no-object-methods/output.json @@ -0,0 +1,195 @@ +{ + "type": "File", + "start": 0, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 5, + "column": 1 + } + }, + "errors": [ + "SyntaxError: Stage 2 decorators disallow object literal property decorators (2:2)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 5, + "column": 1 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "VariableDeclaration", + "start": 0, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 5, + "column": 1 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 4, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 5, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 4, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 5 + }, + "identifierName": "o" + }, + "name": "o" + }, + "init": { + "type": "ObjectExpression", + "start": 8, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 5, + "column": 1 + } + }, + "properties": [ + { + "type": "ObjectMethod", + "start": 19, + "end": 30, + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 4, + "column": 3 + } + }, + "decorators": [ + { + "type": "Decorator", + "start": 12, + "end": 16, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 6 + } + }, + "expression": { + "type": "Identifier", + "start": 13, + "end": 16, + "loc": { + "start": { + "line": 2, + "column": 3 + }, + "end": { + "line": 2, + "column": 6 + }, + "identifierName": "baz" + }, + "name": "baz" + } + } + ], + "method": true, + "key": { + "type": "Identifier", + "start": 19, + "end": 22, + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 3, + "column": 5 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "computed": false, + "kind": "method", + "id": null, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 25, + "end": 30, + "loc": { + "start": { + "line": 3, + "column": 8 + }, + "end": { + "line": 4, + "column": 3 + } + }, + "body": [], + "directives": [] + } + } + ] + } + } + ], + "kind": "var" + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/decorators/no-constructor-decorators/options.json b/packages/babel-parser/test/fixtures/experimental/decorators/no-constructor-decorators/options.json deleted file mode 100644 index a26ed7cacb84..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/decorators/no-constructor-decorators/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "You can't attach decorators to a class constructor (2:2)" -} diff --git a/packages/babel-parser/test/fixtures/experimental/decorators/no-constructor-decorators/output.json b/packages/babel-parser/test/fixtures/experimental/decorators/no-constructor-decorators/output.json new file mode 100644 index 000000000000..084e74570676 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/decorators/no-constructor-decorators/output.json @@ -0,0 +1,178 @@ +{ + "type": "File", + "start": 0, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "errors": [ + "SyntaxError: Decorators can't be used with a constructor. Did you mean '@dec class { ... }'? (2:2)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ClassDeclaration", + "start": 0, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 6, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 9 + }, + "identifierName": "Foo" + }, + "name": "Foo" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "start": 10, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "body": [ + { + "type": "ClassMethod", + "start": 14, + "end": 36, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 3, + "column": 17 + } + }, + "decorators": [ + { + "type": "Decorator", + "start": 14, + "end": 18, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 6 + } + }, + "expression": { + "type": "Identifier", + "start": 15, + "end": 18, + "loc": { + "start": { + "line": 2, + "column": 3 + }, + "end": { + "line": 2, + "column": 6 + }, + "identifierName": "abc" + }, + "name": "abc" + } + } + ], + "static": false, + "key": { + "type": "Identifier", + "start": 21, + "end": 32, + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 3, + "column": 13 + }, + "identifierName": "constructor" + }, + "name": "constructor" + }, + "computed": false, + "kind": "constructor", + "id": null, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 34, + "end": 36, + "loc": { + "start": { + "line": 3, + "column": 15 + }, + "end": { + "line": 3, + "column": 17 + } + }, + "body": [], + "directives": [] + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/dynamic-import/direct-calls-only/options.json b/packages/babel-parser/test/fixtures/experimental/dynamic-import/direct-calls-only/options.json index 599298db4614..fae0a8fe39ac 100644 --- a/packages/babel-parser/test/fixtures/experimental/dynamic-import/direct-calls-only/options.json +++ b/packages/babel-parser/test/fixtures/experimental/dynamic-import/direct-calls-only/options.json @@ -1,3 +1,5 @@ { - "throws": "Dynamic imports require a parameter: import('a.js') (2:9)" -} + "plugins": [ + "dynamicImport" + ] +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/dynamic-import/direct-calls-only/output.json b/packages/babel-parser/test/fixtures/experimental/dynamic-import/direct-calls-only/output.json new file mode 100644 index 000000000000..07f26c50d81d --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/dynamic-import/direct-calls-only/output.json @@ -0,0 +1,172 @@ +{ + "type": "File", + "start": 0, + "end": 49, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "errors": [ + "SyntaxError: Dynamic imports require a parameter: import('a.js') (2:9)", + "SyntaxError: The only valid meta property for import is import.meta (2:16)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 49, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 49, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 19 + }, + "identifierName": "failsParse" + }, + "name": "failsParse" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 22, + "end": 49, + "loc": { + "start": { + "line": 1, + "column": 22 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "body": [ + { + "type": "ReturnStatement", + "start": 26, + "end": 47, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 23 + } + }, + "argument": { + "type": "CallExpression", + "start": 33, + "end": 46, + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 22 + } + }, + "callee": { + "type": "MetaProperty", + "start": 33, + "end": 44, + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 20 + } + }, + "meta": { + "type": "Identifier", + "start": 33, + "end": 39, + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 15 + }, + "identifierName": "import" + }, + "name": "import" + }, + "property": { + "type": "Identifier", + "start": 40, + "end": 44, + "loc": { + "start": { + "line": 2, + "column": 16 + }, + "end": { + "line": 2, + "column": 20 + }, + "identifierName": "then" + }, + "name": "then" + } + }, + "arguments": [] + } + } + ], + "directives": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/dynamic-import/invalid-arguments-spread/options.json b/packages/babel-parser/test/fixtures/experimental/dynamic-import/invalid-arguments-spread/options.json index c4e1e2ffeb50..fae0a8fe39ac 100644 --- a/packages/babel-parser/test/fixtures/experimental/dynamic-import/invalid-arguments-spread/options.json +++ b/packages/babel-parser/test/fixtures/experimental/dynamic-import/invalid-arguments-spread/options.json @@ -1,3 +1,5 @@ { - "throws": "... is not allowed in import() (1:7)" -} + "plugins": [ + "dynamicImport" + ] +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/dynamic-import/invalid-arguments-spread/output.json b/packages/babel-parser/test/fixtures/experimental/dynamic-import/invalid-arguments-spread/output.json new file mode 100644 index 000000000000..d6eaecc7e5c0 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/dynamic-import/invalid-arguments-spread/output.json @@ -0,0 +1,137 @@ +{ + "type": "File", + "start": 0, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "errors": [ + "SyntaxError: ... is not allowed in import() (1:7)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "expression": { + "type": "CallExpression", + "start": 0, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "callee": { + "type": "Import", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + } + }, + "arguments": [ + { + "type": "SpreadElement", + "start": 7, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "argument": { + "type": "ArrayExpression", + "start": 10, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "elements": [ + { + "type": "NumericLiteral", + "start": 11, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + } + ] + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/dynamic-import/invalid-new/options.json b/packages/babel-parser/test/fixtures/experimental/dynamic-import/invalid-new/options.json index 26e64ffc5d96..fae0a8fe39ac 100644 --- a/packages/babel-parser/test/fixtures/experimental/dynamic-import/invalid-new/options.json +++ b/packages/babel-parser/test/fixtures/experimental/dynamic-import/invalid-new/options.json @@ -1,3 +1,5 @@ { - "throws": "Cannot use new with import(...) (1:4)" -} + "plugins": [ + "dynamicImport" + ] +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/dynamic-import/invalid-new/output.json b/packages/babel-parser/test/fixtures/experimental/dynamic-import/invalid-new/output.json new file mode 100644 index 000000000000..a0b8467953bc --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/dynamic-import/invalid-new/output.json @@ -0,0 +1,105 @@ +{ + "type": "File", + "start": 0, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "errors": [ + "SyntaxError: Cannot use new with import(...) (1:4)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "expression": { + "type": "NewExpression", + "start": 0, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "callee": { + "type": "Import", + "start": 4, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 10 + } + } + }, + "arguments": [ + { + "type": "StringLiteral", + "start": 11, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "extra": { + "rawValue": "foo", + "raw": "\"foo\"" + }, + "value": "foo" + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/dynamic-import/invalid-trailing-comma/options.json b/packages/babel-parser/test/fixtures/experimental/dynamic-import/invalid-trailing-comma/options.json index ae6f5f18ff31..329bfdd92330 100644 --- a/packages/babel-parser/test/fixtures/experimental/dynamic-import/invalid-trailing-comma/options.json +++ b/packages/babel-parser/test/fixtures/experimental/dynamic-import/invalid-trailing-comma/options.json @@ -1,3 +1,5 @@ { - "throws": "Trailing comma is disallowed inside import(...) arguments (1:12)" + "plugins": [ + "dynamicImport" + ] } diff --git a/packages/babel-parser/test/fixtures/experimental/dynamic-import/invalid-trailing-comma/output.json b/packages/babel-parser/test/fixtures/experimental/dynamic-import/invalid-trailing-comma/output.json new file mode 100644 index 000000000000..fde34fb849ab --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/dynamic-import/invalid-trailing-comma/output.json @@ -0,0 +1,108 @@ +{ + "type": "File", + "start": 0, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "errors": [ + "SyntaxError: Trailing comma is disallowed inside import(...) arguments (1:12)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "expression": { + "type": "CallExpression", + "start": 0, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "callee": { + "type": "Import", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + } + }, + "extra": { + "trailingComma": 12 + }, + "arguments": [ + { + "type": "StringLiteral", + "start": 7, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "extra": { + "rawValue": "foo", + "raw": "\"foo\"" + }, + "value": "foo" + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/dynamic-import/multiple-args/options.json b/packages/babel-parser/test/fixtures/experimental/dynamic-import/multiple-args/options.json index 95a99c52ae49..fae0a8fe39ac 100644 --- a/packages/babel-parser/test/fixtures/experimental/dynamic-import/multiple-args/options.json +++ b/packages/babel-parser/test/fixtures/experimental/dynamic-import/multiple-args/options.json @@ -1,3 +1,5 @@ { - "throws": "import() requires exactly one argument (1:0)" -} + "plugins": [ + "dynamicImport" + ] +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/dynamic-import/multiple-args/output.json b/packages/babel-parser/test/fixtures/experimental/dynamic-import/multiple-args/output.json new file mode 100644 index 000000000000..f66dbbf22885 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/dynamic-import/multiple-args/output.json @@ -0,0 +1,125 @@ +{ + "type": "File", + "start": 0, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 25 + } + }, + "errors": [ + "SyntaxError: import() requires exactly one argument (1:0)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 25 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 25 + } + }, + "expression": { + "type": "CallExpression", + "start": 0, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "callee": { + "type": "Import", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + } + }, + "arguments": [ + { + "type": "StringLiteral", + "start": 7, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "extra": { + "rawValue": "hello", + "raw": "'hello'" + }, + "value": "hello" + }, + { + "type": "StringLiteral", + "start": 16, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "extra": { + "rawValue": "world", + "raw": "'world'" + }, + "value": "world" + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/dynamic-import/no-args/options.json b/packages/babel-parser/test/fixtures/experimental/dynamic-import/no-args/options.json index 95a99c52ae49..fae0a8fe39ac 100644 --- a/packages/babel-parser/test/fixtures/experimental/dynamic-import/no-args/options.json +++ b/packages/babel-parser/test/fixtures/experimental/dynamic-import/no-args/options.json @@ -1,3 +1,5 @@ { - "throws": "import() requires exactly one argument (1:0)" -} + "plugins": [ + "dynamicImport" + ] +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/dynamic-import/no-args/output.json b/packages/babel-parser/test/fixtures/experimental/dynamic-import/no-args/output.json new file mode 100644 index 000000000000..9f50d0da240c --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/dynamic-import/no-args/output.json @@ -0,0 +1,84 @@ +{ + "type": "File", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "errors": [ + "SyntaxError: import() requires exactly one argument (1:0)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "expression": { + "type": "CallExpression", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "callee": { + "type": "Import", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + } + }, + "arguments": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/export-extensions/default-and-ns/options.json b/packages/babel-parser/test/fixtures/experimental/export-extensions/default-and-ns/options.json index 3bb54891b474..fb17f33a28b5 100644 --- a/packages/babel-parser/test/fixtures/experimental/export-extensions/default-and-ns/options.json +++ b/packages/babel-parser/test/fixtures/experimental/export-extensions/default-and-ns/options.json @@ -1,4 +1,4 @@ { - "plugins": ["exportDefaultFrom", "exportNamespaceFrom"], + "plugins": ["exportDefaultFrom"], "sourceType": "module" } diff --git a/packages/babel-parser/test/fixtures/experimental/export-extensions/ns-and-named/options.json b/packages/babel-parser/test/fixtures/experimental/export-extensions/ns-and-named/options.json deleted file mode 100644 index efa6c457adc3..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/export-extensions/ns-and-named/options.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "sourceType": "module", - "plugins": ["exportNamespaceFrom"] -} diff --git a/packages/babel-parser/test/fixtures/experimental/export-extensions/ns-default/options.json b/packages/babel-parser/test/fixtures/experimental/export-extensions/ns-default/options.json deleted file mode 100644 index e32f18023916..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/export-extensions/ns-default/options.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "plugins": ["exportNamespaceFrom"], - "sourceType": "module" -} diff --git a/packages/babel-parser/test/fixtures/experimental/export-extensions/ns/input.js b/packages/babel-parser/test/fixtures/experimental/export-extensions/ns/input.js deleted file mode 100644 index 27357f4758f9..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/export-extensions/ns/input.js +++ /dev/null @@ -1 +0,0 @@ -export * as A from 'test'; diff --git a/packages/babel-parser/test/fixtures/experimental/export-extensions/ns/options.json b/packages/babel-parser/test/fixtures/experimental/export-extensions/ns/options.json deleted file mode 100644 index e32f18023916..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/export-extensions/ns/options.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "plugins": ["exportNamespaceFrom"], - "sourceType": "module" -} diff --git a/packages/babel-parser/test/fixtures/experimental/import-meta/error-in-script/options.json b/packages/babel-parser/test/fixtures/experimental/import-meta/error-in-script/options.json index eb1e545759e8..cdbf46968b69 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-meta/error-in-script/options.json +++ b/packages/babel-parser/test/fixtures/experimental/import-meta/error-in-script/options.json @@ -1,5 +1,7 @@ { - "throws": "import.meta may appear only with 'sourceType: \"module\"' (1:10)", - "plugins": ["dynamicImport", "importMeta"], + "plugins": [ + "dynamicImport", + "importMeta" + ], "sourceType": "script" -} +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/import-meta/error-in-script/output.json b/packages/babel-parser/test/fixtures/experimental/import-meta/error-in-script/output.json new file mode 100644 index 000000000000..12e01e17c23c --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-meta/error-in-script/output.json @@ -0,0 +1,137 @@ +{ + "type": "File", + "start": 0, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "errors": [ + "SyntaxError: import.meta may appear only with 'sourceType: \"module\"' (1:10)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "VariableDeclaration", + "start": 0, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 6, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "id": { + "type": "Identifier", + "start": 6, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + }, + "identifierName": "x" + }, + "name": "x" + }, + "init": { + "type": "MetaProperty", + "start": 10, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "meta": { + "type": "Identifier", + "start": 10, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 16 + }, + "identifierName": "import" + }, + "name": "import" + }, + "property": { + "type": "Identifier", + "start": 17, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 21 + }, + "identifierName": "meta" + }, + "name": "meta" + } + } + } + ], + "kind": "const" + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/import-meta/no-other-prop-names/options.json b/packages/babel-parser/test/fixtures/experimental/import-meta/no-other-prop-names/options.json index 97ba83ec465d..e05ac2744632 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-meta/no-other-prop-names/options.json +++ b/packages/babel-parser/test/fixtures/experimental/import-meta/no-other-prop-names/options.json @@ -1,5 +1,7 @@ { - "throws": "The only valid meta property for import is import.meta (1:7)", "sourceType": "module", - "plugins": ["dynamicImport", "importMeta"] -} + "plugins": [ + "dynamicImport", + "importMeta" + ] +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/import-meta/no-other-prop-names/output.json b/packages/babel-parser/test/fixtures/experimental/import-meta/no-other-prop-names/output.json new file mode 100644 index 000000000000..9b2370d8c3ec --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-meta/no-other-prop-names/output.json @@ -0,0 +1,102 @@ +{ + "type": "File", + "start": 0, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "errors": [ + "SyntaxError: The only valid meta property for import is import.meta (1:7)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "expression": { + "type": "MetaProperty", + "start": 0, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "meta": { + "type": "Identifier", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + }, + "identifierName": "import" + }, + "name": "import" + }, + "property": { + "type": "Identifier", + "start": 7, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 14 + }, + "identifierName": "notMeta" + }, + "name": "notMeta" + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/import-meta/not-assignable/options.json b/packages/babel-parser/test/fixtures/experimental/import-meta/not-assignable/options.json index 647ad9f65dee..e05ac2744632 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-meta/not-assignable/options.json +++ b/packages/babel-parser/test/fixtures/experimental/import-meta/not-assignable/options.json @@ -1,5 +1,7 @@ { - "throws": "Invalid left-hand side in assignment expression (1:0)", "sourceType": "module", - "plugins": ["dynamicImport", "importMeta"] -} + "plugins": [ + "dynamicImport", + "importMeta" + ] +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/import-meta/not-assignable/output.json b/packages/babel-parser/test/fixtures/experimental/import-meta/not-assignable/output.json new file mode 100644 index 000000000000..7610536beafc --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/import-meta/not-assignable/output.json @@ -0,0 +1,134 @@ +{ + "type": "File", + "start": 0, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "errors": [ + "SyntaxError: Invalid left-hand side in assignment expression (1:0)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "expression": { + "type": "AssignmentExpression", + "start": 0, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "operator": "=", + "left": { + "type": "MetaProperty", + "start": 0, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "meta": { + "type": "Identifier", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + }, + "identifierName": "import" + }, + "name": "import" + }, + "property": { + "type": "Identifier", + "start": 7, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 11 + }, + "identifierName": "meta" + }, + "name": "meta" + } + }, + "right": { + "type": "BooleanLiteral", + "start": 14, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "value": true + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-0/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-0/options.json deleted file mode 100644 index 27e4acfa8f65..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-0/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:1)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-0/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-0/output.json new file mode 100644 index 000000000000..bed1899ddc7e --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-0/output.json @@ -0,0 +1,73 @@ +{ + "type": "File", + "start": 0, + "end": 2, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 2 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:1)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 2, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 2 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 2, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 2 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 0, + "end": 2, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 2 + } + }, + "extra": { + "rawValue": 1, + "raw": "1_" + }, + "value": 1 + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-1/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-1/options.json deleted file mode 100644 index 477511a87822..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-1/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:3)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-1/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-1/output.json new file mode 100644 index 000000000000..c1dac7764035 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-1/output.json @@ -0,0 +1,73 @@ +{ + "type": "File", + "start": 0, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:3)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 0, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "extra": { + "rawValue": 11, + "raw": "1_1_" + }, + "value": 11 + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-10/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-10/options.json deleted file mode 100644 index a65e1ff322a7..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-10/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:5)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-10/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-10/output.json new file mode 100644 index 000000000000..6839504edf6c --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-10/output.json @@ -0,0 +1,73 @@ +{ + "type": "File", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:5)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "extra": { + "rawValue": 17, + "raw": "0x1_1_" + }, + "value": 17 + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-100/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-100/options.json deleted file mode 100644 index 8cb6bf4866a3..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-100/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:2)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-100/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-100/output.json new file mode 100644 index 000000000000..c7f4877e2059 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-100/output.json @@ -0,0 +1,75 @@ +{ + "type": "File", + "start": 0, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:2)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 1, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "extra": { + "rawValue": 1, + "raw": "1_", + "parenthesized": true, + "parenStart": 0 + }, + "value": 1 + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-101/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-101/options.json deleted file mode 100644 index 91c5decd9c42..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-101/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:4)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-101/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-101/output.json new file mode 100644 index 000000000000..1b343c302559 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-101/output.json @@ -0,0 +1,75 @@ +{ + "type": "File", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:4)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 1, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "extra": { + "rawValue": 11, + "raw": "1_1_", + "parenthesized": true, + "parenStart": 0 + }, + "value": 11 + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-102/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-102/options.json deleted file mode 100644 index 91c5decd9c42..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-102/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:4)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-102/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-102/output.json new file mode 100644 index 000000000000..2ab61fd7bb04 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-102/output.json @@ -0,0 +1,76 @@ +{ + "type": "File", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:4)", + "SyntaxError: A numeric separator is only allowed between two digits (1:5)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 1, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "extra": { + "rawValue": 11, + "raw": "1_1__", + "parenthesized": true, + "parenStart": 0 + }, + "value": 11 + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-103/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-103/options.json deleted file mode 100644 index 8cb6bf4866a3..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-103/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:2)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-103/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-103/output.json new file mode 100644 index 000000000000..e799ede442c5 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-103/output.json @@ -0,0 +1,76 @@ +{ + "type": "File", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:2)", + "SyntaxError: A numeric separator is only allowed between two digits (1:3)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 1, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "extra": { + "rawValue": 11, + "raw": "1__1", + "parenthesized": true, + "parenStart": 0 + }, + "value": 11 + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-104/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-104/options.json deleted file mode 100644 index 91c5decd9c42..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-104/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:4)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-104/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-104/output.json new file mode 100644 index 000000000000..7eef10ad862b --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-104/output.json @@ -0,0 +1,75 @@ +{ + "type": "File", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:4)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 1, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "extra": { + "rawValue": 11.11, + "raw": "1_1_.1_1", + "parenthesized": true, + "parenStart": 0 + }, + "value": 11.11 + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-105/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-105/options.json deleted file mode 100644 index a65e1ff322a7..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-105/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:5)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-105/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-105/output.json new file mode 100644 index 000000000000..5a3cc58cada8 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-105/output.json @@ -0,0 +1,75 @@ +{ + "type": "File", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:5)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 1, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "extra": { + "rawValue": 11.11, + "raw": "1_1._1_1", + "parenthesized": true, + "parenStart": 0 + }, + "value": 11.11 + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-106/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-106/options.json deleted file mode 100644 index 9c49308645fd..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-106/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:6)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-106/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-106/output.json new file mode 100644 index 000000000000..45e0aecd2129 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-106/output.json @@ -0,0 +1,75 @@ +{ + "type": "File", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:6)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 1, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "extra": { + "rawValue": 111, + "raw": "1_1.1_e1", + "parenthesized": true, + "parenStart": 0 + }, + "value": 111 + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-107/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-107/options.json deleted file mode 100644 index 9c49308645fd..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-107/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:6)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-107/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-107/output.json new file mode 100644 index 000000000000..73400bf8fd10 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-107/output.json @@ -0,0 +1,75 @@ +{ + "type": "File", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:6)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 1, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "extra": { + "rawValue": 111, + "raw": "1_1.1_E1", + "parenthesized": true, + "parenStart": 0 + }, + "value": 111 + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-108/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-108/options.json deleted file mode 100644 index badcb4c1b655..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-108/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:7)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-108/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-108/output.json new file mode 100644 index 000000000000..6c6aa937ac70 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-108/output.json @@ -0,0 +1,75 @@ +{ + "type": "File", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:7)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 1, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "extra": { + "rawValue": 111, + "raw": "1_1.1e_1", + "parenthesized": true, + "parenStart": 0 + }, + "value": 111 + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-109/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-109/options.json deleted file mode 100644 index badcb4c1b655..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-109/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:7)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-109/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-109/output.json new file mode 100644 index 000000000000..a646828811ea --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-109/output.json @@ -0,0 +1,75 @@ +{ + "type": "File", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:7)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 1, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "extra": { + "rawValue": 111, + "raw": "1_1.1E_1", + "parenthesized": true, + "parenStart": 0 + }, + "value": 111 + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-11/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-11/options.json deleted file mode 100644 index a65e1ff322a7..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-11/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:5)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-11/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-11/output.json new file mode 100644 index 000000000000..0a1b0a11038e --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-11/output.json @@ -0,0 +1,73 @@ +{ + "type": "File", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:5)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "extra": { + "rawValue": 161, + "raw": "0xa_1_" + }, + "value": 161 + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-110/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-110/options.json deleted file mode 100644 index 9c49308645fd..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-110/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:6)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-110/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-110/output.json new file mode 100644 index 000000000000..34647c6e63c9 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-110/output.json @@ -0,0 +1,75 @@ +{ + "type": "File", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:6)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 1, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "extra": { + "rawValue": 17, + "raw": "0x1_1_", + "parenthesized": true, + "parenStart": 0 + }, + "value": 17 + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-111/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-111/options.json deleted file mode 100644 index 9c49308645fd..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-111/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:6)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-111/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-111/output.json new file mode 100644 index 000000000000..e33208bf5970 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-111/output.json @@ -0,0 +1,75 @@ +{ + "type": "File", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:6)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 1, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "extra": { + "rawValue": 161, + "raw": "0xa_1_", + "parenthesized": true, + "parenStart": 0 + }, + "value": 161 + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-112/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-112/options.json deleted file mode 100644 index 477511a87822..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-112/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:3)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-112/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-112/output.json new file mode 100644 index 000000000000..48e2d915883b --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-112/output.json @@ -0,0 +1,75 @@ +{ + "type": "File", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:3)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 1, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "extra": { + "rawValue": 161, + "raw": "0x_a_1", + "parenthesized": true, + "parenStart": 0 + }, + "value": 161 + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-113/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-113/options.json deleted file mode 100644 index 477511a87822..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-113/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:3)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-113/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-113/output.json new file mode 100644 index 000000000000..af714540b44f --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-113/output.json @@ -0,0 +1,77 @@ +{ + "type": "File", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:3)", + "SyntaxError: A numeric separator is only allowed between two digits (1:4)", + "SyntaxError: A numeric separator is only allowed between two digits (1:8)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 1, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "extra": { + "rawValue": 17, + "raw": "0x__1_1_", + "parenthesized": true, + "parenStart": 0 + }, + "value": 17 + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-114/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-114/options.json deleted file mode 100644 index 477511a87822..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-114/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:3)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-114/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-114/output.json new file mode 100644 index 000000000000..151f29fb87dc --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-114/output.json @@ -0,0 +1,77 @@ +{ + "type": "File", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:3)", + "SyntaxError: A numeric separator is only allowed between two digits (1:5)", + "SyntaxError: A numeric separator is only allowed between two digits (1:6)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 1, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "extra": { + "rawValue": 17, + "raw": "0x_1__1", + "parenthesized": true, + "parenStart": 0 + }, + "value": 17 + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-115/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-115/options.json deleted file mode 100644 index 477511a87822..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-115/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:3)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-115/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-115/output.json new file mode 100644 index 000000000000..3ec08e9eab54 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-115/output.json @@ -0,0 +1,76 @@ +{ + "type": "File", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:3)", + "SyntaxError: A numeric separator is only allowed between two digits (1:7)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 1, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "extra": { + "rawValue": 17, + "raw": "0x_1_1_", + "parenthesized": true, + "parenStart": 0 + }, + "value": 17 + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-116/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-116/options.json deleted file mode 100644 index 477511a87822..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-116/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:3)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-116/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-116/output.json new file mode 100644 index 000000000000..b79700fd396f --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-116/output.json @@ -0,0 +1,75 @@ +{ + "type": "File", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:3)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 1, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "extra": { + "rawValue": 9, + "raw": "0o_1_1", + "parenthesized": true, + "parenStart": 0 + }, + "value": 9 + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-117/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-117/options.json deleted file mode 100644 index 477511a87822..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-117/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:3)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-117/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-117/output.json new file mode 100644 index 000000000000..c0bcbc71a47a --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-117/output.json @@ -0,0 +1,75 @@ +{ + "type": "File", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:3)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 1, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "extra": { + "rawValue": 9, + "raw": "0o_11", + "parenthesized": true, + "parenStart": 0 + }, + "value": 9 + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-118/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-118/options.json deleted file mode 100644 index 477511a87822..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-118/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:3)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-118/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-118/output.json new file mode 100644 index 000000000000..00976d92c50f --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-118/output.json @@ -0,0 +1,76 @@ +{ + "type": "File", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:3)", + "SyntaxError: A numeric separator is only allowed between two digits (1:8)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 1, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "extra": { + "rawValue": 9, + "raw": "0o_01_1_", + "parenthesized": true, + "parenStart": 0 + }, + "value": 9 + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-119/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-119/options.json deleted file mode 100644 index 477511a87822..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-119/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:3)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-119/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-119/output.json new file mode 100644 index 000000000000..1858a06292b1 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-119/output.json @@ -0,0 +1,75 @@ +{ + "type": "File", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:3)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 1, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "extra": { + "rawValue": 3, + "raw": "0b_0_1_1", + "parenthesized": true, + "parenStart": 0 + }, + "value": 3 + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-12/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-12/options.json deleted file mode 100644 index 8cb6bf4866a3..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-12/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:2)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-12/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-12/output.json new file mode 100644 index 000000000000..a3ac3d5828d0 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-12/output.json @@ -0,0 +1,73 @@ +{ + "type": "File", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:2)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "extra": { + "rawValue": 161, + "raw": "0x_a_1" + }, + "value": 161 + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-120/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-120/options.json deleted file mode 100644 index 477511a87822..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-120/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:3)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-120/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-120/output.json new file mode 100644 index 000000000000..0b18241bc1c5 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-120/output.json @@ -0,0 +1,76 @@ +{ + "type": "File", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:3)", + "SyntaxError: A numeric separator is only allowed between two digits (1:8)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 1, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "extra": { + "rawValue": 3, + "raw": "0b_01_1_", + "parenthesized": true, + "parenStart": 0 + }, + "value": 3 + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-121/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-121/options.json deleted file mode 100644 index badcb4c1b655..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-121/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:7)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-121/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-121/output.json new file mode 100644 index 000000000000..c478966220d4 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-121/output.json @@ -0,0 +1,75 @@ +{ + "type": "File", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:7)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 1, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "extra": { + "rawValue": 3, + "raw": "0b01_1_", + "parenthesized": true, + "parenStart": 0 + }, + "value": 3 + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-122/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-122/options.json deleted file mode 100644 index 9c49308645fd..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-122/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:6)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-122/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-122/output.json new file mode 100644 index 000000000000..3c73b3979a52 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-122/output.json @@ -0,0 +1,75 @@ +{ + "type": "File", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:6)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 1, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "extra": { + "rawValue": 9, + "raw": "0o1_1_", + "parenthesized": true, + "parenStart": 0 + }, + "value": 9 + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-123/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-123/options.json deleted file mode 100644 index 477511a87822..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-123/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:3)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-123/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-123/output.json new file mode 100644 index 000000000000..7b4538c88e9c --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-123/output.json @@ -0,0 +1,76 @@ +{ + "type": "File", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:3)", + "SyntaxError: A numeric separator is only allowed between two digits (1:7)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 1, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "extra": { + "rawValue": 9, + "raw": "0o_1_1_", + "parenthesized": true, + "parenStart": 0 + }, + "value": 9 + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-124/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-124/options.json deleted file mode 100644 index 8cb6bf4866a3..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-124/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:2)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-124/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-124/output.json new file mode 100644 index 000000000000..55f03701d9db --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-124/output.json @@ -0,0 +1,91 @@ +{ + "type": "File", + "start": 0, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:2)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "BlockStatement", + "start": 0, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 1, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 1, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "extra": { + "rawValue": 1, + "raw": "1_" + }, + "value": 1 + } + } + ], + "directives": [] + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-125/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-125/options.json deleted file mode 100644 index 91c5decd9c42..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-125/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:4)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-125/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-125/output.json new file mode 100644 index 000000000000..4c87cc2b22a7 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-125/output.json @@ -0,0 +1,91 @@ +{ + "type": "File", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:4)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "BlockStatement", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 1, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 1, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "extra": { + "rawValue": 11, + "raw": "1_1_" + }, + "value": 11 + } + } + ], + "directives": [] + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-126/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-126/options.json deleted file mode 100644 index 91c5decd9c42..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-126/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:4)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-126/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-126/output.json new file mode 100644 index 000000000000..65bec6bcbd60 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-126/output.json @@ -0,0 +1,92 @@ +{ + "type": "File", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:4)", + "SyntaxError: A numeric separator is only allowed between two digits (1:5)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "BlockStatement", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 1, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 1, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "extra": { + "rawValue": 11, + "raw": "1_1__" + }, + "value": 11 + } + } + ], + "directives": [] + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-127/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-127/options.json deleted file mode 100644 index 8cb6bf4866a3..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-127/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:2)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-127/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-127/output.json new file mode 100644 index 000000000000..740a870e3ad3 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-127/output.json @@ -0,0 +1,92 @@ +{ + "type": "File", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:2)", + "SyntaxError: A numeric separator is only allowed between two digits (1:3)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "BlockStatement", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 1, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 1, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "extra": { + "rawValue": 11, + "raw": "1__1" + }, + "value": 11 + } + } + ], + "directives": [] + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-128/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-128/options.json deleted file mode 100644 index 91c5decd9c42..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-128/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:4)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-128/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-128/output.json new file mode 100644 index 000000000000..8b3ea170250c --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-128/output.json @@ -0,0 +1,91 @@ +{ + "type": "File", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:4)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "BlockStatement", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 1, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 1, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "extra": { + "rawValue": 11.11, + "raw": "1_1_.1_1" + }, + "value": 11.11 + } + } + ], + "directives": [] + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-129/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-129/options.json deleted file mode 100644 index a65e1ff322a7..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-129/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:5)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-129/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-129/output.json new file mode 100644 index 000000000000..a30df38017e0 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-129/output.json @@ -0,0 +1,91 @@ +{ + "type": "File", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:5)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "BlockStatement", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 1, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 1, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "extra": { + "rawValue": 11.11, + "raw": "1_1._1_1" + }, + "value": 11.11 + } + } + ], + "directives": [] + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-13/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-13/options.json deleted file mode 100644 index 8cb6bf4866a3..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-13/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:2)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-13/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-13/output.json new file mode 100644 index 000000000000..78257d308a98 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-13/output.json @@ -0,0 +1,75 @@ +{ + "type": "File", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:2)", + "SyntaxError: A numeric separator is only allowed between two digits (1:3)", + "SyntaxError: A numeric separator is only allowed between two digits (1:7)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "extra": { + "rawValue": 17, + "raw": "0x__1_1_" + }, + "value": 17 + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-130/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-130/options.json deleted file mode 100644 index 9c49308645fd..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-130/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:6)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-130/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-130/output.json new file mode 100644 index 000000000000..a3ea6fad2e5a --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-130/output.json @@ -0,0 +1,91 @@ +{ + "type": "File", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:6)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "BlockStatement", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 1, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 1, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "extra": { + "rawValue": 111, + "raw": "1_1.1_e1" + }, + "value": 111 + } + } + ], + "directives": [] + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-131/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-131/options.json deleted file mode 100644 index 9c49308645fd..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-131/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:6)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-131/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-131/output.json new file mode 100644 index 000000000000..6461d8dba2bd --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-131/output.json @@ -0,0 +1,91 @@ +{ + "type": "File", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:6)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "BlockStatement", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 1, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 1, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "extra": { + "rawValue": 111, + "raw": "1_1.1_E1" + }, + "value": 111 + } + } + ], + "directives": [] + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-132/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-132/options.json deleted file mode 100644 index badcb4c1b655..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-132/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:7)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-132/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-132/output.json new file mode 100644 index 000000000000..d27ae3b4fadf --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-132/output.json @@ -0,0 +1,91 @@ +{ + "type": "File", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:7)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "BlockStatement", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 1, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 1, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "extra": { + "rawValue": 111, + "raw": "1_1.1e_1" + }, + "value": 111 + } + } + ], + "directives": [] + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-133/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-133/options.json deleted file mode 100644 index badcb4c1b655..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-133/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:7)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-133/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-133/output.json new file mode 100644 index 000000000000..ee4395d21f55 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-133/output.json @@ -0,0 +1,91 @@ +{ + "type": "File", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:7)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "BlockStatement", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 1, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 1, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "extra": { + "rawValue": 111, + "raw": "1_1.1E_1" + }, + "value": 111 + } + } + ], + "directives": [] + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-134/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-134/options.json deleted file mode 100644 index 9c49308645fd..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-134/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:6)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-134/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-134/output.json new file mode 100644 index 000000000000..29dc70b2487f --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-134/output.json @@ -0,0 +1,91 @@ +{ + "type": "File", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:6)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "BlockStatement", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 1, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 1, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "extra": { + "rawValue": 17, + "raw": "0x1_1_" + }, + "value": 17 + } + } + ], + "directives": [] + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-135/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-135/options.json deleted file mode 100644 index 9c49308645fd..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-135/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:6)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-135/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-135/output.json new file mode 100644 index 000000000000..f08afb905eac --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-135/output.json @@ -0,0 +1,91 @@ +{ + "type": "File", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:6)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "BlockStatement", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 1, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 1, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "extra": { + "rawValue": 161, + "raw": "0xa_1_" + }, + "value": 161 + } + } + ], + "directives": [] + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-136/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-136/options.json deleted file mode 100644 index 477511a87822..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-136/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:3)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-136/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-136/output.json new file mode 100644 index 000000000000..2507a579d6de --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-136/output.json @@ -0,0 +1,91 @@ +{ + "type": "File", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:3)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "BlockStatement", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 1, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 1, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "extra": { + "rawValue": 161, + "raw": "0x_a_1" + }, + "value": 161 + } + } + ], + "directives": [] + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-137/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-137/options.json deleted file mode 100644 index 477511a87822..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-137/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:3)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-137/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-137/output.json new file mode 100644 index 000000000000..89afd3efde35 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-137/output.json @@ -0,0 +1,93 @@ +{ + "type": "File", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:3)", + "SyntaxError: A numeric separator is only allowed between two digits (1:4)", + "SyntaxError: A numeric separator is only allowed between two digits (1:8)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "BlockStatement", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 1, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 1, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "extra": { + "rawValue": 17, + "raw": "0x__1_1_" + }, + "value": 17 + } + } + ], + "directives": [] + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-138/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-138/options.json deleted file mode 100644 index 477511a87822..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-138/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:3)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-138/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-138/output.json new file mode 100644 index 000000000000..8cad1428818e --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-138/output.json @@ -0,0 +1,93 @@ +{ + "type": "File", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:3)", + "SyntaxError: A numeric separator is only allowed between two digits (1:5)", + "SyntaxError: A numeric separator is only allowed between two digits (1:6)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "BlockStatement", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 1, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 1, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "extra": { + "rawValue": 17, + "raw": "0x_1__1" + }, + "value": 17 + } + } + ], + "directives": [] + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-139/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-139/options.json deleted file mode 100644 index 477511a87822..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-139/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:3)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-139/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-139/output.json new file mode 100644 index 000000000000..9d86aac2191a --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-139/output.json @@ -0,0 +1,92 @@ +{ + "type": "File", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:3)", + "SyntaxError: A numeric separator is only allowed between two digits (1:7)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "BlockStatement", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 1, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 1, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "extra": { + "rawValue": 17, + "raw": "0x_1_1_" + }, + "value": 17 + } + } + ], + "directives": [] + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-14/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-14/options.json deleted file mode 100644 index 8cb6bf4866a3..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-14/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:2)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-14/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-14/output.json new file mode 100644 index 000000000000..477b3c1f3cf4 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-14/output.json @@ -0,0 +1,75 @@ +{ + "type": "File", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:2)", + "SyntaxError: A numeric separator is only allowed between two digits (1:4)", + "SyntaxError: A numeric separator is only allowed between two digits (1:5)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "extra": { + "rawValue": 17, + "raw": "0x_1__1" + }, + "value": 17 + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-140/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-140/options.json deleted file mode 100644 index 477511a87822..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-140/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:3)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-140/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-140/output.json new file mode 100644 index 000000000000..73b694a6656c --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-140/output.json @@ -0,0 +1,91 @@ +{ + "type": "File", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:3)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "BlockStatement", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 1, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 1, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "extra": { + "rawValue": 9, + "raw": "0o_1_1" + }, + "value": 9 + } + } + ], + "directives": [] + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-141/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-141/options.json deleted file mode 100644 index 477511a87822..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-141/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:3)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-141/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-141/output.json new file mode 100644 index 000000000000..3e602cf8e35b --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-141/output.json @@ -0,0 +1,91 @@ +{ + "type": "File", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:3)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "BlockStatement", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 1, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 1, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "extra": { + "rawValue": 9, + "raw": "0o_11" + }, + "value": 9 + } + } + ], + "directives": [] + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-142/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-142/options.json deleted file mode 100644 index 477511a87822..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-142/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:3)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-142/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-142/output.json new file mode 100644 index 000000000000..7b96b478be97 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-142/output.json @@ -0,0 +1,92 @@ +{ + "type": "File", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:3)", + "SyntaxError: A numeric separator is only allowed between two digits (1:8)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "BlockStatement", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 1, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 1, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "extra": { + "rawValue": 9, + "raw": "0o_01_1_" + }, + "value": 9 + } + } + ], + "directives": [] + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-143/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-143/options.json deleted file mode 100644 index 477511a87822..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-143/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:3)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-143/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-143/output.json new file mode 100644 index 000000000000..bd3c89e95560 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-143/output.json @@ -0,0 +1,91 @@ +{ + "type": "File", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:3)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "BlockStatement", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 1, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 1, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "extra": { + "rawValue": 3, + "raw": "0b_0_1_1" + }, + "value": 3 + } + } + ], + "directives": [] + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-144/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-144/options.json deleted file mode 100644 index 477511a87822..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-144/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:3)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-144/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-144/output.json new file mode 100644 index 000000000000..df4e4858faae --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-144/output.json @@ -0,0 +1,92 @@ +{ + "type": "File", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:3)", + "SyntaxError: A numeric separator is only allowed between two digits (1:8)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "BlockStatement", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 1, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 1, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "extra": { + "rawValue": 3, + "raw": "0b_01_1_" + }, + "value": 3 + } + } + ], + "directives": [] + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-145/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-145/options.json deleted file mode 100644 index badcb4c1b655..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-145/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:7)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-145/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-145/output.json new file mode 100644 index 000000000000..f9203546d16c --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-145/output.json @@ -0,0 +1,91 @@ +{ + "type": "File", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:7)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "BlockStatement", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 1, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 1, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "extra": { + "rawValue": 3, + "raw": "0b01_1_" + }, + "value": 3 + } + } + ], + "directives": [] + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-146/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-146/options.json deleted file mode 100644 index 9c49308645fd..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-146/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:6)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-146/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-146/output.json new file mode 100644 index 000000000000..3138ed92346a --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-146/output.json @@ -0,0 +1,91 @@ +{ + "type": "File", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:6)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "BlockStatement", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 1, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 1, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "extra": { + "rawValue": 9, + "raw": "0o1_1_" + }, + "value": 9 + } + } + ], + "directives": [] + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-147/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-147/options.json deleted file mode 100644 index 477511a87822..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-147/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:3)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-147/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-147/output.json new file mode 100644 index 000000000000..5cd647c2bf7d --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-147/output.json @@ -0,0 +1,92 @@ +{ + "type": "File", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:3)", + "SyntaxError: A numeric separator is only allowed between two digits (1:7)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "BlockStatement", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 1, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 1, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "extra": { + "rawValue": 9, + "raw": "0o_1_1_" + }, + "value": 9 + } + } + ], + "directives": [] + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-15/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-15/options.json deleted file mode 100644 index 8cb6bf4866a3..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-15/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:2)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-15/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-15/output.json new file mode 100644 index 000000000000..a43596db0e4e --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-15/output.json @@ -0,0 +1,74 @@ +{ + "type": "File", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:2)", + "SyntaxError: A numeric separator is only allowed between two digits (1:6)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "extra": { + "rawValue": 17, + "raw": "0x_1_1_" + }, + "value": 17 + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-16/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-16/options.json deleted file mode 100644 index 8cb6bf4866a3..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-16/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:2)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-16/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-16/output.json new file mode 100644 index 000000000000..c6b51546660e --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-16/output.json @@ -0,0 +1,73 @@ +{ + "type": "File", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:2)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "extra": { + "rawValue": 9, + "raw": "0o_1_1" + }, + "value": 9 + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-17/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-17/options.json deleted file mode 100644 index 8cb6bf4866a3..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-17/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:2)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-17/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-17/output.json new file mode 100644 index 000000000000..4788bc887407 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-17/output.json @@ -0,0 +1,73 @@ +{ + "type": "File", + "start": 0, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:2)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 0, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "extra": { + "rawValue": 9, + "raw": "0o_11" + }, + "value": 9 + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-18/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-18/options.json deleted file mode 100644 index 8cb6bf4866a3..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-18/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:2)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-18/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-18/output.json new file mode 100644 index 000000000000..e797620a329e --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-18/output.json @@ -0,0 +1,74 @@ +{ + "type": "File", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:2)", + "SyntaxError: A numeric separator is only allowed between two digits (1:7)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "extra": { + "rawValue": 9, + "raw": "0o_01_1_" + }, + "value": 9 + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-19/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-19/options.json deleted file mode 100644 index 8cb6bf4866a3..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-19/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:2)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-19/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-19/output.json new file mode 100644 index 000000000000..509fa7be5376 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-19/output.json @@ -0,0 +1,73 @@ +{ + "type": "File", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:2)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "extra": { + "rawValue": 3, + "raw": "0b_0_1_1" + }, + "value": 3 + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-2/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-2/options.json deleted file mode 100644 index 477511a87822..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-2/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:3)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-2/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-2/output.json new file mode 100644 index 000000000000..71b523cdc3f5 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-2/output.json @@ -0,0 +1,74 @@ +{ + "type": "File", + "start": 0, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:3)", + "SyntaxError: A numeric separator is only allowed between two digits (1:4)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 0, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "extra": { + "rawValue": 11, + "raw": "1_1__" + }, + "value": 11 + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-20/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-20/options.json deleted file mode 100644 index 8cb6bf4866a3..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-20/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:2)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-20/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-20/output.json new file mode 100644 index 000000000000..386c54cac8e1 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-20/output.json @@ -0,0 +1,74 @@ +{ + "type": "File", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:2)", + "SyntaxError: A numeric separator is only allowed between two digits (1:7)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "extra": { + "rawValue": 3, + "raw": "0b_01_1_" + }, + "value": 3 + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-21/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-21/options.json deleted file mode 100644 index 9c49308645fd..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-21/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:6)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-21/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-21/output.json new file mode 100644 index 000000000000..99329263441c --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-21/output.json @@ -0,0 +1,73 @@ +{ + "type": "File", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:6)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "extra": { + "rawValue": 3, + "raw": "0b01_1_" + }, + "value": 3 + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-22/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-22/options.json deleted file mode 100644 index a65e1ff322a7..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-22/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:5)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-22/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-22/output.json new file mode 100644 index 000000000000..031ce3f9fcf2 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-22/output.json @@ -0,0 +1,73 @@ +{ + "type": "File", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:5)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "extra": { + "rawValue": 9, + "raw": "0o1_1_" + }, + "value": 9 + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-23/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-23/options.json deleted file mode 100644 index 8cb6bf4866a3..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-23/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:2)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-23/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-23/output.json new file mode 100644 index 000000000000..cf60b4557bd1 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-23/output.json @@ -0,0 +1,74 @@ +{ + "type": "File", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:2)", + "SyntaxError: A numeric separator is only allowed between two digits (1:6)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "extra": { + "rawValue": 9, + "raw": "0o_1_1_" + }, + "value": 9 + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-25/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-25/options.json deleted file mode 100644 index 91c5decd9c42..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-25/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:4)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-25/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-25/output.json new file mode 100644 index 000000000000..0de8505e1170 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-25/output.json @@ -0,0 +1,74 @@ +{ + "type": "File", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:4)", + "SyntaxError: Expected number in radix 8 (1:5)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "extra": { + "rawValue": 8, + "raw": "0o01_8" + }, + "value": 8 + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-26/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-26/options.json deleted file mode 100644 index 7f37dbb4686b..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-26/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Expected number in radix 2 (1:2)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-26/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-26/output.json new file mode 100644 index 000000000000..ab45a08cb897 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-26/output.json @@ -0,0 +1,73 @@ +{ + "type": "File", + "start": 0, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "errors": [ + "SyntaxError: Expected number in radix 2 (1:2)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 0, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "extra": { + "rawValue": 1, + "raw": "0b2_1" + }, + "value": 1 + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-27/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-27/options.json index fab06a453d2f..ee18527964e7 100644 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-27/options.json +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-27/options.json @@ -1 +1,3 @@ -{ "throws": "Expected number in radix 16 (1:2)" } +{ + "throws": "Identifier directly after number (1:2)" +} diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-28/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-28/options.json deleted file mode 100644 index 27e4acfa8f65..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-28/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:1)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-28/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-28/output.json new file mode 100644 index 000000000000..22352b5f300f --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-28/output.json @@ -0,0 +1,73 @@ +{ + "type": "File", + "start": 0, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:1)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 0, + "end": 2, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 2 + } + }, + "extra": { + "rawValue": 1, + "raw": "1_" + }, + "value": 1 + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-29/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-29/options.json deleted file mode 100644 index 477511a87822..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-29/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:3)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-29/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-29/output.json new file mode 100644 index 000000000000..109e14677751 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-29/output.json @@ -0,0 +1,73 @@ +{ + "type": "File", + "start": 0, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:3)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 0, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "extra": { + "rawValue": 11, + "raw": "1_1_" + }, + "value": 11 + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-3/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-3/options.json deleted file mode 100644 index 27e4acfa8f65..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-3/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:1)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-3/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-3/output.json new file mode 100644 index 000000000000..39f6afe910ec --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-3/output.json @@ -0,0 +1,74 @@ +{ + "type": "File", + "start": 0, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:1)", + "SyntaxError: A numeric separator is only allowed between two digits (1:2)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 0, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "extra": { + "rawValue": 11, + "raw": "1__1" + }, + "value": 11 + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-30/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-30/options.json deleted file mode 100644 index 477511a87822..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-30/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:3)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-30/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-30/output.json new file mode 100644 index 000000000000..422bdd6c6384 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-30/output.json @@ -0,0 +1,74 @@ +{ + "type": "File", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:3)", + "SyntaxError: A numeric separator is only allowed between two digits (1:4)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 0, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "extra": { + "rawValue": 11, + "raw": "1_1__" + }, + "value": 11 + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-31/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-31/options.json deleted file mode 100644 index 27e4acfa8f65..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-31/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:1)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-31/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-31/output.json new file mode 100644 index 000000000000..4cf178b2082e --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-31/output.json @@ -0,0 +1,74 @@ +{ + "type": "File", + "start": 0, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:1)", + "SyntaxError: A numeric separator is only allowed between two digits (1:2)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 0, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "extra": { + "rawValue": 11, + "raw": "1__1" + }, + "value": 11 + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-32/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-32/options.json deleted file mode 100644 index 477511a87822..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-32/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:3)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-32/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-32/output.json new file mode 100644 index 000000000000..3ac121a5eece --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-32/output.json @@ -0,0 +1,73 @@ +{ + "type": "File", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:3)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "extra": { + "rawValue": 11.11, + "raw": "1_1_.1_1" + }, + "value": 11.11 + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-33/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-33/options.json deleted file mode 100644 index 91c5decd9c42..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-33/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:4)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-33/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-33/output.json new file mode 100644 index 000000000000..4e344f6fd3bf --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-33/output.json @@ -0,0 +1,73 @@ +{ + "type": "File", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:4)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "extra": { + "rawValue": 11.11, + "raw": "1_1._1_1" + }, + "value": 11.11 + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-34/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-34/options.json deleted file mode 100644 index a65e1ff322a7..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-34/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:5)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-34/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-34/output.json new file mode 100644 index 000000000000..d8a2a2deda67 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-34/output.json @@ -0,0 +1,73 @@ +{ + "type": "File", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:5)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "extra": { + "rawValue": 111, + "raw": "1_1.1_e1" + }, + "value": 111 + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-35/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-35/options.json deleted file mode 100644 index a65e1ff322a7..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-35/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:5)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-35/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-35/output.json new file mode 100644 index 000000000000..0b63b9681805 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-35/output.json @@ -0,0 +1,73 @@ +{ + "type": "File", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:5)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "extra": { + "rawValue": 111, + "raw": "1_1.1_E1" + }, + "value": 111 + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-36/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-36/options.json deleted file mode 100644 index 9c49308645fd..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-36/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:6)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-36/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-36/output.json new file mode 100644 index 000000000000..6a9efc69296c --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-36/output.json @@ -0,0 +1,73 @@ +{ + "type": "File", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:6)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "extra": { + "rawValue": 111, + "raw": "1_1.1e_1" + }, + "value": 111 + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-37/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-37/options.json deleted file mode 100644 index 9c49308645fd..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-37/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:6)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-37/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-37/output.json new file mode 100644 index 000000000000..f68c59283508 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-37/output.json @@ -0,0 +1,73 @@ +{ + "type": "File", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:6)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "extra": { + "rawValue": 111, + "raw": "1_1.1E_1" + }, + "value": 111 + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-38/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-38/options.json deleted file mode 100644 index a65e1ff322a7..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-38/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:5)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-38/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-38/output.json new file mode 100644 index 000000000000..0c35b0296649 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-38/output.json @@ -0,0 +1,73 @@ +{ + "type": "File", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:5)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "extra": { + "rawValue": 17, + "raw": "0x1_1_" + }, + "value": 17 + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-39/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-39/options.json deleted file mode 100644 index a65e1ff322a7..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-39/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:5)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-39/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-39/output.json new file mode 100644 index 000000000000..8076713df223 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-39/output.json @@ -0,0 +1,73 @@ +{ + "type": "File", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:5)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "extra": { + "rawValue": 161, + "raw": "0xa_1_" + }, + "value": 161 + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-4/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-4/options.json deleted file mode 100644 index 477511a87822..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-4/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:3)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-4/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-4/output.json new file mode 100644 index 000000000000..ad70ca6fc270 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-4/output.json @@ -0,0 +1,73 @@ +{ + "type": "File", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:3)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "extra": { + "rawValue": 11.11, + "raw": "1_1_.1_1" + }, + "value": 11.11 + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-40/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-40/options.json deleted file mode 100644 index 8cb6bf4866a3..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-40/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:2)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-40/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-40/output.json new file mode 100644 index 000000000000..31bfeccc15a7 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-40/output.json @@ -0,0 +1,73 @@ +{ + "type": "File", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:2)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "extra": { + "rawValue": 161, + "raw": "0x_a_1" + }, + "value": 161 + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-41/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-41/options.json deleted file mode 100644 index 8cb6bf4866a3..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-41/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:2)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-41/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-41/output.json new file mode 100644 index 000000000000..ca8eaf7c7c31 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-41/output.json @@ -0,0 +1,75 @@ +{ + "type": "File", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:2)", + "SyntaxError: A numeric separator is only allowed between two digits (1:3)", + "SyntaxError: A numeric separator is only allowed between two digits (1:7)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "extra": { + "rawValue": 17, + "raw": "0x__1_1_" + }, + "value": 17 + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-42/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-42/options.json deleted file mode 100644 index 8cb6bf4866a3..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-42/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:2)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-42/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-42/output.json new file mode 100644 index 000000000000..689560a3bb3c --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-42/output.json @@ -0,0 +1,75 @@ +{ + "type": "File", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:2)", + "SyntaxError: A numeric separator is only allowed between two digits (1:4)", + "SyntaxError: A numeric separator is only allowed between two digits (1:5)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "extra": { + "rawValue": 17, + "raw": "0x_1__1" + }, + "value": 17 + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-43/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-43/options.json deleted file mode 100644 index 8cb6bf4866a3..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-43/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:2)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-43/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-43/output.json new file mode 100644 index 000000000000..b92b88fa4a19 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-43/output.json @@ -0,0 +1,74 @@ +{ + "type": "File", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:2)", + "SyntaxError: A numeric separator is only allowed between two digits (1:6)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "extra": { + "rawValue": 17, + "raw": "0x_1_1_" + }, + "value": 17 + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-44/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-44/options.json deleted file mode 100644 index 8cb6bf4866a3..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-44/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:2)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-44/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-44/output.json new file mode 100644 index 000000000000..9487edc545b8 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-44/output.json @@ -0,0 +1,73 @@ +{ + "type": "File", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:2)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "extra": { + "rawValue": 9, + "raw": "0o_1_1" + }, + "value": 9 + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-45/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-45/options.json deleted file mode 100644 index 8cb6bf4866a3..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-45/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:2)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-45/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-45/output.json new file mode 100644 index 000000000000..1c39ba7a1d72 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-45/output.json @@ -0,0 +1,73 @@ +{ + "type": "File", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:2)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 0, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "extra": { + "rawValue": 9, + "raw": "0o_11" + }, + "value": 9 + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-46/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-46/options.json deleted file mode 100644 index 8cb6bf4866a3..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-46/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:2)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-46/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-46/output.json new file mode 100644 index 000000000000..2890e46ca71d --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-46/output.json @@ -0,0 +1,74 @@ +{ + "type": "File", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:2)", + "SyntaxError: A numeric separator is only allowed between two digits (1:7)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "extra": { + "rawValue": 9, + "raw": "0o_01_1_" + }, + "value": 9 + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-47/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-47/options.json deleted file mode 100644 index 8cb6bf4866a3..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-47/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:2)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-47/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-47/output.json new file mode 100644 index 000000000000..6de8c77bf903 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-47/output.json @@ -0,0 +1,73 @@ +{ + "type": "File", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:2)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "extra": { + "rawValue": 3, + "raw": "0b_0_1_1" + }, + "value": 3 + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-48/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-48/options.json deleted file mode 100644 index 8cb6bf4866a3..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-48/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:2)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-48/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-48/output.json new file mode 100644 index 000000000000..ae93a109760c --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-48/output.json @@ -0,0 +1,74 @@ +{ + "type": "File", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:2)", + "SyntaxError: A numeric separator is only allowed between two digits (1:7)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "extra": { + "rawValue": 3, + "raw": "0b_01_1_" + }, + "value": 3 + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-49/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-49/options.json deleted file mode 100644 index 9c49308645fd..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-49/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:6)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-49/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-49/output.json new file mode 100644 index 000000000000..fdede7a21ac0 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-49/output.json @@ -0,0 +1,73 @@ +{ + "type": "File", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:6)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "extra": { + "rawValue": 3, + "raw": "0b01_1_" + }, + "value": 3 + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-5/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-5/options.json deleted file mode 100644 index 91c5decd9c42..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-5/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:4)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-5/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-5/output.json new file mode 100644 index 000000000000..ae808dbc99cf --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-5/output.json @@ -0,0 +1,73 @@ +{ + "type": "File", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:4)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "extra": { + "rawValue": 11.11, + "raw": "1_1._1_1" + }, + "value": 11.11 + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-50/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-50/options.json deleted file mode 100644 index a65e1ff322a7..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-50/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:5)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-50/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-50/output.json new file mode 100644 index 000000000000..784d1a34983e --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-50/output.json @@ -0,0 +1,73 @@ +{ + "type": "File", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:5)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "extra": { + "rawValue": 9, + "raw": "0o1_1_" + }, + "value": 9 + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-51/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-51/options.json deleted file mode 100644 index 8cb6bf4866a3..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-51/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:2)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-51/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-51/output.json new file mode 100644 index 000000000000..678bccf4fa1e --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-51/output.json @@ -0,0 +1,74 @@ +{ + "type": "File", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:2)", + "SyntaxError: A numeric separator is only allowed between two digits (1:6)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "extra": { + "rawValue": 9, + "raw": "0o_1_1_" + }, + "value": 9 + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-52/input.js b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-52/input.js index b6b4f448099d..475f52e0eb50 100644 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-52/input.js +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-52/input.js @@ -1 +1 @@ -1_, +1_, 0 diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-52/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-52/options.json deleted file mode 100644 index 27e4acfa8f65..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-52/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:1)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-52/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-52/output.json new file mode 100644 index 000000000000..2c53bf532cbd --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-52/output.json @@ -0,0 +1,110 @@ +{ + "type": "File", + "start": 0, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:1)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "expression": { + "type": "SequenceExpression", + "start": 0, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "expressions": [ + { + "type": "NumericLiteral", + "start": 0, + "end": 2, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 2 + } + }, + "extra": { + "rawValue": 1, + "raw": "1_" + }, + "value": 1 + }, + { + "type": "NumericLiteral", + "start": 4, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-53/input.js b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-53/input.js index 4b8047ea34a5..ce3480ab5810 100644 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-53/input.js +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-53/input.js @@ -1 +1 @@ -1_1_, +1_1_, 0 diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-53/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-53/options.json deleted file mode 100644 index 477511a87822..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-53/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:3)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-53/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-53/output.json new file mode 100644 index 000000000000..f3956eac0884 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-53/output.json @@ -0,0 +1,110 @@ +{ + "type": "File", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:3)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "expression": { + "type": "SequenceExpression", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "expressions": [ + { + "type": "NumericLiteral", + "start": 0, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "extra": { + "rawValue": 11, + "raw": "1_1_" + }, + "value": 11 + }, + { + "type": "NumericLiteral", + "start": 6, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-54/input.js b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-54/input.js index cac8642d14e7..be4906c68d09 100644 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-54/input.js +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-54/input.js @@ -1 +1 @@ -1_1__, +1_1__, 0 diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-54/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-54/options.json deleted file mode 100644 index 477511a87822..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-54/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:3)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-54/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-54/output.json new file mode 100644 index 000000000000..fa8e18cac1a1 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-54/output.json @@ -0,0 +1,111 @@ +{ + "type": "File", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:3)", + "SyntaxError: A numeric separator is only allowed between two digits (1:4)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "expression": { + "type": "SequenceExpression", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "expressions": [ + { + "type": "NumericLiteral", + "start": 0, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "extra": { + "rawValue": 11, + "raw": "1_1__" + }, + "value": 11 + }, + { + "type": "NumericLiteral", + "start": 7, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-55/input.js b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-55/input.js index a9051bb2db71..10191f1bd355 100644 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-55/input.js +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-55/input.js @@ -1 +1 @@ -1__1, +1__1, 0 diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-55/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-55/options.json deleted file mode 100644 index 27e4acfa8f65..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-55/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:1)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-55/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-55/output.json new file mode 100644 index 000000000000..d2ac83f6572e --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-55/output.json @@ -0,0 +1,111 @@ +{ + "type": "File", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:1)", + "SyntaxError: A numeric separator is only allowed between two digits (1:2)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "expression": { + "type": "SequenceExpression", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "expressions": [ + { + "type": "NumericLiteral", + "start": 0, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "extra": { + "rawValue": 11, + "raw": "1__1" + }, + "value": 11 + }, + { + "type": "NumericLiteral", + "start": 6, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-56/input.js b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-56/input.js index 7213755d0f38..be9c6e14d226 100644 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-56/input.js +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-56/input.js @@ -1 +1 @@ -1_1_.1_1, +1_1_.1_1, 0 diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-56/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-56/options.json deleted file mode 100644 index 477511a87822..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-56/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:3)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-56/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-56/output.json new file mode 100644 index 000000000000..154d9a6f4641 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-56/output.json @@ -0,0 +1,110 @@ +{ + "type": "File", + "start": 0, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:3)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "expression": { + "type": "SequenceExpression", + "start": 0, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "expressions": [ + { + "type": "NumericLiteral", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "extra": { + "rawValue": 11.11, + "raw": "1_1_.1_1" + }, + "value": 11.11 + }, + { + "type": "NumericLiteral", + "start": 10, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-57/input.js b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-57/input.js index db8717756d2a..e2a13541725e 100644 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-57/input.js +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-57/input.js @@ -1 +1 @@ -1_1._1_1, +1_1._1_1, 0 diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-57/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-57/options.json deleted file mode 100644 index 91c5decd9c42..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-57/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:4)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-57/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-57/output.json new file mode 100644 index 000000000000..6e462c0e07d4 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-57/output.json @@ -0,0 +1,110 @@ +{ + "type": "File", + "start": 0, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:4)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "expression": { + "type": "SequenceExpression", + "start": 0, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "expressions": [ + { + "type": "NumericLiteral", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "extra": { + "rawValue": 11.11, + "raw": "1_1._1_1" + }, + "value": 11.11 + }, + { + "type": "NumericLiteral", + "start": 10, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-58/input.js b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-58/input.js index 5e5e356da976..49539d8e1686 100644 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-58/input.js +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-58/input.js @@ -1 +1 @@ -1_1.1_e1, +1_1.1_e1, 0 diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-58/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-58/options.json deleted file mode 100644 index a65e1ff322a7..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-58/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:5)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-58/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-58/output.json new file mode 100644 index 000000000000..95a795d633b6 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-58/output.json @@ -0,0 +1,110 @@ +{ + "type": "File", + "start": 0, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:5)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "expression": { + "type": "SequenceExpression", + "start": 0, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "expressions": [ + { + "type": "NumericLiteral", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "extra": { + "rawValue": 111, + "raw": "1_1.1_e1" + }, + "value": 111 + }, + { + "type": "NumericLiteral", + "start": 10, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-59/input.js b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-59/input.js index b07556e6d95e..b06fd2edbbc4 100644 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-59/input.js +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-59/input.js @@ -1 +1 @@ -1_1.1_E1, +1_1.1_E1, 0 diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-59/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-59/options.json deleted file mode 100644 index a65e1ff322a7..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-59/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:5)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-59/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-59/output.json new file mode 100644 index 000000000000..51953305e0c8 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-59/output.json @@ -0,0 +1,110 @@ +{ + "type": "File", + "start": 0, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:5)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "expression": { + "type": "SequenceExpression", + "start": 0, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "expressions": [ + { + "type": "NumericLiteral", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "extra": { + "rawValue": 111, + "raw": "1_1.1_E1" + }, + "value": 111 + }, + { + "type": "NumericLiteral", + "start": 10, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-6/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-6/options.json deleted file mode 100644 index a65e1ff322a7..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-6/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:5)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-6/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-6/output.json new file mode 100644 index 000000000000..d0b1538b39dc --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-6/output.json @@ -0,0 +1,73 @@ +{ + "type": "File", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:5)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "extra": { + "rawValue": 111, + "raw": "1_1.1_e1" + }, + "value": 111 + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-60/input.js b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-60/input.js index 0186dfaccb82..61f6290af574 100644 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-60/input.js +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-60/input.js @@ -1 +1 @@ -1_1.1e_1, +1_1.1e_1, 0 diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-60/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-60/options.json deleted file mode 100644 index 9c49308645fd..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-60/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:6)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-60/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-60/output.json new file mode 100644 index 000000000000..a394466973f3 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-60/output.json @@ -0,0 +1,110 @@ +{ + "type": "File", + "start": 0, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:6)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "expression": { + "type": "SequenceExpression", + "start": 0, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "expressions": [ + { + "type": "NumericLiteral", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "extra": { + "rawValue": 111, + "raw": "1_1.1e_1" + }, + "value": 111 + }, + { + "type": "NumericLiteral", + "start": 10, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-61/input.js b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-61/input.js index 85594dea3099..026cf8e40d3a 100644 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-61/input.js +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-61/input.js @@ -1 +1 @@ -1_1.1E_1, +1_1.1E_1, 0 diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-61/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-61/options.json deleted file mode 100644 index 9c49308645fd..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-61/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:6)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-61/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-61/output.json new file mode 100644 index 000000000000..36605277710f --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-61/output.json @@ -0,0 +1,110 @@ +{ + "type": "File", + "start": 0, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:6)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "expression": { + "type": "SequenceExpression", + "start": 0, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "expressions": [ + { + "type": "NumericLiteral", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "extra": { + "rawValue": 111, + "raw": "1_1.1E_1" + }, + "value": 111 + }, + { + "type": "NumericLiteral", + "start": 10, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-62/input.js b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-62/input.js index e0ed0c98f626..b34d9ea95a4d 100644 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-62/input.js +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-62/input.js @@ -1 +1 @@ -0x1_1_, +0x1_1_, 0 diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-62/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-62/options.json deleted file mode 100644 index a65e1ff322a7..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-62/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:5)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-62/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-62/output.json new file mode 100644 index 000000000000..347125ca2b1d --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-62/output.json @@ -0,0 +1,110 @@ +{ + "type": "File", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:5)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "expression": { + "type": "SequenceExpression", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "expressions": [ + { + "type": "NumericLiteral", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "extra": { + "rawValue": 17, + "raw": "0x1_1_" + }, + "value": 17 + }, + { + "type": "NumericLiteral", + "start": 8, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-63/input.js b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-63/input.js index d1b793f8dfed..28a917a7aca3 100644 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-63/input.js +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-63/input.js @@ -1 +1 @@ -0xa_1_, +0xa_1_, 0 diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-63/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-63/options.json deleted file mode 100644 index a65e1ff322a7..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-63/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:5)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-63/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-63/output.json new file mode 100644 index 000000000000..ac06aae7f847 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-63/output.json @@ -0,0 +1,110 @@ +{ + "type": "File", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:5)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "expression": { + "type": "SequenceExpression", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "expressions": [ + { + "type": "NumericLiteral", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "extra": { + "rawValue": 161, + "raw": "0xa_1_" + }, + "value": 161 + }, + { + "type": "NumericLiteral", + "start": 8, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-64/input.js b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-64/input.js index e5543066d000..8e1c3c4399a1 100644 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-64/input.js +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-64/input.js @@ -1 +1 @@ -0x_a_1, +0x_a_1, 0 diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-64/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-64/options.json deleted file mode 100644 index 8cb6bf4866a3..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-64/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:2)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-64/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-64/output.json new file mode 100644 index 000000000000..a70fc4a0fa0f --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-64/output.json @@ -0,0 +1,110 @@ +{ + "type": "File", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:2)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "expression": { + "type": "SequenceExpression", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "expressions": [ + { + "type": "NumericLiteral", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "extra": { + "rawValue": 161, + "raw": "0x_a_1" + }, + "value": 161 + }, + { + "type": "NumericLiteral", + "start": 8, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-65/input.js b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-65/input.js index 68e6a0d63fea..d8039a473eb0 100644 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-65/input.js +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-65/input.js @@ -1 +1 @@ -0x__1_1_, +0x__1_1_, 0 diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-65/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-65/options.json deleted file mode 100644 index 8cb6bf4866a3..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-65/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:2)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-65/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-65/output.json new file mode 100644 index 000000000000..b75b68e18c5f --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-65/output.json @@ -0,0 +1,112 @@ +{ + "type": "File", + "start": 0, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:2)", + "SyntaxError: A numeric separator is only allowed between two digits (1:3)", + "SyntaxError: A numeric separator is only allowed between two digits (1:7)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "expression": { + "type": "SequenceExpression", + "start": 0, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "expressions": [ + { + "type": "NumericLiteral", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "extra": { + "rawValue": 17, + "raw": "0x__1_1_" + }, + "value": 17 + }, + { + "type": "NumericLiteral", + "start": 10, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-66/input.js b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-66/input.js index fd959c9609a9..3853dd5ba743 100644 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-66/input.js +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-66/input.js @@ -1 +1 @@ -0x_1__1, +0x_1__1, 0 diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-66/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-66/options.json deleted file mode 100644 index 8cb6bf4866a3..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-66/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:2)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-66/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-66/output.json new file mode 100644 index 000000000000..7ddf567a2967 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-66/output.json @@ -0,0 +1,112 @@ +{ + "type": "File", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:2)", + "SyntaxError: A numeric separator is only allowed between two digits (1:4)", + "SyntaxError: A numeric separator is only allowed between two digits (1:5)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "expression": { + "type": "SequenceExpression", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "expressions": [ + { + "type": "NumericLiteral", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "extra": { + "rawValue": 17, + "raw": "0x_1__1" + }, + "value": 17 + }, + { + "type": "NumericLiteral", + "start": 9, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-67/input.js b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-67/input.js index dc2301a00ea7..90213eb4c896 100644 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-67/input.js +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-67/input.js @@ -1 +1 @@ -0x_1_1_, +0x_1_1_, 0 diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-67/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-67/options.json deleted file mode 100644 index 8cb6bf4866a3..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-67/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:2)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-67/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-67/output.json new file mode 100644 index 000000000000..849bdb6de9a8 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-67/output.json @@ -0,0 +1,111 @@ +{ + "type": "File", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:2)", + "SyntaxError: A numeric separator is only allowed between two digits (1:6)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "expression": { + "type": "SequenceExpression", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "expressions": [ + { + "type": "NumericLiteral", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "extra": { + "rawValue": 17, + "raw": "0x_1_1_" + }, + "value": 17 + }, + { + "type": "NumericLiteral", + "start": 9, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-68/input.js b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-68/input.js index 3a7f53b8dc81..56f62d261b65 100644 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-68/input.js +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-68/input.js @@ -1 +1 @@ -0o_1_1, +0o_1_1, 0 diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-68/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-68/options.json deleted file mode 100644 index 8cb6bf4866a3..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-68/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:2)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-68/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-68/output.json new file mode 100644 index 000000000000..112bef72c91a --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-68/output.json @@ -0,0 +1,110 @@ +{ + "type": "File", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:2)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "expression": { + "type": "SequenceExpression", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "expressions": [ + { + "type": "NumericLiteral", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "extra": { + "rawValue": 9, + "raw": "0o_1_1" + }, + "value": 9 + }, + { + "type": "NumericLiteral", + "start": 8, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-69/input.js b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-69/input.js index ed870aa937cd..fe56d1a3c36d 100644 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-69/input.js +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-69/input.js @@ -1 +1 @@ -0o_11, +0o_11, 0 diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-69/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-69/options.json deleted file mode 100644 index 8cb6bf4866a3..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-69/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:2)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-69/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-69/output.json new file mode 100644 index 000000000000..e702d612d243 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-69/output.json @@ -0,0 +1,110 @@ +{ + "type": "File", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:2)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "expression": { + "type": "SequenceExpression", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "expressions": [ + { + "type": "NumericLiteral", + "start": 0, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "extra": { + "rawValue": 9, + "raw": "0o_11" + }, + "value": 9 + }, + { + "type": "NumericLiteral", + "start": 7, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-7/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-7/options.json deleted file mode 100644 index a65e1ff322a7..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-7/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:5)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-7/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-7/output.json new file mode 100644 index 000000000000..13d9caf030b8 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-7/output.json @@ -0,0 +1,73 @@ +{ + "type": "File", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:5)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "extra": { + "rawValue": 111, + "raw": "1_1.1_E1" + }, + "value": 111 + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-70/input.js b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-70/input.js index e9fcb15ff998..d395282140ef 100644 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-70/input.js +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-70/input.js @@ -1 +1 @@ -0o_01_1_, +0o_01_1_, 0 diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-70/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-70/options.json deleted file mode 100644 index 8cb6bf4866a3..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-70/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:2)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-70/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-70/output.json new file mode 100644 index 000000000000..5f86cf161b9a --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-70/output.json @@ -0,0 +1,111 @@ +{ + "type": "File", + "start": 0, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:2)", + "SyntaxError: A numeric separator is only allowed between two digits (1:7)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "expression": { + "type": "SequenceExpression", + "start": 0, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "expressions": [ + { + "type": "NumericLiteral", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "extra": { + "rawValue": 9, + "raw": "0o_01_1_" + }, + "value": 9 + }, + { + "type": "NumericLiteral", + "start": 10, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-71/input.js b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-71/input.js index 86cc54d9ed2d..4f5cb5c1e06b 100644 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-71/input.js +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-71/input.js @@ -1 +1 @@ -0b_0_1_1, +0b_0_1_1, 0 diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-71/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-71/options.json deleted file mode 100644 index 8cb6bf4866a3..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-71/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:2)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-71/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-71/output.json new file mode 100644 index 000000000000..5ce3d7e5f1db --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-71/output.json @@ -0,0 +1,110 @@ +{ + "type": "File", + "start": 0, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:2)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "expression": { + "type": "SequenceExpression", + "start": 0, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "expressions": [ + { + "type": "NumericLiteral", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "extra": { + "rawValue": 3, + "raw": "0b_0_1_1" + }, + "value": 3 + }, + { + "type": "NumericLiteral", + "start": 10, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-72/input.js b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-72/input.js index 0c52a13346c0..1589fddd67c3 100644 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-72/input.js +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-72/input.js @@ -1 +1 @@ -0b_01_1_, +0b_01_1_, 0 diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-72/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-72/options.json deleted file mode 100644 index 8cb6bf4866a3..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-72/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:2)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-72/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-72/output.json new file mode 100644 index 000000000000..3364a2a11b7b --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-72/output.json @@ -0,0 +1,111 @@ +{ + "type": "File", + "start": 0, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:2)", + "SyntaxError: A numeric separator is only allowed between two digits (1:7)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "expression": { + "type": "SequenceExpression", + "start": 0, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "expressions": [ + { + "type": "NumericLiteral", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "extra": { + "rawValue": 3, + "raw": "0b_01_1_" + }, + "value": 3 + }, + { + "type": "NumericLiteral", + "start": 10, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-73/input.js b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-73/input.js index 95c45fd025be..c730763e66fa 100644 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-73/input.js +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-73/input.js @@ -1 +1 @@ -0b01_1_, +0b01_1_, 0 diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-73/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-73/options.json deleted file mode 100644 index 9c49308645fd..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-73/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:6)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-73/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-73/output.json new file mode 100644 index 000000000000..77046a4ee17f --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-73/output.json @@ -0,0 +1,110 @@ +{ + "type": "File", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:6)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "expression": { + "type": "SequenceExpression", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "expressions": [ + { + "type": "NumericLiteral", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "extra": { + "rawValue": 3, + "raw": "0b01_1_" + }, + "value": 3 + }, + { + "type": "NumericLiteral", + "start": 9, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-74/input.js b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-74/input.js index 58ff35dd6c36..3a3aa0484726 100644 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-74/input.js +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-74/input.js @@ -1 +1 @@ -0o1_1_, +0o1_1_, 0 diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-74/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-74/options.json deleted file mode 100644 index a65e1ff322a7..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-74/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:5)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-74/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-74/output.json new file mode 100644 index 000000000000..fdc0933003a0 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-74/output.json @@ -0,0 +1,110 @@ +{ + "type": "File", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:5)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "expression": { + "type": "SequenceExpression", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "expressions": [ + { + "type": "NumericLiteral", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "extra": { + "rawValue": 9, + "raw": "0o1_1_" + }, + "value": 9 + }, + { + "type": "NumericLiteral", + "start": 8, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-75/input.js b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-75/input.js index bd44d425a6fa..a4d36757d478 100644 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-75/input.js +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-75/input.js @@ -1 +1 @@ -0o_1_1_, +0o_1_1_, 0 diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-75/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-75/options.json deleted file mode 100644 index 8cb6bf4866a3..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-75/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:2)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-75/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-75/output.json new file mode 100644 index 000000000000..7f14d41f530d --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-75/output.json @@ -0,0 +1,111 @@ +{ + "type": "File", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:2)", + "SyntaxError: A numeric separator is only allowed between two digits (1:6)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "expression": { + "type": "SequenceExpression", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "expressions": [ + { + "type": "NumericLiteral", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "extra": { + "rawValue": 9, + "raw": "0o_1_1_" + }, + "value": 9 + }, + { + "type": "NumericLiteral", + "start": 9, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-76/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-76/options.json deleted file mode 100644 index 8cb6bf4866a3..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-76/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:2)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-76/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-76/output.json new file mode 100644 index 000000000000..f505cbb81666 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-76/output.json @@ -0,0 +1,90 @@ +{ + "type": "File", + "start": 0, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:2)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "expression": { + "type": "ArrayExpression", + "start": 0, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "elements": [ + { + "type": "NumericLiteral", + "start": 1, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "extra": { + "rawValue": 1, + "raw": "1_" + }, + "value": 1 + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-77/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-77/options.json deleted file mode 100644 index 91c5decd9c42..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-77/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:4)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-77/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-77/output.json new file mode 100644 index 000000000000..2648664f298c --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-77/output.json @@ -0,0 +1,90 @@ +{ + "type": "File", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:4)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "expression": { + "type": "ArrayExpression", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "elements": [ + { + "type": "NumericLiteral", + "start": 1, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "extra": { + "rawValue": 11, + "raw": "1_1_" + }, + "value": 11 + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-78/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-78/options.json deleted file mode 100644 index 91c5decd9c42..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-78/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:4)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-78/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-78/output.json new file mode 100644 index 000000000000..a270c2420610 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-78/output.json @@ -0,0 +1,91 @@ +{ + "type": "File", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:4)", + "SyntaxError: A numeric separator is only allowed between two digits (1:5)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "expression": { + "type": "ArrayExpression", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "elements": [ + { + "type": "NumericLiteral", + "start": 1, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "extra": { + "rawValue": 11, + "raw": "1_1__" + }, + "value": 11 + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-79/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-79/options.json deleted file mode 100644 index 8cb6bf4866a3..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-79/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:2)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-79/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-79/output.json new file mode 100644 index 000000000000..650a98a4cbff --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-79/output.json @@ -0,0 +1,91 @@ +{ + "type": "File", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:2)", + "SyntaxError: A numeric separator is only allowed between two digits (1:3)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "expression": { + "type": "ArrayExpression", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "elements": [ + { + "type": "NumericLiteral", + "start": 1, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "extra": { + "rawValue": 11, + "raw": "1__1" + }, + "value": 11 + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-8/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-8/options.json deleted file mode 100644 index 9c49308645fd..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-8/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:6)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-8/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-8/output.json new file mode 100644 index 000000000000..037c60cbef6f --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-8/output.json @@ -0,0 +1,73 @@ +{ + "type": "File", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:6)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "extra": { + "rawValue": 111, + "raw": "1_1.1e_1" + }, + "value": 111 + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-80/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-80/options.json deleted file mode 100644 index 91c5decd9c42..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-80/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:4)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-80/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-80/output.json new file mode 100644 index 000000000000..1410809bebec --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-80/output.json @@ -0,0 +1,90 @@ +{ + "type": "File", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:4)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "expression": { + "type": "ArrayExpression", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "elements": [ + { + "type": "NumericLiteral", + "start": 1, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "extra": { + "rawValue": 11.11, + "raw": "1_1_.1_1" + }, + "value": 11.11 + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-81/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-81/options.json deleted file mode 100644 index a65e1ff322a7..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-81/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:5)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-81/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-81/output.json new file mode 100644 index 000000000000..5ac0337bfe64 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-81/output.json @@ -0,0 +1,90 @@ +{ + "type": "File", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:5)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "expression": { + "type": "ArrayExpression", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "elements": [ + { + "type": "NumericLiteral", + "start": 1, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "extra": { + "rawValue": 11.11, + "raw": "1_1._1_1" + }, + "value": 11.11 + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-82/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-82/options.json deleted file mode 100644 index 9c49308645fd..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-82/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:6)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-82/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-82/output.json new file mode 100644 index 000000000000..417003e07eaa --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-82/output.json @@ -0,0 +1,90 @@ +{ + "type": "File", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:6)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "expression": { + "type": "ArrayExpression", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "elements": [ + { + "type": "NumericLiteral", + "start": 1, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "extra": { + "rawValue": 111, + "raw": "1_1.1_e1" + }, + "value": 111 + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-83/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-83/options.json deleted file mode 100644 index 9c49308645fd..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-83/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:6)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-83/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-83/output.json new file mode 100644 index 000000000000..9aa4e5c834d8 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-83/output.json @@ -0,0 +1,90 @@ +{ + "type": "File", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:6)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "expression": { + "type": "ArrayExpression", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "elements": [ + { + "type": "NumericLiteral", + "start": 1, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "extra": { + "rawValue": 111, + "raw": "1_1.1_E1" + }, + "value": 111 + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-84/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-84/options.json deleted file mode 100644 index badcb4c1b655..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-84/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:7)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-84/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-84/output.json new file mode 100644 index 000000000000..859e6d5d5325 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-84/output.json @@ -0,0 +1,90 @@ +{ + "type": "File", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:7)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "expression": { + "type": "ArrayExpression", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "elements": [ + { + "type": "NumericLiteral", + "start": 1, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "extra": { + "rawValue": 111, + "raw": "1_1.1e_1" + }, + "value": 111 + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-85/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-85/options.json deleted file mode 100644 index badcb4c1b655..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-85/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:7)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-85/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-85/output.json new file mode 100644 index 000000000000..5020300be097 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-85/output.json @@ -0,0 +1,90 @@ +{ + "type": "File", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:7)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "expression": { + "type": "ArrayExpression", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "elements": [ + { + "type": "NumericLiteral", + "start": 1, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "extra": { + "rawValue": 111, + "raw": "1_1.1E_1" + }, + "value": 111 + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-86/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-86/options.json deleted file mode 100644 index 9c49308645fd..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-86/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:6)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-86/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-86/output.json new file mode 100644 index 000000000000..3f132f054796 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-86/output.json @@ -0,0 +1,90 @@ +{ + "type": "File", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:6)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "expression": { + "type": "ArrayExpression", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "elements": [ + { + "type": "NumericLiteral", + "start": 1, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "extra": { + "rawValue": 17, + "raw": "0x1_1_" + }, + "value": 17 + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-87/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-87/options.json deleted file mode 100644 index 9c49308645fd..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-87/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:6)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-87/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-87/output.json new file mode 100644 index 000000000000..173a126235b1 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-87/output.json @@ -0,0 +1,90 @@ +{ + "type": "File", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:6)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "expression": { + "type": "ArrayExpression", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "elements": [ + { + "type": "NumericLiteral", + "start": 1, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "extra": { + "rawValue": 161, + "raw": "0xa_1_" + }, + "value": 161 + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-88/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-88/options.json deleted file mode 100644 index 477511a87822..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-88/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:3)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-88/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-88/output.json new file mode 100644 index 000000000000..4f7277b6d914 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-88/output.json @@ -0,0 +1,90 @@ +{ + "type": "File", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:3)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "expression": { + "type": "ArrayExpression", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "elements": [ + { + "type": "NumericLiteral", + "start": 1, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "extra": { + "rawValue": 161, + "raw": "0x_a_1" + }, + "value": 161 + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-89/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-89/options.json deleted file mode 100644 index 477511a87822..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-89/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:3)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-89/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-89/output.json new file mode 100644 index 000000000000..1e5f3a747c34 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-89/output.json @@ -0,0 +1,92 @@ +{ + "type": "File", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:3)", + "SyntaxError: A numeric separator is only allowed between two digits (1:4)", + "SyntaxError: A numeric separator is only allowed between two digits (1:8)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "expression": { + "type": "ArrayExpression", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "elements": [ + { + "type": "NumericLiteral", + "start": 1, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "extra": { + "rawValue": 17, + "raw": "0x__1_1_" + }, + "value": 17 + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-9/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-9/options.json deleted file mode 100644 index 9c49308645fd..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-9/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:6)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-9/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-9/output.json new file mode 100644 index 000000000000..ea1d5804721a --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-9/output.json @@ -0,0 +1,73 @@ +{ + "type": "File", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:6)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "extra": { + "rawValue": 111, + "raw": "1_1.1E_1" + }, + "value": 111 + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-90/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-90/options.json deleted file mode 100644 index 477511a87822..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-90/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:3)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-90/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-90/output.json new file mode 100644 index 000000000000..9723cfbd4fda --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-90/output.json @@ -0,0 +1,92 @@ +{ + "type": "File", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:3)", + "SyntaxError: A numeric separator is only allowed between two digits (1:5)", + "SyntaxError: A numeric separator is only allowed between two digits (1:6)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "expression": { + "type": "ArrayExpression", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "elements": [ + { + "type": "NumericLiteral", + "start": 1, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "extra": { + "rawValue": 17, + "raw": "0x_1__1" + }, + "value": 17 + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-91/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-91/options.json deleted file mode 100644 index 477511a87822..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-91/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:3)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-91/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-91/output.json new file mode 100644 index 000000000000..e802a59e0737 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-91/output.json @@ -0,0 +1,91 @@ +{ + "type": "File", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:3)", + "SyntaxError: A numeric separator is only allowed between two digits (1:7)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "expression": { + "type": "ArrayExpression", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "elements": [ + { + "type": "NumericLiteral", + "start": 1, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "extra": { + "rawValue": 17, + "raw": "0x_1_1_" + }, + "value": 17 + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-92/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-92/options.json deleted file mode 100644 index 477511a87822..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-92/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:3)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-92/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-92/output.json new file mode 100644 index 000000000000..ffc792a8db4d --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-92/output.json @@ -0,0 +1,90 @@ +{ + "type": "File", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:3)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "expression": { + "type": "ArrayExpression", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "elements": [ + { + "type": "NumericLiteral", + "start": 1, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "extra": { + "rawValue": 9, + "raw": "0o_1_1" + }, + "value": 9 + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-93/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-93/options.json deleted file mode 100644 index 477511a87822..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-93/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:3)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-93/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-93/output.json new file mode 100644 index 000000000000..583643ac786d --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-93/output.json @@ -0,0 +1,90 @@ +{ + "type": "File", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:3)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "expression": { + "type": "ArrayExpression", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "elements": [ + { + "type": "NumericLiteral", + "start": 1, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "extra": { + "rawValue": 9, + "raw": "0o_11" + }, + "value": 9 + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-94/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-94/options.json deleted file mode 100644 index 477511a87822..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-94/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:3)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-94/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-94/output.json new file mode 100644 index 000000000000..71984f0f6d53 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-94/output.json @@ -0,0 +1,91 @@ +{ + "type": "File", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:3)", + "SyntaxError: A numeric separator is only allowed between two digits (1:8)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "expression": { + "type": "ArrayExpression", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "elements": [ + { + "type": "NumericLiteral", + "start": 1, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "extra": { + "rawValue": 9, + "raw": "0o_01_1_" + }, + "value": 9 + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-95/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-95/options.json deleted file mode 100644 index 477511a87822..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-95/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:3)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-95/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-95/output.json new file mode 100644 index 000000000000..92169c50ab72 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-95/output.json @@ -0,0 +1,90 @@ +{ + "type": "File", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:3)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "expression": { + "type": "ArrayExpression", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "elements": [ + { + "type": "NumericLiteral", + "start": 1, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "extra": { + "rawValue": 3, + "raw": "0b_0_1_1" + }, + "value": 3 + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-96/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-96/options.json deleted file mode 100644 index 477511a87822..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-96/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:3)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-96/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-96/output.json new file mode 100644 index 000000000000..8775652f6e4e --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-96/output.json @@ -0,0 +1,91 @@ +{ + "type": "File", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:3)", + "SyntaxError: A numeric separator is only allowed between two digits (1:8)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "expression": { + "type": "ArrayExpression", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "elements": [ + { + "type": "NumericLiteral", + "start": 1, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "extra": { + "rawValue": 3, + "raw": "0b_01_1_" + }, + "value": 3 + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-97/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-97/options.json deleted file mode 100644 index badcb4c1b655..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-97/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:7)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-97/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-97/output.json new file mode 100644 index 000000000000..8427ff4fefb2 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-97/output.json @@ -0,0 +1,90 @@ +{ + "type": "File", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:7)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "expression": { + "type": "ArrayExpression", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "elements": [ + { + "type": "NumericLiteral", + "start": 1, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "extra": { + "rawValue": 3, + "raw": "0b01_1_" + }, + "value": 3 + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-98/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-98/options.json deleted file mode 100644 index 9c49308645fd..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-98/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:6)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-98/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-98/output.json new file mode 100644 index 000000000000..ab96b90e5fb1 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-98/output.json @@ -0,0 +1,90 @@ +{ + "type": "File", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:6)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "expression": { + "type": "ArrayExpression", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "elements": [ + { + "type": "NumericLiteral", + "start": 1, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "extra": { + "rawValue": 9, + "raw": "0o1_1_" + }, + "value": 9 + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-99/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-99/options.json deleted file mode 100644 index 477511a87822..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-99/options.json +++ /dev/null @@ -1 +0,0 @@ -{ "throws": "Invalid or unexpected token (1:3)" } diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-99/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-99/output.json new file mode 100644 index 000000000000..a3925ad6c8e8 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-99/output.json @@ -0,0 +1,91 @@ +{ + "type": "File", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "errors": [ + "SyntaxError: A numeric separator is only allowed between two digits (1:3)", + "SyntaxError: A numeric separator is only allowed between two digits (1:7)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "expression": { + "type": "ArrayExpression", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "elements": [ + { + "type": "NumericLiteral", + "start": 1, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "extra": { + "rawValue": 9, + "raw": "0o_1_1_" + }, + "value": 9 + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-hex/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-hex/options.json index fd0b1c7f0a7d..45b66a114bf9 100644 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-hex/options.json +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-hex/options.json @@ -1 +1,6 @@ -{ "throws": "Numeric separators are not allowed inside unicode escape sequences or hex escape sequences (1:4)" } +{ + "plugins": [ + "bigInt", + "numericSeparator" + ] +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-hex/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-hex/output.json new file mode 100644 index 000000000000..f47a3612a995 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-hex/output.json @@ -0,0 +1,73 @@ +{ + "type": "File", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "errors": [ + "SyntaxError: Numeric separators are not allowed inside unicode escape sequences or hex escape sequences (1:4)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [], + "directives": [ + { + "type": "Directive", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "value": "\\x1_0", + "extra": { + "raw": "\"\\x1_0\"", + "rawValue": "\\x1_0" + } + } + } + ] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-leading-zero/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-leading-zero/options.json index 57c99a94dbd6..45b66a114bf9 100644 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-leading-zero/options.json +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-leading-zero/options.json @@ -1 +1,6 @@ -{ "throws": "Numeric separator can not be used after leading 0 (1:1)" } +{ + "plugins": [ + "bigInt", + "numericSeparator" + ] +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-leading-zero/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-leading-zero/output.json new file mode 100644 index 000000000000..b9271342b1f5 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-leading-zero/output.json @@ -0,0 +1,73 @@ +{ + "type": "File", + "start": 0, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "errors": [ + "SyntaxError: Numeric separator can not be used after leading 0 (1:1)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 0, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "extra": { + "rawValue": 8, + "raw": "0_8" + }, + "value": 8 + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-legacy-octal-literal/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-legacy-octal-literal/options.json index 5a4fb4525d02..45b66a114bf9 100644 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-legacy-octal-literal/options.json +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-legacy-octal-literal/options.json @@ -1 +1,6 @@ -{ "throws": "Numeric separator can not be used after leading 0 (1:2)" } +{ + "plugins": [ + "bigInt", + "numericSeparator" + ] +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-legacy-octal-literal/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-legacy-octal-literal/output.json new file mode 100644 index 000000000000..9677b88e4b27 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-legacy-octal-literal/output.json @@ -0,0 +1,73 @@ +{ + "type": "File", + "start": 0, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "errors": [ + "SyntaxError: Numeric separator can not be used after leading 0 (1:2)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 0, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "extra": { + "rawValue": 0, + "raw": "00_0" + }, + "value": 0 + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-non-octal-decimal-int/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-non-octal-decimal-int/options.json index 5a4fb4525d02..45b66a114bf9 100644 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-non-octal-decimal-int/options.json +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-non-octal-decimal-int/options.json @@ -1 +1,6 @@ -{ "throws": "Numeric separator can not be used after leading 0 (1:2)" } +{ + "plugins": [ + "bigInt", + "numericSeparator" + ] +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-non-octal-decimal-int/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-non-octal-decimal-int/output.json new file mode 100644 index 000000000000..da24fe2bdd7d --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-non-octal-decimal-int/output.json @@ -0,0 +1,74 @@ +{ + "type": "File", + "start": 0, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "errors": [ + "SyntaxError: Numeric separator can not be used after leading 0 (1:2)", + "SyntaxError: Invalid BigIntLiteral (1:0)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "expression": { + "type": "BigIntLiteral", + "start": 0, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "extra": { + "rawValue": "080", + "raw": "08_0n" + }, + "value": "080" + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-unicode-2/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-unicode-2/options.json index ca0ceaeaaea6..45b66a114bf9 100644 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-unicode-2/options.json +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-unicode-2/options.json @@ -1 +1,6 @@ -{ "throws": "Numeric separators are not allowed inside unicode escape sequences or hex escape sequences (1:5)" } +{ + "plugins": [ + "bigInt", + "numericSeparator" + ] +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-unicode-2/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-unicode-2/output.json new file mode 100644 index 000000000000..b3d5564b9494 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-unicode-2/output.json @@ -0,0 +1,73 @@ +{ + "type": "File", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "errors": [ + "SyntaxError: Numeric separators are not allowed inside unicode escape sequences or hex escape sequences (1:5)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [], + "directives": [ + { + "type": "Directive", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "value": "\\u12_34", + "extra": { + "raw": "\"\\u12_34\"", + "rawValue": "\\u12_34" + } + } + } + ] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-unicode/options.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-unicode/options.json index e42d95d86acf..45b66a114bf9 100644 --- a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-unicode/options.json +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-unicode/options.json @@ -1 +1,6 @@ -{ "throws": "Numeric separators are not allowed inside unicode escape sequences or hex escape sequences (1:6)" } +{ + "plugins": [ + "bigInt", + "numericSeparator" + ] +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-unicode/output.json b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-unicode/output.json new file mode 100644 index 000000000000..e30a6e6b7370 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/numeric-separator/invalid-unicode/output.json @@ -0,0 +1,73 @@ +{ + "type": "File", + "start": 0, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "errors": [ + "SyntaxError: Numeric separators are not allowed inside unicode escape sequences or hex escape sequences (1:6)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [], + "directives": [ + { + "type": "Directive", + "start": 0, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 0, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "value": "\\u{1F_639}", + "extra": { + "raw": "\"\\u{1F_639}\"", + "rawValue": "\\u{1F_639}" + } + } + } + ] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/optional-chaining/class-contructor-call/options.json b/packages/babel-parser/test/fixtures/experimental/optional-chaining/class-contructor-call/options.json index ed5e3c16bf68..0011d898807d 100644 --- a/packages/babel-parser/test/fixtures/experimental/optional-chaining/class-contructor-call/options.json +++ b/packages/babel-parser/test/fixtures/experimental/optional-chaining/class-contructor-call/options.json @@ -1,4 +1,5 @@ { - "plugins": ["optionalChaining"], - "throws": "constructors in/after an Optional Chain are not allowed (1:10)" -} + "plugins": [ + "optionalChaining" + ] +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/optional-chaining/class-contructor-call/output.json b/packages/babel-parser/test/fixtures/experimental/optional-chaining/class-contructor-call/output.json new file mode 100644 index 000000000000..8ecf52133d5f --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/optional-chaining/class-contructor-call/output.json @@ -0,0 +1,154 @@ +{ + "type": "File", + "start": 0, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "errors": [ + "SyntaxError: constructors in/after an Optional Chain are not allowed (1:10)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "expression": { + "type": "NewExpression", + "start": 0, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "callee": { + "type": "OptionalMemberExpression", + "start": 4, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "object": { + "type": "OptionalMemberExpression", + "start": 4, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "object": { + "type": "Identifier", + "start": 4, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 5 + }, + "identifierName": "C" + }, + "name": "C" + }, + "property": { + "type": "Identifier", + "start": 7, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 8 + }, + "identifierName": "b" + }, + "name": "b" + }, + "computed": false, + "optional": true + }, + "property": { + "type": "Identifier", + "start": 9, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 10 + }, + "identifierName": "d" + }, + "name": "d" + }, + "computed": false, + "optional": false + }, + "arguments": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/optional-chaining/optional-constructor/options.json b/packages/babel-parser/test/fixtures/experimental/optional-chaining/optional-constructor/options.json index 10cef4d48073..0011d898807d 100644 --- a/packages/babel-parser/test/fixtures/experimental/optional-chaining/optional-constructor/options.json +++ b/packages/babel-parser/test/fixtures/experimental/optional-chaining/optional-constructor/options.json @@ -1,4 +1,5 @@ { - "plugins": ["optionalChaining"], - "throws": "constructors in/after an Optional Chain are not allowed (1:7)" -} + "plugins": [ + "optionalChaining" + ] +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/optional-chaining/optional-constructor/output.json b/packages/babel-parser/test/fixtures/experimental/optional-chaining/optional-constructor/output.json new file mode 100644 index 000000000000..6c643fbdd8ab --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/optional-chaining/optional-constructor/output.json @@ -0,0 +1,86 @@ +{ + "type": "File", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "errors": [ + "SyntaxError: constructors in/after an Optional Chain are not allowed (1:7)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "expression": { + "type": "NewExpression", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "callee": { + "type": "Identifier", + "start": 4, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 5 + }, + "identifierName": "a" + }, + "name": "a" + }, + "arguments": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/optional-chaining/optional-super-property-class/options.json b/packages/babel-parser/test/fixtures/experimental/optional-chaining/optional-super-property-class/options.json index 86849e8c464a..fd201c1bdb02 100644 --- a/packages/babel-parser/test/fixtures/experimental/optional-chaining/optional-super-property-class/options.json +++ b/packages/babel-parser/test/fixtures/experimental/optional-chaining/optional-super-property-class/options.json @@ -1,4 +1,3 @@ { - "plugins": ["optionalChaining"], - "throws": "Unexpected token (3:20)" + "plugins": ["optionalChaining"] } diff --git a/packages/babel-parser/test/fixtures/experimental/optional-chaining/optional-super-property-class/output.json b/packages/babel-parser/test/fixtures/experimental/optional-chaining/optional-super-property-class/output.json new file mode 100644 index 000000000000..1f9545412a7a --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/optional-chaining/optional-super-property-class/output.json @@ -0,0 +1,209 @@ +{ + "type": "File", + "start": 0, + "end": 50, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 5, + "column": 1 + } + }, + "errors": [ + "SyntaxError: super can only be used with function calls (i.e. super()) or in property accesses (i.e. super.prop or super[prop]) (3:15)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 50, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 5, + "column": 1 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ClassDeclaration", + "start": 0, + "end": 50, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 5, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 6, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + }, + "identifierName": "A" + }, + "name": "A" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "start": 7, + "end": 50, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 5, + "column": 1 + } + }, + "body": [ + { + "type": "ClassMethod", + "start": 13, + "end": 48, + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 4, + "column": 5 + } + }, + "static": false, + "key": { + "type": "Identifier", + "start": 13, + "end": 14, + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 5 + }, + "identifierName": "b" + }, + "name": "b" + }, + "computed": false, + "kind": "method", + "id": null, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 16, + "end": 48, + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 4, + "column": 5 + } + }, + "body": [ + { + "type": "ReturnStatement", + "start": 26, + "end": 42, + "loc": { + "start": { + "line": 3, + "column": 8 + }, + "end": { + "line": 3, + "column": 24 + } + }, + "argument": { + "type": "OptionalMemberExpression", + "start": 33, + "end": 41, + "loc": { + "start": { + "line": 3, + "column": 15 + }, + "end": { + "line": 3, + "column": 23 + } + }, + "object": { + "type": "Super", + "start": 33, + "end": 38, + "loc": { + "start": { + "line": 3, + "column": 15 + }, + "end": { + "line": 3, + "column": 20 + } + } + }, + "property": { + "type": "Identifier", + "start": 40, + "end": 41, + "loc": { + "start": { + "line": 3, + "column": 22 + }, + "end": { + "line": 3, + "column": 23 + }, + "identifierName": "b" + }, + "name": "b" + }, + "computed": false, + "optional": true + } + } + ], + "directives": [] + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/optional-chaining/optional-super-property/options.json b/packages/babel-parser/test/fixtures/experimental/optional-chaining/optional-super-property/options.json index 86849e8c464a..fd201c1bdb02 100644 --- a/packages/babel-parser/test/fixtures/experimental/optional-chaining/optional-super-property/options.json +++ b/packages/babel-parser/test/fixtures/experimental/optional-chaining/optional-super-property/options.json @@ -1,4 +1,3 @@ { - "plugins": ["optionalChaining"], - "throws": "Unexpected token (3:20)" + "plugins": ["optionalChaining"] } diff --git a/packages/babel-parser/test/fixtures/experimental/optional-chaining/optional-super-property/output.json b/packages/babel-parser/test/fixtures/experimental/optional-chaining/optional-super-property/output.json new file mode 100644 index 000000000000..548b5c32d5a7 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/optional-chaining/optional-super-property/output.json @@ -0,0 +1,226 @@ +{ + "type": "File", + "start": 0, + "end": 53, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 5, + "column": 1 + } + }, + "errors": [ + "SyntaxError: super can only be used with function calls (i.e. super()) or in property accesses (i.e. super.prop or super[prop]) (3:15)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 53, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 5, + "column": 1 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "VariableDeclaration", + "start": 0, + "end": 53, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 5, + "column": 1 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 6, + "end": 53, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 5, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 6, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + }, + "identifierName": "a" + }, + "name": "a" + }, + "init": { + "type": "ObjectExpression", + "start": 10, + "end": 53, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 5, + "column": 1 + } + }, + "properties": [ + { + "type": "ObjectMethod", + "start": 16, + "end": 51, + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 4, + "column": 5 + } + }, + "method": true, + "key": { + "type": "Identifier", + "start": 16, + "end": 17, + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 5 + }, + "identifierName": "b" + }, + "name": "b" + }, + "computed": false, + "kind": "method", + "id": null, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 19, + "end": 51, + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 4, + "column": 5 + } + }, + "body": [ + { + "type": "ReturnStatement", + "start": 29, + "end": 45, + "loc": { + "start": { + "line": 3, + "column": 8 + }, + "end": { + "line": 3, + "column": 24 + } + }, + "argument": { + "type": "OptionalMemberExpression", + "start": 36, + "end": 44, + "loc": { + "start": { + "line": 3, + "column": 15 + }, + "end": { + "line": 3, + "column": 23 + } + }, + "object": { + "type": "Super", + "start": 36, + "end": 41, + "loc": { + "start": { + "line": 3, + "column": 15 + }, + "end": { + "line": 3, + "column": 20 + } + } + }, + "property": { + "type": "Identifier", + "start": 43, + "end": 44, + "loc": { + "start": { + "line": 3, + "column": 22 + }, + "end": { + "line": 3, + "column": 23 + }, + "identifierName": "c" + }, + "name": "c" + }, + "computed": false, + "optional": true + } + } + ], + "directives": [] + } + } + ] + } + } + ], + "kind": "const" + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/optional-chaining/optional-tagged-template-literals/options.json b/packages/babel-parser/test/fixtures/experimental/optional-chaining/optional-tagged-template-literals/options.json index 631741b044e0..0011d898807d 100644 --- a/packages/babel-parser/test/fixtures/experimental/optional-chaining/optional-tagged-template-literals/options.json +++ b/packages/babel-parser/test/fixtures/experimental/optional-chaining/optional-tagged-template-literals/options.json @@ -1,4 +1,5 @@ { - "plugins": ["optionalChaining"], - "throws": "Tagged Template Literals are not allowed in optionalChain (1:0)" -} + "plugins": [ + "optionalChaining" + ] +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/optional-chaining/optional-tagged-template-literals/output.json b/packages/babel-parser/test/fixtures/experimental/optional-chaining/optional-tagged-template-literals/output.json new file mode 100644 index 000000000000..9dff15f15eda --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/optional-chaining/optional-tagged-template-literals/output.json @@ -0,0 +1,157 @@ +{ + "type": "File", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "errors": [ + "SyntaxError: Tagged Template Literals are not allowed in optionalChain (1:0)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "expression": { + "type": "TaggedTemplateExpression", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "tag": { + "type": "OptionalMemberExpression", + "start": 0, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "object": { + "type": "Identifier", + "start": 0, + "end": 1, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 1 + }, + "identifierName": "a" + }, + "name": "a" + }, + "property": { + "type": "Identifier", + "start": 3, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 4 + }, + "identifierName": "b" + }, + "name": "b" + }, + "computed": false, + "optional": true + }, + "quasi": { + "type": "TemplateLiteral", + "start": 4, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "expressions": [], + "quasis": [ + { + "type": "TemplateElement", + "start": 5, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "value": { + "raw": "foo", + "cooked": "foo" + }, + "tail": true + } + ] + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/partial-application/in-SuperCall/options.json b/packages/babel-parser/test/fixtures/experimental/partial-application/in-SuperCall/options.json index 58192a87fd99..982b7cd1dab5 100644 --- a/packages/babel-parser/test/fixtures/experimental/partial-application/in-SuperCall/options.json +++ b/packages/babel-parser/test/fixtures/experimental/partial-application/in-SuperCall/options.json @@ -1,4 +1,5 @@ { - "plugins": ["partialApplication"], - "throws": "Unexpected argument placeholder (3:16)" -} + "plugins": [ + "partialApplication" + ] +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/partial-application/in-SuperCall/output.json b/packages/babel-parser/test/fixtures/experimental/partial-application/in-SuperCall/output.json new file mode 100644 index 000000000000..14f531a7e147 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/partial-application/in-SuperCall/output.json @@ -0,0 +1,390 @@ +{ + "type": "File", + "start": 0, + "end": 86, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 6, + "column": 1 + } + }, + "errors": [ + "SyntaxError: Unexpected argument placeholder (3:16)", + "SyntaxError: Unexpected argument placeholder (3:19)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 86, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 6, + "column": 1 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ClassDeclaration", + "start": 0, + "end": 86, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 6, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 6, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 9 + }, + "identifierName": "Foo" + }, + "name": "Foo" + }, + "superClass": { + "type": "Identifier", + "start": 18, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 21 + }, + "identifierName": "Bar" + }, + "name": "Bar" + }, + "body": { + "type": "ClassBody", + "start": 22, + "end": 86, + "loc": { + "start": { + "line": 1, + "column": 22 + }, + "end": { + "line": 6, + "column": 1 + } + }, + "body": [ + { + "type": "ClassMethod", + "start": 26, + "end": 84, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 5, + "column": 3 + } + }, + "static": false, + "key": { + "type": "Identifier", + "start": 26, + "end": 37, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 13 + }, + "identifierName": "constructor" + }, + "name": "constructor" + }, + "computed": false, + "kind": "constructor", + "id": null, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "start": 38, + "end": 39, + "loc": { + "start": { + "line": 2, + "column": 14 + }, + "end": { + "line": 2, + "column": 15 + }, + "identifierName": "x" + }, + "name": "x" + } + ], + "body": { + "type": "BlockStatement", + "start": 40, + "end": 84, + "loc": { + "start": { + "line": 2, + "column": 16 + }, + "end": { + "line": 5, + "column": 3 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 46, + "end": 64, + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 22 + } + }, + "expression": { + "type": "CallExpression", + "start": 46, + "end": 63, + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 21 + } + }, + "callee": { + "type": "Super", + "start": 46, + "end": 51, + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 9 + } + } + }, + "arguments": [ + { + "type": "Identifier", + "start": 52, + "end": 53, + "loc": { + "start": { + "line": 3, + "column": 10 + }, + "end": { + "line": 3, + "column": 11 + }, + "identifierName": "x" + }, + "name": "x" + }, + { + "type": "NumericLiteral", + "start": 55, + "end": 56, + "loc": { + "start": { + "line": 3, + "column": 13 + }, + "end": { + "line": 3, + "column": 14 + } + }, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + }, + { + "type": "ArgumentPlaceholder", + "start": 58, + "end": 59, + "loc": { + "start": { + "line": 3, + "column": 16 + }, + "end": { + "line": 3, + "column": 17 + } + } + }, + { + "type": "ArgumentPlaceholder", + "start": 61, + "end": 62, + "loc": { + "start": { + "line": 3, + "column": 19 + }, + "end": { + "line": 3, + "column": 20 + } + } + } + ] + } + }, + { + "type": "ExpressionStatement", + "start": 69, + "end": 80, + "loc": { + "start": { + "line": 4, + "column": 4 + }, + "end": { + "line": 4, + "column": 15 + } + }, + "expression": { + "type": "AssignmentExpression", + "start": 69, + "end": 79, + "loc": { + "start": { + "line": 4, + "column": 4 + }, + "end": { + "line": 4, + "column": 14 + } + }, + "operator": "=", + "left": { + "type": "MemberExpression", + "start": 69, + "end": 75, + "loc": { + "start": { + "line": 4, + "column": 4 + }, + "end": { + "line": 4, + "column": 10 + } + }, + "object": { + "type": "ThisExpression", + "start": 69, + "end": 73, + "loc": { + "start": { + "line": 4, + "column": 4 + }, + "end": { + "line": 4, + "column": 8 + } + } + }, + "property": { + "type": "Identifier", + "start": 74, + "end": 75, + "loc": { + "start": { + "line": 4, + "column": 9 + }, + "end": { + "line": 4, + "column": 10 + }, + "identifierName": "x" + }, + "name": "x" + }, + "computed": false + }, + "right": { + "type": "Identifier", + "start": 78, + "end": 79, + "loc": { + "start": { + "line": 4, + "column": 13 + }, + "end": { + "line": 4, + "column": 14 + }, + "identifierName": "x" + }, + "name": "x" + } + } + } + ], + "directives": [] + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/partial-application/in-new/options.json b/packages/babel-parser/test/fixtures/experimental/partial-application/in-new/options.json index 3b09c84c03eb..982b7cd1dab5 100644 --- a/packages/babel-parser/test/fixtures/experimental/partial-application/in-new/options.json +++ b/packages/babel-parser/test/fixtures/experimental/partial-application/in-new/options.json @@ -1,4 +1,5 @@ { - "plugins": ["partialApplication"], - "throws": "Unexpected argument placeholder (1:11)" -} + "plugins": [ + "partialApplication" + ] +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/partial-application/in-new/output.json b/packages/babel-parser/test/fixtures/experimental/partial-application/in-new/output.json new file mode 100644 index 000000000000..d12380e4820c --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/partial-application/in-new/output.json @@ -0,0 +1,155 @@ +{ + "type": "File", + "start": 0, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "errors": [ + "SyntaxError: Unexpected argument placeholder (1:11)", + "SyntaxError: Unexpected argument placeholder (1:17)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "expression": { + "type": "NewExpression", + "start": 0, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "callee": { + "type": "Identifier", + "start": 4, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 7 + }, + "identifierName": "bar" + }, + "name": "bar" + }, + "arguments": [ + { + "type": "Identifier", + "start": 8, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 9 + }, + "identifierName": "x" + }, + "name": "x" + }, + { + "type": "ArgumentPlaceholder", + "start": 11, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 12 + } + } + }, + { + "type": "NumericLiteral", + "start": 14, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "extra": { + "rawValue": 2, + "raw": "2" + }, + "value": 2 + }, + { + "type": "ArgumentPlaceholder", + "start": 17, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 18 + } + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-bare-style,-head-with-topic-reference-pair/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-bare-style,-head-with-topic-reference-pair/options.json index cc2c16a778e7..abf908b86e3e 100644 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-bare-style,-head-with-topic-reference-pair/options.json +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-bare-style,-head-with-topic-reference-pair/options.json @@ -1,4 +1,10 @@ { - "plugins": [["pipelineOperator", { "proposal": "smart" }]], - "throws": "Pipeline head should not be a comma-separated sequence expression (1:0)" -} + "plugins": [ + [ + "pipelineOperator", + { + "proposal": "smart" + } + ] + ] +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-bare-style,-head-with-topic-reference-pair/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-bare-style,-head-with-topic-reference-pair/output.json new file mode 100644 index 000000000000..b06186702668 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-bare-style,-head-with-topic-reference-pair/output.json @@ -0,0 +1,162 @@ +{ + "type": "File", + "start": 0, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "errors": [ + "SyntaxError: Pipeline head should not be a comma-separated sequence expression (1:0)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "expression": { + "type": "BinaryExpression", + "start": 0, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "left": { + "type": "SequenceExpression", + "start": 1, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "expressions": [ + { + "type": "NumericLiteral", + "start": 1, + "end": 2, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 2 + } + }, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + }, + { + "type": "NumericLiteral", + "start": 4, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "extra": { + "rawValue": 2, + "raw": "2" + }, + "value": 2 + } + ], + "extra": { + "parenthesized": true, + "parenStart": 0 + } + }, + "operator": "|>", + "right": { + "type": "PipelineBareFunction", + "start": 10, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "callee": { + "type": "Identifier", + "start": 10, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 11 + }, + "identifierName": "f" + }, + "name": "f" + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-nested-pipelines,-topic-style-with-arrow-function-with-bare-style,-no-outer-topic-reference/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-nested-pipelines,-topic-style-with-arrow-function-with-bare-style,-no-outer-topic-reference/options.json index d2b32f77521a..17e4e327bbad 100644 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-nested-pipelines,-topic-style-with-arrow-function-with-bare-style,-no-outer-topic-reference/options.json +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-nested-pipelines,-topic-style-with-arrow-function-with-bare-style,-no-outer-topic-reference/options.json @@ -1,4 +1,3 @@ { - "plugins": [["pipelineOperator", { "proposal": "smart" }]], - "throws": "Pipeline is in topic style but does not use topic reference (1:5)" + "plugins": [["pipelineOperator", { "proposal": "smart" }]] } diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-nested-pipelines,-topic-style-with-arrow-function-with-bare-style,-no-outer-topic-reference/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-nested-pipelines,-topic-style-with-arrow-function-with-bare-style,-no-outer-topic-reference/output.json new file mode 100644 index 000000000000..9aceb13325af --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-nested-pipelines,-topic-style-with-arrow-function-with-bare-style,-no-outer-topic-reference/output.json @@ -0,0 +1,207 @@ +{ + "type": "File", + "start": 0, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "errors": [ + "SyntaxError: Pipeline is in topic style but does not use topic reference (1:5)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "expression": { + "type": "BinaryExpression", + "start": 0, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "left": { + "type": "Identifier", + "start": 0, + "end": 1, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 1 + }, + "identifierName": "x" + }, + "name": "x" + }, + "operator": "|>", + "right": { + "type": "PipelineTopicExpression", + "start": 5, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "expression": { + "type": "ArrowFunctionExpression", + "start": 6, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "id": null, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "start": 6, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + }, + "identifierName": "$" + }, + "name": "$" + } + ], + "body": { + "type": "BinaryExpression", + "start": 11, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "left": { + "type": "Identifier", + "start": 11, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 12 + }, + "identifierName": "$" + }, + "name": "$" + }, + "operator": "|>", + "right": { + "type": "PipelineBareFunction", + "start": 16, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "callee": { + "type": "Identifier", + "start": 16, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 17 + }, + "identifierName": "f" + }, + "name": "f" + } + } + }, + "extra": { + "parenthesized": true, + "parenStart": 5 + } + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-nested-pipelines,-topic-style-with-arrow-function-with-topic-style,-no-inner-topic-reference/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-nested-pipelines,-topic-style-with-arrow-function-with-topic-style,-no-inner-topic-reference/options.json index e9eab6b46fe9..17e4e327bbad 100644 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-nested-pipelines,-topic-style-with-arrow-function-with-topic-style,-no-inner-topic-reference/options.json +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-nested-pipelines,-topic-style-with-arrow-function-with-topic-style,-no-inner-topic-reference/options.json @@ -1,4 +1,3 @@ { - "plugins": [["pipelineOperator", { "proposal": "smart" }]], - "throws": "Pipeline is in topic style but does not use topic reference (1:16)" + "plugins": [["pipelineOperator", { "proposal": "smart" }]] } diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-nested-pipelines,-topic-style-with-arrow-function-with-topic-style,-no-inner-topic-reference/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-nested-pipelines,-topic-style-with-arrow-function-with-topic-style,-no-inner-topic-reference/output.json new file mode 100644 index 000000000000..a4b95926f362 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-nested-pipelines,-topic-style-with-arrow-function-with-topic-style,-no-inner-topic-reference/output.json @@ -0,0 +1,241 @@ +{ + "type": "File", + "start": 0, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "errors": [ + "SyntaxError: Pipeline is in topic style but does not use topic reference (1:16)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "expression": { + "type": "BinaryExpression", + "start": 0, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "left": { + "type": "Identifier", + "start": 0, + "end": 1, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 1 + }, + "identifierName": "x" + }, + "name": "x" + }, + "operator": "|>", + "right": { + "type": "PipelineTopicExpression", + "start": 5, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "expression": { + "type": "ArrowFunctionExpression", + "start": 6, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "id": null, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "start": 6, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + }, + "identifierName": "$" + }, + "name": "$" + } + ], + "body": { + "type": "BinaryExpression", + "start": 11, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "left": { + "type": "PipelinePrimaryTopicReference", + "start": 11, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 12 + } + } + }, + "operator": "|>", + "right": { + "type": "PipelineTopicExpression", + "start": 16, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "expression": { + "type": "BinaryExpression", + "start": 16, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "left": { + "type": "Identifier", + "start": 16, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 17 + }, + "identifierName": "$" + }, + "name": "$" + }, + "operator": "+", + "right": { + "type": "NumericLiteral", + "start": 20, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 20 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + } + } + } + }, + "extra": { + "parenthesized": true, + "parenStart": 5 + } + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-nested-pipelines,-topic-style-with-arrow-function-with-topic-style,-no-outer-topic-reference/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-nested-pipelines,-topic-style-with-arrow-function-with-topic-style,-no-outer-topic-reference/options.json index d2b32f77521a..17e4e327bbad 100644 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-nested-pipelines,-topic-style-with-arrow-function-with-topic-style,-no-outer-topic-reference/options.json +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-nested-pipelines,-topic-style-with-arrow-function-with-topic-style,-no-outer-topic-reference/options.json @@ -1,4 +1,3 @@ { - "plugins": [["pipelineOperator", { "proposal": "smart" }]], - "throws": "Pipeline is in topic style but does not use topic reference (1:5)" + "plugins": [["pipelineOperator", { "proposal": "smart" }]] } diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-nested-pipelines,-topic-style-with-arrow-function-with-topic-style,-no-outer-topic-reference/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-nested-pipelines,-topic-style-with-arrow-function-with-topic-style,-no-outer-topic-reference/output.json new file mode 100644 index 000000000000..257c98280e2e --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-nested-pipelines,-topic-style-with-arrow-function-with-topic-style,-no-outer-topic-reference/output.json @@ -0,0 +1,205 @@ +{ + "type": "File", + "start": 0, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "errors": [ + "SyntaxError: Pipeline is in topic style but does not use topic reference (1:5)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "expression": { + "type": "BinaryExpression", + "start": 0, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "left": { + "type": "Identifier", + "start": 0, + "end": 1, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 1 + }, + "identifierName": "x" + }, + "name": "x" + }, + "operator": "|>", + "right": { + "type": "PipelineTopicExpression", + "start": 5, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "expression": { + "type": "ArrowFunctionExpression", + "start": 6, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "id": null, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "start": 6, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + }, + "identifierName": "$" + }, + "name": "$" + } + ], + "body": { + "type": "BinaryExpression", + "start": 11, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "left": { + "type": "Identifier", + "start": 11, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 12 + }, + "identifierName": "$" + }, + "name": "$" + }, + "operator": "|>", + "right": { + "type": "PipelineTopicExpression", + "start": 16, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "expression": { + "type": "PipelinePrimaryTopicReference", + "start": 16, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 17 + } + } + } + } + }, + "extra": { + "parenthesized": true, + "parenStart": 5 + } + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-nested-pipelines,-topic-style-with-inner-topic-style,-no-inner-topic-reference/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-nested-pipelines,-topic-style-with-inner-topic-style,-no-inner-topic-reference/options.json index bdf0547df8f9..17e4e327bbad 100644 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-nested-pipelines,-topic-style-with-inner-topic-style,-no-inner-topic-reference/options.json +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-nested-pipelines,-topic-style-with-inner-topic-style,-no-inner-topic-reference/options.json @@ -1,4 +1,3 @@ { - "plugins": [["pipelineOperator", { "proposal": "smart" }]], - "throws": "Pipeline is in topic style but does not use topic reference (1:11)" + "plugins": [["pipelineOperator", { "proposal": "smart" }]] } diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-nested-pipelines,-topic-style-with-inner-topic-style,-no-inner-topic-reference/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-nested-pipelines,-topic-style-with-inner-topic-style,-no-inner-topic-reference/output.json new file mode 100644 index 000000000000..5644ff01406b --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-nested-pipelines,-topic-style-with-inner-topic-style,-no-inner-topic-reference/output.json @@ -0,0 +1,184 @@ +{ + "type": "File", + "start": 0, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "errors": [ + "SyntaxError: Pipeline is in topic style but does not use topic reference (1:11)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "expression": { + "type": "BinaryExpression", + "start": 0, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "left": { + "type": "Identifier", + "start": 0, + "end": 1, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 1 + }, + "identifierName": "x" + }, + "name": "x" + }, + "operator": "|>", + "right": { + "type": "PipelineTopicExpression", + "start": 5, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "expression": { + "type": "BinaryExpression", + "start": 6, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "left": { + "type": "PipelinePrimaryTopicReference", + "start": 6, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + } + } + }, + "operator": "|>", + "right": { + "type": "PipelineTopicExpression", + "start": 11, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "expression": { + "type": "CallExpression", + "start": 11, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "callee": { + "type": "Identifier", + "start": 11, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 12 + }, + "identifierName": "f" + }, + "name": "f" + }, + "arguments": [] + } + }, + "extra": { + "parenthesized": true, + "parenStart": 5 + } + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-nested-pipelines,-topic-style-with-inner-topic-style,-no-outer-topic-reference/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-nested-pipelines,-topic-style-with-inner-topic-style,-no-outer-topic-reference/options.json index d2b32f77521a..17e4e327bbad 100644 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-nested-pipelines,-topic-style-with-inner-topic-style,-no-outer-topic-reference/options.json +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-nested-pipelines,-topic-style-with-inner-topic-style,-no-outer-topic-reference/options.json @@ -1,4 +1,3 @@ { - "plugins": [["pipelineOperator", { "proposal": "smart" }]], - "throws": "Pipeline is in topic style but does not use topic reference (1:5)" + "plugins": [["pipelineOperator", { "proposal": "smart" }]] } diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-nested-pipelines,-topic-style-with-inner-topic-style,-no-outer-topic-reference/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-nested-pipelines,-topic-style-with-inner-topic-style,-no-outer-topic-reference/output.json new file mode 100644 index 000000000000..f274dbc1ad48 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-nested-pipelines,-topic-style-with-inner-topic-style,-no-outer-topic-reference/output.json @@ -0,0 +1,170 @@ +{ + "type": "File", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "errors": [ + "SyntaxError: Pipeline is in topic style but does not use topic reference (1:5)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "expression": { + "type": "BinaryExpression", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "left": { + "type": "Identifier", + "start": 0, + "end": 1, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 1 + }, + "identifierName": "x" + }, + "name": "x" + }, + "operator": "|>", + "right": { + "type": "PipelineTopicExpression", + "start": 5, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "expression": { + "type": "BinaryExpression", + "start": 6, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "left": { + "type": "Identifier", + "start": 6, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + }, + "identifierName": "$" + }, + "name": "$" + }, + "operator": "|>", + "right": { + "type": "PipelineBareFunction", + "start": 11, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "callee": { + "type": "Identifier", + "start": 11, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 12 + }, + "identifierName": "f" + }, + "name": "f" + } + }, + "extra": { + "parenthesized": true, + "parenStart": 5 + } + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-sequence-style,-body-with-topic-reference-pair-followed-by-bare-style-pipeline-body/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-sequence-style,-body-with-topic-reference-pair-followed-by-bare-style-pipeline-body/options.json index fe3873ecc67f..abf908b86e3e 100644 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-sequence-style,-body-with-topic-reference-pair-followed-by-bare-style-pipeline-body/options.json +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-sequence-style,-body-with-topic-reference-pair-followed-by-bare-style-pipeline-body/options.json @@ -1,4 +1,10 @@ { - "plugins": [["pipelineOperator", { "proposal": "smart" }]], - "throws": "Pipeline body may not be a comma-separated sequence expression (1:6)" -} + "plugins": [ + [ + "pipelineOperator", + { + "proposal": "smart" + } + ] + ] +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-sequence-style,-body-with-topic-reference-pair-followed-by-bare-style-pipeline-body/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-sequence-style,-body-with-topic-reference-pair-followed-by-bare-style-pipeline-body/output.json new file mode 100644 index 000000000000..b0b8ec5955df --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-sequence-style,-body-with-topic-reference-pair-followed-by-bare-style-pipeline-body/output.json @@ -0,0 +1,203 @@ +{ + "type": "File", + "start": 0, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "errors": [ + "SyntaxError: Pipeline body may not be a comma-separated sequence expression (1:6)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "expression": { + "type": "BinaryExpression", + "start": 0, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "left": { + "type": "BinaryExpression", + "start": 0, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "left": { + "type": "NumericLiteral", + "start": 0, + "end": 2, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 2 + } + }, + "extra": { + "rawValue": 10, + "raw": "10" + }, + "value": 10 + }, + "operator": "|>", + "right": { + "type": "PipelineTopicExpression", + "start": 6, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "expression": { + "type": "SequenceExpression", + "start": 7, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "expressions": [ + { + "type": "PipelinePrimaryTopicReference", + "start": 7, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 8 + } + } + }, + { + "type": "PipelinePrimaryTopicReference", + "start": 10, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 11 + } + } + } + ], + "extra": { + "parenthesized": true, + "parenStart": 6 + } + } + } + }, + "operator": "|>", + "right": { + "type": "PipelineBareFunction", + "start": 16, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "callee": { + "type": "Identifier", + "start": 16, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 17 + }, + "identifierName": "h" + }, + "name": "h" + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-sequence-style,-body-with-topic-reference-pair-then-end/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-sequence-style,-body-with-topic-reference-pair-then-end/options.json index fe3873ecc67f..abf908b86e3e 100644 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-sequence-style,-body-with-topic-reference-pair-then-end/options.json +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-sequence-style,-body-with-topic-reference-pair-then-end/options.json @@ -1,4 +1,10 @@ { - "plugins": [["pipelineOperator", { "proposal": "smart" }]], - "throws": "Pipeline body may not be a comma-separated sequence expression (1:6)" -} + "plugins": [ + [ + "pipelineOperator", + { + "proposal": "smart" + } + ] + ] +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-sequence-style,-body-with-topic-reference-pair-then-end/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-sequence-style,-body-with-topic-reference-pair-then-end/output.json new file mode 100644 index 000000000000..89c673d0bc0c --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-sequence-style,-body-with-topic-reference-pair-then-end/output.json @@ -0,0 +1,155 @@ +{ + "type": "File", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "errors": [ + "SyntaxError: Pipeline body may not be a comma-separated sequence expression (1:6)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "expression": { + "type": "BinaryExpression", + "start": 0, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "left": { + "type": "NumericLiteral", + "start": 0, + "end": 2, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 2 + } + }, + "extra": { + "rawValue": 10, + "raw": "10" + }, + "value": 10 + }, + "operator": "|>", + "right": { + "type": "PipelineTopicExpression", + "start": 6, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "expression": { + "type": "SequenceExpression", + "start": 7, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "expressions": [ + { + "type": "PipelinePrimaryTopicReference", + "start": 7, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 8 + } + } + }, + { + "type": "PipelinePrimaryTopicReference", + "start": 10, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 11 + } + } + } + ], + "extra": { + "parenthesized": true, + "parenStart": 6 + } + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-computed,-no-topic-reference/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-computed,-no-topic-reference/options.json index 7a4451381c91..17e4e327bbad 100644 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-computed,-no-topic-reference/options.json +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-computed,-no-topic-reference/options.json @@ -1,4 +1,3 @@ { - "plugins": [["pipelineOperator", { "proposal": "smart" }]], - "throws": "Pipeline is in topic style but does not use topic reference (1:9)" + "plugins": [["pipelineOperator", { "proposal": "smart" }]] } diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-computed,-no-topic-reference/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-computed,-no-topic-reference/output.json new file mode 100644 index 000000000000..feca14ebaf5b --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-computed,-no-topic-reference/output.json @@ -0,0 +1,151 @@ +{ + "type": "File", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "errors": [ + "SyntaxError: Pipeline is in topic style but does not use topic reference (1:9)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "expression": { + "type": "BinaryExpression", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "left": { + "type": "Identifier", + "start": 0, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + }, + "identifierName": "value" + }, + "name": "value" + }, + "operator": "|>", + "right": { + "type": "PipelineTopicExpression", + "start": 9, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "expression": { + "type": "MemberExpression", + "start": 9, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "object": { + "type": "Identifier", + "start": 9, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 10 + }, + "identifierName": "a" + }, + "name": "a" + }, + "property": { + "type": "Identifier", + "start": 11, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 12 + }, + "identifierName": "b" + }, + "name": "b" + }, + "computed": true + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-no-topic-reference,-addition/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-no-topic-reference,-addition/options.json index 7a4451381c91..17e4e327bbad 100644 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-no-topic-reference,-addition/options.json +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-no-topic-reference,-addition/options.json @@ -1,4 +1,3 @@ { - "plugins": [["pipelineOperator", { "proposal": "smart" }]], - "throws": "Pipeline is in topic style but does not use topic reference (1:9)" + "plugins": [["pipelineOperator", { "proposal": "smart" }]] } diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-no-topic-reference,-addition/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-no-topic-reference,-addition/output.json new file mode 100644 index 000000000000..c1399c71afa2 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-no-topic-reference,-addition/output.json @@ -0,0 +1,151 @@ +{ + "type": "File", + "start": 0, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "errors": [ + "SyntaxError: Pipeline is in topic style but does not use topic reference (1:9)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "expression": { + "type": "BinaryExpression", + "start": 0, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "left": { + "type": "Identifier", + "start": 0, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + }, + "identifierName": "value" + }, + "name": "value" + }, + "operator": "|>", + "right": { + "type": "PipelineTopicExpression", + "start": 9, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "expression": { + "type": "BinaryExpression", + "start": 9, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "left": { + "type": "Identifier", + "start": 9, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 10 + }, + "identifierName": "a" + }, + "name": "a" + }, + "operator": "+", + "right": { + "type": "Identifier", + "start": 13, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 14 + }, + "identifierName": "b" + }, + "name": "b" + } + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-no-topic-reference,-class-expression/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-no-topic-reference,-class-expression/options.json index 7a4451381c91..17e4e327bbad 100644 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-no-topic-reference,-class-expression/options.json +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-no-topic-reference,-class-expression/options.json @@ -1,4 +1,3 @@ { - "plugins": [["pipelineOperator", { "proposal": "smart" }]], - "throws": "Pipeline is in topic style but does not use topic reference (1:9)" + "plugins": [["pipelineOperator", { "proposal": "smart" }]] } diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-no-topic-reference,-class-expression/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-no-topic-reference,-class-expression/output.json new file mode 100644 index 000000000000..da79f8d294e8 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-no-topic-reference,-class-expression/output.json @@ -0,0 +1,134 @@ +{ + "type": "File", + "start": 0, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "errors": [ + "SyntaxError: Pipeline is in topic style but does not use topic reference (1:9)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "expression": { + "type": "BinaryExpression", + "start": 0, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "left": { + "type": "Identifier", + "start": 0, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + }, + "identifierName": "value" + }, + "name": "value" + }, + "operator": "|>", + "right": { + "type": "PipelineTopicExpression", + "start": 9, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "expression": { + "type": "ClassExpression", + "start": 9, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "id": null, + "superClass": null, + "body": { + "type": "ClassBody", + "start": 15, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "body": [] + } + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-no-topic-reference,-function-expression/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-no-topic-reference,-function-expression/options.json index 7a4451381c91..17e4e327bbad 100644 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-no-topic-reference,-function-expression/options.json +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-no-topic-reference,-function-expression/options.json @@ -1,4 +1,3 @@ { - "plugins": [["pipelineOperator", { "proposal": "smart" }]], - "throws": "Pipeline is in topic style but does not use topic reference (1:9)" + "plugins": [["pipelineOperator", { "proposal": "smart" }]] } diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-no-topic-reference,-function-expression/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-no-topic-reference,-function-expression/output.json new file mode 100644 index 000000000000..63e37b46042d --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-no-topic-reference,-function-expression/output.json @@ -0,0 +1,172 @@ +{ + "type": "File", + "start": 0, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 33 + } + }, + "errors": [ + "SyntaxError: Pipeline is in topic style but does not use topic reference (1:9)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 33 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 33 + } + }, + "expression": { + "type": "BinaryExpression", + "start": 0, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 33 + } + }, + "left": { + "type": "Identifier", + "start": 0, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + }, + "identifierName": "value" + }, + "name": "value" + }, + "operator": "|>", + "right": { + "type": "PipelineTopicExpression", + "start": 9, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 33 + } + }, + "expression": { + "type": "FunctionExpression", + "start": 9, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 33 + } + }, + "id": null, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "start": 19, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 20 + }, + "identifierName": "x" + }, + "name": "x" + } + ], + "body": { + "type": "BlockStatement", + "start": 22, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 22 + }, + "end": { + "line": 1, + "column": 33 + } + }, + "body": [ + { + "type": "ReturnStatement", + "start": 24, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 24 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "argument": null + } + ], + "directives": [] + } + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-unbound-topic,-do-expression,-do-while-loop,-outer-topic-reference-in-loop-body/input.js b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-unbound-topic,-do-expression,-do-while-loop,-outer-topic-reference-in-loop-body/input.js index c1005576b7d5..8b34c84f521f 100644 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-unbound-topic,-do-expression,-do-while-loop,-outer-topic-reference-in-loop-body/input.js +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-unbound-topic,-do-expression,-do-while-loop,-outer-topic-reference-in-loop-body/input.js @@ -1 +1 @@ -value |> do { do x += # while (x < 50); } +value |> do { do x += #; while (x < 50); } diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-unbound-topic,-do-expression,-do-while-loop,-outer-topic-reference-in-loop-body/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-unbound-topic,-do-expression,-do-while-loop,-outer-topic-reference-in-loop-body/options.json index 3b7a52d71cf7..edb7679c6a74 100644 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-unbound-topic,-do-expression,-do-while-loop,-outer-topic-reference-in-loop-body/options.json +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-unbound-topic,-do-expression,-do-while-loop,-outer-topic-reference-in-loop-body/options.json @@ -1,4 +1,3 @@ { - "plugins": [["pipelineOperator", { "proposal": "smart" }], "doExpressions"], - "throws": "Topic reference was used in a lexical context without topic binding (1:22)" + "plugins": [["pipelineOperator", { "proposal": "smart" }], "doExpressions"] } diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-unbound-topic,-do-expression,-do-while-loop,-outer-topic-reference-in-loop-body/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-unbound-topic,-do-expression,-do-while-loop,-outer-topic-reference-in-loop-body/output.json new file mode 100644 index 000000000000..95125a326a21 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-unbound-topic,-do-expression,-do-while-loop,-outer-topic-reference-in-loop-body/output.json @@ -0,0 +1,266 @@ +{ + "type": "File", + "start": 0, + "end": 42, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 42 + } + }, + "errors": [ + "SyntaxError: Topic reference was used in a lexical context without topic binding (1:22)", + "SyntaxError: Pipeline is in topic style but does not use topic reference (1:9)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 42, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 42 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 42, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 42 + } + }, + "expression": { + "type": "BinaryExpression", + "start": 0, + "end": 42, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 42 + } + }, + "left": { + "type": "Identifier", + "start": 0, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + }, + "identifierName": "value" + }, + "name": "value" + }, + "operator": "|>", + "right": { + "type": "PipelineTopicExpression", + "start": 9, + "end": 42, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 42 + } + }, + "expression": { + "type": "DoExpression", + "start": 9, + "end": 42, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 42 + } + }, + "body": { + "type": "BlockStatement", + "start": 12, + "end": 42, + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 42 + } + }, + "body": [ + { + "type": "DoWhileStatement", + "start": 14, + "end": 40, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 40 + } + }, + "body": { + "type": "ExpressionStatement", + "start": 17, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "expression": { + "type": "AssignmentExpression", + "start": 17, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "operator": "+=", + "left": { + "type": "Identifier", + "start": 17, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 18 + }, + "identifierName": "x" + }, + "name": "x" + }, + "right": { + "type": "PipelinePrimaryTopicReference", + "start": 22, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 22 + }, + "end": { + "line": 1, + "column": 23 + } + } + } + } + }, + "test": { + "type": "BinaryExpression", + "start": 32, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 38 + } + }, + "left": { + "type": "Identifier", + "start": 32, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 33 + }, + "identifierName": "x" + }, + "name": "x" + }, + "operator": "<", + "right": { + "type": "NumericLiteral", + "start": 36, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 36 + }, + "end": { + "line": 1, + "column": 38 + } + }, + "extra": { + "rawValue": 50, + "raw": "50" + }, + "value": 50 + } + } + } + ], + "directives": [] + } + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-unbound-topic,-do-expression,-for-await-of-loop,-outer-topic-reference-in-loop-body/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-unbound-topic,-do-expression,-for-await-of-loop,-outer-topic-reference-in-loop-body/options.json index d117d235099d..680f780892b7 100644 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-unbound-topic,-do-expression,-for-await-of-loop,-outer-topic-reference-in-loop-body/options.json +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-unbound-topic,-do-expression,-for-await-of-loop,-outer-topic-reference-in-loop-body/options.json @@ -3,6 +3,5 @@ ["pipelineOperator", { "proposal": "smart" }], "doExpressions", "asyncGenerators" - ], - "throws": "Topic reference was used in a lexical context without topic binding (2:48)" + ] } diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-unbound-topic,-do-expression,-for-await-of-loop,-outer-topic-reference-in-loop-body/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-unbound-topic,-do-expression,-for-await-of-loop,-outer-topic-reference-in-loop-body/output.json new file mode 100644 index 000000000000..372a871e8b7b --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-unbound-topic,-do-expression,-for-await-of-loop,-outer-topic-reference-in-loop-body/output.json @@ -0,0 +1,302 @@ +{ + "type": "File", + "start": 0, + "end": 77, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "errors": [ + "SyntaxError: Topic reference was used in a lexical context without topic binding (2:48)", + "SyntaxError: Pipeline is in topic style but does not use topic reference (2:11)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 77, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 77, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 15, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 17 + }, + "identifierName": "af" + }, + "name": "af" + }, + "generator": false, + "async": true, + "params": [], + "body": { + "type": "BlockStatement", + "start": 21, + "end": 77, + "loc": { + "start": { + "line": 1, + "column": 21 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 25, + "end": 75, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 52 + } + }, + "expression": { + "type": "BinaryExpression", + "start": 25, + "end": 75, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 52 + } + }, + "left": { + "type": "Identifier", + "start": 25, + "end": 30, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 7 + }, + "identifierName": "value" + }, + "name": "value" + }, + "operator": "|>", + "right": { + "type": "PipelineTopicExpression", + "start": 34, + "end": 75, + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 52 + } + }, + "expression": { + "type": "DoExpression", + "start": 34, + "end": 75, + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 52 + } + }, + "body": { + "type": "BlockStatement", + "start": 37, + "end": 75, + "loc": { + "start": { + "line": 2, + "column": 14 + }, + "end": { + "line": 2, + "column": 52 + } + }, + "body": [ + { + "type": "ForOfStatement", + "start": 39, + "end": 73, + "loc": { + "start": { + "line": 2, + "column": 16 + }, + "end": { + "line": 2, + "column": 50 + } + }, + "await": true, + "left": { + "type": "VariableDeclaration", + "start": 50, + "end": 57, + "loc": { + "start": { + "line": 2, + "column": 27 + }, + "end": { + "line": 2, + "column": 34 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 56, + "end": 57, + "loc": { + "start": { + "line": 2, + "column": 33 + }, + "end": { + "line": 2, + "column": 34 + } + }, + "id": { + "type": "Identifier", + "start": 56, + "end": 57, + "loc": { + "start": { + "line": 2, + "column": 33 + }, + "end": { + "line": 2, + "column": 34 + }, + "identifierName": "e" + }, + "name": "e" + }, + "init": null + } + ], + "kind": "const" + }, + "right": { + "type": "Identifier", + "start": 61, + "end": 69, + "loc": { + "start": { + "line": 2, + "column": 38 + }, + "end": { + "line": 2, + "column": 46 + }, + "identifierName": "sequence" + }, + "name": "sequence" + }, + "body": { + "type": "ExpressionStatement", + "start": 71, + "end": 73, + "loc": { + "start": { + "line": 2, + "column": 48 + }, + "end": { + "line": 2, + "column": 50 + } + }, + "expression": { + "type": "PipelinePrimaryTopicReference", + "start": 71, + "end": 72, + "loc": { + "start": { + "line": 2, + "column": 48 + }, + "end": { + "line": 2, + "column": 49 + } + } + } + } + } + ], + "directives": [] + } + } + } + } + } + ], + "directives": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-unbound-topic,-do-expression,-for-classic-loop,-outer-topic-reference-in-loop-body/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-unbound-topic,-do-expression,-for-classic-loop,-outer-topic-reference-in-loop-body/options.json index 35e8658a93da..edb7679c6a74 100644 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-unbound-topic,-do-expression,-for-classic-loop,-outer-topic-reference-in-loop-body/options.json +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-unbound-topic,-do-expression,-for-classic-loop,-outer-topic-reference-in-loop-body/options.json @@ -1,4 +1,3 @@ { - "plugins": [["pipelineOperator", { "proposal": "smart" }], "doExpressions"], - "throws": "Topic reference was used in a lexical context without topic binding (1:45)" + "plugins": [["pipelineOperator", { "proposal": "smart" }], "doExpressions"] } diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-unbound-topic,-do-expression,-for-classic-loop,-outer-topic-reference-in-loop-body/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-unbound-topic,-do-expression,-for-classic-loop,-outer-topic-reference-in-loop-body/output.json new file mode 100644 index 000000000000..58ca8064b581 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-unbound-topic,-do-expression,-for-classic-loop,-outer-topic-reference-in-loop-body/output.json @@ -0,0 +1,353 @@ +{ + "type": "File", + "start": 0, + "end": 49, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 49 + } + }, + "errors": [ + "SyntaxError: Topic reference was used in a lexical context without topic binding (1:45)", + "SyntaxError: Pipeline is in topic style but does not use topic reference (1:9)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 49, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 49 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 49, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 49 + } + }, + "expression": { + "type": "BinaryExpression", + "start": 0, + "end": 49, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 49 + } + }, + "left": { + "type": "Identifier", + "start": 0, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + }, + "identifierName": "value" + }, + "name": "value" + }, + "operator": "|>", + "right": { + "type": "PipelineTopicExpression", + "start": 9, + "end": 49, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 49 + } + }, + "expression": { + "type": "DoExpression", + "start": 9, + "end": 49, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 49 + } + }, + "body": { + "type": "BlockStatement", + "start": 12, + "end": 49, + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 49 + } + }, + "body": [ + { + "type": "ForStatement", + "start": 14, + "end": 47, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 47 + } + }, + "init": { + "type": "VariableDeclaration", + "start": 19, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 28 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 23, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 23 + }, + "end": { + "line": 1, + "column": 28 + } + }, + "id": { + "type": "Identifier", + "start": 23, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 23 + }, + "end": { + "line": 1, + "column": 24 + }, + "identifierName": "i" + }, + "name": "i" + }, + "init": { + "type": "NumericLiteral", + "start": 27, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 27 + }, + "end": { + "line": 1, + "column": 28 + } + }, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + } + } + ], + "kind": "let" + }, + "test": { + "type": "BinaryExpression", + "start": 30, + "end": 35, + "loc": { + "start": { + "line": 1, + "column": 30 + }, + "end": { + "line": 1, + "column": 35 + } + }, + "left": { + "type": "Identifier", + "start": 30, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 30 + }, + "end": { + "line": 1, + "column": 31 + }, + "identifierName": "i" + }, + "name": "i" + }, + "operator": "<", + "right": { + "type": "Identifier", + "start": 34, + "end": 35, + "loc": { + "start": { + "line": 1, + "column": 34 + }, + "end": { + "line": 1, + "column": 35 + }, + "identifierName": "n" + }, + "name": "n" + } + }, + "update": { + "type": "AssignmentExpression", + "start": 37, + "end": 43, + "loc": { + "start": { + "line": 1, + "column": 37 + }, + "end": { + "line": 1, + "column": 43 + } + }, + "operator": "+=", + "left": { + "type": "Identifier", + "start": 37, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 37 + }, + "end": { + "line": 1, + "column": 38 + }, + "identifierName": "i" + }, + "name": "i" + }, + "right": { + "type": "NumericLiteral", + "start": 42, + "end": 43, + "loc": { + "start": { + "line": 1, + "column": 42 + }, + "end": { + "line": 1, + "column": 43 + } + }, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + } + }, + "body": { + "type": "ExpressionStatement", + "start": 45, + "end": 47, + "loc": { + "start": { + "line": 1, + "column": 45 + }, + "end": { + "line": 1, + "column": 47 + } + }, + "expression": { + "type": "PipelinePrimaryTopicReference", + "start": 45, + "end": 46, + "loc": { + "start": { + "line": 1, + "column": 45 + }, + "end": { + "line": 1, + "column": 46 + } + } + } + } + } + ], + "directives": [] + } + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-unbound-topic,-do-expression,-for-in-loop,-outer-topic-reference-in-loop-body/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-unbound-topic,-do-expression,-for-in-loop,-outer-topic-reference-in-loop-body/options.json index 6e8b4a6f0d95..edb7679c6a74 100644 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-unbound-topic,-do-expression,-for-in-loop,-outer-topic-reference-in-loop-body/options.json +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-unbound-topic,-do-expression,-for-in-loop,-outer-topic-reference-in-loop-body/options.json @@ -1,4 +1,3 @@ { - "plugins": [["pipelineOperator", { "proposal": "smart" }], "doExpressions"], - "throws": "Topic reference was used in a lexical context without topic binding (1:32)" + "plugins": [["pipelineOperator", { "proposal": "smart" }], "doExpressions"] } diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-unbound-topic,-do-expression,-for-in-loop,-outer-topic-reference-in-loop-body/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-unbound-topic,-do-expression,-for-in-loop,-outer-topic-reference-in-loop-body/output.json new file mode 100644 index 000000000000..6f197479125e --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-unbound-topic,-do-expression,-for-in-loop,-outer-topic-reference-in-loop-body/output.json @@ -0,0 +1,214 @@ +{ + "type": "File", + "start": 0, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "errors": [ + "SyntaxError: Topic reference was used in a lexical context without topic binding (1:32)", + "SyntaxError: Pipeline is in topic style but does not use topic reference (1:9)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "expression": { + "type": "BinaryExpression", + "start": 0, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "left": { + "type": "Identifier", + "start": 0, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + }, + "identifierName": "value" + }, + "name": "value" + }, + "operator": "|>", + "right": { + "type": "PipelineTopicExpression", + "start": 9, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "expression": { + "type": "DoExpression", + "start": 9, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "body": { + "type": "BlockStatement", + "start": 12, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "body": [ + { + "type": "ForInStatement", + "start": 14, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 34 + } + }, + "left": { + "type": "Identifier", + "start": 19, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 20 + }, + "identifierName": "e" + }, + "name": "e" + }, + "right": { + "type": "Identifier", + "start": 24, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 24 + }, + "end": { + "line": 1, + "column": 30 + }, + "identifierName": "object" + }, + "name": "object" + }, + "body": { + "type": "ExpressionStatement", + "start": 32, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 34 + } + }, + "expression": { + "type": "PipelinePrimaryTopicReference", + "start": 32, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 33 + } + } + } + } + } + ], + "directives": [] + } + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-unbound-topic,-do-expression,-for-of-loop,-outer-topic-reference-in-loop-body/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-unbound-topic,-do-expression,-for-of-loop,-outer-topic-reference-in-loop-body/options.json index a3707cc91710..edb7679c6a74 100644 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-unbound-topic,-do-expression,-for-of-loop,-outer-topic-reference-in-loop-body/options.json +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-unbound-topic,-do-expression,-for-of-loop,-outer-topic-reference-in-loop-body/options.json @@ -1,4 +1,3 @@ { - "plugins": [["pipelineOperator", { "proposal": "smart" }], "doExpressions"], - "throws": "Topic reference was used in a lexical context without topic binding (1:34)" + "plugins": [["pipelineOperator", { "proposal": "smart" }], "doExpressions"] } diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-unbound-topic,-do-expression,-for-of-loop,-outer-topic-reference-in-loop-body/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-unbound-topic,-do-expression,-for-of-loop,-outer-topic-reference-in-loop-body/output.json new file mode 100644 index 000000000000..b4bdcb7bcd7d --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-unbound-topic,-do-expression,-for-of-loop,-outer-topic-reference-in-loop-body/output.json @@ -0,0 +1,215 @@ +{ + "type": "File", + "start": 0, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 38 + } + }, + "errors": [ + "SyntaxError: Topic reference was used in a lexical context without topic binding (1:34)", + "SyntaxError: Pipeline is in topic style but does not use topic reference (1:9)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 38 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 38 + } + }, + "expression": { + "type": "BinaryExpression", + "start": 0, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 38 + } + }, + "left": { + "type": "Identifier", + "start": 0, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + }, + "identifierName": "value" + }, + "name": "value" + }, + "operator": "|>", + "right": { + "type": "PipelineTopicExpression", + "start": 9, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 38 + } + }, + "expression": { + "type": "DoExpression", + "start": 9, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 38 + } + }, + "body": { + "type": "BlockStatement", + "start": 12, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 38 + } + }, + "body": [ + { + "type": "ForOfStatement", + "start": 14, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "await": false, + "left": { + "type": "Identifier", + "start": 19, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 20 + }, + "identifierName": "e" + }, + "name": "e" + }, + "right": { + "type": "Identifier", + "start": 24, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 24 + }, + "end": { + "line": 1, + "column": 32 + }, + "identifierName": "sequence" + }, + "name": "sequence" + }, + "body": { + "type": "ExpressionStatement", + "start": 34, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 34 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "expression": { + "type": "PipelinePrimaryTopicReference", + "start": 34, + "end": 35, + "loc": { + "start": { + "line": 1, + "column": 34 + }, + "end": { + "line": 1, + "column": 35 + } + } + } + } + } + ], + "directives": [] + } + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-unbound-topic,-do-expression,-try-statement,-outer-topic-reference-in-catch-clause/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-unbound-topic,-do-expression,-try-statement,-outer-topic-reference-in-catch-clause/options.json index 0f40a90d2204..edb7679c6a74 100644 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-unbound-topic,-do-expression,-try-statement,-outer-topic-reference-in-catch-clause/options.json +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-unbound-topic,-do-expression,-try-statement,-outer-topic-reference-in-catch-clause/options.json @@ -1,4 +1,3 @@ { - "plugins": [["pipelineOperator", { "proposal": "smart" }], "doExpressions"], - "throws": "Topic reference was used in a lexical context without topic binding (3:32)" + "plugins": [["pipelineOperator", { "proposal": "smart" }], "doExpressions"] } diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-unbound-topic,-do-expression,-try-statement,-outer-topic-reference-in-catch-clause/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-unbound-topic,-do-expression,-try-statement,-outer-topic-reference-in-catch-clause/output.json new file mode 100644 index 000000000000..f168982f9d91 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-unbound-topic,-do-expression,-try-statement,-outer-topic-reference-in-catch-clause/output.json @@ -0,0 +1,412 @@ +{ + "type": "File", + "start": 0, + "end": 78, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "errors": [ + "SyntaxError: Topic reference was used in a lexical context without topic binding (3:32)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 78, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 78, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "expression": { + "type": "BinaryExpression", + "start": 0, + "end": 78, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "left": { + "type": "Identifier", + "start": 0, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + }, + "identifierName": "value" + }, + "name": "value" + }, + "operator": "|>", + "right": { + "type": "PipelineTopicExpression", + "start": 9, + "end": 78, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "expression": { + "type": "DoExpression", + "start": 9, + "end": 78, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "body": { + "type": "BlockStatement", + "start": 12, + "end": 78, + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "body": [ + { + "type": "TryStatement", + "start": 16, + "end": 76, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 3, + "column": 37 + } + }, + "block": { + "type": "BlockStatement", + "start": 20, + "end": 38, + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 24 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 22, + "end": 36, + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 22 + } + }, + "expression": { + "type": "CallExpression", + "start": 22, + "end": 35, + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 21 + } + }, + "callee": { + "type": "MemberExpression", + "start": 22, + "end": 32, + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 18 + } + }, + "object": { + "type": "Identifier", + "start": 22, + "end": 26, + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 12 + }, + "identifierName": "JSON" + }, + "name": "JSON" + }, + "property": { + "type": "Identifier", + "start": 27, + "end": 32, + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 18 + }, + "identifierName": "parse" + }, + "name": "parse" + }, + "computed": false + }, + "arguments": [ + { + "type": "PipelinePrimaryTopicReference", + "start": 33, + "end": 34, + "loc": { + "start": { + "line": 2, + "column": 19 + }, + "end": { + "line": 2, + "column": 20 + } + } + } + ] + } + } + ], + "directives": [] + }, + "handler": { + "type": "CatchClause", + "start": 41, + "end": 76, + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 3, + "column": 37 + } + }, + "param": { + "type": "Identifier", + "start": 48, + "end": 53, + "loc": { + "start": { + "line": 3, + "column": 9 + }, + "end": { + "line": 3, + "column": 14 + }, + "identifierName": "error" + }, + "name": "error" + }, + "body": { + "type": "BlockStatement", + "start": 55, + "end": 76, + "loc": { + "start": { + "line": 3, + "column": 16 + }, + "end": { + "line": 3, + "column": 37 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 57, + "end": 74, + "loc": { + "start": { + "line": 3, + "column": 18 + }, + "end": { + "line": 3, + "column": 35 + } + }, + "expression": { + "type": "CallExpression", + "start": 57, + "end": 73, + "loc": { + "start": { + "line": 3, + "column": 18 + }, + "end": { + "line": 3, + "column": 34 + } + }, + "callee": { + "type": "MemberExpression", + "start": 57, + "end": 70, + "loc": { + "start": { + "line": 3, + "column": 18 + }, + "end": { + "line": 3, + "column": 31 + } + }, + "object": { + "type": "Identifier", + "start": 57, + "end": 64, + "loc": { + "start": { + "line": 3, + "column": 18 + }, + "end": { + "line": 3, + "column": 25 + }, + "identifierName": "console" + }, + "name": "console" + }, + "property": { + "type": "Identifier", + "start": 65, + "end": 70, + "loc": { + "start": { + "line": 3, + "column": 26 + }, + "end": { + "line": 3, + "column": 31 + }, + "identifierName": "error" + }, + "name": "error" + }, + "computed": false + }, + "arguments": [ + { + "type": "PipelinePrimaryTopicReference", + "start": 71, + "end": 72, + "loc": { + "start": { + "line": 3, + "column": 32 + }, + "end": { + "line": 3, + "column": 33 + } + } + } + ] + } + } + ], + "directives": [] + } + }, + "finalizer": null + } + ], + "directives": [] + } + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-unbound-topic,-do-expression,-while-loop,-outer-topic-reference-in-loop-body/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-unbound-topic,-do-expression,-while-loop,-outer-topic-reference-in-loop-body/options.json index a3707cc91710..edb7679c6a74 100644 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-unbound-topic,-do-expression,-while-loop,-outer-topic-reference-in-loop-body/options.json +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-unbound-topic,-do-expression,-while-loop,-outer-topic-reference-in-loop-body/options.json @@ -1,4 +1,3 @@ { - "plugins": [["pipelineOperator", { "proposal": "smart" }], "doExpressions"], - "throws": "Topic reference was used in a lexical context without topic binding (1:34)" + "plugins": [["pipelineOperator", { "proposal": "smart" }], "doExpressions"] } diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-unbound-topic,-do-expression,-while-loop,-outer-topic-reference-in-loop-body/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-unbound-topic,-do-expression,-while-loop,-outer-topic-reference-in-loop-body/output.json new file mode 100644 index 000000000000..899a06650593 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-unbound-topic,-do-expression,-while-loop,-outer-topic-reference-in-loop-body/output.json @@ -0,0 +1,266 @@ +{ + "type": "File", + "start": 0, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 38 + } + }, + "errors": [ + "SyntaxError: Topic reference was used in a lexical context without topic binding (1:34)", + "SyntaxError: Pipeline is in topic style but does not use topic reference (1:9)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 38 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 38 + } + }, + "expression": { + "type": "BinaryExpression", + "start": 0, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 38 + } + }, + "left": { + "type": "Identifier", + "start": 0, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + }, + "identifierName": "value" + }, + "name": "value" + }, + "operator": "|>", + "right": { + "type": "PipelineTopicExpression", + "start": 9, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 38 + } + }, + "expression": { + "type": "DoExpression", + "start": 9, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 38 + } + }, + "body": { + "type": "BlockStatement", + "start": 12, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 38 + } + }, + "body": [ + { + "type": "WhileStatement", + "start": 14, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "test": { + "type": "BinaryExpression", + "start": 21, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 21 + }, + "end": { + "line": 1, + "column": 27 + } + }, + "left": { + "type": "Identifier", + "start": 21, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 21 + }, + "end": { + "line": 1, + "column": 22 + }, + "identifierName": "x" + }, + "name": "x" + }, + "operator": "<", + "right": { + "type": "NumericLiteral", + "start": 25, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 25 + }, + "end": { + "line": 1, + "column": 27 + } + }, + "extra": { + "rawValue": 50, + "raw": "50" + }, + "value": 50 + } + }, + "body": { + "type": "ExpressionStatement", + "start": 29, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 29 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "expression": { + "type": "AssignmentExpression", + "start": 29, + "end": 35, + "loc": { + "start": { + "line": 1, + "column": 29 + }, + "end": { + "line": 1, + "column": 35 + } + }, + "operator": "+=", + "left": { + "type": "Identifier", + "start": 29, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 29 + }, + "end": { + "line": 1, + "column": 30 + }, + "identifierName": "x" + }, + "name": "x" + }, + "right": { + "type": "PipelinePrimaryTopicReference", + "start": 34, + "end": 35, + "loc": { + "start": { + "line": 1, + "column": 34 + }, + "end": { + "line": 1, + "column": 35 + } + } + } + } + } + } + ], + "directives": [] + } + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-unbound-topic,-do-expression,-with-statement,-outer-topic-reference-in-with-body/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-unbound-topic,-do-expression,-with-statement,-outer-topic-reference-in-with-body/options.json index fee1ffebc044..edb7679c6a74 100644 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-unbound-topic,-do-expression,-with-statement,-outer-topic-reference-in-with-body/options.json +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-unbound-topic,-do-expression,-with-statement,-outer-topic-reference-in-with-body/options.json @@ -1,4 +1,3 @@ { - "plugins": [["pipelineOperator", { "proposal": "smart" }], "doExpressions"], - "throws": "Topic reference was used in a lexical context without topic binding (1:24)" + "plugins": [["pipelineOperator", { "proposal": "smart" }], "doExpressions"] } diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-unbound-topic,-do-expression,-with-statement,-outer-topic-reference-in-with-body/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-unbound-topic,-do-expression,-with-statement,-outer-topic-reference-in-with-body/output.json new file mode 100644 index 000000000000..a185b5983604 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-topic-style,-unbound-topic,-do-expression,-with-statement,-outer-topic-reference-in-with-body/output.json @@ -0,0 +1,196 @@ +{ + "type": "File", + "start": 0, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 28 + } + }, + "errors": [ + "SyntaxError: Topic reference was used in a lexical context without topic binding (1:24)", + "SyntaxError: Pipeline is in topic style but does not use topic reference (1:9)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 28 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 28 + } + }, + "expression": { + "type": "BinaryExpression", + "start": 0, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 28 + } + }, + "left": { + "type": "Identifier", + "start": 0, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + }, + "identifierName": "value" + }, + "name": "value" + }, + "operator": "|>", + "right": { + "type": "PipelineTopicExpression", + "start": 9, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 28 + } + }, + "expression": { + "type": "DoExpression", + "start": 9, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 28 + } + }, + "body": { + "type": "BlockStatement", + "start": 12, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 28 + } + }, + "body": [ + { + "type": "WithStatement", + "start": 14, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "object": { + "type": "ObjectExpression", + "start": 20, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 20 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "properties": [] + }, + "body": { + "type": "ExpressionStatement", + "start": 24, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 24 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "expression": { + "type": "PipelinePrimaryTopicReference", + "start": 24, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 24 + }, + "end": { + "line": 1, + "column": 25 + } + } + } + } + } + ], + "directives": [] + } + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-unbound-topic,-inner-class-in-pipeline-body/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-unbound-topic,-inner-class-in-pipeline-body/options.json index 6401af97db12..17e4e327bbad 100644 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-unbound-topic,-inner-class-in-pipeline-body/options.json +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-unbound-topic,-inner-class-in-pipeline-body/options.json @@ -1,4 +1,3 @@ { - "plugins": [["pipelineOperator", { "proposal": "smart" }]], - "throws": "Topic reference was used in a lexical context without topic binding (1:39)" + "plugins": [["pipelineOperator", { "proposal": "smart" }]] } diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-unbound-topic,-inner-class-in-pipeline-body/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-unbound-topic,-inner-class-in-pipeline-body/output.json new file mode 100644 index 000000000000..64fb49d7358b --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-unbound-topic,-inner-class-in-pipeline-body/output.json @@ -0,0 +1,287 @@ +{ + "type": "File", + "start": 0, + "end": 45, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 45 + } + }, + "errors": [ + "SyntaxError: Topic reference was used in a lexical context without topic binding (1:39)", + "SyntaxError: Pipeline is in topic style but does not use topic reference (1:5)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 45, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 45 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 45, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 45 + } + }, + "expression": { + "type": "BinaryExpression", + "start": 0, + "end": 45, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 45 + } + }, + "left": { + "type": "Identifier", + "start": 0, + "end": 1, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 1 + }, + "identifierName": "x" + }, + "name": "x" + }, + "operator": "|>", + "right": { + "type": "PipelineTopicExpression", + "start": 5, + "end": 45, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 45 + } + }, + "expression": { + "type": "ClassExpression", + "start": 5, + "end": 45, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 45 + } + }, + "id": null, + "superClass": null, + "body": { + "type": "ClassBody", + "start": 11, + "end": 45, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 45 + } + }, + "body": [ + { + "type": "ClassMethod", + "start": 13, + "end": 43, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 43 + } + }, + "static": false, + "key": { + "type": "Identifier", + "start": 13, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 24 + }, + "identifierName": "constructor" + }, + "name": "constructor" + }, + "computed": false, + "kind": "constructor", + "id": null, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 28, + "end": 43, + "loc": { + "start": { + "line": 1, + "column": 28 + }, + "end": { + "line": 1, + "column": 43 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 30, + "end": 41, + "loc": { + "start": { + "line": 1, + "column": 30 + }, + "end": { + "line": 1, + "column": 41 + } + }, + "expression": { + "type": "AssignmentExpression", + "start": 30, + "end": 40, + "loc": { + "start": { + "line": 1, + "column": 30 + }, + "end": { + "line": 1, + "column": 40 + } + }, + "operator": "=", + "left": { + "type": "MemberExpression", + "start": 30, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 30 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "object": { + "type": "ThisExpression", + "start": 30, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 30 + }, + "end": { + "line": 1, + "column": 34 + } + } + }, + "property": { + "type": "Identifier", + "start": 35, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 35 + }, + "end": { + "line": 1, + "column": 36 + }, + "identifierName": "x" + }, + "name": "x" + }, + "computed": false + }, + "right": { + "type": "PipelinePrimaryTopicReference", + "start": 39, + "end": 40, + "loc": { + "start": { + "line": 1, + "column": 39 + }, + "end": { + "line": 1, + "column": 40 + } + } + } + } + } + ], + "directives": [] + } + } + ] + } + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-unbound-topic,-inner-function-in-pipeline-body/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-unbound-topic,-inner-function-in-pipeline-body/options.json index e6731253189f..17e4e327bbad 100644 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-unbound-topic,-inner-function-in-pipeline-body/options.json +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-unbound-topic,-inner-function-in-pipeline-body/options.json @@ -1,4 +1,3 @@ { - "plugins": [["pipelineOperator", { "proposal": "smart" }]], - "throws": "Topic reference was used in a lexical context without topic binding (1:19)" + "plugins": [["pipelineOperator", { "proposal": "smart" }]] } diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-unbound-topic,-inner-function-in-pipeline-body/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-unbound-topic,-inner-function-in-pipeline-body/output.json new file mode 100644 index 000000000000..df16ab34e48b --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-unbound-topic,-inner-function-in-pipeline-body/output.json @@ -0,0 +1,169 @@ +{ + "type": "File", + "start": 0, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "errors": [ + "SyntaxError: Topic reference was used in a lexical context without topic binding (1:19)", + "SyntaxError: Pipeline is in topic style but does not use topic reference (1:5)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "expression": { + "type": "BinaryExpression", + "start": 0, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "left": { + "type": "Identifier", + "start": 0, + "end": 1, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 1 + }, + "identifierName": "x" + }, + "name": "x" + }, + "operator": "|>", + "right": { + "type": "PipelineTopicExpression", + "start": 5, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "expression": { + "type": "FunctionExpression", + "start": 5, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "id": null, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 17, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 19, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "expression": { + "type": "PipelinePrimaryTopicReference", + "start": 19, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 20 + } + } + } + } + ], + "directives": [] + } + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-unbound-topic,-pipeline-head-in-inner-function-in-pipeline-body/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-unbound-topic,-pipeline-head-in-inner-function-in-pipeline-body/options.json index e6731253189f..17e4e327bbad 100644 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-unbound-topic,-pipeline-head-in-inner-function-in-pipeline-body/options.json +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-unbound-topic,-pipeline-head-in-inner-function-in-pipeline-body/options.json @@ -1,4 +1,3 @@ { - "plugins": [["pipelineOperator", { "proposal": "smart" }]], - "throws": "Topic reference was used in a lexical context without topic binding (1:19)" + "plugins": [["pipelineOperator", { "proposal": "smart" }]] } diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-unbound-topic,-pipeline-head-in-inner-function-in-pipeline-body/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-unbound-topic,-pipeline-head-in-inner-function-in-pipeline-body/output.json new file mode 100644 index 000000000000..0023723944ac --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-error,-unbound-topic,-pipeline-head-in-inner-function-in-pipeline-body/output.json @@ -0,0 +1,215 @@ +{ + "type": "File", + "start": 0, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 27 + } + }, + "errors": [ + "SyntaxError: Topic reference was used in a lexical context without topic binding (1:19)", + "SyntaxError: Pipeline is in topic style but does not use topic reference (1:5)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 27 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 27 + } + }, + "expression": { + "type": "BinaryExpression", + "start": 0, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 27 + } + }, + "left": { + "type": "Identifier", + "start": 0, + "end": 1, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 1 + }, + "identifierName": "x" + }, + "name": "x" + }, + "operator": "|>", + "right": { + "type": "PipelineTopicExpression", + "start": 5, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 27 + } + }, + "expression": { + "type": "FunctionExpression", + "start": 5, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 27 + } + }, + "id": null, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 17, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 27 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 19, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 25 + } + }, + "expression": { + "type": "BinaryExpression", + "start": 19, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 25 + } + }, + "left": { + "type": "PipelinePrimaryTopicReference", + "start": 19, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 20 + } + } + }, + "operator": "|>", + "right": { + "type": "PipelineTopicExpression", + "start": 24, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 24 + }, + "end": { + "line": 1, + "column": 25 + } + }, + "expression": { + "type": "PipelinePrimaryTopicReference", + "start": 24, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 24 + }, + "end": { + "line": 1, + "column": 25 + } + } + } + } + } + } + ], + "directives": [] + } + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/1/options.json b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/1/options.json deleted file mode 100644 index fd4da953a419..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/1/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid escape sequence in template (1:2)" -} diff --git a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/1/output.json b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/1/output.json new file mode 100644 index 000000000000..f2d99c02f8f3 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/1/output.json @@ -0,0 +1,91 @@ +{ + "type": "File", + "start": 0, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "errors": [ + "SyntaxError: Invalid escape sequence in template (1:2)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "expression": { + "type": "TemplateLiteral", + "start": 0, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "expressions": [], + "quasis": [ + { + "type": "TemplateElement", + "start": 1, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "value": { + "raw": "\\01", + "cooked": null + }, + "tail": true + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/10/options.json b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/10/options.json deleted file mode 100644 index fd4da953a419..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/10/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid escape sequence in template (1:2)" -} diff --git a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/10/output.json b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/10/output.json new file mode 100644 index 000000000000..84ac3db2b3e5 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/10/output.json @@ -0,0 +1,132 @@ +{ + "type": "File", + "start": 0, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "errors": [ + "SyntaxError: Invalid escape sequence in template (1:2)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "expression": { + "type": "TemplateLiteral", + "start": 0, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "expressions": [ + { + "type": "NumericLiteral", + "start": 6, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + } + ], + "quasis": [ + { + "type": "TemplateElement", + "start": 1, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "value": { + "raw": "\\xg", + "cooked": null + }, + "tail": false + }, + { + "type": "TemplateElement", + "start": 8, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "value": { + "raw": "right", + "cooked": "right" + }, + "tail": true + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/11/options.json b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/11/options.json deleted file mode 100644 index 27524e2b1f49..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/11/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid escape sequence in template (1:10)" -} diff --git a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/11/output.json b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/11/output.json new file mode 100644 index 000000000000..ad1bda1a1fbc --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/11/output.json @@ -0,0 +1,132 @@ +{ + "type": "File", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "errors": [ + "SyntaxError: Invalid escape sequence in template (1:10)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "expression": { + "type": "TemplateLiteral", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "expressions": [ + { + "type": "NumericLiteral", + "start": 7, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + } + ], + "quasis": [ + { + "type": "TemplateElement", + "start": 1, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "value": { + "raw": "left", + "cooked": "left" + }, + "tail": false + }, + { + "type": "TemplateElement", + "start": 9, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "value": { + "raw": "\\xg", + "cooked": null + }, + "tail": true + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/12/options.json b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/12/options.json deleted file mode 100644 index 27524e2b1f49..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/12/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid escape sequence in template (1:10)" -} diff --git a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/12/output.json b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/12/output.json new file mode 100644 index 000000000000..5c60a91a9482 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/12/output.json @@ -0,0 +1,172 @@ +{ + "type": "File", + "start": 0, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "errors": [ + "SyntaxError: Invalid escape sequence in template (1:10)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "expression": { + "type": "TemplateLiteral", + "start": 0, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "expressions": [ + { + "type": "NumericLiteral", + "start": 7, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + }, + { + "type": "NumericLiteral", + "start": 14, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + } + ], + "quasis": [ + { + "type": "TemplateElement", + "start": 1, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "value": { + "raw": "left", + "cooked": "left" + }, + "tail": false + }, + { + "type": "TemplateElement", + "start": 9, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "value": { + "raw": "\\xg", + "cooked": null + }, + "tail": false + }, + { + "type": "TemplateElement", + "start": 16, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "value": { + "raw": "right", + "cooked": "right" + }, + "tail": true + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/13/options.json b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/13/options.json deleted file mode 100644 index fd4da953a419..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/13/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid escape sequence in template (1:2)" -} diff --git a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/13/output.json b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/13/output.json new file mode 100644 index 000000000000..76b845845cea --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/13/output.json @@ -0,0 +1,91 @@ +{ + "type": "File", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "errors": [ + "SyntaxError: Invalid escape sequence in template (1:2)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "expression": { + "type": "TemplateLiteral", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "expressions": [], + "quasis": [ + { + "type": "TemplateElement", + "start": 1, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "value": { + "raw": "\\xAg", + "cooked": null + }, + "tail": true + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/14/options.json b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/14/options.json deleted file mode 100644 index fd4da953a419..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/14/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid escape sequence in template (1:2)" -} diff --git a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/14/output.json b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/14/output.json new file mode 100644 index 000000000000..6dd7932c623a --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/14/output.json @@ -0,0 +1,132 @@ +{ + "type": "File", + "start": 0, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "errors": [ + "SyntaxError: Invalid escape sequence in template (1:2)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "expression": { + "type": "TemplateLiteral", + "start": 0, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "expressions": [ + { + "type": "NumericLiteral", + "start": 7, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + } + ], + "quasis": [ + { + "type": "TemplateElement", + "start": 1, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "value": { + "raw": "\\xAg", + "cooked": null + }, + "tail": false + }, + { + "type": "TemplateElement", + "start": 9, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "value": { + "raw": "right", + "cooked": "right" + }, + "tail": true + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/15/options.json b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/15/options.json deleted file mode 100644 index 27524e2b1f49..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/15/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid escape sequence in template (1:10)" -} diff --git a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/15/output.json b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/15/output.json new file mode 100644 index 000000000000..46ca5191adb2 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/15/output.json @@ -0,0 +1,132 @@ +{ + "type": "File", + "start": 0, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "errors": [ + "SyntaxError: Invalid escape sequence in template (1:10)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "expression": { + "type": "TemplateLiteral", + "start": 0, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "expressions": [ + { + "type": "NumericLiteral", + "start": 7, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + } + ], + "quasis": [ + { + "type": "TemplateElement", + "start": 1, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "value": { + "raw": "left", + "cooked": "left" + }, + "tail": false + }, + { + "type": "TemplateElement", + "start": 9, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "value": { + "raw": "\\xAg", + "cooked": null + }, + "tail": true + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/16/options.json b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/16/options.json deleted file mode 100644 index 27524e2b1f49..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/16/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid escape sequence in template (1:10)" -} diff --git a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/16/output.json b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/16/output.json new file mode 100644 index 000000000000..b050c973d652 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/16/output.json @@ -0,0 +1,172 @@ +{ + "type": "File", + "start": 0, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "errors": [ + "SyntaxError: Invalid escape sequence in template (1:10)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "expression": { + "type": "TemplateLiteral", + "start": 0, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "expressions": [ + { + "type": "NumericLiteral", + "start": 7, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + }, + { + "type": "NumericLiteral", + "start": 15, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + } + ], + "quasis": [ + { + "type": "TemplateElement", + "start": 1, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "value": { + "raw": "left", + "cooked": "left" + }, + "tail": false + }, + { + "type": "TemplateElement", + "start": 9, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "value": { + "raw": "\\xAg", + "cooked": null + }, + "tail": false + }, + { + "type": "TemplateElement", + "start": 17, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "value": { + "raw": "right", + "cooked": "right" + }, + "tail": true + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/17/options.json b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/17/options.json deleted file mode 100644 index fd4da953a419..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/17/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid escape sequence in template (1:2)" -} diff --git a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/17/output.json b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/17/output.json new file mode 100644 index 000000000000..5876338e6e3c --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/17/output.json @@ -0,0 +1,91 @@ +{ + "type": "File", + "start": 0, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "errors": [ + "SyntaxError: Invalid escape sequence in template (1:2)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "expression": { + "type": "TemplateLiteral", + "start": 0, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "expressions": [], + "quasis": [ + { + "type": "TemplateElement", + "start": 1, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "value": { + "raw": "\\u0", + "cooked": null + }, + "tail": true + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/18/options.json b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/18/options.json deleted file mode 100644 index fd4da953a419..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/18/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid escape sequence in template (1:2)" -} diff --git a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/18/output.json b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/18/output.json new file mode 100644 index 000000000000..ab51dae8c74a --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/18/output.json @@ -0,0 +1,132 @@ +{ + "type": "File", + "start": 0, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "errors": [ + "SyntaxError: Invalid escape sequence in template (1:2)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "expression": { + "type": "TemplateLiteral", + "start": 0, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "expressions": [ + { + "type": "NumericLiteral", + "start": 6, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + } + ], + "quasis": [ + { + "type": "TemplateElement", + "start": 1, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "value": { + "raw": "\\u0", + "cooked": null + }, + "tail": false + }, + { + "type": "TemplateElement", + "start": 8, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "value": { + "raw": "right", + "cooked": "right" + }, + "tail": true + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/19/options.json b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/19/options.json deleted file mode 100644 index 27524e2b1f49..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/19/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid escape sequence in template (1:10)" -} diff --git a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/19/output.json b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/19/output.json new file mode 100644 index 000000000000..7e0fe1f7af88 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/19/output.json @@ -0,0 +1,132 @@ +{ + "type": "File", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "errors": [ + "SyntaxError: Invalid escape sequence in template (1:10)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "expression": { + "type": "TemplateLiteral", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "expressions": [ + { + "type": "NumericLiteral", + "start": 7, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + } + ], + "quasis": [ + { + "type": "TemplateElement", + "start": 1, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "value": { + "raw": "left", + "cooked": "left" + }, + "tail": false + }, + { + "type": "TemplateElement", + "start": 9, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "value": { + "raw": "\\u0", + "cooked": null + }, + "tail": true + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/2/options.json b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/2/options.json deleted file mode 100644 index fd4da953a419..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/2/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid escape sequence in template (1:2)" -} diff --git a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/2/output.json b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/2/output.json new file mode 100644 index 000000000000..05034cfa43af --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/2/output.json @@ -0,0 +1,132 @@ +{ + "type": "File", + "start": 0, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "errors": [ + "SyntaxError: Invalid escape sequence in template (1:2)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "expression": { + "type": "TemplateLiteral", + "start": 0, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "expressions": [ + { + "type": "NumericLiteral", + "start": 6, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + } + ], + "quasis": [ + { + "type": "TemplateElement", + "start": 1, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "value": { + "raw": "\\01", + "cooked": null + }, + "tail": false + }, + { + "type": "TemplateElement", + "start": 8, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "value": { + "raw": "right", + "cooked": "right" + }, + "tail": true + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/20/options.json b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/20/options.json deleted file mode 100644 index 27524e2b1f49..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/20/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid escape sequence in template (1:10)" -} diff --git a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/20/output.json b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/20/output.json new file mode 100644 index 000000000000..4daf639555aa --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/20/output.json @@ -0,0 +1,172 @@ +{ + "type": "File", + "start": 0, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "errors": [ + "SyntaxError: Invalid escape sequence in template (1:10)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "expression": { + "type": "TemplateLiteral", + "start": 0, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "expressions": [ + { + "type": "NumericLiteral", + "start": 7, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + }, + { + "type": "NumericLiteral", + "start": 14, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + } + ], + "quasis": [ + { + "type": "TemplateElement", + "start": 1, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "value": { + "raw": "left", + "cooked": "left" + }, + "tail": false + }, + { + "type": "TemplateElement", + "start": 9, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "value": { + "raw": "\\u0", + "cooked": null + }, + "tail": false + }, + { + "type": "TemplateElement", + "start": 16, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "value": { + "raw": "right", + "cooked": "right" + }, + "tail": true + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/21/options.json b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/21/options.json deleted file mode 100644 index fd4da953a419..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/21/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid escape sequence in template (1:2)" -} diff --git a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/21/output.json b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/21/output.json new file mode 100644 index 000000000000..93487dccb244 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/21/output.json @@ -0,0 +1,91 @@ +{ + "type": "File", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "errors": [ + "SyntaxError: Invalid escape sequence in template (1:2)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "expression": { + "type": "TemplateLiteral", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "expressions": [], + "quasis": [ + { + "type": "TemplateElement", + "start": 1, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "value": { + "raw": "\\u0g", + "cooked": null + }, + "tail": true + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/22/options.json b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/22/options.json deleted file mode 100644 index fd4da953a419..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/22/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid escape sequence in template (1:2)" -} diff --git a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/22/output.json b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/22/output.json new file mode 100644 index 000000000000..d90c680f758c --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/22/output.json @@ -0,0 +1,132 @@ +{ + "type": "File", + "start": 0, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "errors": [ + "SyntaxError: Invalid escape sequence in template (1:2)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "expression": { + "type": "TemplateLiteral", + "start": 0, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "expressions": [ + { + "type": "NumericLiteral", + "start": 7, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + } + ], + "quasis": [ + { + "type": "TemplateElement", + "start": 1, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "value": { + "raw": "\\u0g", + "cooked": null + }, + "tail": false + }, + { + "type": "TemplateElement", + "start": 9, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "value": { + "raw": "right", + "cooked": "right" + }, + "tail": true + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/23/options.json b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/23/options.json deleted file mode 100644 index 27524e2b1f49..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/23/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid escape sequence in template (1:10)" -} diff --git a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/23/output.json b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/23/output.json new file mode 100644 index 000000000000..11b9589834ce --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/23/output.json @@ -0,0 +1,132 @@ +{ + "type": "File", + "start": 0, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "errors": [ + "SyntaxError: Invalid escape sequence in template (1:10)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "expression": { + "type": "TemplateLiteral", + "start": 0, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "expressions": [ + { + "type": "NumericLiteral", + "start": 7, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + } + ], + "quasis": [ + { + "type": "TemplateElement", + "start": 1, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "value": { + "raw": "left", + "cooked": "left" + }, + "tail": false + }, + { + "type": "TemplateElement", + "start": 9, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "value": { + "raw": "\\u0g", + "cooked": null + }, + "tail": true + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/24/options.json b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/24/options.json deleted file mode 100644 index 27524e2b1f49..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/24/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid escape sequence in template (1:10)" -} diff --git a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/24/output.json b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/24/output.json new file mode 100644 index 000000000000..aef068ff0dcb --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/24/output.json @@ -0,0 +1,172 @@ +{ + "type": "File", + "start": 0, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "errors": [ + "SyntaxError: Invalid escape sequence in template (1:10)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "expression": { + "type": "TemplateLiteral", + "start": 0, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "expressions": [ + { + "type": "NumericLiteral", + "start": 7, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + }, + { + "type": "NumericLiteral", + "start": 15, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + } + ], + "quasis": [ + { + "type": "TemplateElement", + "start": 1, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "value": { + "raw": "left", + "cooked": "left" + }, + "tail": false + }, + { + "type": "TemplateElement", + "start": 9, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "value": { + "raw": "\\u0g", + "cooked": null + }, + "tail": false + }, + { + "type": "TemplateElement", + "start": 17, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "value": { + "raw": "right", + "cooked": "right" + }, + "tail": true + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/25/options.json b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/25/options.json deleted file mode 100644 index fd4da953a419..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/25/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid escape sequence in template (1:2)" -} diff --git a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/25/output.json b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/25/output.json new file mode 100644 index 000000000000..83c602cde696 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/25/output.json @@ -0,0 +1,91 @@ +{ + "type": "File", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "errors": [ + "SyntaxError: Invalid escape sequence in template (1:2)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "expression": { + "type": "TemplateLiteral", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "expressions": [], + "quasis": [ + { + "type": "TemplateElement", + "start": 1, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "value": { + "raw": "\\u00g", + "cooked": null + }, + "tail": true + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/26/options.json b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/26/options.json deleted file mode 100644 index fd4da953a419..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/26/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid escape sequence in template (1:2)" -} diff --git a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/26/output.json b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/26/output.json new file mode 100644 index 000000000000..b775d5821aeb --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/26/output.json @@ -0,0 +1,132 @@ +{ + "type": "File", + "start": 0, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "errors": [ + "SyntaxError: Invalid escape sequence in template (1:2)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "expression": { + "type": "TemplateLiteral", + "start": 0, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "expressions": [ + { + "type": "NumericLiteral", + "start": 8, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + } + ], + "quasis": [ + { + "type": "TemplateElement", + "start": 1, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "value": { + "raw": "\\u00g", + "cooked": null + }, + "tail": false + }, + { + "type": "TemplateElement", + "start": 10, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "value": { + "raw": "right", + "cooked": "right" + }, + "tail": true + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/27/options.json b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/27/options.json deleted file mode 100644 index 27524e2b1f49..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/27/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid escape sequence in template (1:10)" -} diff --git a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/27/output.json b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/27/output.json new file mode 100644 index 000000000000..7bfe8f7bc378 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/27/output.json @@ -0,0 +1,132 @@ +{ + "type": "File", + "start": 0, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "errors": [ + "SyntaxError: Invalid escape sequence in template (1:10)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "expression": { + "type": "TemplateLiteral", + "start": 0, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "expressions": [ + { + "type": "NumericLiteral", + "start": 7, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + } + ], + "quasis": [ + { + "type": "TemplateElement", + "start": 1, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "value": { + "raw": "left", + "cooked": "left" + }, + "tail": false + }, + { + "type": "TemplateElement", + "start": 9, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "value": { + "raw": "\\u00g", + "cooked": null + }, + "tail": true + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/28/options.json b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/28/options.json deleted file mode 100644 index 27524e2b1f49..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/28/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid escape sequence in template (1:10)" -} diff --git a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/28/output.json b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/28/output.json new file mode 100644 index 000000000000..b148595b1c8c --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/28/output.json @@ -0,0 +1,172 @@ +{ + "type": "File", + "start": 0, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "errors": [ + "SyntaxError: Invalid escape sequence in template (1:10)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "expression": { + "type": "TemplateLiteral", + "start": 0, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "expressions": [ + { + "type": "NumericLiteral", + "start": 7, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + }, + { + "type": "NumericLiteral", + "start": 16, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + } + ], + "quasis": [ + { + "type": "TemplateElement", + "start": 1, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "value": { + "raw": "left", + "cooked": "left" + }, + "tail": false + }, + { + "type": "TemplateElement", + "start": 9, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "value": { + "raw": "\\u00g", + "cooked": null + }, + "tail": false + }, + { + "type": "TemplateElement", + "start": 18, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "value": { + "raw": "right", + "cooked": "right" + }, + "tail": true + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/29/options.json b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/29/options.json deleted file mode 100644 index fd4da953a419..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/29/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid escape sequence in template (1:2)" -} diff --git a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/29/output.json b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/29/output.json new file mode 100644 index 000000000000..b0e6a55f8b9d --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/29/output.json @@ -0,0 +1,91 @@ +{ + "type": "File", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "errors": [ + "SyntaxError: Invalid escape sequence in template (1:2)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "expression": { + "type": "TemplateLiteral", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "expressions": [], + "quasis": [ + { + "type": "TemplateElement", + "start": 1, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "value": { + "raw": "\\u000g", + "cooked": null + }, + "tail": true + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/3/options.json b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/3/options.json deleted file mode 100644 index 27524e2b1f49..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/3/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid escape sequence in template (1:10)" -} diff --git a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/3/output.json b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/3/output.json new file mode 100644 index 000000000000..0d3190ef7f95 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/3/output.json @@ -0,0 +1,132 @@ +{ + "type": "File", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "errors": [ + "SyntaxError: Invalid escape sequence in template (1:10)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "expression": { + "type": "TemplateLiteral", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "expressions": [ + { + "type": "NumericLiteral", + "start": 7, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + } + ], + "quasis": [ + { + "type": "TemplateElement", + "start": 1, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "value": { + "raw": "left", + "cooked": "left" + }, + "tail": false + }, + { + "type": "TemplateElement", + "start": 9, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "value": { + "raw": "\\01", + "cooked": null + }, + "tail": true + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/30/options.json b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/30/options.json deleted file mode 100644 index fd4da953a419..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/30/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid escape sequence in template (1:2)" -} diff --git a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/30/output.json b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/30/output.json new file mode 100644 index 000000000000..a7b5e0bd1bfd --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/30/output.json @@ -0,0 +1,132 @@ +{ + "type": "File", + "start": 0, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "errors": [ + "SyntaxError: Invalid escape sequence in template (1:2)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "expression": { + "type": "TemplateLiteral", + "start": 0, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "expressions": [ + { + "type": "NumericLiteral", + "start": 9, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + } + ], + "quasis": [ + { + "type": "TemplateElement", + "start": 1, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "value": { + "raw": "\\u000g", + "cooked": null + }, + "tail": false + }, + { + "type": "TemplateElement", + "start": 11, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "value": { + "raw": "right", + "cooked": "right" + }, + "tail": true + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/31/options.json b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/31/options.json deleted file mode 100644 index 27524e2b1f49..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/31/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid escape sequence in template (1:10)" -} diff --git a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/31/output.json b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/31/output.json new file mode 100644 index 000000000000..ac3a71555369 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/31/output.json @@ -0,0 +1,132 @@ +{ + "type": "File", + "start": 0, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "errors": [ + "SyntaxError: Invalid escape sequence in template (1:10)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "expression": { + "type": "TemplateLiteral", + "start": 0, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "expressions": [ + { + "type": "NumericLiteral", + "start": 7, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + } + ], + "quasis": [ + { + "type": "TemplateElement", + "start": 1, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "value": { + "raw": "left", + "cooked": "left" + }, + "tail": false + }, + { + "type": "TemplateElement", + "start": 9, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "value": { + "raw": "\\u000g", + "cooked": null + }, + "tail": true + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/32/options.json b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/32/options.json deleted file mode 100644 index 27524e2b1f49..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/32/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid escape sequence in template (1:10)" -} diff --git a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/32/output.json b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/32/output.json new file mode 100644 index 000000000000..5163754673d0 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/32/output.json @@ -0,0 +1,172 @@ +{ + "type": "File", + "start": 0, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 25 + } + }, + "errors": [ + "SyntaxError: Invalid escape sequence in template (1:10)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 25 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 25 + } + }, + "expression": { + "type": "TemplateLiteral", + "start": 0, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 25 + } + }, + "expressions": [ + { + "type": "NumericLiteral", + "start": 7, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + }, + { + "type": "NumericLiteral", + "start": 17, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + } + ], + "quasis": [ + { + "type": "TemplateElement", + "start": 1, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "value": { + "raw": "left", + "cooked": "left" + }, + "tail": false + }, + { + "type": "TemplateElement", + "start": 9, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "value": { + "raw": "\\u000g", + "cooked": null + }, + "tail": false + }, + { + "type": "TemplateElement", + "start": 19, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "value": { + "raw": "right", + "cooked": "right" + }, + "tail": true + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/33/options.json b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/33/options.json deleted file mode 100644 index fd4da953a419..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/33/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid escape sequence in template (1:2)" -} diff --git a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/33/output.json b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/33/output.json new file mode 100644 index 000000000000..2273b5e141cf --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/33/output.json @@ -0,0 +1,91 @@ +{ + "type": "File", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "errors": [ + "SyntaxError: Invalid escape sequence in template (1:2)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "expression": { + "type": "TemplateLiteral", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "expressions": [], + "quasis": [ + { + "type": "TemplateElement", + "start": 1, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "value": { + "raw": "\\u{}", + "cooked": null + }, + "tail": true + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/34/options.json b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/34/options.json deleted file mode 100644 index fd4da953a419..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/34/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid escape sequence in template (1:2)" -} diff --git a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/34/output.json b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/34/output.json new file mode 100644 index 000000000000..fecd37e4b169 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/34/output.json @@ -0,0 +1,132 @@ +{ + "type": "File", + "start": 0, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "errors": [ + "SyntaxError: Invalid escape sequence in template (1:2)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "expression": { + "type": "TemplateLiteral", + "start": 0, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "expressions": [ + { + "type": "NumericLiteral", + "start": 7, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + } + ], + "quasis": [ + { + "type": "TemplateElement", + "start": 1, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "value": { + "raw": "\\u{}", + "cooked": null + }, + "tail": false + }, + { + "type": "TemplateElement", + "start": 9, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "value": { + "raw": "right", + "cooked": "right" + }, + "tail": true + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/35/options.json b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/35/options.json deleted file mode 100644 index 27524e2b1f49..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/35/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid escape sequence in template (1:10)" -} diff --git a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/35/output.json b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/35/output.json new file mode 100644 index 000000000000..83150d31dec6 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/35/output.json @@ -0,0 +1,132 @@ +{ + "type": "File", + "start": 0, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "errors": [ + "SyntaxError: Invalid escape sequence in template (1:10)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "expression": { + "type": "TemplateLiteral", + "start": 0, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "expressions": [ + { + "type": "NumericLiteral", + "start": 7, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + } + ], + "quasis": [ + { + "type": "TemplateElement", + "start": 1, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "value": { + "raw": "left", + "cooked": "left" + }, + "tail": false + }, + { + "type": "TemplateElement", + "start": 9, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "value": { + "raw": "\\u{}", + "cooked": null + }, + "tail": true + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/36/options.json b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/36/options.json deleted file mode 100644 index 27524e2b1f49..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/36/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid escape sequence in template (1:10)" -} diff --git a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/36/output.json b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/36/output.json new file mode 100644 index 000000000000..f5d1e7ad2ec7 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/36/output.json @@ -0,0 +1,172 @@ +{ + "type": "File", + "start": 0, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "errors": [ + "SyntaxError: Invalid escape sequence in template (1:10)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "expression": { + "type": "TemplateLiteral", + "start": 0, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "expressions": [ + { + "type": "NumericLiteral", + "start": 7, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + }, + { + "type": "NumericLiteral", + "start": 15, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + } + ], + "quasis": [ + { + "type": "TemplateElement", + "start": 1, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "value": { + "raw": "left", + "cooked": "left" + }, + "tail": false + }, + { + "type": "TemplateElement", + "start": 9, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "value": { + "raw": "\\u{}", + "cooked": null + }, + "tail": false + }, + { + "type": "TemplateElement", + "start": 17, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "value": { + "raw": "right", + "cooked": "right" + }, + "tail": true + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/37/options.json b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/37/options.json deleted file mode 100644 index fd4da953a419..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/37/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid escape sequence in template (1:2)" -} diff --git a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/37/output.json b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/37/output.json new file mode 100644 index 000000000000..1f51bd46894e --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/37/output.json @@ -0,0 +1,91 @@ +{ + "type": "File", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "errors": [ + "SyntaxError: Invalid escape sequence in template (1:2)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "expression": { + "type": "TemplateLiteral", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "expressions": [], + "quasis": [ + { + "type": "TemplateElement", + "start": 1, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "value": { + "raw": "\\u{-0}", + "cooked": null + }, + "tail": true + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/38/options.json b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/38/options.json deleted file mode 100644 index fd4da953a419..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/38/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid escape sequence in template (1:2)" -} diff --git a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/38/output.json b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/38/output.json new file mode 100644 index 000000000000..2654eccc8ca8 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/38/output.json @@ -0,0 +1,132 @@ +{ + "type": "File", + "start": 0, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "errors": [ + "SyntaxError: Invalid escape sequence in template (1:2)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "expression": { + "type": "TemplateLiteral", + "start": 0, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "expressions": [ + { + "type": "NumericLiteral", + "start": 9, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + } + ], + "quasis": [ + { + "type": "TemplateElement", + "start": 1, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "value": { + "raw": "\\u{-0}", + "cooked": null + }, + "tail": false + }, + { + "type": "TemplateElement", + "start": 11, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "value": { + "raw": "right", + "cooked": "right" + }, + "tail": true + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/39/options.json b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/39/options.json deleted file mode 100644 index 27524e2b1f49..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/39/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid escape sequence in template (1:10)" -} diff --git a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/39/output.json b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/39/output.json new file mode 100644 index 000000000000..b3b301d701b4 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/39/output.json @@ -0,0 +1,132 @@ +{ + "type": "File", + "start": 0, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "errors": [ + "SyntaxError: Invalid escape sequence in template (1:10)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "expression": { + "type": "TemplateLiteral", + "start": 0, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "expressions": [ + { + "type": "NumericLiteral", + "start": 7, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + } + ], + "quasis": [ + { + "type": "TemplateElement", + "start": 1, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "value": { + "raw": "left", + "cooked": "left" + }, + "tail": false + }, + { + "type": "TemplateElement", + "start": 9, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "value": { + "raw": "\\u{-0}", + "cooked": null + }, + "tail": true + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/4/options.json b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/4/options.json deleted file mode 100644 index 27524e2b1f49..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/4/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid escape sequence in template (1:10)" -} diff --git a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/4/output.json b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/4/output.json new file mode 100644 index 000000000000..1d30df1fa402 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/4/output.json @@ -0,0 +1,172 @@ +{ + "type": "File", + "start": 0, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "errors": [ + "SyntaxError: Invalid escape sequence in template (1:10)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "expression": { + "type": "TemplateLiteral", + "start": 0, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "expressions": [ + { + "type": "NumericLiteral", + "start": 7, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + }, + { + "type": "NumericLiteral", + "start": 14, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + } + ], + "quasis": [ + { + "type": "TemplateElement", + "start": 1, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "value": { + "raw": "left", + "cooked": "left" + }, + "tail": false + }, + { + "type": "TemplateElement", + "start": 9, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "value": { + "raw": "\\01", + "cooked": null + }, + "tail": false + }, + { + "type": "TemplateElement", + "start": 16, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "value": { + "raw": "right", + "cooked": "right" + }, + "tail": true + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/40/options.json b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/40/options.json deleted file mode 100644 index 27524e2b1f49..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/40/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid escape sequence in template (1:10)" -} diff --git a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/40/output.json b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/40/output.json new file mode 100644 index 000000000000..124c7c8c9d41 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/40/output.json @@ -0,0 +1,172 @@ +{ + "type": "File", + "start": 0, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 25 + } + }, + "errors": [ + "SyntaxError: Invalid escape sequence in template (1:10)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 25 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 25 + } + }, + "expression": { + "type": "TemplateLiteral", + "start": 0, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 25 + } + }, + "expressions": [ + { + "type": "NumericLiteral", + "start": 7, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + }, + { + "type": "NumericLiteral", + "start": 17, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + } + ], + "quasis": [ + { + "type": "TemplateElement", + "start": 1, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "value": { + "raw": "left", + "cooked": "left" + }, + "tail": false + }, + { + "type": "TemplateElement", + "start": 9, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "value": { + "raw": "\\u{-0}", + "cooked": null + }, + "tail": false + }, + { + "type": "TemplateElement", + "start": 19, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "value": { + "raw": "right", + "cooked": "right" + }, + "tail": true + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/41/options.json b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/41/options.json deleted file mode 100644 index fd4da953a419..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/41/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid escape sequence in template (1:2)" -} diff --git a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/41/output.json b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/41/output.json new file mode 100644 index 000000000000..e22b35045789 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/41/output.json @@ -0,0 +1,91 @@ +{ + "type": "File", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "errors": [ + "SyntaxError: Invalid escape sequence in template (1:2)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "expression": { + "type": "TemplateLiteral", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "expressions": [], + "quasis": [ + { + "type": "TemplateElement", + "start": 1, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "value": { + "raw": "\\u{g}", + "cooked": null + }, + "tail": true + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/42/options.json b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/42/options.json deleted file mode 100644 index fd4da953a419..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/42/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid escape sequence in template (1:2)" -} diff --git a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/42/output.json b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/42/output.json new file mode 100644 index 000000000000..e25755bdf0c5 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/42/output.json @@ -0,0 +1,132 @@ +{ + "type": "File", + "start": 0, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "errors": [ + "SyntaxError: Invalid escape sequence in template (1:2)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "expression": { + "type": "TemplateLiteral", + "start": 0, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "expressions": [ + { + "type": "NumericLiteral", + "start": 8, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + } + ], + "quasis": [ + { + "type": "TemplateElement", + "start": 1, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "value": { + "raw": "\\u{g}", + "cooked": null + }, + "tail": false + }, + { + "type": "TemplateElement", + "start": 10, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "value": { + "raw": "right", + "cooked": "right" + }, + "tail": true + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/43/options.json b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/43/options.json deleted file mode 100644 index 27524e2b1f49..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/43/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid escape sequence in template (1:10)" -} diff --git a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/43/output.json b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/43/output.json new file mode 100644 index 000000000000..3dfeb7480fa4 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/43/output.json @@ -0,0 +1,132 @@ +{ + "type": "File", + "start": 0, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "errors": [ + "SyntaxError: Invalid escape sequence in template (1:10)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "expression": { + "type": "TemplateLiteral", + "start": 0, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "expressions": [ + { + "type": "NumericLiteral", + "start": 7, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + } + ], + "quasis": [ + { + "type": "TemplateElement", + "start": 1, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "value": { + "raw": "left", + "cooked": "left" + }, + "tail": false + }, + { + "type": "TemplateElement", + "start": 9, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "value": { + "raw": "\\u{g}", + "cooked": null + }, + "tail": true + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/44/options.json b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/44/options.json deleted file mode 100644 index 27524e2b1f49..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/44/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid escape sequence in template (1:10)" -} diff --git a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/44/output.json b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/44/output.json new file mode 100644 index 000000000000..8da7d9e51bdf --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/44/output.json @@ -0,0 +1,172 @@ +{ + "type": "File", + "start": 0, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "errors": [ + "SyntaxError: Invalid escape sequence in template (1:10)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "expression": { + "type": "TemplateLiteral", + "start": 0, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "expressions": [ + { + "type": "NumericLiteral", + "start": 7, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + }, + { + "type": "NumericLiteral", + "start": 16, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + } + ], + "quasis": [ + { + "type": "TemplateElement", + "start": 1, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "value": { + "raw": "left", + "cooked": "left" + }, + "tail": false + }, + { + "type": "TemplateElement", + "start": 9, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "value": { + "raw": "\\u{g}", + "cooked": null + }, + "tail": false + }, + { + "type": "TemplateElement", + "start": 18, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "value": { + "raw": "right", + "cooked": "right" + }, + "tail": true + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/45/options.json b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/45/options.json deleted file mode 100644 index fd4da953a419..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/45/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid escape sequence in template (1:2)" -} diff --git a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/45/output.json b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/45/output.json new file mode 100644 index 000000000000..07b00d61949a --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/45/output.json @@ -0,0 +1,91 @@ +{ + "type": "File", + "start": 0, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "errors": [ + "SyntaxError: Invalid escape sequence in template (1:2)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "expression": { + "type": "TemplateLiteral", + "start": 0, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "expressions": [], + "quasis": [ + { + "type": "TemplateElement", + "start": 1, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "value": { + "raw": "\\u{", + "cooked": null + }, + "tail": true + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/46/options.json b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/46/options.json deleted file mode 100644 index fd4da953a419..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/46/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid escape sequence in template (1:2)" -} diff --git a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/46/output.json b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/46/output.json new file mode 100644 index 000000000000..b03d29b7821a --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/46/output.json @@ -0,0 +1,132 @@ +{ + "type": "File", + "start": 0, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "errors": [ + "SyntaxError: Invalid escape sequence in template (1:2)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "expression": { + "type": "TemplateLiteral", + "start": 0, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "expressions": [ + { + "type": "NumericLiteral", + "start": 6, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + } + ], + "quasis": [ + { + "type": "TemplateElement", + "start": 1, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "value": { + "raw": "\\u{", + "cooked": null + }, + "tail": false + }, + { + "type": "TemplateElement", + "start": 8, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "value": { + "raw": "right", + "cooked": "right" + }, + "tail": true + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/47/options.json b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/47/options.json deleted file mode 100644 index 27524e2b1f49..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/47/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid escape sequence in template (1:10)" -} diff --git a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/47/output.json b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/47/output.json new file mode 100644 index 000000000000..dab814bd833d --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/47/output.json @@ -0,0 +1,132 @@ +{ + "type": "File", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "errors": [ + "SyntaxError: Invalid escape sequence in template (1:10)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "expression": { + "type": "TemplateLiteral", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "expressions": [ + { + "type": "NumericLiteral", + "start": 7, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + } + ], + "quasis": [ + { + "type": "TemplateElement", + "start": 1, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "value": { + "raw": "left", + "cooked": "left" + }, + "tail": false + }, + { + "type": "TemplateElement", + "start": 9, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "value": { + "raw": "\\u{", + "cooked": null + }, + "tail": true + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/48/options.json b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/48/options.json deleted file mode 100644 index 27524e2b1f49..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/48/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid escape sequence in template (1:10)" -} diff --git a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/48/output.json b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/48/output.json new file mode 100644 index 000000000000..28b0d47818c9 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/48/output.json @@ -0,0 +1,172 @@ +{ + "type": "File", + "start": 0, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "errors": [ + "SyntaxError: Invalid escape sequence in template (1:10)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "expression": { + "type": "TemplateLiteral", + "start": 0, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "expressions": [ + { + "type": "NumericLiteral", + "start": 7, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + }, + { + "type": "NumericLiteral", + "start": 14, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + } + ], + "quasis": [ + { + "type": "TemplateElement", + "start": 1, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "value": { + "raw": "left", + "cooked": "left" + }, + "tail": false + }, + { + "type": "TemplateElement", + "start": 9, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "value": { + "raw": "\\u{", + "cooked": null + }, + "tail": false + }, + { + "type": "TemplateElement", + "start": 16, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "value": { + "raw": "right", + "cooked": "right" + }, + "tail": true + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/49/options.json b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/49/options.json deleted file mode 100644 index fd4da953a419..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/49/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid escape sequence in template (1:2)" -} diff --git a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/49/output.json b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/49/output.json new file mode 100644 index 000000000000..0c1f9bcd5045 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/49/output.json @@ -0,0 +1,91 @@ +{ + "type": "File", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "errors": [ + "SyntaxError: Invalid escape sequence in template (1:2)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "expression": { + "type": "TemplateLiteral", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "expressions": [], + "quasis": [ + { + "type": "TemplateElement", + "start": 1, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "value": { + "raw": "\\u{\\\\", + "cooked": null + }, + "tail": true + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/5/options.json b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/5/options.json deleted file mode 100644 index fd4da953a419..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/5/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid escape sequence in template (1:2)" -} diff --git a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/5/output.json b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/5/output.json new file mode 100644 index 000000000000..6ce800288f9a --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/5/output.json @@ -0,0 +1,91 @@ +{ + "type": "File", + "start": 0, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "errors": [ + "SyntaxError: Invalid escape sequence in template (1:2)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "expression": { + "type": "TemplateLiteral", + "start": 0, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "expressions": [], + "quasis": [ + { + "type": "TemplateElement", + "start": 1, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "value": { + "raw": "\\1", + "cooked": null + }, + "tail": true + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/50/options.json b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/50/options.json deleted file mode 100644 index fd4da953a419..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/50/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid escape sequence in template (1:2)" -} diff --git a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/50/output.json b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/50/output.json new file mode 100644 index 000000000000..2e283e2f77c8 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/50/output.json @@ -0,0 +1,132 @@ +{ + "type": "File", + "start": 0, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "errors": [ + "SyntaxError: Invalid escape sequence in template (1:2)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "expression": { + "type": "TemplateLiteral", + "start": 0, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "expressions": [ + { + "type": "NumericLiteral", + "start": 8, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + } + ], + "quasis": [ + { + "type": "TemplateElement", + "start": 1, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "value": { + "raw": "\\u{\\\\", + "cooked": null + }, + "tail": false + }, + { + "type": "TemplateElement", + "start": 10, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "value": { + "raw": "right", + "cooked": "right" + }, + "tail": true + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/51/options.json b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/51/options.json deleted file mode 100644 index 27524e2b1f49..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/51/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid escape sequence in template (1:10)" -} diff --git a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/51/output.json b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/51/output.json new file mode 100644 index 000000000000..151b718a43f4 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/51/output.json @@ -0,0 +1,132 @@ +{ + "type": "File", + "start": 0, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "errors": [ + "SyntaxError: Invalid escape sequence in template (1:10)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "expression": { + "type": "TemplateLiteral", + "start": 0, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "expressions": [ + { + "type": "NumericLiteral", + "start": 7, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + } + ], + "quasis": [ + { + "type": "TemplateElement", + "start": 1, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "value": { + "raw": "left", + "cooked": "left" + }, + "tail": false + }, + { + "type": "TemplateElement", + "start": 9, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "value": { + "raw": "\\u{\\\\", + "cooked": null + }, + "tail": true + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/52/options.json b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/52/options.json deleted file mode 100644 index 27524e2b1f49..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/52/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid escape sequence in template (1:10)" -} diff --git a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/52/output.json b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/52/output.json new file mode 100644 index 000000000000..0ca0c69ed03d --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/52/output.json @@ -0,0 +1,172 @@ +{ + "type": "File", + "start": 0, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "errors": [ + "SyntaxError: Invalid escape sequence in template (1:10)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "expression": { + "type": "TemplateLiteral", + "start": 0, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "expressions": [ + { + "type": "NumericLiteral", + "start": 7, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + }, + { + "type": "NumericLiteral", + "start": 16, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + } + ], + "quasis": [ + { + "type": "TemplateElement", + "start": 1, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "value": { + "raw": "left", + "cooked": "left" + }, + "tail": false + }, + { + "type": "TemplateElement", + "start": 9, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "value": { + "raw": "\\u{\\\\", + "cooked": null + }, + "tail": false + }, + { + "type": "TemplateElement", + "start": 18, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "value": { + "raw": "right", + "cooked": "right" + }, + "tail": true + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/53/options.json b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/53/options.json deleted file mode 100644 index fd4da953a419..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/53/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid escape sequence in template (1:2)" -} diff --git a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/53/output.json b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/53/output.json new file mode 100644 index 000000000000..eb1dc9edcf28 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/53/output.json @@ -0,0 +1,91 @@ +{ + "type": "File", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "errors": [ + "SyntaxError: Invalid escape sequence in template (1:2)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "expression": { + "type": "TemplateLiteral", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "expressions": [], + "quasis": [ + { + "type": "TemplateElement", + "start": 1, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "value": { + "raw": "\\u{\\`", + "cooked": null + }, + "tail": true + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/54/options.json b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/54/options.json deleted file mode 100644 index fd4da953a419..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/54/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid escape sequence in template (1:2)" -} diff --git a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/54/output.json b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/54/output.json new file mode 100644 index 000000000000..a0df02ed0394 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/54/output.json @@ -0,0 +1,132 @@ +{ + "type": "File", + "start": 0, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "errors": [ + "SyntaxError: Invalid escape sequence in template (1:2)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "expression": { + "type": "TemplateLiteral", + "start": 0, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "expressions": [ + { + "type": "NumericLiteral", + "start": 8, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + } + ], + "quasis": [ + { + "type": "TemplateElement", + "start": 1, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "value": { + "raw": "\\u{\\`", + "cooked": null + }, + "tail": false + }, + { + "type": "TemplateElement", + "start": 10, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "value": { + "raw": "right", + "cooked": "right" + }, + "tail": true + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/55/options.json b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/55/options.json deleted file mode 100644 index 27524e2b1f49..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/55/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid escape sequence in template (1:10)" -} diff --git a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/55/output.json b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/55/output.json new file mode 100644 index 000000000000..b757f165c1ee --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/55/output.json @@ -0,0 +1,132 @@ +{ + "type": "File", + "start": 0, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "errors": [ + "SyntaxError: Invalid escape sequence in template (1:10)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "expression": { + "type": "TemplateLiteral", + "start": 0, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "expressions": [ + { + "type": "NumericLiteral", + "start": 7, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + } + ], + "quasis": [ + { + "type": "TemplateElement", + "start": 1, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "value": { + "raw": "left", + "cooked": "left" + }, + "tail": false + }, + { + "type": "TemplateElement", + "start": 9, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "value": { + "raw": "\\u{\\`", + "cooked": null + }, + "tail": true + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/56/options.json b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/56/options.json deleted file mode 100644 index 27524e2b1f49..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/56/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid escape sequence in template (1:10)" -} diff --git a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/56/output.json b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/56/output.json new file mode 100644 index 000000000000..8ee240a36baf --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/56/output.json @@ -0,0 +1,172 @@ +{ + "type": "File", + "start": 0, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "errors": [ + "SyntaxError: Invalid escape sequence in template (1:10)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "expression": { + "type": "TemplateLiteral", + "start": 0, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "expressions": [ + { + "type": "NumericLiteral", + "start": 7, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + }, + { + "type": "NumericLiteral", + "start": 16, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + } + ], + "quasis": [ + { + "type": "TemplateElement", + "start": 1, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "value": { + "raw": "left", + "cooked": "left" + }, + "tail": false + }, + { + "type": "TemplateElement", + "start": 9, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "value": { + "raw": "\\u{\\`", + "cooked": null + }, + "tail": false + }, + { + "type": "TemplateElement", + "start": 18, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "value": { + "raw": "right", + "cooked": "right" + }, + "tail": true + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/57/options.json b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/57/options.json deleted file mode 100644 index fd4da953a419..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/57/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid escape sequence in template (1:2)" -} diff --git a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/57/output.json b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/57/output.json new file mode 100644 index 000000000000..1450743b5caa --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/57/output.json @@ -0,0 +1,91 @@ +{ + "type": "File", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "errors": [ + "SyntaxError: Invalid escape sequence in template (1:2)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "expression": { + "type": "TemplateLiteral", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "expressions": [], + "quasis": [ + { + "type": "TemplateElement", + "start": 1, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "value": { + "raw": "\\u{0", + "cooked": null + }, + "tail": true + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/58/options.json b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/58/options.json deleted file mode 100644 index fd4da953a419..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/58/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid escape sequence in template (1:2)" -} diff --git a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/58/output.json b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/58/output.json new file mode 100644 index 000000000000..24b6f69d7f38 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/58/output.json @@ -0,0 +1,132 @@ +{ + "type": "File", + "start": 0, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "errors": [ + "SyntaxError: Invalid escape sequence in template (1:2)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "expression": { + "type": "TemplateLiteral", + "start": 0, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "expressions": [ + { + "type": "NumericLiteral", + "start": 7, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + } + ], + "quasis": [ + { + "type": "TemplateElement", + "start": 1, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "value": { + "raw": "\\u{0", + "cooked": null + }, + "tail": false + }, + { + "type": "TemplateElement", + "start": 9, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "value": { + "raw": "right", + "cooked": "right" + }, + "tail": true + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/59/options.json b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/59/options.json deleted file mode 100644 index 27524e2b1f49..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/59/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid escape sequence in template (1:10)" -} diff --git a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/59/output.json b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/59/output.json new file mode 100644 index 000000000000..26af843c60e5 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/59/output.json @@ -0,0 +1,132 @@ +{ + "type": "File", + "start": 0, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "errors": [ + "SyntaxError: Invalid escape sequence in template (1:10)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "expression": { + "type": "TemplateLiteral", + "start": 0, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "expressions": [ + { + "type": "NumericLiteral", + "start": 7, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + } + ], + "quasis": [ + { + "type": "TemplateElement", + "start": 1, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "value": { + "raw": "left", + "cooked": "left" + }, + "tail": false + }, + { + "type": "TemplateElement", + "start": 9, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "value": { + "raw": "\\u{0", + "cooked": null + }, + "tail": true + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/6/options.json b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/6/options.json deleted file mode 100644 index fd4da953a419..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/6/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid escape sequence in template (1:2)" -} diff --git a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/6/output.json b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/6/output.json new file mode 100644 index 000000000000..cf4eef5577aa --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/6/output.json @@ -0,0 +1,132 @@ +{ + "type": "File", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "errors": [ + "SyntaxError: Invalid escape sequence in template (1:2)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "expression": { + "type": "TemplateLiteral", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "expressions": [ + { + "type": "NumericLiteral", + "start": 5, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + } + ], + "quasis": [ + { + "type": "TemplateElement", + "start": 1, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "value": { + "raw": "\\1", + "cooked": null + }, + "tail": false + }, + { + "type": "TemplateElement", + "start": 7, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "value": { + "raw": "right", + "cooked": "right" + }, + "tail": true + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/60/options.json b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/60/options.json deleted file mode 100644 index 27524e2b1f49..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/60/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid escape sequence in template (1:10)" -} diff --git a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/60/output.json b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/60/output.json new file mode 100644 index 000000000000..ad94447a587d --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/60/output.json @@ -0,0 +1,172 @@ +{ + "type": "File", + "start": 0, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "errors": [ + "SyntaxError: Invalid escape sequence in template (1:10)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "expression": { + "type": "TemplateLiteral", + "start": 0, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "expressions": [ + { + "type": "NumericLiteral", + "start": 7, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + }, + { + "type": "NumericLiteral", + "start": 15, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + } + ], + "quasis": [ + { + "type": "TemplateElement", + "start": 1, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "value": { + "raw": "left", + "cooked": "left" + }, + "tail": false + }, + { + "type": "TemplateElement", + "start": 9, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "value": { + "raw": "\\u{0", + "cooked": null + }, + "tail": false + }, + { + "type": "TemplateElement", + "start": 17, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "value": { + "raw": "right", + "cooked": "right" + }, + "tail": true + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/61/options.json b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/61/options.json deleted file mode 100644 index fd4da953a419..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/61/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid escape sequence in template (1:2)" -} diff --git a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/61/output.json b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/61/output.json new file mode 100644 index 000000000000..c1f7f255feb4 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/61/output.json @@ -0,0 +1,91 @@ +{ + "type": "File", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "errors": [ + "SyntaxError: Invalid escape sequence in template (1:2)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "expression": { + "type": "TemplateLiteral", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "expressions": [], + "quasis": [ + { + "type": "TemplateElement", + "start": 1, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "value": { + "raw": "\\u{\\u{0}", + "cooked": null + }, + "tail": true + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/62/options.json b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/62/options.json deleted file mode 100644 index fd4da953a419..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/62/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid escape sequence in template (1:2)" -} diff --git a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/62/output.json b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/62/output.json new file mode 100644 index 000000000000..5782d9c9baef --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/62/output.json @@ -0,0 +1,132 @@ +{ + "type": "File", + "start": 0, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "errors": [ + "SyntaxError: Invalid escape sequence in template (1:2)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "expression": { + "type": "TemplateLiteral", + "start": 0, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "expressions": [ + { + "type": "NumericLiteral", + "start": 11, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + } + ], + "quasis": [ + { + "type": "TemplateElement", + "start": 1, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "value": { + "raw": "\\u{\\u{0}", + "cooked": null + }, + "tail": false + }, + { + "type": "TemplateElement", + "start": 13, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "value": { + "raw": "right", + "cooked": "right" + }, + "tail": true + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/63/options.json b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/63/options.json deleted file mode 100644 index 27524e2b1f49..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/63/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid escape sequence in template (1:10)" -} diff --git a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/63/output.json b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/63/output.json new file mode 100644 index 000000000000..2c3d41a7a407 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/63/output.json @@ -0,0 +1,132 @@ +{ + "type": "File", + "start": 0, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "errors": [ + "SyntaxError: Invalid escape sequence in template (1:10)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "expression": { + "type": "TemplateLiteral", + "start": 0, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "expressions": [ + { + "type": "NumericLiteral", + "start": 7, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + } + ], + "quasis": [ + { + "type": "TemplateElement", + "start": 1, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "value": { + "raw": "left", + "cooked": "left" + }, + "tail": false + }, + { + "type": "TemplateElement", + "start": 9, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "value": { + "raw": "\\u{\\u{0}", + "cooked": null + }, + "tail": true + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/64/options.json b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/64/options.json deleted file mode 100644 index 27524e2b1f49..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/64/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid escape sequence in template (1:10)" -} diff --git a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/64/output.json b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/64/output.json new file mode 100644 index 000000000000..4dccbdb5cd3d --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/64/output.json @@ -0,0 +1,172 @@ +{ + "type": "File", + "start": 0, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 27 + } + }, + "errors": [ + "SyntaxError: Invalid escape sequence in template (1:10)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 27 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 27 + } + }, + "expression": { + "type": "TemplateLiteral", + "start": 0, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 27 + } + }, + "expressions": [ + { + "type": "NumericLiteral", + "start": 7, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + }, + { + "type": "NumericLiteral", + "start": 19, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + } + ], + "quasis": [ + { + "type": "TemplateElement", + "start": 1, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "value": { + "raw": "left", + "cooked": "left" + }, + "tail": false + }, + { + "type": "TemplateElement", + "start": 9, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "value": { + "raw": "\\u{\\u{0}", + "cooked": null + }, + "tail": false + }, + { + "type": "TemplateElement", + "start": 21, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 21 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "value": { + "raw": "right", + "cooked": "right" + }, + "tail": true + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/65/options.json b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/65/options.json deleted file mode 100644 index fd4da953a419..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/65/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid escape sequence in template (1:2)" -} diff --git a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/65/output.json b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/65/output.json new file mode 100644 index 000000000000..ae5fba46a8cd --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/65/output.json @@ -0,0 +1,91 @@ +{ + "type": "File", + "start": 0, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "errors": [ + "SyntaxError: Invalid escape sequence in template (1:2)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "expression": { + "type": "TemplateLiteral", + "start": 0, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "expressions": [], + "quasis": [ + { + "type": "TemplateElement", + "start": 1, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "value": { + "raw": "\\u{110000}", + "cooked": null + }, + "tail": true + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/66/options.json b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/66/options.json deleted file mode 100644 index fd4da953a419..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/66/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid escape sequence in template (1:2)" -} diff --git a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/66/output.json b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/66/output.json new file mode 100644 index 000000000000..ea93f11c4126 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/66/output.json @@ -0,0 +1,132 @@ +{ + "type": "File", + "start": 0, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "errors": [ + "SyntaxError: Invalid escape sequence in template (1:2)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "expression": { + "type": "TemplateLiteral", + "start": 0, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "expressions": [ + { + "type": "NumericLiteral", + "start": 13, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + } + ], + "quasis": [ + { + "type": "TemplateElement", + "start": 1, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "value": { + "raw": "\\u{110000}", + "cooked": null + }, + "tail": false + }, + { + "type": "TemplateElement", + "start": 15, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "value": { + "raw": "right", + "cooked": "right" + }, + "tail": true + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/67/options.json b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/67/options.json deleted file mode 100644 index 27524e2b1f49..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/67/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid escape sequence in template (1:10)" -} diff --git a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/67/output.json b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/67/output.json new file mode 100644 index 000000000000..a37b45899de0 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/67/output.json @@ -0,0 +1,132 @@ +{ + "type": "File", + "start": 0, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "errors": [ + "SyntaxError: Invalid escape sequence in template (1:10)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "expression": { + "type": "TemplateLiteral", + "start": 0, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "expressions": [ + { + "type": "NumericLiteral", + "start": 7, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + } + ], + "quasis": [ + { + "type": "TemplateElement", + "start": 1, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "value": { + "raw": "left", + "cooked": "left" + }, + "tail": false + }, + { + "type": "TemplateElement", + "start": 9, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "value": { + "raw": "\\u{110000}", + "cooked": null + }, + "tail": true + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/68/options.json b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/68/options.json deleted file mode 100644 index 27524e2b1f49..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/68/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid escape sequence in template (1:10)" -} diff --git a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/68/output.json b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/68/output.json new file mode 100644 index 000000000000..22154057933d --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/68/output.json @@ -0,0 +1,172 @@ +{ + "type": "File", + "start": 0, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "errors": [ + "SyntaxError: Invalid escape sequence in template (1:10)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "expression": { + "type": "TemplateLiteral", + "start": 0, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "expressions": [ + { + "type": "NumericLiteral", + "start": 7, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + }, + { + "type": "NumericLiteral", + "start": 21, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 21 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + } + ], + "quasis": [ + { + "type": "TemplateElement", + "start": 1, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "value": { + "raw": "left", + "cooked": "left" + }, + "tail": false + }, + { + "type": "TemplateElement", + "start": 9, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "value": { + "raw": "\\u{110000}", + "cooked": null + }, + "tail": false + }, + { + "type": "TemplateElement", + "start": 23, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 23 + }, + "end": { + "line": 1, + "column": 28 + } + }, + "value": { + "raw": "right", + "cooked": "right" + }, + "tail": true + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/7/options.json b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/7/options.json deleted file mode 100644 index 27524e2b1f49..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/7/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid escape sequence in template (1:10)" -} diff --git a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/7/output.json b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/7/output.json new file mode 100644 index 000000000000..ce27b82a7d1e --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/7/output.json @@ -0,0 +1,132 @@ +{ + "type": "File", + "start": 0, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "errors": [ + "SyntaxError: Invalid escape sequence in template (1:10)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "expression": { + "type": "TemplateLiteral", + "start": 0, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "expressions": [ + { + "type": "NumericLiteral", + "start": 7, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + } + ], + "quasis": [ + { + "type": "TemplateElement", + "start": 1, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "value": { + "raw": "left", + "cooked": "left" + }, + "tail": false + }, + { + "type": "TemplateElement", + "start": 9, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "value": { + "raw": "\\1", + "cooked": null + }, + "tail": true + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/8/options.json b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/8/options.json deleted file mode 100644 index 27524e2b1f49..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/8/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid escape sequence in template (1:10)" -} diff --git a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/8/output.json b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/8/output.json new file mode 100644 index 000000000000..81d9e807fc24 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/8/output.json @@ -0,0 +1,172 @@ +{ + "type": "File", + "start": 0, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "errors": [ + "SyntaxError: Invalid escape sequence in template (1:10)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "expression": { + "type": "TemplateLiteral", + "start": 0, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "expressions": [ + { + "type": "NumericLiteral", + "start": 7, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + }, + { + "type": "NumericLiteral", + "start": 13, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + } + ], + "quasis": [ + { + "type": "TemplateElement", + "start": 1, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "value": { + "raw": "left", + "cooked": "left" + }, + "tail": false + }, + { + "type": "TemplateElement", + "start": 9, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "value": { + "raw": "\\1", + "cooked": null + }, + "tail": false + }, + { + "type": "TemplateElement", + "start": 15, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "value": { + "raw": "right", + "cooked": "right" + }, + "tail": true + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/9/options.json b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/9/options.json deleted file mode 100644 index fd4da953a419..000000000000 --- a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/9/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid escape sequence in template (1:2)" -} diff --git a/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/9/output.json b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/9/output.json new file mode 100644 index 000000000000..67d2c1d0b2d0 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/template-literal-invalid-escapes-untagged/9/output.json @@ -0,0 +1,91 @@ +{ + "type": "File", + "start": 0, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "errors": [ + "SyntaxError: Invalid escape sequence in template (1:2)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "expression": { + "type": "TemplateLiteral", + "start": 0, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "expressions": [], + "quasis": [ + { + "type": "TemplateElement", + "start": 1, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "value": { + "raw": "\\xg", + "cooked": null + }, + "tail": true + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/top-level-await/export-default/input.js b/packages/babel-parser/test/fixtures/experimental/top-level-await/export-default/input.js new file mode 100644 index 000000000000..fd1dbe08b03f --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/top-level-await/export-default/input.js @@ -0,0 +1 @@ +export default await 0; \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/top-level-await/export-default/options.json b/packages/babel-parser/test/fixtures/experimental/top-level-await/export-default/options.json new file mode 100644 index 000000000000..4d7a9975be5a --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/top-level-await/export-default/options.json @@ -0,0 +1,4 @@ +{ + "plugins": ["topLevelAwait"], + "sourceType": "module" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/top-level-await/export-default/output.json b/packages/babel-parser/test/fixtures/experimental/top-level-await/export-default/output.json new file mode 100644 index 000000000000..81e260bd12b2 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/top-level-await/export-default/output.json @@ -0,0 +1,85 @@ +{ + "type": "File", + "start": 0, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExportDefaultDeclaration", + "start": 0, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "declaration": { + "type": "AwaitExpression", + "start": 15, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "argument": { + "type": "NumericLiteral", + "start": 21, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 21 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/top-level-await/for-await-module/input.js b/packages/babel-parser/test/fixtures/experimental/top-level-await/for-await-module/input.js new file mode 100644 index 000000000000..ac76014a6f83 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/top-level-await/for-await-module/input.js @@ -0,0 +1 @@ +for await (const a of b); \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/top-level-await/for-await-module/options.json b/packages/babel-parser/test/fixtures/experimental/top-level-await/for-await-module/options.json new file mode 100644 index 000000000000..aadc3411ae9b --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/top-level-await/for-await-module/options.json @@ -0,0 +1,4 @@ +{ + "plugins": ["topLevelAwait"], + "sourceType": "module" +} diff --git a/packages/babel-parser/test/fixtures/experimental/top-level-await/for-await-module/output.json b/packages/babel-parser/test/fixtures/experimental/top-level-await/for-await-module/output.json new file mode 100644 index 000000000000..42be5c156ae8 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/top-level-await/for-await-module/output.json @@ -0,0 +1,134 @@ +{ + "type": "File", + "start": 0, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 25 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 25 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ForOfStatement", + "start": 0, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 25 + } + }, + "await": true, + "left": { + "type": "VariableDeclaration", + "start": 11, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 17, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "id": { + "type": "Identifier", + "start": 17, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 18 + }, + "identifierName": "a" + }, + "name": "a" + }, + "init": null + } + ], + "kind": "const" + }, + "right": { + "type": "Identifier", + "start": 22, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 22 + }, + "end": { + "line": 1, + "column": 23 + }, + "identifierName": "b" + }, + "name": "b" + }, + "body": { + "type": "EmptyStatement", + "start": 24, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 24 + }, + "end": { + "line": 1, + "column": 25 + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/top-level-await/for-await-script/input.js b/packages/babel-parser/test/fixtures/experimental/top-level-await/for-await-script/input.js new file mode 100644 index 000000000000..ac76014a6f83 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/top-level-await/for-await-script/input.js @@ -0,0 +1 @@ +for await (const a of b); \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/top-level-await/for-await-script/options.json b/packages/babel-parser/test/fixtures/experimental/top-level-await/for-await-script/options.json new file mode 100644 index 000000000000..ad8783d13faa --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/top-level-await/for-await-script/options.json @@ -0,0 +1,5 @@ +{ + "plugins": ["topLevelAwait"], + "sourceType": "script", + "throws": "Unexpected token, expected \"(\" (1:4)" +} diff --git a/packages/babel-parser/test/fixtures/experimental/top-level-await/inside-arrow/input.js b/packages/babel-parser/test/fixtures/experimental/top-level-await/inside-arrow/input.js new file mode 100644 index 000000000000..bde15d37c8ca --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/top-level-await/inside-arrow/input.js @@ -0,0 +1 @@ +() => await 0; diff --git a/packages/babel-parser/test/fixtures/experimental/top-level-await/inside-arrow/options.json b/packages/babel-parser/test/fixtures/experimental/top-level-await/inside-arrow/options.json new file mode 100644 index 000000000000..64cfc06e5014 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/top-level-await/inside-arrow/options.json @@ -0,0 +1,6 @@ +{ + "plugins": ["topLevelAwait"], + "sourceType": "module", + "errorRecovery": false, + "throws": "Can not use keyword 'await' outside an async function (1:6)" +} diff --git a/packages/babel-parser/test/fixtures/experimental/top-level-await/inside-block/input.js b/packages/babel-parser/test/fixtures/experimental/top-level-await/inside-block/input.js new file mode 100644 index 000000000000..f264b0344b3b --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/top-level-await/inside-block/input.js @@ -0,0 +1,3 @@ +if (true) { + await 0; +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/top-level-await/inside-block/options.json b/packages/babel-parser/test/fixtures/experimental/top-level-await/inside-block/options.json new file mode 100644 index 000000000000..aadc3411ae9b --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/top-level-await/inside-block/options.json @@ -0,0 +1,4 @@ +{ + "plugins": ["topLevelAwait"], + "sourceType": "module" +} diff --git a/packages/babel-parser/test/fixtures/experimental/top-level-await/inside-block/output.json b/packages/babel-parser/test/fixtures/experimental/top-level-await/inside-block/output.json new file mode 100644 index 000000000000..b70dffe352c1 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/top-level-await/inside-block/output.json @@ -0,0 +1,135 @@ +{ + "type": "File", + "start": 0, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "IfStatement", + "start": 0, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "test": { + "type": "BooleanLiteral", + "start": 4, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "value": true + }, + "consequent": { + "type": "BlockStatement", + "start": 10, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 14, + "end": 22, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 10 + } + }, + "expression": { + "type": "AwaitExpression", + "start": 14, + "end": 21, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 9 + } + }, + "argument": { + "type": "NumericLiteral", + "start": 20, + "end": 21, + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 9 + } + }, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + } + } + } + ], + "directives": [] + }, + "alternate": null + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/top-level-await/inside-function/input.js b/packages/babel-parser/test/fixtures/experimental/top-level-await/inside-function/input.js new file mode 100644 index 000000000000..ced447b77235 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/top-level-await/inside-function/input.js @@ -0,0 +1,3 @@ +function fn() { + await 0; +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/top-level-await/inside-function/options.json b/packages/babel-parser/test/fixtures/experimental/top-level-await/inside-function/options.json new file mode 100644 index 000000000000..8eade50d15b5 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/top-level-await/inside-function/options.json @@ -0,0 +1,6 @@ +{ + "plugins": ["topLevelAwait"], + "sourceType": "module", + "errorRecovery": false, + "throws": "Can not use keyword 'await' outside an async function (2:2)" +} diff --git a/packages/babel-parser/test/fixtures/experimental/top-level-await/top-level-module/input.js b/packages/babel-parser/test/fixtures/experimental/top-level-await/top-level-module/input.js new file mode 100644 index 000000000000..d8ddd6c0ad0b --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/top-level-await/top-level-module/input.js @@ -0,0 +1 @@ +await 0; \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/top-level-await/top-level-module/options.json b/packages/babel-parser/test/fixtures/experimental/top-level-await/top-level-module/options.json new file mode 100644 index 000000000000..aadc3411ae9b --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/top-level-await/top-level-module/options.json @@ -0,0 +1,4 @@ +{ + "plugins": ["topLevelAwait"], + "sourceType": "module" +} diff --git a/packages/babel-parser/test/fixtures/experimental/top-level-await/top-level-module/output.json b/packages/babel-parser/test/fixtures/experimental/top-level-await/top-level-module/output.json new file mode 100644 index 000000000000..02ef8ffabf64 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/top-level-await/top-level-module/output.json @@ -0,0 +1,85 @@ +{ + "type": "File", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "expression": { + "type": "AwaitExpression", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "argument": { + "type": "NumericLiteral", + "start": 6, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/top-level-await/top-level-script/input.js b/packages/babel-parser/test/fixtures/experimental/top-level-await/top-level-script/input.js new file mode 100644 index 000000000000..d8ddd6c0ad0b --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/top-level-await/top-level-script/input.js @@ -0,0 +1 @@ +await 0; \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/top-level-await/top-level-script/options.json b/packages/babel-parser/test/fixtures/experimental/top-level-await/top-level-script/options.json new file mode 100644 index 000000000000..c9dc6113fea3 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/top-level-await/top-level-script/options.json @@ -0,0 +1,5 @@ +{ + "plugins": ["topLevelAwait"], + "sourceType": "script", + "throws": "Unexpected token, expected \";\" (1:6)" +} diff --git a/packages/babel-parser/test/fixtures/experimental/top-level-await/unambiguous-ambiguous-allowAwaitOutsideFunction/input.js b/packages/babel-parser/test/fixtures/experimental/top-level-await/unambiguous-ambiguous-allowAwaitOutsideFunction/input.js new file mode 100644 index 000000000000..1fa05e429c67 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/top-level-await/unambiguous-ambiguous-allowAwaitOutsideFunction/input.js @@ -0,0 +1,7 @@ +await 0 + +await + 0 +await - 0 +await ( 0 ) +await [ 0 ] +await / 0 /u diff --git a/packages/babel-parser/test/fixtures/experimental/top-level-await/unambiguous-ambiguous-allowAwaitOutsideFunction/options.json b/packages/babel-parser/test/fixtures/experimental/top-level-await/unambiguous-ambiguous-allowAwaitOutsideFunction/options.json new file mode 100644 index 000000000000..aceca10c3d74 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/top-level-await/unambiguous-ambiguous-allowAwaitOutsideFunction/options.json @@ -0,0 +1,5 @@ +{ + "plugins": ["topLevelAwait"], + "sourceType": "unambiguous", + "allowAwaitOutsideFunction": true +} diff --git a/packages/babel-parser/test/fixtures/experimental/top-level-await/unambiguous-ambiguous-allowAwaitOutsideFunction/output.json b/packages/babel-parser/test/fixtures/experimental/top-level-await/unambiguous-ambiguous-allowAwaitOutsideFunction/output.json new file mode 100644 index 000000000000..76e30779fc90 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/top-level-await/unambiguous-ambiguous-allowAwaitOutsideFunction/output.json @@ -0,0 +1,388 @@ +{ + "type": "File", + "start": 0, + "end": 65, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 7, + "column": 12 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 65, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 7, + "column": 12 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "expression": { + "type": "AwaitExpression", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "argument": { + "type": "NumericLiteral", + "start": 6, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + } + } + }, + { + "type": "ExpressionStatement", + "start": 9, + "end": 18, + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 9 + } + }, + "expression": { + "type": "AwaitExpression", + "start": 9, + "end": 18, + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 9 + } + }, + "argument": { + "type": "UnaryExpression", + "start": 15, + "end": 18, + "loc": { + "start": { + "line": 3, + "column": 6 + }, + "end": { + "line": 3, + "column": 9 + } + }, + "operator": "+", + "prefix": true, + "argument": { + "type": "NumericLiteral", + "start": 17, + "end": 18, + "loc": { + "start": { + "line": 3, + "column": 8 + }, + "end": { + "line": 3, + "column": 9 + } + }, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + } + } + } + }, + { + "type": "ExpressionStatement", + "start": 19, + "end": 28, + "loc": { + "start": { + "line": 4, + "column": 0 + }, + "end": { + "line": 4, + "column": 9 + } + }, + "expression": { + "type": "AwaitExpression", + "start": 19, + "end": 28, + "loc": { + "start": { + "line": 4, + "column": 0 + }, + "end": { + "line": 4, + "column": 9 + } + }, + "argument": { + "type": "UnaryExpression", + "start": 25, + "end": 28, + "loc": { + "start": { + "line": 4, + "column": 6 + }, + "end": { + "line": 4, + "column": 9 + } + }, + "operator": "-", + "prefix": true, + "argument": { + "type": "NumericLiteral", + "start": 27, + "end": 28, + "loc": { + "start": { + "line": 4, + "column": 8 + }, + "end": { + "line": 4, + "column": 9 + } + }, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + } + } + } + }, + { + "type": "ExpressionStatement", + "start": 29, + "end": 40, + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 5, + "column": 11 + } + }, + "expression": { + "type": "AwaitExpression", + "start": 29, + "end": 40, + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 5, + "column": 11 + } + }, + "argument": { + "type": "NumericLiteral", + "start": 37, + "end": 38, + "loc": { + "start": { + "line": 5, + "column": 8 + }, + "end": { + "line": 5, + "column": 9 + } + }, + "extra": { + "rawValue": 0, + "raw": "0", + "parenthesized": true, + "parenStart": 35 + }, + "value": 0 + } + } + }, + { + "type": "ExpressionStatement", + "start": 41, + "end": 52, + "loc": { + "start": { + "line": 6, + "column": 0 + }, + "end": { + "line": 6, + "column": 11 + } + }, + "expression": { + "type": "AwaitExpression", + "start": 41, + "end": 52, + "loc": { + "start": { + "line": 6, + "column": 0 + }, + "end": { + "line": 6, + "column": 11 + } + }, + "argument": { + "type": "ArrayExpression", + "start": 47, + "end": 52, + "loc": { + "start": { + "line": 6, + "column": 6 + }, + "end": { + "line": 6, + "column": 11 + } + }, + "elements": [ + { + "type": "NumericLiteral", + "start": 49, + "end": 50, + "loc": { + "start": { + "line": 6, + "column": 8 + }, + "end": { + "line": 6, + "column": 9 + } + }, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + } + ] + } + } + }, + { + "type": "ExpressionStatement", + "start": 53, + "end": 65, + "loc": { + "start": { + "line": 7, + "column": 0 + }, + "end": { + "line": 7, + "column": 12 + } + }, + "expression": { + "type": "AwaitExpression", + "start": 53, + "end": 65, + "loc": { + "start": { + "line": 7, + "column": 0 + }, + "end": { + "line": 7, + "column": 12 + } + }, + "argument": { + "type": "RegExpLiteral", + "start": 59, + "end": 65, + "loc": { + "start": { + "line": 7, + "column": 6 + }, + "end": { + "line": 7, + "column": 12 + } + }, + "extra": { + "raw": "/ 0 /u" + }, + "pattern": " 0 ", + "flags": "u" + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/top-level-await/unambiguous-ambiguous-modulo/input.js b/packages/babel-parser/test/fixtures/experimental/top-level-await/unambiguous-ambiguous-modulo/input.js new file mode 100644 index 000000000000..735a0162b362 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/top-level-await/unambiguous-ambiguous-modulo/input.js @@ -0,0 +1 @@ +await %x(0) \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/top-level-await/unambiguous-ambiguous-modulo/options.json b/packages/babel-parser/test/fixtures/experimental/top-level-await/unambiguous-ambiguous-modulo/options.json new file mode 100644 index 000000000000..2503b82adf74 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/top-level-await/unambiguous-ambiguous-modulo/options.json @@ -0,0 +1,4 @@ +{ + "plugins": ["topLevelAwait"], + "sourceType": "unambiguous" +} diff --git a/packages/babel-parser/test/fixtures/experimental/top-level-await/unambiguous-ambiguous-modulo/output.json b/packages/babel-parser/test/fixtures/experimental/top-level-await/unambiguous-ambiguous-modulo/output.json new file mode 100644 index 000000000000..5805e3195560 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/top-level-await/unambiguous-ambiguous-modulo/output.json @@ -0,0 +1,137 @@ +{ + "type": "File", + "start": 0, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "expression": { + "type": "BinaryExpression", + "start": 0, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "left": { + "type": "Identifier", + "start": 0, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + }, + "identifierName": "await" + }, + "name": "await" + }, + "operator": "%", + "right": { + "type": "CallExpression", + "start": 7, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "callee": { + "type": "Identifier", + "start": 7, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 8 + }, + "identifierName": "x" + }, + "name": "x" + }, + "arguments": [ + { + "type": "NumericLiteral", + "start": 9, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + } + ] + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/top-level-await/unambiguous-ambiguous-script/input.js b/packages/babel-parser/test/fixtures/experimental/top-level-await/unambiguous-ambiguous-script/input.js new file mode 100644 index 000000000000..9fac4af0f0aa --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/top-level-await/unambiguous-ambiguous-script/input.js @@ -0,0 +1,8 @@ +await +0 + +await + 0 +await - 0 +await ( 0 ) +await [ 0 ] +await / 0 /u diff --git a/packages/babel-parser/test/fixtures/experimental/top-level-await/unambiguous-ambiguous-script/options.json b/packages/babel-parser/test/fixtures/experimental/top-level-await/unambiguous-ambiguous-script/options.json new file mode 100644 index 000000000000..2503b82adf74 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/top-level-await/unambiguous-ambiguous-script/options.json @@ -0,0 +1,4 @@ +{ + "plugins": ["topLevelAwait"], + "sourceType": "unambiguous" +} diff --git a/packages/babel-parser/test/fixtures/experimental/top-level-await/unambiguous-ambiguous-script/output.json b/packages/babel-parser/test/fixtures/experimental/top-level-await/unambiguous-ambiguous-script/output.json new file mode 100644 index 000000000000..76a211cbb464 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/top-level-await/unambiguous-ambiguous-script/output.json @@ -0,0 +1,476 @@ +{ + "type": "File", + "start": 0, + "end": 65, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 8, + "column": 12 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 65, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 8, + "column": 12 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "expression": { + "type": "Identifier", + "start": 0, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + }, + "identifierName": "await" + }, + "name": "await" + } + }, + { + "type": "ExpressionStatement", + "start": 6, + "end": 7, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 1 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 6, + "end": 7, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 1 + } + }, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + } + }, + { + "type": "ExpressionStatement", + "start": 9, + "end": 18, + "loc": { + "start": { + "line": 4, + "column": 0 + }, + "end": { + "line": 4, + "column": 9 + } + }, + "expression": { + "type": "BinaryExpression", + "start": 9, + "end": 18, + "loc": { + "start": { + "line": 4, + "column": 0 + }, + "end": { + "line": 4, + "column": 9 + } + }, + "left": { + "type": "Identifier", + "start": 9, + "end": 14, + "loc": { + "start": { + "line": 4, + "column": 0 + }, + "end": { + "line": 4, + "column": 5 + }, + "identifierName": "await" + }, + "name": "await" + }, + "operator": "+", + "right": { + "type": "NumericLiteral", + "start": 17, + "end": 18, + "loc": { + "start": { + "line": 4, + "column": 8 + }, + "end": { + "line": 4, + "column": 9 + } + }, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + } + } + }, + { + "type": "ExpressionStatement", + "start": 19, + "end": 28, + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 5, + "column": 9 + } + }, + "expression": { + "type": "BinaryExpression", + "start": 19, + "end": 28, + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 5, + "column": 9 + } + }, + "left": { + "type": "Identifier", + "start": 19, + "end": 24, + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 5, + "column": 5 + }, + "identifierName": "await" + }, + "name": "await" + }, + "operator": "-", + "right": { + "type": "NumericLiteral", + "start": 27, + "end": 28, + "loc": { + "start": { + "line": 5, + "column": 8 + }, + "end": { + "line": 5, + "column": 9 + } + }, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + } + } + }, + { + "type": "ExpressionStatement", + "start": 29, + "end": 40, + "loc": { + "start": { + "line": 6, + "column": 0 + }, + "end": { + "line": 6, + "column": 11 + } + }, + "expression": { + "type": "CallExpression", + "start": 29, + "end": 40, + "loc": { + "start": { + "line": 6, + "column": 0 + }, + "end": { + "line": 6, + "column": 11 + } + }, + "callee": { + "type": "Identifier", + "start": 29, + "end": 34, + "loc": { + "start": { + "line": 6, + "column": 0 + }, + "end": { + "line": 6, + "column": 5 + }, + "identifierName": "await" + }, + "name": "await" + }, + "arguments": [ + { + "type": "NumericLiteral", + "start": 37, + "end": 38, + "loc": { + "start": { + "line": 6, + "column": 8 + }, + "end": { + "line": 6, + "column": 9 + } + }, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + } + ] + } + }, + { + "type": "ExpressionStatement", + "start": 41, + "end": 52, + "loc": { + "start": { + "line": 7, + "column": 0 + }, + "end": { + "line": 7, + "column": 11 + } + }, + "expression": { + "type": "MemberExpression", + "start": 41, + "end": 52, + "loc": { + "start": { + "line": 7, + "column": 0 + }, + "end": { + "line": 7, + "column": 11 + } + }, + "object": { + "type": "Identifier", + "start": 41, + "end": 46, + "loc": { + "start": { + "line": 7, + "column": 0 + }, + "end": { + "line": 7, + "column": 5 + }, + "identifierName": "await" + }, + "name": "await" + }, + "property": { + "type": "NumericLiteral", + "start": 49, + "end": 50, + "loc": { + "start": { + "line": 7, + "column": 8 + }, + "end": { + "line": 7, + "column": 9 + } + }, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + }, + "computed": true + } + }, + { + "type": "ExpressionStatement", + "start": 53, + "end": 65, + "loc": { + "start": { + "line": 8, + "column": 0 + }, + "end": { + "line": 8, + "column": 12 + } + }, + "expression": { + "type": "BinaryExpression", + "start": 53, + "end": 65, + "loc": { + "start": { + "line": 8, + "column": 0 + }, + "end": { + "line": 8, + "column": 12 + } + }, + "left": { + "type": "BinaryExpression", + "start": 53, + "end": 62, + "loc": { + "start": { + "line": 8, + "column": 0 + }, + "end": { + "line": 8, + "column": 9 + } + }, + "left": { + "type": "Identifier", + "start": 53, + "end": 58, + "loc": { + "start": { + "line": 8, + "column": 0 + }, + "end": { + "line": 8, + "column": 5 + }, + "identifierName": "await" + }, + "name": "await" + }, + "operator": "/", + "right": { + "type": "NumericLiteral", + "start": 61, + "end": 62, + "loc": { + "start": { + "line": 8, + "column": 8 + }, + "end": { + "line": 8, + "column": 9 + } + }, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + } + }, + "operator": "/", + "right": { + "type": "Identifier", + "start": 64, + "end": 65, + "loc": { + "start": { + "line": 8, + "column": 11 + }, + "end": { + "line": 8, + "column": 12 + }, + "identifierName": "u" + }, + "name": "u" + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/top-level-await/unambiguous-ambiguous-v8intrinsinc/input.js b/packages/babel-parser/test/fixtures/experimental/top-level-await/unambiguous-ambiguous-v8intrinsinc/input.js new file mode 100644 index 000000000000..735a0162b362 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/top-level-await/unambiguous-ambiguous-v8intrinsinc/input.js @@ -0,0 +1 @@ +await %x(0) \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/top-level-await/unambiguous-ambiguous-v8intrinsinc/options.json b/packages/babel-parser/test/fixtures/experimental/top-level-await/unambiguous-ambiguous-v8intrinsinc/options.json new file mode 100644 index 000000000000..6732f5f2f093 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/top-level-await/unambiguous-ambiguous-v8intrinsinc/options.json @@ -0,0 +1,4 @@ +{ + "plugins": ["topLevelAwait", "v8intrinsic"], + "sourceType": "unambiguous" +} diff --git a/packages/babel-parser/test/fixtures/experimental/top-level-await/unambiguous-ambiguous-v8intrinsinc/output.json b/packages/babel-parser/test/fixtures/experimental/top-level-await/unambiguous-ambiguous-v8intrinsinc/output.json new file mode 100644 index 000000000000..5805e3195560 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/top-level-await/unambiguous-ambiguous-v8intrinsinc/output.json @@ -0,0 +1,137 @@ +{ + "type": "File", + "start": 0, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "expression": { + "type": "BinaryExpression", + "start": 0, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "left": { + "type": "Identifier", + "start": 0, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + }, + "identifierName": "await" + }, + "name": "await" + }, + "operator": "%", + "right": { + "type": "CallExpression", + "start": 7, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "callee": { + "type": "Identifier", + "start": 7, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 8 + }, + "identifierName": "x" + }, + "name": "x" + }, + "arguments": [ + { + "type": "NumericLiteral", + "start": 9, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + } + ] + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/top-level-await/unambiguous-module/input.js b/packages/babel-parser/test/fixtures/experimental/top-level-await/unambiguous-module/input.js new file mode 100644 index 000000000000..1fa05e429c67 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/top-level-await/unambiguous-module/input.js @@ -0,0 +1,7 @@ +await 0 + +await + 0 +await - 0 +await ( 0 ) +await [ 0 ] +await / 0 /u diff --git a/packages/babel-parser/test/fixtures/experimental/top-level-await/unambiguous-module/options.json b/packages/babel-parser/test/fixtures/experimental/top-level-await/unambiguous-module/options.json new file mode 100644 index 000000000000..2503b82adf74 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/top-level-await/unambiguous-module/options.json @@ -0,0 +1,4 @@ +{ + "plugins": ["topLevelAwait"], + "sourceType": "unambiguous" +} diff --git a/packages/babel-parser/test/fixtures/experimental/top-level-await/unambiguous-module/output.json b/packages/babel-parser/test/fixtures/experimental/top-level-await/unambiguous-module/output.json new file mode 100644 index 000000000000..18617474f20a --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/top-level-await/unambiguous-module/output.json @@ -0,0 +1,388 @@ +{ + "type": "File", + "start": 0, + "end": 65, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 7, + "column": 12 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 65, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 7, + "column": 12 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "expression": { + "type": "AwaitExpression", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "argument": { + "type": "NumericLiteral", + "start": 6, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + } + } + }, + { + "type": "ExpressionStatement", + "start": 9, + "end": 18, + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 9 + } + }, + "expression": { + "type": "AwaitExpression", + "start": 9, + "end": 18, + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 9 + } + }, + "argument": { + "type": "UnaryExpression", + "start": 15, + "end": 18, + "loc": { + "start": { + "line": 3, + "column": 6 + }, + "end": { + "line": 3, + "column": 9 + } + }, + "operator": "+", + "prefix": true, + "argument": { + "type": "NumericLiteral", + "start": 17, + "end": 18, + "loc": { + "start": { + "line": 3, + "column": 8 + }, + "end": { + "line": 3, + "column": 9 + } + }, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + } + } + } + }, + { + "type": "ExpressionStatement", + "start": 19, + "end": 28, + "loc": { + "start": { + "line": 4, + "column": 0 + }, + "end": { + "line": 4, + "column": 9 + } + }, + "expression": { + "type": "AwaitExpression", + "start": 19, + "end": 28, + "loc": { + "start": { + "line": 4, + "column": 0 + }, + "end": { + "line": 4, + "column": 9 + } + }, + "argument": { + "type": "UnaryExpression", + "start": 25, + "end": 28, + "loc": { + "start": { + "line": 4, + "column": 6 + }, + "end": { + "line": 4, + "column": 9 + } + }, + "operator": "-", + "prefix": true, + "argument": { + "type": "NumericLiteral", + "start": 27, + "end": 28, + "loc": { + "start": { + "line": 4, + "column": 8 + }, + "end": { + "line": 4, + "column": 9 + } + }, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + } + } + } + }, + { + "type": "ExpressionStatement", + "start": 29, + "end": 40, + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 5, + "column": 11 + } + }, + "expression": { + "type": "AwaitExpression", + "start": 29, + "end": 40, + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 5, + "column": 11 + } + }, + "argument": { + "type": "NumericLiteral", + "start": 37, + "end": 38, + "loc": { + "start": { + "line": 5, + "column": 8 + }, + "end": { + "line": 5, + "column": 9 + } + }, + "extra": { + "rawValue": 0, + "raw": "0", + "parenthesized": true, + "parenStart": 35 + }, + "value": 0 + } + } + }, + { + "type": "ExpressionStatement", + "start": 41, + "end": 52, + "loc": { + "start": { + "line": 6, + "column": 0 + }, + "end": { + "line": 6, + "column": 11 + } + }, + "expression": { + "type": "AwaitExpression", + "start": 41, + "end": 52, + "loc": { + "start": { + "line": 6, + "column": 0 + }, + "end": { + "line": 6, + "column": 11 + } + }, + "argument": { + "type": "ArrayExpression", + "start": 47, + "end": 52, + "loc": { + "start": { + "line": 6, + "column": 6 + }, + "end": { + "line": 6, + "column": 11 + } + }, + "elements": [ + { + "type": "NumericLiteral", + "start": 49, + "end": 50, + "loc": { + "start": { + "line": 6, + "column": 8 + }, + "end": { + "line": 6, + "column": 9 + } + }, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + } + ] + } + } + }, + { + "type": "ExpressionStatement", + "start": 53, + "end": 65, + "loc": { + "start": { + "line": 7, + "column": 0 + }, + "end": { + "line": 7, + "column": 12 + } + }, + "expression": { + "type": "AwaitExpression", + "start": 53, + "end": 65, + "loc": { + "start": { + "line": 7, + "column": 0 + }, + "end": { + "line": 7, + "column": 12 + } + }, + "argument": { + "type": "RegExpLiteral", + "start": 59, + "end": 65, + "loc": { + "start": { + "line": 7, + "column": 6 + }, + "end": { + "line": 7, + "column": 12 + } + }, + "extra": { + "raw": "/ 0 /u" + }, + "pattern": " 0 ", + "flags": "u" + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/classes/constructor-override-with-class-prop-plugin/options.json b/packages/babel-parser/test/fixtures/flow/classes/constructor-override-with-class-prop-plugin/options.json index 382ffd0c6970..493880101c16 100644 --- a/packages/babel-parser/test/fixtures/flow/classes/constructor-override-with-class-prop-plugin/options.json +++ b/packages/babel-parser/test/fixtures/flow/classes/constructor-override-with-class-prop-plugin/options.json @@ -1,4 +1,8 @@ { - "throws": "Classes may not have a field named 'constructor' (2:2)", - "plugins": ["jsx", "flow", "classProperties"] -} + "sourceType": "module", + "plugins": [ + "jsx", + "flow", + "classProperties" + ] +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/classes/constructor-override-with-class-prop-plugin/output.json b/packages/babel-parser/test/fixtures/flow/classes/constructor-override-with-class-prop-plugin/output.json new file mode 100644 index 000000000000..3d9ad56d93cd --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/classes/constructor-override-with-class-prop-plugin/output.json @@ -0,0 +1,172 @@ +{ + "type": "File", + "start": 0, + "end": 40, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "errors": [ + "SyntaxError: Classes may not have a field named 'constructor' (2:2)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 40, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ClassDeclaration", + "start": 0, + "end": 40, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 6, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 9 + }, + "identifierName": "Foo" + }, + "name": "Foo" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "start": 10, + "end": 40, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "body": [ + { + "type": "ClassProperty", + "start": 14, + "end": 38, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 26 + } + }, + "static": false, + "key": { + "type": "Identifier", + "start": 14, + "end": 25, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 13 + }, + "identifierName": "constructor" + }, + "name": "constructor" + }, + "computed": false, + "variance": null, + "typeAnnotation": { + "type": "TypeAnnotation", + "start": 25, + "end": 37, + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 25 + } + }, + "typeAnnotation": { + "type": "FunctionTypeAnnotation", + "start": 27, + "end": 37, + "loc": { + "start": { + "line": 2, + "column": 15 + }, + "end": { + "line": 2, + "column": 25 + } + }, + "params": [], + "rest": null, + "returnType": { + "type": "ThisTypeAnnotation", + "start": 33, + "end": 37, + "loc": { + "start": { + "line": 2, + "column": 21 + }, + "end": { + "line": 2, + "column": 25 + } + } + }, + "typeParameters": null + } + }, + "value": null + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/comment/12-line-comment-nested-invalid/options.json b/packages/babel-parser/test/fixtures/flow/comment/12-line-comment-nested-invalid/options.json deleted file mode 100644 index 9a7e0e3402af..000000000000 --- a/packages/babel-parser/test/fixtures/flow/comment/12-line-comment-nested-invalid/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Unterminated flow-comment (1:13)" -} diff --git a/packages/babel-parser/test/fixtures/flow/comment/12-line-comment-nested-invalid/output.json b/packages/babel-parser/test/fixtures/flow/comment/12-line-comment-nested-invalid/output.json new file mode 100644 index 000000000000..bd82aabe61e4 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/comment/12-line-comment-nested-invalid/output.json @@ -0,0 +1,73 @@ +{ + "type": "File", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "errors": [ + "SyntaxError: Unterminated flow-comment (1:13)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [], + "directives": [], + "innerComments": [ + { + "type": "CommentLine", + "value": "asd */", + "start": 5, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 13 + } + } + } + ] + }, + "comments": [ + { + "type": "CommentLine", + "value": "asd */", + "start": 5, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 13 + } + } + } + ] +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/declare-export/export-star-as/options.json b/packages/babel-parser/test/fixtures/flow/declare-export/export-star-as/options.json index acd5b34be46d..698e7668500f 100644 --- a/packages/babel-parser/test/fixtures/flow/declare-export/export-star-as/options.json +++ b/packages/babel-parser/test/fixtures/flow/declare-export/export-star-as/options.json @@ -1,3 +1,3 @@ { - "plugins": ["jsx", "flow", "exportNamespaceFrom"] + "plugins": ["jsx", "flow"] } diff --git a/packages/babel-parser/test/fixtures/flow/declare-module/invalid-commonjs-module/options.json b/packages/babel-parser/test/fixtures/flow/declare-module/invalid-commonjs-module/options.json deleted file mode 100644 index adfde3236356..000000000000 --- a/packages/babel-parser/test/fixtures/flow/declare-module/invalid-commonjs-module/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Found both `declare module.exports` and `declare export` in the same module. Modules can only have 1 since they are either an ES module or they are a CommonJS module (1:55)" -} diff --git a/packages/babel-parser/test/fixtures/flow/declare-module/invalid-commonjs-module/output.json b/packages/babel-parser/test/fixtures/flow/declare-module/invalid-commonjs-module/output.json new file mode 100644 index 000000000000..43cb8ee092f2 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/declare-module/invalid-commonjs-module/output.json @@ -0,0 +1,214 @@ +{ + "type": "File", + "start": 0, + "end": 87, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 87 + } + }, + "errors": [ + "SyntaxError: Found both `declare module.exports` and `declare export` in the same module. Modules can only have 1 since they are either an ES module or they are a CommonJS module (1:55)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 87, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 87 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "DeclareModule", + "start": 0, + "end": 87, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 87 + } + }, + "id": { + "type": "StringLiteral", + "start": 15, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "extra": { + "rawValue": "foo", + "raw": "\"foo\"" + }, + "value": "foo" + }, + "body": { + "type": "BlockStatement", + "start": 21, + "end": 87, + "loc": { + "start": { + "line": 1, + "column": 21 + }, + "end": { + "line": 1, + "column": 87 + } + }, + "body": [ + { + "type": "DeclareModuleExports", + "start": 23, + "end": 54, + "loc": { + "start": { + "line": 1, + "column": 23 + }, + "end": { + "line": 1, + "column": 54 + } + }, + "typeAnnotation": { + "type": "TypeAnnotation", + "start": 45, + "end": 53, + "loc": { + "start": { + "line": 1, + "column": 45 + }, + "end": { + "line": 1, + "column": 53 + } + }, + "typeAnnotation": { + "type": "NumberTypeAnnotation", + "start": 47, + "end": 53, + "loc": { + "start": { + "line": 1, + "column": 47 + }, + "end": { + "line": 1, + "column": 53 + } + } + } + } + }, + { + "type": "DeclareExportDeclaration", + "start": 55, + "end": 84, + "loc": { + "start": { + "line": 1, + "column": 55 + }, + "end": { + "line": 1, + "column": 84 + } + }, + "declaration": { + "type": "DeclareVariable", + "start": 70, + "end": 84, + "loc": { + "start": { + "line": 1, + "column": 70 + }, + "end": { + "line": 1, + "column": 84 + } + }, + "id": { + "type": "Identifier", + "start": 74, + "end": 83, + "loc": { + "start": { + "line": 1, + "column": 74 + }, + "end": { + "line": 1, + "column": 83 + }, + "identifierName": "a" + }, + "name": "a", + "typeAnnotation": { + "type": "TypeAnnotation", + "start": 75, + "end": 83, + "loc": { + "start": { + "line": 1, + "column": 75 + }, + "end": { + "line": 1, + "column": 83 + } + }, + "typeAnnotation": { + "type": "NumberTypeAnnotation", + "start": 77, + "end": 83, + "loc": { + "start": { + "line": 1, + "column": 77 + }, + "end": { + "line": 1, + "column": 83 + } + } + } + } + } + }, + "default": false + } + ] + }, + "kind": "ES" + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/declare-module/invalid-es-module/options.json b/packages/babel-parser/test/fixtures/flow/declare-module/invalid-es-module/options.json deleted file mode 100644 index b40239a5609c..000000000000 --- a/packages/babel-parser/test/fixtures/flow/declare-module/invalid-es-module/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Found both `declare module.exports` and `declare export` in the same module. Modules can only have 1 since they are either an ES module or they are a CommonJS module (1:53)" -} diff --git a/packages/babel-parser/test/fixtures/flow/declare-module/invalid-es-module/output.json b/packages/babel-parser/test/fixtures/flow/declare-module/invalid-es-module/output.json new file mode 100644 index 000000000000..536157fab722 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/declare-module/invalid-es-module/output.json @@ -0,0 +1,214 @@ +{ + "type": "File", + "start": 0, + "end": 86, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 86 + } + }, + "errors": [ + "SyntaxError: Found both `declare module.exports` and `declare export` in the same module. Modules can only have 1 since they are either an ES module or they are a CommonJS module (1:53)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 86, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 86 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "DeclareModule", + "start": 0, + "end": 86, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 86 + } + }, + "id": { + "type": "StringLiteral", + "start": 15, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "extra": { + "rawValue": "foo", + "raw": "\"foo\"" + }, + "value": "foo" + }, + "body": { + "type": "BlockStatement", + "start": 21, + "end": 86, + "loc": { + "start": { + "line": 1, + "column": 21 + }, + "end": { + "line": 1, + "column": 86 + } + }, + "body": [ + { + "type": "DeclareExportDeclaration", + "start": 23, + "end": 52, + "loc": { + "start": { + "line": 1, + "column": 23 + }, + "end": { + "line": 1, + "column": 52 + } + }, + "declaration": { + "type": "DeclareVariable", + "start": 38, + "end": 52, + "loc": { + "start": { + "line": 1, + "column": 38 + }, + "end": { + "line": 1, + "column": 52 + } + }, + "id": { + "type": "Identifier", + "start": 42, + "end": 51, + "loc": { + "start": { + "line": 1, + "column": 42 + }, + "end": { + "line": 1, + "column": 51 + }, + "identifierName": "a" + }, + "name": "a", + "typeAnnotation": { + "type": "TypeAnnotation", + "start": 43, + "end": 51, + "loc": { + "start": { + "line": 1, + "column": 43 + }, + "end": { + "line": 1, + "column": 51 + } + }, + "typeAnnotation": { + "type": "NumberTypeAnnotation", + "start": 45, + "end": 51, + "loc": { + "start": { + "line": 1, + "column": 45 + }, + "end": { + "line": 1, + "column": 51 + } + } + } + } + } + }, + "default": false + }, + { + "type": "DeclareModuleExports", + "start": 53, + "end": 84, + "loc": { + "start": { + "line": 1, + "column": 53 + }, + "end": { + "line": 1, + "column": 84 + } + }, + "typeAnnotation": { + "type": "TypeAnnotation", + "start": 75, + "end": 83, + "loc": { + "start": { + "line": 1, + "column": 75 + }, + "end": { + "line": 1, + "column": 83 + } + }, + "typeAnnotation": { + "type": "NumberTypeAnnotation", + "start": 77, + "end": 83, + "loc": { + "start": { + "line": 1, + "column": 77 + }, + "end": { + "line": 1, + "column": 83 + } + } + } + } + } + ] + }, + "kind": "CommonJS" + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/declare-module/invalid-import/options.json b/packages/babel-parser/test/fixtures/flow/declare-module/invalid-import/options.json deleted file mode 100644 index c237bb99a73b..000000000000 --- a/packages/babel-parser/test/fixtures/flow/declare-module/invalid-import/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Imports within a `declare module` body must always be `import type` or `import typeof` (1:21)" -} diff --git a/packages/babel-parser/test/fixtures/flow/declare-module/invalid-import/output.json b/packages/babel-parser/test/fixtures/flow/declare-module/invalid-import/output.json new file mode 100644 index 000000000000..2d33b963c778 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/declare-module/invalid-import/output.json @@ -0,0 +1,161 @@ +{ + "type": "File", + "start": 0, + "end": 42, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 42 + } + }, + "errors": [ + "SyntaxError: Imports within a `declare module` body must always be `import type` or `import typeof` (1:21)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 42, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 42 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "DeclareModule", + "start": 0, + "end": 42, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 42 + } + }, + "id": { + "type": "StringLiteral", + "start": 15, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "extra": { + "rawValue": "M", + "raw": "\"M\"" + }, + "value": "M" + }, + "body": { + "type": "BlockStatement", + "start": 19, + "end": 42, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 42 + } + }, + "body": [ + { + "type": "ImportDeclaration", + "start": 21, + "end": 40, + "loc": { + "start": { + "line": 1, + "column": 21 + }, + "end": { + "line": 1, + "column": 40 + } + }, + "specifiers": [ + { + "type": "ImportDefaultSpecifier", + "start": 28, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 28 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "local": { + "type": "Identifier", + "start": 28, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 28 + }, + "end": { + "line": 1, + "column": 29 + }, + "identifierName": "T" + }, + "name": "T" + } + } + ], + "importKind": "value", + "source": { + "type": "StringLiteral", + "start": 35, + "end": 39, + "loc": { + "start": { + "line": 1, + "column": 35 + }, + "end": { + "line": 1, + "column": 39 + } + }, + "extra": { + "rawValue": "TM", + "raw": "\"TM\"" + }, + "value": "TM" + } + } + ] + }, + "kind": "CommonJS" + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/declare-module/invalid-module-in-module/options.json b/packages/babel-parser/test/fixtures/flow/declare-module/invalid-module-in-module/options.json deleted file mode 100644 index cd823bd7c4e0..000000000000 --- a/packages/babel-parser/test/fixtures/flow/declare-module/invalid-module-in-module/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "`declare module` cannot be used inside another `declare module` (1:27)" -} diff --git a/packages/babel-parser/test/fixtures/flow/declare-module/invalid-module-in-module/output.json b/packages/babel-parser/test/fixtures/flow/declare-module/invalid-module-in-module/output.json new file mode 100644 index 000000000000..0a3fe70d8611 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/declare-module/invalid-module-in-module/output.json @@ -0,0 +1,137 @@ +{ + "type": "File", + "start": 0, + "end": 40, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 40 + } + }, + "errors": [ + "SyntaxError: `declare module` cannot be used inside another `declare module` (1:27)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 40, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 40 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "DeclareModule", + "start": 0, + "end": 40, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 40 + } + }, + "id": { + "type": "Identifier", + "start": 15, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 16 + }, + "identifierName": "A" + }, + "name": "A" + }, + "body": { + "type": "BlockStatement", + "start": 17, + "end": 40, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 40 + } + }, + "body": [ + { + "type": "DeclareModule", + "start": 19, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 38 + } + }, + "id": { + "type": "Identifier", + "start": 34, + "end": 35, + "loc": { + "start": { + "line": 1, + "column": 34 + }, + "end": { + "line": 1, + "column": 35 + }, + "identifierName": "B" + }, + "name": "B" + }, + "body": { + "type": "BlockStatement", + "start": 36, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 36 + }, + "end": { + "line": 1, + "column": 38 + } + }, + "body": [] + }, + "kind": "CommonJS" + } + ] + }, + "kind": "CommonJS" + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/declare-module/invalid-multiple-commonjs/options.json b/packages/babel-parser/test/fixtures/flow/declare-module/invalid-multiple-commonjs/options.json deleted file mode 100644 index 1520d766b062..000000000000 --- a/packages/babel-parser/test/fixtures/flow/declare-module/invalid-multiple-commonjs/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Duplicate `declare module.exports` statement (1:55)" -} diff --git a/packages/babel-parser/test/fixtures/flow/declare-module/invalid-multiple-commonjs/output.json b/packages/babel-parser/test/fixtures/flow/declare-module/invalid-multiple-commonjs/output.json new file mode 100644 index 000000000000..4339f6dbf5c6 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/declare-module/invalid-multiple-commonjs/output.json @@ -0,0 +1,181 @@ +{ + "type": "File", + "start": 0, + "end": 88, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 88 + } + }, + "errors": [ + "SyntaxError: Duplicate `declare module.exports` statement (1:55)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 88, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 88 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "DeclareModule", + "start": 0, + "end": 88, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 88 + } + }, + "id": { + "type": "StringLiteral", + "start": 15, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "extra": { + "rawValue": "foo", + "raw": "\"foo\"" + }, + "value": "foo" + }, + "body": { + "type": "BlockStatement", + "start": 21, + "end": 88, + "loc": { + "start": { + "line": 1, + "column": 21 + }, + "end": { + "line": 1, + "column": 88 + } + }, + "body": [ + { + "type": "DeclareModuleExports", + "start": 23, + "end": 54, + "loc": { + "start": { + "line": 1, + "column": 23 + }, + "end": { + "line": 1, + "column": 54 + } + }, + "typeAnnotation": { + "type": "TypeAnnotation", + "start": 45, + "end": 53, + "loc": { + "start": { + "line": 1, + "column": 45 + }, + "end": { + "line": 1, + "column": 53 + } + }, + "typeAnnotation": { + "type": "StringTypeAnnotation", + "start": 47, + "end": 53, + "loc": { + "start": { + "line": 1, + "column": 47 + }, + "end": { + "line": 1, + "column": 53 + } + } + } + } + }, + { + "type": "DeclareModuleExports", + "start": 55, + "end": 86, + "loc": { + "start": { + "line": 1, + "column": 55 + }, + "end": { + "line": 1, + "column": 86 + } + }, + "typeAnnotation": { + "type": "TypeAnnotation", + "start": 77, + "end": 85, + "loc": { + "start": { + "line": 1, + "column": 77 + }, + "end": { + "line": 1, + "column": 85 + } + }, + "typeAnnotation": { + "type": "NumberTypeAnnotation", + "start": 79, + "end": 85, + "loc": { + "start": { + "line": 1, + "column": 79 + }, + "end": { + "line": 1, + "column": 85 + } + } + } + } + } + ] + }, + "kind": "CommonJS" + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/enum-declaration/boolean-explicit/input.js b/packages/babel-parser/test/fixtures/flow/enum-declaration/boolean-explicit/input.js new file mode 100644 index 000000000000..7b63f4eb2962 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/enum-declaration/boolean-explicit/input.js @@ -0,0 +1,4 @@ +enum E of boolean { + A = true, + B = false, +} diff --git a/packages/babel-parser/test/fixtures/flow/enum-declaration/boolean-explicit/output.json b/packages/babel-parser/test/fixtures/flow/enum-declaration/boolean-explicit/output.json new file mode 100644 index 000000000000..df48f24b108b --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/enum-declaration/boolean-explicit/output.json @@ -0,0 +1,181 @@ +{ + "type": "File", + "start": 0, + "end": 46, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 46, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "EnumDeclaration", + "start": 0, + "end": 46, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 5, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 6 + }, + "identifierName": "E" + }, + "name": "E" + }, + "body": { + "type": "EnumBooleanBody", + "start": 22, + "end": 44, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 3, + "column": 12 + } + }, + "explicitType": true, + "members": [ + { + "type": "EnumBooleanMember", + "start": 22, + "end": 30, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 10 + } + }, + "id": { + "type": "Identifier", + "start": 22, + "end": 23, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 3 + }, + "identifierName": "A" + }, + "name": "A" + }, + "init": { + "type": "BooleanLiteral", + "start": 26, + "end": 30, + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 10 + } + }, + "value": true + } + }, + { + "type": "EnumBooleanMember", + "start": 34, + "end": 43, + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 3, + "column": 11 + } + }, + "id": { + "type": "Identifier", + "start": 34, + "end": 35, + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 3, + "column": 3 + }, + "identifierName": "B" + }, + "name": "B" + }, + "init": { + "type": "BooleanLiteral", + "start": 38, + "end": 43, + "loc": { + "start": { + "line": 3, + "column": 6 + }, + "end": { + "line": 3, + "column": 11 + } + }, + "value": false + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/enum-declaration/boolean-implicit/input.js b/packages/babel-parser/test/fixtures/flow/enum-declaration/boolean-implicit/input.js new file mode 100644 index 000000000000..6ab49ea7b2b8 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/enum-declaration/boolean-implicit/input.js @@ -0,0 +1,4 @@ +enum E { + A = true, + B = false, +} diff --git a/packages/babel-parser/test/fixtures/flow/enum-declaration/boolean-implicit/output.json b/packages/babel-parser/test/fixtures/flow/enum-declaration/boolean-implicit/output.json new file mode 100644 index 000000000000..d7d3bae2e7c4 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/enum-declaration/boolean-implicit/output.json @@ -0,0 +1,181 @@ +{ + "type": "File", + "start": 0, + "end": 35, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 35, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "EnumDeclaration", + "start": 0, + "end": 35, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 5, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 6 + }, + "identifierName": "E" + }, + "name": "E" + }, + "body": { + "type": "EnumBooleanBody", + "start": 11, + "end": 33, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 3, + "column": 12 + } + }, + "explicitType": false, + "members": [ + { + "type": "EnumBooleanMember", + "start": 11, + "end": 19, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 10 + } + }, + "id": { + "type": "Identifier", + "start": 11, + "end": 12, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 3 + }, + "identifierName": "A" + }, + "name": "A" + }, + "init": { + "type": "BooleanLiteral", + "start": 15, + "end": 19, + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 10 + } + }, + "value": true + } + }, + { + "type": "EnumBooleanMember", + "start": 23, + "end": 32, + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 3, + "column": 11 + } + }, + "id": { + "type": "Identifier", + "start": 23, + "end": 24, + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 3, + "column": 3 + }, + "identifierName": "B" + }, + "name": "B" + }, + "init": { + "type": "BooleanLiteral", + "start": 27, + "end": 32, + "loc": { + "start": { + "line": 3, + "column": 6 + }, + "end": { + "line": 3, + "column": 11 + } + }, + "value": false + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/enum-declaration/boolean-member-not-initialized-explicit/input.js b/packages/babel-parser/test/fixtures/flow/enum-declaration/boolean-member-not-initialized-explicit/input.js new file mode 100644 index 000000000000..4fecb537fb2e --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/enum-declaration/boolean-member-not-initialized-explicit/input.js @@ -0,0 +1,3 @@ +enum E of boolean { + A, +} diff --git a/packages/babel-parser/test/fixtures/flow/enum-declaration/boolean-member-not-initialized-explicit/options.json b/packages/babel-parser/test/fixtures/flow/enum-declaration/boolean-member-not-initialized-explicit/options.json new file mode 100644 index 000000000000..53fd48c051cb --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/enum-declaration/boolean-member-not-initialized-explicit/options.json @@ -0,0 +1,3 @@ +{ + "plugins": [["flow", { "enums": true }]] +} diff --git a/packages/babel-parser/test/fixtures/flow/enum-declaration/boolean-member-not-initialized-explicit/output.json b/packages/babel-parser/test/fixtures/flow/enum-declaration/boolean-member-not-initialized-explicit/output.json new file mode 100644 index 000000000000..8ca6221bd05f --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/enum-declaration/boolean-member-not-initialized-explicit/output.json @@ -0,0 +1,87 @@ +{ + "type": "File", + "start": 0, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "errors": [ + "SyntaxError: Boolean enum members need to be initialized. Use either `A = true,` or `A = false,` in enum `E`. (2:2)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "EnumDeclaration", + "start": 0, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 5, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 6 + }, + "identifierName": "E" + }, + "name": "E" + }, + "body": { + "type": "EnumBooleanBody", + "start": 22, + "end": 24, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 4 + } + }, + "explicitType": true, + "members": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/enum-declaration/boolean-member-not-initialized-implicit/input.js b/packages/babel-parser/test/fixtures/flow/enum-declaration/boolean-member-not-initialized-implicit/input.js new file mode 100644 index 000000000000..73704345dc4b --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/enum-declaration/boolean-member-not-initialized-implicit/input.js @@ -0,0 +1,4 @@ +enum E { + A, + B = true, +} diff --git a/packages/babel-parser/test/fixtures/flow/enum-declaration/boolean-member-not-initialized-implicit/options.json b/packages/babel-parser/test/fixtures/flow/enum-declaration/boolean-member-not-initialized-implicit/options.json new file mode 100644 index 000000000000..53fd48c051cb --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/enum-declaration/boolean-member-not-initialized-implicit/options.json @@ -0,0 +1,3 @@ +{ + "plugins": [["flow", { "enums": true }]] +} diff --git a/packages/babel-parser/test/fixtures/flow/enum-declaration/boolean-member-not-initialized-implicit/output.json b/packages/babel-parser/test/fixtures/flow/enum-declaration/boolean-member-not-initialized-implicit/output.json new file mode 100644 index 000000000000..de57afc78eea --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/enum-declaration/boolean-member-not-initialized-implicit/output.json @@ -0,0 +1,136 @@ +{ + "type": "File", + "start": 0, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "errors": [ + "SyntaxError: Boolean enum members need to be initialized. Use either `A = true,` or `A = false,` in enum `E`. (2:2)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "EnumDeclaration", + "start": 0, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 5, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 6 + }, + "identifierName": "E" + }, + "name": "E" + }, + "body": { + "type": "EnumBooleanBody", + "start": 11, + "end": 25, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 3, + "column": 11 + } + }, + "explicitType": false, + "members": [ + { + "type": "EnumBooleanMember", + "start": 16, + "end": 24, + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 3, + "column": 10 + } + }, + "id": { + "type": "Identifier", + "start": 16, + "end": 17, + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 3, + "column": 3 + }, + "identifierName": "B" + }, + "name": "B" + }, + "init": { + "type": "BooleanLiteral", + "start": 20, + "end": 24, + "loc": { + "start": { + "line": 3, + "column": 6 + }, + "end": { + "line": 3, + "column": 10 + } + }, + "value": true + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/enum-declaration/duplicate-member-name/input.js b/packages/babel-parser/test/fixtures/flow/enum-declaration/duplicate-member-name/input.js new file mode 100644 index 000000000000..c9fde50253ac --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/enum-declaration/duplicate-member-name/input.js @@ -0,0 +1,4 @@ +enum E { + A, + A, +} diff --git a/packages/babel-parser/test/fixtures/flow/enum-declaration/duplicate-member-name/options.json b/packages/babel-parser/test/fixtures/flow/enum-declaration/duplicate-member-name/options.json new file mode 100644 index 000000000000..53fd48c051cb --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/enum-declaration/duplicate-member-name/options.json @@ -0,0 +1,3 @@ +{ + "plugins": [["flow", { "enums": true }]] +} diff --git a/packages/babel-parser/test/fixtures/flow/enum-declaration/duplicate-member-name/output.json b/packages/babel-parser/test/fixtures/flow/enum-declaration/duplicate-member-name/output.json new file mode 100644 index 000000000000..419248b77ef1 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/enum-declaration/duplicate-member-name/output.json @@ -0,0 +1,152 @@ +{ + "type": "File", + "start": 0, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "errors": [ + "SyntaxError: Enum member names need to be unique, but the name `A` has already been used before in enum `E`. (3:2)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "EnumDeclaration", + "start": 0, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 5, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 6 + }, + "identifierName": "E" + }, + "name": "E" + }, + "body": { + "type": "EnumStringBody", + "start": 11, + "end": 18, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 3, + "column": 4 + } + }, + "explicitType": false, + "members": [ + { + "type": "EnumDefaultedMember", + "start": 11, + "end": 12, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 3 + } + }, + "id": { + "type": "Identifier", + "start": 11, + "end": 12, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 3 + }, + "identifierName": "A" + }, + "name": "A" + } + }, + { + "type": "EnumDefaultedMember", + "start": 16, + "end": 17, + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 3, + "column": 3 + } + }, + "id": { + "type": "Identifier", + "start": 16, + "end": 17, + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 3, + "column": 3 + }, + "identifierName": "A" + }, + "name": "A" + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/enum-declaration/empty/input.js b/packages/babel-parser/test/fixtures/flow/enum-declaration/empty/input.js new file mode 100644 index 000000000000..714f607bf333 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/enum-declaration/empty/input.js @@ -0,0 +1 @@ +enum E { } diff --git a/packages/babel-parser/test/fixtures/flow/enum-declaration/empty/output.json b/packages/babel-parser/test/fixtures/flow/enum-declaration/empty/output.json new file mode 100644 index 000000000000..336475b12dd5 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/enum-declaration/empty/output.json @@ -0,0 +1,84 @@ +{ + "type": "File", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "EnumDeclaration", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "id": { + "type": "Identifier", + "start": 5, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 6 + }, + "identifierName": "E" + }, + "name": "E" + }, + "body": { + "type": "EnumStringBody", + "start": 9, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "explicitType": false, + "members": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/enum-declaration/end-of-file/input.js b/packages/babel-parser/test/fixtures/flow/enum-declaration/end-of-file/input.js new file mode 100644 index 000000000000..e3caefb45c49 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/enum-declaration/end-of-file/input.js @@ -0,0 +1 @@ +enum diff --git a/packages/babel-parser/test/fixtures/flow/enum-declaration/end-of-file/options.json b/packages/babel-parser/test/fixtures/flow/enum-declaration/end-of-file/options.json new file mode 100644 index 000000000000..030f339842d5 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/enum-declaration/end-of-file/options.json @@ -0,0 +1,4 @@ +{ + "plugins": [["flow", { "enums": true }]], + "throws": "Unexpected token (1:4)" +} diff --git a/packages/babel-parser/test/fixtures/flow/enum-declaration/enum-name/input.js b/packages/babel-parser/test/fixtures/flow/enum-declaration/enum-name/input.js new file mode 100644 index 000000000000..8d057902fa7e --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/enum-declaration/enum-name/input.js @@ -0,0 +1,2 @@ +enum type { +} diff --git a/packages/babel-parser/test/fixtures/flow/enum-declaration/enum-name/output.json b/packages/babel-parser/test/fixtures/flow/enum-declaration/enum-name/output.json new file mode 100644 index 000000000000..57bea3fab460 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/enum-declaration/enum-name/output.json @@ -0,0 +1,84 @@ +{ + "type": "File", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 1 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 1 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "EnumDeclaration", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 5, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 9 + }, + "identifierName": "type" + }, + "name": "type" + }, + "body": { + "type": "EnumStringBody", + "start": 12, + "end": 11, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "explicitType": false, + "members": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/enum-declaration/export/input.js b/packages/babel-parser/test/fixtures/flow/enum-declaration/export/input.js new file mode 100644 index 000000000000..ebdc5a4a8bb8 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/enum-declaration/export/input.js @@ -0,0 +1,3 @@ +export enum A {} + +export default enum B {} diff --git a/packages/babel-parser/test/fixtures/flow/enum-declaration/export/options.json b/packages/babel-parser/test/fixtures/flow/enum-declaration/export/options.json new file mode 100644 index 000000000000..9d3b4fdaaa37 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/enum-declaration/export/options.json @@ -0,0 +1,4 @@ +{ + "plugins": [["flow", { "enums": true }]], + "sourceType": "module" +} diff --git a/packages/babel-parser/test/fixtures/flow/enum-declaration/export/output.json b/packages/babel-parser/test/fixtures/flow/enum-declaration/export/output.json new file mode 100644 index 000000000000..5762ca30b575 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/enum-declaration/export/output.json @@ -0,0 +1,166 @@ +{ + "type": "File", + "start": 0, + "end": 42, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 24 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 42, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 24 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExportNamedDeclaration", + "start": 0, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "specifiers": [], + "source": null, + "exportKind": "value", + "declaration": { + "type": "EnumDeclaration", + "start": 7, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "id": { + "type": "Identifier", + "start": 12, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 13 + }, + "identifierName": "A" + }, + "name": "A" + }, + "body": { + "type": "EnumStringBody", + "start": 15, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "explicitType": false, + "members": [] + } + } + }, + { + "type": "ExportDefaultDeclaration", + "start": 18, + "end": 42, + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 24 + } + }, + "declaration": { + "type": "EnumDeclaration", + "start": 33, + "end": 42, + "loc": { + "start": { + "line": 3, + "column": 15 + }, + "end": { + "line": 3, + "column": 24 + } + }, + "id": { + "type": "Identifier", + "start": 38, + "end": 39, + "loc": { + "start": { + "line": 3, + "column": 20 + }, + "end": { + "line": 3, + "column": 21 + }, + "identifierName": "B" + }, + "name": "B" + }, + "body": { + "type": "EnumStringBody", + "start": 41, + "end": 41, + "loc": { + "start": { + "line": 3, + "column": 23 + }, + "end": { + "line": 3, + "column": 23 + } + }, + "explicitType": false, + "members": [] + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/enum-declaration/inconsistent-member-values-majority-defaulted/input.js b/packages/babel-parser/test/fixtures/flow/enum-declaration/inconsistent-member-values-majority-defaulted/input.js new file mode 100644 index 000000000000..5a639f107119 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/enum-declaration/inconsistent-member-values-majority-defaulted/input.js @@ -0,0 +1,5 @@ +enum E { + A, + B, + C = 3, +} diff --git a/packages/babel-parser/test/fixtures/flow/enum-declaration/inconsistent-member-values-majority-defaulted/options.json b/packages/babel-parser/test/fixtures/flow/enum-declaration/inconsistent-member-values-majority-defaulted/options.json new file mode 100644 index 000000000000..53fd48c051cb --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/enum-declaration/inconsistent-member-values-majority-defaulted/options.json @@ -0,0 +1,3 @@ +{ + "plugins": [["flow", { "enums": true }]] +} diff --git a/packages/babel-parser/test/fixtures/flow/enum-declaration/inconsistent-member-values-majority-defaulted/output.json b/packages/babel-parser/test/fixtures/flow/enum-declaration/inconsistent-member-values-majority-defaulted/output.json new file mode 100644 index 000000000000..b9a7090addd4 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/enum-declaration/inconsistent-member-values-majority-defaulted/output.json @@ -0,0 +1,87 @@ +{ + "type": "File", + "start": 0, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 5, + "column": 1 + } + }, + "errors": [ + "SyntaxError: Enum `E` has inconsistent member initializers. Either use no initializers, or consistently use literals (either booleans, numbers, or strings) for all member initializers. (1:5)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 5, + "column": 1 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "EnumDeclaration", + "start": 0, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 5, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 5, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 6 + }, + "identifierName": "E" + }, + "name": "E" + }, + "body": { + "type": "EnumStringBody", + "start": 11, + "end": 27, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 4, + "column": 8 + } + }, + "explicitType": false, + "members": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/enum-declaration/inconsistent-member-values-mixed-initializers/input.js b/packages/babel-parser/test/fixtures/flow/enum-declaration/inconsistent-member-values-mixed-initializers/input.js new file mode 100644 index 000000000000..b0b10ec4d43a --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/enum-declaration/inconsistent-member-values-mixed-initializers/input.js @@ -0,0 +1,4 @@ +enum E { + A = 1, + B = true, +} diff --git a/packages/babel-parser/test/fixtures/flow/enum-declaration/inconsistent-member-values-mixed-initializers/options.json b/packages/babel-parser/test/fixtures/flow/enum-declaration/inconsistent-member-values-mixed-initializers/options.json new file mode 100644 index 000000000000..53fd48c051cb --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/enum-declaration/inconsistent-member-values-mixed-initializers/options.json @@ -0,0 +1,3 @@ +{ + "plugins": [["flow", { "enums": true }]] +} diff --git a/packages/babel-parser/test/fixtures/flow/enum-declaration/inconsistent-member-values-mixed-initializers/output.json b/packages/babel-parser/test/fixtures/flow/enum-declaration/inconsistent-member-values-mixed-initializers/output.json new file mode 100644 index 000000000000..a6954ed31095 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/enum-declaration/inconsistent-member-values-mixed-initializers/output.json @@ -0,0 +1,87 @@ +{ + "type": "File", + "start": 0, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "errors": [ + "SyntaxError: Enum `E` has inconsistent member initializers. Either use no initializers, or consistently use literals (either booleans, numbers, or strings) for all member initializers. (1:5)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "EnumDeclaration", + "start": 0, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 5, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 6 + }, + "identifierName": "E" + }, + "name": "E" + }, + "body": { + "type": "EnumStringBody", + "start": 11, + "end": 29, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 3, + "column": 11 + } + }, + "explicitType": false, + "members": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/enum-declaration/invalid-explicit-type-expression/input.js b/packages/babel-parser/test/fixtures/flow/enum-declaration/invalid-explicit-type-expression/input.js new file mode 100644 index 000000000000..e3353ef78879 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/enum-declaration/invalid-explicit-type-expression/input.js @@ -0,0 +1,2 @@ +enum E of [] { +} diff --git a/packages/babel-parser/test/fixtures/flow/enum-declaration/invalid-explicit-type-expression/options.json b/packages/babel-parser/test/fixtures/flow/enum-declaration/invalid-explicit-type-expression/options.json new file mode 100644 index 000000000000..9916e88639b9 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/enum-declaration/invalid-explicit-type-expression/options.json @@ -0,0 +1,4 @@ +{ + "plugins": [["flow", { "enums": true }]], + "throws": "Supplied enum type is not valid. Use one of `boolean`, `number`, `string`, or `symbol` in enum `E`. (1:10)" +} diff --git a/packages/babel-parser/test/fixtures/flow/enum-declaration/invalid-explicit-type-identifier/input.js b/packages/babel-parser/test/fixtures/flow/enum-declaration/invalid-explicit-type-identifier/input.js new file mode 100644 index 000000000000..25bbeb7024e8 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/enum-declaration/invalid-explicit-type-identifier/input.js @@ -0,0 +1,2 @@ +enum E of xxx { +} diff --git a/packages/babel-parser/test/fixtures/flow/enum-declaration/invalid-explicit-type-identifier/options.json b/packages/babel-parser/test/fixtures/flow/enum-declaration/invalid-explicit-type-identifier/options.json new file mode 100644 index 000000000000..30df8c2ef701 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/enum-declaration/invalid-explicit-type-identifier/options.json @@ -0,0 +1,4 @@ +{ + "plugins": [["flow", { "enums": true }]] + +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/enum-declaration/invalid-explicit-type-identifier/output.json b/packages/babel-parser/test/fixtures/flow/enum-declaration/invalid-explicit-type-identifier/output.json new file mode 100644 index 000000000000..7b6a1da0ed1f --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/enum-declaration/invalid-explicit-type-identifier/output.json @@ -0,0 +1,87 @@ +{ + "type": "File", + "start": 0, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 1 + } + }, + "errors": [ + "SyntaxError: Enum type `xxx` is not valid. Use one of `boolean`, `number`, `string`, or `symbol` in enum `E`. (1:14)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 1 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "EnumDeclaration", + "start": 0, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 5, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 6 + }, + "identifierName": "E" + }, + "name": "E" + }, + "body": { + "type": "EnumStringBody", + "start": 16, + "end": 15, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "explicitType": false, + "members": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/enum-declaration/invalid-member-initializer-boolean-explicit-string/input.js b/packages/babel-parser/test/fixtures/flow/enum-declaration/invalid-member-initializer-boolean-explicit-string/input.js new file mode 100644 index 000000000000..31e79ef9f119 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/enum-declaration/invalid-member-initializer-boolean-explicit-string/input.js @@ -0,0 +1,3 @@ +enum E of string { + A = true, +} diff --git a/packages/babel-parser/test/fixtures/flow/enum-declaration/invalid-member-initializer-boolean-explicit-string/options.json b/packages/babel-parser/test/fixtures/flow/enum-declaration/invalid-member-initializer-boolean-explicit-string/options.json new file mode 100644 index 000000000000..53fd48c051cb --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/enum-declaration/invalid-member-initializer-boolean-explicit-string/options.json @@ -0,0 +1,3 @@ +{ + "plugins": [["flow", { "enums": true }]] +} diff --git a/packages/babel-parser/test/fixtures/flow/enum-declaration/invalid-member-initializer-boolean-explicit-string/output.json b/packages/babel-parser/test/fixtures/flow/enum-declaration/invalid-member-initializer-boolean-explicit-string/output.json new file mode 100644 index 000000000000..a8f898034c39 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/enum-declaration/invalid-member-initializer-boolean-explicit-string/output.json @@ -0,0 +1,87 @@ +{ + "type": "File", + "start": 0, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "errors": [ + "SyntaxError: Enum `E` has type `string`, so the initializer of `A` needs to be a string literal. (2:6)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "EnumDeclaration", + "start": 0, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 5, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 6 + }, + "identifierName": "E" + }, + "name": "E" + }, + "body": { + "type": "EnumStringBody", + "start": 21, + "end": 30, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 11 + } + }, + "explicitType": true, + "members": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/enum-declaration/invalid-member-initializer-expression-explicit-boolean/input.js b/packages/babel-parser/test/fixtures/flow/enum-declaration/invalid-member-initializer-expression-explicit-boolean/input.js new file mode 100644 index 000000000000..d4f1afa92f09 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/enum-declaration/invalid-member-initializer-expression-explicit-boolean/input.js @@ -0,0 +1,3 @@ +enum E of boolean { + A = 1 + 2, +} diff --git a/packages/babel-parser/test/fixtures/flow/enum-declaration/invalid-member-initializer-expression-explicit-boolean/options.json b/packages/babel-parser/test/fixtures/flow/enum-declaration/invalid-member-initializer-expression-explicit-boolean/options.json new file mode 100644 index 000000000000..14ed173defa0 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/enum-declaration/invalid-member-initializer-expression-explicit-boolean/options.json @@ -0,0 +1,4 @@ +{ + "plugins": [["flow", { "enums": true }]], + "throws": "Enum `E` has type `boolean`, so the initializer of `A` needs to be a boolean literal. (2:6)" +} diff --git a/packages/babel-parser/test/fixtures/flow/enum-declaration/invalid-member-initializer-expression-explicit-number/input.js b/packages/babel-parser/test/fixtures/flow/enum-declaration/invalid-member-initializer-expression-explicit-number/input.js new file mode 100644 index 000000000000..a6f7ed2152c2 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/enum-declaration/invalid-member-initializer-expression-explicit-number/input.js @@ -0,0 +1,3 @@ +enum E of number { + A = 1 + 2, +} diff --git a/packages/babel-parser/test/fixtures/flow/enum-declaration/invalid-member-initializer-expression-explicit-number/options.json b/packages/babel-parser/test/fixtures/flow/enum-declaration/invalid-member-initializer-expression-explicit-number/options.json new file mode 100644 index 000000000000..7a8a81f75442 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/enum-declaration/invalid-member-initializer-expression-explicit-number/options.json @@ -0,0 +1,4 @@ +{ + "plugins": [["flow", { "enums": true }]], + "throws": "Enum `E` has type `number`, so the initializer of `A` needs to be a number literal. (2:6)" +} diff --git a/packages/babel-parser/test/fixtures/flow/enum-declaration/invalid-member-initializer-expression-explicit-string/input.js b/packages/babel-parser/test/fixtures/flow/enum-declaration/invalid-member-initializer-expression-explicit-string/input.js new file mode 100644 index 000000000000..704efcf615b5 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/enum-declaration/invalid-member-initializer-expression-explicit-string/input.js @@ -0,0 +1,3 @@ +enum E of string { + A = 1 + 2, +} diff --git a/packages/babel-parser/test/fixtures/flow/enum-declaration/invalid-member-initializer-expression-explicit-string/options.json b/packages/babel-parser/test/fixtures/flow/enum-declaration/invalid-member-initializer-expression-explicit-string/options.json new file mode 100644 index 000000000000..1587909dd62e --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/enum-declaration/invalid-member-initializer-expression-explicit-string/options.json @@ -0,0 +1,4 @@ +{ + "plugins": [["flow", { "enums": true }]], + "throws": "Enum `E` has type `string`, so the initializer of `A` needs to be a string literal. (2:6)" +} diff --git a/packages/babel-parser/test/fixtures/flow/enum-declaration/invalid-member-initializer-expression-explicit-symbol/input.js b/packages/babel-parser/test/fixtures/flow/enum-declaration/invalid-member-initializer-expression-explicit-symbol/input.js new file mode 100644 index 000000000000..d4acb6dfd235 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/enum-declaration/invalid-member-initializer-expression-explicit-symbol/input.js @@ -0,0 +1,3 @@ +enum E of symbol { + A = 1 + 2, +} diff --git a/packages/babel-parser/test/fixtures/flow/enum-declaration/invalid-member-initializer-expression-explicit-symbol/options.json b/packages/babel-parser/test/fixtures/flow/enum-declaration/invalid-member-initializer-expression-explicit-symbol/options.json new file mode 100644 index 000000000000..e9b2692f126a --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/enum-declaration/invalid-member-initializer-expression-explicit-symbol/options.json @@ -0,0 +1,4 @@ +{ + "plugins": [["flow", { "enums": true }]], + "throws": "Symbol enum members cannot be initialized. Use `A,` in enum `E`. (2:6)" +} diff --git a/packages/babel-parser/test/fixtures/flow/enum-declaration/invalid-member-initializer-expression-implicit/input.js b/packages/babel-parser/test/fixtures/flow/enum-declaration/invalid-member-initializer-expression-implicit/input.js new file mode 100644 index 000000000000..bed31f7fdc1c --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/enum-declaration/invalid-member-initializer-expression-implicit/input.js @@ -0,0 +1,3 @@ +enum E { + A = 1 + 2, +} diff --git a/packages/babel-parser/test/fixtures/flow/enum-declaration/invalid-member-initializer-expression-implicit/options.json b/packages/babel-parser/test/fixtures/flow/enum-declaration/invalid-member-initializer-expression-implicit/options.json new file mode 100644 index 000000000000..282f44e03ab4 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/enum-declaration/invalid-member-initializer-expression-implicit/options.json @@ -0,0 +1,4 @@ +{ + "plugins": [["flow", { "enums": true }]], + "throws": "The enum member initializer for `A` needs to be a literal (either a boolean, number, or string) in enum `E`. (2:6)" +} diff --git a/packages/babel-parser/test/fixtures/flow/enum-declaration/invalid-member-initializer-literal-explicit-symbol/input.js b/packages/babel-parser/test/fixtures/flow/enum-declaration/invalid-member-initializer-literal-explicit-symbol/input.js new file mode 100644 index 000000000000..dc8429b75342 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/enum-declaration/invalid-member-initializer-literal-explicit-symbol/input.js @@ -0,0 +1,3 @@ +enum E of symbol { + A = 1, +} diff --git a/packages/babel-parser/test/fixtures/flow/enum-declaration/invalid-member-initializer-literal-explicit-symbol/options.json b/packages/babel-parser/test/fixtures/flow/enum-declaration/invalid-member-initializer-literal-explicit-symbol/options.json new file mode 100644 index 000000000000..53fd48c051cb --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/enum-declaration/invalid-member-initializer-literal-explicit-symbol/options.json @@ -0,0 +1,3 @@ +{ + "plugins": [["flow", { "enums": true }]] +} diff --git a/packages/babel-parser/test/fixtures/flow/enum-declaration/invalid-member-initializer-literal-explicit-symbol/output.json b/packages/babel-parser/test/fixtures/flow/enum-declaration/invalid-member-initializer-literal-explicit-symbol/output.json new file mode 100644 index 000000000000..4cf1122979e8 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/enum-declaration/invalid-member-initializer-literal-explicit-symbol/output.json @@ -0,0 +1,86 @@ +{ + "type": "File", + "start": 0, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "errors": [ + "SyntaxError: Symbol enum members cannot be initialized. Use `A,` in enum `E`. (2:6)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "EnumDeclaration", + "start": 0, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 5, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 6 + }, + "identifierName": "E" + }, + "name": "E" + }, + "body": { + "type": "EnumSymbolBody", + "start": 21, + "end": 27, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 8 + } + }, + "members": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/enum-declaration/invalid-member-initializer-number-explicit-boolean/input.js b/packages/babel-parser/test/fixtures/flow/enum-declaration/invalid-member-initializer-number-explicit-boolean/input.js new file mode 100644 index 000000000000..81e1097efdd9 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/enum-declaration/invalid-member-initializer-number-explicit-boolean/input.js @@ -0,0 +1,3 @@ +enum E of boolean { + A = 1, +} diff --git a/packages/babel-parser/test/fixtures/flow/enum-declaration/invalid-member-initializer-number-explicit-boolean/options.json b/packages/babel-parser/test/fixtures/flow/enum-declaration/invalid-member-initializer-number-explicit-boolean/options.json new file mode 100644 index 000000000000..53fd48c051cb --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/enum-declaration/invalid-member-initializer-number-explicit-boolean/options.json @@ -0,0 +1,3 @@ +{ + "plugins": [["flow", { "enums": true }]] +} diff --git a/packages/babel-parser/test/fixtures/flow/enum-declaration/invalid-member-initializer-number-explicit-boolean/output.json b/packages/babel-parser/test/fixtures/flow/enum-declaration/invalid-member-initializer-number-explicit-boolean/output.json new file mode 100644 index 000000000000..c737d1129440 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/enum-declaration/invalid-member-initializer-number-explicit-boolean/output.json @@ -0,0 +1,87 @@ +{ + "type": "File", + "start": 0, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "errors": [ + "SyntaxError: Enum `E` has type `boolean`, so the initializer of `A` needs to be a boolean literal. (2:6)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "EnumDeclaration", + "start": 0, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 5, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 6 + }, + "identifierName": "E" + }, + "name": "E" + }, + "body": { + "type": "EnumBooleanBody", + "start": 22, + "end": 28, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 8 + } + }, + "explicitType": true, + "members": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/enum-declaration/invalid-member-initializer-number-explicit-string/input.js b/packages/babel-parser/test/fixtures/flow/enum-declaration/invalid-member-initializer-number-explicit-string/input.js new file mode 100644 index 000000000000..708914906e1d --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/enum-declaration/invalid-member-initializer-number-explicit-string/input.js @@ -0,0 +1,3 @@ +enum E of string { + A = 1, +} diff --git a/packages/babel-parser/test/fixtures/flow/enum-declaration/invalid-member-initializer-number-explicit-string/options.json b/packages/babel-parser/test/fixtures/flow/enum-declaration/invalid-member-initializer-number-explicit-string/options.json new file mode 100644 index 000000000000..53fd48c051cb --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/enum-declaration/invalid-member-initializer-number-explicit-string/options.json @@ -0,0 +1,3 @@ +{ + "plugins": [["flow", { "enums": true }]] +} diff --git a/packages/babel-parser/test/fixtures/flow/enum-declaration/invalid-member-initializer-number-explicit-string/output.json b/packages/babel-parser/test/fixtures/flow/enum-declaration/invalid-member-initializer-number-explicit-string/output.json new file mode 100644 index 000000000000..653573513644 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/enum-declaration/invalid-member-initializer-number-explicit-string/output.json @@ -0,0 +1,87 @@ +{ + "type": "File", + "start": 0, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "errors": [ + "SyntaxError: Enum `E` has type `string`, so the initializer of `A` needs to be a string literal. (2:6)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "EnumDeclaration", + "start": 0, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 5, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 6 + }, + "identifierName": "E" + }, + "name": "E" + }, + "body": { + "type": "EnumStringBody", + "start": 21, + "end": 27, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 8 + } + }, + "explicitType": true, + "members": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/enum-declaration/invalid-member-initializer-parenthesized/input.js b/packages/babel-parser/test/fixtures/flow/enum-declaration/invalid-member-initializer-parenthesized/input.js new file mode 100644 index 000000000000..92cc2012d905 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/enum-declaration/invalid-member-initializer-parenthesized/input.js @@ -0,0 +1,3 @@ +enum E { + A = (1), +} diff --git a/packages/babel-parser/test/fixtures/flow/enum-declaration/invalid-member-initializer-parenthesized/options.json b/packages/babel-parser/test/fixtures/flow/enum-declaration/invalid-member-initializer-parenthesized/options.json new file mode 100644 index 000000000000..db9720997638 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/enum-declaration/invalid-member-initializer-parenthesized/options.json @@ -0,0 +1,4 @@ +{ + "plugins": [["flow", { "enums": true }]], + "throws": "The enum member initializer for `A` needs to be a literal (either a boolean, number, or string) in enum `E`. (2:6)" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/enum-declaration/invalid-member-initializer-string-explicit-boolean/input.js b/packages/babel-parser/test/fixtures/flow/enum-declaration/invalid-member-initializer-string-explicit-boolean/input.js new file mode 100644 index 000000000000..86674e7f2053 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/enum-declaration/invalid-member-initializer-string-explicit-boolean/input.js @@ -0,0 +1,3 @@ +enum E of boolean { + A = "hi", +} diff --git a/packages/babel-parser/test/fixtures/flow/enum-declaration/invalid-member-initializer-string-explicit-boolean/options.json b/packages/babel-parser/test/fixtures/flow/enum-declaration/invalid-member-initializer-string-explicit-boolean/options.json new file mode 100644 index 000000000000..53fd48c051cb --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/enum-declaration/invalid-member-initializer-string-explicit-boolean/options.json @@ -0,0 +1,3 @@ +{ + "plugins": [["flow", { "enums": true }]] +} diff --git a/packages/babel-parser/test/fixtures/flow/enum-declaration/invalid-member-initializer-string-explicit-boolean/output.json b/packages/babel-parser/test/fixtures/flow/enum-declaration/invalid-member-initializer-string-explicit-boolean/output.json new file mode 100644 index 000000000000..2f1b07d00c15 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/enum-declaration/invalid-member-initializer-string-explicit-boolean/output.json @@ -0,0 +1,87 @@ +{ + "type": "File", + "start": 0, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "errors": [ + "SyntaxError: Enum `E` has type `boolean`, so the initializer of `A` needs to be a boolean literal. (2:6)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "EnumDeclaration", + "start": 0, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 5, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 6 + }, + "identifierName": "E" + }, + "name": "E" + }, + "body": { + "type": "EnumBooleanBody", + "start": 22, + "end": 31, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 11 + } + }, + "explicitType": true, + "members": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/enum-declaration/invalid-member-initializer-string-explicit-number/input.js b/packages/babel-parser/test/fixtures/flow/enum-declaration/invalid-member-initializer-string-explicit-number/input.js new file mode 100644 index 000000000000..5b0a7937af0a --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/enum-declaration/invalid-member-initializer-string-explicit-number/input.js @@ -0,0 +1,3 @@ +enum E of number { + A = "hi", +} diff --git a/packages/babel-parser/test/fixtures/flow/enum-declaration/invalid-member-initializer-string-explicit-number/options.json b/packages/babel-parser/test/fixtures/flow/enum-declaration/invalid-member-initializer-string-explicit-number/options.json new file mode 100644 index 000000000000..53fd48c051cb --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/enum-declaration/invalid-member-initializer-string-explicit-number/options.json @@ -0,0 +1,3 @@ +{ + "plugins": [["flow", { "enums": true }]] +} diff --git a/packages/babel-parser/test/fixtures/flow/enum-declaration/invalid-member-initializer-string-explicit-number/output.json b/packages/babel-parser/test/fixtures/flow/enum-declaration/invalid-member-initializer-string-explicit-number/output.json new file mode 100644 index 000000000000..263ac8c203cb --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/enum-declaration/invalid-member-initializer-string-explicit-number/output.json @@ -0,0 +1,87 @@ +{ + "type": "File", + "start": 0, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "errors": [ + "SyntaxError: Enum `E` has type `number`, so the initializer of `A` needs to be a number literal. (2:6)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "EnumDeclaration", + "start": 0, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 5, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 6 + }, + "identifierName": "E" + }, + "name": "E" + }, + "body": { + "type": "EnumNumberBody", + "start": 21, + "end": 30, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 11 + } + }, + "explicitType": true, + "members": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/enum-declaration/invalid-member-name/input.js b/packages/babel-parser/test/fixtures/flow/enum-declaration/invalid-member-name/input.js new file mode 100644 index 000000000000..3604a85bb2d4 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/enum-declaration/invalid-member-name/input.js @@ -0,0 +1,4 @@ +enum E { + foo, + bar, +} diff --git a/packages/babel-parser/test/fixtures/flow/enum-declaration/invalid-member-name/options.json b/packages/babel-parser/test/fixtures/flow/enum-declaration/invalid-member-name/options.json new file mode 100644 index 000000000000..53fd48c051cb --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/enum-declaration/invalid-member-name/options.json @@ -0,0 +1,3 @@ +{ + "plugins": [["flow", { "enums": true }]] +} diff --git a/packages/babel-parser/test/fixtures/flow/enum-declaration/invalid-member-name/output.json b/packages/babel-parser/test/fixtures/flow/enum-declaration/invalid-member-name/output.json new file mode 100644 index 000000000000..f4f24a70b045 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/enum-declaration/invalid-member-name/output.json @@ -0,0 +1,153 @@ +{ + "type": "File", + "start": 0, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "errors": [ + "SyntaxError: Enum member names cannot start with lowercase 'a' through 'z'. Instead of using `foo`, consider using `Foo`, in enum `E`. (2:2)", + "SyntaxError: Enum member names cannot start with lowercase 'a' through 'z'. Instead of using `bar`, consider using `Bar`, in enum `E`. (3:2)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "EnumDeclaration", + "start": 0, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 5, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 6 + }, + "identifierName": "E" + }, + "name": "E" + }, + "body": { + "type": "EnumStringBody", + "start": 11, + "end": 22, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 3, + "column": 6 + } + }, + "explicitType": false, + "members": [ + { + "type": "EnumDefaultedMember", + "start": 11, + "end": 14, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 5 + } + }, + "id": { + "type": "Identifier", + "start": 11, + "end": 14, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 5 + }, + "identifierName": "foo" + }, + "name": "foo" + } + }, + { + "type": "EnumDefaultedMember", + "start": 18, + "end": 21, + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 3, + "column": 5 + } + }, + "id": { + "type": "Identifier", + "start": 18, + "end": 21, + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 3, + "column": 5 + }, + "identifierName": "bar" + }, + "name": "bar" + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/enum-declaration/no-trailing-comma/input.js b/packages/babel-parser/test/fixtures/flow/enum-declaration/no-trailing-comma/input.js new file mode 100644 index 000000000000..228a928299de --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/enum-declaration/no-trailing-comma/input.js @@ -0,0 +1,3 @@ +enum E { + A +} diff --git a/packages/babel-parser/test/fixtures/flow/enum-declaration/no-trailing-comma/output.json b/packages/babel-parser/test/fixtures/flow/enum-declaration/no-trailing-comma/output.json new file mode 100644 index 000000000000..ed614a856575 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/enum-declaration/no-trailing-comma/output.json @@ -0,0 +1,117 @@ +{ + "type": "File", + "start": 0, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "EnumDeclaration", + "start": 0, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 5, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 6 + }, + "identifierName": "E" + }, + "name": "E" + }, + "body": { + "type": "EnumStringBody", + "start": 11, + "end": 12, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 3 + } + }, + "explicitType": false, + "members": [ + { + "type": "EnumDefaultedMember", + "start": 11, + "end": 12, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 3 + } + }, + "id": { + "type": "Identifier", + "start": 11, + "end": 12, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 3 + }, + "identifierName": "A" + }, + "name": "A" + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/enum-declaration/number-explicit/input.js b/packages/babel-parser/test/fixtures/flow/enum-declaration/number-explicit/input.js new file mode 100644 index 000000000000..f597c5898aa0 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/enum-declaration/number-explicit/input.js @@ -0,0 +1,4 @@ +enum E of number { + A = 1, + B = 2, +} diff --git a/packages/babel-parser/test/fixtures/flow/enum-declaration/number-explicit/output.json b/packages/babel-parser/test/fixtures/flow/enum-declaration/number-explicit/output.json new file mode 100644 index 000000000000..4f5a6f26c614 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/enum-declaration/number-explicit/output.json @@ -0,0 +1,189 @@ +{ + "type": "File", + "start": 0, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "EnumDeclaration", + "start": 0, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 5, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 6 + }, + "identifierName": "E" + }, + "name": "E" + }, + "body": { + "type": "EnumNumberBody", + "start": 21, + "end": 36, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 3, + "column": 8 + } + }, + "explicitType": true, + "members": [ + { + "type": "EnumNumberMember", + "start": 21, + "end": 26, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 7 + } + }, + "id": { + "type": "Identifier", + "start": 21, + "end": 22, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 3 + }, + "identifierName": "A" + }, + "name": "A" + }, + "init": { + "type": "NumericLiteral", + "start": 25, + "end": 26, + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 7 + } + }, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + } + }, + { + "type": "EnumNumberMember", + "start": 30, + "end": 35, + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 3, + "column": 7 + } + }, + "id": { + "type": "Identifier", + "start": 30, + "end": 31, + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 3, + "column": 3 + }, + "identifierName": "B" + }, + "name": "B" + }, + "init": { + "type": "NumericLiteral", + "start": 34, + "end": 35, + "loc": { + "start": { + "line": 3, + "column": 6 + }, + "end": { + "line": 3, + "column": 7 + } + }, + "extra": { + "rawValue": 2, + "raw": "2" + }, + "value": 2 + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/enum-declaration/number-implicit/input.js b/packages/babel-parser/test/fixtures/flow/enum-declaration/number-implicit/input.js new file mode 100644 index 000000000000..1b99bb7ff34a --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/enum-declaration/number-implicit/input.js @@ -0,0 +1,4 @@ +enum E { + A = 1, + B = 2, +} diff --git a/packages/babel-parser/test/fixtures/flow/enum-declaration/number-implicit/output.json b/packages/babel-parser/test/fixtures/flow/enum-declaration/number-implicit/output.json new file mode 100644 index 000000000000..862a8bc5691b --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/enum-declaration/number-implicit/output.json @@ -0,0 +1,189 @@ +{ + "type": "File", + "start": 0, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "EnumDeclaration", + "start": 0, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 5, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 6 + }, + "identifierName": "E" + }, + "name": "E" + }, + "body": { + "type": "EnumNumberBody", + "start": 11, + "end": 26, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 3, + "column": 8 + } + }, + "explicitType": false, + "members": [ + { + "type": "EnumNumberMember", + "start": 11, + "end": 16, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 7 + } + }, + "id": { + "type": "Identifier", + "start": 11, + "end": 12, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 3 + }, + "identifierName": "A" + }, + "name": "A" + }, + "init": { + "type": "NumericLiteral", + "start": 15, + "end": 16, + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 7 + } + }, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + } + }, + { + "type": "EnumNumberMember", + "start": 20, + "end": 25, + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 3, + "column": 7 + } + }, + "id": { + "type": "Identifier", + "start": 20, + "end": 21, + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 3, + "column": 3 + }, + "identifierName": "B" + }, + "name": "B" + }, + "init": { + "type": "NumericLiteral", + "start": 24, + "end": 25, + "loc": { + "start": { + "line": 3, + "column": 6 + }, + "end": { + "line": 3, + "column": 7 + } + }, + "extra": { + "rawValue": 2, + "raw": "2" + }, + "value": 2 + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/enum-declaration/number-member-not-initialized-explicit/input.js b/packages/babel-parser/test/fixtures/flow/enum-declaration/number-member-not-initialized-explicit/input.js new file mode 100644 index 000000000000..7f4f9cb05bbf --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/enum-declaration/number-member-not-initialized-explicit/input.js @@ -0,0 +1,3 @@ +enum E of number { + A, +} diff --git a/packages/babel-parser/test/fixtures/flow/enum-declaration/number-member-not-initialized-explicit/options.json b/packages/babel-parser/test/fixtures/flow/enum-declaration/number-member-not-initialized-explicit/options.json new file mode 100644 index 000000000000..53fd48c051cb --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/enum-declaration/number-member-not-initialized-explicit/options.json @@ -0,0 +1,3 @@ +{ + "plugins": [["flow", { "enums": true }]] +} diff --git a/packages/babel-parser/test/fixtures/flow/enum-declaration/number-member-not-initialized-explicit/output.json b/packages/babel-parser/test/fixtures/flow/enum-declaration/number-member-not-initialized-explicit/output.json new file mode 100644 index 000000000000..8408025e1256 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/enum-declaration/number-member-not-initialized-explicit/output.json @@ -0,0 +1,87 @@ +{ + "type": "File", + "start": 0, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "errors": [ + "SyntaxError: Number enum members need to be initialized, e.g. `A = 1` in enum `E`. (2:2)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "EnumDeclaration", + "start": 0, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 5, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 6 + }, + "identifierName": "E" + }, + "name": "E" + }, + "body": { + "type": "EnumNumberBody", + "start": 21, + "end": 23, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 4 + } + }, + "explicitType": true, + "members": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/enum-declaration/number-member-not-initialized-implicit/input.js b/packages/babel-parser/test/fixtures/flow/enum-declaration/number-member-not-initialized-implicit/input.js new file mode 100644 index 000000000000..a435e44e3da9 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/enum-declaration/number-member-not-initialized-implicit/input.js @@ -0,0 +1,4 @@ +enum E { + A, + B = 1, +} diff --git a/packages/babel-parser/test/fixtures/flow/enum-declaration/number-member-not-initialized-implicit/options.json b/packages/babel-parser/test/fixtures/flow/enum-declaration/number-member-not-initialized-implicit/options.json new file mode 100644 index 000000000000..53fd48c051cb --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/enum-declaration/number-member-not-initialized-implicit/options.json @@ -0,0 +1,3 @@ +{ + "plugins": [["flow", { "enums": true }]] +} diff --git a/packages/babel-parser/test/fixtures/flow/enum-declaration/number-member-not-initialized-implicit/output.json b/packages/babel-parser/test/fixtures/flow/enum-declaration/number-member-not-initialized-implicit/output.json new file mode 100644 index 000000000000..67dae3487d84 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/enum-declaration/number-member-not-initialized-implicit/output.json @@ -0,0 +1,140 @@ +{ + "type": "File", + "start": 0, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "errors": [ + "SyntaxError: Number enum members need to be initialized, e.g. `A = 1` in enum `E`. (2:2)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "EnumDeclaration", + "start": 0, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 5, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 6 + }, + "identifierName": "E" + }, + "name": "E" + }, + "body": { + "type": "EnumNumberBody", + "start": 11, + "end": 22, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 3, + "column": 8 + } + }, + "explicitType": false, + "members": [ + { + "type": "EnumNumberMember", + "start": 16, + "end": 21, + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 3, + "column": 7 + } + }, + "id": { + "type": "Identifier", + "start": 16, + "end": 17, + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 3, + "column": 3 + }, + "identifierName": "B" + }, + "name": "B" + }, + "init": { + "type": "NumericLiteral", + "start": 20, + "end": 21, + "loc": { + "start": { + "line": 3, + "column": 6 + }, + "end": { + "line": 3, + "column": 7 + } + }, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/enum-declaration/options.json b/packages/babel-parser/test/fixtures/flow/enum-declaration/options.json new file mode 100644 index 000000000000..53fd48c051cb --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/enum-declaration/options.json @@ -0,0 +1,3 @@ +{ + "plugins": [["flow", { "enums": true }]] +} diff --git a/packages/babel-parser/test/fixtures/flow/enum-declaration/reserved-word-enum-name/input.js b/packages/babel-parser/test/fixtures/flow/enum-declaration/reserved-word-enum-name/input.js new file mode 100644 index 000000000000..95350dba2f86 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/enum-declaration/reserved-word-enum-name/input.js @@ -0,0 +1,2 @@ +enum class { +} diff --git a/packages/babel-parser/test/fixtures/flow/enum-declaration/reserved-word-enum-name/options.json b/packages/babel-parser/test/fixtures/flow/enum-declaration/reserved-word-enum-name/options.json new file mode 100644 index 000000000000..53fd48c051cb --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/enum-declaration/reserved-word-enum-name/options.json @@ -0,0 +1,3 @@ +{ + "plugins": [["flow", { "enums": true }]] +} diff --git a/packages/babel-parser/test/fixtures/flow/enum-declaration/reserved-word-enum-name/output.json b/packages/babel-parser/test/fixtures/flow/enum-declaration/reserved-word-enum-name/output.json new file mode 100644 index 000000000000..f80ecb8f4d3d --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/enum-declaration/reserved-word-enum-name/output.json @@ -0,0 +1,87 @@ +{ + "type": "File", + "start": 0, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 1 + } + }, + "errors": [ + "SyntaxError: Unexpected keyword 'class' (1:5)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 1 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "EnumDeclaration", + "start": 0, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 5, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 10 + }, + "identifierName": "class" + }, + "name": "class" + }, + "body": { + "type": "EnumStringBody", + "start": 13, + "end": 12, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "explicitType": false, + "members": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/enum-declaration/string-explicit-defaulted/input.js b/packages/babel-parser/test/fixtures/flow/enum-declaration/string-explicit-defaulted/input.js new file mode 100644 index 000000000000..0d3f7fed8378 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/enum-declaration/string-explicit-defaulted/input.js @@ -0,0 +1,4 @@ +enum E of string { + A, + B, +} diff --git a/packages/babel-parser/test/fixtures/flow/enum-declaration/string-explicit-defaulted/output.json b/packages/babel-parser/test/fixtures/flow/enum-declaration/string-explicit-defaulted/output.json new file mode 100644 index 000000000000..57cc928ec552 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/enum-declaration/string-explicit-defaulted/output.json @@ -0,0 +1,149 @@ +{ + "type": "File", + "start": 0, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "EnumDeclaration", + "start": 0, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 5, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 6 + }, + "identifierName": "E" + }, + "name": "E" + }, + "body": { + "type": "EnumStringBody", + "start": 21, + "end": 28, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 3, + "column": 4 + } + }, + "explicitType": true, + "members": [ + { + "type": "EnumDefaultedMember", + "start": 21, + "end": 22, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 3 + } + }, + "id": { + "type": "Identifier", + "start": 21, + "end": 22, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 3 + }, + "identifierName": "A" + }, + "name": "A" + } + }, + { + "type": "EnumDefaultedMember", + "start": 26, + "end": 27, + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 3, + "column": 3 + } + }, + "id": { + "type": "Identifier", + "start": 26, + "end": 27, + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 3, + "column": 3 + }, + "identifierName": "B" + }, + "name": "B" + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/enum-declaration/string-explicit-initialized/input.js b/packages/babel-parser/test/fixtures/flow/enum-declaration/string-explicit-initialized/input.js new file mode 100644 index 000000000000..4d27120ac56a --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/enum-declaration/string-explicit-initialized/input.js @@ -0,0 +1,4 @@ +enum E of string { + A = "a", + B = "b", +} diff --git a/packages/babel-parser/test/fixtures/flow/enum-declaration/string-explicit-initialized/output.json b/packages/babel-parser/test/fixtures/flow/enum-declaration/string-explicit-initialized/output.json new file mode 100644 index 000000000000..1ab361d41977 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/enum-declaration/string-explicit-initialized/output.json @@ -0,0 +1,189 @@ +{ + "type": "File", + "start": 0, + "end": 42, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 42, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "EnumDeclaration", + "start": 0, + "end": 42, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 5, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 6 + }, + "identifierName": "E" + }, + "name": "E" + }, + "body": { + "type": "EnumStringBody", + "start": 21, + "end": 40, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 3, + "column": 10 + } + }, + "explicitType": true, + "members": [ + { + "type": "EnumStringMember", + "start": 21, + "end": 28, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 9 + } + }, + "id": { + "type": "Identifier", + "start": 21, + "end": 22, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 3 + }, + "identifierName": "A" + }, + "name": "A" + }, + "init": { + "type": "StringLiteral", + "start": 25, + "end": 28, + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 9 + } + }, + "extra": { + "rawValue": "a", + "raw": "\"a\"" + }, + "value": "a" + } + }, + { + "type": "EnumStringMember", + "start": 32, + "end": 39, + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 3, + "column": 9 + } + }, + "id": { + "type": "Identifier", + "start": 32, + "end": 33, + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 3, + "column": 3 + }, + "identifierName": "B" + }, + "name": "B" + }, + "init": { + "type": "StringLiteral", + "start": 36, + "end": 39, + "loc": { + "start": { + "line": 3, + "column": 6 + }, + "end": { + "line": 3, + "column": 9 + } + }, + "extra": { + "rawValue": "b", + "raw": "\"b\"" + }, + "value": "b" + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/enum-declaration/string-implicit-defaulted/input.js b/packages/babel-parser/test/fixtures/flow/enum-declaration/string-implicit-defaulted/input.js new file mode 100644 index 000000000000..b74648fd612c --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/enum-declaration/string-implicit-defaulted/input.js @@ -0,0 +1,4 @@ +enum E { + A, + B, +} diff --git a/packages/babel-parser/test/fixtures/flow/enum-declaration/string-implicit-defaulted/output.json b/packages/babel-parser/test/fixtures/flow/enum-declaration/string-implicit-defaulted/output.json new file mode 100644 index 000000000000..b14d096085c2 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/enum-declaration/string-implicit-defaulted/output.json @@ -0,0 +1,149 @@ +{ + "type": "File", + "start": 0, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "EnumDeclaration", + "start": 0, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 5, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 6 + }, + "identifierName": "E" + }, + "name": "E" + }, + "body": { + "type": "EnumStringBody", + "start": 11, + "end": 18, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 3, + "column": 4 + } + }, + "explicitType": false, + "members": [ + { + "type": "EnumDefaultedMember", + "start": 11, + "end": 12, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 3 + } + }, + "id": { + "type": "Identifier", + "start": 11, + "end": 12, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 3 + }, + "identifierName": "A" + }, + "name": "A" + } + }, + { + "type": "EnumDefaultedMember", + "start": 16, + "end": 17, + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 3, + "column": 3 + } + }, + "id": { + "type": "Identifier", + "start": 16, + "end": 17, + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 3, + "column": 3 + }, + "identifierName": "B" + }, + "name": "B" + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/enum-declaration/string-implicit-initialized/input.js b/packages/babel-parser/test/fixtures/flow/enum-declaration/string-implicit-initialized/input.js new file mode 100644 index 000000000000..d1b1c29fc8a8 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/enum-declaration/string-implicit-initialized/input.js @@ -0,0 +1,4 @@ +enum E { + A = "a", + B = "b", +} diff --git a/packages/babel-parser/test/fixtures/flow/enum-declaration/string-implicit-initialized/output.json b/packages/babel-parser/test/fixtures/flow/enum-declaration/string-implicit-initialized/output.json new file mode 100644 index 000000000000..8f3e4e6eb48a --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/enum-declaration/string-implicit-initialized/output.json @@ -0,0 +1,189 @@ +{ + "type": "File", + "start": 0, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "EnumDeclaration", + "start": 0, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 5, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 6 + }, + "identifierName": "E" + }, + "name": "E" + }, + "body": { + "type": "EnumStringBody", + "start": 11, + "end": 30, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 3, + "column": 10 + } + }, + "explicitType": false, + "members": [ + { + "type": "EnumStringMember", + "start": 11, + "end": 18, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 9 + } + }, + "id": { + "type": "Identifier", + "start": 11, + "end": 12, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 3 + }, + "identifierName": "A" + }, + "name": "A" + }, + "init": { + "type": "StringLiteral", + "start": 15, + "end": 18, + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 9 + } + }, + "extra": { + "rawValue": "a", + "raw": "\"a\"" + }, + "value": "a" + } + }, + { + "type": "EnumStringMember", + "start": 22, + "end": 29, + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 3, + "column": 9 + } + }, + "id": { + "type": "Identifier", + "start": 22, + "end": 23, + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 3, + "column": 3 + }, + "identifierName": "B" + }, + "name": "B" + }, + "init": { + "type": "StringLiteral", + "start": 26, + "end": 29, + "loc": { + "start": { + "line": 3, + "column": 6 + }, + "end": { + "line": 3, + "column": 9 + } + }, + "extra": { + "rawValue": "b", + "raw": "\"b\"" + }, + "value": "b" + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/enum-declaration/string-member-inconsistently-initialized-majority-defaulted/input.js b/packages/babel-parser/test/fixtures/flow/enum-declaration/string-member-inconsistently-initialized-majority-defaulted/input.js new file mode 100644 index 000000000000..279605f466c4 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/enum-declaration/string-member-inconsistently-initialized-majority-defaulted/input.js @@ -0,0 +1,5 @@ +enum E of string { + A = "a", + B, + C, +} diff --git a/packages/babel-parser/test/fixtures/flow/enum-declaration/string-member-inconsistently-initialized-majority-defaulted/options.json b/packages/babel-parser/test/fixtures/flow/enum-declaration/string-member-inconsistently-initialized-majority-defaulted/options.json new file mode 100644 index 000000000000..53fd48c051cb --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/enum-declaration/string-member-inconsistently-initialized-majority-defaulted/options.json @@ -0,0 +1,3 @@ +{ + "plugins": [["flow", { "enums": true }]] +} diff --git a/packages/babel-parser/test/fixtures/flow/enum-declaration/string-member-inconsistently-initialized-majority-defaulted/output.json b/packages/babel-parser/test/fixtures/flow/enum-declaration/string-member-inconsistently-initialized-majority-defaulted/output.json new file mode 100644 index 000000000000..f3a0304fb310 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/enum-declaration/string-member-inconsistently-initialized-majority-defaulted/output.json @@ -0,0 +1,152 @@ +{ + "type": "File", + "start": 0, + "end": 41, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 5, + "column": 1 + } + }, + "errors": [ + "SyntaxError: String enum members need to consistently either all use initializers, or use no initializers, in enum `E`. (2:2)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 41, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 5, + "column": 1 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "EnumDeclaration", + "start": 0, + "end": 41, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 5, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 5, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 6 + }, + "identifierName": "E" + }, + "name": "E" + }, + "body": { + "type": "EnumStringBody", + "start": 21, + "end": 39, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 4, + "column": 4 + } + }, + "explicitType": true, + "members": [ + { + "type": "EnumDefaultedMember", + "start": 32, + "end": 33, + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 3, + "column": 3 + } + }, + "id": { + "type": "Identifier", + "start": 32, + "end": 33, + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 3, + "column": 3 + }, + "identifierName": "B" + }, + "name": "B" + } + }, + { + "type": "EnumDefaultedMember", + "start": 37, + "end": 38, + "loc": { + "start": { + "line": 4, + "column": 2 + }, + "end": { + "line": 4, + "column": 3 + } + }, + "id": { + "type": "Identifier", + "start": 37, + "end": 38, + "loc": { + "start": { + "line": 4, + "column": 2 + }, + "end": { + "line": 4, + "column": 3 + }, + "identifierName": "C" + }, + "name": "C" + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/enum-declaration/string-member-inconsistently-initialized-majority-initialized/input.js b/packages/babel-parser/test/fixtures/flow/enum-declaration/string-member-inconsistently-initialized-majority-initialized/input.js new file mode 100644 index 000000000000..e8db50effe4d --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/enum-declaration/string-member-inconsistently-initialized-majority-initialized/input.js @@ -0,0 +1,5 @@ +enum E of string { + A, + B = "b", + C = "c", +} diff --git a/packages/babel-parser/test/fixtures/flow/enum-declaration/string-member-inconsistently-initialized-majority-initialized/options.json b/packages/babel-parser/test/fixtures/flow/enum-declaration/string-member-inconsistently-initialized-majority-initialized/options.json new file mode 100644 index 000000000000..53fd48c051cb --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/enum-declaration/string-member-inconsistently-initialized-majority-initialized/options.json @@ -0,0 +1,3 @@ +{ + "plugins": [["flow", { "enums": true }]] +} diff --git a/packages/babel-parser/test/fixtures/flow/enum-declaration/string-member-inconsistently-initialized-majority-initialized/output.json b/packages/babel-parser/test/fixtures/flow/enum-declaration/string-member-inconsistently-initialized-majority-initialized/output.json new file mode 100644 index 000000000000..9a637136e9c2 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/enum-declaration/string-member-inconsistently-initialized-majority-initialized/output.json @@ -0,0 +1,192 @@ +{ + "type": "File", + "start": 0, + "end": 47, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 5, + "column": 1 + } + }, + "errors": [ + "SyntaxError: String enum members need to consistently either all use initializers, or use no initializers, in enum `E`. (2:2)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 47, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 5, + "column": 1 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "EnumDeclaration", + "start": 0, + "end": 47, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 5, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 5, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 6 + }, + "identifierName": "E" + }, + "name": "E" + }, + "body": { + "type": "EnumStringBody", + "start": 21, + "end": 45, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 4, + "column": 10 + } + }, + "explicitType": true, + "members": [ + { + "type": "EnumStringMember", + "start": 26, + "end": 33, + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 3, + "column": 9 + } + }, + "id": { + "type": "Identifier", + "start": 26, + "end": 27, + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 3, + "column": 3 + }, + "identifierName": "B" + }, + "name": "B" + }, + "init": { + "type": "StringLiteral", + "start": 30, + "end": 33, + "loc": { + "start": { + "line": 3, + "column": 6 + }, + "end": { + "line": 3, + "column": 9 + } + }, + "extra": { + "rawValue": "b", + "raw": "\"b\"" + }, + "value": "b" + } + }, + { + "type": "EnumStringMember", + "start": 37, + "end": 44, + "loc": { + "start": { + "line": 4, + "column": 2 + }, + "end": { + "line": 4, + "column": 9 + } + }, + "id": { + "type": "Identifier", + "start": 37, + "end": 38, + "loc": { + "start": { + "line": 4, + "column": 2 + }, + "end": { + "line": 4, + "column": 3 + }, + "identifierName": "C" + }, + "name": "C" + }, + "init": { + "type": "StringLiteral", + "start": 41, + "end": 44, + "loc": { + "start": { + "line": 4, + "column": 6 + }, + "end": { + "line": 4, + "column": 9 + } + }, + "extra": { + "rawValue": "c", + "raw": "\"c\"" + }, + "value": "c" + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/enum-declaration/symbol/input.js b/packages/babel-parser/test/fixtures/flow/enum-declaration/symbol/input.js new file mode 100644 index 000000000000..26e5377f5e71 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/enum-declaration/symbol/input.js @@ -0,0 +1,4 @@ +enum E of symbol { + A, + B, +} diff --git a/packages/babel-parser/test/fixtures/flow/enum-declaration/symbol/output.json b/packages/babel-parser/test/fixtures/flow/enum-declaration/symbol/output.json new file mode 100644 index 000000000000..6f5ba3e152c1 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/enum-declaration/symbol/output.json @@ -0,0 +1,148 @@ +{ + "type": "File", + "start": 0, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "EnumDeclaration", + "start": 0, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 5, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 6 + }, + "identifierName": "E" + }, + "name": "E" + }, + "body": { + "type": "EnumSymbolBody", + "start": 21, + "end": 28, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 3, + "column": 4 + } + }, + "members": [ + { + "type": "EnumDefaultedMember", + "start": 21, + "end": 22, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 3 + } + }, + "id": { + "type": "Identifier", + "start": 21, + "end": 22, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 3 + }, + "identifierName": "A" + }, + "name": "A" + } + }, + { + "type": "EnumDefaultedMember", + "start": 26, + "end": 27, + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 3, + "column": 3 + } + }, + "id": { + "type": "Identifier", + "start": 26, + "end": 27, + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 3, + "column": 3 + }, + "identifierName": "B" + }, + "name": "B" + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_disallowed_in_non_objects1/options.json b/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_disallowed_in_non_objects1/options.json index c9188366d4e8..2104ca43283f 100644 --- a/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_disallowed_in_non_objects1/options.json +++ b/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_disallowed_in_non_objects1/options.json @@ -1,5 +1,3 @@ { - "sourceType": "module", - "plugins": ["jsx", "flow"], - "throws": "Spread operator cannot appear in class or interface definitions (3:2)" + "sourceType": "module" } diff --git a/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_disallowed_in_non_objects1/output.json b/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_disallowed_in_non_objects1/output.json new file mode 100644 index 000000000000..f896b9fffbcb --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_disallowed_in_non_objects1/output.json @@ -0,0 +1,130 @@ +{ + "type": "File", + "start": 0, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "errors": [ + "SyntaxError: Explicit inexact syntax cannot appear in class or interface definitions (3:2)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "DeclareClass", + "start": 8, + "end": 34, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 22, + "end": 23, + "loc": { + "start": { + "line": 2, + "column": 14 + }, + "end": { + "line": 2, + "column": 15 + }, + "identifierName": "A" + }, + "name": "A" + }, + "typeParameters": null, + "extends": [], + "implements": [], + "mixins": [], + "body": { + "type": "ObjectTypeAnnotation", + "start": 24, + "end": 34, + "loc": { + "start": { + "line": 2, + "column": 16 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "callProperties": [], + "properties": [], + "indexers": [], + "internalSlots": [], + "exact": false + }, + "leadingComments": [ + { + "type": "CommentLine", + "value": "@flow", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + } + } + ] + } + ], + "directives": [] + }, + "comments": [ + { + "type": "CommentLine", + "value": "@flow", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + } + } + ] +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_disallowed_in_non_objects2/options.json b/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_disallowed_in_non_objects2/options.json index 658f8c434773..2104ca43283f 100644 --- a/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_disallowed_in_non_objects2/options.json +++ b/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_disallowed_in_non_objects2/options.json @@ -1,5 +1,3 @@ { - "sourceType": "module", - "plugins": ["jsx", "flow"], - "throws": "Spread operator cannot appear in class or interface definitions (4:2)" + "sourceType": "module" } diff --git a/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_disallowed_in_non_objects2/output.json b/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_disallowed_in_non_objects2/output.json new file mode 100644 index 000000000000..6a0edc43c316 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_disallowed_in_non_objects2/output.json @@ -0,0 +1,184 @@ +{ + "type": "File", + "start": 0, + "end": 49, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 5, + "column": 1 + } + }, + "errors": [ + "SyntaxError: Explicit inexact syntax cannot appear in class or interface definitions (4:2)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 49, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 5, + "column": 1 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "DeclareClass", + "start": 8, + "end": 49, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 5, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 22, + "end": 23, + "loc": { + "start": { + "line": 2, + "column": 14 + }, + "end": { + "line": 2, + "column": 15 + }, + "identifierName": "B" + }, + "name": "B" + }, + "typeParameters": null, + "extends": [], + "implements": [], + "mixins": [], + "body": { + "type": "ObjectTypeAnnotation", + "start": 24, + "end": 49, + "loc": { + "start": { + "line": 2, + "column": 16 + }, + "end": { + "line": 5, + "column": 1 + } + }, + "callProperties": [], + "properties": [ + { + "type": "ObjectTypeProperty", + "start": 28, + "end": 39, + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 3, + "column": 13 + } + }, + "key": { + "type": "Identifier", + "start": 28, + "end": 31, + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 3, + "column": 5 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "static": false, + "proto": false, + "kind": "init", + "method": false, + "value": { + "type": "NumberTypeAnnotation", + "start": 33, + "end": 39, + "loc": { + "start": { + "line": 3, + "column": 7 + }, + "end": { + "line": 3, + "column": 13 + } + } + }, + "variance": null, + "optional": false + } + ], + "indexers": [], + "internalSlots": [], + "exact": false + }, + "leadingComments": [ + { + "type": "CommentLine", + "value": "@flow", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + } + } + ] + } + ], + "directives": [] + }, + "comments": [ + { + "type": "CommentLine", + "value": "@flow", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + } + } + ] +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_disallowed_in_non_objects3/options.json b/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_disallowed_in_non_objects3/options.json index c9188366d4e8..d822c40fbba2 100644 --- a/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_disallowed_in_non_objects3/options.json +++ b/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_disallowed_in_non_objects3/options.json @@ -1,5 +1,4 @@ { "sourceType": "module", - "plugins": ["jsx", "flow"], - "throws": "Spread operator cannot appear in class or interface definitions (3:2)" + "plugins": ["jsx", "flow"] } diff --git a/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_disallowed_in_non_objects3/output.json b/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_disallowed_in_non_objects3/output.json new file mode 100644 index 000000000000..7fa5b4a0b07f --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_disallowed_in_non_objects3/output.json @@ -0,0 +1,185 @@ +{ + "type": "File", + "start": 0, + "end": 49, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 5, + "column": 1 + } + }, + "errors": [ + "SyntaxError: Explicit inexact syntax cannot appear in class or interface definitions (3:2)", + "SyntaxError: Explicit inexact syntax must appear at the end of an inexact object (3:2)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 49, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 5, + "column": 1 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "DeclareClass", + "start": 8, + "end": 49, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 5, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 22, + "end": 23, + "loc": { + "start": { + "line": 2, + "column": 14 + }, + "end": { + "line": 2, + "column": 15 + }, + "identifierName": "C" + }, + "name": "C" + }, + "typeParameters": null, + "extends": [], + "implements": [], + "mixins": [], + "body": { + "type": "ObjectTypeAnnotation", + "start": 24, + "end": 49, + "loc": { + "start": { + "line": 2, + "column": 16 + }, + "end": { + "line": 5, + "column": 1 + } + }, + "callProperties": [], + "properties": [ + { + "type": "ObjectTypeProperty", + "start": 35, + "end": 46, + "loc": { + "start": { + "line": 4, + "column": 2 + }, + "end": { + "line": 4, + "column": 13 + } + }, + "key": { + "type": "Identifier", + "start": 35, + "end": 38, + "loc": { + "start": { + "line": 4, + "column": 2 + }, + "end": { + "line": 4, + "column": 5 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "static": false, + "proto": false, + "kind": "init", + "method": false, + "value": { + "type": "NumberTypeAnnotation", + "start": 40, + "end": 46, + "loc": { + "start": { + "line": 4, + "column": 7 + }, + "end": { + "line": 4, + "column": 13 + } + } + }, + "variance": null, + "optional": false + } + ], + "indexers": [], + "internalSlots": [], + "exact": false + }, + "leadingComments": [ + { + "type": "CommentLine", + "value": "@flow", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + } + } + ] + } + ], + "directives": [] + }, + "comments": [ + { + "type": "CommentLine", + "value": "@flow", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + } + } + ] +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_disallowed_in_non_objects4/options.json b/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_disallowed_in_non_objects4/options.json index 658f8c434773..d822c40fbba2 100644 --- a/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_disallowed_in_non_objects4/options.json +++ b/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_disallowed_in_non_objects4/options.json @@ -1,5 +1,4 @@ { "sourceType": "module", - "plugins": ["jsx", "flow"], - "throws": "Spread operator cannot appear in class or interface definitions (4:2)" + "plugins": ["jsx", "flow"] } diff --git a/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_disallowed_in_non_objects4/output.json b/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_disallowed_in_non_objects4/output.json new file mode 100644 index 000000000000..224a0566437c --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_disallowed_in_non_objects4/output.json @@ -0,0 +1,238 @@ +{ + "type": "File", + "start": 0, + "end": 64, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 6, + "column": 1 + } + }, + "errors": [ + "SyntaxError: Explicit inexact syntax cannot appear in class or interface definitions (4:2)", + "SyntaxError: Explicit inexact syntax must appear at the end of an inexact object (4:2)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 64, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 6, + "column": 1 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "DeclareClass", + "start": 8, + "end": 64, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 6, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 22, + "end": 23, + "loc": { + "start": { + "line": 2, + "column": 14 + }, + "end": { + "line": 2, + "column": 15 + }, + "identifierName": "D" + }, + "name": "D" + }, + "typeParameters": null, + "extends": [], + "implements": [], + "mixins": [], + "body": { + "type": "ObjectTypeAnnotation", + "start": 24, + "end": 64, + "loc": { + "start": { + "line": 2, + "column": 16 + }, + "end": { + "line": 6, + "column": 1 + } + }, + "callProperties": [], + "properties": [ + { + "type": "ObjectTypeProperty", + "start": 28, + "end": 39, + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 3, + "column": 13 + } + }, + "key": { + "type": "Identifier", + "start": 28, + "end": 31, + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 3, + "column": 5 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "static": false, + "proto": false, + "kind": "init", + "method": false, + "value": { + "type": "NumberTypeAnnotation", + "start": 33, + "end": 39, + "loc": { + "start": { + "line": 3, + "column": 7 + }, + "end": { + "line": 3, + "column": 13 + } + } + }, + "variance": null, + "optional": false + }, + { + "type": "ObjectTypeProperty", + "start": 50, + "end": 61, + "loc": { + "start": { + "line": 5, + "column": 2 + }, + "end": { + "line": 5, + "column": 13 + } + }, + "key": { + "type": "Identifier", + "start": 50, + "end": 53, + "loc": { + "start": { + "line": 5, + "column": 2 + }, + "end": { + "line": 5, + "column": 5 + }, + "identifierName": "bar" + }, + "name": "bar" + }, + "static": false, + "proto": false, + "kind": "init", + "method": false, + "value": { + "type": "NumberTypeAnnotation", + "start": 55, + "end": 61, + "loc": { + "start": { + "line": 5, + "column": 7 + }, + "end": { + "line": 5, + "column": 13 + } + } + }, + "variance": null, + "optional": false + } + ], + "indexers": [], + "internalSlots": [], + "exact": false + }, + "leadingComments": [ + { + "type": "CommentLine", + "value": "@flow", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + } + } + ] + } + ], + "directives": [] + }, + "comments": [ + { + "type": "CommentLine", + "value": "@flow", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + } + } + ] +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_disallowed_in_non_objects5/options.json b/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_disallowed_in_non_objects5/options.json deleted file mode 100644 index 658f8c434773..000000000000 --- a/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_disallowed_in_non_objects5/options.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "sourceType": "module", - "plugins": ["jsx", "flow"], - "throws": "Spread operator cannot appear in class or interface definitions (4:2)" -} diff --git a/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_disallowed_in_non_objects5/output.json b/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_disallowed_in_non_objects5/output.json new file mode 100644 index 000000000000..0f4fe47c8e64 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_disallowed_in_non_objects5/output.json @@ -0,0 +1,184 @@ +{ + "type": "File", + "start": 0, + "end": 45, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 5, + "column": 1 + } + }, + "errors": [ + "SyntaxError: Explicit inexact syntax cannot appear in class or interface definitions (4:2)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 45, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 5, + "column": 1 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "InterfaceDeclaration", + "start": 8, + "end": 45, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 5, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 18, + "end": 19, + "loc": { + "start": { + "line": 2, + "column": 10 + }, + "end": { + "line": 2, + "column": 11 + }, + "identifierName": "F" + }, + "name": "F" + }, + "typeParameters": null, + "extends": [], + "implements": [], + "mixins": [], + "body": { + "type": "ObjectTypeAnnotation", + "start": 20, + "end": 45, + "loc": { + "start": { + "line": 2, + "column": 12 + }, + "end": { + "line": 5, + "column": 1 + } + }, + "callProperties": [], + "properties": [ + { + "type": "ObjectTypeProperty", + "start": 24, + "end": 35, + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 3, + "column": 13 + } + }, + "key": { + "type": "Identifier", + "start": 24, + "end": 27, + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 3, + "column": 5 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "static": false, + "proto": false, + "kind": "init", + "method": false, + "value": { + "type": "NumberTypeAnnotation", + "start": 29, + "end": 35, + "loc": { + "start": { + "line": 3, + "column": 7 + }, + "end": { + "line": 3, + "column": 13 + } + } + }, + "variance": null, + "optional": false + } + ], + "indexers": [], + "internalSlots": [], + "exact": false + }, + "leadingComments": [ + { + "type": "CommentLine", + "value": "@flow", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + } + } + ] + } + ], + "directives": [] + }, + "comments": [ + { + "type": "CommentLine", + "value": "@flow", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + } + } + ] +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_disallowed_in_non_objects6/options.json b/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_disallowed_in_non_objects6/options.json index c9188366d4e8..d822c40fbba2 100644 --- a/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_disallowed_in_non_objects6/options.json +++ b/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_disallowed_in_non_objects6/options.json @@ -1,5 +1,4 @@ { "sourceType": "module", - "plugins": ["jsx", "flow"], - "throws": "Spread operator cannot appear in class or interface definitions (3:2)" + "plugins": ["jsx", "flow"] } diff --git a/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_disallowed_in_non_objects6/output.json b/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_disallowed_in_non_objects6/output.json new file mode 100644 index 000000000000..685bd5b4d17e --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_disallowed_in_non_objects6/output.json @@ -0,0 +1,185 @@ +{ + "type": "File", + "start": 0, + "end": 45, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 5, + "column": 1 + } + }, + "errors": [ + "SyntaxError: Explicit inexact syntax cannot appear in class or interface definitions (3:2)", + "SyntaxError: Explicit inexact syntax must appear at the end of an inexact object (3:2)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 45, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 5, + "column": 1 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "InterfaceDeclaration", + "start": 8, + "end": 45, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 5, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 18, + "end": 19, + "loc": { + "start": { + "line": 2, + "column": 10 + }, + "end": { + "line": 2, + "column": 11 + }, + "identifierName": "G" + }, + "name": "G" + }, + "typeParameters": null, + "extends": [], + "implements": [], + "mixins": [], + "body": { + "type": "ObjectTypeAnnotation", + "start": 20, + "end": 45, + "loc": { + "start": { + "line": 2, + "column": 12 + }, + "end": { + "line": 5, + "column": 1 + } + }, + "callProperties": [], + "properties": [ + { + "type": "ObjectTypeProperty", + "start": 31, + "end": 42, + "loc": { + "start": { + "line": 4, + "column": 2 + }, + "end": { + "line": 4, + "column": 13 + } + }, + "key": { + "type": "Identifier", + "start": 31, + "end": 34, + "loc": { + "start": { + "line": 4, + "column": 2 + }, + "end": { + "line": 4, + "column": 5 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "static": false, + "proto": false, + "kind": "init", + "method": false, + "value": { + "type": "NumberTypeAnnotation", + "start": 36, + "end": 42, + "loc": { + "start": { + "line": 4, + "column": 7 + }, + "end": { + "line": 4, + "column": 13 + } + } + }, + "variance": null, + "optional": false + } + ], + "indexers": [], + "internalSlots": [], + "exact": false + }, + "leadingComments": [ + { + "type": "CommentLine", + "value": "@flow", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + } + } + ] + } + ], + "directives": [] + }, + "comments": [ + { + "type": "CommentLine", + "value": "@flow", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + } + } + ] +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_disallowed_in_non_objects7/options.json b/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_disallowed_in_non_objects7/options.json index 658f8c434773..d822c40fbba2 100644 --- a/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_disallowed_in_non_objects7/options.json +++ b/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_disallowed_in_non_objects7/options.json @@ -1,5 +1,4 @@ { "sourceType": "module", - "plugins": ["jsx", "flow"], - "throws": "Spread operator cannot appear in class or interface definitions (4:2)" + "plugins": ["jsx", "flow"] } diff --git a/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_disallowed_in_non_objects7/output.json b/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_disallowed_in_non_objects7/output.json new file mode 100644 index 000000000000..37b85349439d --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_disallowed_in_non_objects7/output.json @@ -0,0 +1,238 @@ +{ + "type": "File", + "start": 0, + "end": 60, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 6, + "column": 1 + } + }, + "errors": [ + "SyntaxError: Explicit inexact syntax cannot appear in class or interface definitions (4:2)", + "SyntaxError: Explicit inexact syntax must appear at the end of an inexact object (4:2)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 60, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 6, + "column": 1 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "InterfaceDeclaration", + "start": 8, + "end": 60, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 6, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 18, + "end": 19, + "loc": { + "start": { + "line": 2, + "column": 10 + }, + "end": { + "line": 2, + "column": 11 + }, + "identifierName": "H" + }, + "name": "H" + }, + "typeParameters": null, + "extends": [], + "implements": [], + "mixins": [], + "body": { + "type": "ObjectTypeAnnotation", + "start": 20, + "end": 60, + "loc": { + "start": { + "line": 2, + "column": 12 + }, + "end": { + "line": 6, + "column": 1 + } + }, + "callProperties": [], + "properties": [ + { + "type": "ObjectTypeProperty", + "start": 24, + "end": 35, + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 3, + "column": 13 + } + }, + "key": { + "type": "Identifier", + "start": 24, + "end": 27, + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 3, + "column": 5 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "static": false, + "proto": false, + "kind": "init", + "method": false, + "value": { + "type": "NumberTypeAnnotation", + "start": 29, + "end": 35, + "loc": { + "start": { + "line": 3, + "column": 7 + }, + "end": { + "line": 3, + "column": 13 + } + } + }, + "variance": null, + "optional": false + }, + { + "type": "ObjectTypeProperty", + "start": 46, + "end": 57, + "loc": { + "start": { + "line": 5, + "column": 2 + }, + "end": { + "line": 5, + "column": 13 + } + }, + "key": { + "type": "Identifier", + "start": 46, + "end": 49, + "loc": { + "start": { + "line": 5, + "column": 2 + }, + "end": { + "line": 5, + "column": 5 + }, + "identifierName": "bar" + }, + "name": "bar" + }, + "static": false, + "proto": false, + "kind": "init", + "method": false, + "value": { + "type": "NumberTypeAnnotation", + "start": 51, + "end": 57, + "loc": { + "start": { + "line": 5, + "column": 7 + }, + "end": { + "line": 5, + "column": 13 + } + } + }, + "variance": null, + "optional": false + } + ], + "indexers": [], + "internalSlots": [], + "exact": false + }, + "leadingComments": [ + { + "type": "CommentLine", + "value": "@flow", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + } + } + ] + } + ], + "directives": [] + }, + "comments": [ + { + "type": "CommentLine", + "value": "@flow", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + } + } + ] +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_forbidden_in_exact/options.json b/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_forbidden_in_exact/options.json index 49936ac94990..d822c40fbba2 100644 --- a/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_forbidden_in_exact/options.json +++ b/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_forbidden_in_exact/options.json @@ -1,5 +1,4 @@ { "sourceType": "module", - "plugins": ["jsx", "flow"], - "throws": "Explicit inexact syntax cannot appear inside an explicit exact object type (2:29)" + "plugins": ["jsx", "flow"] } diff --git a/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_forbidden_in_exact/output.json b/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_forbidden_in_exact/output.json new file mode 100644 index 000000000000..98ff5ceeead4 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_forbidden_in_exact/output.json @@ -0,0 +1,182 @@ +{ + "type": "File", + "start": 0, + "end": 39, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 31 + } + }, + "errors": [ + "SyntaxError: Explicit inexact syntax cannot appear inside an explicit exact object type (2:25)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 39, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 31 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "TypeAlias", + "start": 8, + "end": 39, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 31 + } + }, + "id": { + "type": "Identifier", + "start": 13, + "end": 14, + "loc": { + "start": { + "line": 2, + "column": 5 + }, + "end": { + "line": 2, + "column": 6 + }, + "identifierName": "T" + }, + "name": "T" + }, + "typeParameters": null, + "right": { + "type": "ObjectTypeAnnotation", + "start": 17, + "end": 39, + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 31 + } + }, + "callProperties": [], + "properties": [ + { + "type": "ObjectTypeProperty", + "start": 20, + "end": 31, + "loc": { + "start": { + "line": 2, + "column": 12 + }, + "end": { + "line": 2, + "column": 23 + } + }, + "key": { + "type": "Identifier", + "start": 20, + "end": 23, + "loc": { + "start": { + "line": 2, + "column": 12 + }, + "end": { + "line": 2, + "column": 15 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "static": false, + "proto": false, + "kind": "init", + "method": false, + "value": { + "type": "NumberTypeAnnotation", + "start": 25, + "end": 31, + "loc": { + "start": { + "line": 2, + "column": 17 + }, + "end": { + "line": 2, + "column": 23 + } + } + }, + "variance": null, + "optional": false + } + ], + "indexers": [], + "internalSlots": [], + "exact": true, + "inexact": true + }, + "leadingComments": [ + { + "type": "CommentLine", + "value": "@flow", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + } + } + ] + } + ], + "directives": [] + }, + "comments": [ + { + "type": "CommentLine", + "value": "@flow", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + } + } + ] +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_must_appear_last/options.json b/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_must_appear_last/options.json index ebb74417a527..d822c40fbba2 100644 --- a/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_must_appear_last/options.json +++ b/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_must_appear_last/options.json @@ -1,5 +1,4 @@ { "sourceType": "module", - "plugins": ["jsx", "flow"], - "throws": "Explicit inexact syntax must appear at the end of an inexact object (2:15)" + "plugins": ["jsx", "flow"] } diff --git a/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_must_appear_last/output.json b/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_must_appear_last/output.json new file mode 100644 index 000000000000..24b9575138dc --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_must_appear_last/output.json @@ -0,0 +1,182 @@ +{ + "type": "File", + "start": 0, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 28 + } + }, + "errors": [ + "SyntaxError: Explicit inexact syntax must appear at the end of an inexact object (2:10)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 28 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "TypeAlias", + "start": 8, + "end": 36, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 28 + } + }, + "id": { + "type": "Identifier", + "start": 13, + "end": 14, + "loc": { + "start": { + "line": 2, + "column": 5 + }, + "end": { + "line": 2, + "column": 6 + }, + "identifierName": "T" + }, + "name": "T" + }, + "typeParameters": null, + "right": { + "type": "ObjectTypeAnnotation", + "start": 17, + "end": 35, + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 27 + } + }, + "callProperties": [], + "properties": [ + { + "type": "ObjectTypeProperty", + "start": 23, + "end": 34, + "loc": { + "start": { + "line": 2, + "column": 15 + }, + "end": { + "line": 2, + "column": 26 + } + }, + "key": { + "type": "Identifier", + "start": 23, + "end": 26, + "loc": { + "start": { + "line": 2, + "column": 15 + }, + "end": { + "line": 2, + "column": 18 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "static": false, + "proto": false, + "kind": "init", + "method": false, + "value": { + "type": "NumberTypeAnnotation", + "start": 28, + "end": 34, + "loc": { + "start": { + "line": 2, + "column": 20 + }, + "end": { + "line": 2, + "column": 26 + } + } + }, + "variance": null, + "optional": false + } + ], + "indexers": [], + "internalSlots": [], + "exact": false, + "inexact": true + }, + "leadingComments": [ + { + "type": "CommentLine", + "value": "@flow", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + } + } + ] + } + ], + "directives": [] + }, + "comments": [ + { + "type": "CommentLine", + "value": "@flow", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + } + } + ] +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_object_invalid1/options.json b/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_object_invalid1/options.json index 6d703769bf61..d822c40fbba2 100644 --- a/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_object_invalid1/options.json +++ b/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_object_invalid1/options.json @@ -1,5 +1,4 @@ { "sourceType": "module", - "plugins": ["jsx", "flow"], - "throws": "Explicit inexact syntax must appear at the end of an inexact object (2:26)" + "plugins": ["jsx", "flow"] } diff --git a/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_object_invalid1/output.json b/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_object_invalid1/output.json new file mode 100644 index 000000000000..8efbd4b84fe9 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_object_invalid1/output.json @@ -0,0 +1,235 @@ +{ + "type": "File", + "start": 0, + "end": 45, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 37 + } + }, + "errors": [ + "SyntaxError: Explicit inexact syntax must appear at the end of an inexact object (2:21)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 45, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 37 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "TypeAlias", + "start": 8, + "end": 45, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 37 + } + }, + "id": { + "type": "Identifier", + "start": 13, + "end": 14, + "loc": { + "start": { + "line": 2, + "column": 5 + }, + "end": { + "line": 2, + "column": 6 + }, + "identifierName": "T" + }, + "name": "T" + }, + "typeParameters": null, + "right": { + "type": "ObjectTypeAnnotation", + "start": 17, + "end": 44, + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 36 + } + }, + "callProperties": [], + "properties": [ + { + "type": "ObjectTypeProperty", + "start": 18, + "end": 27, + "loc": { + "start": { + "line": 2, + "column": 10 + }, + "end": { + "line": 2, + "column": 19 + } + }, + "key": { + "type": "Identifier", + "start": 18, + "end": 19, + "loc": { + "start": { + "line": 2, + "column": 10 + }, + "end": { + "line": 2, + "column": 11 + }, + "identifierName": "x" + }, + "name": "x" + }, + "static": false, + "proto": false, + "kind": "init", + "method": false, + "value": { + "type": "NumberTypeAnnotation", + "start": 21, + "end": 27, + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 19 + } + } + }, + "variance": null, + "optional": false + }, + { + "type": "ObjectTypeProperty", + "start": 34, + "end": 43, + "loc": { + "start": { + "line": 2, + "column": 26 + }, + "end": { + "line": 2, + "column": 35 + } + }, + "key": { + "type": "Identifier", + "start": 34, + "end": 35, + "loc": { + "start": { + "line": 2, + "column": 26 + }, + "end": { + "line": 2, + "column": 27 + }, + "identifierName": "y" + }, + "name": "y" + }, + "static": false, + "proto": false, + "kind": "init", + "method": false, + "value": { + "type": "NumberTypeAnnotation", + "start": 37, + "end": 43, + "loc": { + "start": { + "line": 2, + "column": 29 + }, + "end": { + "line": 2, + "column": 35 + } + } + }, + "variance": null, + "optional": false + } + ], + "indexers": [], + "internalSlots": [], + "exact": false, + "inexact": true + }, + "leadingComments": [ + { + "type": "CommentLine", + "value": "@flow", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + } + } + ] + } + ], + "directives": [] + }, + "comments": [ + { + "type": "CommentLine", + "value": "@flow", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + } + } + ] +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_object_invalid2/options.json b/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_object_invalid2/options.json index 6d703769bf61..d822c40fbba2 100644 --- a/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_object_invalid2/options.json +++ b/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_object_invalid2/options.json @@ -1,5 +1,4 @@ { "sourceType": "module", - "plugins": ["jsx", "flow"], - "throws": "Explicit inexact syntax must appear at the end of an inexact object (2:26)" + "plugins": ["jsx", "flow"] } diff --git a/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_object_invalid2/output.json b/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_object_invalid2/output.json new file mode 100644 index 000000000000..fe5b3ee400f9 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_object_invalid2/output.json @@ -0,0 +1,182 @@ +{ + "type": "File", + "start": 0, + "end": 39, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 31 + } + }, + "errors": [ + "SyntaxError: Explicit inexact syntax must appear at the end of an inexact object (2:21)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 39, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 31 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "TypeAlias", + "start": 8, + "end": 39, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 31 + } + }, + "id": { + "type": "Identifier", + "start": 13, + "end": 14, + "loc": { + "start": { + "line": 2, + "column": 5 + }, + "end": { + "line": 2, + "column": 6 + }, + "identifierName": "U" + }, + "name": "U" + }, + "typeParameters": null, + "right": { + "type": "ObjectTypeAnnotation", + "start": 17, + "end": 38, + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 30 + } + }, + "callProperties": [], + "properties": [ + { + "type": "ObjectTypeProperty", + "start": 18, + "end": 27, + "loc": { + "start": { + "line": 2, + "column": 10 + }, + "end": { + "line": 2, + "column": 19 + } + }, + "key": { + "type": "Identifier", + "start": 18, + "end": 19, + "loc": { + "start": { + "line": 2, + "column": 10 + }, + "end": { + "line": 2, + "column": 11 + }, + "identifierName": "x" + }, + "name": "x" + }, + "static": false, + "proto": false, + "kind": "init", + "method": false, + "value": { + "type": "NumberTypeAnnotation", + "start": 21, + "end": 27, + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 19 + } + } + }, + "variance": null, + "optional": false + } + ], + "indexers": [], + "internalSlots": [], + "exact": false, + "inexact": true + }, + "leadingComments": [ + { + "type": "CommentLine", + "value": "@flow", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + } + } + ] + } + ], + "directives": [] + }, + "comments": [ + { + "type": "CommentLine", + "value": "@flow", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + } + } + ] +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_object_invalid3/options.json b/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_object_invalid3/options.json index 6d703769bf61..d822c40fbba2 100644 --- a/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_object_invalid3/options.json +++ b/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_object_invalid3/options.json @@ -1,5 +1,4 @@ { "sourceType": "module", - "plugins": ["jsx", "flow"], - "throws": "Explicit inexact syntax must appear at the end of an inexact object (2:26)" + "plugins": ["jsx", "flow"] } diff --git a/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_object_invalid3/output.json b/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_object_invalid3/output.json new file mode 100644 index 000000000000..0bedbf8f82e4 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/explicit-inexact-object/explicit_inexact_object_invalid3/output.json @@ -0,0 +1,230 @@ +{ + "type": "File", + "start": 0, + "end": 40, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 32 + } + }, + "errors": [ + "SyntaxError: Explicit inexact syntax must appear at the end of an inexact object (2:21)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 40, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 32 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "TypeAlias", + "start": 8, + "end": 40, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 32 + } + }, + "id": { + "type": "Identifier", + "start": 13, + "end": 14, + "loc": { + "start": { + "line": 2, + "column": 5 + }, + "end": { + "line": 2, + "column": 6 + }, + "identifierName": "V" + }, + "name": "V" + }, + "typeParameters": null, + "right": { + "type": "ObjectTypeAnnotation", + "start": 17, + "end": 39, + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 31 + } + }, + "callProperties": [], + "properties": [ + { + "type": "ObjectTypeProperty", + "start": 18, + "end": 27, + "loc": { + "start": { + "line": 2, + "column": 10 + }, + "end": { + "line": 2, + "column": 19 + } + }, + "key": { + "type": "Identifier", + "start": 18, + "end": 19, + "loc": { + "start": { + "line": 2, + "column": 10 + }, + "end": { + "line": 2, + "column": 11 + }, + "identifierName": "x" + }, + "name": "x" + }, + "static": false, + "proto": false, + "kind": "init", + "method": false, + "value": { + "type": "NumberTypeAnnotation", + "start": 21, + "end": 27, + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 19 + } + } + }, + "variance": null, + "optional": false + }, + { + "type": "ObjectTypeSpreadProperty", + "start": 34, + "end": 38, + "loc": { + "start": { + "line": 2, + "column": 26 + }, + "end": { + "line": 2, + "column": 30 + } + }, + "argument": { + "type": "GenericTypeAnnotation", + "start": 37, + "end": 38, + "loc": { + "start": { + "line": 2, + "column": 29 + }, + "end": { + "line": 2, + "column": 30 + } + }, + "typeParameters": null, + "id": { + "type": "Identifier", + "start": 37, + "end": 38, + "loc": { + "start": { + "line": 2, + "column": 29 + }, + "end": { + "line": 2, + "column": 30 + }, + "identifierName": "X" + }, + "name": "X" + } + } + } + ], + "indexers": [], + "internalSlots": [], + "exact": false, + "inexact": true + }, + "leadingComments": [ + { + "type": "CommentLine", + "value": "@flow", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + } + } + ] + } + ], + "directives": [] + }, + "comments": [ + { + "type": "CommentLine", + "value": "@flow", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + } + } + ] +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/interfaces-module-and-script/id-reserved-type-invalid/options.json b/packages/babel-parser/test/fixtures/flow/interfaces-module-and-script/id-reserved-type-invalid/options.json deleted file mode 100644 index b945b9a0a123..000000000000 --- a/packages/babel-parser/test/fixtures/flow/interfaces-module-and-script/id-reserved-type-invalid/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Cannot overwrite reserved type string (1:10)" -} diff --git a/packages/babel-parser/test/fixtures/flow/interfaces-module-and-script/id-reserved-type-invalid/output.json b/packages/babel-parser/test/fixtures/flow/interfaces-module-and-script/id-reserved-type-invalid/output.json new file mode 100644 index 000000000000..b4b12c31dccb --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/interfaces-module-and-script/id-reserved-type-invalid/output.json @@ -0,0 +1,94 @@ +{ + "type": "File", + "start": 0, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "errors": [ + "SyntaxError: Cannot overwrite reserved type string (1:10)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "InterfaceDeclaration", + "start": 0, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "id": { + "type": "Identifier", + "start": 10, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 16 + }, + "identifierName": "string" + }, + "name": "string" + }, + "typeParameters": null, + "extends": [], + "implements": [], + "mixins": [], + "body": { + "type": "ObjectTypeAnnotation", + "start": 17, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "callProperties": [], + "properties": [], + "indexers": [], + "internalSlots": [], + "exact": false + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/interfaces-module-and-script/implements-reserved-type-invalid/options.json b/packages/babel-parser/test/fixtures/flow/interfaces-module-and-script/implements-reserved-type-invalid/options.json deleted file mode 100644 index 7aecee1ff0ae..000000000000 --- a/packages/babel-parser/test/fixtures/flow/interfaces-module-and-script/implements-reserved-type-invalid/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Cannot overwrite reserved type string (1:21)" -} diff --git a/packages/babel-parser/test/fixtures/flow/interfaces-module-and-script/implements-reserved-type-invalid/output.json b/packages/babel-parser/test/fixtures/flow/interfaces-module-and-script/implements-reserved-type-invalid/output.json new file mode 100644 index 000000000000..1765354398c7 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/interfaces-module-and-script/implements-reserved-type-invalid/output.json @@ -0,0 +1,122 @@ +{ + "type": "File", + "start": 0, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "errors": [ + "SyntaxError: Cannot overwrite reserved type string (1:21)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ClassDeclaration", + "start": 0, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "id": { + "type": "Identifier", + "start": 6, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 9 + }, + "identifierName": "Foo" + }, + "name": "Foo" + }, + "superClass": null, + "implements": [ + { + "type": "ClassImplements", + "start": 21, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 21 + }, + "end": { + "line": 1, + "column": 27 + } + }, + "id": { + "type": "Identifier", + "start": 21, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 21 + }, + "end": { + "line": 1, + "column": 27 + }, + "identifierName": "string" + }, + "name": "string" + }, + "typeParameters": null + } + ], + "body": { + "type": "ClassBody", + "start": 28, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 28 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "body": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/iterator/03/options.json b/packages/babel-parser/test/fixtures/flow/iterator/03/options.json deleted file mode 100644 index 7bad2fe143ae..000000000000 --- a/packages/babel-parser/test/fixtures/flow/iterator/03/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid identifier @@asyncIterator (1:19)" -} diff --git a/packages/babel-parser/test/fixtures/flow/iterator/03/output.json b/packages/babel-parser/test/fixtures/flow/iterator/03/output.json new file mode 100644 index 000000000000..cac241733955 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/iterator/03/output.json @@ -0,0 +1,89 @@ +{ + "type": "File", + "start": 0, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "errors": [ + "SyntaxError: Invalid identifier @@asyncIterator (1:19)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "VariableDeclaration", + "start": 0, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 4, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "id": { + "type": "Identifier", + "start": 4, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 19 + }, + "identifierName": "@@asyncIterator" + }, + "name": "@@asyncIterator" + }, + "init": null + } + ], + "kind": "var" + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/iterator/04/options.json b/packages/babel-parser/test/fixtures/flow/iterator/04/options.json deleted file mode 100644 index ae3871cf99a0..000000000000 --- a/packages/babel-parser/test/fixtures/flow/iterator/04/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid identifier @@iterator (1:14)" -} diff --git a/packages/babel-parser/test/fixtures/flow/iterator/04/output.json b/packages/babel-parser/test/fixtures/flow/iterator/04/output.json new file mode 100644 index 000000000000..e86fe7ccc7a0 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/iterator/04/output.json @@ -0,0 +1,89 @@ +{ + "type": "File", + "start": 0, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "errors": [ + "SyntaxError: Invalid identifier @@iterator (1:14)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "VariableDeclaration", + "start": 0, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 4, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "id": { + "type": "Identifier", + "start": 4, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 14 + }, + "identifierName": "@@iterator" + }, + "name": "@@iterator" + }, + "init": null + } + ], + "kind": "var" + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/iterator/05/options.json b/packages/babel-parser/test/fixtures/flow/iterator/05/options.json deleted file mode 100644 index 9d235ec74a06..000000000000 --- a/packages/babel-parser/test/fixtures/flow/iterator/05/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid identifier @@asyncIterator (2:17)" -} diff --git a/packages/babel-parser/test/fixtures/flow/iterator/05/output.json b/packages/babel-parser/test/fixtures/flow/iterator/05/output.json new file mode 100644 index 000000000000..a5e29cf34dc2 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/iterator/05/output.json @@ -0,0 +1,144 @@ +{ + "type": "File", + "start": 0, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "errors": [ + "SyntaxError: Invalid identifier @@asyncIterator (2:17)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ClassDeclaration", + "start": 0, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 6, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + }, + "identifierName": "T" + }, + "name": "T" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "start": 8, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "body": [ + { + "type": "ClassMethod", + "start": 12, + "end": 31, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 21 + } + }, + "static": false, + "key": { + "type": "Identifier", + "start": 12, + "end": 27, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 17 + }, + "identifierName": "@@asyncIterator" + }, + "name": "@@asyncIterator" + }, + "computed": false, + "kind": "method", + "id": null, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 29, + "end": 31, + "loc": { + "start": { + "line": 2, + "column": 19 + }, + "end": { + "line": 2, + "column": 21 + } + }, + "body": [], + "directives": [] + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/iterator/06/options.json b/packages/babel-parser/test/fixtures/flow/iterator/06/options.json deleted file mode 100644 index 515a2cba19f8..000000000000 --- a/packages/babel-parser/test/fixtures/flow/iterator/06/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid identifier @@iterator (2:12)" -} diff --git a/packages/babel-parser/test/fixtures/flow/iterator/06/output.json b/packages/babel-parser/test/fixtures/flow/iterator/06/output.json new file mode 100644 index 000000000000..08e5603a221c --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/iterator/06/output.json @@ -0,0 +1,144 @@ +{ + "type": "File", + "start": 0, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "errors": [ + "SyntaxError: Invalid identifier @@iterator (2:12)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ClassDeclaration", + "start": 0, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 6, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + }, + "identifierName": "T" + }, + "name": "T" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "start": 8, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "body": [ + { + "type": "ClassMethod", + "start": 12, + "end": 26, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 16 + } + }, + "static": false, + "key": { + "type": "Identifier", + "start": 12, + "end": 22, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 12 + }, + "identifierName": "@@iterator" + }, + "name": "@@iterator" + }, + "computed": false, + "kind": "method", + "id": null, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 24, + "end": 26, + "loc": { + "start": { + "line": 2, + "column": 14 + }, + "end": { + "line": 2, + "column": 16 + } + }, + "body": [], + "directives": [] + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/iterator/07/options.json b/packages/babel-parser/test/fixtures/flow/iterator/07/options.json deleted file mode 100644 index 4c1f323d1622..000000000000 --- a/packages/babel-parser/test/fixtures/flow/iterator/07/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid identifier @@iterator (1:15)" -} diff --git a/packages/babel-parser/test/fixtures/flow/iterator/07/output.json b/packages/babel-parser/test/fixtures/flow/iterator/07/output.json new file mode 100644 index 000000000000..60d612821347 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/iterator/07/output.json @@ -0,0 +1,86 @@ +{ + "type": "File", + "start": 0, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "errors": [ + "SyntaxError: Invalid identifier @@iterator (1:15)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "TypeAlias", + "start": 0, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "id": { + "type": "Identifier", + "start": 5, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 15 + }, + "identifierName": "@@iterator" + }, + "name": "@@iterator" + }, + "typeParameters": null, + "right": { + "type": "NumberTypeAnnotation", + "start": 18, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 24 + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/iterator/08/options.json b/packages/babel-parser/test/fixtures/flow/iterator/08/options.json deleted file mode 100644 index 3efa2ffcd0a1..000000000000 --- a/packages/babel-parser/test/fixtures/flow/iterator/08/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid identifier @@asyncIterator (1:20)" -} diff --git a/packages/babel-parser/test/fixtures/flow/iterator/08/output.json b/packages/babel-parser/test/fixtures/flow/iterator/08/output.json new file mode 100644 index 000000000000..3994f46fa03e --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/iterator/08/output.json @@ -0,0 +1,86 @@ +{ + "type": "File", + "start": 0, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "errors": [ + "SyntaxError: Invalid identifier @@asyncIterator (1:20)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "TypeAlias", + "start": 0, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "id": { + "type": "Identifier", + "start": 5, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 20 + }, + "identifierName": "@@asyncIterator" + }, + "name": "@@asyncIterator" + }, + "typeParameters": null, + "right": { + "type": "NumberTypeAnnotation", + "start": 23, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 23 + }, + "end": { + "line": 1, + "column": 29 + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/iterator/09/options.json b/packages/babel-parser/test/fixtures/flow/iterator/09/options.json deleted file mode 100644 index 515a2cba19f8..000000000000 --- a/packages/babel-parser/test/fixtures/flow/iterator/09/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid identifier @@iterator (2:12)" -} diff --git a/packages/babel-parser/test/fixtures/flow/iterator/09/output.json b/packages/babel-parser/test/fixtures/flow/iterator/09/output.json new file mode 100644 index 000000000000..95c09f5b7c60 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/iterator/09/output.json @@ -0,0 +1,161 @@ +{ + "type": "File", + "start": 0, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "errors": [ + "SyntaxError: Invalid identifier @@iterator (2:12)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "VariableDeclaration", + "start": 0, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 4, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 4, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 5 + }, + "identifierName": "x" + }, + "name": "x" + }, + "init": { + "type": "ObjectExpression", + "start": 8, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "properties": [ + { + "type": "ObjectMethod", + "start": 12, + "end": 27, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 17 + } + }, + "method": true, + "key": { + "type": "Identifier", + "start": 12, + "end": 22, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 12 + }, + "identifierName": "@@iterator" + }, + "name": "@@iterator" + }, + "computed": false, + "kind": "method", + "id": null, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 25, + "end": 27, + "loc": { + "start": { + "line": 2, + "column": 15 + }, + "end": { + "line": 2, + "column": 17 + } + }, + "body": [], + "directives": [] + } + } + ] + } + } + ], + "kind": "let" + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/iterator/10/options.json b/packages/babel-parser/test/fixtures/flow/iterator/10/options.json deleted file mode 100644 index 9d235ec74a06..000000000000 --- a/packages/babel-parser/test/fixtures/flow/iterator/10/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid identifier @@asyncIterator (2:17)" -} diff --git a/packages/babel-parser/test/fixtures/flow/iterator/10/output.json b/packages/babel-parser/test/fixtures/flow/iterator/10/output.json new file mode 100644 index 000000000000..9e58c564ebbf --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/iterator/10/output.json @@ -0,0 +1,161 @@ +{ + "type": "File", + "start": 0, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "errors": [ + "SyntaxError: Invalid identifier @@asyncIterator (2:17)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "VariableDeclaration", + "start": 0, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 4, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 4, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 5 + }, + "identifierName": "x" + }, + "name": "x" + }, + "init": { + "type": "ObjectExpression", + "start": 8, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "properties": [ + { + "type": "ObjectMethod", + "start": 12, + "end": 32, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 22 + } + }, + "method": true, + "key": { + "type": "Identifier", + "start": 12, + "end": 27, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 17 + }, + "identifierName": "@@asyncIterator" + }, + "name": "@@asyncIterator" + }, + "computed": false, + "kind": "method", + "id": null, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 30, + "end": 32, + "loc": { + "start": { + "line": 2, + "column": 20 + }, + "end": { + "line": 2, + "column": 22 + } + }, + "body": [], + "directives": [] + } + } + ] + } + } + ], + "kind": "let" + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/iterator/11/options.json b/packages/babel-parser/test/fixtures/flow/iterator/11/options.json deleted file mode 100644 index 248b8a4d9d0a..000000000000 --- a/packages/babel-parser/test/fixtures/flow/iterator/11/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid identifier @@random (2:10)" -} diff --git a/packages/babel-parser/test/fixtures/flow/iterator/11/output.json b/packages/babel-parser/test/fixtures/flow/iterator/11/output.json new file mode 100644 index 000000000000..b43086a4226b --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/iterator/11/output.json @@ -0,0 +1,161 @@ +{ + "type": "File", + "start": 0, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "errors": [ + "SyntaxError: Invalid identifier @@random (2:10)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "VariableDeclaration", + "start": 0, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 4, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 4, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 5 + }, + "identifierName": "x" + }, + "name": "x" + }, + "init": { + "type": "ObjectExpression", + "start": 8, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "properties": [ + { + "type": "ObjectMethod", + "start": 12, + "end": 25, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 15 + } + }, + "method": true, + "key": { + "type": "Identifier", + "start": 12, + "end": 20, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 10 + }, + "identifierName": "@@random" + }, + "name": "@@random" + }, + "computed": false, + "kind": "method", + "id": null, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 23, + "end": 25, + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 15 + } + }, + "body": [], + "directives": [] + } + } + ] + } + } + ], + "kind": "let" + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/multiple-declarations/class/options.json b/packages/babel-parser/test/fixtures/flow/multiple-declarations/class/options.json index 06ad6ded6032..3962be507d38 100644 --- a/packages/babel-parser/test/fixtures/flow/multiple-declarations/class/options.json +++ b/packages/babel-parser/test/fixtures/flow/multiple-declarations/class/options.json @@ -3,6 +3,5 @@ "plugins": [ "jsx", "flow" - ], - "throws": "Identifier 'C1' has already been declared (2:6)" + ] } \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/multiple-declarations/class/output.json b/packages/babel-parser/test/fixtures/flow/multiple-declarations/class/output.json new file mode 100644 index 000000000000..c350f1ed1904 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/multiple-declarations/class/output.json @@ -0,0 +1,143 @@ +{ + "type": "File", + "start": 0, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 11 + } + }, + "errors": [ + "SyntaxError: Identifier 'C1' has already been declared (2:6)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 11 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "DeclareClass", + "start": 0, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "id": { + "type": "Identifier", + "start": 14, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 16 + }, + "identifierName": "C1" + }, + "name": "C1" + }, + "typeParameters": null, + "extends": [], + "implements": [], + "mixins": [], + "body": { + "type": "ObjectTypeAnnotation", + "start": 17, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "callProperties": [], + "properties": [], + "indexers": [], + "internalSlots": [], + "exact": false + } + }, + { + "type": "ClassDeclaration", + "start": 20, + "end": 31, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 11 + } + }, + "id": { + "type": "Identifier", + "start": 26, + "end": 28, + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 8 + }, + "identifierName": "C1" + }, + "name": "C1" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "start": 29, + "end": 31, + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 11 + } + }, + "body": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/multiple-declarations/interface/options.json b/packages/babel-parser/test/fixtures/flow/multiple-declarations/interface/options.json index 5672ce1b6444..3962be507d38 100644 --- a/packages/babel-parser/test/fixtures/flow/multiple-declarations/interface/options.json +++ b/packages/babel-parser/test/fixtures/flow/multiple-declarations/interface/options.json @@ -3,6 +3,5 @@ "plugins": [ "jsx", "flow" - ], - "throws": "Identifier 'I' has already been declared (2:10)" + ] } \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/multiple-declarations/interface/output.json b/packages/babel-parser/test/fixtures/flow/multiple-declarations/interface/output.json new file mode 100644 index 000000000000..823ca9be9eac --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/multiple-declarations/interface/output.json @@ -0,0 +1,180 @@ +{ + "type": "File", + "start": 0, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 15 + } + }, + "errors": [ + "SyntaxError: Identifier 'I' has already been declared (2:10)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 15 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "InterfaceDeclaration", + "start": 0, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "id": { + "type": "Identifier", + "start": 10, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 11 + }, + "identifierName": "I" + }, + "name": "I" + }, + "typeParameters": null, + "extends": [], + "implements": [], + "mixins": [], + "body": { + "type": "ObjectTypeAnnotation", + "start": 12, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "callProperties": [], + "properties": [], + "indexers": [], + "internalSlots": [], + "exact": false + } + }, + { + "type": "EmptyStatement", + "start": 14, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 15 + } + } + }, + { + "type": "InterfaceDeclaration", + "start": 16, + "end": 30, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 14 + } + }, + "id": { + "type": "Identifier", + "start": 26, + "end": 27, + "loc": { + "start": { + "line": 2, + "column": 10 + }, + "end": { + "line": 2, + "column": 11 + }, + "identifierName": "I" + }, + "name": "I" + }, + "typeParameters": null, + "extends": [], + "implements": [], + "mixins": [], + "body": { + "type": "ObjectTypeAnnotation", + "start": 28, + "end": 30, + "loc": { + "start": { + "line": 2, + "column": 12 + }, + "end": { + "line": 2, + "column": 14 + } + }, + "callProperties": [], + "properties": [], + "indexers": [], + "internalSlots": [], + "exact": false + } + }, + { + "type": "EmptyStatement", + "start": 30, + "end": 31, + "loc": { + "start": { + "line": 2, + "column": 14 + }, + "end": { + "line": 2, + "column": 15 + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/multiple-declarations/type/options.json b/packages/babel-parser/test/fixtures/flow/multiple-declarations/type/options.json index 946261f4e872..3962be507d38 100644 --- a/packages/babel-parser/test/fixtures/flow/multiple-declarations/type/options.json +++ b/packages/babel-parser/test/fixtures/flow/multiple-declarations/type/options.json @@ -3,6 +3,5 @@ "plugins": [ "jsx", "flow" - ], - "throws": "Identifier 'T1' has already been declared (2:5)" + ] } \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/multiple-declarations/type/output.json b/packages/babel-parser/test/fixtures/flow/multiple-declarations/type/output.json new file mode 100644 index 000000000000..080077918fd1 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/multiple-declarations/type/output.json @@ -0,0 +1,134 @@ +{ + "type": "File", + "start": 0, + "end": 35, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 17 + } + }, + "errors": [ + "SyntaxError: Identifier 'T1' has already been declared (2:5)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 35, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 17 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "TypeAlias", + "start": 0, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "id": { + "type": "Identifier", + "start": 5, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 7 + }, + "identifierName": "T1" + }, + "name": "T1" + }, + "typeParameters": null, + "right": { + "type": "StringTypeAnnotation", + "start": 10, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 16 + } + } + } + }, + { + "type": "TypeAlias", + "start": 18, + "end": 35, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 17 + } + }, + "id": { + "type": "Identifier", + "start": 23, + "end": 25, + "loc": { + "start": { + "line": 2, + "column": 5 + }, + "end": { + "line": 2, + "column": 7 + }, + "identifierName": "T1" + }, + "name": "T1" + }, + "typeParameters": null, + "right": { + "type": "NumberTypeAnnotation", + "start": 28, + "end": 34, + "loc": { + "start": { + "line": 2, + "column": 10 + }, + "end": { + "line": 2, + "column": 16 + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/object-types/invalid-getter-param-count-rest/options.json b/packages/babel-parser/test/fixtures/flow/object-types/invalid-getter-param-count-rest/options.json deleted file mode 100644 index 65bc24a66fcd..000000000000 --- a/packages/babel-parser/test/fixtures/flow/object-types/invalid-getter-param-count-rest/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "getter must not have any formal parameters (2:2)" -} diff --git a/packages/babel-parser/test/fixtures/flow/object-types/invalid-getter-param-count-rest/output.json b/packages/babel-parser/test/fixtures/flow/object-types/invalid-getter-param-count-rest/output.json new file mode 100644 index 000000000000..efdc8832124e --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/object-types/invalid-getter-param-count-rest/output.json @@ -0,0 +1,212 @@ +{ + "type": "File", + "start": 0, + "end": 37, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "errors": [ + "SyntaxError: getter must not have any formal parameters (2:2)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 37, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "TypeAlias", + "start": 0, + "end": 37, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 5, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 6 + }, + "identifierName": "B" + }, + "name": "B" + }, + "typeParameters": null, + "right": { + "type": "ObjectTypeAnnotation", + "start": 9, + "end": 37, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "callProperties": [], + "properties": [ + { + "type": "ObjectTypeProperty", + "start": 13, + "end": 34, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 23 + } + }, + "key": { + "type": "Identifier", + "start": 17, + "end": 18, + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 7 + }, + "identifierName": "a" + }, + "name": "a" + }, + "static": false, + "proto": false, + "kind": "get", + "method": true, + "value": { + "type": "FunctionTypeAnnotation", + "start": 13, + "end": 34, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 23 + } + }, + "params": [], + "rest": { + "type": "FunctionTypeParam", + "start": 22, + "end": 25, + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 14 + } + }, + "name": null, + "optional": false, + "typeAnnotation": { + "type": "GenericTypeAnnotation", + "start": 22, + "end": 25, + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 14 + } + }, + "typeParameters": null, + "id": { + "type": "Identifier", + "start": 22, + "end": 25, + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 14 + }, + "identifierName": "foo" + }, + "name": "foo" + } + } + }, + "typeParameters": null, + "returnType": { + "type": "NumberTypeAnnotation", + "start": 28, + "end": 34, + "loc": { + "start": { + "line": 2, + "column": 17 + }, + "end": { + "line": 2, + "column": 23 + } + } + } + }, + "optional": false + } + ], + "indexers": [], + "internalSlots": [], + "exact": false, + "inexact": false + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/object-types/invalid-getter-param-count/options.json b/packages/babel-parser/test/fixtures/flow/object-types/invalid-getter-param-count/options.json deleted file mode 100644 index 65bc24a66fcd..000000000000 --- a/packages/babel-parser/test/fixtures/flow/object-types/invalid-getter-param-count/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "getter must not have any formal parameters (2:2)" -} diff --git a/packages/babel-parser/test/fixtures/flow/object-types/invalid-getter-param-count/output.json b/packages/babel-parser/test/fixtures/flow/object-types/invalid-getter-param-count/output.json new file mode 100644 index 000000000000..66bd6ed1baf2 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/object-types/invalid-getter-param-count/output.json @@ -0,0 +1,212 @@ +{ + "type": "File", + "start": 0, + "end": 41, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "errors": [ + "SyntaxError: getter must not have any formal parameters (2:2)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 41, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "TypeAlias", + "start": 0, + "end": 41, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 5, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 6 + }, + "identifierName": "B" + }, + "name": "B" + }, + "typeParameters": null, + "right": { + "type": "ObjectTypeAnnotation", + "start": 9, + "end": 41, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "callProperties": [], + "properties": [ + { + "type": "ObjectTypeProperty", + "start": 13, + "end": 38, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 27 + } + }, + "key": { + "type": "Identifier", + "start": 17, + "end": 18, + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 7 + }, + "identifierName": "a" + }, + "name": "a" + }, + "static": false, + "proto": false, + "kind": "get", + "method": true, + "value": { + "type": "FunctionTypeAnnotation", + "start": 13, + "end": 38, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 27 + } + }, + "params": [ + { + "type": "FunctionTypeParam", + "start": 19, + "end": 29, + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 18 + } + }, + "name": { + "type": "Identifier", + "start": 19, + "end": 22, + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 11 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "optional": false, + "typeAnnotation": { + "type": "NumberTypeAnnotation", + "start": 23, + "end": 29, + "loc": { + "start": { + "line": 2, + "column": 12 + }, + "end": { + "line": 2, + "column": 18 + } + } + } + } + ], + "rest": null, + "typeParameters": null, + "returnType": { + "type": "NumberTypeAnnotation", + "start": 32, + "end": 38, + "loc": { + "start": { + "line": 2, + "column": 21 + }, + "end": { + "line": 2, + "column": 27 + } + } + } + }, + "optional": false + } + ], + "indexers": [], + "internalSlots": [], + "exact": false, + "inexact": false + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/object-types/invalid-setter-param-count/options.json b/packages/babel-parser/test/fixtures/flow/object-types/invalid-setter-param-count/options.json deleted file mode 100644 index 6a1567782202..000000000000 --- a/packages/babel-parser/test/fixtures/flow/object-types/invalid-setter-param-count/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "setter must have exactly one formal parameter (2:2)" -} diff --git a/packages/babel-parser/test/fixtures/flow/object-types/invalid-setter-param-count/output.json b/packages/babel-parser/test/fixtures/flow/object-types/invalid-setter-param-count/output.json new file mode 100644 index 000000000000..b79f9a52c897 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/object-types/invalid-setter-param-count/output.json @@ -0,0 +1,163 @@ +{ + "type": "File", + "start": 0, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "errors": [ + "SyntaxError: setter must have exactly one formal parameter (2:2)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "TypeAlias", + "start": 0, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 5, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 6 + }, + "identifierName": "B" + }, + "name": "B" + }, + "typeParameters": null, + "right": { + "type": "ObjectTypeAnnotation", + "start": 9, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "callProperties": [], + "properties": [ + { + "type": "ObjectTypeProperty", + "start": 13, + "end": 26, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 15 + } + }, + "key": { + "type": "Identifier", + "start": 17, + "end": 18, + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 7 + }, + "identifierName": "a" + }, + "name": "a" + }, + "static": false, + "proto": false, + "kind": "set", + "method": true, + "value": { + "type": "FunctionTypeAnnotation", + "start": 13, + "end": 26, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 15 + } + }, + "params": [], + "rest": null, + "typeParameters": null, + "returnType": { + "type": "VoidTypeAnnotation", + "start": 22, + "end": 26, + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 15 + } + } + } + }, + "optional": false + } + ], + "indexers": [], + "internalSlots": [], + "exact": false, + "inexact": false + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/object-types/invalid-setter-param-type/options.json b/packages/babel-parser/test/fixtures/flow/object-types/invalid-setter-param-type/options.json deleted file mode 100644 index 15ce6a4c5a51..000000000000 --- a/packages/babel-parser/test/fixtures/flow/object-types/invalid-setter-param-type/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "setter function argument must not be a rest parameter (2:2)" -} diff --git a/packages/babel-parser/test/fixtures/flow/object-types/invalid-setter-param-type/output.json b/packages/babel-parser/test/fixtures/flow/object-types/invalid-setter-param-type/output.json new file mode 100644 index 000000000000..5171dbc8a45f --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/object-types/invalid-setter-param-type/output.json @@ -0,0 +1,212 @@ +{ + "type": "File", + "start": 0, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "errors": [ + "SyntaxError: setter function argument must not be a rest parameter (2:2)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "TypeAlias", + "start": 0, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 5, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 6 + }, + "identifierName": "B" + }, + "name": "B" + }, + "typeParameters": null, + "right": { + "type": "ObjectTypeAnnotation", + "start": 9, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "callProperties": [], + "properties": [ + { + "type": "ObjectTypeProperty", + "start": 13, + "end": 30, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 19 + } + }, + "key": { + "type": "Identifier", + "start": 17, + "end": 18, + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 7 + }, + "identifierName": "a" + }, + "name": "a" + }, + "static": false, + "proto": false, + "kind": "set", + "method": true, + "value": { + "type": "FunctionTypeAnnotation", + "start": 13, + "end": 30, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 19 + } + }, + "params": [], + "rest": { + "type": "FunctionTypeParam", + "start": 22, + "end": 23, + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 12 + } + }, + "name": null, + "optional": false, + "typeAnnotation": { + "type": "GenericTypeAnnotation", + "start": 22, + "end": 23, + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 12 + } + }, + "typeParameters": null, + "id": { + "type": "Identifier", + "start": 22, + "end": 23, + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 12 + }, + "identifierName": "w" + }, + "name": "w" + } + } + }, + "typeParameters": null, + "returnType": { + "type": "VoidTypeAnnotation", + "start": 26, + "end": 30, + "loc": { + "start": { + "line": 2, + "column": 15 + }, + "end": { + "line": 2, + "column": 19 + } + } + } + }, + "optional": false + } + ], + "indexers": [], + "internalSlots": [], + "exact": false, + "inexact": false + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/opaque-type-alias/reserved-type-invalid/options.json b/packages/babel-parser/test/fixtures/flow/opaque-type-alias/reserved-type-invalid/options.json deleted file mode 100644 index 0c2cdd4d777c..000000000000 --- a/packages/babel-parser/test/fixtures/flow/opaque-type-alias/reserved-type-invalid/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Cannot overwrite reserved type string (1:12)" -} diff --git a/packages/babel-parser/test/fixtures/flow/opaque-type-alias/reserved-type-invalid/output.json b/packages/babel-parser/test/fixtures/flow/opaque-type-alias/reserved-type-invalid/output.json new file mode 100644 index 000000000000..bc568d5767be --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/opaque-type-alias/reserved-type-invalid/output.json @@ -0,0 +1,87 @@ +{ + "type": "File", + "start": 0, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 28 + } + }, + "errors": [ + "SyntaxError: Cannot overwrite reserved type string (1:12)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 28 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "OpaqueType", + "start": 0, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 28 + } + }, + "id": { + "type": "Identifier", + "start": 12, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 18 + }, + "identifierName": "string" + }, + "name": "string" + }, + "typeParameters": null, + "supertype": null, + "impltype": { + "type": "NumberTypeAnnotation", + "start": 21, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 21 + }, + "end": { + "line": 1, + "column": 27 + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/optional-type/6/options.json b/packages/babel-parser/test/fixtures/flow/optional-type/6/options.json deleted file mode 100644 index fb2831d6188b..000000000000 --- a/packages/babel-parser/test/fixtures/flow/optional-type/6/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "A binding pattern parameter cannot be optional in an implementation signature. (1:11)" -} diff --git a/packages/babel-parser/test/fixtures/flow/optional-type/6/output.json b/packages/babel-parser/test/fixtures/flow/optional-type/6/output.json new file mode 100644 index 000000000000..3ef0fdc07d93 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/optional-type/6/output.json @@ -0,0 +1,124 @@ +{ + "type": "File", + "start": 0, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "errors": [ + "SyntaxError: A binding pattern parameter cannot be optional in an implementation signature. (1:11)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 10 + }, + "identifierName": "f" + }, + "name": "f" + }, + "generator": false, + "async": false, + "params": [ + { + "type": "ArrayPattern", + "start": 11, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "elements": [], + "optional": true + }, + { + "type": "ObjectPattern", + "start": 16, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "properties": [] + } + ], + "body": { + "type": "BlockStatement", + "start": 20, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 20 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "body": [], + "directives": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/predicates/4/options.json b/packages/babel-parser/test/fixtures/flow/predicates/4/options.json deleted file mode 100644 index cec83fa54fba..000000000000 --- a/packages/babel-parser/test/fixtures/flow/predicates/4/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Unexpected token, expected \";\" (1:18)" -} diff --git a/packages/babel-parser/test/fixtures/flow/predicates/4/output.json b/packages/babel-parser/test/fixtures/flow/predicates/4/output.json new file mode 100644 index 000000000000..e1e9eeffbc7b --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/predicates/4/output.json @@ -0,0 +1,241 @@ +{ + "type": "File", + "start": 0, + "end": 54, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 54 + } + }, + "errors": [ + "SyntaxError: Spaces between ´%´ and ´checks´ are not allowed here. (1:20)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 54, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 54 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "VariableDeclaration", + "start": 0, + "end": 54, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 54 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 4, + "end": 53, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 53 + } + }, + "id": { + "type": "Identifier", + "start": 4, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 5 + }, + "identifierName": "f" + }, + "name": "f" + }, + "init": { + "type": "ArrowFunctionExpression", + "start": 8, + "end": 53, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 53 + } + }, + "predicate": { + "type": "InferredPredicate", + "start": 20, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 20 + }, + "end": { + "line": 1, + "column": 28 + } + } + }, + "returnType": null, + "id": null, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "start": 9, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 17 + }, + "identifierName": "x" + }, + "name": "x", + "typeAnnotation": { + "type": "TypeAnnotation", + "start": 10, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "typeAnnotation": { + "type": "MixedTypeAnnotation", + "start": 12, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 17 + } + } + } + } + } + ], + "body": { + "type": "BinaryExpression", + "start": 32, + "end": 53, + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 53 + } + }, + "left": { + "type": "UnaryExpression", + "start": 32, + "end": 40, + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 40 + } + }, + "operator": "typeof", + "prefix": true, + "argument": { + "type": "Identifier", + "start": 39, + "end": 40, + "loc": { + "start": { + "line": 1, + "column": 39 + }, + "end": { + "line": 1, + "column": 40 + }, + "identifierName": "x" + }, + "name": "x" + } + }, + "operator": "===", + "right": { + "type": "StringLiteral", + "start": 45, + "end": 53, + "loc": { + "start": { + "line": 1, + "column": 45 + }, + "end": { + "line": 1, + "column": 53 + } + }, + "extra": { + "rawValue": "string", + "raw": "\"string\"" + }, + "value": "string" + } + } + } + } + ], + "kind": "var" + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/predicates/5/options.json b/packages/babel-parser/test/fixtures/flow/predicates/5/options.json deleted file mode 100644 index dbdc7697ac5b..000000000000 --- a/packages/babel-parser/test/fixtures/flow/predicates/5/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Spaces between ´%´ and ´checks´ are not allowed here. (1:17)" -} diff --git a/packages/babel-parser/test/fixtures/flow/predicates/5/output.json b/packages/babel-parser/test/fixtures/flow/predicates/5/output.json new file mode 100644 index 000000000000..0d7a47afacfd --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/predicates/5/output.json @@ -0,0 +1,210 @@ +{ + "type": "File", + "start": 0, + "end": 61, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "errors": [ + "SyntaxError: Spaces between ´%´ and ´checks´ are not allowed here. (1:17)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 61, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 61, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 12 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "start": 13, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 14 + }, + "identifierName": "x" + }, + "name": "x" + } + ], + "predicate": { + "type": "InferredPredicate", + "start": 17, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 25 + } + } + }, + "returnType": null, + "body": { + "type": "BlockStatement", + "start": 26, + "end": 61, + "loc": { + "start": { + "line": 1, + "column": 26 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "body": [ + { + "type": "ReturnStatement", + "start": 30, + "end": 59, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 31 + } + }, + "argument": { + "type": "BinaryExpression", + "start": 37, + "end": 58, + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 30 + } + }, + "left": { + "type": "UnaryExpression", + "start": 37, + "end": 45, + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 17 + } + }, + "operator": "typeof", + "prefix": true, + "argument": { + "type": "Identifier", + "start": 44, + "end": 45, + "loc": { + "start": { + "line": 2, + "column": 16 + }, + "end": { + "line": 2, + "column": 17 + }, + "identifierName": "x" + }, + "name": "x" + } + }, + "operator": "===", + "right": { + "type": "StringLiteral", + "start": 50, + "end": 58, + "loc": { + "start": { + "line": 2, + "column": 22 + }, + "end": { + "line": 2, + "column": 30 + } + }, + "extra": { + "rawValue": "string", + "raw": "\"string\"" + }, + "value": "string" + } + } + } + ], + "directives": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/regression/arrow-in-ternary-with-param-type-and-return-type-like/input.js b/packages/babel-parser/test/fixtures/flow/regression/arrow-in-ternary-with-param-type-and-return-type-like/input.js new file mode 100644 index 000000000000..1f0c3e33482c --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/regression/arrow-in-ternary-with-param-type-and-return-type-like/input.js @@ -0,0 +1,2 @@ +test + ? (x: T): U => y diff --git a/packages/babel-parser/test/fixtures/flow/regression/arrow-in-ternary-with-param-type-and-return-type-like/output.json b/packages/babel-parser/test/fixtures/flow/regression/arrow-in-ternary-with-param-type-and-return-type-like/output.json new file mode 100644 index 000000000000..3c80e21673a6 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/regression/arrow-in-ternary-with-param-type-and-return-type-like/output.json @@ -0,0 +1,220 @@ +{ + "type": "File", + "start": 0, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 18 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 18 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 18 + } + }, + "expression": { + "type": "ConditionalExpression", + "start": 0, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 18 + } + }, + "test": { + "type": "Identifier", + "start": 0, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 4 + }, + "identifierName": "test" + }, + "name": "test" + }, + "consequent": { + "type": "TypeCastExpression", + "start": 10, + "end": 14, + "loc": { + "start": { + "line": 2, + "column": 5 + }, + "end": { + "line": 2, + "column": 9 + } + }, + "expression": { + "type": "Identifier", + "start": 10, + "end": 11, + "loc": { + "start": { + "line": 2, + "column": 5 + }, + "end": { + "line": 2, + "column": 6 + }, + "identifierName": "x" + }, + "name": "x" + }, + "typeAnnotation": { + "type": "TypeAnnotation", + "start": 11, + "end": 14, + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 9 + } + }, + "typeAnnotation": { + "type": "GenericTypeAnnotation", + "start": 13, + "end": 14, + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 9 + } + }, + "typeParameters": null, + "id": { + "type": "Identifier", + "start": 13, + "end": 14, + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 9 + }, + "identifierName": "T" + }, + "name": "T" + } + } + }, + "extra": { + "parenthesized": true, + "parenStart": 9 + } + }, + "alternate": { + "type": "ArrowFunctionExpression", + "start": 17, + "end": 23, + "loc": { + "start": { + "line": 2, + "column": 12 + }, + "end": { + "line": 2, + "column": 18 + } + }, + "id": null, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "start": 17, + "end": 18, + "loc": { + "start": { + "line": 2, + "column": 12 + }, + "end": { + "line": 2, + "column": 13 + }, + "identifierName": "U" + }, + "name": "U" + } + ], + "body": { + "type": "Identifier", + "start": 22, + "end": 23, + "loc": { + "start": { + "line": 2, + "column": 17 + }, + "end": { + "line": 2, + "column": 18 + }, + "identifierName": "y" + }, + "name": "y" + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/regression/arrow-in-ternary-with-param-type-and-return-type/input.js b/packages/babel-parser/test/fixtures/flow/regression/arrow-in-ternary-with-param-type-and-return-type/input.js new file mode 100644 index 000000000000..a36f5ca0c5d8 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/regression/arrow-in-ternary-with-param-type-and-return-type/input.js @@ -0,0 +1,3 @@ +test + ? (x: T): U => y + : z \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/regression/arrow-in-ternary-with-param-type-and-return-type/output.json b/packages/babel-parser/test/fixtures/flow/regression/arrow-in-ternary-with-param-type-and-return-type/output.json new file mode 100644 index 000000000000..6be59ef645aa --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/regression/arrow-in-ternary-with-param-type-and-return-type/output.json @@ -0,0 +1,250 @@ +{ + "type": "File", + "start": 0, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 5 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 5 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 5 + } + }, + "expression": { + "type": "ConditionalExpression", + "start": 0, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 5 + } + }, + "test": { + "type": "Identifier", + "start": 0, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 4 + }, + "identifierName": "test" + }, + "name": "test" + }, + "consequent": { + "type": "ArrowFunctionExpression", + "start": 9, + "end": 23, + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 18 + } + }, + "predicate": null, + "returnType": { + "type": "TypeAnnotation", + "start": 15, + "end": 18, + "loc": { + "start": { + "line": 2, + "column": 10 + }, + "end": { + "line": 2, + "column": 13 + } + }, + "typeAnnotation": { + "type": "GenericTypeAnnotation", + "start": 17, + "end": 18, + "loc": { + "start": { + "line": 2, + "column": 12 + }, + "end": { + "line": 2, + "column": 13 + } + }, + "typeParameters": null, + "id": { + "type": "Identifier", + "start": 17, + "end": 18, + "loc": { + "start": { + "line": 2, + "column": 12 + }, + "end": { + "line": 2, + "column": 13 + }, + "identifierName": "U" + }, + "name": "U" + } + } + }, + "id": null, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "start": 10, + "end": 14, + "loc": { + "start": { + "line": 2, + "column": 5 + }, + "end": { + "line": 2, + "column": 9 + }, + "identifierName": "x" + }, + "name": "x", + "typeAnnotation": { + "type": "TypeAnnotation", + "start": 11, + "end": 14, + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 9 + } + }, + "typeAnnotation": { + "type": "GenericTypeAnnotation", + "start": 13, + "end": 14, + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 9 + } + }, + "typeParameters": null, + "id": { + "type": "Identifier", + "start": 13, + "end": 14, + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 9 + }, + "identifierName": "T" + }, + "name": "T" + } + } + } + } + ], + "body": { + "type": "Identifier", + "start": 22, + "end": 23, + "loc": { + "start": { + "line": 2, + "column": 17 + }, + "end": { + "line": 2, + "column": 18 + }, + "identifierName": "y" + }, + "name": "y" + } + }, + "alternate": { + "type": "Identifier", + "start": 28, + "end": 29, + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 5 + }, + "identifierName": "z" + }, + "name": "z" + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/regression/issue-58-ambiguous/options.json b/packages/babel-parser/test/fixtures/flow/regression/issue-58-ambiguous/options.json index 49dc6c3d5a6a..abfcf6f44eba 100644 --- a/packages/babel-parser/test/fixtures/flow/regression/issue-58-ambiguous/options.json +++ b/packages/babel-parser/test/fixtures/flow/regression/issue-58-ambiguous/options.json @@ -1,3 +1,3 @@ { - "throws": "Ambiguous expression: wrap the arrow functions in parentheses to disambiguate. (4:4)" + "throws": "Unexpected token, expected \":\" (4:27)" } diff --git a/packages/babel-parser/test/fixtures/flow/regression/issue-58-failing-1/options.json b/packages/babel-parser/test/fixtures/flow/regression/issue-58-failing-1/options.json deleted file mode 100644 index 215199590424..000000000000 --- a/packages/babel-parser/test/fixtures/flow/regression/issue-58-failing-1/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid left-hand side in arrow function parameters (2:11)" -} diff --git a/packages/babel-parser/test/fixtures/flow/regression/issue-58-failing-1/output.json b/packages/babel-parser/test/fixtures/flow/regression/issue-58-failing-1/output.json new file mode 100644 index 000000000000..598107b6493b --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/regression/issue-58-failing-1/output.json @@ -0,0 +1,233 @@ +{ + "type": "File", + "start": 0, + "end": 67, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 24 + } + }, + "errors": [ + "SyntaxError: Binding invalid left-hand side in function parameter list (2:11)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 67, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 24 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 43, + "end": 67, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 24 + } + }, + "expression": { + "type": "ConditionalExpression", + "start": 43, + "end": 66, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 23 + } + }, + "test": { + "type": "Identifier", + "start": 43, + "end": 44, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 1 + }, + "identifierName": "a" + }, + "name": "a" + }, + "consequent": { + "type": "Identifier", + "start": 48, + "end": 49, + "loc": { + "start": { + "line": 2, + "column": 5 + }, + "end": { + "line": 2, + "column": 6 + }, + "identifierName": "b" + }, + "name": "b", + "extra": { + "parenthesized": true, + "parenStart": 47 + } + }, + "alternate": { + "type": "ArrowFunctionExpression", + "start": 53, + "end": 66, + "loc": { + "start": { + "line": 2, + "column": 10 + }, + "end": { + "line": 2, + "column": 23 + } + }, + "id": null, + "generator": false, + "async": false, + "params": [ + { + "type": "ArrowFunctionExpression", + "start": 54, + "end": 60, + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 17 + } + }, + "id": null, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "start": 54, + "end": 55, + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 12 + }, + "identifierName": "c" + }, + "name": "c" + } + ], + "body": { + "type": "Identifier", + "start": 59, + "end": 60, + "loc": { + "start": { + "line": 2, + "column": 16 + }, + "end": { + "line": 2, + "column": 17 + }, + "identifierName": "d" + }, + "name": "d" + } + } + ], + "body": { + "type": "Identifier", + "start": 65, + "end": 66, + "loc": { + "start": { + "line": 2, + "column": 22 + }, + "end": { + "line": 2, + "column": 23 + }, + "identifierName": "e" + }, + "name": "e" + } + } + }, + "leadingComments": [ + { + "type": "CommentLine", + "value": " Function which looks like a return type", + "start": 0, + "end": 42, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 42 + } + } + } + ] + } + ], + "directives": [] + }, + "comments": [ + { + "type": "CommentLine", + "value": " Function which looks like a return type", + "start": 0, + "end": 42, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 42 + } + } + } + ] +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/regression/issue-58-failing-2/options.json b/packages/babel-parser/test/fixtures/flow/regression/issue-58-failing-2/options.json deleted file mode 100644 index 36a678e0e538..000000000000 --- a/packages/babel-parser/test/fixtures/flow/regression/issue-58-failing-2/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid left-hand side in arrow function parameters (2:8)" -} diff --git a/packages/babel-parser/test/fixtures/flow/regression/issue-58-failing-2/output.json b/packages/babel-parser/test/fixtures/flow/regression/issue-58-failing-2/output.json new file mode 100644 index 000000000000..c65e342557c3 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/regression/issue-58-failing-2/output.json @@ -0,0 +1,353 @@ +{ + "type": "File", + "start": 0, + "end": 83, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 36 + } + }, + "errors": [ + "SyntaxError: Binding invalid left-hand side in function parameter list (2:8)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 83, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 36 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 47, + "end": 83, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 36 + } + }, + "expression": { + "type": "ConditionalExpression", + "start": 47, + "end": 82, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 35 + } + }, + "test": { + "type": "Identifier", + "start": 47, + "end": 48, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 1 + }, + "identifierName": "a" + }, + "name": "a" + }, + "consequent": { + "type": "ArrowFunctionExpression", + "start": 51, + "end": 73, + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 26 + } + }, + "predicate": null, + "returnType": { + "type": "TypeAnnotation", + "start": 63, + "end": 66, + "loc": { + "start": { + "line": 2, + "column": 16 + }, + "end": { + "line": 2, + "column": 19 + } + }, + "typeAnnotation": { + "type": "GenericTypeAnnotation", + "start": 65, + "end": 66, + "loc": { + "start": { + "line": 2, + "column": 18 + }, + "end": { + "line": 2, + "column": 19 + } + }, + "typeParameters": null, + "id": { + "type": "Identifier", + "start": 65, + "end": 66, + "loc": { + "start": { + "line": 2, + "column": 18 + }, + "end": { + "line": 2, + "column": 19 + }, + "identifierName": "d" + }, + "name": "d" + } + } + }, + "id": null, + "generator": false, + "async": false, + "params": [ + { + "type": "ArrowFunctionExpression", + "start": 55, + "end": 61, + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 14 + } + }, + "id": null, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "start": 55, + "end": 56, + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 9 + }, + "identifierName": "b" + }, + "name": "b" + } + ], + "body": { + "type": "Identifier", + "start": 60, + "end": 61, + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 14 + }, + "identifierName": "c" + }, + "name": "c" + } + } + ], + "body": { + "type": "Identifier", + "start": 71, + "end": 72, + "loc": { + "start": { + "line": 2, + "column": 24 + }, + "end": { + "line": 2, + "column": 25 + }, + "identifierName": "e" + }, + "name": "e", + "extra": { + "parenthesized": true, + "parenStart": 70 + } + }, + "typeParameters": { + "type": "TypeParameterDeclaration", + "start": 51, + "end": 54, + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 7 + } + }, + "params": [ + { + "type": "TypeParameter", + "start": 52, + "end": 53, + "loc": { + "start": { + "line": 2, + "column": 5 + }, + "end": { + "line": 2, + "column": 6 + } + }, + "name": "T", + "variance": null + } + ] + } + }, + "alternate": { + "type": "ArrowFunctionExpression", + "start": 76, + "end": 82, + "loc": { + "start": { + "line": 2, + "column": 29 + }, + "end": { + "line": 2, + "column": 35 + } + }, + "id": null, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "start": 76, + "end": 77, + "loc": { + "start": { + "line": 2, + "column": 29 + }, + "end": { + "line": 2, + "column": 30 + }, + "identifierName": "f" + }, + "name": "f" + } + ], + "body": { + "type": "Identifier", + "start": 81, + "end": 82, + "loc": { + "start": { + "line": 2, + "column": 34 + }, + "end": { + "line": 2, + "column": 35 + }, + "identifierName": "g" + }, + "name": "g" + } + } + }, + "leadingComments": [ + { + "type": "CommentLine", + "value": " Invalid LHS parameter after type parameters", + "start": 0, + "end": 46, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 46 + } + } + } + ] + } + ], + "directives": [] + }, + "comments": [ + { + "type": "CommentLine", + "value": " Invalid LHS parameter after type parameters", + "start": 0, + "end": 46, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 46 + } + } + } + ] +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/regression/issue-58-failing-3/options.json b/packages/babel-parser/test/fixtures/flow/regression/issue-58-failing-3/options.json deleted file mode 100644 index 2fc0696df35a..000000000000 --- a/packages/babel-parser/test/fixtures/flow/regression/issue-58-failing-3/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid left-hand side in arrow function parameters (2:5)" -} diff --git a/packages/babel-parser/test/fixtures/flow/regression/issue-58-failing-3/output.json b/packages/babel-parser/test/fixtures/flow/regression/issue-58-failing-3/output.json new file mode 100644 index 000000000000..ae2fe29bafc4 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/regression/issue-58-failing-3/output.json @@ -0,0 +1,270 @@ +{ + "type": "File", + "start": 0, + "end": 76, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 29 + } + }, + "errors": [ + "SyntaxError: Binding invalid left-hand side in function parameter list (2:5)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 76, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 29 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 47, + "end": 76, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 29 + } + }, + "expression": { + "type": "ConditionalExpression", + "start": 47, + "end": 75, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 28 + } + }, + "test": { + "type": "Identifier", + "start": 47, + "end": 48, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 1 + }, + "identifierName": "a" + }, + "name": "a" + }, + "consequent": { + "type": "ArrowFunctionExpression", + "start": 51, + "end": 66, + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 19 + } + }, + "id": null, + "generator": false, + "async": false, + "params": [ + { + "type": "ArrowFunctionExpression", + "start": 52, + "end": 58, + "loc": { + "start": { + "line": 2, + "column": 5 + }, + "end": { + "line": 2, + "column": 11 + } + }, + "id": null, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "start": 52, + "end": 53, + "loc": { + "start": { + "line": 2, + "column": 5 + }, + "end": { + "line": 2, + "column": 6 + }, + "identifierName": "b" + }, + "name": "b" + } + ], + "body": { + "type": "Identifier", + "start": 57, + "end": 58, + "loc": { + "start": { + "line": 2, + "column": 10 + }, + "end": { + "line": 2, + "column": 11 + }, + "identifierName": "c" + }, + "name": "c" + } + } + ], + "body": { + "type": "Identifier", + "start": 64, + "end": 65, + "loc": { + "start": { + "line": 2, + "column": 17 + }, + "end": { + "line": 2, + "column": 18 + }, + "identifierName": "e" + }, + "name": "e", + "extra": { + "parenthesized": true, + "parenStart": 63 + } + } + }, + "alternate": { + "type": "ArrowFunctionExpression", + "start": 69, + "end": 75, + "loc": { + "start": { + "line": 2, + "column": 22 + }, + "end": { + "line": 2, + "column": 28 + } + }, + "id": null, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "start": 69, + "end": 70, + "loc": { + "start": { + "line": 2, + "column": 22 + }, + "end": { + "line": 2, + "column": 23 + }, + "identifierName": "f" + }, + "name": "f" + } + ], + "body": { + "type": "Identifier", + "start": 74, + "end": 75, + "loc": { + "start": { + "line": 2, + "column": 27 + }, + "end": { + "line": 2, + "column": 28 + }, + "identifierName": "g" + }, + "name": "g" + } + } + }, + "leadingComments": [ + { + "type": "CommentLine", + "value": " Invalid LHS parameter after type parameters", + "start": 0, + "end": 46, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 46 + } + } + } + ] + } + ], + "directives": [] + }, + "comments": [ + { + "type": "CommentLine", + "value": " Invalid LHS parameter after type parameters", + "start": 0, + "end": 46, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 46 + } + } + } + ] +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/regression/issue-58-failing-4/options.json b/packages/babel-parser/test/fixtures/flow/regression/issue-58-failing-4/options.json deleted file mode 100644 index 215199590424..000000000000 --- a/packages/babel-parser/test/fixtures/flow/regression/issue-58-failing-4/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Invalid left-hand side in arrow function parameters (2:11)" -} diff --git a/packages/babel-parser/test/fixtures/flow/regression/issue-58-failing-4/output.json b/packages/babel-parser/test/fixtures/flow/regression/issue-58-failing-4/output.json new file mode 100644 index 000000000000..2479192b7877 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/regression/issue-58-failing-4/output.json @@ -0,0 +1,270 @@ +{ + "type": "File", + "start": 0, + "end": 60, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 35 + } + }, + "errors": [ + "SyntaxError: Binding invalid left-hand side in function parameter list (2:11)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 60, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 35 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 25, + "end": 60, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 35 + } + }, + "expression": { + "type": "ConditionalExpression", + "start": 25, + "end": 59, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 34 + } + }, + "test": { + "type": "Identifier", + "start": 25, + "end": 26, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 1 + }, + "identifierName": "a" + }, + "name": "a" + }, + "consequent": { + "type": "ArrowFunctionExpression", + "start": 29, + "end": 50, + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 25 + } + }, + "id": null, + "generator": false, + "async": true, + "params": [ + { + "type": "ArrowFunctionExpression", + "start": 36, + "end": 42, + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 17 + } + }, + "id": null, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "start": 36, + "end": 37, + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 12 + }, + "identifierName": "b" + }, + "name": "b" + } + ], + "body": { + "type": "Identifier", + "start": 41, + "end": 42, + "loc": { + "start": { + "line": 2, + "column": 16 + }, + "end": { + "line": 2, + "column": 17 + }, + "identifierName": "c" + }, + "name": "c" + } + } + ], + "body": { + "type": "Identifier", + "start": 48, + "end": 49, + "loc": { + "start": { + "line": 2, + "column": 23 + }, + "end": { + "line": 2, + "column": 24 + }, + "identifierName": "d" + }, + "name": "d", + "extra": { + "parenthesized": true, + "parenStart": 47 + } + } + }, + "alternate": { + "type": "ArrowFunctionExpression", + "start": 53, + "end": 59, + "loc": { + "start": { + "line": 2, + "column": 28 + }, + "end": { + "line": 2, + "column": 34 + } + }, + "id": null, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "start": 53, + "end": 54, + "loc": { + "start": { + "line": 2, + "column": 28 + }, + "end": { + "line": 2, + "column": 29 + }, + "identifierName": "f" + }, + "name": "f" + } + ], + "body": { + "type": "Identifier", + "start": 58, + "end": 59, + "loc": { + "start": { + "line": 2, + "column": 33 + }, + "end": { + "line": 2, + "column": 34 + }, + "identifierName": "g" + }, + "name": "g" + } + } + }, + "leadingComments": [ + { + "type": "CommentLine", + "value": " Invalid LHS parameter", + "start": 0, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 24 + } + } + } + ] + } + ], + "directives": [] + }, + "comments": [ + { + "type": "CommentLine", + "value": " Invalid LHS parameter", + "start": 0, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 24 + } + } + } + ] +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-const-declare-class/options.json b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-const-declare-class/options.json index 4a1b4e5c5cd4..3962be507d38 100644 --- a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-const-declare-class/options.json +++ b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-const-declare-class/options.json @@ -1,3 +1,7 @@ { - "throws": "Identifier 'A' has already been declared (2:14)" -} + "sourceType": "module", + "plugins": [ + "jsx", + "flow" + ] +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-const-declare-class/output.json b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-const-declare-class/output.json new file mode 100644 index 000000000000..a5fb057eb10c --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-const-declare-class/output.json @@ -0,0 +1,164 @@ +{ + "type": "File", + "start": 0, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 18 + } + }, + "errors": [ + "SyntaxError: Identifier 'A' has already been declared (2:14)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 18 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "VariableDeclaration", + "start": 0, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 6, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "id": { + "type": "Identifier", + "start": 6, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + }, + "identifierName": "A" + }, + "name": "A" + }, + "init": { + "type": "NumericLiteral", + "start": 10, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + } + } + ], + "kind": "const" + }, + { + "type": "DeclareClass", + "start": 13, + "end": 31, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 18 + } + }, + "id": { + "type": "Identifier", + "start": 27, + "end": 28, + "loc": { + "start": { + "line": 2, + "column": 14 + }, + "end": { + "line": 2, + "column": 15 + }, + "identifierName": "A" + }, + "name": "A" + }, + "typeParameters": null, + "extends": [], + "implements": [], + "mixins": [], + "body": { + "type": "ObjectTypeAnnotation", + "start": 29, + "end": 31, + "loc": { + "start": { + "line": 2, + "column": 16 + }, + "end": { + "line": 2, + "column": 18 + } + }, + "callProperties": [], + "properties": [], + "indexers": [], + "internalSlots": [], + "exact": false + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-const-declare-interface/options.json b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-const-declare-interface/options.json index 187fea591b95..3962be507d38 100644 --- a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-const-declare-interface/options.json +++ b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-const-declare-interface/options.json @@ -1,3 +1,7 @@ { - "throws": "Identifier 'A' has already been declared (2:18)" -} + "sourceType": "module", + "plugins": [ + "jsx", + "flow" + ] +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-const-declare-interface/output.json b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-const-declare-interface/output.json new file mode 100644 index 000000000000..93ec46f9bc31 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-const-declare-interface/output.json @@ -0,0 +1,164 @@ +{ + "type": "File", + "start": 0, + "end": 35, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 22 + } + }, + "errors": [ + "SyntaxError: Identifier 'A' has already been declared (2:18)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 35, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 22 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "VariableDeclaration", + "start": 0, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 6, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "id": { + "type": "Identifier", + "start": 6, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + }, + "identifierName": "A" + }, + "name": "A" + }, + "init": { + "type": "NumericLiteral", + "start": 10, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + } + } + ], + "kind": "const" + }, + { + "type": "DeclareInterface", + "start": 13, + "end": 35, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 22 + } + }, + "id": { + "type": "Identifier", + "start": 31, + "end": 32, + "loc": { + "start": { + "line": 2, + "column": 18 + }, + "end": { + "line": 2, + "column": 19 + }, + "identifierName": "A" + }, + "name": "A" + }, + "typeParameters": null, + "extends": [], + "implements": [], + "mixins": [], + "body": { + "type": "ObjectTypeAnnotation", + "start": 33, + "end": 35, + "loc": { + "start": { + "line": 2, + "column": 20 + }, + "end": { + "line": 2, + "column": 22 + } + }, + "callProperties": [], + "properties": [], + "indexers": [], + "internalSlots": [], + "exact": false + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-const-interface/options.json b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-const-interface/options.json index 04242bd1565b..3962be507d38 100644 --- a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-const-interface/options.json +++ b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-const-interface/options.json @@ -1,3 +1,7 @@ { - "throws": "Identifier 'A' has already been declared (2:10)" -} + "sourceType": "module", + "plugins": [ + "jsx", + "flow" + ] +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-const-interface/output.json b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-const-interface/output.json new file mode 100644 index 000000000000..9de1cc4338cf --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-const-interface/output.json @@ -0,0 +1,164 @@ +{ + "type": "File", + "start": 0, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 14 + } + }, + "errors": [ + "SyntaxError: Identifier 'A' has already been declared (2:10)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 14 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "VariableDeclaration", + "start": 0, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 6, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "id": { + "type": "Identifier", + "start": 6, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + }, + "identifierName": "A" + }, + "name": "A" + }, + "init": { + "type": "NumericLiteral", + "start": 10, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + } + } + ], + "kind": "const" + }, + { + "type": "InterfaceDeclaration", + "start": 13, + "end": 27, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 14 + } + }, + "id": { + "type": "Identifier", + "start": 23, + "end": 24, + "loc": { + "start": { + "line": 2, + "column": 10 + }, + "end": { + "line": 2, + "column": 11 + }, + "identifierName": "A" + }, + "name": "A" + }, + "typeParameters": null, + "extends": [], + "implements": [], + "mixins": [], + "body": { + "type": "ObjectTypeAnnotation", + "start": 25, + "end": 27, + "loc": { + "start": { + "line": 2, + "column": 12 + }, + "end": { + "line": 2, + "column": 14 + } + }, + "callProperties": [], + "properties": [], + "indexers": [], + "internalSlots": [], + "exact": false + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-const-opaque-type/options.json b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-const-opaque-type/options.json deleted file mode 100644 index 81dc2c90799f..000000000000 --- a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-const-opaque-type/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Identifier 'A' has already been declared (2:12)" -} diff --git a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-const-opaque-type/output.json b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-const-opaque-type/output.json new file mode 100644 index 000000000000..7b807528c3b9 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-const-opaque-type/output.json @@ -0,0 +1,163 @@ +{ + "type": "File", + "start": 0, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 19 + } + }, + "errors": [ + "SyntaxError: Identifier 'A' has already been declared (2:12)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 19 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "VariableDeclaration", + "start": 0, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 6, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "id": { + "type": "Identifier", + "start": 6, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + }, + "identifierName": "A" + }, + "name": "A" + }, + "init": { + "type": "NumericLiteral", + "start": 10, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + } + } + ], + "kind": "const" + }, + { + "type": "OpaqueType", + "start": 13, + "end": 32, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 19 + } + }, + "id": { + "type": "Identifier", + "start": 25, + "end": 26, + "loc": { + "start": { + "line": 2, + "column": 12 + }, + "end": { + "line": 2, + "column": 13 + }, + "identifierName": "A" + }, + "name": "A" + }, + "typeParameters": null, + "supertype": null, + "impltype": { + "type": "ObjectTypeAnnotation", + "start": 29, + "end": 31, + "loc": { + "start": { + "line": 2, + "column": 16 + }, + "end": { + "line": 2, + "column": 18 + } + }, + "callProperties": [], + "properties": [], + "indexers": [], + "internalSlots": [], + "exact": false, + "inexact": false + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-const-type/options.json b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-const-type/options.json deleted file mode 100644 index 1eed93f49a0e..000000000000 --- a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-const-type/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Identifier 'A' has already been declared (2:5)" -} diff --git a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-const-type/output.json b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-const-type/output.json new file mode 100644 index 000000000000..a69cbb049a89 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-const-type/output.json @@ -0,0 +1,162 @@ +{ + "type": "File", + "start": 0, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 12 + } + }, + "errors": [ + "SyntaxError: Identifier 'A' has already been declared (2:5)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 12 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "VariableDeclaration", + "start": 0, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 6, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "id": { + "type": "Identifier", + "start": 6, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + }, + "identifierName": "A" + }, + "name": "A" + }, + "init": { + "type": "NumericLiteral", + "start": 10, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + } + } + ], + "kind": "const" + }, + { + "type": "TypeAlias", + "start": 13, + "end": 25, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 12 + } + }, + "id": { + "type": "Identifier", + "start": 18, + "end": 19, + "loc": { + "start": { + "line": 2, + "column": 5 + }, + "end": { + "line": 2, + "column": 6 + }, + "identifierName": "A" + }, + "name": "A" + }, + "typeParameters": null, + "right": { + "type": "ObjectTypeAnnotation", + "start": 22, + "end": 24, + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 11 + } + }, + "callProperties": [], + "properties": [], + "indexers": [], + "internalSlots": [], + "exact": false, + "inexact": false + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-declare-class-declare-interface/options.json b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-declare-class-declare-interface/options.json index 187fea591b95..3962be507d38 100644 --- a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-declare-class-declare-interface/options.json +++ b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-declare-class-declare-interface/options.json @@ -1,3 +1,7 @@ { - "throws": "Identifier 'A' has already been declared (2:18)" -} + "sourceType": "module", + "plugins": [ + "jsx", + "flow" + ] +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-declare-class-declare-interface/output.json b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-declare-class-declare-interface/output.json new file mode 100644 index 000000000000..a5e92908c53a --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-declare-class-declare-interface/output.json @@ -0,0 +1,150 @@ +{ + "type": "File", + "start": 0, + "end": 41, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 22 + } + }, + "errors": [ + "SyntaxError: Identifier 'A' has already been declared (2:18)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 41, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 22 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "DeclareClass", + "start": 0, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "id": { + "type": "Identifier", + "start": 14, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 15 + }, + "identifierName": "A" + }, + "name": "A" + }, + "typeParameters": null, + "extends": [], + "implements": [], + "mixins": [], + "body": { + "type": "ObjectTypeAnnotation", + "start": 16, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "callProperties": [], + "properties": [], + "indexers": [], + "internalSlots": [], + "exact": false + } + }, + { + "type": "DeclareInterface", + "start": 19, + "end": 41, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 22 + } + }, + "id": { + "type": "Identifier", + "start": 37, + "end": 38, + "loc": { + "start": { + "line": 2, + "column": 18 + }, + "end": { + "line": 2, + "column": 19 + }, + "identifierName": "A" + }, + "name": "A" + }, + "typeParameters": null, + "extends": [], + "implements": [], + "mixins": [], + "body": { + "type": "ObjectTypeAnnotation", + "start": 39, + "end": 41, + "loc": { + "start": { + "line": 2, + "column": 20 + }, + "end": { + "line": 2, + "column": 22 + } + }, + "callProperties": [], + "properties": [], + "indexers": [], + "internalSlots": [], + "exact": false + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-declare-interface-declare-class/options.json b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-declare-interface-declare-class/options.json index 4a1b4e5c5cd4..3962be507d38 100644 --- a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-declare-interface-declare-class/options.json +++ b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-declare-interface-declare-class/options.json @@ -1,3 +1,7 @@ { - "throws": "Identifier 'A' has already been declared (2:14)" -} + "sourceType": "module", + "plugins": [ + "jsx", + "flow" + ] +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-declare-interface-declare-class/output.json b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-declare-interface-declare-class/output.json new file mode 100644 index 000000000000..b2a4c51e2bc0 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-declare-interface-declare-class/output.json @@ -0,0 +1,150 @@ +{ + "type": "File", + "start": 0, + "end": 41, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 18 + } + }, + "errors": [ + "SyntaxError: Identifier 'A' has already been declared (2:14)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 41, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 18 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "DeclareInterface", + "start": 0, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "id": { + "type": "Identifier", + "start": 18, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 19 + }, + "identifierName": "A" + }, + "name": "A" + }, + "typeParameters": null, + "extends": [], + "implements": [], + "mixins": [], + "body": { + "type": "ObjectTypeAnnotation", + "start": 20, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 20 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "callProperties": [], + "properties": [], + "indexers": [], + "internalSlots": [], + "exact": false + } + }, + { + "type": "DeclareClass", + "start": 23, + "end": 41, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 18 + } + }, + "id": { + "type": "Identifier", + "start": 37, + "end": 38, + "loc": { + "start": { + "line": 2, + "column": 14 + }, + "end": { + "line": 2, + "column": 15 + }, + "identifierName": "A" + }, + "name": "A" + }, + "typeParameters": null, + "extends": [], + "implements": [], + "mixins": [], + "body": { + "type": "ObjectTypeAnnotation", + "start": 39, + "end": 41, + "loc": { + "start": { + "line": 2, + "column": 16 + }, + "end": { + "line": 2, + "column": 18 + } + }, + "callProperties": [], + "properties": [], + "indexers": [], + "internalSlots": [], + "exact": false + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-declare-var-let/options.json b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-declare-var-let/options.json index b6ff3a4b0987..3962be507d38 100644 --- a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-declare-var-let/options.json +++ b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-declare-var-let/options.json @@ -1,3 +1,7 @@ { - "throws": "Identifier 'A' has already been declared (2:4)" -} + "sourceType": "module", + "plugins": [ + "jsx", + "flow" + ] +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-declare-var-let/output.json b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-declare-var-let/output.json new file mode 100644 index 000000000000..8389c568e814 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-declare-var-let/output.json @@ -0,0 +1,151 @@ +{ + "type": "File", + "start": 0, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 6 + } + }, + "errors": [ + "SyntaxError: Identifier 'A' has already been declared (2:4)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 6 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "DeclareVariable", + "start": 0, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "id": { + "type": "Identifier", + "start": 12, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 21 + }, + "identifierName": "A" + }, + "name": "A", + "typeAnnotation": { + "type": "TypeAnnotation", + "start": 13, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "typeAnnotation": { + "type": "NumberTypeAnnotation", + "start": 15, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 21 + } + } + } + } + } + }, + { + "type": "VariableDeclaration", + "start": 23, + "end": 29, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 6 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 27, + "end": 28, + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 5 + } + }, + "id": { + "type": "Identifier", + "start": 27, + "end": 28, + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 5 + }, + "identifierName": "A" + }, + "name": "A" + }, + "init": null + } + ], + "kind": "let" + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-interface-interface/options.json b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-interface-interface/options.json index 04242bd1565b..3962be507d38 100644 --- a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-interface-interface/options.json +++ b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-interface-interface/options.json @@ -1,3 +1,7 @@ { - "throws": "Identifier 'A' has already been declared (2:10)" -} + "sourceType": "module", + "plugins": [ + "jsx", + "flow" + ] +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-interface-interface/output.json b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-interface-interface/output.json new file mode 100644 index 000000000000..d79d846383cf --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-interface-interface/output.json @@ -0,0 +1,150 @@ +{ + "type": "File", + "start": 0, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 14 + } + }, + "errors": [ + "SyntaxError: Identifier 'A' has already been declared (2:10)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 14 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "InterfaceDeclaration", + "start": 0, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "id": { + "type": "Identifier", + "start": 10, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 11 + }, + "identifierName": "A" + }, + "name": "A" + }, + "typeParameters": null, + "extends": [], + "implements": [], + "mixins": [], + "body": { + "type": "ObjectTypeAnnotation", + "start": 12, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "callProperties": [], + "properties": [], + "indexers": [], + "internalSlots": [], + "exact": false + } + }, + { + "type": "InterfaceDeclaration", + "start": 15, + "end": 29, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 14 + } + }, + "id": { + "type": "Identifier", + "start": 25, + "end": 26, + "loc": { + "start": { + "line": 2, + "column": 10 + }, + "end": { + "line": 2, + "column": 11 + }, + "identifierName": "A" + }, + "name": "A" + }, + "typeParameters": null, + "extends": [], + "implements": [], + "mixins": [], + "body": { + "type": "ObjectTypeAnnotation", + "start": 27, + "end": 29, + "loc": { + "start": { + "line": 2, + "column": 12 + }, + "end": { + "line": 2, + "column": 14 + } + }, + "callProperties": [], + "properties": [], + "indexers": [], + "internalSlots": [], + "exact": false + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-let-declare-class/options.json b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-let-declare-class/options.json index 4a1b4e5c5cd4..3962be507d38 100644 --- a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-let-declare-class/options.json +++ b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-let-declare-class/options.json @@ -1,3 +1,7 @@ { - "throws": "Identifier 'A' has already been declared (2:14)" -} + "sourceType": "module", + "plugins": [ + "jsx", + "flow" + ] +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-let-declare-class/output.json b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-let-declare-class/output.json new file mode 100644 index 000000000000..2dbdc1e727c2 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-let-declare-class/output.json @@ -0,0 +1,164 @@ +{ + "type": "File", + "start": 0, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 18 + } + }, + "errors": [ + "SyntaxError: Identifier 'A' has already been declared (2:14)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 18 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "VariableDeclaration", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 4, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "id": { + "type": "Identifier", + "start": 4, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 5 + }, + "identifierName": "A" + }, + "name": "A" + }, + "init": { + "type": "NumericLiteral", + "start": 8, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + } + } + ], + "kind": "let" + }, + { + "type": "DeclareClass", + "start": 11, + "end": 29, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 18 + } + }, + "id": { + "type": "Identifier", + "start": 25, + "end": 26, + "loc": { + "start": { + "line": 2, + "column": 14 + }, + "end": { + "line": 2, + "column": 15 + }, + "identifierName": "A" + }, + "name": "A" + }, + "typeParameters": null, + "extends": [], + "implements": [], + "mixins": [], + "body": { + "type": "ObjectTypeAnnotation", + "start": 27, + "end": 29, + "loc": { + "start": { + "line": 2, + "column": 16 + }, + "end": { + "line": 2, + "column": 18 + } + }, + "callProperties": [], + "properties": [], + "indexers": [], + "internalSlots": [], + "exact": false + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-let-declare-interface/options.json b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-let-declare-interface/options.json index 187fea591b95..3962be507d38 100644 --- a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-let-declare-interface/options.json +++ b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-let-declare-interface/options.json @@ -1,3 +1,7 @@ { - "throws": "Identifier 'A' has already been declared (2:18)" -} + "sourceType": "module", + "plugins": [ + "jsx", + "flow" + ] +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-let-declare-interface/output.json b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-let-declare-interface/output.json new file mode 100644 index 000000000000..a13ba7dc082c --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-let-declare-interface/output.json @@ -0,0 +1,164 @@ +{ + "type": "File", + "start": 0, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 22 + } + }, + "errors": [ + "SyntaxError: Identifier 'A' has already been declared (2:18)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 22 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "VariableDeclaration", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 4, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "id": { + "type": "Identifier", + "start": 4, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 5 + }, + "identifierName": "A" + }, + "name": "A" + }, + "init": { + "type": "NumericLiteral", + "start": 8, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + } + } + ], + "kind": "let" + }, + { + "type": "DeclareInterface", + "start": 11, + "end": 33, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 22 + } + }, + "id": { + "type": "Identifier", + "start": 29, + "end": 30, + "loc": { + "start": { + "line": 2, + "column": 18 + }, + "end": { + "line": 2, + "column": 19 + }, + "identifierName": "A" + }, + "name": "A" + }, + "typeParameters": null, + "extends": [], + "implements": [], + "mixins": [], + "body": { + "type": "ObjectTypeAnnotation", + "start": 31, + "end": 33, + "loc": { + "start": { + "line": 2, + "column": 20 + }, + "end": { + "line": 2, + "column": 22 + } + }, + "callProperties": [], + "properties": [], + "indexers": [], + "internalSlots": [], + "exact": false + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-let-interface/options.json b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-let-interface/options.json index 04242bd1565b..3962be507d38 100644 --- a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-let-interface/options.json +++ b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-let-interface/options.json @@ -1,3 +1,7 @@ { - "throws": "Identifier 'A' has already been declared (2:10)" -} + "sourceType": "module", + "plugins": [ + "jsx", + "flow" + ] +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-let-interface/output.json b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-let-interface/output.json new file mode 100644 index 000000000000..a8dc40e08d4c --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-let-interface/output.json @@ -0,0 +1,164 @@ +{ + "type": "File", + "start": 0, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 14 + } + }, + "errors": [ + "SyntaxError: Identifier 'A' has already been declared (2:10)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 14 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "VariableDeclaration", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 4, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "id": { + "type": "Identifier", + "start": 4, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 5 + }, + "identifierName": "A" + }, + "name": "A" + }, + "init": { + "type": "NumericLiteral", + "start": 8, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + } + } + ], + "kind": "let" + }, + { + "type": "InterfaceDeclaration", + "start": 11, + "end": 25, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 14 + } + }, + "id": { + "type": "Identifier", + "start": 21, + "end": 22, + "loc": { + "start": { + "line": 2, + "column": 10 + }, + "end": { + "line": 2, + "column": 11 + }, + "identifierName": "A" + }, + "name": "A" + }, + "typeParameters": null, + "extends": [], + "implements": [], + "mixins": [], + "body": { + "type": "ObjectTypeAnnotation", + "start": 23, + "end": 25, + "loc": { + "start": { + "line": 2, + "column": 12 + }, + "end": { + "line": 2, + "column": 14 + } + }, + "callProperties": [], + "properties": [], + "indexers": [], + "internalSlots": [], + "exact": false + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-let-opaque-type/options.json b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-let-opaque-type/options.json deleted file mode 100644 index 81dc2c90799f..000000000000 --- a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-let-opaque-type/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Identifier 'A' has already been declared (2:12)" -} diff --git a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-let-opaque-type/output.json b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-let-opaque-type/output.json new file mode 100644 index 000000000000..07a5a53fbc08 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-let-opaque-type/output.json @@ -0,0 +1,163 @@ +{ + "type": "File", + "start": 0, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 19 + } + }, + "errors": [ + "SyntaxError: Identifier 'A' has already been declared (2:12)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 19 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "VariableDeclaration", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 4, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "id": { + "type": "Identifier", + "start": 4, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 5 + }, + "identifierName": "A" + }, + "name": "A" + }, + "init": { + "type": "NumericLiteral", + "start": 8, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + } + } + ], + "kind": "let" + }, + { + "type": "OpaqueType", + "start": 11, + "end": 30, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 19 + } + }, + "id": { + "type": "Identifier", + "start": 23, + "end": 24, + "loc": { + "start": { + "line": 2, + "column": 12 + }, + "end": { + "line": 2, + "column": 13 + }, + "identifierName": "A" + }, + "name": "A" + }, + "typeParameters": null, + "supertype": null, + "impltype": { + "type": "ObjectTypeAnnotation", + "start": 27, + "end": 29, + "loc": { + "start": { + "line": 2, + "column": 16 + }, + "end": { + "line": 2, + "column": 18 + } + }, + "callProperties": [], + "properties": [], + "indexers": [], + "internalSlots": [], + "exact": false, + "inexact": false + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-let-type/options.json b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-let-type/options.json deleted file mode 100644 index 1eed93f49a0e..000000000000 --- a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-let-type/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Identifier 'A' has already been declared (2:5)" -} diff --git a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-let-type/output.json b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-let-type/output.json new file mode 100644 index 000000000000..6833e37c4de1 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-let-type/output.json @@ -0,0 +1,162 @@ +{ + "type": "File", + "start": 0, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 12 + } + }, + "errors": [ + "SyntaxError: Identifier 'A' has already been declared (2:5)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 12 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "VariableDeclaration", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 4, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "id": { + "type": "Identifier", + "start": 4, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 5 + }, + "identifierName": "A" + }, + "name": "A" + }, + "init": { + "type": "NumericLiteral", + "start": 8, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + } + } + ], + "kind": "let" + }, + { + "type": "TypeAlias", + "start": 11, + "end": 23, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 12 + } + }, + "id": { + "type": "Identifier", + "start": 16, + "end": 17, + "loc": { + "start": { + "line": 2, + "column": 5 + }, + "end": { + "line": 2, + "column": 6 + }, + "identifierName": "A" + }, + "name": "A" + }, + "typeParameters": null, + "right": { + "type": "ObjectTypeAnnotation", + "start": 20, + "end": 22, + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 11 + } + }, + "callProperties": [], + "properties": [], + "indexers": [], + "internalSlots": [], + "exact": false, + "inexact": false + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-opaque-type-const/options.json b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-opaque-type-const/options.json deleted file mode 100644 index 336686170eb0..000000000000 --- a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-opaque-type-const/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Identifier 'A' has already been declared (2:6)" -} diff --git a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-opaque-type-const/output.json b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-opaque-type-const/output.json new file mode 100644 index 000000000000..b374e2bcebd9 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-opaque-type-const/output.json @@ -0,0 +1,163 @@ +{ + "type": "File", + "start": 0, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 12 + } + }, + "errors": [ + "SyntaxError: Identifier 'A' has already been declared (2:6)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 12 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "OpaqueType", + "start": 0, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "id": { + "type": "Identifier", + "start": 12, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 13 + }, + "identifierName": "A" + }, + "name": "A" + }, + "typeParameters": null, + "supertype": null, + "impltype": { + "type": "ObjectTypeAnnotation", + "start": 16, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "callProperties": [], + "properties": [], + "indexers": [], + "internalSlots": [], + "exact": false, + "inexact": false + } + }, + { + "type": "VariableDeclaration", + "start": 20, + "end": 32, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 12 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 26, + "end": 31, + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 11 + } + }, + "id": { + "type": "Identifier", + "start": 26, + "end": 27, + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 7 + }, + "identifierName": "A" + }, + "name": "A" + }, + "init": { + "type": "NumericLiteral", + "start": 30, + "end": 31, + "loc": { + "start": { + "line": 2, + "column": 10 + }, + "end": { + "line": 2, + "column": 11 + } + }, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + } + } + ], + "kind": "const" + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-opaque-type-let/options.json b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-opaque-type-let/options.json deleted file mode 100644 index b6ff3a4b0987..000000000000 --- a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-opaque-type-let/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Identifier 'A' has already been declared (2:4)" -} diff --git a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-opaque-type-let/output.json b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-opaque-type-let/output.json new file mode 100644 index 000000000000..9f326dfe3e5e --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-opaque-type-let/output.json @@ -0,0 +1,163 @@ +{ + "type": "File", + "start": 0, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 10 + } + }, + "errors": [ + "SyntaxError: Identifier 'A' has already been declared (2:4)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 10 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "OpaqueType", + "start": 0, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "id": { + "type": "Identifier", + "start": 12, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 13 + }, + "identifierName": "A" + }, + "name": "A" + }, + "typeParameters": null, + "supertype": null, + "impltype": { + "type": "ObjectTypeAnnotation", + "start": 16, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "callProperties": [], + "properties": [], + "indexers": [], + "internalSlots": [], + "exact": false, + "inexact": false + } + }, + { + "type": "VariableDeclaration", + "start": 20, + "end": 30, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 10 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 24, + "end": 29, + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 9 + } + }, + "id": { + "type": "Identifier", + "start": 24, + "end": 25, + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 5 + }, + "identifierName": "A" + }, + "name": "A" + }, + "init": { + "type": "NumericLiteral", + "start": 28, + "end": 29, + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 9 + } + }, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + } + } + ], + "kind": "let" + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-opaque-type-opaque-type/options.json b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-opaque-type-opaque-type/options.json deleted file mode 100644 index 81dc2c90799f..000000000000 --- a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-opaque-type-opaque-type/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Identifier 'A' has already been declared (2:12)" -} diff --git a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-opaque-type-opaque-type/output.json b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-opaque-type-opaque-type/output.json new file mode 100644 index 000000000000..86b98af15006 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-opaque-type-opaque-type/output.json @@ -0,0 +1,148 @@ +{ + "type": "File", + "start": 0, + "end": 39, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 19 + } + }, + "errors": [ + "SyntaxError: Identifier 'A' has already been declared (2:12)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 39, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 19 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "OpaqueType", + "start": 0, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "id": { + "type": "Identifier", + "start": 12, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 13 + }, + "identifierName": "A" + }, + "name": "A" + }, + "typeParameters": null, + "supertype": null, + "impltype": { + "type": "ObjectTypeAnnotation", + "start": 16, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "callProperties": [], + "properties": [], + "indexers": [], + "internalSlots": [], + "exact": false, + "inexact": false + } + }, + { + "type": "OpaqueType", + "start": 20, + "end": 39, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 19 + } + }, + "id": { + "type": "Identifier", + "start": 32, + "end": 33, + "loc": { + "start": { + "line": 2, + "column": 12 + }, + "end": { + "line": 2, + "column": 13 + }, + "identifierName": "A" + }, + "name": "A" + }, + "typeParameters": null, + "supertype": null, + "impltype": { + "type": "ObjectTypeAnnotation", + "start": 36, + "end": 38, + "loc": { + "start": { + "line": 2, + "column": 16 + }, + "end": { + "line": 2, + "column": 18 + } + }, + "callProperties": [], + "properties": [], + "indexers": [], + "internalSlots": [], + "exact": false, + "inexact": false + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-opaque-type-type/options.json b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-opaque-type-type/options.json deleted file mode 100644 index 1eed93f49a0e..000000000000 --- a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-opaque-type-type/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Identifier 'A' has already been declared (2:5)" -} diff --git a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-opaque-type-type/output.json b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-opaque-type-type/output.json new file mode 100644 index 000000000000..76300249f569 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-opaque-type-type/output.json @@ -0,0 +1,147 @@ +{ + "type": "File", + "start": 0, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 12 + } + }, + "errors": [ + "SyntaxError: Identifier 'A' has already been declared (2:5)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 12 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "OpaqueType", + "start": 0, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "id": { + "type": "Identifier", + "start": 12, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 13 + }, + "identifierName": "A" + }, + "name": "A" + }, + "typeParameters": null, + "supertype": null, + "impltype": { + "type": "ObjectTypeAnnotation", + "start": 16, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "callProperties": [], + "properties": [], + "indexers": [], + "internalSlots": [], + "exact": false, + "inexact": false + } + }, + { + "type": "TypeAlias", + "start": 20, + "end": 32, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 12 + } + }, + "id": { + "type": "Identifier", + "start": 25, + "end": 26, + "loc": { + "start": { + "line": 2, + "column": 5 + }, + "end": { + "line": 2, + "column": 6 + }, + "identifierName": "A" + }, + "name": "A" + }, + "typeParameters": null, + "right": { + "type": "ObjectTypeAnnotation", + "start": 29, + "end": 31, + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 11 + } + }, + "callProperties": [], + "properties": [], + "indexers": [], + "internalSlots": [], + "exact": false, + "inexact": false + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-opaque-type-var/options.json b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-opaque-type-var/options.json deleted file mode 100644 index b6ff3a4b0987..000000000000 --- a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-opaque-type-var/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Identifier 'A' has already been declared (2:4)" -} diff --git a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-opaque-type-var/output.json b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-opaque-type-var/output.json new file mode 100644 index 000000000000..b5b462a59cf5 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-opaque-type-var/output.json @@ -0,0 +1,163 @@ +{ + "type": "File", + "start": 0, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 10 + } + }, + "errors": [ + "SyntaxError: Identifier 'A' has already been declared (2:4)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 10 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "OpaqueType", + "start": 0, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "id": { + "type": "Identifier", + "start": 12, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 13 + }, + "identifierName": "A" + }, + "name": "A" + }, + "typeParameters": null, + "supertype": null, + "impltype": { + "type": "ObjectTypeAnnotation", + "start": 16, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "callProperties": [], + "properties": [], + "indexers": [], + "internalSlots": [], + "exact": false, + "inexact": false + } + }, + { + "type": "VariableDeclaration", + "start": 20, + "end": 30, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 10 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 24, + "end": 29, + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 9 + } + }, + "id": { + "type": "Identifier", + "start": 24, + "end": 25, + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 5 + }, + "identifierName": "A" + }, + "name": "A" + }, + "init": { + "type": "NumericLiteral", + "start": 28, + "end": 29, + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 9 + } + }, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + } + } + ], + "kind": "var" + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-type-const/options.json b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-type-const/options.json deleted file mode 100644 index 336686170eb0..000000000000 --- a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-type-const/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Identifier 'A' has already been declared (2:6)" -} diff --git a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-type-const/output.json b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-type-const/output.json new file mode 100644 index 000000000000..916e60eaa94a --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-type-const/output.json @@ -0,0 +1,162 @@ +{ + "type": "File", + "start": 0, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 12 + } + }, + "errors": [ + "SyntaxError: Identifier 'A' has already been declared (2:6)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 12 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "TypeAlias", + "start": 0, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "id": { + "type": "Identifier", + "start": 5, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 6 + }, + "identifierName": "A" + }, + "name": "A" + }, + "typeParameters": null, + "right": { + "type": "ObjectTypeAnnotation", + "start": 9, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "callProperties": [], + "properties": [], + "indexers": [], + "internalSlots": [], + "exact": false, + "inexact": false + } + }, + { + "type": "VariableDeclaration", + "start": 13, + "end": 25, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 12 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 19, + "end": 24, + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 11 + } + }, + "id": { + "type": "Identifier", + "start": 19, + "end": 20, + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 7 + }, + "identifierName": "A" + }, + "name": "A" + }, + "init": { + "type": "NumericLiteral", + "start": 23, + "end": 24, + "loc": { + "start": { + "line": 2, + "column": 10 + }, + "end": { + "line": 2, + "column": 11 + } + }, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + } + } + ], + "kind": "const" + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-type-interface/options.json b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-type-interface/options.json index 04242bd1565b..3962be507d38 100644 --- a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-type-interface/options.json +++ b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-type-interface/options.json @@ -1,3 +1,7 @@ { - "throws": "Identifier 'A' has already been declared (2:10)" -} + "sourceType": "module", + "plugins": [ + "jsx", + "flow" + ] +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-type-interface/output.json b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-type-interface/output.json new file mode 100644 index 000000000000..0aa57e51c3ff --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-type-interface/output.json @@ -0,0 +1,142 @@ +{ + "type": "File", + "start": 0, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 14 + } + }, + "errors": [ + "SyntaxError: Identifier 'A' has already been declared (2:10)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 14 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "TypeAlias", + "start": 0, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "id": { + "type": "Identifier", + "start": 5, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 6 + }, + "identifierName": "A" + }, + "name": "A" + }, + "typeParameters": null, + "right": { + "type": "NumberTypeAnnotation", + "start": 9, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 15 + } + } + } + }, + { + "type": "InterfaceDeclaration", + "start": 17, + "end": 31, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 14 + } + }, + "id": { + "type": "Identifier", + "start": 27, + "end": 28, + "loc": { + "start": { + "line": 2, + "column": 10 + }, + "end": { + "line": 2, + "column": 11 + }, + "identifierName": "A" + }, + "name": "A" + }, + "typeParameters": null, + "extends": [], + "implements": [], + "mixins": [], + "body": { + "type": "ObjectTypeAnnotation", + "start": 29, + "end": 31, + "loc": { + "start": { + "line": 2, + "column": 12 + }, + "end": { + "line": 2, + "column": 14 + } + }, + "callProperties": [], + "properties": [], + "indexers": [], + "internalSlots": [], + "exact": false + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-type-let/options.json b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-type-let/options.json deleted file mode 100644 index b6ff3a4b0987..000000000000 --- a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-type-let/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Identifier 'A' has already been declared (2:4)" -} diff --git a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-type-let/output.json b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-type-let/output.json new file mode 100644 index 000000000000..6e394ffbcda1 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-type-let/output.json @@ -0,0 +1,162 @@ +{ + "type": "File", + "start": 0, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 10 + } + }, + "errors": [ + "SyntaxError: Identifier 'A' has already been declared (2:4)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 10 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "TypeAlias", + "start": 0, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "id": { + "type": "Identifier", + "start": 5, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 6 + }, + "identifierName": "A" + }, + "name": "A" + }, + "typeParameters": null, + "right": { + "type": "ObjectTypeAnnotation", + "start": 9, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "callProperties": [], + "properties": [], + "indexers": [], + "internalSlots": [], + "exact": false, + "inexact": false + } + }, + { + "type": "VariableDeclaration", + "start": 13, + "end": 23, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 10 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 17, + "end": 22, + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 9 + } + }, + "id": { + "type": "Identifier", + "start": 17, + "end": 18, + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 5 + }, + "identifierName": "A" + }, + "name": "A" + }, + "init": { + "type": "NumericLiteral", + "start": 21, + "end": 22, + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 9 + } + }, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + } + } + ], + "kind": "let" + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-type-opaque-type/options.json b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-type-opaque-type/options.json deleted file mode 100644 index 81dc2c90799f..000000000000 --- a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-type-opaque-type/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Identifier 'A' has already been declared (2:12)" -} diff --git a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-type-opaque-type/output.json b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-type-opaque-type/output.json new file mode 100644 index 000000000000..95d0b22f7cfd --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-type-opaque-type/output.json @@ -0,0 +1,147 @@ +{ + "type": "File", + "start": 0, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 19 + } + }, + "errors": [ + "SyntaxError: Identifier 'A' has already been declared (2:12)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 19 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "TypeAlias", + "start": 0, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "id": { + "type": "Identifier", + "start": 5, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 6 + }, + "identifierName": "A" + }, + "name": "A" + }, + "typeParameters": null, + "right": { + "type": "ObjectTypeAnnotation", + "start": 9, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "callProperties": [], + "properties": [], + "indexers": [], + "internalSlots": [], + "exact": false, + "inexact": false + } + }, + { + "type": "OpaqueType", + "start": 13, + "end": 32, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 19 + } + }, + "id": { + "type": "Identifier", + "start": 25, + "end": 26, + "loc": { + "start": { + "line": 2, + "column": 12 + }, + "end": { + "line": 2, + "column": 13 + }, + "identifierName": "A" + }, + "name": "A" + }, + "typeParameters": null, + "supertype": null, + "impltype": { + "type": "ObjectTypeAnnotation", + "start": 29, + "end": 31, + "loc": { + "start": { + "line": 2, + "column": 16 + }, + "end": { + "line": 2, + "column": 18 + } + }, + "callProperties": [], + "properties": [], + "indexers": [], + "internalSlots": [], + "exact": false, + "inexact": false + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-type-type/options.json b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-type-type/options.json deleted file mode 100644 index 1eed93f49a0e..000000000000 --- a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-type-type/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Identifier 'A' has already been declared (2:5)" -} diff --git a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-type-type/output.json b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-type-type/output.json new file mode 100644 index 000000000000..09c73482f8f1 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-type-type/output.json @@ -0,0 +1,146 @@ +{ + "type": "File", + "start": 0, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 12 + } + }, + "errors": [ + "SyntaxError: Identifier 'A' has already been declared (2:5)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 12 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "TypeAlias", + "start": 0, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "id": { + "type": "Identifier", + "start": 5, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 6 + }, + "identifierName": "A" + }, + "name": "A" + }, + "typeParameters": null, + "right": { + "type": "ObjectTypeAnnotation", + "start": 9, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "callProperties": [], + "properties": [], + "indexers": [], + "internalSlots": [], + "exact": false, + "inexact": false + } + }, + { + "type": "TypeAlias", + "start": 13, + "end": 25, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 12 + } + }, + "id": { + "type": "Identifier", + "start": 18, + "end": 19, + "loc": { + "start": { + "line": 2, + "column": 5 + }, + "end": { + "line": 2, + "column": 6 + }, + "identifierName": "A" + }, + "name": "A" + }, + "typeParameters": null, + "right": { + "type": "ObjectTypeAnnotation", + "start": 22, + "end": 24, + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 11 + } + }, + "callProperties": [], + "properties": [], + "indexers": [], + "internalSlots": [], + "exact": false, + "inexact": false + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-type-var/options.json b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-type-var/options.json deleted file mode 100644 index b6ff3a4b0987..000000000000 --- a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-type-var/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Identifier 'A' has already been declared (2:4)" -} diff --git a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-type-var/output.json b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-type-var/output.json new file mode 100644 index 000000000000..52626b852e33 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-type-var/output.json @@ -0,0 +1,162 @@ +{ + "type": "File", + "start": 0, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 10 + } + }, + "errors": [ + "SyntaxError: Identifier 'A' has already been declared (2:4)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 10 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "TypeAlias", + "start": 0, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "id": { + "type": "Identifier", + "start": 5, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 6 + }, + "identifierName": "A" + }, + "name": "A" + }, + "typeParameters": null, + "right": { + "type": "ObjectTypeAnnotation", + "start": 9, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "callProperties": [], + "properties": [], + "indexers": [], + "internalSlots": [], + "exact": false, + "inexact": false + } + }, + { + "type": "VariableDeclaration", + "start": 13, + "end": 23, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 10 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 17, + "end": 22, + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 9 + } + }, + "id": { + "type": "Identifier", + "start": 17, + "end": 18, + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 5 + }, + "identifierName": "A" + }, + "name": "A" + }, + "init": { + "type": "NumericLiteral", + "start": 21, + "end": 22, + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 9 + } + }, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + } + } + ], + "kind": "var" + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-var-declare-interface/options.json b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-var-declare-interface/options.json index 187fea591b95..3962be507d38 100644 --- a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-var-declare-interface/options.json +++ b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-var-declare-interface/options.json @@ -1,3 +1,7 @@ { - "throws": "Identifier 'A' has already been declared (2:18)" -} + "sourceType": "module", + "plugins": [ + "jsx", + "flow" + ] +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-var-declare-interface/output.json b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-var-declare-interface/output.json new file mode 100644 index 000000000000..f60940e178bf --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-var-declare-interface/output.json @@ -0,0 +1,164 @@ +{ + "type": "File", + "start": 0, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 22 + } + }, + "errors": [ + "SyntaxError: Identifier 'A' has already been declared (2:18)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 22 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "VariableDeclaration", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 4, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "id": { + "type": "Identifier", + "start": 4, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 5 + }, + "identifierName": "A" + }, + "name": "A" + }, + "init": { + "type": "NumericLiteral", + "start": 8, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + } + } + ], + "kind": "var" + }, + { + "type": "DeclareInterface", + "start": 11, + "end": 33, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 22 + } + }, + "id": { + "type": "Identifier", + "start": 29, + "end": 30, + "loc": { + "start": { + "line": 2, + "column": 18 + }, + "end": { + "line": 2, + "column": 19 + }, + "identifierName": "A" + }, + "name": "A" + }, + "typeParameters": null, + "extends": [], + "implements": [], + "mixins": [], + "body": { + "type": "ObjectTypeAnnotation", + "start": 31, + "end": 33, + "loc": { + "start": { + "line": 2, + "column": 20 + }, + "end": { + "line": 2, + "column": 22 + } + }, + "callProperties": [], + "properties": [], + "indexers": [], + "internalSlots": [], + "exact": false + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-var-interface/options.json b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-var-interface/options.json index 04242bd1565b..3962be507d38 100644 --- a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-var-interface/options.json +++ b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-var-interface/options.json @@ -1,3 +1,7 @@ { - "throws": "Identifier 'A' has already been declared (2:10)" -} + "sourceType": "module", + "plugins": [ + "jsx", + "flow" + ] +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-var-interface/output.json b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-var-interface/output.json new file mode 100644 index 000000000000..271c66e47dd7 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-var-interface/output.json @@ -0,0 +1,164 @@ +{ + "type": "File", + "start": 0, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 14 + } + }, + "errors": [ + "SyntaxError: Identifier 'A' has already been declared (2:10)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 14 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "VariableDeclaration", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 4, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "id": { + "type": "Identifier", + "start": 4, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 5 + }, + "identifierName": "A" + }, + "name": "A" + }, + "init": { + "type": "NumericLiteral", + "start": 8, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + } + } + ], + "kind": "var" + }, + { + "type": "InterfaceDeclaration", + "start": 11, + "end": 25, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 14 + } + }, + "id": { + "type": "Identifier", + "start": 21, + "end": 22, + "loc": { + "start": { + "line": 2, + "column": 10 + }, + "end": { + "line": 2, + "column": 11 + }, + "identifierName": "A" + }, + "name": "A" + }, + "typeParameters": null, + "extends": [], + "implements": [], + "mixins": [], + "body": { + "type": "ObjectTypeAnnotation", + "start": 23, + "end": 25, + "loc": { + "start": { + "line": 2, + "column": 12 + }, + "end": { + "line": 2, + "column": 14 + } + }, + "callProperties": [], + "properties": [], + "indexers": [], + "internalSlots": [], + "exact": false + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-var-opaque-type/options.json b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-var-opaque-type/options.json deleted file mode 100644 index 81dc2c90799f..000000000000 --- a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-var-opaque-type/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Identifier 'A' has already been declared (2:12)" -} diff --git a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-var-opaque-type/output.json b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-var-opaque-type/output.json new file mode 100644 index 000000000000..d41f91a9d947 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-var-opaque-type/output.json @@ -0,0 +1,163 @@ +{ + "type": "File", + "start": 0, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 19 + } + }, + "errors": [ + "SyntaxError: Identifier 'A' has already been declared (2:12)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 19 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "VariableDeclaration", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 4, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "id": { + "type": "Identifier", + "start": 4, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 5 + }, + "identifierName": "A" + }, + "name": "A" + }, + "init": { + "type": "NumericLiteral", + "start": 8, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + } + } + ], + "kind": "var" + }, + { + "type": "OpaqueType", + "start": 11, + "end": 30, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 19 + } + }, + "id": { + "type": "Identifier", + "start": 23, + "end": 24, + "loc": { + "start": { + "line": 2, + "column": 12 + }, + "end": { + "line": 2, + "column": 13 + }, + "identifierName": "A" + }, + "name": "A" + }, + "typeParameters": null, + "supertype": null, + "impltype": { + "type": "ObjectTypeAnnotation", + "start": 27, + "end": 29, + "loc": { + "start": { + "line": 2, + "column": 16 + }, + "end": { + "line": 2, + "column": 18 + } + }, + "callProperties": [], + "properties": [], + "indexers": [], + "internalSlots": [], + "exact": false, + "inexact": false + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-var-type/options.json b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-var-type/options.json deleted file mode 100644 index 1eed93f49a0e..000000000000 --- a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-var-type/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Identifier 'A' has already been declared (2:5)" -} diff --git a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-var-type/output.json b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-var-type/output.json new file mode 100644 index 000000000000..4f1dcc135976 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-var-type/output.json @@ -0,0 +1,162 @@ +{ + "type": "File", + "start": 0, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 12 + } + }, + "errors": [ + "SyntaxError: Identifier 'A' has already been declared (2:5)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 12 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "VariableDeclaration", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 4, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "id": { + "type": "Identifier", + "start": 4, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 5 + }, + "identifierName": "A" + }, + "name": "A" + }, + "init": { + "type": "NumericLiteral", + "start": 8, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + } + } + ], + "kind": "var" + }, + { + "type": "TypeAlias", + "start": 11, + "end": 23, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 12 + } + }, + "id": { + "type": "Identifier", + "start": 16, + "end": 17, + "loc": { + "start": { + "line": 2, + "column": 5 + }, + "end": { + "line": 2, + "column": 6 + }, + "identifierName": "A" + }, + "name": "A" + }, + "typeParameters": null, + "right": { + "type": "ObjectTypeAnnotation", + "start": 20, + "end": 22, + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 11 + } + }, + "callProperties": [], + "properties": [], + "indexers": [], + "internalSlots": [], + "exact": false, + "inexact": false + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/type-annotations/131/options.json b/packages/babel-parser/test/fixtures/flow/type-annotations/131/options.json deleted file mode 100644 index 50bea8a5db27..000000000000 --- a/packages/babel-parser/test/fixtures/flow/type-annotations/131/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Cannot overwrite reserved type number (1:5)" -} diff --git a/packages/babel-parser/test/fixtures/flow/type-annotations/131/output.json b/packages/babel-parser/test/fixtures/flow/type-annotations/131/output.json new file mode 100644 index 000000000000..ef2bc17e2d96 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/type-annotations/131/output.json @@ -0,0 +1,86 @@ +{ + "type": "File", + "start": 0, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "errors": [ + "SyntaxError: Cannot overwrite reserved type number (1:5)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "TypeAlias", + "start": 0, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "id": { + "type": "Identifier", + "start": 5, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 11 + }, + "identifierName": "number" + }, + "name": "number" + }, + "typeParameters": null, + "right": { + "type": "StringTypeAnnotation", + "start": 14, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 20 + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/type-annotations/132/options.json b/packages/babel-parser/test/fixtures/flow/type-annotations/132/options.json deleted file mode 100644 index 257d651b33e2..000000000000 --- a/packages/babel-parser/test/fixtures/flow/type-annotations/132/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Cannot overwrite reserved type number (1:9)" -} diff --git a/packages/babel-parser/test/fixtures/flow/type-annotations/132/output.json b/packages/babel-parser/test/fixtures/flow/type-annotations/132/output.json new file mode 100644 index 000000000000..aa2b8b19ecb0 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/type-annotations/132/output.json @@ -0,0 +1,119 @@ +{ + "type": "File", + "start": 0, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "errors": [ + "SyntaxError: Cannot overwrite reserved type number (1:9)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "TypeAlias", + "start": 0, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "id": { + "type": "Identifier", + "start": 5, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 8 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "typeParameters": { + "type": "TypeParameterDeclaration", + "start": 8, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "params": [ + { + "type": "TypeParameter", + "start": 9, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "name": "number", + "variance": null + } + ] + }, + "right": { + "type": "StringTypeAnnotation", + "start": 19, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 25 + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/type-annotations/133/options.json b/packages/babel-parser/test/fixtures/flow/type-annotations/133/options.json deleted file mode 100644 index 2c7a5836d8bc..000000000000 --- a/packages/babel-parser/test/fixtures/flow/type-annotations/133/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Cannot overwrite reserved type string (1:11)" -} diff --git a/packages/babel-parser/test/fixtures/flow/type-annotations/133/output.json b/packages/babel-parser/test/fixtures/flow/type-annotations/133/output.json new file mode 100644 index 000000000000..bb722c84feec --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/type-annotations/133/output.json @@ -0,0 +1,236 @@ +{ + "type": "File", + "start": 0, + "end": 53, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "errors": [ + "SyntaxError: Cannot overwrite reserved type string (1:11)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 53, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 53, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 10 + }, + "identifierName": "a" + }, + "name": "a" + }, + "generator": false, + "async": false, + "typeParameters": { + "type": "TypeParameterDeclaration", + "start": 10, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "params": [ + { + "type": "TypeParameter", + "start": 11, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "name": "string", + "variance": null + } + ] + }, + "params": [ + { + "type": "Identifier", + "start": 19, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 28 + }, + "identifierName": "x" + }, + "name": "x", + "typeAnnotation": { + "type": "TypeAnnotation", + "start": 20, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 20 + }, + "end": { + "line": 1, + "column": 28 + } + }, + "typeAnnotation": { + "type": "StringTypeAnnotation", + "start": 22, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 22 + }, + "end": { + "line": 1, + "column": 28 + } + } + } + } + } + ], + "predicate": null, + "returnType": { + "type": "TypeAnnotation", + "start": 29, + "end": 37, + "loc": { + "start": { + "line": 1, + "column": 29 + }, + "end": { + "line": 1, + "column": 37 + } + }, + "typeAnnotation": { + "type": "StringTypeAnnotation", + "start": 31, + "end": 37, + "loc": { + "start": { + "line": 1, + "column": 31 + }, + "end": { + "line": 1, + "column": 37 + } + } + } + }, + "body": { + "type": "BlockStatement", + "start": 38, + "end": 53, + "loc": { + "start": { + "line": 1, + "column": 38 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "body": [ + { + "type": "ReturnStatement", + "start": 42, + "end": 51, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 11 + } + }, + "argument": { + "type": "Identifier", + "start": 49, + "end": 50, + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 10 + }, + "identifierName": "x" + }, + "name": "x" + } + } + ], + "directives": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/type-annotations/134/options.json b/packages/babel-parser/test/fixtures/flow/type-annotations/134/options.json deleted file mode 100644 index 396a14ca22d4..000000000000 --- a/packages/babel-parser/test/fixtures/flow/type-annotations/134/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Cannot overwrite reserved type bool (1:13)" -} diff --git a/packages/babel-parser/test/fixtures/flow/type-annotations/134/output.json b/packages/babel-parser/test/fixtures/flow/type-annotations/134/output.json new file mode 100644 index 000000000000..c88abb4a585c --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/type-annotations/134/output.json @@ -0,0 +1,86 @@ +{ + "type": "File", + "start": 0, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "errors": [ + "SyntaxError: Cannot overwrite reserved type bool (1:13)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "DeclareTypeAlias", + "start": 0, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "id": { + "type": "Identifier", + "start": 13, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 17 + }, + "identifierName": "bool" + }, + "name": "bool" + }, + "typeParameters": null, + "right": { + "type": "AnyTypeAnnotation", + "start": 20, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 20 + }, + "end": { + "line": 1, + "column": 23 + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/type-annotations/137/options.json b/packages/babel-parser/test/fixtures/flow/type-annotations/137/options.json deleted file mode 100644 index 786acad32af0..000000000000 --- a/packages/babel-parser/test/fixtures/flow/type-annotations/137/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Spread operator cannot appear in class or interface definitions (2:1)" -} diff --git a/packages/babel-parser/test/fixtures/flow/type-annotations/137/output.json b/packages/babel-parser/test/fixtures/flow/type-annotations/137/output.json new file mode 100644 index 000000000000..2e33b31f6c8f --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/type-annotations/137/output.json @@ -0,0 +1,140 @@ +{ + "type": "File", + "start": 0, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 2 + } + }, + "errors": [ + "SyntaxError: Spread operator cannot appear in class or interface definitions (2:1)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 2 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "InterfaceDeclaration", + "start": 0, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 10, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 11 + }, + "identifierName": "A" + }, + "name": "A" + }, + "typeParameters": null, + "extends": [], + "implements": [], + "mixins": [], + "body": { + "type": "ObjectTypeAnnotation", + "start": 12, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "callProperties": [], + "properties": [ + { + "type": "ObjectTypeSpreadProperty", + "start": 15, + "end": 21, + "loc": { + "start": { + "line": 2, + "column": 1 + }, + "end": { + "line": 2, + "column": 7 + } + }, + "argument": { + "type": "AnyTypeAnnotation", + "start": 18, + "end": 21, + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 7 + } + } + } + } + ], + "indexers": [], + "internalSlots": [], + "exact": false + } + }, + { + "type": "EmptyStatement", + "start": 24, + "end": 25, + "loc": { + "start": { + "line": 3, + "column": 1 + }, + "end": { + "line": 3, + "column": 2 + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/type-annotations/139/options.json b/packages/babel-parser/test/fixtures/flow/type-annotations/139/options.json deleted file mode 100644 index 2b0782bcbc3e..000000000000 --- a/packages/babel-parser/test/fixtures/flow/type-annotations/139/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Spread properties cannot have variance (3:1)" -} diff --git a/packages/babel-parser/test/fixtures/flow/type-annotations/139/output.json b/packages/babel-parser/test/fixtures/flow/type-annotations/139/output.json new file mode 100644 index 000000000000..6d1756ac6212 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/type-annotations/139/output.json @@ -0,0 +1,190 @@ +{ + "type": "File", + "start": 0, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 2 + } + }, + "errors": [ + "SyntaxError: Spread properties cannot have variance (3:1)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 2 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ClassDeclaration", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "id": { + "type": "Identifier", + "start": 6, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + }, + "identifierName": "A" + }, + "name": "A" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "start": 8, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "body": [] + } + }, + { + "type": "TypeAlias", + "start": 11, + "end": 31, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 4, + "column": 2 + } + }, + "id": { + "type": "Identifier", + "start": 16, + "end": 17, + "loc": { + "start": { + "line": 2, + "column": 5 + }, + "end": { + "line": 2, + "column": 6 + }, + "identifierName": "C" + }, + "name": "C" + }, + "typeParameters": null, + "right": { + "type": "ObjectTypeAnnotation", + "start": 20, + "end": 30, + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "callProperties": [], + "properties": [ + { + "type": "ObjectTypeSpreadProperty", + "start": 23, + "end": 28, + "loc": { + "start": { + "line": 3, + "column": 1 + }, + "end": { + "line": 3, + "column": 6 + } + }, + "argument": { + "type": "GenericTypeAnnotation", + "start": 27, + "end": 28, + "loc": { + "start": { + "line": 3, + "column": 5 + }, + "end": { + "line": 3, + "column": 6 + } + }, + "typeParameters": null, + "id": { + "type": "Identifier", + "start": 27, + "end": 28, + "loc": { + "start": { + "line": 3, + "column": 5 + }, + "end": { + "line": 3, + "column": 6 + }, + "identifierName": "A" + }, + "name": "A" + } + } + } + ], + "indexers": [], + "internalSlots": [], + "exact": false, + "inexact": false + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/type-annotations/with-default-invalid/options.json b/packages/babel-parser/test/fixtures/flow/type-annotations/with-default-invalid/options.json deleted file mode 100644 index 24792311b3e9..000000000000 --- a/packages/babel-parser/test/fixtures/flow/type-annotations/with-default-invalid/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Type annotations must come before default assignments, e.g. instead of `age = 25: number` use `age: number = 25` (1:20)" -} diff --git a/packages/babel-parser/test/fixtures/flow/type-annotations/with-default-invalid/output.json b/packages/babel-parser/test/fixtures/flow/type-annotations/with-default-invalid/output.json new file mode 100644 index 000000000000..a08797bcf335 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/type-annotations/with-default-invalid/output.json @@ -0,0 +1,173 @@ +{ + "type": "File", + "start": 0, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "errors": [ + "SyntaxError: Type annotations must come before default assignments, e.g. instead of `age = 25: number` use `age: number = 25` (1:20)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 10 + }, + "identifierName": "x" + }, + "name": "x" + }, + "generator": false, + "async": false, + "params": [ + { + "type": "AssignmentPattern", + "start": 11, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 28 + } + }, + "left": { + "type": "Identifier", + "start": 11, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 14 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "right": { + "type": "StringLiteral", + "start": 17, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "extra": { + "rawValue": "1", + "raw": "\"1\"" + }, + "value": "1" + }, + "typeAnnotation": { + "type": "TypeAnnotation", + "start": 20, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 20 + }, + "end": { + "line": 1, + "column": 28 + } + }, + "typeAnnotation": { + "type": "StringTypeAnnotation", + "start": 22, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 22 + }, + "end": { + "line": 1, + "column": 28 + } + } + } + } + } + ], + "body": { + "type": "BlockStatement", + "start": 30, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 30 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "body": [], + "directives": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/type-exports/star-as-from/options.json b/packages/babel-parser/test/fixtures/flow/type-exports/star-as-from/options.json index d482b18c6cff..6a0cd1358ef1 100644 --- a/packages/babel-parser/test/fixtures/flow/type-exports/star-as-from/options.json +++ b/packages/babel-parser/test/fixtures/flow/type-exports/star-as-from/options.json @@ -1,5 +1,5 @@ { "sourceType": "module", - "plugins": ["flow", "exportNamespaceFrom"], + "plugins": ["flow"], "throws": "Unexpected token (1:14)" } diff --git a/packages/babel-parser/test/fixtures/flow/type-imports/invalid-import-type-2/options.json b/packages/babel-parser/test/fixtures/flow/type-imports/invalid-import-type-2/options.json deleted file mode 100644 index 7624c4d3b99a..000000000000 --- a/packages/babel-parser/test/fixtures/flow/type-imports/invalid-import-type-2/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Cannot overwrite reserved type string (1:14)" -} diff --git a/packages/babel-parser/test/fixtures/flow/type-imports/invalid-import-type-2/output.json b/packages/babel-parser/test/fixtures/flow/type-imports/invalid-import-type-2/output.json new file mode 100644 index 000000000000..5ac98d7b46b7 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/type-imports/invalid-import-type-2/output.json @@ -0,0 +1,126 @@ +{ + "type": "File", + "start": 0, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 34 + } + }, + "errors": [ + "SyntaxError: Cannot overwrite reserved type string (1:14)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 34 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ImportDeclaration", + "start": 0, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 34 + } + }, + "specifiers": [ + { + "type": "ImportSpecifier", + "start": 14, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "imported": { + "type": "Identifier", + "start": 14, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 20 + }, + "identifierName": "string" + }, + "name": "string" + }, + "importKind": null, + "local": { + "type": "Identifier", + "start": 14, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 20 + }, + "identifierName": "string" + }, + "name": "string" + } + } + ], + "importKind": "type", + "source": { + "type": "StringLiteral", + "start": 28, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 28 + }, + "end": { + "line": 1, + "column": 33 + } + }, + "extra": { + "rawValue": "foo", + "raw": "\"foo\"" + }, + "value": "foo" + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/type-imports/invalid-import-type-3/options.json b/packages/babel-parser/test/fixtures/flow/type-imports/invalid-import-type-3/options.json deleted file mode 100644 index 7624c4d3b99a..000000000000 --- a/packages/babel-parser/test/fixtures/flow/type-imports/invalid-import-type-3/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Cannot overwrite reserved type string (1:14)" -} diff --git a/packages/babel-parser/test/fixtures/flow/type-imports/invalid-import-type-3/output.json b/packages/babel-parser/test/fixtures/flow/type-imports/invalid-import-type-3/output.json new file mode 100644 index 000000000000..3a1010d807fe --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/type-imports/invalid-import-type-3/output.json @@ -0,0 +1,108 @@ +{ + "type": "File", + "start": 0, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "errors": [ + "SyntaxError: Cannot overwrite reserved type string (1:14)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ImportDeclaration", + "start": 0, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "specifiers": [ + { + "type": "ImportDefaultSpecifier", + "start": 14, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "local": { + "type": "Identifier", + "start": 14, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 20 + }, + "identifierName": "string" + }, + "name": "string" + } + } + ], + "importKind": "typeof", + "source": { + "type": "StringLiteral", + "start": 26, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 26 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "extra": { + "rawValue": "foo", + "raw": "\"foo\"" + }, + "value": "foo" + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/type-imports/invalid-import-type-4/options.json b/packages/babel-parser/test/fixtures/flow/type-imports/invalid-import-type-4/options.json deleted file mode 100644 index d64a5d353bf8..000000000000 --- a/packages/babel-parser/test/fixtures/flow/type-imports/invalid-import-type-4/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Cannot overwrite reserved type string (1:19)" -} diff --git a/packages/babel-parser/test/fixtures/flow/type-imports/invalid-import-type-4/output.json b/packages/babel-parser/test/fixtures/flow/type-imports/invalid-import-type-4/output.json new file mode 100644 index 000000000000..dcbca6978a12 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/type-imports/invalid-import-type-4/output.json @@ -0,0 +1,108 @@ +{ + "type": "File", + "start": 0, + "end": 37, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 37 + } + }, + "errors": [ + "SyntaxError: Cannot overwrite reserved type string (1:19)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 37, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 37 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ImportDeclaration", + "start": 0, + "end": 37, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 37 + } + }, + "specifiers": [ + { + "type": "ImportNamespaceSpecifier", + "start": 14, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 25 + } + }, + "local": { + "type": "Identifier", + "start": 19, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 25 + }, + "identifierName": "string" + }, + "name": "string" + } + } + ], + "importKind": "typeof", + "source": { + "type": "StringLiteral", + "start": 31, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 31 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "extra": { + "rawValue": "foo", + "raw": "\"foo\"" + }, + "value": "foo" + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/type-imports/invalid-import-type-as/options.json b/packages/babel-parser/test/fixtures/flow/type-imports/invalid-import-type-as/options.json index 5133797973d2..3962be507d38 100644 --- a/packages/babel-parser/test/fixtures/flow/type-imports/invalid-import-type-as/options.json +++ b/packages/babel-parser/test/fixtures/flow/type-imports/invalid-import-type-as/options.json @@ -1,3 +1,7 @@ { - "throws": "Unexpected keyword 'debugger' (1:17)" -} + "sourceType": "module", + "plugins": [ + "jsx", + "flow" + ] +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/type-imports/invalid-import-type-as/output.json b/packages/babel-parser/test/fixtures/flow/type-imports/invalid-import-type-as/output.json new file mode 100644 index 000000000000..05cc09533a23 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/type-imports/invalid-import-type-as/output.json @@ -0,0 +1,126 @@ +{ + "type": "File", + "start": 0, + "end": 39, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 39 + } + }, + "errors": [ + "SyntaxError: Unexpected keyword 'debugger' (1:17)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 39, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 39 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ImportDeclaration", + "start": 0, + "end": 39, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 39 + } + }, + "specifiers": [ + { + "type": "ImportSpecifier", + "start": 9, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 25 + } + }, + "imported": { + "type": "Identifier", + "start": 9, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 13 + }, + "identifierName": "type" + }, + "name": "type" + }, + "importKind": null, + "local": { + "type": "Identifier", + "start": 17, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 25 + }, + "identifierName": "debugger" + }, + "name": "debugger" + } + } + ], + "importKind": "value", + "source": { + "type": "StringLiteral", + "start": 33, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 33 + }, + "end": { + "line": 1, + "column": 38 + } + }, + "extra": { + "rawValue": "foo", + "raw": "\"foo\"" + }, + "value": "foo" + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/type-imports/invalid-import-type-shorthand-2/options.json b/packages/babel-parser/test/fixtures/flow/type-imports/invalid-import-type-shorthand-2/options.json deleted file mode 100644 index 036229c5b95a..000000000000 --- a/packages/babel-parser/test/fixtures/flow/type-imports/invalid-import-type-shorthand-2/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "The `type` and `typeof` keywords on named imports can only be used on regular `import` statements. It cannot be used with `import type` or `import typeof` statements (1:13)" -} diff --git a/packages/babel-parser/test/fixtures/flow/type-imports/invalid-import-type-shorthand-2/output.json b/packages/babel-parser/test/fixtures/flow/type-imports/invalid-import-type-shorthand-2/output.json new file mode 100644 index 000000000000..90585f1b4f80 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/type-imports/invalid-import-type-shorthand-2/output.json @@ -0,0 +1,126 @@ +{ + "type": "File", + "start": 0, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "errors": [ + "SyntaxError: The `type` and `typeof` keywords on named imports can only be used on regular `import` statements. It cannot be used with `import type` or `import typeof` statements (1:13)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ImportDeclaration", + "start": 0, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "specifiers": [ + { + "type": "ImportSpecifier", + "start": 13, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "imported": { + "type": "Identifier", + "start": 18, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 19 + }, + "identifierName": "t" + }, + "name": "t" + }, + "importKind": "type", + "local": { + "type": "Identifier", + "start": 18, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 19 + }, + "identifierName": "t" + }, + "name": "t" + } + } + ], + "importKind": "type", + "source": { + "type": "StringLiteral", + "start": 26, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 26 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "extra": { + "rawValue": "foo", + "raw": "\"foo\"" + }, + "value": "foo" + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/type-imports/invalid-import-type-shorthand-3/options.json b/packages/babel-parser/test/fixtures/flow/type-imports/invalid-import-type-shorthand-3/options.json deleted file mode 100644 index e425b795f180..000000000000 --- a/packages/babel-parser/test/fixtures/flow/type-imports/invalid-import-type-shorthand-3/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Cannot overwrite reserved type string (1:16)" -} diff --git a/packages/babel-parser/test/fixtures/flow/type-imports/invalid-import-type-shorthand-3/output.json b/packages/babel-parser/test/fixtures/flow/type-imports/invalid-import-type-shorthand-3/output.json new file mode 100644 index 000000000000..4969f577a320 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/type-imports/invalid-import-type-shorthand-3/output.json @@ -0,0 +1,126 @@ +{ + "type": "File", + "start": 0, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "errors": [ + "SyntaxError: Cannot overwrite reserved type string (1:16)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ImportDeclaration", + "start": 0, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "specifiers": [ + { + "type": "ImportSpecifier", + "start": 9, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "imported": { + "type": "Identifier", + "start": 16, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 22 + }, + "identifierName": "string" + }, + "name": "string" + }, + "importKind": "typeof", + "local": { + "type": "Identifier", + "start": 16, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 22 + }, + "identifierName": "string" + }, + "name": "string" + } + } + ], + "importKind": "value", + "source": { + "type": "StringLiteral", + "start": 30, + "end": 35, + "loc": { + "start": { + "line": 1, + "column": 30 + }, + "end": { + "line": 1, + "column": 35 + } + }, + "extra": { + "rawValue": "foo", + "raw": "\"foo\"" + }, + "value": "foo" + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/type-imports/invalid-import-type-shorthand-4/options.json b/packages/babel-parser/test/fixtures/flow/type-imports/invalid-import-type-shorthand-4/options.json deleted file mode 100644 index 7624c4d3b99a..000000000000 --- a/packages/babel-parser/test/fixtures/flow/type-imports/invalid-import-type-shorthand-4/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Cannot overwrite reserved type string (1:14)" -} diff --git a/packages/babel-parser/test/fixtures/flow/type-imports/invalid-import-type-shorthand-4/output.json b/packages/babel-parser/test/fixtures/flow/type-imports/invalid-import-type-shorthand-4/output.json new file mode 100644 index 000000000000..2b57e99a30e7 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/type-imports/invalid-import-type-shorthand-4/output.json @@ -0,0 +1,126 @@ +{ + "type": "File", + "start": 0, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 34 + } + }, + "errors": [ + "SyntaxError: Cannot overwrite reserved type string (1:14)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 34 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ImportDeclaration", + "start": 0, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 34 + } + }, + "specifiers": [ + { + "type": "ImportSpecifier", + "start": 9, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "imported": { + "type": "Identifier", + "start": 14, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 20 + }, + "identifierName": "string" + }, + "name": "string" + }, + "importKind": "type", + "local": { + "type": "Identifier", + "start": 14, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 20 + }, + "identifierName": "string" + }, + "name": "string" + } + } + ], + "importKind": "value", + "source": { + "type": "StringLiteral", + "start": 28, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 28 + }, + "end": { + "line": 1, + "column": 33 + } + }, + "extra": { + "rawValue": "foo", + "raw": "\"foo\"" + }, + "value": "foo" + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/type-imports/invalid-import-type-shorthand/options.json b/packages/babel-parser/test/fixtures/flow/type-imports/invalid-import-type-shorthand/options.json deleted file mode 100644 index 7aa4274c7160..000000000000 --- a/packages/babel-parser/test/fixtures/flow/type-imports/invalid-import-type-shorthand/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "The `type` and `typeof` keywords on named imports can only be used on regular `import` statements. It cannot be used with `import type` or `import typeof` statements (1:15)" -} diff --git a/packages/babel-parser/test/fixtures/flow/type-imports/invalid-import-type-shorthand/output.json b/packages/babel-parser/test/fixtures/flow/type-imports/invalid-import-type-shorthand/output.json new file mode 100644 index 000000000000..174e856304f7 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/type-imports/invalid-import-type-shorthand/output.json @@ -0,0 +1,126 @@ +{ + "type": "File", + "start": 0, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "errors": [ + "SyntaxError: The `type` and `typeof` keywords on named imports can only be used on regular `import` statements. It cannot be used with `import type` or `import typeof` statements (1:15)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ImportDeclaration", + "start": 0, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "specifiers": [ + { + "type": "ImportSpecifier", + "start": 15, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "imported": { + "type": "Identifier", + "start": 22, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 22 + }, + "end": { + "line": 1, + "column": 23 + }, + "identifierName": "t" + }, + "name": "t" + }, + "importKind": "typeof", + "local": { + "type": "Identifier", + "start": 22, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 22 + }, + "end": { + "line": 1, + "column": 23 + }, + "identifierName": "t" + }, + "name": "t" + } + } + ], + "importKind": "typeof", + "source": { + "type": "StringLiteral", + "start": 30, + "end": 35, + "loc": { + "start": { + "line": 1, + "column": 30 + }, + "end": { + "line": 1, + "column": 35 + } + }, + "extra": { + "rawValue": "foo", + "raw": "\"foo\"" + }, + "value": "foo" + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/type-imports/invalid-import-type/options.json b/packages/babel-parser/test/fixtures/flow/type-imports/invalid-import-type/options.json deleted file mode 100644 index 0c2cdd4d777c..000000000000 --- a/packages/babel-parser/test/fixtures/flow/type-imports/invalid-import-type/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Cannot overwrite reserved type string (1:12)" -} diff --git a/packages/babel-parser/test/fixtures/flow/type-imports/invalid-import-type/output.json b/packages/babel-parser/test/fixtures/flow/type-imports/invalid-import-type/output.json new file mode 100644 index 000000000000..95872d960a5c --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/type-imports/invalid-import-type/output.json @@ -0,0 +1,108 @@ +{ + "type": "File", + "start": 0, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "errors": [ + "SyntaxError: Cannot overwrite reserved type string (1:12)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ImportDeclaration", + "start": 0, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "specifiers": [ + { + "type": "ImportDefaultSpecifier", + "start": 12, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "local": { + "type": "Identifier", + "start": 12, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 18 + }, + "identifierName": "string" + }, + "name": "string" + } + } + ], + "importKind": "type", + "source": { + "type": "StringLiteral", + "start": 24, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 24 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "extra": { + "rawValue": "foo", + "raw": "\"foo\"" + }, + "value": "foo" + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/type-parameter-declaration/default-missing/options.json b/packages/babel-parser/test/fixtures/flow/type-parameter-declaration/default-missing/options.json deleted file mode 100644 index 022607b81797..000000000000 --- a/packages/babel-parser/test/fixtures/flow/type-parameter-declaration/default-missing/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Type parameter declaration needs a default, since a preceding type parameter declaration has a default. (1:28)" -} diff --git a/packages/babel-parser/test/fixtures/flow/type-parameter-declaration/default-missing/output.json b/packages/babel-parser/test/fixtures/flow/type-parameter-declaration/default-missing/output.json new file mode 100644 index 000000000000..b902d88e157e --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/type-parameter-declaration/default-missing/output.json @@ -0,0 +1,169 @@ +{ + "type": "File", + "start": 0, + "end": 43, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 43 + } + }, + "errors": [ + "SyntaxError: Type parameter declaration needs a default, since a preceding type parameter declaration has a default. (1:28)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 43, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 43 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "TypeAlias", + "start": 0, + "end": 43, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 43 + } + }, + "id": { + "type": "Identifier", + "start": 5, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 6 + }, + "identifierName": "A" + }, + "name": "A" + }, + "typeParameters": { + "type": "TypeParameterDeclaration", + "start": 6, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 38 + } + }, + "params": [ + { + "type": "TypeParameter", + "start": 7, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "name": "HasDefault", + "variance": null, + "default": { + "type": "StringTypeAnnotation", + "start": 20, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 20 + }, + "end": { + "line": 1, + "column": 26 + } + } + } + }, + { + "type": "TypeParameter", + "start": 28, + "end": 37, + "loc": { + "start": { + "line": 1, + "column": 28 + }, + "end": { + "line": 1, + "column": 37 + } + }, + "name": "NoDefault", + "variance": null + } + ] + }, + "right": { + "type": "GenericTypeAnnotation", + "start": 41, + "end": 42, + "loc": { + "start": { + "line": 1, + "column": 41 + }, + "end": { + "line": 1, + "column": 42 + } + }, + "typeParameters": null, + "id": { + "type": "Identifier", + "start": 41, + "end": 42, + "loc": { + "start": { + "line": 1, + "column": 41 + }, + "end": { + "line": 1, + "column": 42 + }, + "identifierName": "T" + }, + "name": "T" + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/type-parameter-declaration/reserved-word-class-name-failure/options.json b/packages/babel-parser/test/fixtures/flow/type-parameter-declaration/reserved-word-class-name-failure/options.json index f45196d78df9..a282a109bf16 100644 --- a/packages/babel-parser/test/fixtures/flow/type-parameter-declaration/reserved-word-class-name-failure/options.json +++ b/packages/babel-parser/test/fixtures/flow/type-parameter-declaration/reserved-word-class-name-failure/options.json @@ -1,4 +1,7 @@ { - "throws": "Unexpected keyword 'delete' (1:14)", - "plugins": ["flow", "jsx"] -} + "sourceType": "module", + "plugins": [ + "flow", + "jsx" + ] +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/type-parameter-declaration/reserved-word-class-name-failure/output.json b/packages/babel-parser/test/fixtures/flow/type-parameter-declaration/reserved-word-class-name-failure/output.json new file mode 100644 index 000000000000..a86c5b5aebde --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/type-parameter-declaration/reserved-word-class-name-failure/output.json @@ -0,0 +1,94 @@ +{ + "type": "File", + "start": 0, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "errors": [ + "SyntaxError: Unexpected keyword 'delete' (1:14)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "DeclareClass", + "start": 0, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "id": { + "type": "Identifier", + "start": 14, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 20 + }, + "identifierName": "delete" + }, + "name": "delete" + }, + "typeParameters": null, + "extends": [], + "implements": [], + "mixins": [], + "body": { + "type": "ObjectTypeAnnotation", + "start": 21, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 21 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "callProperties": [], + "properties": [], + "indexers": [], + "internalSlots": [], + "exact": false + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/typeapp-call/underscore_is_illegal_param_instantiation_otherwise/options.json b/packages/babel-parser/test/fixtures/flow/typeapp-call/underscore_is_illegal_param_instantiation_otherwise/options.json deleted file mode 100644 index 101e77f3861c..000000000000 --- a/packages/babel-parser/test/fixtures/flow/typeapp-call/underscore_is_illegal_param_instantiation_otherwise/options.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "sourceType": "module", - "plugins": ["jsx", "flow"], - "throws": "`_` is only allowed as a type argument to call or new (2:16)" -} diff --git a/packages/babel-parser/test/fixtures/flow/typeapp-call/underscore_is_illegal_param_instantiation_otherwise/output.json b/packages/babel-parser/test/fixtures/flow/typeapp-call/underscore_is_illegal_param_instantiation_otherwise/output.json new file mode 100644 index 000000000000..297c8d177689 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/typeapp-call/underscore_is_illegal_param_instantiation_otherwise/output.json @@ -0,0 +1,241 @@ +{ + "type": "File", + "start": 0, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 22 + } + }, + "errors": [ + "SyntaxError: `_` is only allowed as a type argument to call or new (2:16)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 22 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "VariableDeclaration", + "start": 8, + "end": 30, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 22 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 12, + "end": 29, + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 21 + } + }, + "id": { + "type": "Identifier", + "start": 12, + "end": 25, + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 17 + }, + "identifierName": "x" + }, + "name": "x", + "typeAnnotation": { + "type": "TypeAnnotation", + "start": 13, + "end": 25, + "loc": { + "start": { + "line": 2, + "column": 5 + }, + "end": { + "line": 2, + "column": 17 + } + }, + "typeAnnotation": { + "type": "GenericTypeAnnotation", + "start": 15, + "end": 25, + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 2, + "column": 17 + } + }, + "typeParameters": { + "type": "TypeParameterInstantiation", + "start": 22, + "end": 25, + "loc": { + "start": { + "line": 2, + "column": 14 + }, + "end": { + "line": 2, + "column": 17 + } + }, + "params": [ + { + "type": "GenericTypeAnnotation", + "start": 23, + "end": 24, + "loc": { + "start": { + "line": 2, + "column": 15 + }, + "end": { + "line": 2, + "column": 16 + } + }, + "typeParameters": null, + "id": { + "type": "Identifier", + "start": 23, + "end": 24, + "loc": { + "start": { + "line": 2, + "column": 15 + }, + "end": { + "line": 2, + "column": 16 + }, + "identifierName": "_" + }, + "name": "_" + } + } + ] + }, + "id": { + "type": "Identifier", + "start": 15, + "end": 22, + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 2, + "column": 14 + }, + "identifierName": "Generic" + }, + "name": "Generic" + } + } + } + }, + "init": { + "type": "NumericLiteral", + "start": 28, + "end": 29, + "loc": { + "start": { + "line": 2, + "column": 20 + }, + "end": { + "line": 2, + "column": 21 + } + }, + "extra": { + "rawValue": 3, + "raw": "3" + }, + "value": 3 + } + } + ], + "kind": "var", + "leadingComments": [ + { + "type": "CommentLine", + "value": "@flow", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + } + } + ] + } + ], + "directives": [] + }, + "comments": [ + { + "type": "CommentLine", + "value": "@flow", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + } + } + ] +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/typeapp-call/underscore_is_illegal_type_name/options.json b/packages/babel-parser/test/fixtures/flow/typeapp-call/underscore_is_illegal_type_name/options.json index 85a0456eceff..d822c40fbba2 100644 --- a/packages/babel-parser/test/fixtures/flow/typeapp-call/underscore_is_illegal_type_name/options.json +++ b/packages/babel-parser/test/fixtures/flow/typeapp-call/underscore_is_illegal_type_name/options.json @@ -1,5 +1,4 @@ { "sourceType": "module", - "plugins": ["jsx", "flow"], - "throws": "Cannot overwrite reserved type _ (2:5)" + "plugins": ["jsx", "flow"] } diff --git a/packages/babel-parser/test/fixtures/flow/typeapp-call/underscore_is_illegal_type_name/output.json b/packages/babel-parser/test/fixtures/flow/typeapp-call/underscore_is_illegal_type_name/output.json new file mode 100644 index 000000000000..53ac01f6fe9a --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/typeapp-call/underscore_is_illegal_type_name/output.json @@ -0,0 +1,122 @@ +{ + "type": "File", + "start": 0, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 16 + } + }, + "errors": [ + "SyntaxError: Cannot overwrite reserved type _ (2:5)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 16 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "TypeAlias", + "start": 8, + "end": 24, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 16 + } + }, + "id": { + "type": "Identifier", + "start": 13, + "end": 14, + "loc": { + "start": { + "line": 2, + "column": 5 + }, + "end": { + "line": 2, + "column": 6 + }, + "identifierName": "_" + }, + "name": "_" + }, + "typeParameters": null, + "right": { + "type": "NumberTypeAnnotation", + "start": 17, + "end": 23, + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 15 + } + } + }, + "leadingComments": [ + { + "type": "CommentLine", + "value": "@flow", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + } + } + ] + } + ], + "directives": [] + }, + "comments": [ + { + "type": "CommentLine", + "value": "@flow", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + } + } + ] +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/typeapp-call/underscore_is_illegal_type_param_name/options.json b/packages/babel-parser/test/fixtures/flow/typeapp-call/underscore_is_illegal_type_param_name/options.json deleted file mode 100644 index 872ad2f73408..000000000000 --- a/packages/babel-parser/test/fixtures/flow/typeapp-call/underscore_is_illegal_type_param_name/options.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "sourceType": "module", - "plugins": ["jsx", "flow"], - "throws": "Cannot overwrite reserved type _ (2:13)" -} diff --git a/packages/babel-parser/test/fixtures/flow/typeapp-call/underscore_is_illegal_type_param_name/output.json b/packages/babel-parser/test/fixtures/flow/typeapp-call/underscore_is_illegal_type_param_name/output.json new file mode 100644 index 000000000000..e89da7ec21b6 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/typeapp-call/underscore_is_illegal_type_param_name/output.json @@ -0,0 +1,174 @@ +{ + "type": "File", + "start": 0, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 20 + } + }, + "errors": [ + "SyntaxError: Cannot overwrite reserved type _ (2:13)", + "SyntaxError: `_` is only allowed as a type argument to call or new (2:19)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 20 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "TypeAlias", + "start": 8, + "end": 28, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 20 + } + }, + "id": { + "type": "Identifier", + "start": 13, + "end": 20, + "loc": { + "start": { + "line": 2, + "column": 5 + }, + "end": { + "line": 2, + "column": 12 + }, + "identifierName": "Generic" + }, + "name": "Generic" + }, + "typeParameters": { + "type": "TypeParameterDeclaration", + "start": 20, + "end": 23, + "loc": { + "start": { + "line": 2, + "column": 12 + }, + "end": { + "line": 2, + "column": 15 + } + }, + "params": [ + { + "type": "TypeParameter", + "start": 21, + "end": 22, + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 14 + } + }, + "name": "_", + "variance": null + } + ] + }, + "right": { + "type": "GenericTypeAnnotation", + "start": 26, + "end": 27, + "loc": { + "start": { + "line": 2, + "column": 18 + }, + "end": { + "line": 2, + "column": 19 + } + }, + "typeParameters": null, + "id": { + "type": "Identifier", + "start": 26, + "end": 27, + "loc": { + "start": { + "line": 2, + "column": 18 + }, + "end": { + "line": 2, + "column": 19 + }, + "identifierName": "_" + }, + "name": "_" + } + }, + "leadingComments": [ + { + "type": "CommentLine", + "value": "@flow", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + } + } + ] + } + ], + "directives": [] + }, + "comments": [ + { + "type": "CommentLine", + "value": "@flow", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + } + } + ] +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/typecasts/fail-in-calls-with-one-arg/options.json b/packages/babel-parser/test/fixtures/flow/typecasts/fail-in-calls-with-one-arg/options.json deleted file mode 100644 index e4012a53ad5d..000000000000 --- a/packages/babel-parser/test/fixtures/flow/typecasts/fail-in-calls-with-one-arg/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "The type cast expression is expected to be wrapped with parenthesis (1:10)" -} diff --git a/packages/babel-parser/test/fixtures/flow/typecasts/fail-in-calls-with-one-arg/output.json b/packages/babel-parser/test/fixtures/flow/typecasts/fail-in-calls-with-one-arg/output.json new file mode 100644 index 000000000000..098b44cec651 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/typecasts/fail-in-calls-with-one-arg/output.json @@ -0,0 +1,149 @@ +{ + "type": "File", + "start": 0, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "errors": [ + "SyntaxError: The type cast expression is expected to be wrapped with parenthesis (1:10)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "expression": { + "type": "CallExpression", + "start": 0, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "callee": { + "type": "Identifier", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + }, + "identifierName": "funccall" + }, + "name": "funccall" + }, + "arguments": [ + { + "type": "TypeCastExpression", + "start": 9, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "expression": { + "type": "Identifier", + "start": 9, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 10 + }, + "identifierName": "b" + }, + "name": "b" + }, + "typeAnnotation": { + "type": "TypeAnnotation", + "start": 10, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "typeAnnotation": { + "type": "StringTypeAnnotation", + "start": 12, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 18 + } + } + } + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/typecasts/fail-in-calls/options.json b/packages/babel-parser/test/fixtures/flow/typecasts/fail-in-calls/options.json deleted file mode 100644 index 3f861de320eb..000000000000 --- a/packages/babel-parser/test/fixtures/flow/typecasts/fail-in-calls/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "The type cast expression is expected to be wrapped with parenthesis (1:13)" -} diff --git a/packages/babel-parser/test/fixtures/flow/typecasts/fail-in-calls/output.json b/packages/babel-parser/test/fixtures/flow/typecasts/fail-in-calls/output.json new file mode 100644 index 000000000000..6b5b957074e0 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/typecasts/fail-in-calls/output.json @@ -0,0 +1,166 @@ +{ + "type": "File", + "start": 0, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "errors": [ + "SyntaxError: The type cast expression is expected to be wrapped with parenthesis (1:13)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "expression": { + "type": "CallExpression", + "start": 0, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "callee": { + "type": "Identifier", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + }, + "identifierName": "funccall" + }, + "name": "funccall" + }, + "arguments": [ + { + "type": "Identifier", + "start": 9, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 10 + }, + "identifierName": "a" + }, + "name": "a" + }, + { + "type": "TypeCastExpression", + "start": 12, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "expression": { + "type": "Identifier", + "start": 12, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 13 + }, + "identifierName": "b" + }, + "name": "b" + }, + "typeAnnotation": { + "type": "TypeAnnotation", + "start": 13, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "typeAnnotation": { + "type": "StringTypeAnnotation", + "start": 15, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 21 + } + } + } + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/typecasts/fail-without-parens/options.json b/packages/babel-parser/test/fixtures/flow/typecasts/fail-without-parens/options.json deleted file mode 100644 index 847e987ef0af..000000000000 --- a/packages/babel-parser/test/fixtures/flow/typecasts/fail-without-parens/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "The type cast expression is expected to be wrapped with parenthesis (1:5)" -} diff --git a/packages/babel-parser/test/fixtures/flow/typecasts/fail-without-parens/output.json b/packages/babel-parser/test/fixtures/flow/typecasts/fail-without-parens/output.json new file mode 100644 index 000000000000..0e18e29a41ea --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/typecasts/fail-without-parens/output.json @@ -0,0 +1,171 @@ +{ + "type": "File", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "errors": [ + "SyntaxError: The type cast expression is expected to be wrapped with parenthesis (1:5)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "expression": { + "type": "SequenceExpression", + "start": 1, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "expressions": [ + { + "type": "Identifier", + "start": 1, + "end": 2, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 2 + }, + "identifierName": "A" + }, + "name": "A" + }, + { + "type": "TypeCastExpression", + "start": 4, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "expression": { + "type": "Identifier", + "start": 4, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 5 + }, + "identifierName": "B" + }, + "name": "B" + }, + "typeAnnotation": { + "type": "TypeAnnotation", + "start": 5, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "typeAnnotation": { + "type": "GenericTypeAnnotation", + "start": 7, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "typeParameters": null, + "id": { + "type": "Identifier", + "start": 7, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 8 + }, + "identifierName": "T" + }, + "name": "T" + } + } + } + } + ], + "extra": { + "parenthesized": true, + "parenStart": 0 + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/typecasts/fails-in-array-expression-1/options.json b/packages/babel-parser/test/fixtures/flow/typecasts/fails-in-array-expression-1/options.json deleted file mode 100644 index 18cdf0d35e40..000000000000 --- a/packages/babel-parser/test/fixtures/flow/typecasts/fails-in-array-expression-1/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "The type cast expression is expected to be wrapped with parenthesis (1:2)" -} diff --git a/packages/babel-parser/test/fixtures/flow/typecasts/fails-in-array-expression-1/output.json b/packages/babel-parser/test/fixtures/flow/typecasts/fails-in-array-expression-1/output.json new file mode 100644 index 000000000000..8170ccf4c8d9 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/typecasts/fails-in-array-expression-1/output.json @@ -0,0 +1,132 @@ +{ + "type": "File", + "start": 0, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "errors": [ + "SyntaxError: The type cast expression is expected to be wrapped with parenthesis (1:2)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "expression": { + "type": "ArrayExpression", + "start": 0, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "elements": [ + { + "type": "TypeCastExpression", + "start": 1, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "expression": { + "type": "Identifier", + "start": 1, + "end": 2, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 2 + }, + "identifierName": "a" + }, + "name": "a" + }, + "typeAnnotation": { + "type": "TypeAnnotation", + "start": 2, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 2 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "typeAnnotation": { + "type": "StringTypeAnnotation", + "start": 4, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 10 + } + } + } + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/typecasts/fails-in-array-expression-2/options.json b/packages/babel-parser/test/fixtures/flow/typecasts/fails-in-array-expression-2/options.json deleted file mode 100644 index 624681c0d415..000000000000 --- a/packages/babel-parser/test/fixtures/flow/typecasts/fails-in-array-expression-2/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "The type cast expression is expected to be wrapped with parenthesis (1:3)" -} diff --git a/packages/babel-parser/test/fixtures/flow/typecasts/fails-in-array-expression-2/output.json b/packages/babel-parser/test/fixtures/flow/typecasts/fails-in-array-expression-2/output.json new file mode 100644 index 000000000000..c5ba396b8101 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/typecasts/fails-in-array-expression-2/output.json @@ -0,0 +1,136 @@ +{ + "type": "File", + "start": 0, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "errors": [ + "SyntaxError: The type cast expression is expected to be wrapped with parenthesis (1:3)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "expression": { + "type": "ArrayExpression", + "start": 1, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "elements": [ + { + "type": "TypeCastExpression", + "start": 2, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 2 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "expression": { + "type": "Identifier", + "start": 2, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 2 + }, + "end": { + "line": 1, + "column": 3 + }, + "identifierName": "a" + }, + "name": "a" + }, + "typeAnnotation": { + "type": "TypeAnnotation", + "start": 3, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "typeAnnotation": { + "type": "StringTypeAnnotation", + "start": 5, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 11 + } + } + } + } + } + ], + "extra": { + "parenthesized": true, + "parenStart": 0 + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/typecasts/fails-in-array-expression-3/options.json b/packages/babel-parser/test/fixtures/flow/typecasts/fails-in-array-expression-3/options.json deleted file mode 100644 index 7f8da08031af..000000000000 --- a/packages/babel-parser/test/fixtures/flow/typecasts/fails-in-array-expression-3/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "The type cast expression is expected to be wrapped with parenthesis (1:7)" -} diff --git a/packages/babel-parser/test/fixtures/flow/typecasts/fails-in-array-expression-3/output.json b/packages/babel-parser/test/fixtures/flow/typecasts/fails-in-array-expression-3/output.json new file mode 100644 index 000000000000..d8bfbe9b1216 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/typecasts/fails-in-array-expression-3/output.json @@ -0,0 +1,170 @@ +{ + "type": "File", + "start": 0, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "errors": [ + "SyntaxError: The type cast expression is expected to be wrapped with parenthesis (1:7)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "expression": { + "type": "ArrayExpression", + "start": 1, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "elements": [ + { + "type": "Identifier", + "start": 2, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 2 + }, + "end": { + "line": 1, + "column": 3 + }, + "identifierName": "a" + }, + "name": "a" + }, + { + "type": "ArrayExpression", + "start": 5, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "elements": [ + { + "type": "TypeCastExpression", + "start": 6, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "expression": { + "type": "Identifier", + "start": 6, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + }, + "identifierName": "b" + }, + "name": "b" + }, + "typeAnnotation": { + "type": "TypeAnnotation", + "start": 7, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "typeAnnotation": { + "type": "StringTypeAnnotation", + "start": 9, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 15 + } + } + } + } + } + ] + } + ], + "extra": { + "parenthesized": true, + "parenStart": 0 + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/typecasts/fails-in-array-expression-4/options.json b/packages/babel-parser/test/fixtures/flow/typecasts/fails-in-array-expression-4/options.json deleted file mode 100644 index 23c75013dad4..000000000000 --- a/packages/babel-parser/test/fixtures/flow/typecasts/fails-in-array-expression-4/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "The type cast expression is expected to be wrapped with parenthesis (1:9)" -} diff --git a/packages/babel-parser/test/fixtures/flow/typecasts/fails-in-array-expression-4/output.json b/packages/babel-parser/test/fixtures/flow/typecasts/fails-in-array-expression-4/output.json new file mode 100644 index 000000000000..517f9d043755 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/typecasts/fails-in-array-expression-4/output.json @@ -0,0 +1,166 @@ +{ + "type": "File", + "start": 0, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "errors": [ + "SyntaxError: The type cast expression is expected to be wrapped with parenthesis (1:9)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "expression": { + "type": "CallExpression", + "start": 0, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "callee": { + "type": "Identifier", + "start": 0, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + }, + "identifierName": "async" + }, + "name": "async" + }, + "arguments": [ + { + "type": "ArrayExpression", + "start": 7, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "elements": [ + { + "type": "TypeCastExpression", + "start": 8, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "expression": { + "type": "Identifier", + "start": 8, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 9 + }, + "identifierName": "a" + }, + "name": "a" + }, + "typeAnnotation": { + "type": "TypeAnnotation", + "start": 9, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "typeAnnotation": { + "type": "StringTypeAnnotation", + "start": 11, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 17 + } + } + } + } + } + ] + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/typecasts/fails-in-array-expression-5/options.json b/packages/babel-parser/test/fixtures/flow/typecasts/fails-in-array-expression-5/options.json deleted file mode 100644 index 3f861de320eb..000000000000 --- a/packages/babel-parser/test/fixtures/flow/typecasts/fails-in-array-expression-5/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "The type cast expression is expected to be wrapped with parenthesis (1:13)" -} diff --git a/packages/babel-parser/test/fixtures/flow/typecasts/fails-in-array-expression-5/output.json b/packages/babel-parser/test/fixtures/flow/typecasts/fails-in-array-expression-5/output.json new file mode 100644 index 000000000000..5ae330ce23f7 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/typecasts/fails-in-array-expression-5/output.json @@ -0,0 +1,200 @@ +{ + "type": "File", + "start": 0, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 25 + } + }, + "errors": [ + "SyntaxError: The type cast expression is expected to be wrapped with parenthesis (1:13)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 25 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 25 + } + }, + "expression": { + "type": "CallExpression", + "start": 0, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "callee": { + "type": "Identifier", + "start": 0, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + }, + "identifierName": "async" + }, + "name": "async" + }, + "arguments": [ + { + "type": "ArrayExpression", + "start": 7, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "elements": [ + { + "type": "Identifier", + "start": 8, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 9 + }, + "identifierName": "a" + }, + "name": "a" + }, + { + "type": "ArrayExpression", + "start": 11, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "elements": [ + { + "type": "TypeCastExpression", + "start": 12, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "expression": { + "type": "Identifier", + "start": 12, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 13 + }, + "identifierName": "b" + }, + "name": "b" + }, + "typeAnnotation": { + "type": "TypeAnnotation", + "start": 13, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "typeAnnotation": { + "type": "StringTypeAnnotation", + "start": 15, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 21 + } + } + } + } + } + ] + } + ] + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/jsx/errors/adjacent-tags/options.json b/packages/babel-parser/test/fixtures/jsx/errors/adjacent-tags/options.json index 182a3a9016d8..9835a882e99c 100644 --- a/packages/babel-parser/test/fixtures/jsx/errors/adjacent-tags/options.json +++ b/packages/babel-parser/test/fixtures/jsx/errors/adjacent-tags/options.json @@ -1,3 +1,3 @@ { "throws": "Adjacent JSX elements must be wrapped in an enclosing tag. Did you want a JSX fragment <>...? (1:22)" -} +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/jsx/errors/attribute-empty-expression/options.json b/packages/babel-parser/test/fixtures/jsx/errors/attribute-empty-expression/options.json deleted file mode 100644 index d5960e11a308..000000000000 --- a/packages/babel-parser/test/fixtures/jsx/errors/attribute-empty-expression/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "JSX attributes must only be assigned a non-empty expression (1:9)" -} diff --git a/packages/babel-parser/test/fixtures/jsx/errors/attribute-empty-expression/output.json b/packages/babel-parser/test/fixtures/jsx/errors/attribute-empty-expression/output.json new file mode 100644 index 000000000000..a58504569cb5 --- /dev/null +++ b/packages/babel-parser/test/fixtures/jsx/errors/attribute-empty-expression/output.json @@ -0,0 +1,165 @@ +{ + "type": "File", + "start": 0, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "errors": [ + "SyntaxError: JSX attributes must only be assigned a non-empty expression (1:9)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "expression": { + "type": "JSXElement", + "start": 0, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "openingElement": { + "type": "JSXOpeningElement", + "start": 0, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "name": { + "type": "JSXIdentifier", + "start": 1, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "name": "foo" + }, + "attributes": [ + { + "type": "JSXAttribute", + "start": 5, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "name": { + "type": "JSXIdentifier", + "start": 5, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "name": "bar" + }, + "value": { + "type": "JSXExpressionContainer", + "start": 9, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "expression": { + "type": "JSXEmptyExpression", + "start": 10, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 10 + } + } + } + } + } + ], + "selfClosing": true + }, + "closingElement": null, + "children": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/jsx/errors/wrong-closing-tag-fragment/options.json b/packages/babel-parser/test/fixtures/jsx/errors/wrong-closing-tag-fragment/options.json deleted file mode 100644 index 4ca478c5b41f..000000000000 --- a/packages/babel-parser/test/fixtures/jsx/errors/wrong-closing-tag-fragment/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Expected corresponding JSX closing tag for <> (1:2)" -} diff --git a/packages/babel-parser/test/fixtures/jsx/errors/wrong-closing-tag-fragment/output.json b/packages/babel-parser/test/fixtures/jsx/errors/wrong-closing-tag-fragment/output.json new file mode 100644 index 000000000000..8a88583570c3 --- /dev/null +++ b/packages/babel-parser/test/fixtures/jsx/errors/wrong-closing-tag-fragment/output.json @@ -0,0 +1,115 @@ +{ + "type": "File", + "start": 0, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "errors": [ + "SyntaxError: Expected corresponding JSX closing tag for <> (1:2)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "expression": { + "type": "JSXFragment", + "start": 0, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "openingFragment": { + "type": "JSXOpeningFragment", + "start": 0, + "end": 2, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 2 + } + } + }, + "closingFragment": { + "type": "JSXClosingElement", + "start": 2, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 2 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "name": { + "type": "JSXIdentifier", + "start": 4, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "name": "something" + } + }, + "children": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/jsx/errors/wrong-closing-tag/options.json b/packages/babel-parser/test/fixtures/jsx/errors/wrong-closing-tag/options.json deleted file mode 100644 index f3afda9ee91d..000000000000 --- a/packages/babel-parser/test/fixtures/jsx/errors/wrong-closing-tag/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Expected corresponding JSX closing tag for (1:5)" -} diff --git a/packages/babel-parser/test/fixtures/jsx/errors/wrong-closing-tag/output.json b/packages/babel-parser/test/fixtures/jsx/errors/wrong-closing-tag/output.json new file mode 100644 index 000000000000..29ab5696546f --- /dev/null +++ b/packages/babel-parser/test/fixtures/jsx/errors/wrong-closing-tag/output.json @@ -0,0 +1,133 @@ +{ + "type": "File", + "start": 0, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "errors": [ + "SyntaxError: Expected corresponding JSX closing tag for (1:5)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "expression": { + "type": "JSXElement", + "start": 0, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "openingElement": { + "type": "JSXOpeningElement", + "start": 0, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "name": { + "type": "JSXIdentifier", + "start": 1, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "name": "Foo" + }, + "attributes": [], + "selfClosing": false + }, + "closingElement": { + "type": "JSXClosingElement", + "start": 5, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "name": { + "type": "JSXIdentifier", + "start": 7, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "name": "Bar" + } + }, + "children": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/jsx/errors/wrong-opening-tag-fragment/options.json b/packages/babel-parser/test/fixtures/jsx/errors/wrong-opening-tag-fragment/options.json deleted file mode 100644 index 25d9465b06be..000000000000 --- a/packages/babel-parser/test/fixtures/jsx/errors/wrong-opening-tag-fragment/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Expected corresponding JSX closing tag for (1:11)" -} diff --git a/packages/babel-parser/test/fixtures/jsx/errors/wrong-opening-tag-fragment/output.json b/packages/babel-parser/test/fixtures/jsx/errors/wrong-opening-tag-fragment/output.json new file mode 100644 index 000000000000..63350c9eb5d8 --- /dev/null +++ b/packages/babel-parser/test/fixtures/jsx/errors/wrong-opening-tag-fragment/output.json @@ -0,0 +1,117 @@ +{ + "type": "File", + "start": 0, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "errors": [ + "SyntaxError: Expected corresponding JSX closing tag for (1:11)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "expression": { + "type": "JSXElement", + "start": 0, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "openingElement": { + "type": "JSXOpeningElement", + "start": 0, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "name": { + "type": "JSXIdentifier", + "start": 1, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "name": "something" + }, + "attributes": [], + "selfClosing": false + }, + "closingElement": { + "type": "JSXClosingFragment", + "start": 11, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 14 + } + } + }, + "children": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/placeholders/_errors/space-after/options.json b/packages/babel-parser/test/fixtures/placeholders/_errors/space-after/options.json index a307a35df63e..92404e501295 100644 --- a/packages/babel-parser/test/fixtures/placeholders/_errors/space-after/options.json +++ b/packages/babel-parser/test/fixtures/placeholders/_errors/space-after/options.json @@ -1,4 +1,3 @@ { - "plugins": ["placeholders"], - "throws": "Unexpected space in placeholder. (1:5)" + "plugins": ["placeholders"] } diff --git a/packages/babel-parser/test/fixtures/placeholders/_errors/space-after/output.json b/packages/babel-parser/test/fixtures/placeholders/_errors/space-after/output.json new file mode 100644 index 000000000000..4d13018c3020 --- /dev/null +++ b/packages/babel-parser/test/fixtures/placeholders/_errors/space-after/output.json @@ -0,0 +1,71 @@ +{ + "type": "File", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "errors": [ + "SyntaxError: Unexpected space in placeholder. (1:5)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "Placeholder", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "name": { + "type": "Identifier", + "start": 2, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 2 + }, + "end": { + "line": 1, + "column": 5 + }, + "identifierName": "FOO" + }, + "name": "FOO" + }, + "expectedNode": "Statement" + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/placeholders/_errors/space-before/options.json b/packages/babel-parser/test/fixtures/placeholders/_errors/space-before/options.json index 2d76cfab7e2f..92404e501295 100644 --- a/packages/babel-parser/test/fixtures/placeholders/_errors/space-before/options.json +++ b/packages/babel-parser/test/fixtures/placeholders/_errors/space-before/options.json @@ -1,4 +1,3 @@ { - "plugins": ["placeholders"], - "throws": "Unexpected space in placeholder. (1:2)" + "plugins": ["placeholders"] } diff --git a/packages/babel-parser/test/fixtures/placeholders/_errors/space-before/output.json b/packages/babel-parser/test/fixtures/placeholders/_errors/space-before/output.json new file mode 100644 index 000000000000..0bd5ffb6bd40 --- /dev/null +++ b/packages/babel-parser/test/fixtures/placeholders/_errors/space-before/output.json @@ -0,0 +1,71 @@ +{ + "type": "File", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "errors": [ + "SyntaxError: Unexpected space in placeholder. (1:2)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "Placeholder", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "name": { + "type": "Identifier", + "start": 3, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 6 + }, + "identifierName": "FOO" + }, + "name": "FOO" + }, + "expectedNode": "Statement" + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/placeholders/export/options.json b/packages/babel-parser/test/fixtures/placeholders/export/options.json index e7ff26ae7014..14a812b67661 100644 --- a/packages/babel-parser/test/fixtures/placeholders/export/options.json +++ b/packages/babel-parser/test/fixtures/placeholders/export/options.json @@ -1,4 +1,4 @@ { - "plugins": ["placeholders", "exportDefaultFrom", "exportNamespaceFrom"], + "plugins": ["placeholders", "exportDefaultFrom"], "sourceType": "module" } diff --git a/packages/babel-parser/test/fixtures/placeholders/export/star-from-2/options.json b/packages/babel-parser/test/fixtures/placeholders/export/star-from-2/options.json index ec7b8f83c3d7..986e9cefa93e 100644 --- a/packages/babel-parser/test/fixtures/placeholders/export/star-from-2/options.json +++ b/packages/babel-parser/test/fixtures/placeholders/export/star-from-2/options.json @@ -1,5 +1,4 @@ { "plugins": ["placeholders"], - "sourceType": "module", - "throws": "This experimental syntax requires enabling the parser plugin: 'exportNamespaceFrom' (1:9)" + "sourceType": "module" } diff --git a/packages/babel-parser/test/fixtures/placeholders/export/star-from-2/output.json b/packages/babel-parser/test/fixtures/placeholders/export/star-from-2/output.json new file mode 100644 index 000000000000..b89f3e8dec86 --- /dev/null +++ b/packages/babel-parser/test/fixtures/placeholders/export/star-from-2/output.json @@ -0,0 +1,120 @@ +{ + "type": "File", + "start": 0, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 33 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 33 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExportNamedDeclaration", + "start": 0, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 33 + } + }, + "specifiers": [ + { + "type": "ExportNamespaceSpecifier", + "start": 7, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "exported": { + "type": "Placeholder", + "start": 12, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "name": { + "type": "Identifier", + "start": 14, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 18 + }, + "identifierName": "STAR" + }, + "name": "STAR" + }, + "expectedNode": "Identifier" + } + } + ], + "source": { + "type": "StringLiteral", + "start": 26, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 26 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "extra": { + "rawValue": "file", + "raw": "\"file\"" + }, + "value": "file" + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/placeholders/export/star-from-3/options.json b/packages/babel-parser/test/fixtures/placeholders/export/star-from-3/options.json index ec7b8f83c3d7..986e9cefa93e 100644 --- a/packages/babel-parser/test/fixtures/placeholders/export/star-from-3/options.json +++ b/packages/babel-parser/test/fixtures/placeholders/export/star-from-3/options.json @@ -1,5 +1,4 @@ { "plugins": ["placeholders"], - "sourceType": "module", - "throws": "This experimental syntax requires enabling the parser plugin: 'exportNamespaceFrom' (1:9)" + "sourceType": "module" } diff --git a/packages/babel-parser/test/fixtures/placeholders/export/star-from-3/output.json b/packages/babel-parser/test/fixtures/placeholders/export/star-from-3/output.json new file mode 100644 index 000000000000..2391c0c770d0 --- /dev/null +++ b/packages/babel-parser/test/fixtures/placeholders/export/star-from-3/output.json @@ -0,0 +1,133 @@ +{ + "type": "File", + "start": 0, + "end": 35, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 35 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 35, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 35 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExportNamedDeclaration", + "start": 0, + "end": 35, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 35 + } + }, + "specifiers": [ + { + "type": "ExportNamespaceSpecifier", + "start": 7, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "exported": { + "type": "Placeholder", + "start": 12, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "name": { + "type": "Identifier", + "start": 14, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 18 + }, + "identifierName": "STAR" + }, + "name": "STAR" + }, + "expectedNode": "Identifier" + } + } + ], + "source": { + "type": "Placeholder", + "start": 26, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 26 + }, + "end": { + "line": 1, + "column": 34 + } + }, + "name": { + "type": "Identifier", + "start": 28, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 28 + }, + "end": { + "line": 1, + "column": 32 + }, + "identifierName": "FILE" + }, + "name": "FILE" + }, + "expectedNode": "StringLiteral" + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/typescript/arrow-function/predicate-types/output.json b/packages/babel-parser/test/fixtures/typescript/arrow-function/predicate-types/output.json index e1f9142855b1..45239b7a0c11 100644 --- a/packages/babel-parser/test/fixtures/typescript/arrow-function/predicate-types/output.json +++ b/packages/babel-parser/test/fixtures/typescript/arrow-function/predicate-types/output.json @@ -73,12 +73,12 @@ }, "typeAnnotation": { "type": "TSTypePredicate", - "start": 10, + "start": 8, "end": 21, "loc": { "start": { "line": 1, - "column": 10 + "column": 8 }, "end": { "line": 1, diff --git a/packages/babel-parser/test/fixtures/typescript/assert-predicate/arrow-function/input.ts b/packages/babel-parser/test/fixtures/typescript/assert-predicate/arrow-function/input.ts new file mode 100644 index 000000000000..5989d8d4f2b4 --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/assert-predicate/arrow-function/input.ts @@ -0,0 +1,3 @@ +const assert1 = (value: unknown): asserts value is string => {} +const assert2 = (value: unknown): asserts value => {} +const assert3 = (value: unknown): asserts => {} diff --git a/packages/babel-parser/test/fixtures/typescript/assert-predicate/arrow-function/output.json b/packages/babel-parser/test/fixtures/typescript/assert-predicate/arrow-function/output.json new file mode 100644 index 000000000000..f06258409292 --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/assert-predicate/arrow-function/output.json @@ -0,0 +1,610 @@ +{ + "type": "File", + "start": 0, + "end": 165, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 47 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 165, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 47 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "VariableDeclaration", + "start": 0, + "end": 63, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 63 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 6, + "end": 63, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 63 + } + }, + "id": { + "type": "Identifier", + "start": 6, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 13 + }, + "identifierName": "assert1" + }, + "name": "assert1" + }, + "init": { + "type": "ArrowFunctionExpression", + "start": 16, + "end": 63, + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 63 + } + }, + "returnType": { + "type": "TSTypeAnnotation", + "start": 32, + "end": 57, + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 57 + } + }, + "typeAnnotation": { + "type": "TSTypePredicate", + "start": 32, + "end": 57, + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 57 + } + }, + "parameterName": { + "type": "Identifier", + "start": 42, + "end": 47, + "loc": { + "start": { + "line": 1, + "column": 42 + }, + "end": { + "line": 1, + "column": 47 + }, + "identifierName": "value" + }, + "name": "value" + }, + "typeAnnotation": { + "type": "TSTypeAnnotation", + "start": 51, + "end": 57, + "loc": { + "start": { + "line": 1, + "column": 51 + }, + "end": { + "line": 1, + "column": 57 + } + }, + "typeAnnotation": { + "type": "TSStringKeyword", + "start": 51, + "end": 57, + "loc": { + "start": { + "line": 1, + "column": 51 + }, + "end": { + "line": 1, + "column": 57 + } + } + } + }, + "asserts": true + } + }, + "id": null, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "start": 17, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 31 + }, + "identifierName": "value" + }, + "name": "value", + "typeAnnotation": { + "type": "TSTypeAnnotation", + "start": 22, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 22 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "typeAnnotation": { + "type": "TSUnknownKeyword", + "start": 24, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 24 + }, + "end": { + "line": 1, + "column": 31 + } + } + } + } + } + ], + "body": { + "type": "BlockStatement", + "start": 61, + "end": 63, + "loc": { + "start": { + "line": 1, + "column": 61 + }, + "end": { + "line": 1, + "column": 63 + } + }, + "body": [], + "directives": [] + } + } + } + ], + "kind": "const" + }, + { + "type": "VariableDeclaration", + "start": 64, + "end": 117, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 53 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 70, + "end": 117, + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 53 + } + }, + "id": { + "type": "Identifier", + "start": 70, + "end": 77, + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 13 + }, + "identifierName": "assert2" + }, + "name": "assert2" + }, + "init": { + "type": "ArrowFunctionExpression", + "start": 80, + "end": 117, + "loc": { + "start": { + "line": 2, + "column": 16 + }, + "end": { + "line": 2, + "column": 53 + } + }, + "returnType": { + "type": "TSTypeAnnotation", + "start": 96, + "end": 111, + "loc": { + "start": { + "line": 2, + "column": 32 + }, + "end": { + "line": 2, + "column": 47 + } + }, + "typeAnnotation": { + "type": "TSTypePredicate", + "start": 96, + "end": 111, + "loc": { + "start": { + "line": 2, + "column": 32 + }, + "end": { + "line": 2, + "column": 47 + } + }, + "parameterName": { + "type": "Identifier", + "start": 106, + "end": 111, + "loc": { + "start": { + "line": 2, + "column": 42 + }, + "end": { + "line": 2, + "column": 47 + }, + "identifierName": "value" + }, + "name": "value" + }, + "asserts": true + } + }, + "id": null, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "start": 81, + "end": 95, + "loc": { + "start": { + "line": 2, + "column": 17 + }, + "end": { + "line": 2, + "column": 31 + }, + "identifierName": "value" + }, + "name": "value", + "typeAnnotation": { + "type": "TSTypeAnnotation", + "start": 86, + "end": 95, + "loc": { + "start": { + "line": 2, + "column": 22 + }, + "end": { + "line": 2, + "column": 31 + } + }, + "typeAnnotation": { + "type": "TSUnknownKeyword", + "start": 88, + "end": 95, + "loc": { + "start": { + "line": 2, + "column": 24 + }, + "end": { + "line": 2, + "column": 31 + } + } + } + } + } + ], + "body": { + "type": "BlockStatement", + "start": 115, + "end": 117, + "loc": { + "start": { + "line": 2, + "column": 51 + }, + "end": { + "line": 2, + "column": 53 + } + }, + "body": [], + "directives": [] + } + } + } + ], + "kind": "const" + }, + { + "type": "VariableDeclaration", + "start": 118, + "end": 165, + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 47 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 124, + "end": 165, + "loc": { + "start": { + "line": 3, + "column": 6 + }, + "end": { + "line": 3, + "column": 47 + } + }, + "id": { + "type": "Identifier", + "start": 124, + "end": 131, + "loc": { + "start": { + "line": 3, + "column": 6 + }, + "end": { + "line": 3, + "column": 13 + }, + "identifierName": "assert3" + }, + "name": "assert3" + }, + "init": { + "type": "ArrowFunctionExpression", + "start": 134, + "end": 165, + "loc": { + "start": { + "line": 3, + "column": 16 + }, + "end": { + "line": 3, + "column": 47 + } + }, + "returnType": { + "type": "TSTypeAnnotation", + "start": 150, + "end": 159, + "loc": { + "start": { + "line": 3, + "column": 32 + }, + "end": { + "line": 3, + "column": 41 + } + }, + "typeAnnotation": { + "type": "TSTypeReference", + "start": 152, + "end": 159, + "loc": { + "start": { + "line": 3, + "column": 34 + }, + "end": { + "line": 3, + "column": 41 + } + }, + "typeName": { + "type": "Identifier", + "start": 152, + "end": 159, + "loc": { + "start": { + "line": 3, + "column": 34 + }, + "end": { + "line": 3, + "column": 41 + }, + "identifierName": "asserts" + }, + "name": "asserts" + } + } + }, + "id": null, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "start": 135, + "end": 149, + "loc": { + "start": { + "line": 3, + "column": 17 + }, + "end": { + "line": 3, + "column": 31 + }, + "identifierName": "value" + }, + "name": "value", + "typeAnnotation": { + "type": "TSTypeAnnotation", + "start": 140, + "end": 149, + "loc": { + "start": { + "line": 3, + "column": 22 + }, + "end": { + "line": 3, + "column": 31 + } + }, + "typeAnnotation": { + "type": "TSUnknownKeyword", + "start": 142, + "end": 149, + "loc": { + "start": { + "line": 3, + "column": 24 + }, + "end": { + "line": 3, + "column": 31 + } + } + } + } + } + ], + "body": { + "type": "BlockStatement", + "start": 163, + "end": 165, + "loc": { + "start": { + "line": 3, + "column": 45 + }, + "end": { + "line": 3, + "column": 47 + } + }, + "body": [], + "directives": [] + } + } + } + ], + "kind": "const" + } + ], + "directives": [] + } +} diff --git a/packages/babel-parser/test/fixtures/typescript/assert-predicate/asserts-as-identifier/input.ts b/packages/babel-parser/test/fixtures/typescript/assert-predicate/asserts-as-identifier/input.ts new file mode 100644 index 000000000000..d5ee9a42ce01 --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/assert-predicate/asserts-as-identifier/input.ts @@ -0,0 +1 @@ +declare function assertIsString(value: unknown): asserts; diff --git a/packages/babel-parser/test/fixtures/typescript/assert-predicate/asserts-as-identifier/output.json b/packages/babel-parser/test/fixtures/typescript/assert-predicate/asserts-as-identifier/output.json new file mode 100644 index 000000000000..dc6f8702bdce --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/assert-predicate/asserts-as-identifier/output.json @@ -0,0 +1,166 @@ +{ + "type": "File", + "start": 0, + "end": 57, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 57 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 57, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 57 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "TSDeclareFunction", + "start": 0, + "end": 57, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 57 + } + }, + "id": { + "type": "Identifier", + "start": 17, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 31 + }, + "identifierName": "assertIsString" + }, + "name": "assertIsString" + }, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "start": 32, + "end": 46, + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 46 + }, + "identifierName": "value" + }, + "name": "value", + "typeAnnotation": { + "type": "TSTypeAnnotation", + "start": 37, + "end": 46, + "loc": { + "start": { + "line": 1, + "column": 37 + }, + "end": { + "line": 1, + "column": 46 + } + }, + "typeAnnotation": { + "type": "TSUnknownKeyword", + "start": 39, + "end": 46, + "loc": { + "start": { + "line": 1, + "column": 39 + }, + "end": { + "line": 1, + "column": 46 + } + } + } + } + } + ], + "returnType": { + "type": "TSTypeAnnotation", + "start": 47, + "end": 56, + "loc": { + "start": { + "line": 1, + "column": 47 + }, + "end": { + "line": 1, + "column": 56 + } + }, + "typeAnnotation": { + "type": "TSTypeReference", + "start": 49, + "end": 56, + "loc": { + "start": { + "line": 1, + "column": 49 + }, + "end": { + "line": 1, + "column": 56 + } + }, + "typeName": { + "type": "Identifier", + "start": 49, + "end": 56, + "loc": { + "start": { + "line": 1, + "column": 49 + }, + "end": { + "line": 1, + "column": 56 + }, + "identifierName": "asserts" + }, + "name": "asserts" + } + } + }, + "declare": true + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/typescript/assert-predicate/asserts-this-with-predicate/input.ts b/packages/babel-parser/test/fixtures/typescript/assert-predicate/asserts-this-with-predicate/input.ts new file mode 100644 index 000000000000..cc1a550f07bb --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/assert-predicate/asserts-this-with-predicate/input.ts @@ -0,0 +1,4 @@ +class Foo { + isBar(): asserts this is Foo {} + isBaz = (): asserts this is Foo => {} +} diff --git a/packages/babel-parser/test/fixtures/typescript/assert-predicate/asserts-this-with-predicate/options.json b/packages/babel-parser/test/fixtures/typescript/assert-predicate/asserts-this-with-predicate/options.json new file mode 100644 index 000000000000..efb11900ba6e --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/assert-predicate/asserts-this-with-predicate/options.json @@ -0,0 +1,5 @@ +{ + "plugins": [ + "typescript", "classProperties" + ] +} diff --git a/packages/babel-parser/test/fixtures/typescript/assert-predicate/asserts-this-with-predicate/output.json b/packages/babel-parser/test/fixtures/typescript/assert-predicate/asserts-this-with-predicate/output.json new file mode 100644 index 000000000000..bed7e168b396 --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/assert-predicate/asserts-this-with-predicate/output.json @@ -0,0 +1,397 @@ +{ + "type": "File", + "start": 0, + "end": 87, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 87, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ClassDeclaration", + "start": 0, + "end": 87, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 6, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 9 + }, + "identifierName": "Foo" + }, + "name": "Foo" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "start": 10, + "end": 87, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "body": [ + { + "type": "ClassMethod", + "start": 14, + "end": 45, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 33 + } + }, + "static": false, + "key": { + "type": "Identifier", + "start": 14, + "end": 19, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 7 + }, + "identifierName": "isBar" + }, + "name": "isBar" + }, + "computed": false, + "kind": "method", + "id": null, + "generator": false, + "async": false, + "params": [], + "returnType": { + "type": "TSTypeAnnotation", + "start": 21, + "end": 42, + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 30 + } + }, + "typeAnnotation": { + "type": "TSTypePredicate", + "start": 31, + "end": 42, + "loc": { + "start": { + "line": 2, + "column": 19 + }, + "end": { + "line": 2, + "column": 30 + } + }, + "parameterName": { + "type": "TSThisType", + "start": 31, + "end": 35, + "loc": { + "start": { + "line": 2, + "column": 19 + }, + "end": { + "line": 2, + "column": 23 + } + } + }, + "typeAnnotation": { + "type": "TSTypeAnnotation", + "start": 39, + "end": 42, + "loc": { + "start": { + "line": 2, + "column": 27 + }, + "end": { + "line": 2, + "column": 30 + } + }, + "typeAnnotation": { + "type": "TSTypeReference", + "start": 39, + "end": 42, + "loc": { + "start": { + "line": 2, + "column": 27 + }, + "end": { + "line": 2, + "column": 30 + } + }, + "typeName": { + "type": "Identifier", + "start": 39, + "end": 42, + "loc": { + "start": { + "line": 2, + "column": 27 + }, + "end": { + "line": 2, + "column": 30 + }, + "identifierName": "Foo" + }, + "name": "Foo" + } + } + }, + "asserts": true + } + }, + "body": { + "type": "BlockStatement", + "start": 43, + "end": 45, + "loc": { + "start": { + "line": 2, + "column": 31 + }, + "end": { + "line": 2, + "column": 33 + } + }, + "body": [], + "directives": [] + } + }, + { + "type": "ClassProperty", + "start": 48, + "end": 85, + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 3, + "column": 39 + } + }, + "static": false, + "key": { + "type": "Identifier", + "start": 48, + "end": 53, + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 3, + "column": 7 + }, + "identifierName": "isBaz" + }, + "name": "isBaz" + }, + "computed": false, + "value": { + "type": "ArrowFunctionExpression", + "start": 56, + "end": 85, + "loc": { + "start": { + "line": 3, + "column": 10 + }, + "end": { + "line": 3, + "column": 39 + } + }, + "returnType": { + "type": "TSTypeAnnotation", + "start": 58, + "end": 79, + "loc": { + "start": { + "line": 3, + "column": 12 + }, + "end": { + "line": 3, + "column": 33 + } + }, + "typeAnnotation": { + "type": "TSTypePredicate", + "start": 68, + "end": 79, + "loc": { + "start": { + "line": 3, + "column": 22 + }, + "end": { + "line": 3, + "column": 33 + } + }, + "parameterName": { + "type": "TSThisType", + "start": 68, + "end": 72, + "loc": { + "start": { + "line": 3, + "column": 22 + }, + "end": { + "line": 3, + "column": 26 + } + } + }, + "typeAnnotation": { + "type": "TSTypeAnnotation", + "start": 76, + "end": 79, + "loc": { + "start": { + "line": 3, + "column": 30 + }, + "end": { + "line": 3, + "column": 33 + } + }, + "typeAnnotation": { + "type": "TSTypeReference", + "start": 76, + "end": 79, + "loc": { + "start": { + "line": 3, + "column": 30 + }, + "end": { + "line": 3, + "column": 33 + } + }, + "typeName": { + "type": "Identifier", + "start": 76, + "end": 79, + "loc": { + "start": { + "line": 3, + "column": 30 + }, + "end": { + "line": 3, + "column": 33 + }, + "identifierName": "Foo" + }, + "name": "Foo" + } + } + }, + "asserts": true + } + }, + "id": null, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 83, + "end": 85, + "loc": { + "start": { + "line": 3, + "column": 37 + }, + "end": { + "line": 3, + "column": 39 + } + }, + "body": [], + "directives": [] + } + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/typescript/assert-predicate/asserts-this/input.ts b/packages/babel-parser/test/fixtures/typescript/assert-predicate/asserts-this/input.ts new file mode 100644 index 000000000000..839483541d5b --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/assert-predicate/asserts-this/input.ts @@ -0,0 +1,3 @@ +class C { + m(): asserts this {}; +} diff --git a/packages/babel-parser/test/fixtures/typescript/assert-predicate/asserts-this/output.json b/packages/babel-parser/test/fixtures/typescript/assert-predicate/asserts-this/output.json new file mode 100644 index 000000000000..e9d5458c1c89 --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/assert-predicate/asserts-this/output.json @@ -0,0 +1,187 @@ +{ + "type": "File", + "start": 0, + "end": 35, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 35, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ClassDeclaration", + "start": 0, + "end": 35, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 6, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + }, + "identifierName": "C" + }, + "name": "C" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "start": 8, + "end": 35, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "body": [ + { + "type": "ClassMethod", + "start": 12, + "end": 32, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 22 + } + }, + "static": false, + "key": { + "type": "Identifier", + "start": 12, + "end": 13, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 3 + }, + "identifierName": "m" + }, + "name": "m" + }, + "computed": false, + "kind": "method", + "id": null, + "generator": false, + "async": false, + "params": [], + "returnType": { + "type": "TSTypeAnnotation", + "start": 15, + "end": 29, + "loc": { + "start": { + "line": 2, + "column": 5 + }, + "end": { + "line": 2, + "column": 19 + } + }, + "typeAnnotation": { + "type": "TSTypePredicate", + "start": 15, + "end": 29, + "loc": { + "start": { + "line": 2, + "column": 5 + }, + "end": { + "line": 2, + "column": 19 + } + }, + "parameterName": { + "type": "TSThisType", + "start": 25, + "end": 29, + "loc": { + "start": { + "line": 2, + "column": 15 + }, + "end": { + "line": 2, + "column": 19 + } + } + }, + "asserts": true + } + }, + "body": { + "type": "BlockStatement", + "start": 30, + "end": 32, + "loc": { + "start": { + "line": 2, + "column": 20 + }, + "end": { + "line": 2, + "column": 22 + } + }, + "body": [], + "directives": [] + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/typescript/assert-predicate/asserts-var-with-predicate/input.ts b/packages/babel-parser/test/fixtures/typescript/assert-predicate/asserts-var-with-predicate/input.ts new file mode 100644 index 000000000000..2b580e64e906 --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/assert-predicate/asserts-var-with-predicate/input.ts @@ -0,0 +1,3 @@ +class C { + assertIsString(value: unknown): asserts value is string {} +} diff --git a/packages/babel-parser/test/fixtures/typescript/assert-predicate/asserts-var-with-predicate/output.json b/packages/babel-parser/test/fixtures/typescript/assert-predicate/asserts-var-with-predicate/output.json new file mode 100644 index 000000000000..f63a5e0581c3 --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/assert-predicate/asserts-var-with-predicate/output.json @@ -0,0 +1,267 @@ +{ + "type": "File", + "start": 0, + "end": 72, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 72, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ClassDeclaration", + "start": 0, + "end": 72, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 6, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + }, + "identifierName": "C" + }, + "name": "C" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "start": 8, + "end": 72, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "body": [ + { + "type": "ClassMethod", + "start": 12, + "end": 70, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 60 + } + }, + "static": false, + "key": { + "type": "Identifier", + "start": 12, + "end": 26, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 16 + }, + "identifierName": "assertIsString" + }, + "name": "assertIsString" + }, + "computed": false, + "kind": "method", + "id": null, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "start": 27, + "end": 41, + "loc": { + "start": { + "line": 2, + "column": 17 + }, + "end": { + "line": 2, + "column": 31 + }, + "identifierName": "value" + }, + "name": "value", + "typeAnnotation": { + "type": "TSTypeAnnotation", + "start": 32, + "end": 41, + "loc": { + "start": { + "line": 2, + "column": 22 + }, + "end": { + "line": 2, + "column": 31 + } + }, + "typeAnnotation": { + "type": "TSUnknownKeyword", + "start": 34, + "end": 41, + "loc": { + "start": { + "line": 2, + "column": 24 + }, + "end": { + "line": 2, + "column": 31 + } + } + } + } + } + ], + "returnType": { + "type": "TSTypeAnnotation", + "start": 42, + "end": 67, + "loc": { + "start": { + "line": 2, + "column": 32 + }, + "end": { + "line": 2, + "column": 57 + } + }, + "typeAnnotation": { + "type": "TSTypePredicate", + "start": 42, + "end": 67, + "loc": { + "start": { + "line": 2, + "column": 32 + }, + "end": { + "line": 2, + "column": 57 + } + }, + "parameterName": { + "type": "Identifier", + "start": 52, + "end": 57, + "loc": { + "start": { + "line": 2, + "column": 42 + }, + "end": { + "line": 2, + "column": 47 + }, + "identifierName": "value" + }, + "name": "value" + }, + "typeAnnotation": { + "type": "TSTypeAnnotation", + "start": 61, + "end": 67, + "loc": { + "start": { + "line": 2, + "column": 51 + }, + "end": { + "line": 2, + "column": 57 + } + }, + "typeAnnotation": { + "type": "TSStringKeyword", + "start": 61, + "end": 67, + "loc": { + "start": { + "line": 2, + "column": 51 + }, + "end": { + "line": 2, + "column": 57 + } + } + } + }, + "asserts": true + } + }, + "body": { + "type": "BlockStatement", + "start": 68, + "end": 70, + "loc": { + "start": { + "line": 2, + "column": 58 + }, + "end": { + "line": 2, + "column": 60 + } + }, + "body": [], + "directives": [] + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/typescript/assert-predicate/asserts-var/input.ts b/packages/babel-parser/test/fixtures/typescript/assert-predicate/asserts-var/input.ts new file mode 100644 index 000000000000..63613906e9fd --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/assert-predicate/asserts-var/input.ts @@ -0,0 +1 @@ +declare function assertIsString(value: unknown): asserts value; diff --git a/packages/babel-parser/test/fixtures/typescript/assert-predicate/asserts-var/output.json b/packages/babel-parser/test/fixtures/typescript/assert-predicate/asserts-var/output.json new file mode 100644 index 000000000000..62c634c7dc8e --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/assert-predicate/asserts-var/output.json @@ -0,0 +1,167 @@ +{ + "type": "File", + "start": 0, + "end": 63, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 63 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 63, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 63 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "TSDeclareFunction", + "start": 0, + "end": 63, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 63 + } + }, + "id": { + "type": "Identifier", + "start": 17, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 31 + }, + "identifierName": "assertIsString" + }, + "name": "assertIsString" + }, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "start": 32, + "end": 46, + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 46 + }, + "identifierName": "value" + }, + "name": "value", + "typeAnnotation": { + "type": "TSTypeAnnotation", + "start": 37, + "end": 46, + "loc": { + "start": { + "line": 1, + "column": 37 + }, + "end": { + "line": 1, + "column": 46 + } + }, + "typeAnnotation": { + "type": "TSUnknownKeyword", + "start": 39, + "end": 46, + "loc": { + "start": { + "line": 1, + "column": 39 + }, + "end": { + "line": 1, + "column": 46 + } + } + } + } + } + ], + "returnType": { + "type": "TSTypeAnnotation", + "start": 47, + "end": 62, + "loc": { + "start": { + "line": 1, + "column": 47 + }, + "end": { + "line": 1, + "column": 62 + } + }, + "typeAnnotation": { + "type": "TSTypePredicate", + "start": 47, + "end": 62, + "loc": { + "start": { + "line": 1, + "column": 47 + }, + "end": { + "line": 1, + "column": 62 + } + }, + "parameterName": { + "type": "Identifier", + "start": 57, + "end": 62, + "loc": { + "start": { + "line": 1, + "column": 57 + }, + "end": { + "line": 1, + "column": 62 + }, + "identifierName": "value" + }, + "name": "value" + }, + "asserts": true + } + }, + "declare": true + } + ], + "directives": [] + } +} diff --git a/packages/babel-parser/test/fixtures/typescript/assert-predicate/declare-asserts-var-with-predicate/input.ts b/packages/babel-parser/test/fixtures/typescript/assert-predicate/declare-asserts-var-with-predicate/input.ts new file mode 100644 index 000000000000..9456a5cb2e50 --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/assert-predicate/declare-asserts-var-with-predicate/input.ts @@ -0,0 +1 @@ +declare function assertIsString(value: unknown): asserts value is string; diff --git a/packages/babel-parser/test/fixtures/typescript/assert-predicate/declare-asserts-var-with-predicate/output.json b/packages/babel-parser/test/fixtures/typescript/assert-predicate/declare-asserts-var-with-predicate/output.json new file mode 100644 index 000000000000..82cdaebbcf79 --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/assert-predicate/declare-asserts-var-with-predicate/output.json @@ -0,0 +1,197 @@ +{ + "type": "File", + "start": 0, + "end": 73, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 73 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 73, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 73 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "TSDeclareFunction", + "start": 0, + "end": 73, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 73 + } + }, + "id": { + "type": "Identifier", + "start": 17, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 31 + }, + "identifierName": "assertIsString" + }, + "name": "assertIsString" + }, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "start": 32, + "end": 46, + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 46 + }, + "identifierName": "value" + }, + "name": "value", + "typeAnnotation": { + "type": "TSTypeAnnotation", + "start": 37, + "end": 46, + "loc": { + "start": { + "line": 1, + "column": 37 + }, + "end": { + "line": 1, + "column": 46 + } + }, + "typeAnnotation": { + "type": "TSUnknownKeyword", + "start": 39, + "end": 46, + "loc": { + "start": { + "line": 1, + "column": 39 + }, + "end": { + "line": 1, + "column": 46 + } + } + } + } + } + ], + "returnType": { + "type": "TSTypeAnnotation", + "start": 47, + "end": 72, + "loc": { + "start": { + "line": 1, + "column": 47 + }, + "end": { + "line": 1, + "column": 72 + } + }, + "typeAnnotation": { + "type": "TSTypePredicate", + "start": 47, + "end": 72, + "loc": { + "start": { + "line": 1, + "column": 47 + }, + "end": { + "line": 1, + "column": 72 + } + }, + "parameterName": { + "type": "Identifier", + "start": 57, + "end": 62, + "loc": { + "start": { + "line": 1, + "column": 57 + }, + "end": { + "line": 1, + "column": 62 + }, + "identifierName": "value" + }, + "name": "value" + }, + "typeAnnotation": { + "type": "TSTypeAnnotation", + "start": 66, + "end": 72, + "loc": { + "start": { + "line": 1, + "column": 66 + }, + "end": { + "line": 1, + "column": 72 + } + }, + "typeAnnotation": { + "type": "TSStringKeyword", + "start": 66, + "end": 72, + "loc": { + "start": { + "line": 1, + "column": 66 + }, + "end": { + "line": 1, + "column": 72 + } + } + } + }, + "asserts": true + } + }, + "declare": true + } + ], + "directives": [] + } +} diff --git a/packages/babel-parser/test/fixtures/typescript/assert-predicate/function-declaration/input.ts b/packages/babel-parser/test/fixtures/typescript/assert-predicate/function-declaration/input.ts new file mode 100644 index 000000000000..b04da8349ca2 --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/assert-predicate/function-declaration/input.ts @@ -0,0 +1,3 @@ +function asserts1 (value: unknown): asserts value is string {} +function asserts2 (value: unknown): asserts value {} +function asserts3 (value: unknown): asserts {} diff --git a/packages/babel-parser/test/fixtures/typescript/assert-predicate/function-declaration/output.json b/packages/babel-parser/test/fixtures/typescript/assert-predicate/function-declaration/output.json new file mode 100644 index 000000000000..bea1caf3de2a --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/assert-predicate/function-declaration/output.json @@ -0,0 +1,508 @@ +{ + "type": "File", + "start": 0, + "end": 163, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 46 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 163, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 46 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 62, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 62 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 17 + }, + "identifierName": "asserts1" + }, + "name": "asserts1" + }, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "start": 19, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 33 + }, + "identifierName": "value" + }, + "name": "value", + "typeAnnotation": { + "type": "TSTypeAnnotation", + "start": 24, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 24 + }, + "end": { + "line": 1, + "column": 33 + } + }, + "typeAnnotation": { + "type": "TSUnknownKeyword", + "start": 26, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 26 + }, + "end": { + "line": 1, + "column": 33 + } + } + } + } + } + ], + "returnType": { + "type": "TSTypeAnnotation", + "start": 34, + "end": 59, + "loc": { + "start": { + "line": 1, + "column": 34 + }, + "end": { + "line": 1, + "column": 59 + } + }, + "typeAnnotation": { + "type": "TSTypePredicate", + "start": 34, + "end": 59, + "loc": { + "start": { + "line": 1, + "column": 34 + }, + "end": { + "line": 1, + "column": 59 + } + }, + "parameterName": { + "type": "Identifier", + "start": 44, + "end": 49, + "loc": { + "start": { + "line": 1, + "column": 44 + }, + "end": { + "line": 1, + "column": 49 + }, + "identifierName": "value" + }, + "name": "value" + }, + "typeAnnotation": { + "type": "TSTypeAnnotation", + "start": 53, + "end": 59, + "loc": { + "start": { + "line": 1, + "column": 53 + }, + "end": { + "line": 1, + "column": 59 + } + }, + "typeAnnotation": { + "type": "TSStringKeyword", + "start": 53, + "end": 59, + "loc": { + "start": { + "line": 1, + "column": 53 + }, + "end": { + "line": 1, + "column": 59 + } + } + } + }, + "asserts": true + } + }, + "body": { + "type": "BlockStatement", + "start": 60, + "end": 62, + "loc": { + "start": { + "line": 1, + "column": 60 + }, + "end": { + "line": 1, + "column": 62 + } + }, + "body": [], + "directives": [] + } + }, + { + "type": "FunctionDeclaration", + "start": 64, + "end": 116, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 52 + } + }, + "id": { + "type": "Identifier", + "start": 73, + "end": 81, + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 17 + }, + "identifierName": "asserts2" + }, + "name": "asserts2" + }, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "start": 83, + "end": 97, + "loc": { + "start": { + "line": 2, + "column": 19 + }, + "end": { + "line": 2, + "column": 33 + }, + "identifierName": "value" + }, + "name": "value", + "typeAnnotation": { + "type": "TSTypeAnnotation", + "start": 88, + "end": 97, + "loc": { + "start": { + "line": 2, + "column": 24 + }, + "end": { + "line": 2, + "column": 33 + } + }, + "typeAnnotation": { + "type": "TSUnknownKeyword", + "start": 90, + "end": 97, + "loc": { + "start": { + "line": 2, + "column": 26 + }, + "end": { + "line": 2, + "column": 33 + } + } + } + } + } + ], + "returnType": { + "type": "TSTypeAnnotation", + "start": 98, + "end": 113, + "loc": { + "start": { + "line": 2, + "column": 34 + }, + "end": { + "line": 2, + "column": 49 + } + }, + "typeAnnotation": { + "type": "TSTypePredicate", + "start": 98, + "end": 113, + "loc": { + "start": { + "line": 2, + "column": 34 + }, + "end": { + "line": 2, + "column": 49 + } + }, + "parameterName": { + "type": "Identifier", + "start": 108, + "end": 113, + "loc": { + "start": { + "line": 2, + "column": 44 + }, + "end": { + "line": 2, + "column": 49 + }, + "identifierName": "value" + }, + "name": "value" + }, + "asserts": true + } + }, + "body": { + "type": "BlockStatement", + "start": 114, + "end": 116, + "loc": { + "start": { + "line": 2, + "column": 50 + }, + "end": { + "line": 2, + "column": 52 + } + }, + "body": [], + "directives": [] + } + }, + { + "type": "FunctionDeclaration", + "start": 117, + "end": 163, + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 46 + } + }, + "id": { + "type": "Identifier", + "start": 126, + "end": 134, + "loc": { + "start": { + "line": 3, + "column": 9 + }, + "end": { + "line": 3, + "column": 17 + }, + "identifierName": "asserts3" + }, + "name": "asserts3" + }, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "start": 136, + "end": 150, + "loc": { + "start": { + "line": 3, + "column": 19 + }, + "end": { + "line": 3, + "column": 33 + }, + "identifierName": "value" + }, + "name": "value", + "typeAnnotation": { + "type": "TSTypeAnnotation", + "start": 141, + "end": 150, + "loc": { + "start": { + "line": 3, + "column": 24 + }, + "end": { + "line": 3, + "column": 33 + } + }, + "typeAnnotation": { + "type": "TSUnknownKeyword", + "start": 143, + "end": 150, + "loc": { + "start": { + "line": 3, + "column": 26 + }, + "end": { + "line": 3, + "column": 33 + } + } + } + } + } + ], + "returnType": { + "type": "TSTypeAnnotation", + "start": 151, + "end": 160, + "loc": { + "start": { + "line": 3, + "column": 34 + }, + "end": { + "line": 3, + "column": 43 + } + }, + "typeAnnotation": { + "type": "TSTypeReference", + "start": 153, + "end": 160, + "loc": { + "start": { + "line": 3, + "column": 36 + }, + "end": { + "line": 3, + "column": 43 + } + }, + "typeName": { + "type": "Identifier", + "start": 153, + "end": 160, + "loc": { + "start": { + "line": 3, + "column": 36 + }, + "end": { + "line": 3, + "column": 43 + }, + "identifierName": "asserts" + }, + "name": "asserts" + } + } + }, + "body": { + "type": "BlockStatement", + "start": 161, + "end": 163, + "loc": { + "start": { + "line": 3, + "column": 44 + }, + "end": { + "line": 3, + "column": 46 + } + }, + "body": [], + "directives": [] + } + } + ], + "directives": [] + } +} diff --git a/packages/babel-parser/test/fixtures/typescript/assert-predicate/invalid-escaped-asserts-keyword/input.ts b/packages/babel-parser/test/fixtures/typescript/assert-predicate/invalid-escaped-asserts-keyword/input.ts new file mode 100644 index 000000000000..a89b5ad6c9fa --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/assert-predicate/invalid-escaped-asserts-keyword/input.ts @@ -0,0 +1 @@ +declare function assertIsString(value: unknown): \u{61}sserts value; diff --git a/packages/babel-parser/test/fixtures/typescript/assert-predicate/invalid-escaped-asserts-keyword/output.json b/packages/babel-parser/test/fixtures/typescript/assert-predicate/invalid-escaped-asserts-keyword/output.json new file mode 100644 index 000000000000..90484c4b93a3 --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/assert-predicate/invalid-escaped-asserts-keyword/output.json @@ -0,0 +1,170 @@ +{ + "type": "File", + "start": 0, + "end": 68, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 68 + } + }, + "errors": [ + "SyntaxError: Escape sequence in keyword asserts (1:49)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 68, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 68 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "TSDeclareFunction", + "start": 0, + "end": 68, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 68 + } + }, + "id": { + "type": "Identifier", + "start": 17, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 31 + }, + "identifierName": "assertIsString" + }, + "name": "assertIsString" + }, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "start": 32, + "end": 46, + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 46 + }, + "identifierName": "value" + }, + "name": "value", + "typeAnnotation": { + "type": "TSTypeAnnotation", + "start": 37, + "end": 46, + "loc": { + "start": { + "line": 1, + "column": 37 + }, + "end": { + "line": 1, + "column": 46 + } + }, + "typeAnnotation": { + "type": "TSUnknownKeyword", + "start": 39, + "end": 46, + "loc": { + "start": { + "line": 1, + "column": 39 + }, + "end": { + "line": 1, + "column": 46 + } + } + } + } + } + ], + "returnType": { + "type": "TSTypeAnnotation", + "start": 47, + "end": 67, + "loc": { + "start": { + "line": 1, + "column": 47 + }, + "end": { + "line": 1, + "column": 67 + } + }, + "typeAnnotation": { + "type": "TSTypePredicate", + "start": 47, + "end": 67, + "loc": { + "start": { + "line": 1, + "column": 47 + }, + "end": { + "line": 1, + "column": 67 + } + }, + "parameterName": { + "type": "Identifier", + "start": 62, + "end": 67, + "loc": { + "start": { + "line": 1, + "column": 62 + }, + "end": { + "line": 1, + "column": 67 + }, + "identifierName": "value" + }, + "name": "value" + }, + "asserts": true + } + }, + "declare": true + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/typescript/cast/arrow-async-parameter-as/options.json b/packages/babel-parser/test/fixtures/typescript/cast/arrow-async-parameter-as/options.json deleted file mode 100644 index 69d91502496d..000000000000 --- a/packages/babel-parser/test/fixtures/typescript/cast/arrow-async-parameter-as/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Unexpected type cast in parameter position. (1:7)" -} diff --git a/packages/babel-parser/test/fixtures/typescript/cast/arrow-async-parameter-as/output.json b/packages/babel-parser/test/fixtures/typescript/cast/arrow-async-parameter-as/output.json new file mode 100644 index 000000000000..84bb9f048205 --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/cast/arrow-async-parameter-as/output.json @@ -0,0 +1,154 @@ +{ + "type": "File", + "start": 0, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "errors": [ + "SyntaxError: Unexpected type cast in parameter position. (1:7)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "expression": { + "type": "ArrowFunctionExpression", + "start": 0, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "id": null, + "generator": false, + "async": true, + "params": [ + { + "type": "TSAsExpression", + "start": 7, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "expression": { + "type": "Identifier", + "start": 7, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 8 + }, + "identifierName": "a" + }, + "name": "a" + }, + "typeAnnotation": { + "type": "TSTypeReference", + "start": 12, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "typeName": { + "type": "Identifier", + "start": 12, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 13 + }, + "identifierName": "T" + }, + "name": "T" + } + } + } + ], + "body": { + "type": "BlockStatement", + "start": 18, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "body": [], + "directives": [] + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/typescript/cast/arrow-async-parameter-assertion/options.json b/packages/babel-parser/test/fixtures/typescript/cast/arrow-async-parameter-assertion/options.json deleted file mode 100644 index 69d91502496d..000000000000 --- a/packages/babel-parser/test/fixtures/typescript/cast/arrow-async-parameter-assertion/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Unexpected type cast in parameter position. (1:7)" -} diff --git a/packages/babel-parser/test/fixtures/typescript/cast/arrow-async-parameter-assertion/output.json b/packages/babel-parser/test/fixtures/typescript/cast/arrow-async-parameter-assertion/output.json new file mode 100644 index 000000000000..5825bdc4db33 --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/cast/arrow-async-parameter-assertion/output.json @@ -0,0 +1,154 @@ +{ + "type": "File", + "start": 0, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "errors": [ + "SyntaxError: Unexpected type cast in parameter position. (1:7)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "expression": { + "type": "ArrowFunctionExpression", + "start": 0, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "id": null, + "generator": false, + "async": true, + "params": [ + { + "type": "TSTypeAssertion", + "start": 7, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "typeAnnotation": { + "type": "TSTypeReference", + "start": 8, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "typeName": { + "type": "Identifier", + "start": 8, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 9 + }, + "identifierName": "T" + }, + "name": "T" + } + }, + "expression": { + "type": "Identifier", + "start": 11, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 12 + }, + "identifierName": "a" + }, + "name": "a" + } + } + ], + "body": { + "type": "BlockStatement", + "start": 17, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "body": [], + "directives": [] + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/typescript/cast/arrow-parameter-as/options.json b/packages/babel-parser/test/fixtures/typescript/cast/arrow-parameter-as/options.json deleted file mode 100644 index b5bdba868c9f..000000000000 --- a/packages/babel-parser/test/fixtures/typescript/cast/arrow-parameter-as/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Unexpected type cast in parameter position. (1:1)" -} diff --git a/packages/babel-parser/test/fixtures/typescript/cast/arrow-parameter-as/output.json b/packages/babel-parser/test/fixtures/typescript/cast/arrow-parameter-as/output.json new file mode 100644 index 000000000000..369ec9d0eb08 --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/cast/arrow-parameter-as/output.json @@ -0,0 +1,154 @@ +{ + "type": "File", + "start": 0, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "errors": [ + "SyntaxError: Unexpected type cast in parameter position. (1:1)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "expression": { + "type": "ArrowFunctionExpression", + "start": 0, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "id": null, + "generator": false, + "async": false, + "params": [ + { + "type": "TSAsExpression", + "start": 1, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "expression": { + "type": "Identifier", + "start": 1, + "end": 2, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 2 + }, + "identifierName": "a" + }, + "name": "a" + }, + "typeAnnotation": { + "type": "TSTypeReference", + "start": 6, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "typeName": { + "type": "Identifier", + "start": 6, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + }, + "identifierName": "T" + }, + "name": "T" + } + } + } + ], + "body": { + "type": "BlockStatement", + "start": 12, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "body": [], + "directives": [] + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/typescript/cast/arrow-parameter-assertion/options.json b/packages/babel-parser/test/fixtures/typescript/cast/arrow-parameter-assertion/options.json deleted file mode 100644 index b5bdba868c9f..000000000000 --- a/packages/babel-parser/test/fixtures/typescript/cast/arrow-parameter-assertion/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Unexpected type cast in parameter position. (1:1)" -} diff --git a/packages/babel-parser/test/fixtures/typescript/cast/arrow-parameter-assertion/output.json b/packages/babel-parser/test/fixtures/typescript/cast/arrow-parameter-assertion/output.json new file mode 100644 index 000000000000..52cb7ee9d5a9 --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/cast/arrow-parameter-assertion/output.json @@ -0,0 +1,154 @@ +{ + "type": "File", + "start": 0, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "errors": [ + "SyntaxError: Unexpected type cast in parameter position. (1:1)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "expression": { + "type": "ArrowFunctionExpression", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "id": null, + "generator": false, + "async": false, + "params": [ + { + "type": "TSTypeAssertion", + "start": 1, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "typeAnnotation": { + "type": "TSTypeReference", + "start": 2, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 2 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "typeName": { + "type": "Identifier", + "start": 2, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 2 + }, + "end": { + "line": 1, + "column": 3 + }, + "identifierName": "T" + }, + "name": "T" + } + }, + "expression": { + "type": "Identifier", + "start": 5, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 6 + }, + "identifierName": "a" + }, + "name": "a" + } + } + ], + "body": { + "type": "BlockStatement", + "start": 11, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "body": [], + "directives": [] + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/typescript/cast/destructure-and-assign/input.ts b/packages/babel-parser/test/fixtures/typescript/cast/destructure-and-assign/input.ts new file mode 100644 index 000000000000..ece9096fb9f6 --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/cast/destructure-and-assign/input.ts @@ -0,0 +1,2 @@ +[a as number] = [42]; +[a] = [42]; diff --git a/packages/babel-parser/test/fixtures/typescript/cast/destructure-and-assign/output.json b/packages/babel-parser/test/fixtures/typescript/cast/destructure-and-assign/output.json new file mode 100644 index 000000000000..d621a6cb84c1 --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/cast/destructure-and-assign/output.json @@ -0,0 +1,269 @@ +{ + "type": "File", + "start": 0, + "end": 41, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 19 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 41, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 19 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "expression": { + "type": "AssignmentExpression", + "start": 0, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "operator": "=", + "left": { + "type": "ArrayPattern", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "elements": [ + { + "type": "Identifier", + "start": 1, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 12 + }, + "identifierName": "a" + }, + "name": "a", + "typeAnnotation": { + "type": "TSNumberKeyword", + "start": 6, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 12 + } + } + } + } + ] + }, + "right": { + "type": "ArrayExpression", + "start": 16, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "elements": [ + { + "type": "NumericLiteral", + "start": 17, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "extra": { + "rawValue": 42, + "raw": "42" + }, + "value": 42 + } + ] + } + } + }, + { + "type": "ExpressionStatement", + "start": 22, + "end": 41, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 19 + } + }, + "expression": { + "type": "AssignmentExpression", + "start": 22, + "end": 40, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 18 + } + }, + "operator": "=", + "left": { + "type": "ArrayPattern", + "start": 22, + "end": 33, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 11 + } + }, + "elements": [ + { + "type": "Identifier", + "start": 31, + "end": 30, + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 8 + }, + "identifierName": "a" + }, + "name": "a", + "typeAnnotation": { + "type": "TSNumberKeyword", + "start": 24, + "end": 30, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 8 + } + } + } + } + ] + }, + "right": { + "type": "ArrayExpression", + "start": 36, + "end": 40, + "loc": { + "start": { + "line": 2, + "column": 14 + }, + "end": { + "line": 2, + "column": 18 + } + }, + "elements": [ + { + "type": "NumericLiteral", + "start": 37, + "end": 39, + "loc": { + "start": { + "line": 2, + "column": 15 + }, + "end": { + "line": 2, + "column": 17 + } + }, + "extra": { + "rawValue": 42, + "raw": "42" + }, + "value": 42 + } + ] + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/typescript/class/async-named-properties/input.ts b/packages/babel-parser/test/fixtures/typescript/class/async-named-properties/input.ts new file mode 100644 index 000000000000..1e0af756a626 --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/class/async-named-properties/input.ts @@ -0,0 +1,4 @@ +class A { + async?(): void + async?: boolean +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/typescript/class/async-named-properties/output.json b/packages/babel-parser/test/fixtures/typescript/class/async-named-properties/output.json new file mode 100644 index 000000000000..e0ac8a5907fa --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/class/async-named-properties/output.json @@ -0,0 +1,221 @@ +{ + "type": "File", + "start": 0, + "end": 46, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 46, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ClassDeclaration", + "start": 0, + "end": 46, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 6, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + }, + "identifierName": "A" + }, + "name": "A" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "start": 8, + "end": 46, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "body": [ + { + "type": "TSDeclareMethod", + "start": 12, + "end": 26, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 16 + } + }, + "static": false, + "key": { + "type": "Identifier", + "start": 12, + "end": 17, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 7 + }, + "identifierName": "async" + }, + "name": "async" + }, + "computed": false, + "optional": true, + "kind": "method", + "id": null, + "generator": false, + "async": false, + "params": [], + "returnType": { + "type": "TSTypeAnnotation", + "start": 20, + "end": 26, + "loc": { + "start": { + "line": 2, + "column": 10 + }, + "end": { + "line": 2, + "column": 16 + } + }, + "typeAnnotation": { + "type": "TSVoidKeyword", + "start": 22, + "end": 26, + "loc": { + "start": { + "line": 2, + "column": 12 + }, + "end": { + "line": 2, + "column": 16 + } + } + } + } + }, + { + "type": "ClassProperty", + "start": 29, + "end": 44, + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 3, + "column": 17 + } + }, + "static": false, + "key": { + "type": "Identifier", + "start": 29, + "end": 34, + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 3, + "column": 7 + }, + "identifierName": "async" + }, + "name": "async" + }, + "computed": false, + "optional": true, + "typeAnnotation": { + "type": "TSTypeAnnotation", + "start": 35, + "end": 44, + "loc": { + "start": { + "line": 3, + "column": 8 + }, + "end": { + "line": 3, + "column": 17 + } + }, + "typeAnnotation": { + "type": "TSBooleanKeyword", + "start": 37, + "end": 44, + "loc": { + "start": { + "line": 3, + "column": 10 + }, + "end": { + "line": 3, + "column": 17 + } + } + } + }, + "value": null + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/typescript/class/declare-field-initializer/input.ts b/packages/babel-parser/test/fixtures/typescript/class/declare-field-initializer/input.ts new file mode 100644 index 000000000000..b77a17738bf5 --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/class/declare-field-initializer/input.ts @@ -0,0 +1,3 @@ +class A { + declare bar: string = "test"; +} diff --git a/packages/babel-parser/test/fixtures/typescript/class/declare-field-initializer/output.json b/packages/babel-parser/test/fixtures/typescript/class/declare-field-initializer/output.json new file mode 100644 index 000000000000..fb27f3055064 --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/class/declare-field-initializer/output.json @@ -0,0 +1,170 @@ +{ + "type": "File", + "start": 0, + "end": 43, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 43, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ClassDeclaration", + "start": 0, + "end": 43, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 6, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + }, + "identifierName": "A" + }, + "name": "A" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "start": 8, + "end": 43, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "body": [ + { + "type": "ClassProperty", + "start": 12, + "end": 41, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 31 + } + }, + "declare": true, + "static": false, + "key": { + "type": "Identifier", + "start": 20, + "end": 23, + "loc": { + "start": { + "line": 2, + "column": 10 + }, + "end": { + "line": 2, + "column": 13 + }, + "identifierName": "bar" + }, + "name": "bar" + }, + "computed": false, + "typeAnnotation": { + "type": "TSTypeAnnotation", + "start": 23, + "end": 31, + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 21 + } + }, + "typeAnnotation": { + "type": "TSStringKeyword", + "start": 25, + "end": 31, + "loc": { + "start": { + "line": 2, + "column": 15 + }, + "end": { + "line": 2, + "column": 21 + } + } + } + }, + "value": { + "type": "StringLiteral", + "start": 34, + "end": 40, + "loc": { + "start": { + "line": 2, + "column": 24 + }, + "end": { + "line": 2, + "column": 30 + } + }, + "extra": { + "rawValue": "test", + "raw": "\"test\"" + }, + "value": "test" + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/typescript/class/declare-field/input.ts b/packages/babel-parser/test/fixtures/typescript/class/declare-field/input.ts new file mode 100644 index 000000000000..a7a8b2d36280 --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/class/declare-field/input.ts @@ -0,0 +1,4 @@ +class A { + declare foo; + declare bar: string; +} diff --git a/packages/babel-parser/test/fixtures/typescript/class/declare-field/output.json b/packages/babel-parser/test/fixtures/typescript/class/declare-field/output.json new file mode 100644 index 000000000000..746e2964f438 --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/class/declare-field/output.json @@ -0,0 +1,187 @@ +{ + "type": "File", + "start": 0, + "end": 49, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 49, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ClassDeclaration", + "start": 0, + "end": 49, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 6, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + }, + "identifierName": "A" + }, + "name": "A" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "start": 8, + "end": 49, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "body": [ + { + "type": "ClassProperty", + "start": 12, + "end": 24, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 14 + } + }, + "declare": true, + "static": false, + "key": { + "type": "Identifier", + "start": 20, + "end": 23, + "loc": { + "start": { + "line": 2, + "column": 10 + }, + "end": { + "line": 2, + "column": 13 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "computed": false, + "value": null + }, + { + "type": "ClassProperty", + "start": 27, + "end": 47, + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 3, + "column": 22 + } + }, + "declare": true, + "static": false, + "key": { + "type": "Identifier", + "start": 35, + "end": 38, + "loc": { + "start": { + "line": 3, + "column": 10 + }, + "end": { + "line": 3, + "column": 13 + }, + "identifierName": "bar" + }, + "name": "bar" + }, + "computed": false, + "typeAnnotation": { + "type": "TSTypeAnnotation", + "start": 38, + "end": 46, + "loc": { + "start": { + "line": 3, + "column": 13 + }, + "end": { + "line": 3, + "column": 21 + } + }, + "typeAnnotation": { + "type": "TSStringKeyword", + "start": 40, + "end": 46, + "loc": { + "start": { + "line": 3, + "column": 15 + }, + "end": { + "line": 3, + "column": 21 + } + } + } + }, + "value": null + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/typescript/class/declare-method/input.ts b/packages/babel-parser/test/fixtures/typescript/class/declare-method/input.ts new file mode 100644 index 000000000000..0e539a84a2a5 --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/class/declare-method/input.ts @@ -0,0 +1,3 @@ +class A { + declare foo() {} +} diff --git a/packages/babel-parser/test/fixtures/typescript/class/declare-method/output.json b/packages/babel-parser/test/fixtures/typescript/class/declare-method/output.json new file mode 100644 index 000000000000..0219c43119d2 --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/class/declare-method/output.json @@ -0,0 +1,145 @@ +{ + "type": "File", + "start": 0, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "errors": [ + "SyntaxError: Class methods cannot have the 'declare' modifier (2:2)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ClassDeclaration", + "start": 0, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 6, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + }, + "identifierName": "A" + }, + "name": "A" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "start": 8, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "body": [ + { + "type": "ClassMethod", + "start": 12, + "end": 28, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 18 + } + }, + "declare": true, + "static": false, + "key": { + "type": "Identifier", + "start": 20, + "end": 23, + "loc": { + "start": { + "line": 2, + "column": 10 + }, + "end": { + "line": 2, + "column": 13 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "computed": false, + "kind": "method", + "id": null, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 26, + "end": 28, + "loc": { + "start": { + "line": 2, + "column": 16 + }, + "end": { + "line": 2, + "column": 18 + } + }, + "body": [], + "directives": [] + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/typescript/class/extends-empty/options.json b/packages/babel-parser/test/fixtures/typescript/class/extends-empty/options.json deleted file mode 100644 index 3de0ab8596c4..000000000000 --- a/packages/babel-parser/test/fixtures/typescript/class/extends-empty/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "'extends' list cannot be empty. (1:22)" -} diff --git a/packages/babel-parser/test/fixtures/typescript/class/extends-empty/output.json b/packages/babel-parser/test/fixtures/typescript/class/extends-empty/output.json new file mode 100644 index 000000000000..0fe556a129e5 --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/class/extends-empty/output.json @@ -0,0 +1,87 @@ +{ + "type": "File", + "start": 0, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 1 + } + }, + "errors": [ + "SyntaxError: 'extends' list cannot be empty. (1:22)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 1 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "TSInterfaceDeclaration", + "start": 0, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 10, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 13 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "extends": [], + "body": { + "type": "TSInterfaceBody", + "start": 22, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 22 + }, + "end": { + "line": 2, + "column": 1 + } + }, + "body": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/typescript/class/extends-implements-empty/options.json b/packages/babel-parser/test/fixtures/typescript/class/extends-implements-empty/options.json deleted file mode 100644 index 950506446835..000000000000 --- a/packages/babel-parser/test/fixtures/typescript/class/extends-implements-empty/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "'implements' list cannot be empty. (1:33)" -} diff --git a/packages/babel-parser/test/fixtures/typescript/class/extends-implements-empty/output.json b/packages/babel-parser/test/fixtures/typescript/class/extends-implements-empty/output.json new file mode 100644 index 000000000000..a84755dbbeb5 --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/class/extends-implements-empty/output.json @@ -0,0 +1,104 @@ +{ + "type": "File", + "start": 0, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 1 + } + }, + "errors": [ + "SyntaxError: 'implements' list cannot be empty. (1:33)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 1 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ClassDeclaration", + "start": 0, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 6, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 9 + }, + "identifierName": "Foo" + }, + "name": "Foo" + }, + "superClass": { + "type": "Identifier", + "start": 18, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 21 + }, + "identifierName": "Bar" + }, + "name": "Bar" + }, + "implements": [], + "body": { + "type": "ClassBody", + "start": 33, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 33 + }, + "end": { + "line": 2, + "column": 1 + } + }, + "body": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/typescript/class/implements-empty/options.json b/packages/babel-parser/test/fixtures/typescript/class/implements-empty/options.json deleted file mode 100644 index 6751fbcc5443..000000000000 --- a/packages/babel-parser/test/fixtures/typescript/class/implements-empty/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "'implements' list cannot be empty. (1:21)" -} diff --git a/packages/babel-parser/test/fixtures/typescript/class/implements-empty/output.json b/packages/babel-parser/test/fixtures/typescript/class/implements-empty/output.json new file mode 100644 index 000000000000..bcf3445883b0 --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/class/implements-empty/output.json @@ -0,0 +1,88 @@ +{ + "type": "File", + "start": 0, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 1 + } + }, + "errors": [ + "SyntaxError: 'implements' list cannot be empty. (1:21)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 1 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ClassDeclaration", + "start": 0, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 6, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 9 + }, + "identifierName": "Foo" + }, + "name": "Foo" + }, + "superClass": null, + "implements": [], + "body": { + "type": "ClassBody", + "start": 21, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 21 + }, + "end": { + "line": 2, + "column": 1 + } + }, + "body": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/typescript/class/method-readonly/options.json b/packages/babel-parser/test/fixtures/typescript/class/method-readonly/options.json deleted file mode 100644 index f7dd2e27ef2c..000000000000 --- a/packages/babel-parser/test/fixtures/typescript/class/method-readonly/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Unexpected token, expected \";\" (2:14)" -} diff --git a/packages/babel-parser/test/fixtures/typescript/class/method-readonly/output.json b/packages/babel-parser/test/fixtures/typescript/class/method-readonly/output.json new file mode 100644 index 000000000000..198e2e1cf0c9 --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/class/method-readonly/output.json @@ -0,0 +1,145 @@ +{ + "type": "File", + "start": 0, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "errors": [ + "SyntaxError: Class methods cannot have the 'readonly' modifier (2:4)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ClassDeclaration", + "start": 0, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 6, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + }, + "identifierName": "C" + }, + "name": "C" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "start": 8, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "body": [ + { + "type": "ClassMethod", + "start": 14, + "end": 29, + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 19 + } + }, + "readonly": true, + "static": false, + "key": { + "type": "Identifier", + "start": 23, + "end": 24, + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 14 + }, + "identifierName": "m" + }, + "name": "m" + }, + "computed": false, + "kind": "method", + "id": null, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 27, + "end": 29, + "loc": { + "start": { + "line": 2, + "column": 17 + }, + "end": { + "line": 2, + "column": 19 + } + }, + "body": [], + "directives": [] + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/typescript/class/optional-async-error/input.js b/packages/babel-parser/test/fixtures/typescript/class/optional-async-error/input.js new file mode 100644 index 000000000000..01d6018a50d2 --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/class/optional-async-error/input.js @@ -0,0 +1,4 @@ +class B { } +class A extends B { + async? method(val: string): Promise; +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/typescript/class/optional-async-error/options.json b/packages/babel-parser/test/fixtures/typescript/class/optional-async-error/options.json new file mode 100644 index 000000000000..8dde42aa3f55 --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/class/optional-async-error/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Unexpected token (3:9)" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/typescript/class/options.json b/packages/babel-parser/test/fixtures/typescript/class/options.json index 9f3a0c2c0ff1..fff045d3a491 100644 --- a/packages/babel-parser/test/fixtures/typescript/class/options.json +++ b/packages/babel-parser/test/fixtures/typescript/class/options.json @@ -1,4 +1,4 @@ { "sourceType": "module", - "plugins": ["typescript", "classProperties"] + "plugins": ["typescript", "classProperties", "classPrivateProperties"] } diff --git a/packages/babel-parser/test/fixtures/typescript/class/parameter-properties-binding-patterns/options.json b/packages/babel-parser/test/fixtures/typescript/class/parameter-properties-binding-patterns/options.json deleted file mode 100644 index b84b0421721a..000000000000 --- a/packages/babel-parser/test/fixtures/typescript/class/parameter-properties-binding-patterns/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "A parameter property may not be declared using a binding pattern. (2:16)" -} diff --git a/packages/babel-parser/test/fixtures/typescript/class/parameter-properties-binding-patterns/output.json b/packages/babel-parser/test/fixtures/typescript/class/parameter-properties-binding-patterns/output.json new file mode 100644 index 000000000000..9436fb7283a9 --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/class/parameter-properties-binding-patterns/output.json @@ -0,0 +1,177 @@ +{ + "type": "File", + "start": 0, + "end": 41, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "errors": [ + "SyntaxError: A parameter property may not be declared using a binding pattern. (2:16)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 41, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ClassDeclaration", + "start": 0, + "end": 41, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 6, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + }, + "identifierName": "C" + }, + "name": "C" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "start": 8, + "end": 41, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "body": [ + { + "type": "ClassMethod", + "start": 14, + "end": 39, + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 29 + } + }, + "static": false, + "key": { + "type": "Identifier", + "start": 14, + "end": 25, + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 15 + }, + "identifierName": "constructor" + }, + "name": "constructor" + }, + "computed": false, + "kind": "constructor", + "id": null, + "generator": false, + "async": false, + "params": [ + { + "type": "TSParameterProperty", + "start": 26, + "end": 35, + "loc": { + "start": { + "line": 2, + "column": 16 + }, + "end": { + "line": 2, + "column": 25 + } + }, + "accessibility": "public", + "parameter": { + "type": "ArrayPattern", + "start": 33, + "end": 35, + "loc": { + "start": { + "line": 2, + "column": 23 + }, + "end": { + "line": 2, + "column": 25 + } + }, + "elements": [] + } + } + ], + "body": { + "type": "BlockStatement", + "start": 37, + "end": 39, + "loc": { + "start": { + "line": 2, + "column": 27 + }, + "end": { + "line": 2, + "column": 29 + } + }, + "body": [], + "directives": [] + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/typescript/class/private-fields-modifier-abstract/input.ts b/packages/babel-parser/test/fixtures/typescript/class/private-fields-modifier-abstract/input.ts new file mode 100644 index 000000000000..7cf85ea5ec29 --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/class/private-fields-modifier-abstract/input.ts @@ -0,0 +1,3 @@ +abstract class A { + abstract #a; +} diff --git a/packages/babel-parser/test/fixtures/typescript/class/private-fields-modifier-abstract/output.json b/packages/babel-parser/test/fixtures/typescript/class/private-fields-modifier-abstract/output.json new file mode 100644 index 000000000000..9107b0794815 --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/class/private-fields-modifier-abstract/output.json @@ -0,0 +1,139 @@ +{ + "type": "File", + "start": 0, + "end": 35, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "errors": [ + "SyntaxError: Private elements cannot have the 'abstract' modifier. (2:2)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 35, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ClassDeclaration", + "start": 0, + "end": 35, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "abstract": true, + "id": { + "type": "Identifier", + "start": 15, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 16 + }, + "identifierName": "A" + }, + "name": "A" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "start": 17, + "end": 35, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "body": [ + { + "type": "ClassPrivateProperty", + "start": 21, + "end": 33, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 14 + } + }, + "abstract": true, + "static": false, + "key": { + "type": "PrivateName", + "start": 30, + "end": 32, + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 13 + } + }, + "id": { + "type": "Identifier", + "start": 31, + "end": 32, + "loc": { + "start": { + "line": 2, + "column": 12 + }, + "end": { + "line": 2, + "column": 13 + }, + "identifierName": "a" + }, + "name": "a" + } + }, + "value": null + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/typescript/class/private-fields-modifier-private/input.ts b/packages/babel-parser/test/fixtures/typescript/class/private-fields-modifier-private/input.ts new file mode 100644 index 000000000000..a4472caceb86 --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/class/private-fields-modifier-private/input.ts @@ -0,0 +1,3 @@ +class A { + private #a; +} diff --git a/packages/babel-parser/test/fixtures/typescript/class/private-fields-modifier-private/output.json b/packages/babel-parser/test/fixtures/typescript/class/private-fields-modifier-private/output.json new file mode 100644 index 000000000000..360a75b9f7a1 --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/class/private-fields-modifier-private/output.json @@ -0,0 +1,138 @@ +{ + "type": "File", + "start": 0, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "errors": [ + "SyntaxError: Private elements cannot have an accessibility modifier ('private') (2:2)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ClassDeclaration", + "start": 0, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 6, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + }, + "identifierName": "A" + }, + "name": "A" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "start": 8, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "body": [ + { + "type": "ClassPrivateProperty", + "start": 12, + "end": 23, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 13 + } + }, + "accessibility": "private", + "static": false, + "key": { + "type": "PrivateName", + "start": 20, + "end": 22, + "loc": { + "start": { + "line": 2, + "column": 10 + }, + "end": { + "line": 2, + "column": 12 + } + }, + "id": { + "type": "Identifier", + "start": 21, + "end": 22, + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 12 + }, + "identifierName": "a" + }, + "name": "a" + } + }, + "value": null + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/typescript/class/private-fields-modifier-protected/input.ts b/packages/babel-parser/test/fixtures/typescript/class/private-fields-modifier-protected/input.ts new file mode 100644 index 000000000000..0f35b844a7be --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/class/private-fields-modifier-protected/input.ts @@ -0,0 +1,3 @@ +class A { + protected #a; +} diff --git a/packages/babel-parser/test/fixtures/typescript/class/private-fields-modifier-protected/output.json b/packages/babel-parser/test/fixtures/typescript/class/private-fields-modifier-protected/output.json new file mode 100644 index 000000000000..60afa0c3bc76 --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/class/private-fields-modifier-protected/output.json @@ -0,0 +1,138 @@ +{ + "type": "File", + "start": 0, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "errors": [ + "SyntaxError: Private elements cannot have an accessibility modifier ('protected') (2:2)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ClassDeclaration", + "start": 0, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 6, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + }, + "identifierName": "A" + }, + "name": "A" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "start": 8, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "body": [ + { + "type": "ClassPrivateProperty", + "start": 12, + "end": 25, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 15 + } + }, + "accessibility": "protected", + "static": false, + "key": { + "type": "PrivateName", + "start": 22, + "end": 24, + "loc": { + "start": { + "line": 2, + "column": 12 + }, + "end": { + "line": 2, + "column": 14 + } + }, + "id": { + "type": "Identifier", + "start": 23, + "end": 24, + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 14 + }, + "identifierName": "a" + }, + "name": "a" + } + }, + "value": null + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/typescript/class/private-fields-modifier-public/input.ts b/packages/babel-parser/test/fixtures/typescript/class/private-fields-modifier-public/input.ts new file mode 100644 index 000000000000..59a236000e60 --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/class/private-fields-modifier-public/input.ts @@ -0,0 +1,3 @@ +class A { + public #a; +} diff --git a/packages/babel-parser/test/fixtures/typescript/class/private-fields-modifier-public/output.json b/packages/babel-parser/test/fixtures/typescript/class/private-fields-modifier-public/output.json new file mode 100644 index 000000000000..3f526e42418c --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/class/private-fields-modifier-public/output.json @@ -0,0 +1,138 @@ +{ + "type": "File", + "start": 0, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "errors": [ + "SyntaxError: Private elements cannot have an accessibility modifier ('public') (2:2)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ClassDeclaration", + "start": 0, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 6, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + }, + "identifierName": "A" + }, + "name": "A" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "start": 8, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "body": [ + { + "type": "ClassPrivateProperty", + "start": 12, + "end": 22, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 12 + } + }, + "accessibility": "public", + "static": false, + "key": { + "type": "PrivateName", + "start": 19, + "end": 21, + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 11 + } + }, + "id": { + "type": "Identifier", + "start": 20, + "end": 21, + "loc": { + "start": { + "line": 2, + "column": 10 + }, + "end": { + "line": 2, + "column": 11 + }, + "identifierName": "a" + }, + "name": "a" + } + }, + "value": null + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/typescript/class/private-fields-modifier-readonly/input.ts b/packages/babel-parser/test/fixtures/typescript/class/private-fields-modifier-readonly/input.ts new file mode 100644 index 000000000000..355def79b8b7 --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/class/private-fields-modifier-readonly/input.ts @@ -0,0 +1,4 @@ +class A { + readonly #a; + readonly #b: string; +} diff --git a/packages/babel-parser/test/fixtures/typescript/class/private-fields-modifier-readonly/output.json b/packages/babel-parser/test/fixtures/typescript/class/private-fields-modifier-readonly/output.json new file mode 100644 index 000000000000..456ca59ae4ae --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/class/private-fields-modifier-readonly/output.json @@ -0,0 +1,215 @@ +{ + "type": "File", + "start": 0, + "end": 49, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 49, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ClassDeclaration", + "start": 0, + "end": 49, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 6, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + }, + "identifierName": "A" + }, + "name": "A" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "start": 8, + "end": 49, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "body": [ + { + "type": "ClassPrivateProperty", + "start": 12, + "end": 24, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 14 + } + }, + "readonly": true, + "static": false, + "key": { + "type": "PrivateName", + "start": 21, + "end": 23, + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 13 + } + }, + "id": { + "type": "Identifier", + "start": 22, + "end": 23, + "loc": { + "start": { + "line": 2, + "column": 12 + }, + "end": { + "line": 2, + "column": 13 + }, + "identifierName": "a" + }, + "name": "a" + } + }, + "value": null + }, + { + "type": "ClassPrivateProperty", + "start": 27, + "end": 47, + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 3, + "column": 22 + } + }, + "readonly": true, + "static": false, + "key": { + "type": "PrivateName", + "start": 36, + "end": 38, + "loc": { + "start": { + "line": 3, + "column": 11 + }, + "end": { + "line": 3, + "column": 13 + } + }, + "id": { + "type": "Identifier", + "start": 37, + "end": 38, + "loc": { + "start": { + "line": 3, + "column": 12 + }, + "end": { + "line": 3, + "column": 13 + }, + "identifierName": "b" + }, + "name": "b" + } + }, + "typeAnnotation": { + "type": "TSTypeAnnotation", + "start": 38, + "end": 46, + "loc": { + "start": { + "line": 3, + "column": 13 + }, + "end": { + "line": 3, + "column": 21 + } + }, + "typeAnnotation": { + "type": "TSStringKeyword", + "start": 40, + "end": 46, + "loc": { + "start": { + "line": 3, + "column": 15 + }, + "end": { + "line": 3, + "column": 21 + } + } + } + }, + "value": null + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/typescript/class/private-fields-static/input.ts b/packages/babel-parser/test/fixtures/typescript/class/private-fields-static/input.ts new file mode 100644 index 000000000000..4725b09bea74 --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/class/private-fields-static/input.ts @@ -0,0 +1,4 @@ +class A { + static #x; + static #y: string; +} diff --git a/packages/babel-parser/test/fixtures/typescript/class/private-fields-static/output.json b/packages/babel-parser/test/fixtures/typescript/class/private-fields-static/output.json new file mode 100644 index 000000000000..dcb6ab198f52 --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/class/private-fields-static/output.json @@ -0,0 +1,213 @@ +{ + "type": "File", + "start": 0, + "end": 45, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 45, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ClassDeclaration", + "start": 0, + "end": 45, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 6, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + }, + "identifierName": "A" + }, + "name": "A" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "start": 8, + "end": 45, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "body": [ + { + "type": "ClassPrivateProperty", + "start": 12, + "end": 22, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 12 + } + }, + "static": true, + "key": { + "type": "PrivateName", + "start": 19, + "end": 21, + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 11 + } + }, + "id": { + "type": "Identifier", + "start": 20, + "end": 21, + "loc": { + "start": { + "line": 2, + "column": 10 + }, + "end": { + "line": 2, + "column": 11 + }, + "identifierName": "x" + }, + "name": "x" + } + }, + "value": null + }, + { + "type": "ClassPrivateProperty", + "start": 25, + "end": 43, + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 3, + "column": 20 + } + }, + "static": true, + "key": { + "type": "PrivateName", + "start": 32, + "end": 34, + "loc": { + "start": { + "line": 3, + "column": 9 + }, + "end": { + "line": 3, + "column": 11 + } + }, + "id": { + "type": "Identifier", + "start": 33, + "end": 34, + "loc": { + "start": { + "line": 3, + "column": 10 + }, + "end": { + "line": 3, + "column": 11 + }, + "identifierName": "y" + }, + "name": "y" + } + }, + "typeAnnotation": { + "type": "TSTypeAnnotation", + "start": 34, + "end": 42, + "loc": { + "start": { + "line": 3, + "column": 11 + }, + "end": { + "line": 3, + "column": 19 + } + }, + "typeAnnotation": { + "type": "TSStringKeyword", + "start": 36, + "end": 42, + "loc": { + "start": { + "line": 3, + "column": 13 + }, + "end": { + "line": 3, + "column": 19 + } + } + } + }, + "value": null + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/typescript/class/private-fields/input.ts b/packages/babel-parser/test/fixtures/typescript/class/private-fields/input.ts new file mode 100644 index 000000000000..30c6024e99ce --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/class/private-fields/input.ts @@ -0,0 +1,7 @@ +class A { + #a: string; + #b?; + #c?: number; + #d!; + #e!: boolean; +} diff --git a/packages/babel-parser/test/fixtures/typescript/class/private-fields/output.json b/packages/babel-parser/test/fixtures/typescript/class/private-fields/output.json new file mode 100644 index 000000000000..67a50c2c16ff --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/class/private-fields/output.json @@ -0,0 +1,424 @@ +{ + "type": "File", + "start": 0, + "end": 70, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 7, + "column": 1 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 70, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 7, + "column": 1 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ClassDeclaration", + "start": 0, + "end": 70, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 7, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 6, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + }, + "identifierName": "A" + }, + "name": "A" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "start": 8, + "end": 70, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 7, + "column": 1 + } + }, + "body": [ + { + "type": "ClassPrivateProperty", + "start": 12, + "end": 23, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 13 + } + }, + "static": false, + "key": { + "type": "PrivateName", + "start": 12, + "end": 14, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 4 + } + }, + "id": { + "type": "Identifier", + "start": 13, + "end": 14, + "loc": { + "start": { + "line": 2, + "column": 3 + }, + "end": { + "line": 2, + "column": 4 + }, + "identifierName": "a" + }, + "name": "a" + } + }, + "typeAnnotation": { + "type": "TSTypeAnnotation", + "start": 14, + "end": 22, + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 12 + } + }, + "typeAnnotation": { + "type": "TSStringKeyword", + "start": 16, + "end": 22, + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 12 + } + } + } + }, + "value": null + }, + { + "type": "ClassPrivateProperty", + "start": 26, + "end": 30, + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 3, + "column": 6 + } + }, + "static": false, + "key": { + "type": "PrivateName", + "start": 26, + "end": 28, + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 3, + "column": 4 + } + }, + "id": { + "type": "Identifier", + "start": 27, + "end": 28, + "loc": { + "start": { + "line": 3, + "column": 3 + }, + "end": { + "line": 3, + "column": 4 + }, + "identifierName": "b" + }, + "name": "b" + } + }, + "optional": true, + "value": null + }, + { + "type": "ClassPrivateProperty", + "start": 33, + "end": 45, + "loc": { + "start": { + "line": 4, + "column": 2 + }, + "end": { + "line": 4, + "column": 14 + } + }, + "static": false, + "key": { + "type": "PrivateName", + "start": 33, + "end": 35, + "loc": { + "start": { + "line": 4, + "column": 2 + }, + "end": { + "line": 4, + "column": 4 + } + }, + "id": { + "type": "Identifier", + "start": 34, + "end": 35, + "loc": { + "start": { + "line": 4, + "column": 3 + }, + "end": { + "line": 4, + "column": 4 + }, + "identifierName": "c" + }, + "name": "c" + } + }, + "optional": true, + "typeAnnotation": { + "type": "TSTypeAnnotation", + "start": 36, + "end": 44, + "loc": { + "start": { + "line": 4, + "column": 5 + }, + "end": { + "line": 4, + "column": 13 + } + }, + "typeAnnotation": { + "type": "TSNumberKeyword", + "start": 38, + "end": 44, + "loc": { + "start": { + "line": 4, + "column": 7 + }, + "end": { + "line": 4, + "column": 13 + } + } + } + }, + "value": null + }, + { + "type": "ClassPrivateProperty", + "start": 48, + "end": 52, + "loc": { + "start": { + "line": 5, + "column": 2 + }, + "end": { + "line": 5, + "column": 6 + } + }, + "static": false, + "key": { + "type": "PrivateName", + "start": 48, + "end": 50, + "loc": { + "start": { + "line": 5, + "column": 2 + }, + "end": { + "line": 5, + "column": 4 + } + }, + "id": { + "type": "Identifier", + "start": 49, + "end": 50, + "loc": { + "start": { + "line": 5, + "column": 3 + }, + "end": { + "line": 5, + "column": 4 + }, + "identifierName": "d" + }, + "name": "d" + } + }, + "definite": true, + "value": null + }, + { + "type": "ClassPrivateProperty", + "start": 55, + "end": 68, + "loc": { + "start": { + "line": 6, + "column": 2 + }, + "end": { + "line": 6, + "column": 15 + } + }, + "static": false, + "key": { + "type": "PrivateName", + "start": 55, + "end": 57, + "loc": { + "start": { + "line": 6, + "column": 2 + }, + "end": { + "line": 6, + "column": 4 + } + }, + "id": { + "type": "Identifier", + "start": 56, + "end": 57, + "loc": { + "start": { + "line": 6, + "column": 3 + }, + "end": { + "line": 6, + "column": 4 + }, + "identifierName": "e" + }, + "name": "e" + } + }, + "definite": true, + "typeAnnotation": { + "type": "TSTypeAnnotation", + "start": 58, + "end": 67, + "loc": { + "start": { + "line": 6, + "column": 5 + }, + "end": { + "line": 6, + "column": 14 + } + }, + "typeAnnotation": { + "type": "TSBooleanKeyword", + "start": 60, + "end": 67, + "loc": { + "start": { + "line": 6, + "column": 7 + }, + "end": { + "line": 6, + "column": 14 + } + } + } + }, + "value": null + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/typescript/function/pattern-parameters/options.json b/packages/babel-parser/test/fixtures/typescript/function/pattern-parameters/options.json deleted file mode 100644 index fb2831d6188b..000000000000 --- a/packages/babel-parser/test/fixtures/typescript/function/pattern-parameters/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "A binding pattern parameter cannot be optional in an implementation signature. (1:11)" -} diff --git a/packages/babel-parser/test/fixtures/typescript/function/pattern-parameters/output.json b/packages/babel-parser/test/fixtures/typescript/function/pattern-parameters/output.json new file mode 100644 index 000000000000..3ef0fdc07d93 --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/function/pattern-parameters/output.json @@ -0,0 +1,124 @@ +{ + "type": "File", + "start": 0, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "errors": [ + "SyntaxError: A binding pattern parameter cannot be optional in an implementation signature. (1:11)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 10 + }, + "identifierName": "f" + }, + "name": "f" + }, + "generator": false, + "async": false, + "params": [ + { + "type": "ArrayPattern", + "start": 11, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "elements": [], + "optional": true + }, + { + "type": "ObjectPattern", + "start": 16, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "properties": [] + } + ], + "body": { + "type": "BlockStatement", + "start": 20, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 20 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "body": [], + "directives": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/typescript/function/predicate-types/output.json b/packages/babel-parser/test/fixtures/typescript/function/predicate-types/output.json index 85ab4987f1c2..90bae5b4ceda 100644 --- a/packages/babel-parser/test/fixtures/typescript/function/predicate-types/output.json +++ b/packages/babel-parser/test/fixtures/typescript/function/predicate-types/output.json @@ -127,12 +127,12 @@ }, "typeAnnotation": { "type": "TSTypePredicate", - "start": 20, + "start": 18, "end": 32, "loc": { "start": { "line": 1, - "column": 20 + "column": 18 }, "end": { "line": 1, @@ -302,12 +302,12 @@ }, "typeAnnotation": { "type": "TSTypePredicate", - "start": 55, + "start": 53, "end": 67, "loc": { "start": { "line": 2, - "column": 19 + "column": 17 }, "end": { "line": 2, diff --git a/packages/babel-parser/test/fixtures/typescript/optional-chaining/type-arguments/input.ts b/packages/babel-parser/test/fixtures/typescript/optional-chaining/type-arguments/input.ts new file mode 100644 index 000000000000..731a05f63b36 --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/optional-chaining/type-arguments/input.ts @@ -0,0 +1 @@ +example.inner?.greet() diff --git a/packages/babel-parser/test/fixtures/typescript/optional-chaining/type-arguments/options.json b/packages/babel-parser/test/fixtures/typescript/optional-chaining/type-arguments/options.json new file mode 100644 index 000000000000..ccc6341666b4 --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/optional-chaining/type-arguments/options.json @@ -0,0 +1,4 @@ +{ + "sourceType": "module", + "plugins": ["typescript", "optionalChaining"] +} diff --git a/packages/babel-parser/test/fixtures/typescript/optional-chaining/type-arguments/output.json b/packages/babel-parser/test/fixtures/typescript/optional-chaining/type-arguments/output.json new file mode 100644 index 000000000000..42f6c8b98b0e --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/optional-chaining/type-arguments/output.json @@ -0,0 +1,182 @@ +{ + "type": "File", + "start": 0, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "expression": { + "type": "OptionalCallExpression", + "start": 0, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "callee": { + "type": "OptionalMemberExpression", + "start": 0, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "object": { + "type": "MemberExpression", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "object": { + "type": "Identifier", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + }, + "identifierName": "example" + }, + "name": "example" + }, + "property": { + "type": "Identifier", + "start": 8, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 13 + }, + "identifierName": "inner" + }, + "name": "inner" + }, + "computed": false + }, + "property": { + "type": "Identifier", + "start": 15, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 20 + }, + "identifierName": "greet" + }, + "name": "greet" + }, + "computed": false, + "optional": true + }, + "arguments": [], + "typeParameters": { + "type": "TSTypeParameterInstantiation", + "start": 20, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 20 + }, + "end": { + "line": 1, + "column": 28 + } + }, + "params": [ + { + "type": "TSStringKeyword", + "start": 21, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 21 + }, + "end": { + "line": 1, + "column": 27 + } + } + } + ] + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-class-class/options.json b/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-class-class/options.json deleted file mode 100644 index 336686170eb0..000000000000 --- a/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-class-class/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Identifier 'A' has already been declared (2:6)" -} diff --git a/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-class-class/output.json b/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-class-class/output.json new file mode 100644 index 000000000000..5642df62a53c --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-class-class/output.json @@ -0,0 +1,136 @@ +{ + "type": "File", + "start": 0, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 10 + } + }, + "errors": [ + "SyntaxError: Identifier 'A' has already been declared (2:6)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 10 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ClassDeclaration", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "id": { + "type": "Identifier", + "start": 6, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + }, + "identifierName": "A" + }, + "name": "A" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "start": 8, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "body": [] + } + }, + { + "type": "ClassDeclaration", + "start": 11, + "end": 21, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 10 + } + }, + "id": { + "type": "Identifier", + "start": 17, + "end": 18, + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 7 + }, + "identifierName": "A" + }, + "name": "A" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "start": 19, + "end": 21, + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 10 + } + }, + "body": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-class-enum/options.json b/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-class-enum/options.json deleted file mode 100644 index 1eed93f49a0e..000000000000 --- a/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-class-enum/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Identifier 'A' has already been declared (2:5)" -} diff --git a/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-class-enum/output.json b/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-class-enum/output.json new file mode 100644 index 000000000000..6d6bbe962695 --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-class-enum/output.json @@ -0,0 +1,120 @@ +{ + "type": "File", + "start": 0, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 9 + } + }, + "errors": [ + "SyntaxError: Identifier 'A' has already been declared (2:5)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 9 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ClassDeclaration", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "id": { + "type": "Identifier", + "start": 6, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + }, + "identifierName": "A" + }, + "name": "A" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "start": 8, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "body": [] + } + }, + { + "type": "TSEnumDeclaration", + "start": 11, + "end": 20, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 9 + } + }, + "id": { + "type": "Identifier", + "start": 16, + "end": 17, + "loc": { + "start": { + "line": 2, + "column": 5 + }, + "end": { + "line": 2, + "column": 6 + }, + "identifierName": "A" + }, + "name": "A" + }, + "members": [] + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-class-type/options.json b/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-class-type/options.json deleted file mode 100644 index 1eed93f49a0e..000000000000 --- a/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-class-type/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Identifier 'A' has already been declared (2:5)" -} diff --git a/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-class-type/output.json b/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-class-type/output.json new file mode 100644 index 000000000000..c6886d19470d --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-class-type/output.json @@ -0,0 +1,134 @@ +{ + "type": "File", + "start": 0, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 16 + } + }, + "errors": [ + "SyntaxError: Identifier 'A' has already been declared (2:5)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 16 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ClassDeclaration", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "id": { + "type": "Identifier", + "start": 6, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + }, + "identifierName": "A" + }, + "name": "A" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "start": 8, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "body": [] + } + }, + { + "type": "TSTypeAliasDeclaration", + "start": 11, + "end": 27, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 16 + } + }, + "id": { + "type": "Identifier", + "start": 16, + "end": 17, + "loc": { + "start": { + "line": 2, + "column": 5 + }, + "end": { + "line": 2, + "column": 6 + }, + "identifierName": "A" + }, + "name": "A" + }, + "typeAnnotation": { + "type": "TSNumberKeyword", + "start": 20, + "end": 26, + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 15 + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-constenum-enum/options.json b/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-constenum-enum/options.json deleted file mode 100644 index ee82975e59a3..000000000000 --- a/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-constenum-enum/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Identifier 'X' has already been declared (2:5)" -} diff --git a/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-constenum-enum/output.json b/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-constenum-enum/output.json new file mode 100644 index 000000000000..b6b67ebef96c --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-constenum-enum/output.json @@ -0,0 +1,105 @@ +{ + "type": "File", + "start": 0, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 9 + } + }, + "errors": [ + "SyntaxError: Identifier 'X' has already been declared (2:5)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 9 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "TSEnumDeclaration", + "start": 0, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "const": true, + "id": { + "type": "Identifier", + "start": 11, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 12 + }, + "identifierName": "X" + }, + "name": "X" + }, + "members": [] + }, + { + "type": "TSEnumDeclaration", + "start": 16, + "end": 25, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 9 + } + }, + "id": { + "type": "Identifier", + "start": 21, + "end": 22, + "loc": { + "start": { + "line": 2, + "column": 5 + }, + "end": { + "line": 2, + "column": 6 + }, + "identifierName": "X" + }, + "name": "X" + }, + "members": [] + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-enum-class/options.json b/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-enum-class/options.json deleted file mode 100644 index 69462b29a995..000000000000 --- a/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-enum-class/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Identifier 'X' has already been declared (2:6)" -} diff --git a/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-enum-class/output.json b/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-enum-class/output.json new file mode 100644 index 000000000000..8518fac0e7e9 --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-enum-class/output.json @@ -0,0 +1,120 @@ +{ + "type": "File", + "start": 0, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 10 + } + }, + "errors": [ + "SyntaxError: Identifier 'X' has already been declared (2:6)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 10 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "TSEnumDeclaration", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "id": { + "type": "Identifier", + "start": 5, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 6 + }, + "identifierName": "X" + }, + "name": "X" + }, + "members": [] + }, + { + "type": "ClassDeclaration", + "start": 10, + "end": 20, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 10 + } + }, + "id": { + "type": "Identifier", + "start": 16, + "end": 17, + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 7 + }, + "identifierName": "X" + }, + "name": "X" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "start": 18, + "end": 20, + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 10 + } + }, + "body": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-enum-constenum/options.json b/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-enum-constenum/options.json deleted file mode 100644 index c77fcb7927ac..000000000000 --- a/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-enum-constenum/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Identifier 'X' has already been declared (2:11)" -} diff --git a/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-enum-constenum/output.json b/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-enum-constenum/output.json new file mode 100644 index 000000000000..8a9778e36851 --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-enum-constenum/output.json @@ -0,0 +1,105 @@ +{ + "type": "File", + "start": 0, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 15 + } + }, + "errors": [ + "SyntaxError: Identifier 'X' has already been declared (2:11)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 15 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "TSEnumDeclaration", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "id": { + "type": "Identifier", + "start": 5, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 6 + }, + "identifierName": "X" + }, + "name": "X" + }, + "members": [] + }, + { + "type": "TSEnumDeclaration", + "start": 10, + "end": 25, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 15 + } + }, + "const": true, + "id": { + "type": "Identifier", + "start": 21, + "end": 22, + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 12 + }, + "identifierName": "X" + }, + "name": "X" + }, + "members": [] + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-enum-function/options.json b/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-enum-function/options.json deleted file mode 100644 index ee47ddce75a8..000000000000 --- a/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-enum-function/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Identifier 'Foo' has already been declared (2:9)" -} diff --git a/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-enum-function/output.json b/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-enum-function/output.json new file mode 100644 index 000000000000..ab31065f580b --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-enum-function/output.json @@ -0,0 +1,123 @@ +{ + "type": "File", + "start": 0, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 17 + } + }, + "errors": [ + "SyntaxError: Identifier 'Foo' has already been declared (2:9)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 17 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "TSEnumDeclaration", + "start": 0, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "id": { + "type": "Identifier", + "start": 5, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 8 + }, + "identifierName": "Foo" + }, + "name": "Foo" + }, + "members": [] + }, + { + "type": "FunctionDeclaration", + "start": 12, + "end": 29, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 17 + } + }, + "id": { + "type": "Identifier", + "start": 21, + "end": 24, + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 12 + }, + "identifierName": "Foo" + }, + "name": "Foo" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 27, + "end": 29, + "loc": { + "start": { + "line": 2, + "column": 15 + }, + "end": { + "line": 2, + "column": 17 + } + }, + "body": [], + "directives": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-enum-interface/options.json b/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-enum-interface/options.json deleted file mode 100644 index a5f623f4e212..000000000000 --- a/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-enum-interface/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Identifier 'X' has already been declared (2:10)" -} diff --git a/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-enum-interface/output.json b/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-enum-interface/output.json new file mode 100644 index 000000000000..80905a927dc9 --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-enum-interface/output.json @@ -0,0 +1,119 @@ +{ + "type": "File", + "start": 0, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 14 + } + }, + "errors": [ + "SyntaxError: Identifier 'X' has already been declared (2:10)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 14 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "TSEnumDeclaration", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "id": { + "type": "Identifier", + "start": 5, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 6 + }, + "identifierName": "X" + }, + "name": "X" + }, + "members": [] + }, + { + "type": "TSInterfaceDeclaration", + "start": 10, + "end": 24, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 14 + } + }, + "id": { + "type": "Identifier", + "start": 20, + "end": 21, + "loc": { + "start": { + "line": 2, + "column": 10 + }, + "end": { + "line": 2, + "column": 11 + }, + "identifierName": "X" + }, + "name": "X" + }, + "body": { + "type": "TSInterfaceBody", + "start": 22, + "end": 24, + "loc": { + "start": { + "line": 2, + "column": 12 + }, + "end": { + "line": 2, + "column": 14 + } + }, + "body": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-enum-let/options.json b/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-enum-let/options.json deleted file mode 100644 index 4172f917bdb1..000000000000 --- a/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-enum-let/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Identifier 'Foo' has already been declared (2:4)" -} diff --git a/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-enum-let/output.json b/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-enum-let/output.json new file mode 100644 index 000000000000..4f8b4783578a --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-enum-let/output.json @@ -0,0 +1,122 @@ +{ + "type": "File", + "start": 0, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 8 + } + }, + "errors": [ + "SyntaxError: Identifier 'Foo' has already been declared (2:4)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 8 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "TSEnumDeclaration", + "start": 0, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "id": { + "type": "Identifier", + "start": 5, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 8 + }, + "identifierName": "Foo" + }, + "name": "Foo" + }, + "members": [] + }, + { + "type": "VariableDeclaration", + "start": 12, + "end": 20, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 8 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 16, + "end": 19, + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 7 + } + }, + "id": { + "type": "Identifier", + "start": 16, + "end": 19, + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 7 + }, + "identifierName": "Foo" + }, + "name": "Foo" + }, + "init": null + } + ], + "kind": "let" + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-enum-type/options.json b/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-enum-type/options.json deleted file mode 100644 index ee82975e59a3..000000000000 --- a/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-enum-type/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Identifier 'X' has already been declared (2:5)" -} diff --git a/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-enum-type/output.json b/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-enum-type/output.json new file mode 100644 index 000000000000..e347d9e0a548 --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-enum-type/output.json @@ -0,0 +1,118 @@ +{ + "type": "File", + "start": 0, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 16 + } + }, + "errors": [ + "SyntaxError: Identifier 'X' has already been declared (2:5)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 16 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "TSEnumDeclaration", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "id": { + "type": "Identifier", + "start": 5, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 6 + }, + "identifierName": "X" + }, + "name": "X" + }, + "members": [] + }, + { + "type": "TSTypeAliasDeclaration", + "start": 10, + "end": 26, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 16 + } + }, + "id": { + "type": "Identifier", + "start": 15, + "end": 16, + "loc": { + "start": { + "line": 2, + "column": 5 + }, + "end": { + "line": 2, + "column": 6 + }, + "identifierName": "X" + }, + "name": "X" + }, + "typeAnnotation": { + "type": "TSNumberKeyword", + "start": 19, + "end": 25, + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 15 + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-enum-var/options.json b/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-enum-var/options.json deleted file mode 100644 index 4172f917bdb1..000000000000 --- a/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-enum-var/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Identifier 'Foo' has already been declared (2:4)" -} diff --git a/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-enum-var/output.json b/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-enum-var/output.json new file mode 100644 index 000000000000..4f8b4783578a --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-enum-var/output.json @@ -0,0 +1,122 @@ +{ + "type": "File", + "start": 0, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 8 + } + }, + "errors": [ + "SyntaxError: Identifier 'Foo' has already been declared (2:4)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 8 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "TSEnumDeclaration", + "start": 0, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "id": { + "type": "Identifier", + "start": 5, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 8 + }, + "identifierName": "Foo" + }, + "name": "Foo" + }, + "members": [] + }, + { + "type": "VariableDeclaration", + "start": 12, + "end": 20, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 8 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 16, + "end": 19, + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 7 + } + }, + "id": { + "type": "Identifier", + "start": 16, + "end": 19, + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 7 + }, + "identifierName": "Foo" + }, + "name": "Foo" + }, + "init": null + } + ], + "kind": "let" + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-function-enum/options.json b/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-function-enum/options.json deleted file mode 100644 index 92349410e8cf..000000000000 --- a/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-function-enum/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Identifier 'Foo' has already been declared (2:5)" -} diff --git a/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-function-enum/output.json b/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-function-enum/output.json new file mode 100644 index 000000000000..c8a1a8f8dc65 --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-function-enum/output.json @@ -0,0 +1,123 @@ +{ + "type": "File", + "start": 0, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 11 + } + }, + "errors": [ + "SyntaxError: Identifier 'Foo' has already been declared (2:5)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 11 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 12 + }, + "identifierName": "Foo" + }, + "name": "Foo" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 15, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "body": [], + "directives": [] + } + }, + { + "type": "TSEnumDeclaration", + "start": 18, + "end": 29, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 11 + } + }, + "id": { + "type": "Identifier", + "start": 23, + "end": 26, + "loc": { + "start": { + "line": 2, + "column": 5 + }, + "end": { + "line": 2, + "column": 8 + }, + "identifierName": "Foo" + }, + "name": "Foo" + }, + "members": [] + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-interface-enum/options.json b/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-interface-enum/options.json deleted file mode 100644 index ee82975e59a3..000000000000 --- a/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-interface-enum/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Identifier 'X' has already been declared (2:5)" -} diff --git a/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-interface-enum/output.json b/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-interface-enum/output.json new file mode 100644 index 000000000000..63b26bca4458 --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-interface-enum/output.json @@ -0,0 +1,119 @@ +{ + "type": "File", + "start": 0, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 9 + } + }, + "errors": [ + "SyntaxError: Identifier 'X' has already been declared (2:5)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 9 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "TSInterfaceDeclaration", + "start": 0, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "id": { + "type": "Identifier", + "start": 10, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 11 + }, + "identifierName": "X" + }, + "name": "X" + }, + "body": { + "type": "TSInterfaceBody", + "start": 12, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "body": [] + } + }, + { + "type": "TSEnumDeclaration", + "start": 15, + "end": 24, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 9 + } + }, + "id": { + "type": "Identifier", + "start": 20, + "end": 21, + "loc": { + "start": { + "line": 2, + "column": 5 + }, + "end": { + "line": 2, + "column": 6 + }, + "identifierName": "X" + }, + "name": "X" + }, + "members": [] + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-let-enum/options.json b/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-let-enum/options.json deleted file mode 100644 index 92349410e8cf..000000000000 --- a/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-let-enum/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Identifier 'Foo' has already been declared (2:5)" -} diff --git a/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-let-enum/output.json b/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-let-enum/output.json new file mode 100644 index 000000000000..1c1cfb5c1696 --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-let-enum/output.json @@ -0,0 +1,122 @@ +{ + "type": "File", + "start": 0, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 11 + } + }, + "errors": [ + "SyntaxError: Identifier 'Foo' has already been declared (2:5)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 11 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "VariableDeclaration", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 4, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "id": { + "type": "Identifier", + "start": 4, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 7 + }, + "identifierName": "Foo" + }, + "name": "Foo" + }, + "init": null + } + ], + "kind": "let" + }, + { + "type": "TSEnumDeclaration", + "start": 9, + "end": 20, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 11 + } + }, + "id": { + "type": "Identifier", + "start": 14, + "end": 17, + "loc": { + "start": { + "line": 2, + "column": 5 + }, + "end": { + "line": 2, + "column": 8 + }, + "identifierName": "Foo" + }, + "name": "Foo" + }, + "members": [] + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-type-class/options.json b/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-type-class/options.json deleted file mode 100644 index 336686170eb0..000000000000 --- a/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-type-class/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Identifier 'A' has already been declared (2:6)" -} diff --git a/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-type-class/output.json b/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-type-class/output.json new file mode 100644 index 000000000000..3e63a0f7f298 --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-type-class/output.json @@ -0,0 +1,134 @@ +{ + "type": "File", + "start": 0, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 10 + } + }, + "errors": [ + "SyntaxError: Identifier 'A' has already been declared (2:6)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 10 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "TSTypeAliasDeclaration", + "start": 0, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "id": { + "type": "Identifier", + "start": 5, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 6 + }, + "identifierName": "A" + }, + "name": "A" + }, + "typeAnnotation": { + "type": "TSNumberKeyword", + "start": 9, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 15 + } + } + } + }, + { + "type": "ClassDeclaration", + "start": 17, + "end": 27, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 10 + } + }, + "id": { + "type": "Identifier", + "start": 23, + "end": 24, + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 7 + }, + "identifierName": "A" + }, + "name": "A" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "start": 25, + "end": 27, + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 10 + } + }, + "body": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-type-enum/options.json b/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-type-enum/options.json deleted file mode 100644 index 1eed93f49a0e..000000000000 --- a/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-type-enum/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Identifier 'A' has already been declared (2:5)" -} diff --git a/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-type-enum/output.json b/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-type-enum/output.json new file mode 100644 index 000000000000..ba27b683a4b7 --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-type-enum/output.json @@ -0,0 +1,118 @@ +{ + "type": "File", + "start": 0, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 9 + } + }, + "errors": [ + "SyntaxError: Identifier 'A' has already been declared (2:5)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 9 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "TSTypeAliasDeclaration", + "start": 0, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "id": { + "type": "Identifier", + "start": 5, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 6 + }, + "identifierName": "A" + }, + "name": "A" + }, + "typeAnnotation": { + "type": "TSNumberKeyword", + "start": 9, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 15 + } + } + } + }, + { + "type": "TSEnumDeclaration", + "start": 17, + "end": 26, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 9 + } + }, + "id": { + "type": "Identifier", + "start": 22, + "end": 23, + "loc": { + "start": { + "line": 2, + "column": 5 + }, + "end": { + "line": 2, + "column": 6 + }, + "identifierName": "A" + }, + "name": "A" + }, + "members": [] + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-type-interface/options.json b/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-type-interface/options.json deleted file mode 100644 index 04242bd1565b..000000000000 --- a/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-type-interface/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Identifier 'A' has already been declared (2:10)" -} diff --git a/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-type-interface/output.json b/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-type-interface/output.json new file mode 100644 index 000000000000..4983be36642d --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-type-interface/output.json @@ -0,0 +1,133 @@ +{ + "type": "File", + "start": 0, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 14 + } + }, + "errors": [ + "SyntaxError: Identifier 'A' has already been declared (2:10)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 14 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "TSTypeAliasDeclaration", + "start": 0, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "id": { + "type": "Identifier", + "start": 5, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 6 + }, + "identifierName": "A" + }, + "name": "A" + }, + "typeAnnotation": { + "type": "TSNumberKeyword", + "start": 9, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 15 + } + } + } + }, + { + "type": "TSInterfaceDeclaration", + "start": 17, + "end": 31, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 14 + } + }, + "id": { + "type": "Identifier", + "start": 27, + "end": 28, + "loc": { + "start": { + "line": 2, + "column": 10 + }, + "end": { + "line": 2, + "column": 11 + }, + "identifierName": "A" + }, + "name": "A" + }, + "body": { + "type": "TSInterfaceBody", + "start": 29, + "end": 31, + "loc": { + "start": { + "line": 2, + "column": 12 + }, + "end": { + "line": 2, + "column": 14 + } + }, + "body": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-type-type/options.json b/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-type-type/options.json deleted file mode 100644 index 1eed93f49a0e..000000000000 --- a/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-type-type/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Identifier 'A' has already been declared (2:5)" -} diff --git a/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-type-type/output.json b/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-type-type/output.json new file mode 100644 index 000000000000..02fde75620f0 --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-type-type/output.json @@ -0,0 +1,132 @@ +{ + "type": "File", + "start": 0, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 16 + } + }, + "errors": [ + "SyntaxError: Identifier 'A' has already been declared (2:5)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 16 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "TSTypeAliasDeclaration", + "start": 0, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "id": { + "type": "Identifier", + "start": 5, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 6 + }, + "identifierName": "A" + }, + "name": "A" + }, + "typeAnnotation": { + "type": "TSNumberKeyword", + "start": 9, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 15 + } + } + } + }, + { + "type": "TSTypeAliasDeclaration", + "start": 17, + "end": 33, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 16 + } + }, + "id": { + "type": "Identifier", + "start": 22, + "end": 23, + "loc": { + "start": { + "line": 2, + "column": 5 + }, + "end": { + "line": 2, + "column": 6 + }, + "identifierName": "A" + }, + "name": "A" + }, + "typeAnnotation": { + "type": "TSStringKeyword", + "start": 26, + "end": 32, + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 15 + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-var-enum/options.json b/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-var-enum/options.json deleted file mode 100644 index 92349410e8cf..000000000000 --- a/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-var-enum/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Identifier 'Foo' has already been declared (2:5)" -} diff --git a/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-var-enum/output.json b/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-var-enum/output.json new file mode 100644 index 000000000000..1c1cfb5c1696 --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/scope/redeclaration-var-enum/output.json @@ -0,0 +1,122 @@ +{ + "type": "File", + "start": 0, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 11 + } + }, + "errors": [ + "SyntaxError: Identifier 'Foo' has already been declared (2:5)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 11 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "VariableDeclaration", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 4, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "id": { + "type": "Identifier", + "start": 4, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 7 + }, + "identifierName": "Foo" + }, + "name": "Foo" + }, + "init": null + } + ], + "kind": "let" + }, + { + "type": "TSEnumDeclaration", + "start": 9, + "end": 20, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 11 + } + }, + "id": { + "type": "Identifier", + "start": 14, + "end": 17, + "loc": { + "start": { + "line": 2, + "column": 5 + }, + "end": { + "line": 2, + "column": 8 + }, + "identifierName": "Foo" + }, + "name": "Foo" + }, + "members": [] + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/typescript/types/literal-string-2/options.json b/packages/babel-parser/test/fixtures/typescript/types/literal-string-2/options.json deleted file mode 100644 index 856a8477d1ca..000000000000 --- a/packages/babel-parser/test/fixtures/typescript/types/literal-string-2/options.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "sourceType": "module", - "plugins": ["typescript"], - "throws": "Template literal types cannot have any substitution (1:14)" -} diff --git a/packages/babel-parser/test/fixtures/typescript/types/literal-string-2/output.json b/packages/babel-parser/test/fixtures/typescript/types/literal-string-2/output.json new file mode 100644 index 000000000000..ee3c9e5da012 --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/types/literal-string-2/output.json @@ -0,0 +1,195 @@ +{ + "type": "File", + "start": 0, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "errors": [ + "SyntaxError: Template literal types cannot have any substitution (1:14)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "VariableDeclaration", + "start": 0, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 4, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "id": { + "type": "Identifier", + "start": 4, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 19 + }, + "identifierName": "x" + }, + "name": "x", + "typeAnnotation": { + "type": "TSTypeAnnotation", + "start": 5, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "typeAnnotation": { + "type": "TSLiteralType", + "start": 7, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "literal": { + "type": "TemplateLiteral", + "start": 7, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "expressions": [ + { + "type": "Identifier", + "start": 14, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 17 + }, + "identifierName": "bar" + }, + "name": "bar" + } + ], + "quasis": [ + { + "type": "TemplateElement", + "start": 8, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "value": { + "raw": "foo-", + "cooked": "foo-" + }, + "tail": false + }, + { + "type": "TemplateElement", + "start": 18, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "value": { + "raw": "", + "cooked": "" + }, + "tail": true + } + ] + } + } + } + }, + "init": null + } + ], + "kind": "let" + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/typescript/types/read-only-1/options.json b/packages/babel-parser/test/fixtures/typescript/types/read-only-1/options.json deleted file mode 100644 index 0a91d0015278..000000000000 --- a/packages/babel-parser/test/fixtures/typescript/types/read-only-1/options.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "sourceType": "module", - "plugins": ["typescript"], - "throws": "'readonly' type modifier is only permitted on array and tuple literal types. (1:11)" -} diff --git a/packages/babel-parser/test/fixtures/typescript/types/read-only-1/output.json b/packages/babel-parser/test/fixtures/typescript/types/read-only-1/output.json new file mode 100644 index 000000000000..ced722e79dd3 --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/types/read-only-1/output.json @@ -0,0 +1,137 @@ +{ + "type": "File", + "start": 0, + "end": 37, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 37 + } + }, + "errors": [ + "SyntaxError: 'readonly' type modifier is only permitted on array and tuple literal types. (1:11)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 37, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 37 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "TSTypeAliasDeclaration", + "start": 0, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 27 + } + }, + "id": { + "type": "Identifier", + "start": 5, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 8 + }, + "identifierName": "T30" + }, + "name": "T30" + }, + "typeAnnotation": { + "type": "TSTypeOperator", + "start": 11, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "operator": "readonly", + "typeAnnotation": { + "type": "TSStringKeyword", + "start": 20, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 20 + }, + "end": { + "line": 1, + "column": 26 + } + } + } + }, + "trailingComments": [ + { + "type": "CommentLine", + "value": " Error", + "start": 29, + "end": 37, + "loc": { + "start": { + "line": 1, + "column": 29 + }, + "end": { + "line": 1, + "column": 37 + } + } + } + ] + } + ], + "directives": [] + }, + "comments": [ + { + "type": "CommentLine", + "value": " Error", + "start": 29, + "end": 37, + "loc": { + "start": { + "line": 1, + "column": 29 + }, + "end": { + "line": 1, + "column": 37 + } + } + } + ] +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/typescript/types/read-only-2/options.json b/packages/babel-parser/test/fixtures/typescript/types/read-only-2/options.json deleted file mode 100644 index 0a91d0015278..000000000000 --- a/packages/babel-parser/test/fixtures/typescript/types/read-only-2/options.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "sourceType": "module", - "plugins": ["typescript"], - "throws": "'readonly' type modifier is only permitted on array and tuple literal types. (1:11)" -} diff --git a/packages/babel-parser/test/fixtures/typescript/types/read-only-2/output.json b/packages/babel-parser/test/fixtures/typescript/types/read-only-2/output.json new file mode 100644 index 000000000000..73c4d7d4cd3f --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/types/read-only-2/output.json @@ -0,0 +1,154 @@ +{ + "type": "File", + "start": 0, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "errors": [ + "SyntaxError: 'readonly' type modifier is only permitted on array and tuple literal types. (1:11)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "TSTypeAliasDeclaration", + "start": 0, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "id": { + "type": "Identifier", + "start": 5, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 8 + }, + "identifierName": "T31" + }, + "name": "T31" + }, + "typeAnnotation": { + "type": "TSTypeOperator", + "start": 11, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "operator": "readonly", + "typeAnnotation": { + "type": "TSTypeReference", + "start": 20, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 20 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "typeName": { + "type": "Identifier", + "start": 20, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 20 + }, + "end": { + "line": 1, + "column": 21 + }, + "identifierName": "T" + }, + "name": "T" + } + } + }, + "trailingComments": [ + { + "type": "CommentLine", + "value": " Error", + "start": 24, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 24 + }, + "end": { + "line": 1, + "column": 32 + } + } + } + ] + } + ], + "directives": [] + }, + "comments": [ + { + "type": "CommentLine", + "value": " Error", + "start": 24, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 24 + }, + "end": { + "line": 1, + "column": 32 + } + } + } + ] +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/typescript/types/read-only-3/options.json b/packages/babel-parser/test/fixtures/typescript/types/read-only-3/options.json deleted file mode 100644 index 0a91d0015278..000000000000 --- a/packages/babel-parser/test/fixtures/typescript/types/read-only-3/options.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "sourceType": "module", - "plugins": ["typescript"], - "throws": "'readonly' type modifier is only permitted on array and tuple literal types. (1:11)" -} diff --git a/packages/babel-parser/test/fixtures/typescript/types/read-only-3/output.json b/packages/babel-parser/test/fixtures/typescript/types/read-only-3/output.json new file mode 100644 index 000000000000..8a977f1e3987 --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/types/read-only-3/output.json @@ -0,0 +1,168 @@ +{ + "type": "File", + "start": 0, + "end": 48, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 48 + } + }, + "errors": [ + "SyntaxError: 'readonly' type modifier is only permitted on array and tuple literal types. (1:11)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 48, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 48 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "TSTypeAliasDeclaration", + "start": 0, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 38 + } + }, + "id": { + "type": "Identifier", + "start": 5, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 8 + }, + "identifierName": "T32" + }, + "name": "T32" + }, + "typeAnnotation": { + "type": "TSTypeOperator", + "start": 11, + "end": 37, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 37 + } + }, + "operator": "readonly", + "typeAnnotation": { + "type": "TSTypeOperator", + "start": 20, + "end": 37, + "loc": { + "start": { + "line": 1, + "column": 20 + }, + "end": { + "line": 1, + "column": 37 + } + }, + "operator": "readonly", + "typeAnnotation": { + "type": "TSArrayType", + "start": 29, + "end": 37, + "loc": { + "start": { + "line": 1, + "column": 29 + }, + "end": { + "line": 1, + "column": 37 + } + }, + "elementType": { + "type": "TSStringKeyword", + "start": 29, + "end": 35, + "loc": { + "start": { + "line": 1, + "column": 29 + }, + "end": { + "line": 1, + "column": 35 + } + } + } + } + } + }, + "trailingComments": [ + { + "type": "CommentLine", + "value": " Error", + "start": 40, + "end": 48, + "loc": { + "start": { + "line": 1, + "column": 40 + }, + "end": { + "line": 1, + "column": 48 + } + } + } + ] + } + ], + "directives": [] + }, + "comments": [ + { + "type": "CommentLine", + "value": " Error", + "start": 40, + "end": 48, + "loc": { + "start": { + "line": 1, + "column": 40 + }, + "end": { + "line": 1, + "column": 48 + } + } + } + ] +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/typescript/types/read-only-4/options.json b/packages/babel-parser/test/fixtures/typescript/types/read-only-4/options.json deleted file mode 100644 index 0a91d0015278..000000000000 --- a/packages/babel-parser/test/fixtures/typescript/types/read-only-4/options.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "sourceType": "module", - "plugins": ["typescript"], - "throws": "'readonly' type modifier is only permitted on array and tuple literal types. (1:11)" -} diff --git a/packages/babel-parser/test/fixtures/typescript/types/read-only-4/output.json b/packages/babel-parser/test/fixtures/typescript/types/read-only-4/output.json new file mode 100644 index 000000000000..0e0dd2eb9f49 --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/types/read-only-4/output.json @@ -0,0 +1,186 @@ +{ + "type": "File", + "start": 0, + "end": 44, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 44 + } + }, + "errors": [ + "SyntaxError: 'readonly' type modifier is only permitted on array and tuple literal types. (1:11)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 44, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 44 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "TSTypeAliasDeclaration", + "start": 0, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 34 + } + }, + "id": { + "type": "Identifier", + "start": 5, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 8 + }, + "identifierName": "T33" + }, + "name": "T33" + }, + "typeAnnotation": { + "type": "TSTypeOperator", + "start": 11, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 33 + } + }, + "operator": "readonly", + "typeAnnotation": { + "type": "TSTypeReference", + "start": 20, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 20 + }, + "end": { + "line": 1, + "column": 33 + } + }, + "typeName": { + "type": "Identifier", + "start": 20, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 20 + }, + "end": { + "line": 1, + "column": 25 + }, + "identifierName": "Array" + }, + "name": "Array" + }, + "typeParameters": { + "type": "TSTypeParameterInstantiation", + "start": 25, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 25 + }, + "end": { + "line": 1, + "column": 33 + } + }, + "params": [ + { + "type": "TSStringKeyword", + "start": 26, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 26 + }, + "end": { + "line": 1, + "column": 32 + } + } + } + ] + } + } + }, + "trailingComments": [ + { + "type": "CommentLine", + "value": " Error", + "start": 36, + "end": 44, + "loc": { + "start": { + "line": 1, + "column": 36 + }, + "end": { + "line": 1, + "column": 44 + } + } + } + ] + } + ], + "directives": [] + }, + "comments": [ + { + "type": "CommentLine", + "value": " Error", + "start": 36, + "end": 44, + "loc": { + "start": { + "line": 1, + "column": 36 + }, + "end": { + "line": 1, + "column": 44 + } + } + } + ] +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/typescript/types/tuple-optional-invalid/options.json b/packages/babel-parser/test/fixtures/typescript/types/tuple-optional-invalid/options.json deleted file mode 100644 index 15111b29065f..000000000000 --- a/packages/babel-parser/test/fixtures/typescript/types/tuple-optional-invalid/options.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "sourceType": "module", - "plugins": ["typescript"], - "throws": "A required element cannot follow an optional element. (1:17)" -} diff --git a/packages/babel-parser/test/fixtures/typescript/types/tuple-optional-invalid/output.json b/packages/babel-parser/test/fixtures/typescript/types/tuple-optional-invalid/output.json new file mode 100644 index 000000000000..b66ac1ec7326 --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/types/tuple-optional-invalid/output.json @@ -0,0 +1,166 @@ +{ + "type": "File", + "start": 0, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "errors": [ + "SyntaxError: A required element cannot follow an optional element. (1:17)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "VariableDeclaration", + "start": 0, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 4, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "id": { + "type": "Identifier", + "start": 4, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 24 + }, + "identifierName": "x" + }, + "name": "x", + "typeAnnotation": { + "type": "TSTypeAnnotation", + "start": 5, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "typeAnnotation": { + "type": "TSTupleType", + "start": 7, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "elementTypes": [ + { + "type": "TSOptionalType", + "start": 8, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "typeAnnotation": { + "type": "TSStringKeyword", + "start": 8, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 14 + } + } + } + }, + { + "type": "TSNumberKeyword", + "start": 17, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 23 + } + } + } + ] + } + } + }, + "init": null + } + ], + "kind": "let" + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/typescript/variable-declarator/definite-assignment-not-allowed/options.json b/packages/babel-parser/test/fixtures/typescript/variable-declarator/definite-assignment-not-allowed/options.json index 57893e4eee56..c4c1edaca3c6 100644 --- a/packages/babel-parser/test/fixtures/typescript/variable-declarator/definite-assignment-not-allowed/options.json +++ b/packages/babel-parser/test/fixtures/typescript/variable-declarator/definite-assignment-not-allowed/options.json @@ -1,3 +1,3 @@ { - "throws": "Complex binding patterns require an initialization value (1:6)" + "throws": "Unexpected token, expected \";\" (1:6)" } diff --git a/packages/babel-parser/test/helpers/runFixtureTests.js b/packages/babel-parser/test/helpers/runFixtureTests.js index 9e97ee46f727..f08ed2312101 100644 --- a/packages/babel-parser/test/helpers/runFixtureTests.js +++ b/packages/babel-parser/test/helpers/runFixtureTests.js @@ -107,11 +107,19 @@ export function runThrowTestsWithEstree(fixturesPath, parseFunction) { } function save(test, ast) { - // Ensure that RegExp are serialized as strings - const toJSON = RegExp.prototype.toJSON; - RegExp.prototype.toJSON = RegExp.prototype.toString; - require("fs").writeFileSync(test.expect.loc, JSON.stringify(ast, null, " ")); - RegExp.prototype.toJSON = toJSON; + // Ensure that RegExp and Errors are serialized as strings + forceToString(RegExp, () => + forceToString(Error, () => + fs.writeFileSync(test.expect.loc, JSON.stringify(ast, null, " ")), + ), + ); +} + +function forceToString(obj, cb) { + const { toJSON } = obj.prototype; + obj.prototype.toJSON = obj.prototype.toString; + cb(); + obj.prototype.toJSON = toJSON; } function runTest(test, parseFunction) { @@ -125,7 +133,7 @@ function runTest(test, parseFunction) { let ast; try { - ast = parseFunction(test.actual.code, opts); + ast = parseFunction(test.actual.code, { errorRecovery: true, ...opts }); } catch (err) { if (opts.throws) { if (err.message === opts.throws) { @@ -152,6 +160,7 @@ function runTest(test, parseFunction) { } if (ast.comments && !ast.comments.length) delete ast.comments; + if (ast.errors && !ast.errors.length) delete ast.errors; if (!test.expect.code && !opts.throws && !process.env.CI) { test.expect.loc += "on"; @@ -159,6 +168,20 @@ function runTest(test, parseFunction) { } if (opts.throws) { + if (process.env.OVERWRITE) { + const fn = path.dirname(test.expect.loc) + "/options.json"; + test.options = test.options || {}; + delete test.options.throws; + const contents = JSON.stringify(test.options, null, " "); + if (contents === "{}") { + fs.unlinkSync(fn); + } else { + fs.writeFileSync(fn, JSON.stringify(test.options, null, " ")); + } + test.expect.loc += "on"; + return save(test, ast); + } + throw new Error( "Expected error message: " + opts.throws + ". But parsing succeeded.", ); @@ -175,7 +198,7 @@ function runTest(test, parseFunction) { } function ppJSON(v) { - v = v instanceof RegExp ? v.toString() : v; + v = v instanceof RegExp || v instanceof Error ? v.toString() : v; return JSON.stringify(v, null, 2); } @@ -188,7 +211,12 @@ function addPath(str, pt) { } function misMatch(exp, act) { - if (exp instanceof RegExp || act instanceof RegExp) { + if ( + exp instanceof RegExp || + act instanceof RegExp || + exp instanceof Error || + act instanceof Error + ) { const left = ppJSON(exp); const right = ppJSON(act); if (left !== right) return left + " !== " + right; diff --git a/packages/babel-parser/typings/babel-parser.d.ts b/packages/babel-parser/typings/babel-parser.d.ts index 371b9a4633da..40161080996b 100644 --- a/packages/babel-parser/typings/babel-parser.d.ts +++ b/packages/babel-parser/typings/babel-parser.d.ts @@ -106,7 +106,7 @@ export type ParserPlugin = 'dynamicImport' | 'estree' | 'exportDefaultFrom' | - 'exportNamespaceFrom' | + 'exportNamespaceFrom' | // deprecated 'flow' | 'flowComments' | 'functionBind' | @@ -123,6 +123,7 @@ export type ParserPlugin = 'pipelineOperator' | 'placeholders' | 'throwExpressions' | + 'topLevelAwait' | 'typescript' | 'v8intrinsic' | ParserPluginWithOptions; diff --git a/packages/babel-plugin-proposal-async-generator-functions/package.json b/packages/babel-plugin-proposal-async-generator-functions/package.json index 81db9bcc3d53..276aa93ea371 100644 --- a/packages/babel-plugin-proposal-async-generator-functions/package.json +++ b/packages/babel-plugin-proposal-async-generator-functions/package.json @@ -1,6 +1,6 @@ { "name": "@babel/plugin-proposal-async-generator-functions", - "version": "7.2.0", + "version": "7.7.0", "description": "Turn async generator functions into ES2015 generators", "repository": "https://github.com/babel/babel/tree/master/packages/babel-plugin-proposal-async-generator-functions", "license": "MIT", @@ -13,14 +13,14 @@ ], "dependencies": { "@babel/helper-plugin-utils": "^7.0.0", - "@babel/helper-remap-async-to-generator": "^7.1.0", + "@babel/helper-remap-async-to-generator": "^7.7.0", "@babel/plugin-syntax-async-generators": "^7.2.0" }, "peerDependencies": { "@babel/core": "^7.0.0-0" }, "devDependencies": { - "@babel/core": "^7.2.0", + "@babel/core": "^7.7.0", "@babel/helper-plugin-test-runner": "^7.0.0" } } diff --git a/packages/babel-plugin-proposal-async-generator-functions/test/fixtures/yield-star/issue-9905/exec.js b/packages/babel-plugin-proposal-async-generator-functions/test/fixtures/yield-star/issue-9905/exec.js new file mode 100644 index 000000000000..a4bf16180e24 --- /dev/null +++ b/packages/babel-plugin-proposal-async-generator-functions/test/fixtures/yield-star/issue-9905/exec.js @@ -0,0 +1,20 @@ +const log = []; + +async function* func1() { + log.push(1); + yield "a"; + log.push(2); +} + +async function* func2() { + yield* func1(); + log.push(3); +} + +return (async () => { + const iterator = func2(); + await iterator.next(); + await iterator.return(); + + expect(log).toEqual([1]); +})(); \ No newline at end of file diff --git a/packages/babel-plugin-proposal-async-generator-functions/test/fixtures/yield-star/issue-9905/options.json b/packages/babel-plugin-proposal-async-generator-functions/test/fixtures/yield-star/issue-9905/options.json new file mode 100644 index 000000000000..7edb6d2fc815 --- /dev/null +++ b/packages/babel-plugin-proposal-async-generator-functions/test/fixtures/yield-star/issue-9905/options.json @@ -0,0 +1,3 @@ +{ + "minNodeVersion": "8.0.0" +} \ No newline at end of file diff --git a/packages/babel-plugin-proposal-async-generator-functions/test/fixtures/yield-star/options.json b/packages/babel-plugin-proposal-async-generator-functions/test/fixtures/yield-star/options.json new file mode 100644 index 000000000000..b0483f766a07 --- /dev/null +++ b/packages/babel-plugin-proposal-async-generator-functions/test/fixtures/yield-star/options.json @@ -0,0 +1,10 @@ +{ + "parserOpts": { + "allowReturnOutsideFunction": true + }, + "plugins": [ + "external-helpers", + "transform-async-to-generator", + "proposal-async-generator-functions" + ] +} \ No newline at end of file diff --git a/packages/babel-plugin-proposal-async-generator-functions/test/fixtures/yield-star/return-method-with-finally-multiple-parallel/exec.js b/packages/babel-plugin-proposal-async-generator-functions/test/fixtures/yield-star/return-method-with-finally-multiple-parallel/exec.js new file mode 100644 index 000000000000..1c4ef15d5d06 --- /dev/null +++ b/packages/babel-plugin-proposal-async-generator-functions/test/fixtures/yield-star/return-method-with-finally-multiple-parallel/exec.js @@ -0,0 +1,34 @@ +const log = []; + +async function* inner() { + try { + log.push(1); + yield "a"; + log.push(2); + yield "b"; + log.push(3); + } finally { + log.push(4); + yield "c"; + log.push(5); + } +} + +async function* outer() { + log.push(6); + yield* inner(); + log.push(7); +} + +return (async () => { + const iterator = outer(); + + let res = await iterator.next(); + expect(res).toEqual({ value: "a", done: false }); + expect(log).toEqual([6, 1]); + + const [res1, res2] = await Promise.all([ iterator.return("x"), iterator.return("y") ]); + expect(res1).toEqual({ value: "c", done: false }); + expect(res2).toEqual({ value: "y", done: true }); + expect(log).toEqual([6, 1, 4]); +})(); diff --git a/packages/babel-plugin-proposal-async-generator-functions/test/fixtures/yield-star/return-method-with-finally-multiple-parallel/options.json b/packages/babel-plugin-proposal-async-generator-functions/test/fixtures/yield-star/return-method-with-finally-multiple-parallel/options.json new file mode 100644 index 000000000000..7edb6d2fc815 --- /dev/null +++ b/packages/babel-plugin-proposal-async-generator-functions/test/fixtures/yield-star/return-method-with-finally-multiple-parallel/options.json @@ -0,0 +1,3 @@ +{ + "minNodeVersion": "8.0.0" +} \ No newline at end of file diff --git a/packages/babel-plugin-proposal-async-generator-functions/test/fixtures/yield-star/return-method-with-finally-multiple-serial/exec.js b/packages/babel-plugin-proposal-async-generator-functions/test/fixtures/yield-star/return-method-with-finally-multiple-serial/exec.js new file mode 100644 index 000000000000..84865ef6f3df --- /dev/null +++ b/packages/babel-plugin-proposal-async-generator-functions/test/fixtures/yield-star/return-method-with-finally-multiple-serial/exec.js @@ -0,0 +1,37 @@ +const log = []; + +async function* inner() { + try { + log.push(1); + yield "a"; + log.push(2); + yield "b"; + log.push(3); + } finally { + log.push(4); + yield "c"; + log.push(5); + } +} + +async function* outer() { + log.push(6); + yield* inner(); + log.push(7); +} + +return (async () => { + const iterator = outer(); + + let res = await iterator.next(); + expect(res).toEqual({ value: "a", done: false }); + expect(log).toEqual([6, 1]); + + res = await iterator.return("x"); + expect(res).toEqual({ value: "c", done: false }); + expect(log).toEqual([6, 1, 4]); + + res = await iterator.return("y"); + expect(res).toEqual({ value: "y", done: true }); + expect(log).toEqual([6, 1, 4]); +})(); diff --git a/packages/babel-plugin-proposal-async-generator-functions/test/fixtures/yield-star/return-method-with-finally-multiple-serial/options.json b/packages/babel-plugin-proposal-async-generator-functions/test/fixtures/yield-star/return-method-with-finally-multiple-serial/options.json new file mode 100644 index 000000000000..7edb6d2fc815 --- /dev/null +++ b/packages/babel-plugin-proposal-async-generator-functions/test/fixtures/yield-star/return-method-with-finally-multiple-serial/options.json @@ -0,0 +1,3 @@ +{ + "minNodeVersion": "8.0.0" +} \ No newline at end of file diff --git a/packages/babel-plugin-proposal-async-generator-functions/test/fixtures/yield-star/return-method-with-finally/exec.js b/packages/babel-plugin-proposal-async-generator-functions/test/fixtures/yield-star/return-method-with-finally/exec.js new file mode 100644 index 000000000000..0ef1d454a19f --- /dev/null +++ b/packages/babel-plugin-proposal-async-generator-functions/test/fixtures/yield-star/return-method-with-finally/exec.js @@ -0,0 +1,37 @@ +const log = []; + +async function* inner() { + try { + log.push(1); + yield "a"; + log.push(2); + yield "b"; + log.push(3); + } finally { + log.push(4); + yield "c"; + log.push(5); + } +} + +async function* outer() { + log.push(6); + yield* inner(); + log.push(7); +} + +return (async () => { + const iterator = outer(); + + let res = await iterator.next(); + expect(res).toEqual({ value: "a", done: false }); + expect(log).toEqual([6, 1]); + + res = await iterator.return(); + expect(res).toEqual({ value: "c", done: false }); + expect(log).toEqual([6, 1, 4]); + + res = await iterator.next(); + expect(res).toEqual({ value: undefined, done: true }); + expect(log).toEqual([6, 1, 4, 5, 7]); +})(); diff --git a/packages/babel-plugin-proposal-async-generator-functions/test/fixtures/yield-star/return-method/exec.js b/packages/babel-plugin-proposal-async-generator-functions/test/fixtures/yield-star/return-method/exec.js new file mode 100644 index 000000000000..73be9d85e495 --- /dev/null +++ b/packages/babel-plugin-proposal-async-generator-functions/test/fixtures/yield-star/return-method/exec.js @@ -0,0 +1,31 @@ +const log = []; + +async function* inner() { + log.push(1); + yield "a"; + log.push(2); + yield "b"; + log.push(3); +} + +async function* outer() { + log.push(4); + yield* inner(); + log.push(5); +} + +return (async () => { + const iterator = outer(); + + let res = await iterator.next(); + expect(res).toEqual({ value: "a", done: false }); + expect(log).toEqual([4, 1]); + + res = await iterator.return(); + expect(res).toEqual({ value: undefined, done: true }); + expect(log).toEqual([4, 1]); + + res = await iterator.next(); + expect(res).toEqual({ value: undefined, done: true }); + expect(log).toEqual([4, 1]); +})(); diff --git a/packages/babel-plugin-proposal-async-generator-functions/test/fixtures/yield-star/return-method/options.json b/packages/babel-plugin-proposal-async-generator-functions/test/fixtures/yield-star/return-method/options.json new file mode 100644 index 000000000000..7edb6d2fc815 --- /dev/null +++ b/packages/babel-plugin-proposal-async-generator-functions/test/fixtures/yield-star/return-method/options.json @@ -0,0 +1,3 @@ +{ + "minNodeVersion": "8.0.0" +} \ No newline at end of file diff --git a/packages/babel-plugin-proposal-async-generator-functions/test/fixtures/yield-star/throw-method-with-catch/exec.js b/packages/babel-plugin-proposal-async-generator-functions/test/fixtures/yield-star/throw-method-with-catch/exec.js new file mode 100644 index 000000000000..0859ad463e00 --- /dev/null +++ b/packages/babel-plugin-proposal-async-generator-functions/test/fixtures/yield-star/throw-method-with-catch/exec.js @@ -0,0 +1,37 @@ +const log = []; + +async function* inner() { + try { + log.push(1); + yield "a"; + log.push(2); + yield "b"; + log.push(3); + } catch (e) { + log.push(4); + yield "c"; + log.push(5); + } +} + +async function* outer() { + log.push(6); + yield* inner(); + log.push(7); +} + +return (async () => { + const iterator = outer(); + + let res = await iterator.next(); + expect(res).toEqual({ value: "a", done: false }); + expect(log).toEqual([6, 1]); + + res = await iterator.throw(new Error("TEST")); + expect(res).toEqual({ value: "c", done: false }); + expect(log).toEqual([6, 1, 4]); + + res = await iterator.next(); + expect(res).toEqual({ value: undefined, done: true }); + expect(log).toEqual([6, 1, 4, 5, 7]); +})(); diff --git a/packages/babel-plugin-proposal-async-generator-functions/test/fixtures/yield-star/throw-method-with-finally/exec.js b/packages/babel-plugin-proposal-async-generator-functions/test/fixtures/yield-star/throw-method-with-finally/exec.js new file mode 100644 index 000000000000..425a00b33f80 --- /dev/null +++ b/packages/babel-plugin-proposal-async-generator-functions/test/fixtures/yield-star/throw-method-with-finally/exec.js @@ -0,0 +1,37 @@ +const log = []; + +async function* inner() { + try { + log.push(1); + yield "a"; + log.push(2); + yield "b"; + log.push(3); + } finally { + log.push(4); + yield "c"; + log.push(5); + } +} + +async function* outer() { + log.push(6); + yield* inner(); + log.push(7); +} + +return (async () => { + const iterator = outer(); + + let res = await iterator.next(); + expect(res).toEqual({ value: "a", done: false }); + expect(log).toEqual([6, 1]); + + res = await iterator.throw(new Error("TEST")); + expect(res).toEqual({ value: "c", done: false }); + expect(log).toEqual([6, 1, 4]); + + // "yield" in finally suspended the exception for one turn + await expect(iterator.next()).rejects.toThrow(/TEST/); + expect(log).toEqual([6, 1, 4, 5]); +})(); diff --git a/packages/babel-plugin-proposal-class-properties/package.json b/packages/babel-plugin-proposal-class-properties/package.json index 9a11e1c822a6..5036770a07d3 100644 --- a/packages/babel-plugin-proposal-class-properties/package.json +++ b/packages/babel-plugin-proposal-class-properties/package.json @@ -1,6 +1,6 @@ { "name": "@babel/plugin-proposal-class-properties", - "version": "7.5.5", + "version": "7.7.0", "description": "This plugin transforms static class properties as well as properties declared with the property initializer syntax", "repository": "https://github.com/babel/babel/tree/master/packages/babel-plugin-proposal-class-properties", "license": "MIT", @@ -12,14 +12,14 @@ "babel-plugin" ], "dependencies": { - "@babel/helper-create-class-features-plugin": "^7.5.5", + "@babel/helper-create-class-features-plugin": "^7.7.0", "@babel/helper-plugin-utils": "^7.0.0" }, "peerDependencies": { "@babel/core": "^7.0.0-0" }, "devDependencies": { - "@babel/core": "^7.5.5", + "@babel/core": "^7.7.0", "@babel/helper-plugin-test-runner": "^7.0.0" } } diff --git a/packages/babel-plugin-proposal-class-properties/test/fixtures/decorators-legacy-interop/local-define-property/input.js b/packages/babel-plugin-proposal-class-properties/test/fixtures/decorators-legacy-interop/local-define-property/input.js new file mode 100644 index 000000000000..f939e63b3b71 --- /dev/null +++ b/packages/babel-plugin-proposal-class-properties/test/fixtures/decorators-legacy-interop/local-define-property/input.js @@ -0,0 +1,12 @@ +function dec() {} + +// Create a local function binding so babel has to change the name of the helper +function _defineProperty() {} + +class A { + @dec a; + + @dec b = 123; + + c = 456; +} diff --git a/packages/babel-plugin-proposal-class-properties/test/fixtures/decorators-legacy-interop/local-define-property/options.json b/packages/babel-plugin-proposal-class-properties/test/fixtures/decorators-legacy-interop/local-define-property/options.json new file mode 100644 index 000000000000..6f03cd7aad03 --- /dev/null +++ b/packages/babel-plugin-proposal-class-properties/test/fixtures/decorators-legacy-interop/local-define-property/options.json @@ -0,0 +1,7 @@ +{ + "plugins": [ + ["proposal-decorators", { "legacy": true }], + ["proposal-class-properties"], + "transform-classes" + ] +} diff --git a/packages/babel-plugin-proposal-class-properties/test/fixtures/decorators-legacy-interop/local-define-property/output.js b/packages/babel-plugin-proposal-class-properties/test/fixtures/decorators-legacy-interop/local-define-property/output.js new file mode 100644 index 000000000000..641307b44d0d --- /dev/null +++ b/packages/babel-plugin-proposal-class-properties/test/fixtures/decorators-legacy-interop/local-define-property/output.js @@ -0,0 +1,40 @@ +var _class, _descriptor, _descriptor2, _temp; + +function _initializerDefineProperty(target, property, descriptor, context) { if (!descriptor) return; Object.defineProperty(target, property, { enumerable: descriptor.enumerable, configurable: descriptor.configurable, writable: descriptor.writable, value: descriptor.initializer ? descriptor.initializer.call(context) : void 0 }); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperty2(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) { var desc = {}; Object.keys(descriptor).forEach(function (key) { desc[key] = descriptor[key]; }); desc.enumerable = !!desc.enumerable; desc.configurable = !!desc.configurable; if ('value' in desc || desc.initializer) { desc.writable = true; } desc = decorators.slice().reverse().reduce(function (desc, decorator) { return decorator(target, property, desc) || desc; }, desc); if (context && desc.initializer !== void 0) { desc.value = desc.initializer ? desc.initializer.call(context) : void 0; desc.initializer = undefined; } if (desc.initializer === void 0) { Object.defineProperty(target, property, desc); desc = null; } return desc; } + +function _initializerWarningHelper(descriptor, context) { throw new Error('Decorating class property failed. Please ensure that ' + 'proposal-class-properties is enabled and runs after the decorators transform.'); } + +function dec() {} // Create a local function binding so babel has to change the name of the helper + + +function _defineProperty() {} + +let A = (_class = (_temp = function A() { + "use strict"; + + _classCallCheck(this, A); + + _initializerDefineProperty(this, "a", _descriptor, this); + + _initializerDefineProperty(this, "b", _descriptor2, this); + + _defineProperty2(this, "c", 456); +}, _temp), (_descriptor = _applyDecoratedDescriptor(_class.prototype, "a", [dec], { + configurable: true, + enumerable: true, + writable: true, + initializer: null +}), _descriptor2 = _applyDecoratedDescriptor(_class.prototype, "b", [dec], { + configurable: true, + enumerable: true, + writable: true, + initializer: function () { + return 123; + } +})), _class); diff --git a/packages/babel-plugin-proposal-class-properties/test/fixtures/decorators-legacy-interop/loose/input.js b/packages/babel-plugin-proposal-class-properties/test/fixtures/decorators-legacy-interop/loose/input.js new file mode 100644 index 000000000000..92298f2eb49b --- /dev/null +++ b/packages/babel-plugin-proposal-class-properties/test/fixtures/decorators-legacy-interop/loose/input.js @@ -0,0 +1,9 @@ +function dec() {} + +class A { + @dec a; + + @dec b = 123; + + c = 456; +} diff --git a/packages/babel-plugin-proposal-class-properties/test/fixtures/decorators-legacy-interop/loose/options.json b/packages/babel-plugin-proposal-class-properties/test/fixtures/decorators-legacy-interop/loose/options.json new file mode 100644 index 000000000000..8c831989533b --- /dev/null +++ b/packages/babel-plugin-proposal-class-properties/test/fixtures/decorators-legacy-interop/loose/options.json @@ -0,0 +1,7 @@ +{ + "plugins": [ + ["proposal-decorators", { "legacy": true }], + ["proposal-class-properties", { "loose": true }], + "transform-classes" + ] +} diff --git a/packages/babel-plugin-proposal-class-properties/test/fixtures/decorators-legacy-interop/loose/output.js b/packages/babel-plugin-proposal-class-properties/test/fixtures/decorators-legacy-interop/loose/output.js new file mode 100644 index 000000000000..0a25e2b1023c --- /dev/null +++ b/packages/babel-plugin-proposal-class-properties/test/fixtures/decorators-legacy-interop/loose/output.js @@ -0,0 +1,35 @@ +var _class, _descriptor, _descriptor2, _temp; + +function _initializerDefineProperty(target, property, descriptor, context) { if (!descriptor) return; Object.defineProperty(target, property, { enumerable: descriptor.enumerable, configurable: descriptor.configurable, writable: descriptor.writable, value: descriptor.initializer ? descriptor.initializer.call(context) : void 0 }); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) { var desc = {}; Object.keys(descriptor).forEach(function (key) { desc[key] = descriptor[key]; }); desc.enumerable = !!desc.enumerable; desc.configurable = !!desc.configurable; if ('value' in desc || desc.initializer) { desc.writable = true; } desc = decorators.slice().reverse().reduce(function (desc, decorator) { return decorator(target, property, desc) || desc; }, desc); if (context && desc.initializer !== void 0) { desc.value = desc.initializer ? desc.initializer.call(context) : void 0; desc.initializer = undefined; } if (desc.initializer === void 0) { Object.defineProperty(target, property, desc); desc = null; } return desc; } + +function _initializerWarningHelper(descriptor, context) { throw new Error('Decorating class property failed. Please ensure that ' + 'proposal-class-properties is enabled and runs after the decorators transform.'); } + +function dec() {} + +let A = (_class = (_temp = function A() { + "use strict"; + + _classCallCheck(this, A); + + _initializerDefineProperty(this, "a", _descriptor, this); + + _initializerDefineProperty(this, "b", _descriptor2, this); + + this.c = 456; +}, _temp), (_descriptor = _applyDecoratedDescriptor(_class.prototype, "a", [dec], { + configurable: true, + enumerable: true, + writable: true, + initializer: null +}), _descriptor2 = _applyDecoratedDescriptor(_class.prototype, "b", [dec], { + configurable: true, + enumerable: true, + writable: true, + initializer: function () { + return 123; + } +})), _class); diff --git a/packages/babel-plugin-proposal-class-properties/test/fixtures/decorators-legacy-interop/strict/input.js b/packages/babel-plugin-proposal-class-properties/test/fixtures/decorators-legacy-interop/strict/input.js new file mode 100644 index 000000000000..92298f2eb49b --- /dev/null +++ b/packages/babel-plugin-proposal-class-properties/test/fixtures/decorators-legacy-interop/strict/input.js @@ -0,0 +1,9 @@ +function dec() {} + +class A { + @dec a; + + @dec b = 123; + + c = 456; +} diff --git a/packages/babel-plugin-proposal-class-properties/test/fixtures/decorators-legacy-interop/strict/options.json b/packages/babel-plugin-proposal-class-properties/test/fixtures/decorators-legacy-interop/strict/options.json new file mode 100644 index 000000000000..6f03cd7aad03 --- /dev/null +++ b/packages/babel-plugin-proposal-class-properties/test/fixtures/decorators-legacy-interop/strict/options.json @@ -0,0 +1,7 @@ +{ + "plugins": [ + ["proposal-decorators", { "legacy": true }], + ["proposal-class-properties"], + "transform-classes" + ] +} diff --git a/packages/babel-plugin-proposal-class-properties/test/fixtures/decorators-legacy-interop/strict/output.js b/packages/babel-plugin-proposal-class-properties/test/fixtures/decorators-legacy-interop/strict/output.js new file mode 100644 index 000000000000..11cce4ac923d --- /dev/null +++ b/packages/babel-plugin-proposal-class-properties/test/fixtures/decorators-legacy-interop/strict/output.js @@ -0,0 +1,37 @@ +var _class, _descriptor, _descriptor2, _temp; + +function _initializerDefineProperty(target, property, descriptor, context) { if (!descriptor) return; Object.defineProperty(target, property, { enumerable: descriptor.enumerable, configurable: descriptor.configurable, writable: descriptor.writable, value: descriptor.initializer ? descriptor.initializer.call(context) : void 0 }); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) { var desc = {}; Object.keys(descriptor).forEach(function (key) { desc[key] = descriptor[key]; }); desc.enumerable = !!desc.enumerable; desc.configurable = !!desc.configurable; if ('value' in desc || desc.initializer) { desc.writable = true; } desc = decorators.slice().reverse().reduce(function (desc, decorator) { return decorator(target, property, desc) || desc; }, desc); if (context && desc.initializer !== void 0) { desc.value = desc.initializer ? desc.initializer.call(context) : void 0; desc.initializer = undefined; } if (desc.initializer === void 0) { Object.defineProperty(target, property, desc); desc = null; } return desc; } + +function _initializerWarningHelper(descriptor, context) { throw new Error('Decorating class property failed. Please ensure that ' + 'proposal-class-properties is enabled and runs after the decorators transform.'); } + +function dec() {} + +let A = (_class = (_temp = function A() { + "use strict"; + + _classCallCheck(this, A); + + _initializerDefineProperty(this, "a", _descriptor, this); + + _initializerDefineProperty(this, "b", _descriptor2, this); + + _defineProperty(this, "c", 456); +}, _temp), (_descriptor = _applyDecoratedDescriptor(_class.prototype, "a", [dec], { + configurable: true, + enumerable: true, + writable: true, + initializer: null +}), _descriptor2 = _applyDecoratedDescriptor(_class.prototype, "b", [dec], { + configurable: true, + enumerable: true, + writable: true, + initializer: function () { + return 123; + } +})), _class); diff --git a/packages/babel-plugin-proposal-class-properties/test/fixtures/static-property-tdz/decorator-interop/output.js b/packages/babel-plugin-proposal-class-properties/test/fixtures/static-property-tdz/decorator-interop/output.js index 2cd978b722c9..9a71c175287f 100644 --- a/packages/babel-plugin-proposal-class-properties/test/fixtures/static-property-tdz/decorator-interop/output.js +++ b/packages/babel-plugin-proposal-class-properties/test/fixtures/static-property-tdz/decorator-interop/output.js @@ -12,7 +12,7 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) { var desc = {}; Object.keys(descriptor).forEach(function (key) { desc[key] = descriptor[key]; }); desc.enumerable = !!desc.enumerable; desc.configurable = !!desc.configurable; if ('value' in desc || desc.initializer) { desc.writable = true; } desc = decorators.slice().reverse().reduce(function (desc, decorator) { return decorator(target, property, desc) || desc; }, desc); if (context && desc.initializer !== void 0) { desc.value = desc.initializer ? desc.initializer.call(context) : void 0; desc.initializer = undefined; } if (desc.initializer === void 0) { Object.defineProperty(target, property, desc); desc = null; } return desc; } -function _initializerWarningHelper(descriptor, context) { throw new Error('Decorating class property failed. Please ensure that ' + 'proposal-class-properties is enabled and set to use loose mode. ' + 'To use proposal-class-properties in spec mode with decorators, wait for ' + 'the next major version of decorators in stage 2.'); } +function _initializerWarningHelper(descriptor, context) { throw new Error('Decorating class property failed. Please ensure that ' + 'proposal-class-properties is enabled and runs after the decorators transform.'); } function dec() {} diff --git a/packages/babel-plugin-proposal-decorators/package.json b/packages/babel-plugin-proposal-decorators/package.json index 6278dff8e544..e7f9f4de57e3 100644 --- a/packages/babel-plugin-proposal-decorators/package.json +++ b/packages/babel-plugin-proposal-decorators/package.json @@ -1,6 +1,6 @@ { "name": "@babel/plugin-proposal-decorators", - "version": "7.6.0", + "version": "7.7.0", "author": "Logan Smyth ", "license": "MIT", "publishConfig": { @@ -15,7 +15,7 @@ "decorators" ], "dependencies": { - "@babel/helper-create-class-features-plugin": "^7.6.0", + "@babel/helper-create-class-features-plugin": "^7.7.0", "@babel/helper-plugin-utils": "^7.0.0", "@babel/plugin-syntax-decorators": "^7.2.0" }, @@ -23,7 +23,7 @@ "@babel/core": "^7.0.0-0" }, "devDependencies": { - "@babel/core": "^7.6.0", + "@babel/core": "^7.7.0", "@babel/helper-plugin-test-runner": "^7.0.0" } } diff --git a/packages/babel-plugin-proposal-decorators/src/transformer-legacy.js b/packages/babel-plugin-proposal-decorators/src/transformer-legacy.js index 53cfe47df91d..ca23bad24824 100644 --- a/packages/babel-plugin-proposal-decorators/src/transformer-legacy.js +++ b/packages/babel-plugin-proposal-decorators/src/transformer-legacy.js @@ -281,10 +281,33 @@ export default { path.replaceWith( t.callExpression(state.addHelper("initializerDefineProperty"), [ t.cloneNode(path.get("left.object").node), - t.stringLiteral(path.get("left.property").node.name), + t.stringLiteral( + path.get("left.property").node.name || + path.get("left.property").node.value, + ), t.cloneNode(path.get("right.arguments")[0].node), t.cloneNode(path.get("right.arguments")[1].node), ]), ); }, + + CallExpression(path, state) { + if (path.node.arguments.length !== 3) return; + if (!WARNING_CALLS.has(path.node.arguments[2])) return; + + // If the class properties plugin isn't enabled, this line will add an unused helper + // to the code. It's not ideal, but it's ok since the configuration is not valid anyway. + if (path.node.callee.name !== state.addHelper("defineProperty").name) { + return; + } + + path.replaceWith( + t.callExpression(state.addHelper("initializerDefineProperty"), [ + t.cloneNode(path.get("arguments")[0].node), + t.cloneNode(path.get("arguments")[1].node), + t.cloneNode(path.get("arguments.2.arguments")[0].node), + t.cloneNode(path.get("arguments.2.arguments")[1].node), + ]), + ); + }, }; diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/legacy-class-prototype-properties/string-literal-properties/exec.js b/packages/babel-plugin-proposal-decorators/test/fixtures/legacy-class-prototype-properties/string-literal-properties/exec.js new file mode 100644 index 000000000000..c3e4ca274083 --- /dev/null +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/legacy-class-prototype-properties/string-literal-properties/exec.js @@ -0,0 +1,29 @@ +function dec(target, name, descriptor) { + expect(target).toBeTruthy(); + expect(typeof name).toBe("string"); + expect(typeof descriptor).toBe("object"); + + target.decoratedProps = (target.decoratedProps || []).concat([name]); + + return descriptor; +} + +class Example { + @dec "a-prop"; +} + +let inst = new Example(); + +expect(Example.prototype).toHaveProperty("decoratedProps"); +expect(inst.decoratedProps).toEqual([ + "a-prop" +]); + +expect(inst).toHaveProperty("a-prop"); +expect(inst["a-prop"]).toBeUndefined(); + +const descs = Object.getOwnPropertyDescriptors(inst); + +expect(descs["a-prop"].enumerable).toBeTruthy(); +expect(descs["a-prop"].writable).toBeTruthy(); +expect(descs["a-prop"].configurable).toBeTruthy(); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/legacy-regression/10264/options.json b/packages/babel-plugin-proposal-decorators/test/fixtures/legacy-regression/10264/options.json index 51aa897d2c31..ee996d3cfc6f 100644 --- a/packages/babel-plugin-proposal-decorators/test/fixtures/legacy-regression/10264/options.json +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/legacy-regression/10264/options.json @@ -1,6 +1,6 @@ { "plugins": [ "transform-typescript", - [ "proposal-decorators", { "legacy": true } ] + ["proposal-decorators", { "legacy": true }] ] } diff --git a/packages/babel-plugin-proposal-dynamic-import/package.json b/packages/babel-plugin-proposal-dynamic-import/package.json index a691155641e4..1ade94814252 100644 --- a/packages/babel-plugin-proposal-dynamic-import/package.json +++ b/packages/babel-plugin-proposal-dynamic-import/package.json @@ -1,6 +1,6 @@ { "name": "@babel/plugin-proposal-dynamic-import", - "version": "7.5.0", + "version": "7.7.0", "description": "Transform import() expressions", "repository": "https://github.com/babel/babel/tree/master/packages/babel-plugin-proposal-dynamic-import", "license": "MIT", @@ -19,7 +19,7 @@ "@babel/core": "^7.0.0-0" }, "devDependencies": { - "@babel/core": "^7.5.0", + "@babel/core": "^7.7.0", "@babel/helper-plugin-test-runner": "^7.0.0" } } diff --git a/packages/babel-plugin-proposal-function-sent/package.json b/packages/babel-plugin-proposal-function-sent/package.json index 0ba394b625af..f8335257f1a6 100644 --- a/packages/babel-plugin-proposal-function-sent/package.json +++ b/packages/babel-plugin-proposal-function-sent/package.json @@ -1,6 +1,6 @@ { "name": "@babel/plugin-proposal-function-sent", - "version": "7.5.0", + "version": "7.7.0", "description": "Compile the function.sent meta property to valid ES2015 code", "repository": "https://github.com/babel/babel/tree/master/packages/babel-plugin-proposal-function-sent", "license": "MIT", @@ -13,14 +13,14 @@ ], "dependencies": { "@babel/helper-plugin-utils": "^7.0.0", - "@babel/helper-wrap-function": "^7.2.0", + "@babel/helper-wrap-function": "^7.7.0", "@babel/plugin-syntax-function-sent": "^7.2.0" }, "peerDependencies": { "@babel/core": "^7.0.0-0" }, "devDependencies": { - "@babel/core": "^7.5.0", + "@babel/core": "^7.7.0", "@babel/helper-plugin-test-runner": "^7.0.0" } } diff --git a/packages/babel-plugin-proposal-function-sent/test/fixtures/generator-kinds/async-generator/output.js b/packages/babel-plugin-proposal-function-sent/test/fixtures/generator-kinds/async-generator/output.js index a05d6843d84e..8bccb5d80c6c 100644 --- a/packages/babel-plugin-proposal-function-sent/test/fixtures/generator-kinds/async-generator/output.js +++ b/packages/babel-plugin-proposal-function-sent/test/fixtures/generator-kinds/async-generator/output.js @@ -4,7 +4,7 @@ function _awaitAsyncGenerator(value) { return new _AwaitValue(value); } function _wrapAsyncGenerator(fn) { return function () { return new _AsyncGenerator(fn.apply(this, arguments)); }; } -function _AsyncGenerator(gen) { var front, back; function send(key, arg) { return new Promise(function (resolve, reject) { var request = { key: key, arg: arg, resolve: resolve, reject: reject, next: null }; if (back) { back = back.next = request; } else { front = back = request; resume(key, arg); } }); } function resume(key, arg) { try { var result = gen[key](arg); var value = result.value; var wrappedAwait = value instanceof _AwaitValue; Promise.resolve(wrappedAwait ? value.wrapped : value).then(function (arg) { if (wrappedAwait) { resume("next", arg); return; } settle(result.done ? "return" : "normal", arg); }, function (err) { resume("throw", err); }); } catch (err) { settle("throw", err); } } function settle(type, value) { switch (type) { case "return": front.resolve({ value: value, done: true }); break; case "throw": front.reject(value); break; default: front.resolve({ value: value, done: false }); break; } front = front.next; if (front) { resume(front.key, front.arg); } else { back = null; } } this._invoke = send; if (typeof gen.return !== "function") { this.return = undefined; } } +function _AsyncGenerator(gen) { var front, back; function send(key, arg) { return new Promise(function (resolve, reject) { var request = { key: key, arg: arg, resolve: resolve, reject: reject, next: null }; if (back) { back = back.next = request; } else { front = back = request; resume(key, arg); } }); } function resume(key, arg) { try { var result = gen[key](arg); var value = result.value; var wrappedAwait = value instanceof _AwaitValue; Promise.resolve(wrappedAwait ? value.wrapped : value).then(function (arg) { if (wrappedAwait) { resume(key === "return" ? "return" : "next", arg); return; } settle(result.done ? "return" : "normal", arg); }, function (err) { resume("throw", err); }); } catch (err) { settle("throw", err); } } function settle(type, value) { switch (type) { case "return": front.resolve({ value: value, done: true }); break; case "throw": front.reject(value); break; default: front.resolve({ value: value, done: false }); break; } front = front.next; if (front) { resume(front.key, front.arg); } else { back = null; } } this._invoke = send; if (typeof gen.return !== "function") { this.return = undefined; } } if (typeof Symbol === "function" && Symbol.asyncIterator) { _AsyncGenerator.prototype[Symbol.asyncIterator] = function () { return this; }; } diff --git a/packages/babel-plugin-proposal-object-rest-spread/test/fixtures/object-spread/assignment/output.js b/packages/babel-plugin-proposal-object-rest-spread/test/fixtures/object-spread/assignment/output.js index bca55509f8df..a1f2970a3264 100644 --- a/packages/babel-plugin-proposal-object-rest-spread/test/fixtures/object-spread/assignment/output.js +++ b/packages/babel-plugin-proposal-object-rest-spread/test/fixtures/object-spread/assignment/output.js @@ -1,6 +1,6 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } -function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } diff --git a/packages/babel-plugin-proposal-object-rest-spread/test/fixtures/object-spread/expression/output.js b/packages/babel-plugin-proposal-object-rest-spread/test/fixtures/object-spread/expression/output.js index ba0e5ad1c8e3..a172df60bd16 100644 --- a/packages/babel-plugin-proposal-object-rest-spread/test/fixtures/object-spread/expression/output.js +++ b/packages/babel-plugin-proposal-object-rest-spread/test/fixtures/object-spread/expression/output.js @@ -1,6 +1,6 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } -function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } diff --git a/packages/babel-plugin-proposal-object-rest-spread/test/fixtures/object-spread/variable-declaration/output.js b/packages/babel-plugin-proposal-object-rest-spread/test/fixtures/object-spread/variable-declaration/output.js index 1370408b8354..9fabf3047b3d 100644 --- a/packages/babel-plugin-proposal-object-rest-spread/test/fixtures/object-spread/variable-declaration/output.js +++ b/packages/babel-plugin-proposal-object-rest-spread/test/fixtures/object-spread/variable-declaration/output.js @@ -1,6 +1,6 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } -function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } diff --git a/packages/babel-plugin-proposal-optional-chaining/src/index.js b/packages/babel-plugin-proposal-optional-chaining/src/index.js index c3e324041520..918a59ade508 100644 --- a/packages/babel-plugin-proposal-optional-chaining/src/index.js +++ b/packages/babel-plugin-proposal-optional-chaining/src/index.js @@ -82,6 +82,8 @@ export default declare((api, options) => { let context = scope.maybeGenerateMemoised(object); if (context) { chain.object = t.assignmentExpression("=", context, object); + } else if (t.isSuper(object)) { + context = t.thisExpression(); } else { context = object; } diff --git a/packages/babel-plugin-proposal-optional-chaining/test/fixtures/general/super-method-call-loose/input.js b/packages/babel-plugin-proposal-optional-chaining/test/fixtures/general/super-method-call-loose/input.js new file mode 100644 index 000000000000..445c06ab259e --- /dev/null +++ b/packages/babel-plugin-proposal-optional-chaining/test/fixtures/general/super-method-call-loose/input.js @@ -0,0 +1,12 @@ +"use strict"; +class Base { + method() { + return 'Hello!'; + } +} + +class Derived extends Base { + method() { + return super.method?.() + } +} diff --git a/packages/babel-plugin-proposal-optional-chaining/test/fixtures/general/super-method-call-loose/options.json b/packages/babel-plugin-proposal-optional-chaining/test/fixtures/general/super-method-call-loose/options.json new file mode 100644 index 000000000000..39ea3f99c7ff --- /dev/null +++ b/packages/babel-plugin-proposal-optional-chaining/test/fixtures/general/super-method-call-loose/options.json @@ -0,0 +1,3 @@ +{ + "plugins": [["proposal-optional-chaining", { "loose": true }]] +} diff --git a/packages/babel-plugin-proposal-optional-chaining/test/fixtures/general/super-method-call-loose/output.js b/packages/babel-plugin-proposal-optional-chaining/test/fixtures/general/super-method-call-loose/output.js new file mode 100644 index 000000000000..6fd3890a61aa --- /dev/null +++ b/packages/babel-plugin-proposal-optional-chaining/test/fixtures/general/super-method-call-loose/output.js @@ -0,0 +1,15 @@ +"use strict"; + +class Base { + method() { + return 'Hello!'; + } + +} + +class Derived extends Base { + method() { + return super.method == null ? void 0 : super.method(); + } + +} diff --git a/packages/babel-plugin-proposal-optional-chaining/test/fixtures/general/super-method-call/input.js b/packages/babel-plugin-proposal-optional-chaining/test/fixtures/general/super-method-call/input.js new file mode 100644 index 000000000000..445c06ab259e --- /dev/null +++ b/packages/babel-plugin-proposal-optional-chaining/test/fixtures/general/super-method-call/input.js @@ -0,0 +1,12 @@ +"use strict"; +class Base { + method() { + return 'Hello!'; + } +} + +class Derived extends Base { + method() { + return super.method?.() + } +} diff --git a/packages/babel-plugin-proposal-optional-chaining/test/fixtures/general/super-method-call/output.js b/packages/babel-plugin-proposal-optional-chaining/test/fixtures/general/super-method-call/output.js new file mode 100644 index 000000000000..891da0508e27 --- /dev/null +++ b/packages/babel-plugin-proposal-optional-chaining/test/fixtures/general/super-method-call/output.js @@ -0,0 +1,17 @@ +"use strict"; + +class Base { + method() { + return 'Hello!'; + } + +} + +class Derived extends Base { + method() { + var _super$method; + + return (_super$method = super.method) === null || _super$method === void 0 ? void 0 : _super$method.call(this); + } + +} diff --git a/packages/babel-plugin-proposal-unicode-property-regex/package.json b/packages/babel-plugin-proposal-unicode-property-regex/package.json index 2fe4510857d1..b478bbdde033 100644 --- a/packages/babel-plugin-proposal-unicode-property-regex/package.json +++ b/packages/babel-plugin-proposal-unicode-property-regex/package.json @@ -1,6 +1,6 @@ { "name": "@babel/plugin-proposal-unicode-property-regex", - "version": "7.6.2", + "version": "7.7.0", "description": "Compile Unicode property escapes in Unicode regular expressions to ES5.", "homepage": "https://babeljs.io/", "license": "MIT", @@ -22,15 +22,14 @@ "repository": "https://github.com/babel/babel/tree/master/packages/babel-plugin-proposal-unicode-property-regex", "bugs": "https://github.com/babel/babel/issues", "dependencies": { - "@babel/helper-plugin-utils": "^7.0.0", - "@babel/helper-regex": "^7.4.4", - "regexpu-core": "^4.6.0" + "@babel/helper-create-regexp-features-plugin": "^7.7.0", + "@babel/helper-plugin-utils": "^7.0.0" }, "peerDependencies": { "@babel/core": "^7.0.0-0" }, "devDependencies": { - "@babel/core": "^7.6.2", + "@babel/core": "^7.7.0", "@babel/helper-plugin-test-runner": "^7.0.0" } } diff --git a/packages/babel-plugin-proposal-unicode-property-regex/src/index.js b/packages/babel-plugin-proposal-unicode-property-regex/src/index.js index b0245892311f..bf76031cbf12 100644 --- a/packages/babel-plugin-proposal-unicode-property-regex/src/index.js +++ b/packages/babel-plugin-proposal-unicode-property-regex/src/index.js @@ -1,6 +1,6 @@ +/* eslint-disable @babel/development/plugin-name */ +import { createRegExpFeaturePlugin } from "@babel/helper-create-regexp-features-plugin"; import { declare } from "@babel/helper-plugin-utils"; -import rewritePattern from "regexpu-core"; -import * as regex from "@babel/helper-regex"; export default declare((api, options) => { api.assertVersion(7); @@ -10,23 +10,9 @@ export default declare((api, options) => { throw new Error(".useUnicodeFlag must be a boolean, or undefined"); } - return { + return createRegExpFeaturePlugin({ name: "proposal-unicode-property-regex", - - visitor: { - RegExpLiteral(path) { - const node = path.node; - if (!regex.is(node, "u")) { - return; - } - node.pattern = rewritePattern(node.pattern, node.flags, { - unicodePropertyEscape: true, - useUnicodeFlag, - }); - if (!useUnicodeFlag) { - regex.pullFlag(node, "u"); - } - }, - }, - }; + feature: "unicodePropertyEscape", + options: { useUnicodeFlag }, + }); }); diff --git a/packages/babel-plugin-proposal-unicode-property-regex/test/fixtures/with-unicode-flag/unicode-12/input.js b/packages/babel-plugin-proposal-unicode-property-regex/test/fixtures/with-unicode-flag/unicode-12/input.js index 711dde943b3c..e50ab9eb68e0 100644 --- a/packages/babel-plugin-proposal-unicode-property-regex/test/fixtures/with-unicode-flag/unicode-12/input.js +++ b/packages/babel-plugin-proposal-unicode-property-regex/test/fixtures/with-unicode-flag/unicode-12/input.js @@ -1 +1 @@ -var regex = /[\u{1E2C0}-\u{1E2F9}\u{1E2FF}]/u; +var regex = /[\p{Script_Extensions=Wancho}]/u; diff --git a/packages/babel-plugin-syntax-flow/package.json b/packages/babel-plugin-syntax-flow/package.json index 864023567a5d..2885aa9f81ec 100644 --- a/packages/babel-plugin-syntax-flow/package.json +++ b/packages/babel-plugin-syntax-flow/package.json @@ -1,6 +1,6 @@ { "name": "@babel/plugin-syntax-flow", - "version": "7.2.0", + "version": "7.7.0", "description": "Allow parsing of the flow syntax", "repository": "https://github.com/babel/babel/tree/master/packages/babel-plugin-syntax-flow", "license": "MIT", @@ -18,6 +18,6 @@ "@babel/core": "^7.0.0-0" }, "devDependencies": { - "@babel/core": "^7.2.0" + "@babel/core": "^7.7.0" } } diff --git a/packages/babel-plugin-syntax-flow/src/index.js b/packages/babel-plugin-syntax-flow/src/index.js index 0062dbee50e6..72fb7dc60b95 100644 --- a/packages/babel-plugin-syntax-flow/src/index.js +++ b/packages/babel-plugin-syntax-flow/src/index.js @@ -5,12 +5,16 @@ export default declare((api, options) => { // When enabled and plugins includes flow, all files should be parsed as if // the @flow pragma was provided. - const { all } = options; + const { all, enums } = options; if (typeof all !== "boolean" && typeof all !== "undefined") { throw new Error(".all must be a boolean, or undefined"); } + if (typeof enums !== "boolean" && typeof enums !== "undefined") { + throw new Error(".enums must be a boolean, or undefined"); + } + return { name: "syntax-flow", @@ -25,7 +29,7 @@ export default declare((api, options) => { return; } - parserOpts.plugins.push(["flow", { all }]); + parserOpts.plugins.push(["flow", { all, enums }]); }, }; }); diff --git a/packages/babel-plugin-syntax-top-level-await/.npmignore b/packages/babel-plugin-syntax-top-level-await/.npmignore new file mode 100644 index 000000000000..cace0d6ddcdd --- /dev/null +++ b/packages/babel-plugin-syntax-top-level-await/.npmignore @@ -0,0 +1,3 @@ +node_modules +*.log +src diff --git a/packages/babel-plugin-syntax-top-level-await/README.md b/packages/babel-plugin-syntax-top-level-await/README.md new file mode 100644 index 000000000000..476cb27d6bbb --- /dev/null +++ b/packages/babel-plugin-syntax-top-level-await/README.md @@ -0,0 +1,19 @@ +# @babel/plugin-syntax-top-level-await + +> Allow parsing of top-level await in modules + +See our website [@babel/plugin-syntax-top-level-await](https://babeljs.io/docs/en/next/babel-plugin-syntax-top-level-await.html) for more information. + +## Install + +Using npm: + +```sh +npm install --save-dev @babel/plugin-syntax-top-level-await +``` + +or using yarn: + +```sh +yarn add @babel/plugin-syntax-top-level-await --dev +``` diff --git a/packages/babel-plugin-syntax-top-level-await/package.json b/packages/babel-plugin-syntax-top-level-await/package.json new file mode 100644 index 000000000000..5b42d9a1f1c9 --- /dev/null +++ b/packages/babel-plugin-syntax-top-level-await/package.json @@ -0,0 +1,23 @@ +{ + "name": "@babel/plugin-syntax-top-level-await", + "version": "7.7.0", + "description": "Allow parsing of top-level await in modules", + "repository": "https://github.com/babel/babel/tree/master/packages/babel-plugin-syntax-top-level-await", + "license": "MIT", + "publishConfig": { + "access": "public" + }, + "main": "lib/index.js", + "keywords": [ + "babel-plugin" + ], + "dependencies": { + "@babel/helper-plugin-utils": "^7.0.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + }, + "devDependencies": { + "@babel/core": "^7.7.0" + } +} diff --git a/packages/babel-plugin-syntax-top-level-await/src/index.js b/packages/babel-plugin-syntax-top-level-await/src/index.js new file mode 100644 index 000000000000..2429b8ead657 --- /dev/null +++ b/packages/babel-plugin-syntax-top-level-await/src/index.js @@ -0,0 +1,13 @@ +import { declare } from "@babel/helper-plugin-utils"; + +export default declare(api => { + api.assertVersion(7); + + return { + name: "syntax-top-level-await", + + manipulateOptions(opts, parserOpts) { + parserOpts.plugins.push("topLevelAwait"); + }, + }; +}); diff --git a/packages/babel-plugin-transform-async-to-generator/package.json b/packages/babel-plugin-transform-async-to-generator/package.json index d6b8b908e89a..7703da8097fe 100644 --- a/packages/babel-plugin-transform-async-to-generator/package.json +++ b/packages/babel-plugin-transform-async-to-generator/package.json @@ -1,6 +1,6 @@ { "name": "@babel/plugin-transform-async-to-generator", - "version": "7.5.0", + "version": "7.7.0", "description": "Turn async functions into ES2015 generators", "repository": "https://github.com/babel/babel/tree/master/packages/babel-plugin-transform-async-to-generator", "license": "MIT", @@ -12,15 +12,15 @@ "babel-plugin" ], "dependencies": { - "@babel/helper-module-imports": "^7.0.0", + "@babel/helper-module-imports": "^7.7.0", "@babel/helper-plugin-utils": "^7.0.0", - "@babel/helper-remap-async-to-generator": "^7.1.0" + "@babel/helper-remap-async-to-generator": "^7.7.0" }, "peerDependencies": { "@babel/core": "^7.0.0-0" }, "devDependencies": { - "@babel/core": "^7.5.0", + "@babel/core": "^7.7.0", "@babel/helper-plugin-test-runner": "^7.0.0" } } diff --git a/packages/babel-plugin-transform-classes/package.json b/packages/babel-plugin-transform-classes/package.json index f1fcc8a2e80b..cfb696cf0a8f 100644 --- a/packages/babel-plugin-transform-classes/package.json +++ b/packages/babel-plugin-transform-classes/package.json @@ -1,6 +1,6 @@ { "name": "@babel/plugin-transform-classes", - "version": "7.5.5", + "version": "7.7.0", "description": "Compile ES2015 classes to ES5", "repository": "https://github.com/babel/babel/tree/master/packages/babel-plugin-transform-classes", "license": "MIT", @@ -9,13 +9,13 @@ }, "main": "lib/index.js", "dependencies": { - "@babel/helper-annotate-as-pure": "^7.0.0", - "@babel/helper-define-map": "^7.5.5", - "@babel/helper-function-name": "^7.1.0", - "@babel/helper-optimise-call-expression": "^7.0.0", + "@babel/helper-annotate-as-pure": "^7.7.0", + "@babel/helper-define-map": "^7.7.0", + "@babel/helper-function-name": "^7.7.0", + "@babel/helper-optimise-call-expression": "^7.7.0", "@babel/helper-plugin-utils": "^7.0.0", - "@babel/helper-replace-supers": "^7.5.5", - "@babel/helper-split-export-declaration": "^7.4.4", + "@babel/helper-replace-supers": "^7.7.0", + "@babel/helper-split-export-declaration": "^7.7.0", "globals": "^11.1.0" }, "keywords": [ @@ -25,7 +25,7 @@ "@babel/core": "^7.0.0-0" }, "devDependencies": { - "@babel/core": "^7.5.5", + "@babel/core": "^7.7.0", "@babel/helper-plugin-test-runner": "^7.0.0" } } diff --git a/packages/babel-plugin-transform-classes/test/fixtures/regression/T6755/output.js b/packages/babel-plugin-transform-classes/test/fixtures/regression/T6755/output.js index 435ad8c4dfa3..204120c62c82 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/regression/T6755/output.js +++ b/packages/babel-plugin-transform-classes/test/fixtures/regression/T6755/output.js @@ -1,7 +1,3 @@ -function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } } - -function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; } - var Example = /*#__PURE__*/ function () { @@ -11,33 +7,21 @@ function () { var _proto = Example.prototype; - _proto.test1 = - /*#__PURE__*/ - function () { - var _test = _asyncToGenerator( - /*#__PURE__*/ - regeneratorRuntime.mark(function _callee() { - return regeneratorRuntime.wrap(function _callee$(_context) { - while (1) { - switch (_context.prev = _context.next) { - case 0: - _context.next = 2; - return Promise.resolve(2); + _proto.test1 = function test1() { + return regeneratorRuntime.async(function test1$(_context) { + while (1) { + switch (_context.prev = _context.next) { + case 0: + _context.next = 2; + return regeneratorRuntime.awrap(Promise.resolve(2)); - case 2: - case "end": - return _context.stop(); - } + case 2: + case "end": + return _context.stop(); } - }, _callee); - })); - - function test1() { - return _test.apply(this, arguments); - } - - return test1; - }(); + } + }); + }; _proto.test2 = /*#__PURE__*/ diff --git a/packages/babel-plugin-transform-dotall-regex/package.json b/packages/babel-plugin-transform-dotall-regex/package.json index 106ce8056802..77dc9f4deb5e 100644 --- a/packages/babel-plugin-transform-dotall-regex/package.json +++ b/packages/babel-plugin-transform-dotall-regex/package.json @@ -1,6 +1,6 @@ { "name": "@babel/plugin-transform-dotall-regex", - "version": "7.6.2", + "version": "7.7.0", "description": "Compile regular expressions using the `s` (`dotAll`) flag to ES5.", "homepage": "https://babeljs.io/", "license": "MIT", @@ -8,9 +8,6 @@ "access": "public" }, "main": "lib/index.js", - "engines": { - "node": ">=4" - }, "keywords": [ "babel-plugin", "regex", @@ -21,15 +18,14 @@ "repository": "https://github.com/babel/babel/tree/master/packages/babel-plugin-transform-dotall-regex", "bugs": "https://github.com/babel/babel/issues", "dependencies": { - "@babel/helper-plugin-utils": "^7.0.0", - "@babel/helper-regex": "^7.4.4", - "regexpu-core": "^4.6.0" + "@babel/helper-create-regexp-features-plugin": "^7.7.0", + "@babel/helper-plugin-utils": "^7.0.0" }, "peerDependencies": { "@babel/core": "^7.0.0-0" }, "devDependencies": { - "@babel/core": "^7.6.2", + "@babel/core": "^7.7.0", "@babel/helper-plugin-test-runner": "^7.0.0" } } diff --git a/packages/babel-plugin-transform-dotall-regex/src/index.js b/packages/babel-plugin-transform-dotall-regex/src/index.js index af11660ea05e..a41961076922 100644 --- a/packages/babel-plugin-transform-dotall-regex/src/index.js +++ b/packages/babel-plugin-transform-dotall-regex/src/index.js @@ -1,25 +1,12 @@ +/* eslint-disable @babel/development/plugin-name */ +import { createRegExpFeaturePlugin } from "@babel/helper-create-regexp-features-plugin"; import { declare } from "@babel/helper-plugin-utils"; -import rewritePattern from "regexpu-core"; -import * as regex from "@babel/helper-regex"; export default declare(api => { api.assertVersion(7); - return { + return createRegExpFeaturePlugin({ name: "transform-dotall-regex", - - visitor: { - RegExpLiteral(path) { - const node = path.node; - if (!regex.is(node, "s")) { - return; - } - node.pattern = rewritePattern(node.pattern, node.flags, { - dotAllFlag: true, - useUnicodeFlag: regex.is(node, "u"), - }); - regex.pullFlag(node, "s"); - }, - }, - }; + feature: "dotAllFlag", + }); }); diff --git a/packages/babel-plugin-transform-dotall-regex/test/fixtures/dotall-regex/with-unicode-property-escape/input.js b/packages/babel-plugin-transform-dotall-regex/test/fixtures/dotall-regex/with-unicode-property-escape/input.js new file mode 100644 index 000000000000..dc74dbc0d615 --- /dev/null +++ b/packages/babel-plugin-transform-dotall-regex/test/fixtures/dotall-regex/with-unicode-property-escape/input.js @@ -0,0 +1,2 @@ +var a = /\p{Unified_Ideograph}./u; +var b = /\p{Unified_Ideograph}./su; diff --git a/packages/babel-plugin-transform-dotall-regex/test/fixtures/dotall-regex/with-unicode-property-escape/options.json b/packages/babel-plugin-transform-dotall-regex/test/fixtures/dotall-regex/with-unicode-property-escape/options.json new file mode 100644 index 000000000000..2078653dce15 --- /dev/null +++ b/packages/babel-plugin-transform-dotall-regex/test/fixtures/dotall-regex/with-unicode-property-escape/options.json @@ -0,0 +1,3 @@ +{ + "plugins": ["transform-dotall-regex", "proposal-unicode-property-regex"] +} diff --git a/packages/babel-plugin-transform-dotall-regex/test/fixtures/dotall-regex/with-unicode-property-escape/output.js b/packages/babel-plugin-transform-dotall-regex/test/fixtures/dotall-regex/with-unicode-property-escape/output.js new file mode 100644 index 000000000000..a8ddf757d926 --- /dev/null +++ b/packages/babel-plugin-transform-dotall-regex/test/fixtures/dotall-regex/with-unicode-property-escape/output.js @@ -0,0 +1,2 @@ +var a = /[\u3400-\u4DB5\u4E00-\u9FEF\uFA0E\uFA0F\uFA11\uFA13\uFA14\uFA1F\uFA21\uFA23\uFA24\uFA27-\uFA29\u{20000}-\u{2A6D6}\u{2A700}-\u{2B734}\u{2B740}-\u{2B81D}\u{2B820}-\u{2CEA1}\u{2CEB0}-\u{2EBE0}][\0-\t\x0B\f\x0E-\u2027\u202A-\u{10FFFF}]/u; +var b = /[\u3400-\u4DB5\u4E00-\u9FEF\uFA0E\uFA0F\uFA11\uFA13\uFA14\uFA1F\uFA21\uFA23\uFA24\uFA27-\uFA29\u{20000}-\u{2A6D6}\u{2A700}-\u{2B734}\u{2B740}-\u{2B81D}\u{2B820}-\u{2CEA1}\u{2CEB0}-\u{2EBE0}][\0-\u{10FFFF}]/u; diff --git a/packages/babel-plugin-transform-function-name/package.json b/packages/babel-plugin-transform-function-name/package.json index 2a03ae1b21ac..c6be0eee3d0a 100644 --- a/packages/babel-plugin-transform-function-name/package.json +++ b/packages/babel-plugin-transform-function-name/package.json @@ -1,6 +1,6 @@ { "name": "@babel/plugin-transform-function-name", - "version": "7.4.4", + "version": "7.7.0", "description": "Apply ES2015 function.name semantics to all functions", "repository": "https://github.com/babel/babel/tree/master/packages/babel-plugin-transform-function-name", "license": "MIT", @@ -12,14 +12,14 @@ "babel-plugin" ], "dependencies": { - "@babel/helper-function-name": "^7.1.0", + "@babel/helper-function-name": "^7.7.0", "@babel/helper-plugin-utils": "^7.0.0" }, "peerDependencies": { "@babel/core": "^7.0.0-0" }, "devDependencies": { - "@babel/core": "^7.4.4", + "@babel/core": "^7.7.0", "@babel/helper-plugin-test-runner": "^7.0.0" } } diff --git a/packages/babel-plugin-transform-function-name/test/fixtures/function-name/export-default-arrow-renaming-module-umd/output.js b/packages/babel-plugin-transform-function-name/test/fixtures/function-name/export-default-arrow-renaming-module-umd/output.js index 318c2544cd52..cd8510701baf 100644 --- a/packages/babel-plugin-transform-function-name/test/fixtures/function-name/export-default-arrow-renaming-module-umd/output.js +++ b/packages/babel-plugin-transform-function-name/test/fixtures/function-name/export-default-arrow-renaming-module-umd/output.js @@ -10,7 +10,7 @@ factory(mod.exports); global.input = mod.exports; } -})(this, function (_exports) { +})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports) { "use strict"; Object.defineProperty(_exports, "__esModule", { diff --git a/packages/babel-plugin-transform-modules-commonjs/package.json b/packages/babel-plugin-transform-modules-commonjs/package.json index e6f010f39412..2b278105db8c 100644 --- a/packages/babel-plugin-transform-modules-commonjs/package.json +++ b/packages/babel-plugin-transform-modules-commonjs/package.json @@ -1,6 +1,6 @@ { "name": "@babel/plugin-transform-modules-commonjs", - "version": "7.6.0", + "version": "7.7.0", "description": "This plugin transforms ES2015 modules to CommonJS", "repository": "https://github.com/babel/babel/tree/master/packages/babel-plugin-transform-modules-commonjs", "license": "MIT", @@ -9,9 +9,9 @@ }, "main": "lib/index.js", "dependencies": { - "@babel/helper-module-transforms": "^7.4.4", + "@babel/helper-module-transforms": "^7.7.0", "@babel/helper-plugin-utils": "^7.0.0", - "@babel/helper-simple-access": "^7.1.0", + "@babel/helper-simple-access": "^7.7.0", "babel-plugin-dynamic-import-node": "^2.3.0" }, "keywords": [ @@ -21,7 +21,7 @@ "@babel/core": "^7.0.0-0" }, "devDependencies": { - "@babel/core": "^7.6.0", + "@babel/core": "^7.7.0", "@babel/helper-plugin-test-runner": "^7.0.0", "@babel/plugin-syntax-object-rest-spread": "^7.2.0" } diff --git a/packages/babel-plugin-transform-modules-commonjs/test/fixtures/misc/copy-getters-setters-star/output.js b/packages/babel-plugin-transform-modules-commonjs/test/fixtures/misc/copy-getters-setters-star/output.js index f17e16f9dacf..015566b41f7a 100644 --- a/packages/babel-plugin-transform-modules-commonjs/test/fixtures/misc/copy-getters-setters-star/output.js +++ b/packages/babel-plugin-transform-modules-commonjs/test/fixtures/misc/copy-getters-setters-star/output.js @@ -11,4 +11,4 @@ exports.foo = foo; function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; } -function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; if (obj != null) { var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } diff --git a/packages/babel-plugin-transform-modules-commonjs/test/fixtures/misc/import-shadowed-assign/input.mjs b/packages/babel-plugin-transform-modules-commonjs/test/fixtures/misc/import-shadowed-assign/input.mjs new file mode 100644 index 000000000000..0ba3bfe4e6bc --- /dev/null +++ b/packages/babel-plugin-transform-modules-commonjs/test/fixtures/misc/import-shadowed-assign/input.mjs @@ -0,0 +1,12 @@ +import { foo } from "x"; + +function f(foo) { + foo = 2; + [foo] = []; + ({ foo } = {}); +} + + +foo = 2; +[foo] = []; +({ foo } = {}); diff --git a/packages/babel-plugin-transform-modules-commonjs/test/fixtures/misc/import-shadowed-assign/output.js b/packages/babel-plugin-transform-modules-commonjs/test/fixtures/misc/import-shadowed-assign/output.js new file mode 100644 index 000000000000..d78aaf7826e6 --- /dev/null +++ b/packages/babel-plugin-transform-modules-commonjs/test/fixtures/misc/import-shadowed-assign/output.js @@ -0,0 +1,23 @@ +"use strict"; + +var _x = require("x"); + +function f(foo) { + foo = 2; + [foo] = []; + ({ + foo + } = {}); +} + +_x.foo = (2, function () { + throw new Error('"' + "foo" + '" is read-only.'); +}()); +[foo] = ([], function () { + throw new Error('"' + "foo" + '" is read-only.'); +}()); +({ + foo +} = ({}, function () { + throw new Error('"' + "foo" + '" is read-only.'); +}())); diff --git a/packages/babel-plugin-transform-modules-systemjs/package.json b/packages/babel-plugin-transform-modules-systemjs/package.json index d827ae959527..381c7ba180a3 100644 --- a/packages/babel-plugin-transform-modules-systemjs/package.json +++ b/packages/babel-plugin-transform-modules-systemjs/package.json @@ -1,6 +1,6 @@ { "name": "@babel/plugin-transform-modules-systemjs", - "version": "7.5.0", + "version": "7.7.0", "description": "This plugin transforms ES2015 modules to SystemJS", "repository": "https://github.com/babel/babel/tree/master/packages/babel-plugin-transform-modules-systemjs", "license": "MIT", @@ -9,7 +9,7 @@ }, "main": "lib/index.js", "dependencies": { - "@babel/helper-hoist-variables": "^7.4.4", + "@babel/helper-hoist-variables": "^7.7.0", "@babel/helper-plugin-utils": "^7.0.0", "babel-plugin-dynamic-import-node": "^2.3.0" }, @@ -20,7 +20,7 @@ "@babel/core": "^7.0.0-0" }, "devDependencies": { - "@babel/core": "^7.5.0", + "@babel/core": "^7.7.0", "@babel/helper-plugin-test-runner": "^7.0.0", "@babel/plugin-syntax-dynamic-import": "^7.2.0" } diff --git a/packages/babel-plugin-transform-modules-systemjs/src/index.js b/packages/babel-plugin-transform-modules-systemjs/src/index.js index 779b76170cdc..c09a438262bc 100644 --- a/packages/babel-plugin-transform-modules-systemjs/src/index.js +++ b/packages/babel-plugin-transform-modules-systemjs/src/index.js @@ -413,6 +413,8 @@ export default declare((api, options) => { path.replaceWithMultiple(nodes); } + } else { + path.remove(); } } } diff --git a/packages/babel-plugin-transform-modules-systemjs/test/fixtures/systemjs/export-named-8/input.mjs b/packages/babel-plugin-transform-modules-systemjs/test/fixtures/systemjs/export-named-8/input.mjs new file mode 100644 index 000000000000..336ce12bb910 --- /dev/null +++ b/packages/babel-plugin-transform-modules-systemjs/test/fixtures/systemjs/export-named-8/input.mjs @@ -0,0 +1 @@ +export {} diff --git a/packages/babel-plugin-transform-modules-systemjs/test/fixtures/systemjs/export-named-8/output.mjs b/packages/babel-plugin-transform-modules-systemjs/test/fixtures/systemjs/export-named-8/output.mjs new file mode 100644 index 000000000000..5ed7cacb99d1 --- /dev/null +++ b/packages/babel-plugin-transform-modules-systemjs/test/fixtures/systemjs/export-named-8/output.mjs @@ -0,0 +1,8 @@ +System.register([], function (_export, _context) { + "use strict"; + + return { + setters: [], + execute: function () {} + }; +}); diff --git a/packages/babel-plugin-transform-modules-umd/package.json b/packages/babel-plugin-transform-modules-umd/package.json index 9dd0f73213e6..8db718dec04f 100644 --- a/packages/babel-plugin-transform-modules-umd/package.json +++ b/packages/babel-plugin-transform-modules-umd/package.json @@ -1,6 +1,6 @@ { "name": "@babel/plugin-transform-modules-umd", - "version": "7.2.0", + "version": "7.7.0", "description": "This plugin transforms ES2015 modules to UMD", "repository": "https://github.com/babel/babel/tree/master/packages/babel-plugin-transform-modules-umd", "license": "MIT", @@ -9,7 +9,7 @@ }, "main": "lib/index.js", "dependencies": { - "@babel/helper-module-transforms": "^7.1.0", + "@babel/helper-module-transforms": "^7.7.0", "@babel/helper-plugin-utils": "^7.0.0" }, "keywords": [ @@ -19,7 +19,7 @@ "@babel/core": "^7.0.0-0" }, "devDependencies": { - "@babel/core": "^7.2.0", + "@babel/core": "^7.7.0", "@babel/helper-plugin-test-runner": "^7.0.0" } } diff --git a/packages/babel-plugin-transform-modules-umd/src/index.js b/packages/babel-plugin-transform-modules-umd/src/index.js index cd8000febb85..87ab37eff91d 100644 --- a/packages/babel-plugin-transform-modules-umd/src/index.js +++ b/packages/babel-plugin-transform-modules-umd/src/index.js @@ -14,7 +14,9 @@ import { types as t, template } from "@babel/core"; const buildPrerequisiteAssignment = template(` GLOBAL_REFERENCE = GLOBAL_REFERENCE || {} `); - +// Note: we avoid comparing typeof results with "object" or "symbol" otherwise +// they will be processed by `transform-typeof-symbol`, which in return could +// cause typeof helper used before declaration const buildWrapper = template(` (function (global, factory) { if (typeof define === "function" && define.amd) { @@ -27,7 +29,11 @@ const buildWrapper = template(` GLOBAL_TO_ASSIGN; } - })(this, function(IMPORT_NAMES) { + })( + typeof globalThis !== "undefined" ? globalThis + : typeof self !== "undefined" ? self + : this, + function(IMPORT_NAMES) { }) `); diff --git a/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/export-default-10/output.js b/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/export-default-10/output.js index f8e0cb66efbf..16cf5dab5b0e 100644 --- a/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/export-default-10/output.js +++ b/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/export-default-10/output.js @@ -10,7 +10,7 @@ factory(mod.exports); global.input = mod.exports; } -})(this, function (_exports) { +})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports) { "use strict"; _exports.__esModule = true; diff --git a/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/export-default-11/output.js b/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/export-default-11/output.js index 44e4e41f1697..43f6f4120ba2 100644 --- a/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/export-default-11/output.js +++ b/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/export-default-11/output.js @@ -10,7 +10,7 @@ factory(mod.exports); global.input = mod.exports; } -})(this, function (_exports) { +})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports) { "use strict"; _exports.__esModule = true; diff --git a/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/export-default-2/output.js b/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/export-default-2/output.js index 690c27a48c25..1eb753f05ea7 100644 --- a/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/export-default-2/output.js +++ b/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/export-default-2/output.js @@ -10,7 +10,7 @@ factory(mod.exports); global.input = mod.exports; } -})(this, function (_exports) { +})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports) { "use strict"; _exports.__esModule = true; diff --git a/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/export-default-3/output.js b/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/export-default-3/output.js index 956a4b228e56..8b28dd6ec87b 100644 --- a/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/export-default-3/output.js +++ b/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/export-default-3/output.js @@ -10,7 +10,7 @@ factory(mod.exports); global.input = mod.exports; } -})(this, function (_exports) { +})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports) { "use strict"; _exports.__esModule = true; diff --git a/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/export-default-4/output.js b/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/export-default-4/output.js index dcc999f2fb2b..d1aa080c8110 100644 --- a/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/export-default-4/output.js +++ b/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/export-default-4/output.js @@ -10,7 +10,7 @@ factory(mod.exports); global.input = mod.exports; } -})(this, function (_exports) { +})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports) { "use strict"; _exports.__esModule = true; diff --git a/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/export-default-5/output.js b/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/export-default-5/output.js index 255345ddc41e..50d6e6ae7234 100644 --- a/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/export-default-5/output.js +++ b/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/export-default-5/output.js @@ -10,7 +10,7 @@ factory(mod.exports); global.input = mod.exports; } -})(this, function (_exports) { +})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports) { "use strict"; _exports.__esModule = true; diff --git a/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/export-default-6/output.js b/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/export-default-6/output.js index c10daf42709d..2e9a39834a8f 100644 --- a/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/export-default-6/output.js +++ b/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/export-default-6/output.js @@ -10,7 +10,7 @@ factory(mod.exports); global.input = mod.exports; } -})(this, function (_exports) { +})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports) { "use strict"; _exports.__esModule = true; diff --git a/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/export-default-7/output.js b/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/export-default-7/output.js index 7cfc99ccd16c..99ed0428f6f9 100644 --- a/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/export-default-7/output.js +++ b/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/export-default-7/output.js @@ -10,7 +10,7 @@ factory(mod.exports); global.input = mod.exports; } -})(this, function (_exports) { +})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports) { "use strict"; _exports.__esModule = true; diff --git a/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/export-default-8/output.js b/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/export-default-8/output.js index 605b6c2762f8..50619c0ab739 100644 --- a/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/export-default-8/output.js +++ b/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/export-default-8/output.js @@ -10,7 +10,7 @@ factory(mod.exports); global.input = mod.exports; } -})(this, function (_exports) { +})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports) { "use strict"; _exports.__esModule = true; diff --git a/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/export-default-9/output.js b/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/export-default-9/output.js index 493509da29c4..78580db2a617 100644 --- a/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/export-default-9/output.js +++ b/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/export-default-9/output.js @@ -10,7 +10,7 @@ factory(mod.exports); global.input = mod.exports; } -})(this, function (_exports) { +})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports) { "use strict"; _exports.__esModule = true; diff --git a/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/export-default/output.js b/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/export-default/output.js index 406ad75ef7dc..005e2f9b8237 100644 --- a/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/export-default/output.js +++ b/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/export-default/output.js @@ -10,7 +10,7 @@ factory(mod.exports); global.input = mod.exports; } -})(this, function (_exports) { +})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports) { "use strict"; _exports.__esModule = true; diff --git a/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/export-from-2/output.js b/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/export-from-2/output.js index b03b7b38d0f8..75e19b01ab38 100644 --- a/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/export-from-2/output.js +++ b/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/export-from-2/output.js @@ -10,7 +10,7 @@ factory(mod.exports, global.foo); global.input = mod.exports; } -})(this, function (_exports, _foo) { +})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports, _foo) { "use strict"; _exports.__esModule = true; diff --git a/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/export-from-3/output.js b/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/export-from-3/output.js index 99cc2cff28f4..d6c735f4b8c8 100644 --- a/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/export-from-3/output.js +++ b/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/export-from-3/output.js @@ -10,7 +10,7 @@ factory(mod.exports, global.foo); global.input = mod.exports; } -})(this, function (_exports, _foo) { +})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports, _foo) { "use strict"; _exports.__esModule = true; diff --git a/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/export-from-4/output.js b/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/export-from-4/output.js index 36925b451778..13cd6c56cf1a 100644 --- a/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/export-from-4/output.js +++ b/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/export-from-4/output.js @@ -10,7 +10,7 @@ factory(mod.exports, global.foo); global.input = mod.exports; } -})(this, function (_exports, _foo) { +})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports, _foo) { "use strict"; _exports.__esModule = true; diff --git a/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/export-from-5/output.js b/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/export-from-5/output.js index eaa85ea93a42..db35ffb83d9e 100644 --- a/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/export-from-5/output.js +++ b/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/export-from-5/output.js @@ -10,7 +10,7 @@ factory(mod.exports, global.foo); global.input = mod.exports; } -})(this, function (_exports, _foo) { +})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports, _foo) { "use strict"; _exports.__esModule = true; diff --git a/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/export-from-6/output.js b/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/export-from-6/output.js index b7d54d8219b9..8405ded47ad5 100644 --- a/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/export-from-6/output.js +++ b/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/export-from-6/output.js @@ -10,7 +10,7 @@ factory(mod.exports, global.foo); global.input = mod.exports; } -})(this, function (_exports, _foo) { +})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports, _foo) { "use strict"; _exports.__esModule = true; diff --git a/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/export-from/output.js b/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/export-from/output.js index cde17ba82168..f200b057fbbf 100644 --- a/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/export-from/output.js +++ b/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/export-from/output.js @@ -10,7 +10,7 @@ factory(mod.exports, global.foo); global.input = mod.exports; } -})(this, function (_exports, _foo) { +})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports, _foo) { "use strict"; _exports.__esModule = true; diff --git a/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/export-named-2/output.js b/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/export-named-2/output.js index 493509da29c4..78580db2a617 100644 --- a/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/export-named-2/output.js +++ b/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/export-named-2/output.js @@ -10,7 +10,7 @@ factory(mod.exports); global.input = mod.exports; } -})(this, function (_exports) { +})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports) { "use strict"; _exports.__esModule = true; diff --git a/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/export-named-3/output.js b/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/export-named-3/output.js index c0e16dfcdfd3..4e96e316480b 100644 --- a/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/export-named-3/output.js +++ b/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/export-named-3/output.js @@ -10,7 +10,7 @@ factory(mod.exports); global.input = mod.exports; } -})(this, function (_exports) { +})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports) { "use strict"; _exports.__esModule = true; diff --git a/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/export-named-4/output.js b/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/export-named-4/output.js index b612eb59ae64..e19d1a5d1fc3 100644 --- a/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/export-named-4/output.js +++ b/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/export-named-4/output.js @@ -10,7 +10,7 @@ factory(mod.exports); global.input = mod.exports; } -})(this, function (_exports) { +})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports) { "use strict"; _exports.__esModule = true; diff --git a/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/export-named-5/output.js b/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/export-named-5/output.js index 37b7013b6631..c9353e2a5bd1 100644 --- a/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/export-named-5/output.js +++ b/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/export-named-5/output.js @@ -10,7 +10,7 @@ factory(mod.exports); global.input = mod.exports; } -})(this, function (_exports) { +})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports) { "use strict"; _exports.__esModule = true; diff --git a/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/export-named/output.js b/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/export-named/output.js index e1e04041f87f..23ff6af10e6e 100644 --- a/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/export-named/output.js +++ b/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/export-named/output.js @@ -10,7 +10,7 @@ factory(mod.exports); global.input = mod.exports; } -})(this, function (_exports) { +})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports) { "use strict"; _exports.__esModule = true; diff --git a/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/exports-variable/output.js b/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/exports-variable/output.js index 5606fe898c1a..d4aeec297660 100644 --- a/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/exports-variable/output.js +++ b/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/exports-variable/output.js @@ -10,7 +10,7 @@ factory(mod.exports); global.input = mod.exports; } -})(this, function (_exports) { +})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports) { "use strict"; _exports.__esModule = true; diff --git a/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/get-module-name-option/output.js b/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/get-module-name-option/output.js index d5c94066201a..bbfb355912b8 100644 --- a/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/get-module-name-option/output.js +++ b/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/get-module-name-option/output.js @@ -10,6 +10,6 @@ factory(); global.myCustomModuleName = mod.exports; } -})(this, function () { +})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function () { "use strict"; }); diff --git a/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/hoist-function-exports/output.js b/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/hoist-function-exports/output.js index 87e3e0226890..640ce3bb776c 100644 --- a/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/hoist-function-exports/output.js +++ b/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/hoist-function-exports/output.js @@ -10,7 +10,7 @@ factory(mod.exports, global.evens); global.input = mod.exports; } -})(this, function (_exports, _evens) { +})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports, _evens) { "use strict"; _exports.__esModule = true; diff --git a/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/imports-default/output.js b/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/imports-default/output.js index bdc895976fd3..71c3133b263f 100644 --- a/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/imports-default/output.js +++ b/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/imports-default/output.js @@ -10,7 +10,7 @@ factory(global.foo); global.input = mod.exports; } -})(this, function (_foo) { +})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_foo) { "use strict"; _foo = babelHelpers.interopRequireDefault(_foo); diff --git a/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/imports-exact-globals-false-with-overrides/output.js b/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/imports-exact-globals-false-with-overrides/output.js index 79531c289ced..c751e3aee868 100644 --- a/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/imports-exact-globals-false-with-overrides/output.js +++ b/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/imports-exact-globals-false-with-overrides/output.js @@ -10,7 +10,7 @@ factory(global.fooBAR, global.fooBAR, global.fizzBuzz); global.input = mod.exports; } -})(this, function (_fooBar, _fooBar2, _fizzbuzz) { +})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_fooBar, _fooBar2, _fizzbuzz) { "use strict"; _fooBar = babelHelpers.interopRequireDefault(_fooBar); diff --git a/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/imports-exact-globals-false/output.js b/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/imports-exact-globals-false/output.js index 72d8bf864d29..5229781b738a 100644 --- a/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/imports-exact-globals-false/output.js +++ b/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/imports-exact-globals-false/output.js @@ -10,7 +10,7 @@ factory(global.fooBar, global.fooBar, global.fizzbuzz); global.input = mod.exports; } -})(this, function (_fooBar, _fooBar2, _fizzbuzz) { +})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_fooBar, _fooBar2, _fizzbuzz) { "use strict"; _fooBar = babelHelpers.interopRequireDefault(_fooBar); diff --git a/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/imports-exact-globals-true-with-overrides/output.js b/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/imports-exact-globals-true-with-overrides/output.js index bd083836e425..54211b04b3c0 100644 --- a/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/imports-exact-globals-true-with-overrides/output.js +++ b/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/imports-exact-globals-true-with-overrides/output.js @@ -10,7 +10,7 @@ factory(global.fooBAR, global.mylib.fooBar, global.fizz.buzz); global.input = mod.exports; } -})(this, function (_fooBar, _fooBar2, _fizzbuzz) { +})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_fooBar, _fooBar2, _fizzbuzz) { "use strict"; _fooBar = babelHelpers.interopRequireDefault(_fooBar); diff --git a/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/imports-exact-globals-true/output.js b/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/imports-exact-globals-true/output.js index c16c74d6d69c..bf4c741e6ce0 100644 --- a/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/imports-exact-globals-true/output.js +++ b/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/imports-exact-globals-true/output.js @@ -10,7 +10,7 @@ factory(global.fooBar, global.mylibFooBar, global.fizzbuzz); global.input = mod.exports; } -})(this, function (_fooBar, _fooBar2, _fizzbuzz) { +})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_fooBar, _fooBar2, _fizzbuzz) { "use strict"; _fooBar = babelHelpers.interopRequireDefault(_fooBar); diff --git a/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/imports-glob/output.js b/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/imports-glob/output.js index 3f403ba8ad4a..be83fe78d33c 100644 --- a/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/imports-glob/output.js +++ b/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/imports-glob/output.js @@ -10,7 +10,7 @@ factory(global.foo); global.input = mod.exports; } -})(this, function (foo) { +})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (foo) { "use strict"; foo = babelHelpers.interopRequireWildcard(foo); diff --git a/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/imports-mixing/output.js b/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/imports-mixing/output.js index f51c2d99aefa..17bf5e1fac30 100644 --- a/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/imports-mixing/output.js +++ b/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/imports-mixing/output.js @@ -10,7 +10,7 @@ factory(global.foo); global.input = mod.exports; } -})(this, function (_foo) { +})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_foo) { "use strict"; _foo = babelHelpers.interopRequireWildcard(_foo); diff --git a/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/imports-named/output.js b/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/imports-named/output.js index d0629b1666d4..d6e7457a2618 100644 --- a/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/imports-named/output.js +++ b/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/imports-named/output.js @@ -10,7 +10,7 @@ factory(global.foo); global.input = mod.exports; } -})(this, function (_foo) { +})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_foo) { "use strict"; _foo.bar; diff --git a/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/imports/output.js b/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/imports/output.js index c625f2ad0f13..5d36f0f1abf6 100644 --- a/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/imports/output.js +++ b/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/imports/output.js @@ -10,6 +10,6 @@ factory(global.foo, global.fooBar, global.fooBar); global.input = mod.exports; } -})(this, function (_foo, _fooBar, _fooBar2) { +})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_foo, _fooBar, _fooBar2) { "use strict"; }); diff --git a/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/module-id-with-overridden-global-in-namespace/output.js b/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/module-id-with-overridden-global-in-namespace/output.js index b1b88602b1d5..06cb04062449 100644 --- a/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/module-id-with-overridden-global-in-namespace/output.js +++ b/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/module-id-with-overridden-global-in-namespace/output.js @@ -11,7 +11,7 @@ global.foo = global.foo || {}; global.foo.bar = mod.exports; } -})(this, function (_exports) { +})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports) { "use strict"; _exports.__esModule = true; diff --git a/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/module-id-with-overridden-global-in-very-nested-namespace/output.js b/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/module-id-with-overridden-global-in-very-nested-namespace/output.js index bcae91ef8031..da053338dc3b 100644 --- a/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/module-id-with-overridden-global-in-very-nested-namespace/output.js +++ b/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/module-id-with-overridden-global-in-very-nested-namespace/output.js @@ -13,7 +13,7 @@ global.foo.bar.baz = global.foo.bar.baz || {}; global.foo.bar.baz.qux = mod.exports; } -})(this, function (_exports) { +})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports) { "use strict"; _exports.__esModule = true; diff --git a/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/module-id-with-overridden-global/output.js b/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/module-id-with-overridden-global/output.js index e643ca1729cf..55f97d820fda 100644 --- a/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/module-id-with-overridden-global/output.js +++ b/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/module-id-with-overridden-global/output.js @@ -10,7 +10,7 @@ factory(mod.exports); global.baz = mod.exports; } -})(this, function (_exports) { +})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports) { "use strict"; _exports.__esModule = true; diff --git a/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/module-id/output.js b/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/module-id/output.js index 2e8e731219b9..2d9c9cd817c0 100644 --- a/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/module-id/output.js +++ b/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/module-id/output.js @@ -10,7 +10,7 @@ factory(); global.MyLib = mod.exports; } -})(this, function () { +})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function () { "use strict"; foobar(); diff --git a/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/module-name-with-overridden-global/output.js b/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/module-name-with-overridden-global/output.js index 516c1e9a10c0..45d0bcb7c75b 100644 --- a/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/module-name-with-overridden-global/output.js +++ b/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/module-name-with-overridden-global/output.js @@ -10,7 +10,7 @@ factory(mod.exports); global.looseModuleNameWithOverriddenGlobalInput = mod.exports; } -})(this, function (_exports) { +})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports) { "use strict"; _exports.__esModule = true; diff --git a/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/module-name/output.js b/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/module-name/output.js index 37b367916622..ec9d725704c7 100644 --- a/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/module-name/output.js +++ b/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/module-name/output.js @@ -10,7 +10,7 @@ factory(); global.looseModuleNameInput = mod.exports; } -})(this, function () { +})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function () { "use strict"; foobar(); diff --git a/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/non-default-imports/output.js b/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/non-default-imports/output.js index a9273b54d4ba..81afa0c2b734 100644 --- a/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/non-default-imports/output.js +++ b/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/non-default-imports/output.js @@ -10,6 +10,6 @@ factory(global.render); global.input = mod.exports; } -})(this, function (_render) { +})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_render) { "use strict"; }); diff --git a/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/override-export-name/output.js b/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/override-export-name/output.js index 406ad75ef7dc..005e2f9b8237 100644 --- a/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/override-export-name/output.js +++ b/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/override-export-name/output.js @@ -10,7 +10,7 @@ factory(mod.exports); global.input = mod.exports; } -})(this, function (_exports) { +})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports) { "use strict"; _exports.__esModule = true; diff --git a/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/override-import-name/output.js b/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/override-import-name/output.js index 21f8cbe8bd64..9a60cc93eeff 100644 --- a/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/override-import-name/output.js +++ b/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/override-import-name/output.js @@ -10,6 +10,6 @@ factory(global.Promise); global.input = mod.exports; } -})(this, function (_es6Promise) { +})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_es6Promise) { "use strict"; }); diff --git a/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/overview/output.js b/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/overview/output.js index b66382de9469..92177358c8c4 100644 --- a/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/overview/output.js +++ b/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/overview/output.js @@ -10,7 +10,7 @@ factory(mod.exports, global.foo, global.fooBar, global.fooBar); global.input = mod.exports; } -})(this, function (_exports, foo2, _fooBar, _fooBar2) { +})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports, foo2, _fooBar, _fooBar2) { "use strict"; _exports.__esModule = true; diff --git a/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/remap/output.js b/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/remap/output.js index 32e24f80c89b..03b4c1258a54 100644 --- a/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/remap/output.js +++ b/packages/babel-plugin-transform-modules-umd/test/fixtures/loose/remap/output.js @@ -10,7 +10,7 @@ factory(mod.exports); global.input = mod.exports; } -})(this, function (_exports) { +})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports) { "use strict"; _exports.__esModule = true; diff --git a/packages/babel-plugin-transform-modules-umd/test/fixtures/regression/4192/output.js b/packages/babel-plugin-transform-modules-umd/test/fixtures/regression/4192/output.js index 83495f9586e8..78689e28938e 100644 --- a/packages/babel-plugin-transform-modules-umd/test/fixtures/regression/4192/output.js +++ b/packages/babel-plugin-transform-modules-umd/test/fixtures/regression/4192/output.js @@ -10,7 +10,7 @@ factory(mod.exports); global.input = mod.exports; } -})(this, function (_exports) { +})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports) { "use strict"; Object.defineProperty(_exports, "__esModule", { diff --git a/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/export-default-10/output.js b/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/export-default-10/output.js index b4d81f7d48c9..96660c937784 100644 --- a/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/export-default-10/output.js +++ b/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/export-default-10/output.js @@ -10,7 +10,7 @@ factory(mod.exports); global.input = mod.exports; } -})(this, function (_exports) { +})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports) { "use strict"; Object.defineProperty(_exports, "__esModule", { diff --git a/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/export-default-11/output.js b/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/export-default-11/output.js index 053cce392d75..670be0b97f02 100644 --- a/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/export-default-11/output.js +++ b/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/export-default-11/output.js @@ -10,7 +10,7 @@ factory(mod.exports); global.input = mod.exports; } -})(this, function (_exports) { +})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports) { "use strict"; Object.defineProperty(_exports, "__esModule", { diff --git a/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/export-default-2/output.js b/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/export-default-2/output.js index 91736c0197c2..ec688671cff5 100644 --- a/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/export-default-2/output.js +++ b/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/export-default-2/output.js @@ -10,7 +10,7 @@ factory(mod.exports); global.input = mod.exports; } -})(this, function (_exports) { +})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports) { "use strict"; Object.defineProperty(_exports, "__esModule", { diff --git a/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/export-default-3/output.js b/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/export-default-3/output.js index 3ca1ff7d7423..b982d97d90da 100644 --- a/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/export-default-3/output.js +++ b/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/export-default-3/output.js @@ -10,7 +10,7 @@ factory(mod.exports); global.input = mod.exports; } -})(this, function (_exports) { +})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports) { "use strict"; Object.defineProperty(_exports, "__esModule", { diff --git a/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/export-default-4/output.js b/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/export-default-4/output.js index 006b7c28772a..e5dafcbe9c01 100644 --- a/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/export-default-4/output.js +++ b/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/export-default-4/output.js @@ -10,7 +10,7 @@ factory(mod.exports); global.input = mod.exports; } -})(this, function (_exports) { +})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports) { "use strict"; Object.defineProperty(_exports, "__esModule", { diff --git a/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/export-default-5/output.js b/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/export-default-5/output.js index e9d30703b26f..b57a16c2680f 100644 --- a/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/export-default-5/output.js +++ b/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/export-default-5/output.js @@ -10,7 +10,7 @@ factory(mod.exports); global.input = mod.exports; } -})(this, function (_exports) { +})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports) { "use strict"; Object.defineProperty(_exports, "__esModule", { diff --git a/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/export-default-6/output.js b/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/export-default-6/output.js index 7fdc39f6adf3..b244eea085de 100644 --- a/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/export-default-6/output.js +++ b/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/export-default-6/output.js @@ -10,7 +10,7 @@ factory(mod.exports); global.input = mod.exports; } -})(this, function (_exports) { +})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports) { "use strict"; Object.defineProperty(_exports, "__esModule", { diff --git a/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/export-default-7/output.js b/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/export-default-7/output.js index 15cad508a21a..7a36751246c2 100644 --- a/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/export-default-7/output.js +++ b/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/export-default-7/output.js @@ -10,7 +10,7 @@ factory(mod.exports); global.input = mod.exports; } -})(this, function (_exports) { +})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports) { "use strict"; Object.defineProperty(_exports, "__esModule", { diff --git a/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/export-default-8/output.js b/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/export-default-8/output.js index c92a85338f1b..260883e265f2 100644 --- a/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/export-default-8/output.js +++ b/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/export-default-8/output.js @@ -10,7 +10,7 @@ factory(mod.exports); global.input = mod.exports; } -})(this, function (_exports) { +})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports) { "use strict"; Object.defineProperty(_exports, "__esModule", { diff --git a/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/export-default-9/output.js b/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/export-default-9/output.js index b6a052ac6671..20b42c4faae2 100644 --- a/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/export-default-9/output.js +++ b/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/export-default-9/output.js @@ -10,7 +10,7 @@ factory(mod.exports); global.input = mod.exports; } -})(this, function (_exports) { +})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports) { "use strict"; Object.defineProperty(_exports, "__esModule", { diff --git a/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/export-default/output.js b/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/export-default/output.js index 3f5a188475c0..127234bed6d4 100644 --- a/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/export-default/output.js +++ b/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/export-default/output.js @@ -10,7 +10,7 @@ factory(mod.exports); global.input = mod.exports; } -})(this, function (_exports) { +})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports) { "use strict"; Object.defineProperty(_exports, "__esModule", { diff --git a/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/export-from-2/output.js b/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/export-from-2/output.js index fe946f300c70..3580d4361beb 100644 --- a/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/export-from-2/output.js +++ b/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/export-from-2/output.js @@ -10,7 +10,7 @@ factory(mod.exports, global.foo); global.input = mod.exports; } -})(this, function (_exports, _foo) { +})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports, _foo) { "use strict"; Object.defineProperty(_exports, "__esModule", { diff --git a/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/export-from-3/output.js b/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/export-from-3/output.js index 126e1be461b0..033dc64eadbe 100644 --- a/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/export-from-3/output.js +++ b/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/export-from-3/output.js @@ -10,7 +10,7 @@ factory(mod.exports, global.foo); global.input = mod.exports; } -})(this, function (_exports, _foo) { +})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports, _foo) { "use strict"; Object.defineProperty(_exports, "__esModule", { diff --git a/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/export-from-4/output.js b/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/export-from-4/output.js index dc6f562b4e3a..1a2577046f54 100644 --- a/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/export-from-4/output.js +++ b/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/export-from-4/output.js @@ -10,7 +10,7 @@ factory(mod.exports, global.foo); global.input = mod.exports; } -})(this, function (_exports, _foo) { +})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports, _foo) { "use strict"; Object.defineProperty(_exports, "__esModule", { diff --git a/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/export-from-5/output.js b/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/export-from-5/output.js index f0381a2ddba0..fd5bfbed33af 100644 --- a/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/export-from-5/output.js +++ b/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/export-from-5/output.js @@ -10,7 +10,7 @@ factory(mod.exports, global.foo); global.input = mod.exports; } -})(this, function (_exports, _foo) { +})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports, _foo) { "use strict"; Object.defineProperty(_exports, "__esModule", { diff --git a/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/export-from-6/output.js b/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/export-from-6/output.js index ec9180133584..46e4a2b27dd2 100644 --- a/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/export-from-6/output.js +++ b/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/export-from-6/output.js @@ -10,7 +10,7 @@ factory(mod.exports, global.foo); global.input = mod.exports; } -})(this, function (_exports, _foo) { +})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports, _foo) { "use strict"; Object.defineProperty(_exports, "__esModule", { diff --git a/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/export-from/output.js b/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/export-from/output.js index 116bc257736a..cda318717a4c 100644 --- a/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/export-from/output.js +++ b/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/export-from/output.js @@ -10,7 +10,7 @@ factory(mod.exports, global.foo); global.input = mod.exports; } -})(this, function (_exports, _foo) { +})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports, _foo) { "use strict"; Object.defineProperty(_exports, "__esModule", { diff --git a/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/export-named-2/output.js b/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/export-named-2/output.js index b6a052ac6671..20b42c4faae2 100644 --- a/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/export-named-2/output.js +++ b/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/export-named-2/output.js @@ -10,7 +10,7 @@ factory(mod.exports); global.input = mod.exports; } -})(this, function (_exports) { +})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports) { "use strict"; Object.defineProperty(_exports, "__esModule", { diff --git a/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/export-named-3/output.js b/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/export-named-3/output.js index 7263e5f91f48..9b45a5008053 100644 --- a/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/export-named-3/output.js +++ b/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/export-named-3/output.js @@ -10,7 +10,7 @@ factory(mod.exports); global.input = mod.exports; } -})(this, function (_exports) { +})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports) { "use strict"; Object.defineProperty(_exports, "__esModule", { diff --git a/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/export-named-4/output.js b/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/export-named-4/output.js index 14c4273fdc06..096434af4d2e 100644 --- a/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/export-named-4/output.js +++ b/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/export-named-4/output.js @@ -10,7 +10,7 @@ factory(mod.exports); global.input = mod.exports; } -})(this, function (_exports) { +})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports) { "use strict"; Object.defineProperty(_exports, "__esModule", { diff --git a/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/export-named-5/output.js b/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/export-named-5/output.js index 0ac1f5a990cc..6966fb097e00 100644 --- a/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/export-named-5/output.js +++ b/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/export-named-5/output.js @@ -10,7 +10,7 @@ factory(mod.exports); global.input = mod.exports; } -})(this, function (_exports) { +})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports) { "use strict"; Object.defineProperty(_exports, "__esModule", { diff --git a/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/export-named/output.js b/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/export-named/output.js index 009aedbfef27..1062cc37298a 100644 --- a/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/export-named/output.js +++ b/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/export-named/output.js @@ -10,7 +10,7 @@ factory(mod.exports); global.input = mod.exports; } -})(this, function (_exports) { +})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports) { "use strict"; Object.defineProperty(_exports, "__esModule", { diff --git a/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/exports-variable/output.js b/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/exports-variable/output.js index 90292c4609f7..9ad3023932a7 100644 --- a/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/exports-variable/output.js +++ b/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/exports-variable/output.js @@ -10,7 +10,7 @@ factory(mod.exports); global.input = mod.exports; } -})(this, function (_exports) { +})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports) { "use strict"; Object.defineProperty(_exports, "__esModule", { diff --git a/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/get-module-name-option/output.js b/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/get-module-name-option/output.js index d5c94066201a..bbfb355912b8 100644 --- a/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/get-module-name-option/output.js +++ b/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/get-module-name-option/output.js @@ -10,6 +10,6 @@ factory(); global.myCustomModuleName = mod.exports; } -})(this, function () { +})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function () { "use strict"; }); diff --git a/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/hoist-function-exports/output.js b/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/hoist-function-exports/output.js index f5427d448fd1..f6448a39188b 100644 --- a/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/hoist-function-exports/output.js +++ b/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/hoist-function-exports/output.js @@ -10,7 +10,7 @@ factory(mod.exports, global.evens); global.input = mod.exports; } -})(this, function (_exports, _evens) { +})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports, _evens) { "use strict"; Object.defineProperty(_exports, "__esModule", { diff --git a/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/imports-default/output.js b/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/imports-default/output.js index bdc895976fd3..71c3133b263f 100644 --- a/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/imports-default/output.js +++ b/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/imports-default/output.js @@ -10,7 +10,7 @@ factory(global.foo); global.input = mod.exports; } -})(this, function (_foo) { +})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_foo) { "use strict"; _foo = babelHelpers.interopRequireDefault(_foo); diff --git a/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/imports-exact-globals-false-with-overrides/output.js b/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/imports-exact-globals-false-with-overrides/output.js index 79531c289ced..c751e3aee868 100644 --- a/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/imports-exact-globals-false-with-overrides/output.js +++ b/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/imports-exact-globals-false-with-overrides/output.js @@ -10,7 +10,7 @@ factory(global.fooBAR, global.fooBAR, global.fizzBuzz); global.input = mod.exports; } -})(this, function (_fooBar, _fooBar2, _fizzbuzz) { +})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_fooBar, _fooBar2, _fizzbuzz) { "use strict"; _fooBar = babelHelpers.interopRequireDefault(_fooBar); diff --git a/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/imports-exact-globals-false/output.js b/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/imports-exact-globals-false/output.js index 72d8bf864d29..5229781b738a 100644 --- a/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/imports-exact-globals-false/output.js +++ b/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/imports-exact-globals-false/output.js @@ -10,7 +10,7 @@ factory(global.fooBar, global.fooBar, global.fizzbuzz); global.input = mod.exports; } -})(this, function (_fooBar, _fooBar2, _fizzbuzz) { +})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_fooBar, _fooBar2, _fizzbuzz) { "use strict"; _fooBar = babelHelpers.interopRequireDefault(_fooBar); diff --git a/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/imports-exact-globals-true-with-overrides/output.js b/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/imports-exact-globals-true-with-overrides/output.js index bd083836e425..54211b04b3c0 100644 --- a/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/imports-exact-globals-true-with-overrides/output.js +++ b/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/imports-exact-globals-true-with-overrides/output.js @@ -10,7 +10,7 @@ factory(global.fooBAR, global.mylib.fooBar, global.fizz.buzz); global.input = mod.exports; } -})(this, function (_fooBar, _fooBar2, _fizzbuzz) { +})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_fooBar, _fooBar2, _fizzbuzz) { "use strict"; _fooBar = babelHelpers.interopRequireDefault(_fooBar); diff --git a/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/imports-exact-globals-true/output.js b/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/imports-exact-globals-true/output.js index c16c74d6d69c..bf4c741e6ce0 100644 --- a/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/imports-exact-globals-true/output.js +++ b/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/imports-exact-globals-true/output.js @@ -10,7 +10,7 @@ factory(global.fooBar, global.mylibFooBar, global.fizzbuzz); global.input = mod.exports; } -})(this, function (_fooBar, _fooBar2, _fizzbuzz) { +})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_fooBar, _fooBar2, _fizzbuzz) { "use strict"; _fooBar = babelHelpers.interopRequireDefault(_fooBar); diff --git a/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/imports-glob/output.js b/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/imports-glob/output.js index 3f403ba8ad4a..be83fe78d33c 100644 --- a/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/imports-glob/output.js +++ b/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/imports-glob/output.js @@ -10,7 +10,7 @@ factory(global.foo); global.input = mod.exports; } -})(this, function (foo) { +})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (foo) { "use strict"; foo = babelHelpers.interopRequireWildcard(foo); diff --git a/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/imports-mixing/output.js b/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/imports-mixing/output.js index f51c2d99aefa..17bf5e1fac30 100644 --- a/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/imports-mixing/output.js +++ b/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/imports-mixing/output.js @@ -10,7 +10,7 @@ factory(global.foo); global.input = mod.exports; } -})(this, function (_foo) { +})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_foo) { "use strict"; _foo = babelHelpers.interopRequireWildcard(_foo); diff --git a/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/imports-named/output.js b/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/imports-named/output.js index d0629b1666d4..d6e7457a2618 100644 --- a/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/imports-named/output.js +++ b/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/imports-named/output.js @@ -10,7 +10,7 @@ factory(global.foo); global.input = mod.exports; } -})(this, function (_foo) { +})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_foo) { "use strict"; _foo.bar; diff --git a/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/imports/output.js b/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/imports/output.js index c625f2ad0f13..5d36f0f1abf6 100644 --- a/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/imports/output.js +++ b/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/imports/output.js @@ -10,6 +10,6 @@ factory(global.foo, global.fooBar, global.fooBar); global.input = mod.exports; } -})(this, function (_foo, _fooBar, _fooBar2) { +})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_foo, _fooBar, _fooBar2) { "use strict"; }); diff --git a/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/module-id-with-overridden-global-in-namespace/output.js b/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/module-id-with-overridden-global-in-namespace/output.js index 3f43c9478122..db961cbcdf89 100644 --- a/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/module-id-with-overridden-global-in-namespace/output.js +++ b/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/module-id-with-overridden-global-in-namespace/output.js @@ -11,7 +11,7 @@ global.foo = global.foo || {}; global.foo.bar = mod.exports; } -})(this, function (_exports) { +})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports) { "use strict"; Object.defineProperty(_exports, "__esModule", { diff --git a/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/module-id-with-overridden-global-in-very-nested-namespace/output.js b/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/module-id-with-overridden-global-in-very-nested-namespace/output.js index 1ddcae34725f..c3bd11fb105c 100644 --- a/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/module-id-with-overridden-global-in-very-nested-namespace/output.js +++ b/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/module-id-with-overridden-global-in-very-nested-namespace/output.js @@ -13,7 +13,7 @@ global.foo.bar.baz = global.foo.bar.baz || {}; global.foo.bar.baz.qux = mod.exports; } -})(this, function (_exports) { +})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports) { "use strict"; Object.defineProperty(_exports, "__esModule", { diff --git a/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/module-id-with-overridden-global/output.js b/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/module-id-with-overridden-global/output.js index a9feedf65627..dd85a01acf7d 100644 --- a/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/module-id-with-overridden-global/output.js +++ b/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/module-id-with-overridden-global/output.js @@ -10,7 +10,7 @@ factory(mod.exports); global.baz = mod.exports; } -})(this, function (_exports) { +})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports) { "use strict"; Object.defineProperty(_exports, "__esModule", { diff --git a/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/module-id/output.js b/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/module-id/output.js index 2e8e731219b9..2d9c9cd817c0 100644 --- a/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/module-id/output.js +++ b/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/module-id/output.js @@ -10,7 +10,7 @@ factory(); global.MyLib = mod.exports; } -})(this, function () { +})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function () { "use strict"; foobar(); diff --git a/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/module-name-with-overridden-global/output.js b/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/module-name-with-overridden-global/output.js index b17d582429ed..e6186c39d886 100644 --- a/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/module-name-with-overridden-global/output.js +++ b/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/module-name-with-overridden-global/output.js @@ -10,7 +10,7 @@ factory(mod.exports); global.umdModuleNameWithOverriddenGlobalInput = mod.exports; } -})(this, function (_exports) { +})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports) { "use strict"; Object.defineProperty(_exports, "__esModule", { diff --git a/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/module-name/output.js b/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/module-name/output.js index 3967f520001c..e85460f205bb 100644 --- a/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/module-name/output.js +++ b/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/module-name/output.js @@ -10,7 +10,7 @@ factory(); global.umdModuleNameInput = mod.exports; } -})(this, function () { +})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function () { "use strict"; foobar(); diff --git a/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/non-default-imports/output.js b/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/non-default-imports/output.js index a9273b54d4ba..81afa0c2b734 100644 --- a/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/non-default-imports/output.js +++ b/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/non-default-imports/output.js @@ -10,6 +10,6 @@ factory(global.render); global.input = mod.exports; } -})(this, function (_render) { +})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_render) { "use strict"; }); diff --git a/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/override-export-name/output.js b/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/override-export-name/output.js index 3f5a188475c0..127234bed6d4 100644 --- a/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/override-export-name/output.js +++ b/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/override-export-name/output.js @@ -10,7 +10,7 @@ factory(mod.exports); global.input = mod.exports; } -})(this, function (_exports) { +})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports) { "use strict"; Object.defineProperty(_exports, "__esModule", { diff --git a/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/override-import-name/output.js b/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/override-import-name/output.js index 21f8cbe8bd64..9a60cc93eeff 100644 --- a/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/override-import-name/output.js +++ b/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/override-import-name/output.js @@ -10,6 +10,6 @@ factory(global.Promise); global.input = mod.exports; } -})(this, function (_es6Promise) { +})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_es6Promise) { "use strict"; }); diff --git a/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/overview/output.js b/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/overview/output.js index e60dd5dcb0e2..294904dbbd39 100644 --- a/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/overview/output.js +++ b/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/overview/output.js @@ -10,7 +10,7 @@ factory(mod.exports, global.foo, global.fooBar, global.fooBar); global.input = mod.exports; } -})(this, function (_exports, foo2, _fooBar, _fooBar2) { +})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports, foo2, _fooBar, _fooBar2) { "use strict"; Object.defineProperty(_exports, "__esModule", { diff --git a/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/remap/output.js b/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/remap/output.js index e5d904ca9981..33c36e34dc22 100644 --- a/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/remap/output.js +++ b/packages/babel-plugin-transform-modules-umd/test/fixtures/umd/remap/output.js @@ -10,7 +10,7 @@ factory(mod.exports); global.input = mod.exports; } -})(this, function (_exports) { +})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports) { "use strict"; Object.defineProperty(_exports, "__esModule", { diff --git a/packages/babel-plugin-transform-named-capturing-groups-regex/package.json b/packages/babel-plugin-transform-named-capturing-groups-regex/package.json index 679aa4396f52..8186a98c0685 100644 --- a/packages/babel-plugin-transform-named-capturing-groups-regex/package.json +++ b/packages/babel-plugin-transform-named-capturing-groups-regex/package.json @@ -1,6 +1,6 @@ { "name": "@babel/plugin-transform-named-capturing-groups-regex", - "version": "7.6.3", + "version": "7.7.0", "description": "Compile regular expressions using named groups to ES5.", "homepage": "https://babeljs.io/", "license": "MIT", @@ -21,13 +21,13 @@ }, "bugs": "https://github.com/babel/babel/issues", "dependencies": { - "regexpu-core": "^4.6.0" + "@babel/helper-create-regexp-features-plugin": "^7.7.0" }, "peerDependencies": { "@babel/core": "^7.0.0" }, "devDependencies": { - "@babel/core": "^7.6.3", + "@babel/core": "^7.7.0", "@babel/helper-plugin-test-runner": "^7.0.0", "core-js": "^3.2.1", "core-js-pure": "^3.2.1" diff --git a/packages/babel-plugin-transform-named-capturing-groups-regex/src/index.js b/packages/babel-plugin-transform-named-capturing-groups-regex/src/index.js index 148da9e99a55..2cc0193310fd 100644 --- a/packages/babel-plugin-transform-named-capturing-groups-regex/src/index.js +++ b/packages/babel-plugin-transform-named-capturing-groups-regex/src/index.js @@ -1,56 +1,15 @@ -import rewritePattern from "regexpu-core"; +/* eslint-disable @babel/development/plugin-name */ +import { createRegExpFeaturePlugin } from "@babel/helper-create-regexp-features-plugin"; -export default function({ types: t }, options) { +export default function(core, options) { const { runtime = true } = options; if (typeof runtime !== "boolean") { throw new Error("The 'runtime' option must be boolean"); } - return { + return createRegExpFeaturePlugin({ name: "transform-named-capturing-groups-regex", - - visitor: { - RegExpLiteral(path) { - const node = path.node; - if (!/\(\?<(?![=!])/.test(node.pattern)) { - // Return early if there are no named groups. - // The .indexOf check may have false positives (e.g. /\(? 0) { - node.pattern = result; - - if (runtime && !isRegExpTest(path)) { - path.replaceWith( - t.callExpression(this.addHelper("wrapRegExp"), [ - node, - t.valueToNode(namedCapturingGroups), - ]), - ); - } - } - }, - }, - }; -} - -function isRegExpTest(path) { - return ( - path.parentPath.isMemberExpression({ - object: path.node, - computed: false, - }) && path.parentPath.get("property").isIdentifier({ name: "test" }) - ); + feature: "namedCaptureGroups", + options: { runtime }, + }); } diff --git a/packages/babel-plugin-transform-named-capturing-groups-regex/test/fixtures/runtime/issue-10601/exec.js b/packages/babel-plugin-transform-named-capturing-groups-regex/test/fixtures/runtime/issue-10601/exec.js new file mode 100644 index 000000000000..21136a48f1ac --- /dev/null +++ b/packages/babel-plugin-transform-named-capturing-groups-regex/test/fixtures/runtime/issue-10601/exec.js @@ -0,0 +1,7 @@ +const regex = /<(?\d)+>.*?<\/\k>/su; + +const result = regex.exec('<0>xxx\nyyy'); + +expect(result.groups).toEqual({ + tag: "0" +}); diff --git a/packages/babel-plugin-transform-named-capturing-groups-regex/test/fixtures/runtime/issue-10601/options.json b/packages/babel-plugin-transform-named-capturing-groups-regex/test/fixtures/runtime/issue-10601/options.json new file mode 100644 index 000000000000..2454c2169cf8 --- /dev/null +++ b/packages/babel-plugin-transform-named-capturing-groups-regex/test/fixtures/runtime/issue-10601/options.json @@ -0,0 +1,3 @@ +{ + "minNodeVersion": "8.0.0" +} diff --git a/packages/babel-plugin-transform-named-capturing-groups-regex/test/fixtures/wrapper/looks-like-a-group-unicode/input.js b/packages/babel-plugin-transform-named-capturing-groups-regex/test/fixtures/wrapper/looks-like-a-group-unicode/input.js new file mode 100644 index 000000000000..00a7c78b9344 --- /dev/null +++ b/packages/babel-plugin-transform-named-capturing-groups-regex/test/fixtures/wrapper/looks-like-a-group-unicode/input.js @@ -0,0 +1 @@ +/no-groups-\(?looks\)\u{10000}/u; diff --git a/packages/babel-plugin-transform-named-capturing-groups-regex/test/fixtures/wrapper/looks-like-a-group-unicode/options.json b/packages/babel-plugin-transform-named-capturing-groups-regex/test/fixtures/wrapper/looks-like-a-group-unicode/options.json new file mode 100644 index 000000000000..1832df9cd6ad --- /dev/null +++ b/packages/babel-plugin-transform-named-capturing-groups-regex/test/fixtures/wrapper/looks-like-a-group-unicode/options.json @@ -0,0 +1,7 @@ +{ + "plugins": [ + ["external-helpers", { "helperVersion": "7.1000.0" }], + "transform-named-capturing-groups-regex", + "transform-unicode-regex" + ] +} diff --git a/packages/babel-plugin-transform-named-capturing-groups-regex/test/fixtures/wrapper/looks-like-a-group-unicode/output.js b/packages/babel-plugin-transform-named-capturing-groups-regex/test/fixtures/wrapper/looks-like-a-group-unicode/output.js new file mode 100644 index 000000000000..af299f8fceaf --- /dev/null +++ b/packages/babel-plugin-transform-named-capturing-groups-regex/test/fixtures/wrapper/looks-like-a-group-unicode/output.js @@ -0,0 +1 @@ +/no\x2Dgroups\x2D\(?looks\)(?:\uD800\uDC00)/; diff --git a/packages/babel-plugin-transform-named-capturing-groups-regex/test/fixtures/wrapper/looks-like-a-group/output.js b/packages/babel-plugin-transform-named-capturing-groups-regex/test/fixtures/wrapper/looks-like-a-group/output.js index 4c55ef0dbe17..6fe7c2ef533c 100644 --- a/packages/babel-plugin-transform-named-capturing-groups-regex/test/fixtures/wrapper/looks-like-a-group/output.js +++ b/packages/babel-plugin-transform-named-capturing-groups-regex/test/fixtures/wrapper/looks-like-a-group/output.js @@ -1 +1 @@ -/no-groups-\(?looks\)/; +/no\x2Dgroups\x2D\(?looks\)/; diff --git a/packages/babel-plugin-transform-react-jsx/package.json b/packages/babel-plugin-transform-react-jsx/package.json index 5af70957b122..a3c3b36d70e1 100644 --- a/packages/babel-plugin-transform-react-jsx/package.json +++ b/packages/babel-plugin-transform-react-jsx/package.json @@ -1,6 +1,6 @@ { "name": "@babel/plugin-transform-react-jsx", - "version": "7.3.0", + "version": "7.7.0", "description": "Turn JSX into React function calls", "repository": "https://github.com/babel/babel/tree/master/packages/babel-plugin-transform-react-jsx", "license": "MIT", @@ -12,7 +12,7 @@ "babel-plugin" ], "dependencies": { - "@babel/helper-builder-react-jsx": "^7.3.0", + "@babel/helper-builder-react-jsx": "^7.7.0", "@babel/helper-plugin-utils": "^7.0.0", "@babel/plugin-syntax-jsx": "^7.2.0" }, @@ -20,7 +20,7 @@ "@babel/core": "^7.0.0-0" }, "devDependencies": { - "@babel/core": "^7.2.0", + "@babel/core": "^7.7.0", "@babel/helper-plugin-test-runner": "^7.0.0" } } diff --git a/packages/babel-plugin-transform-react-jsx/test/fixtures/useSpread/assignment-invalid-option/input.js b/packages/babel-plugin-transform-react-jsx/test/fixtures/useSpread/assignment-invalid-option/input.js new file mode 100644 index 000000000000..4caacb6aa17d --- /dev/null +++ b/packages/babel-plugin-transform-react-jsx/test/fixtures/useSpread/assignment-invalid-option/input.js @@ -0,0 +1 @@ +var div = diff --git a/packages/babel-plugin-transform-react-jsx/test/fixtures/useSpread/assignment-invalid-option/options.json b/packages/babel-plugin-transform-react-jsx/test/fixtures/useSpread/assignment-invalid-option/options.json new file mode 100644 index 000000000000..ff6406c9a4e2 --- /dev/null +++ b/packages/babel-plugin-transform-react-jsx/test/fixtures/useSpread/assignment-invalid-option/options.json @@ -0,0 +1,4 @@ +{ + "plugins": [["transform-react-jsx", { "useSpread": 0 }]], + "throws": "transform-react-jsx currently only accepts a boolean option for useSpread (defaults to false)" +} diff --git a/packages/babel-plugin-transform-react-jsx/test/fixtures/useSpread/assignment-use-builtin/input.js b/packages/babel-plugin-transform-react-jsx/test/fixtures/useSpread/assignment-use-builtin/input.js new file mode 100644 index 000000000000..4caacb6aa17d --- /dev/null +++ b/packages/babel-plugin-transform-react-jsx/test/fixtures/useSpread/assignment-use-builtin/input.js @@ -0,0 +1 @@ +var div = diff --git a/packages/babel-plugin-transform-react-jsx/test/fixtures/useSpread/assignment-use-builtin/options.json b/packages/babel-plugin-transform-react-jsx/test/fixtures/useSpread/assignment-use-builtin/options.json new file mode 100644 index 000000000000..eab6051daa03 --- /dev/null +++ b/packages/babel-plugin-transform-react-jsx/test/fixtures/useSpread/assignment-use-builtin/options.json @@ -0,0 +1,6 @@ +{ + "plugins": [ + ["transform-react-jsx", { "useSpread": true, "useBuiltIns": true }] + ], + "throws": "transform-react-jsx currently only accepts useBuiltIns or useSpread but not both" +} diff --git a/packages/babel-plugin-transform-react-jsx/test/fixtures/useSpread/assignment/input.js b/packages/babel-plugin-transform-react-jsx/test/fixtures/useSpread/assignment/input.js new file mode 100644 index 000000000000..4caacb6aa17d --- /dev/null +++ b/packages/babel-plugin-transform-react-jsx/test/fixtures/useSpread/assignment/input.js @@ -0,0 +1 @@ +var div = diff --git a/packages/babel-plugin-transform-react-jsx/test/fixtures/useSpread/assignment/output.js b/packages/babel-plugin-transform-react-jsx/test/fixtures/useSpread/assignment/output.js new file mode 100644 index 000000000000..6d3c49132173 --- /dev/null +++ b/packages/babel-plugin-transform-react-jsx/test/fixtures/useSpread/assignment/output.js @@ -0,0 +1,3 @@ +var div = React.createElement(Component, { ...props, + foo: "bar" +}); diff --git a/packages/babel-plugin-transform-react-jsx/test/fixtures/useSpread/options.json b/packages/babel-plugin-transform-react-jsx/test/fixtures/useSpread/options.json new file mode 100644 index 000000000000..7e0d5fcba0f3 --- /dev/null +++ b/packages/babel-plugin-transform-react-jsx/test/fixtures/useSpread/options.json @@ -0,0 +1,3 @@ +{ + "plugins": [["transform-react-jsx", { "useSpread": true }]] +} diff --git a/packages/babel-plugin-transform-regenerator/package.json b/packages/babel-plugin-transform-regenerator/package.json index 9dbdaa4c6c7c..503edd243e8a 100644 --- a/packages/babel-plugin-transform-regenerator/package.json +++ b/packages/babel-plugin-transform-regenerator/package.json @@ -2,7 +2,7 @@ "name": "@babel/plugin-transform-regenerator", "author": "Ben Newman ", "description": "Explode async and generator functions into a state machine.", - "version": "7.4.5", + "version": "7.7.0", "homepage": "https://github.com/babel/babel/tree/master/packages/babel-plugin-transform-regenerator", "repository": "https://github.com/babel/babel/tree/master/packages/babel-plugin-transform-regenerator", "main": "lib/index.js", @@ -17,7 +17,7 @@ "@babel/core": "^7.0.0-0" }, "devDependencies": { - "@babel/core": "^7.4.5", + "@babel/core": "^7.7.0", "@babel/helper-plugin-test-runner": "^7.0.0" } } diff --git a/packages/babel-plugin-transform-regenerator/test/fixtures/regression/4219/output.js b/packages/babel-plugin-transform-regenerator/test/fixtures/regression/4219/output.js index 0b2d02f3770d..a3b8fd1f26c4 100644 --- a/packages/babel-plugin-transform-regenerator/test/fixtures/regression/4219/output.js +++ b/packages/babel-plugin-transform-regenerator/test/fixtures/regression/4219/output.js @@ -1,26 +1,17 @@ -function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } } - -function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; } - function test(fn) { - return ( - /*#__PURE__*/ - _asyncToGenerator( - /*#__PURE__*/ - regeneratorRuntime.mark(function _callee() { - var _args = arguments; - return regeneratorRuntime.wrap(function _callee$(_context) { - while (1) { - switch (_context.prev = _context.next) { - case 0: - return _context.abrupt("return", fn.apply(void 0, _args)); + return function _callee() { + var _args = arguments; + return regeneratorRuntime.async(function _callee$(_context) { + while (1) { + switch (_context.prev = _context.next) { + case 0: + return _context.abrupt("return", fn.apply(void 0, _args)); - case 1: - case "end": - return _context.stop(); - } + case 1: + case "end": + return _context.stop(); } - }, _callee); - })) - ); + } + }); + }; } diff --git a/packages/babel-plugin-transform-typescript/package.json b/packages/babel-plugin-transform-typescript/package.json index c685bcda9077..abe6f25e2b07 100644 --- a/packages/babel-plugin-transform-typescript/package.json +++ b/packages/babel-plugin-transform-typescript/package.json @@ -1,6 +1,6 @@ { "name": "@babel/plugin-transform-typescript", - "version": "7.6.3", + "version": "7.7.2", "description": "Transform TypeScript into ES.next", "repository": "https://github.com/babel/babel/tree/master/packages/babel-plugin-transform-typescript", "license": "MIT", @@ -13,7 +13,7 @@ "typescript" ], "dependencies": { - "@babel/helper-create-class-features-plugin": "^7.6.0", + "@babel/helper-create-class-features-plugin": "^7.7.0", "@babel/helper-plugin-utils": "^7.0.0", "@babel/plugin-syntax-typescript": "^7.2.0" }, @@ -21,7 +21,7 @@ "@babel/core": "^7.0.0-0" }, "devDependencies": { - "@babel/core": "^7.6.3", + "@babel/core": "^7.7.2", "@babel/helper-plugin-test-runner": "^7.0.0" } } diff --git a/packages/babel-plugin-transform-typescript/src/enum.js b/packages/babel-plugin-transform-typescript/src/enum.js index 11c7b5376d83..3b604e2e8fab 100644 --- a/packages/babel-plugin-transform-typescript/src/enum.js +++ b/packages/babel-plugin-transform-typescript/src/enum.js @@ -144,13 +144,12 @@ function evaluate( expr, seen: PreviousEnumMembers, ): number | string | typeof undefined { - if (expr.type === "StringLiteral") { - return expr.value; - } return evalConstant(expr); function evalConstant(expr): number | typeof undefined { switch (expr.type) { + case "StringLiteral": + return expr.value; case "UnaryExpression": return evalUnaryExpression(expr); case "BinaryExpression": @@ -161,6 +160,11 @@ function evaluate( return evalConstant(expr.expression); case "Identifier": return seen[expr.name]; + case "TemplateLiteral": + if (expr.quasis.length === 1) { + return expr.quasis[0].value.cooked; + } + /* falls through */ default: return undefined; } diff --git a/packages/babel-plugin-transform-typescript/src/index.js b/packages/babel-plugin-transform-typescript/src/index.js index c89e2dbe8185..97b23b454503 100644 --- a/packages/babel-plugin-transform-typescript/src/index.js +++ b/packages/babel-plugin-transform-typescript/src/index.js @@ -44,11 +44,95 @@ function registerGlobalType(programScope, name) { } export default declare( - (api, { jsxPragma = "React", allowNamespaces = false }) => { + ( + api, + { + jsxPragma = "React", + allowNamespaces = false, + allowDeclareFields = false, + }, + ) => { api.assertVersion(7); const JSX_ANNOTATION_REGEX = /\*?\s*@jsx\s+([^\s]+)/; + const classMemberVisitors = { + field(path) { + const { node } = path; + + if (!allowDeclareFields && node.declare) { + throw path.buildCodeFrameError( + `The 'declare' modifier is only allowed when the 'allowDeclareFields' option of ` + + `@babel/plugin-transform-typescript or @babel/preset-typescript is enabled.`, + ); + } + if (node.definite || node.declare) { + if (node.value) { + throw path.buildCodeFrameError( + `Definietly assigned fields and fields with the 'declare' modifier cannot` + + ` be initialized here, but only in the constructor`, + ); + } + + path.remove(); + } else if (!allowDeclareFields && !node.value && !node.decorators) { + path.remove(); + } + + if (node.accessibility) node.accessibility = null; + if (node.abstract) node.abstract = null; + if (node.readonly) node.readonly = null; + if (node.optional) node.optional = null; + if (node.typeAnnotation) node.typeAnnotation = null; + }, + method({ node }) { + if (node.accessibility) node.accessibility = null; + if (node.abstract) node.abstract = null; + if (node.optional) node.optional = null; + + // Rest handled by Function visitor + }, + constructor(path, classPath) { + if (path.node.accessibility) path.node.accessibility = null; + // Collects parameter properties so that we can add an assignment + // for each of them in the constructor body + // + // We use a WeakSet to ensure an assignment for a parameter + // property is only added once. This is necessary for cases like + // using `transform-classes`, which causes this visitor to run + // twice. + const parameterProperties = []; + for (const param of path.node.params) { + if ( + param.type === "TSParameterProperty" && + !PARSED_PARAMS.has(param.parameter) + ) { + PARSED_PARAMS.add(param.parameter); + parameterProperties.push(param.parameter); + } + } + + if (parameterProperties.length) { + const assigns = parameterProperties.map(p => { + let id; + if (t.isIdentifier(p)) { + id = p; + } else if (t.isAssignmentPattern(p) && t.isIdentifier(p.left)) { + id = p.left; + } else { + throw path.buildCodeFrameError( + "Parameter properties can not be destructuring patterns.", + ); + } + + return template.statement.ast`this.${id} = ${id}`; + }); + + injectInitialization(classPath, path, assigns); + } + }, + }; + return { name: "transform-typescript", inherits: syntaxTypeScript, @@ -192,27 +276,6 @@ export default declare( if (node.definite) node.definite = null; }, - ClassMethod(path) { - const { node } = path; - - if (node.accessibility) node.accessibility = null; - if (node.abstract) node.abstract = null; - if (node.optional) node.optional = null; - - // Rest handled by Function visitor - }, - - ClassProperty(path) { - const { node } = path; - - if (node.accessibility) node.accessibility = null; - if (node.abstract) node.abstract = null; - if (node.readonly) node.readonly = null; - if (node.optional) node.optional = null; - if (node.definite) node.definite = null; - if (node.typeAnnotation) node.typeAnnotation = null; - }, - TSIndexSignature(path) { path.remove(); }, @@ -238,54 +301,14 @@ export default declare( // class transform would transform the class, causing more specific // visitors to not run. path.get("body.body").forEach(child => { - const childNode = child.node; - - if (t.isClassMethod(childNode, { kind: "constructor" })) { - // Collects parameter properties so that we can add an assignment - // for each of them in the constructor body - // - // We use a WeakSet to ensure an assignment for a parameter - // property is only added once. This is necessary for cases like - // using `transform-classes`, which causes this visitor to run - // twice. - const parameterProperties = []; - for (const param of childNode.params) { - if ( - param.type === "TSParameterProperty" && - !PARSED_PARAMS.has(param.parameter) - ) { - PARSED_PARAMS.add(param.parameter); - parameterProperties.push(param.parameter); - } - } - - if (parameterProperties.length) { - const assigns = parameterProperties.map(p => { - let id; - if (t.isIdentifier(p)) { - id = p; - } else if ( - t.isAssignmentPattern(p) && - t.isIdentifier(p.left) - ) { - id = p.left; - } else { - throw path.buildCodeFrameError( - "Parameter properties can not be destructuring patterns.", - ); - } - - return template.statement.ast`this.${id} = ${id}`; - }); - - injectInitialization(path, child, assigns); + if (child.isClassMethod()) { + if (child.node.kind === "constructor") { + classMemberVisitors.constructor(child, path); + } else { + classMemberVisitors.method(child, path); } } else if (child.isClassProperty()) { - childNode.typeAnnotation = null; - - if (!childNode.value && !childNode.decorators) { - child.remove(); - } + classMemberVisitors.field(child, path); } }); }, diff --git a/packages/babel-plugin-transform-typescript/test/fixtures/class/abstract-class-decorated-parameter/output.mjs b/packages/babel-plugin-transform-typescript/test/fixtures/class/abstract-class-decorated-parameter/output.mjs index e8982550efbf..58aa80d516ec 100644 --- a/packages/babel-plugin-transform-typescript/test/fixtures/class/abstract-class-decorated-parameter/output.mjs +++ b/packages/babel-plugin-transform-typescript/test/fixtures/class/abstract-class-decorated-parameter/output.mjs @@ -2,7 +2,7 @@ var _class, _descriptor; function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) { var desc = {}; Object.keys(descriptor).forEach(function (key) { desc[key] = descriptor[key]; }); desc.enumerable = !!desc.enumerable; desc.configurable = !!desc.configurable; if ('value' in desc || desc.initializer) { desc.writable = true; } desc = decorators.slice().reverse().reduce(function (desc, decorator) { return decorator(target, property, desc) || desc; }, desc); if (context && desc.initializer !== void 0) { desc.value = desc.initializer ? desc.initializer.call(context) : void 0; desc.initializer = undefined; } if (desc.initializer === void 0) { Object.defineProperty(target, property, desc); desc = null; } return desc; } -function _initializerWarningHelper(descriptor, context) { throw new Error('Decorating class property failed. Please ensure that ' + 'proposal-class-properties is enabled and set to use loose mode. ' + 'To use proposal-class-properties in spec mode with decorators, wait for ' + 'the next major version of decorators in stage 2.'); } +function _initializerWarningHelper(descriptor, context) { throw new Error('Decorating class property failed. Please ensure that ' + 'proposal-class-properties is enabled and runs after the decorators transform.'); } import { observable } from 'mobx'; let Foo = (_class = class Foo { diff --git a/packages/babel-plugin-transform-typescript/test/fixtures/class/declare-not-enabled/input.ts b/packages/babel-plugin-transform-typescript/test/fixtures/class/declare-not-enabled/input.ts new file mode 100644 index 000000000000..3cb9d54665fa --- /dev/null +++ b/packages/babel-plugin-transform-typescript/test/fixtures/class/declare-not-enabled/input.ts @@ -0,0 +1,3 @@ +class A { + declare x; +} diff --git a/packages/babel-plugin-transform-typescript/test/fixtures/class/declare-not-enabled/options.json b/packages/babel-plugin-transform-typescript/test/fixtures/class/declare-not-enabled/options.json new file mode 100644 index 000000000000..c844b0ad736c --- /dev/null +++ b/packages/babel-plugin-transform-typescript/test/fixtures/class/declare-not-enabled/options.json @@ -0,0 +1,4 @@ +{ + "plugins": ["transform-typescript"], + "throws": "The 'declare' modifier is only allowed when the 'allowDeclareFields' option of @babel/plugin-transform-typescript or @babel/preset-typescript is enabled." +} diff --git a/packages/babel-plugin-transform-typescript/test/fixtures/class/declare-not-initialized/input.ts b/packages/babel-plugin-transform-typescript/test/fixtures/class/declare-not-initialized/input.ts new file mode 100644 index 000000000000..c7c42323a390 --- /dev/null +++ b/packages/babel-plugin-transform-typescript/test/fixtures/class/declare-not-initialized/input.ts @@ -0,0 +1,3 @@ +class A { + x; +} \ No newline at end of file diff --git a/packages/babel-plugin-transform-typescript/test/fixtures/class/declare-not-initialized/options.json b/packages/babel-plugin-transform-typescript/test/fixtures/class/declare-not-initialized/options.json new file mode 100644 index 000000000000..a6d406a50e49 --- /dev/null +++ b/packages/babel-plugin-transform-typescript/test/fixtures/class/declare-not-initialized/options.json @@ -0,0 +1,3 @@ +{ + "plugins": [["transform-typescript", { "allowDeclareFields": true }]] +} diff --git a/packages/babel-plugin-transform-typescript/test/fixtures/class/declare-not-initialized/output.js b/packages/babel-plugin-transform-typescript/test/fixtures/class/declare-not-initialized/output.js new file mode 100644 index 000000000000..eebf5c5c33db --- /dev/null +++ b/packages/babel-plugin-transform-typescript/test/fixtures/class/declare-not-initialized/output.js @@ -0,0 +1,3 @@ +class A { + x; +} diff --git a/packages/babel-plugin-transform-typescript/test/fixtures/class/declare/input.ts b/packages/babel-plugin-transform-typescript/test/fixtures/class/declare/input.ts new file mode 100644 index 000000000000..7ab37b71fb39 --- /dev/null +++ b/packages/babel-plugin-transform-typescript/test/fixtures/class/declare/input.ts @@ -0,0 +1,3 @@ +class A { + declare x; +} \ No newline at end of file diff --git a/packages/babel-plugin-transform-typescript/test/fixtures/class/declare/options.json b/packages/babel-plugin-transform-typescript/test/fixtures/class/declare/options.json new file mode 100644 index 000000000000..a6d406a50e49 --- /dev/null +++ b/packages/babel-plugin-transform-typescript/test/fixtures/class/declare/options.json @@ -0,0 +1,3 @@ +{ + "plugins": [["transform-typescript", { "allowDeclareFields": true }]] +} diff --git a/packages/babel-plugin-transform-typescript/test/fixtures/class/declare/output.js b/packages/babel-plugin-transform-typescript/test/fixtures/class/declare/output.js new file mode 100644 index 000000000000..a869c2849526 --- /dev/null +++ b/packages/babel-plugin-transform-typescript/test/fixtures/class/declare/output.js @@ -0,0 +1 @@ +class A {} diff --git a/packages/babel-plugin-transform-typescript/test/fixtures/class/methods/input.ts b/packages/babel-plugin-transform-typescript/test/fixtures/class/methods/input.ts index 35f255f2b23e..58026a1bdaa7 100644 --- a/packages/babel-plugin-transform-typescript/test/fixtures/class/methods/input.ts +++ b/packages/babel-plugin-transform-typescript/test/fixtures/class/methods/input.ts @@ -1,4 +1,5 @@ class C { m(): void; public m(x?: number, ...y: number[]): void {} + public constructor() {} } diff --git a/packages/babel-plugin-transform-typescript/test/fixtures/class/methods/output.js b/packages/babel-plugin-transform-typescript/test/fixtures/class/methods/output.js index cb6e585efbb4..b5436ecfaec6 100644 --- a/packages/babel-plugin-transform-typescript/test/fixtures/class/methods/output.js +++ b/packages/babel-plugin-transform-typescript/test/fixtures/class/methods/output.js @@ -1,4 +1,6 @@ class C { m(x, ...y) {} + constructor() {} + } diff --git a/packages/babel-plugin-transform-typescript/test/fixtures/class/properties/input.ts b/packages/babel-plugin-transform-typescript/test/fixtures/class/properties/input.ts index abb53ac69bc3..b59f26e0c387 100644 --- a/packages/babel-plugin-transform-typescript/test/fixtures/class/properties/input.ts +++ b/packages/babel-plugin-transform-typescript/test/fixtures/class/properties/input.ts @@ -1,7 +1,8 @@ class C { public a?: number; private b: number = 0; - readonly c!: number = 1; + readonly c: number = 1; @foo d: number; @foo e: number = 3; + f!: number; } diff --git a/packages/babel-plugin-transform-typescript/test/fixtures/class/transform-properties-declare-wrong-order/input.ts b/packages/babel-plugin-transform-typescript/test/fixtures/class/transform-properties-declare-wrong-order/input.ts new file mode 100644 index 000000000000..afc220470140 --- /dev/null +++ b/packages/babel-plugin-transform-typescript/test/fixtures/class/transform-properties-declare-wrong-order/input.ts @@ -0,0 +1,4 @@ +class A { + declare x; + y; +} \ No newline at end of file diff --git a/packages/babel-plugin-transform-typescript/test/fixtures/class/transform-properties-declare-wrong-order/options.json b/packages/babel-plugin-transform-typescript/test/fixtures/class/transform-properties-declare-wrong-order/options.json new file mode 100644 index 000000000000..8a07f1cc2003 --- /dev/null +++ b/packages/babel-plugin-transform-typescript/test/fixtures/class/transform-properties-declare-wrong-order/options.json @@ -0,0 +1,7 @@ +{ + "plugins": [ + "proposal-class-properties", + ["transform-typescript", { "allowDeclareFields": true }] + ], + "throws": "TypeScript 'declare' fields must first be transformed by @babel/plugin-transform-typescript.\nIf you have already enabled that plugin (or '@babel/preset-typescript'), make sure that it runs before any plugin related to additional class features:\n - @babel/plugin-proposal-class-properties\n - @babel/plugin-proposal-private-methods\n - @babel/plugin-proposal-decorators" +} diff --git a/packages/babel-plugin-transform-typescript/test/fixtures/class/transform-properties-declare/input.ts b/packages/babel-plugin-transform-typescript/test/fixtures/class/transform-properties-declare/input.ts new file mode 100644 index 000000000000..afc220470140 --- /dev/null +++ b/packages/babel-plugin-transform-typescript/test/fixtures/class/transform-properties-declare/input.ts @@ -0,0 +1,4 @@ +class A { + declare x; + y; +} \ No newline at end of file diff --git a/packages/babel-plugin-transform-typescript/test/fixtures/class/transform-properties-declare/options.json b/packages/babel-plugin-transform-typescript/test/fixtures/class/transform-properties-declare/options.json new file mode 100644 index 000000000000..18a1de9a1531 --- /dev/null +++ b/packages/babel-plugin-transform-typescript/test/fixtures/class/transform-properties-declare/options.json @@ -0,0 +1,6 @@ +{ + "plugins": [ + ["transform-typescript", { "allowDeclareFields": true }], + "proposal-class-properties" + ] +} \ No newline at end of file diff --git a/packages/babel-plugin-transform-typescript/test/fixtures/class/transform-properties-declare/output.js b/packages/babel-plugin-transform-typescript/test/fixtures/class/transform-properties-declare/output.js new file mode 100644 index 000000000000..44b56f160013 --- /dev/null +++ b/packages/babel-plugin-transform-typescript/test/fixtures/class/transform-properties-declare/output.js @@ -0,0 +1,8 @@ +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +class A { + constructor() { + _defineProperty(this, "y", void 0); + } + +} diff --git a/packages/babel-plugin-transform-typescript/test/fixtures/class/uninitialized-definite-with-declare-enabled/input.ts b/packages/babel-plugin-transform-typescript/test/fixtures/class/uninitialized-definite-with-declare-enabled/input.ts new file mode 100644 index 000000000000..4bb8da7936c6 --- /dev/null +++ b/packages/babel-plugin-transform-typescript/test/fixtures/class/uninitialized-definite-with-declare-enabled/input.ts @@ -0,0 +1,3 @@ +class A { + x!; +} \ No newline at end of file diff --git a/packages/babel-plugin-transform-typescript/test/fixtures/class/uninitialized-definite-with-declare-enabled/options.json b/packages/babel-plugin-transform-typescript/test/fixtures/class/uninitialized-definite-with-declare-enabled/options.json new file mode 100644 index 000000000000..a6d406a50e49 --- /dev/null +++ b/packages/babel-plugin-transform-typescript/test/fixtures/class/uninitialized-definite-with-declare-enabled/options.json @@ -0,0 +1,3 @@ +{ + "plugins": [["transform-typescript", { "allowDeclareFields": true }]] +} diff --git a/packages/babel-plugin-transform-typescript/test/fixtures/class/uninitialized-definite-with-declare-enabled/output.js b/packages/babel-plugin-transform-typescript/test/fixtures/class/uninitialized-definite-with-declare-enabled/output.js new file mode 100644 index 000000000000..a869c2849526 --- /dev/null +++ b/packages/babel-plugin-transform-typescript/test/fixtures/class/uninitialized-definite-with-declare-enabled/output.js @@ -0,0 +1 @@ +class A {} diff --git a/packages/babel-plugin-transform-typescript/test/fixtures/enum/string-value-template/input.ts b/packages/babel-plugin-transform-typescript/test/fixtures/enum/string-value-template/input.ts new file mode 100644 index 000000000000..01086419eaff --- /dev/null +++ b/packages/babel-plugin-transform-typescript/test/fixtures/enum/string-value-template/input.ts @@ -0,0 +1,3 @@ +enum E { + A = `Hey` +} diff --git a/packages/babel-plugin-transform-typescript/test/fixtures/enum/string-value-template/output.js b/packages/babel-plugin-transform-typescript/test/fixtures/enum/string-value-template/output.js new file mode 100644 index 000000000000..dfc0f72fcd49 --- /dev/null +++ b/packages/babel-plugin-transform-typescript/test/fixtures/enum/string-value-template/output.js @@ -0,0 +1,5 @@ +var E; + +(function (E) { + E["A"] = "Hey"; +})(E || (E = {})); diff --git a/packages/babel-plugin-transform-typescript/test/fixtures/enum/string-values/input.ts b/packages/babel-plugin-transform-typescript/test/fixtures/enum/string-value/input.ts similarity index 100% rename from packages/babel-plugin-transform-typescript/test/fixtures/enum/string-values/input.ts rename to packages/babel-plugin-transform-typescript/test/fixtures/enum/string-value/input.ts diff --git a/packages/babel-plugin-transform-typescript/test/fixtures/enum/string-values/output.js b/packages/babel-plugin-transform-typescript/test/fixtures/enum/string-value/output.js similarity index 100% rename from packages/babel-plugin-transform-typescript/test/fixtures/enum/string-values/output.js rename to packages/babel-plugin-transform-typescript/test/fixtures/enum/string-value/output.js diff --git a/packages/babel-plugin-transform-typescript/test/fixtures/enum/string-values-computed/input.ts b/packages/babel-plugin-transform-typescript/test/fixtures/enum/string-values-computed/input.ts index ac52806fb927..06e9b00f0682 100644 --- a/packages/babel-plugin-transform-typescript/test/fixtures/enum/string-values-computed/input.ts +++ b/packages/babel-plugin-transform-typescript/test/fixtures/enum/string-values-computed/input.ts @@ -1,4 +1,3 @@ -// Not type-correct code enum E { A = "HALLO" + "WERLD" } diff --git a/packages/babel-plugin-transform-typescript/test/fixtures/enum/string-values-computed/output.js b/packages/babel-plugin-transform-typescript/test/fixtures/enum/string-values-computed/output.js index e449a1ca233d..a0f3ea2ca81f 100644 --- a/packages/babel-plugin-transform-typescript/test/fixtures/enum/string-values-computed/output.js +++ b/packages/babel-plugin-transform-typescript/test/fixtures/enum/string-values-computed/output.js @@ -1,6 +1,5 @@ -// Not type-correct code var E; (function (E) { - E[E["A"] = "HALLO" + "WERLD"] = "A"; + E["A"] = "HALLOWERLD"; })(E || (E = {})); diff --git a/packages/babel-plugin-transform-unicode-regex/package.json b/packages/babel-plugin-transform-unicode-regex/package.json index a3a534041774..f71c3d1dd38b 100644 --- a/packages/babel-plugin-transform-unicode-regex/package.json +++ b/packages/babel-plugin-transform-unicode-regex/package.json @@ -1,6 +1,6 @@ { "name": "@babel/plugin-transform-unicode-regex", - "version": "7.6.2", + "version": "7.7.0", "description": "Compile ES2015 Unicode regex to ES5", "repository": "https://github.com/babel/babel/tree/master/packages/babel-plugin-transform-unicode-regex", "license": "MIT", @@ -12,15 +12,14 @@ "babel-plugin" ], "dependencies": { - "@babel/helper-plugin-utils": "^7.0.0", - "@babel/helper-regex": "^7.4.4", - "regexpu-core": "^4.6.0" + "@babel/helper-create-regexp-features-plugin": "^7.7.0", + "@babel/helper-plugin-utils": "^7.0.0" }, "peerDependencies": { "@babel/core": "^7.0.0-0" }, "devDependencies": { - "@babel/core": "^7.6.2", + "@babel/core": "^7.7.0", "@babel/helper-plugin-test-runner": "^7.0.0" } } diff --git a/packages/babel-plugin-transform-unicode-regex/src/index.js b/packages/babel-plugin-transform-unicode-regex/src/index.js index 88593e055917..cfc4cd8a40f2 100644 --- a/packages/babel-plugin-transform-unicode-regex/src/index.js +++ b/packages/babel-plugin-transform-unicode-regex/src/index.js @@ -1,19 +1,12 @@ +/* eslint-disable @babel/development/plugin-name */ +import { createRegExpFeaturePlugin } from "@babel/helper-create-regexp-features-plugin"; import { declare } from "@babel/helper-plugin-utils"; -import rewritePattern from "regexpu-core"; -import * as regex from "@babel/helper-regex"; export default declare(api => { api.assertVersion(7); - return { + return createRegExpFeaturePlugin({ name: "transform-unicode-regex", - - visitor: { - RegExpLiteral({ node }) { - if (!regex.is(node, "u")) return; - node.pattern = rewritePattern(node.pattern, node.flags); - regex.pullFlag(node, "u"); - }, - }, - }; + feature: "unicodeFlag", + }); }); diff --git a/packages/babel-polyfill/package.json b/packages/babel-polyfill/package.json index d3a4055dadf1..013e949556e3 100644 --- a/packages/babel-polyfill/package.json +++ b/packages/babel-polyfill/package.json @@ -1,6 +1,6 @@ { "name": "@babel/polyfill", - "version": "7.6.0", + "version": "7.7.0", "description": "Provides polyfills necessary for a full ES2015+ environment", "author": "Sebastian McKenzie ", "homepage": "https://babeljs.io/", diff --git a/packages/babel-preset-env-standalone/package.json b/packages/babel-preset-env-standalone/package.json index bdda607f1596..c749a6caae8f 100644 --- a/packages/babel-preset-env-standalone/package.json +++ b/packages/babel-preset-env-standalone/package.json @@ -1,6 +1,6 @@ { "name": "@babel/preset-env-standalone", - "version": "7.6.3", + "version": "7.7.3", "description": "Standalone build of babel-prest-env for use in non-Node.js environments.", "main": "babel-preset-env.js", "files": [ @@ -12,12 +12,12 @@ "prepublishOnly": "cd ../.. && make prepublish-build-preset-env-standalone" }, "devDependencies": { - "@babel/plugin-proposal-dynamic-import": "^7.5.0", + "@babel/plugin-proposal-dynamic-import": "^7.7.0", "@babel/plugin-proposal-json-strings": "^7.0.0", - "@babel/plugin-transform-named-capturing-groups-regex": "^7.6.3", + "@babel/plugin-transform-named-capturing-groups-regex": "^7.7.0", "@babel/plugin-transform-new-target": "^7.4.4", - "@babel/preset-env": "^7.6.3", - "@babel/standalone": "^7.6.3" + "@babel/preset-env": "^7.7.1", + "@babel/standalone": "^7.7.3" }, "keywords": [ "babel", diff --git a/packages/babel-preset-env/data/overlapping-plugins.js b/packages/babel-preset-env/data/overlapping-plugins.js new file mode 100644 index 000000000000..84c0d416b4ad --- /dev/null +++ b/packages/babel-preset-env/data/overlapping-plugins.js @@ -0,0 +1,15 @@ +"use strict"; + +module.exports = new Map(); + +// async -> regenerator is better than async -> generator -> regenerator +ifIncluded("transform-regenerator") + .isUnnecessary("transform-async-to-generator"); + +function ifIncluded(name) { + const set = new Set(); + module.exports.set(name, set); + return { + isUnnecessary(name) { set.add(name); return this; } + }; +} diff --git a/packages/babel-preset-env/package.json b/packages/babel-preset-env/package.json index 740beedde749..7648965e88be 100644 --- a/packages/babel-preset-env/package.json +++ b/packages/babel-preset-env/package.json @@ -1,6 +1,6 @@ { "name": "@babel/preset-env", - "version": "7.6.3", + "version": "7.7.1", "description": "A Babel preset for each environment.", "author": "Henry Zhu ", "homepage": "https://babeljs.io/", @@ -14,51 +14,52 @@ "build-data": "node ./scripts/build-data.js; node ./scripts/build-modules-support.js" }, "dependencies": { - "@babel/helper-module-imports": "^7.0.0", + "@babel/helper-module-imports": "^7.7.0", "@babel/helper-plugin-utils": "^7.0.0", - "@babel/plugin-proposal-async-generator-functions": "^7.2.0", - "@babel/plugin-proposal-dynamic-import": "^7.5.0", + "@babel/plugin-proposal-async-generator-functions": "^7.7.0", + "@babel/plugin-proposal-dynamic-import": "^7.7.0", "@babel/plugin-proposal-json-strings": "^7.2.0", "@babel/plugin-proposal-object-rest-spread": "^7.6.2", "@babel/plugin-proposal-optional-catch-binding": "^7.2.0", - "@babel/plugin-proposal-unicode-property-regex": "^7.6.2", + "@babel/plugin-proposal-unicode-property-regex": "^7.7.0", "@babel/plugin-syntax-async-generators": "^7.2.0", "@babel/plugin-syntax-dynamic-import": "^7.2.0", "@babel/plugin-syntax-json-strings": "^7.2.0", "@babel/plugin-syntax-object-rest-spread": "^7.2.0", "@babel/plugin-syntax-optional-catch-binding": "^7.2.0", + "@babel/plugin-syntax-top-level-await": "^7.7.0", "@babel/plugin-transform-arrow-functions": "^7.2.0", - "@babel/plugin-transform-async-to-generator": "^7.5.0", + "@babel/plugin-transform-async-to-generator": "^7.7.0", "@babel/plugin-transform-block-scoped-functions": "^7.2.0", "@babel/plugin-transform-block-scoping": "^7.6.3", - "@babel/plugin-transform-classes": "^7.5.5", + "@babel/plugin-transform-classes": "^7.7.0", "@babel/plugin-transform-computed-properties": "^7.2.0", "@babel/plugin-transform-destructuring": "^7.6.0", - "@babel/plugin-transform-dotall-regex": "^7.6.2", + "@babel/plugin-transform-dotall-regex": "^7.7.0", "@babel/plugin-transform-duplicate-keys": "^7.5.0", "@babel/plugin-transform-exponentiation-operator": "^7.2.0", "@babel/plugin-transform-for-of": "^7.4.4", - "@babel/plugin-transform-function-name": "^7.4.4", + "@babel/plugin-transform-function-name": "^7.7.0", "@babel/plugin-transform-literals": "^7.2.0", "@babel/plugin-transform-member-expression-literals": "^7.2.0", "@babel/plugin-transform-modules-amd": "^7.5.0", - "@babel/plugin-transform-modules-commonjs": "^7.6.0", - "@babel/plugin-transform-modules-systemjs": "^7.5.0", - "@babel/plugin-transform-modules-umd": "^7.2.0", - "@babel/plugin-transform-named-capturing-groups-regex": "^7.6.3", + "@babel/plugin-transform-modules-commonjs": "^7.7.0", + "@babel/plugin-transform-modules-systemjs": "^7.7.0", + "@babel/plugin-transform-modules-umd": "^7.7.0", + "@babel/plugin-transform-named-capturing-groups-regex": "^7.7.0", "@babel/plugin-transform-new-target": "^7.4.4", "@babel/plugin-transform-object-super": "^7.5.5", "@babel/plugin-transform-parameters": "^7.4.4", "@babel/plugin-transform-property-literals": "^7.2.0", - "@babel/plugin-transform-regenerator": "^7.4.5", + "@babel/plugin-transform-regenerator": "^7.7.0", "@babel/plugin-transform-reserved-words": "^7.2.0", "@babel/plugin-transform-shorthand-properties": "^7.2.0", "@babel/plugin-transform-spread": "^7.6.2", "@babel/plugin-transform-sticky-regex": "^7.2.0", "@babel/plugin-transform-template-literals": "^7.4.4", "@babel/plugin-transform-typeof-symbol": "^7.2.0", - "@babel/plugin-transform-unicode-regex": "^7.6.2", - "@babel/types": "^7.6.3", + "@babel/plugin-transform-unicode-regex": "^7.7.0", + "@babel/types": "^7.7.1", "browserslist": "^4.6.0", "core-js-compat": "^3.1.1", "invariant": "^2.2.2", @@ -69,8 +70,8 @@ "@babel/core": "^7.0.0-0" }, "devDependencies": { - "@babel/cli": "^7.6.3", - "@babel/core": "^7.6.3", + "@babel/cli": "^7.7.0", + "@babel/core": "^7.7.0", "@babel/helper-fixtures": "^7.6.3", "@babel/helper-plugin-test-runner": "^7.0.0", "@babel/plugin-syntax-dynamic-import": "^7.2.0", diff --git a/packages/babel-preset-env/src/available-plugins.js b/packages/babel-preset-env/src/available-plugins.js index 77da4ff02cf0..8ce0c72f1aa0 100644 --- a/packages/babel-preset-env/src/available-plugins.js +++ b/packages/babel-preset-env/src/available-plugins.js @@ -6,6 +6,7 @@ export default { "syntax-json-strings": require("@babel/plugin-syntax-json-strings"), "syntax-object-rest-spread": require("@babel/plugin-syntax-object-rest-spread"), "syntax-optional-catch-binding": require("@babel/plugin-syntax-optional-catch-binding"), + "syntax-top-level-await": require("@babel/plugin-syntax-top-level-await"), "transform-async-to-generator": require("@babel/plugin-transform-async-to-generator"), "proposal-async-generator-functions": require("@babel/plugin-proposal-async-generator-functions"), "proposal-dynamic-import": require("@babel/plugin-proposal-dynamic-import"), diff --git a/packages/babel-preset-env/src/filter-items.js b/packages/babel-preset-env/src/filter-items.js index 7d9c07026eba..3c5a3297083f 100644 --- a/packages/babel-preset-env/src/filter-items.js +++ b/packages/babel-preset-env/src/filter-items.js @@ -85,3 +85,13 @@ export default function( return result; } + +export function removeUnnecessaryItems( + items: Set, + overlapping: Map>, +) { + items.forEach(item => { + const names = overlapping.get(item); + if (names) names.forEach(name => items.delete(name)); + }); +} diff --git a/packages/babel-preset-env/src/index.js b/packages/babel-preset-env/src/index.js index 76f11ebcb934..17740c4c3586 100644 --- a/packages/babel-preset-env/src/index.js +++ b/packages/babel-preset-env/src/index.js @@ -3,11 +3,12 @@ import { SemVer } from "semver"; import { logPluginOrPolyfill } from "./debug"; import getOptionSpecificExcludesFor from "./get-option-specific-excludes"; -import filterItems from "./filter-items"; +import filterItems, { removeUnnecessaryItems } from "./filter-items"; import moduleTransformations from "./module-transformations"; import normalizeOptions from "./normalize-options"; import pluginList from "../data/plugins.json"; import { proposalPlugins, pluginSyntaxMap } from "../data/shipped-proposals"; +import overlappingPlugins from "../data/overlapping-plugins"; import addCoreJS2UsagePlugin from "./polyfills/corejs2/usage-plugin"; import addCoreJS3UsagePlugin from "./polyfills/corejs3/usage-plugin"; @@ -65,11 +66,13 @@ export const getModulesPluginNames = ({ transformations, shouldTransformESM, shouldTransformDynamicImport, + shouldParseTopLevelAwait, }: { modules: ModuleOption, transformations: ModuleTransformationsType, shouldTransformESM: boolean, shouldTransformDynamicImport: boolean, + shouldParseTopLevelAwait: boolean, }) => { const modulesPluginNames = []; if (modules !== false && transformations[modules]) { @@ -95,6 +98,11 @@ export const getModulesPluginNames = ({ } else { modulesPluginNames.push("syntax-dynamic-import"); } + + if (shouldParseTopLevelAwait) { + modulesPluginNames.push("syntax-top-level-await"); + } + return modulesPluginNames; }; @@ -165,6 +173,10 @@ function supportsDynamicImport(caller) { return !!(caller && caller.supportsDynamicImport); } +function supportsTopLevelAwait(caller) { + return !!(caller && caller.supportsTopLevelAwait); +} + export default declare((api, opts) => { api.assertVersion(7); @@ -225,6 +237,7 @@ export default declare((api, opts) => { modules !== "auto" || !api.caller || !api.caller(supportsStaticESM), shouldTransformDynamicImport: modules !== "auto" || !api.caller || !api.caller(supportsDynamicImport), + shouldParseTopLevelAwait: !api.caller || api.caller(supportsTopLevelAwait), }); const pluginNames = filterItems( @@ -236,6 +249,7 @@ export default declare((api, opts) => { getOptionSpecificExcludesFor({ loose }), pluginSyntaxMap, ); + removeUnnecessaryItems(pluginNames, overlappingPlugins); const polyfillPlugins = getPolyfillPlugins({ useBuiltIns, diff --git a/packages/babel-preset-env/test/fixtures/corejs2/entry-shippedProposals/output.js b/packages/babel-preset-env/test/fixtures/corejs2/entry-shippedProposals/output.js index 86637af3ee15..fa7c74df32ac 100644 --- a/packages/babel-preset-env/test/fixtures/corejs2/entry-shippedProposals/output.js +++ b/packages/babel-preset-env/test/fixtures/corejs2/entry-shippedProposals/output.js @@ -298,7 +298,7 @@ require("regenerator-runtime/runtime.js"); function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } -function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } @@ -310,7 +310,7 @@ function _awaitAsyncGenerator(value) { return new _AwaitValue(value); } function _wrapAsyncGenerator(fn) { return function () { return new _AsyncGenerator(fn.apply(this, arguments)); }; } -function _AsyncGenerator(gen) { var front, back; function send(key, arg) { return new Promise(function (resolve, reject) { var request = { key: key, arg: arg, resolve: resolve, reject: reject, next: null }; if (back) { back = back.next = request; } else { front = back = request; resume(key, arg); } }); } function resume(key, arg) { try { var result = gen[key](arg); var value = result.value; var wrappedAwait = value instanceof _AwaitValue; Promise.resolve(wrappedAwait ? value.wrapped : value).then(function (arg) { if (wrappedAwait) { resume("next", arg); return; } settle(result.done ? "return" : "normal", arg); }, function (err) { resume("throw", err); }); } catch (err) { settle("throw", err); } } function settle(type, value) { switch (type) { case "return": front.resolve({ value: value, done: true }); break; case "throw": front.reject(value); break; default: front.resolve({ value: value, done: false }); break; } front = front.next; if (front) { resume(front.key, front.arg); } else { back = null; } } this._invoke = send; if (typeof gen["return"] !== "function") { this["return"] = undefined; } } +function _AsyncGenerator(gen) { var front, back; function send(key, arg) { return new Promise(function (resolve, reject) { var request = { key: key, arg: arg, resolve: resolve, reject: reject, next: null }; if (back) { back = back.next = request; } else { front = back = request; resume(key, arg); } }); } function resume(key, arg) { try { var result = gen[key](arg); var value = result.value; var wrappedAwait = value instanceof _AwaitValue; Promise.resolve(wrappedAwait ? value.wrapped : value).then(function (arg) { if (wrappedAwait) { resume(key === "return" ? "return" : "next", arg); return; } settle(result.done ? "return" : "normal", arg); }, function (err) { resume("throw", err); }); } catch (err) { settle("throw", err); } } function settle(type, value) { switch (type) { case "return": front.resolve({ value: value, done: true }); break; case "throw": front.reject(value); break; default: front.resolve({ value: value, done: false }); break; } front = front.next; if (front) { resume(front.key, front.arg); } else { back = null; } } this._invoke = send; if (typeof gen["return"] !== "function") { this["return"] = undefined; } } if (typeof Symbol === "function" && Symbol.asyncIterator) { _AsyncGenerator.prototype[Symbol.asyncIterator] = function () { return this; }; } diff --git a/packages/babel-preset-env/test/fixtures/corejs2/usage-regenerator-used-async/output.mjs b/packages/babel-preset-env/test/fixtures/corejs2/usage-regenerator-used-async/output.mjs index b7b1e3037b95..c73c0f569615 100644 --- a/packages/babel-preset-env/test/fixtures/corejs2/usage-regenerator-used-async/output.mjs +++ b/packages/babel-preset-env/test/fixtures/corejs2/usage-regenerator-used-async/output.mjs @@ -1,28 +1,13 @@ import "regenerator-runtime/runtime.js"; -import "core-js/modules/es6.promise.js"; -import "core-js/modules/es6.object.to-string.js"; - -function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } } - -function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; } function a() { - return _a.apply(this, arguments); -} - -function _a() { - _a = _asyncToGenerator( - /*#__PURE__*/ - regeneratorRuntime.mark(function _callee() { - return regeneratorRuntime.wrap(function _callee$(_context) { - while (1) { - switch (_context.prev = _context.next) { - case 0: - case "end": - return _context.stop(); - } + return regeneratorRuntime.async(function a$(_context) { + while (1) { + switch (_context.prev = _context.next) { + case 0: + case "end": + return _context.stop(); } - }, _callee); - })); - return _a.apply(this, arguments); + } + }); } diff --git a/packages/babel-preset-env/test/fixtures/corejs2/usage-shippedProposals/output.js b/packages/babel-preset-env/test/fixtures/corejs2/usage-shippedProposals/output.js index 9f00d94e03de..5dc8847cf692 100644 --- a/packages/babel-preset-env/test/fixtures/corejs2/usage-shippedProposals/output.js +++ b/packages/babel-preset-env/test/fixtures/corejs2/usage-shippedProposals/output.js @@ -30,7 +30,7 @@ require("core-js/modules/es6.object.to-string.js"); function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } -function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } @@ -42,7 +42,7 @@ function _awaitAsyncGenerator(value) { return new _AwaitValue(value); } function _wrapAsyncGenerator(fn) { return function () { return new _AsyncGenerator(fn.apply(this, arguments)); }; } -function _AsyncGenerator(gen) { var front, back; function send(key, arg) { return new Promise(function (resolve, reject) { var request = { key: key, arg: arg, resolve: resolve, reject: reject, next: null }; if (back) { back = back.next = request; } else { front = back = request; resume(key, arg); } }); } function resume(key, arg) { try { var result = gen[key](arg); var value = result.value; var wrappedAwait = value instanceof _AwaitValue; Promise.resolve(wrappedAwait ? value.wrapped : value).then(function (arg) { if (wrappedAwait) { resume("next", arg); return; } settle(result.done ? "return" : "normal", arg); }, function (err) { resume("throw", err); }); } catch (err) { settle("throw", err); } } function settle(type, value) { switch (type) { case "return": front.resolve({ value: value, done: true }); break; case "throw": front.reject(value); break; default: front.resolve({ value: value, done: false }); break; } front = front.next; if (front) { resume(front.key, front.arg); } else { back = null; } } this._invoke = send; if (typeof gen["return"] !== "function") { this["return"] = undefined; } } +function _AsyncGenerator(gen) { var front, back; function send(key, arg) { return new Promise(function (resolve, reject) { var request = { key: key, arg: arg, resolve: resolve, reject: reject, next: null }; if (back) { back = back.next = request; } else { front = back = request; resume(key, arg); } }); } function resume(key, arg) { try { var result = gen[key](arg); var value = result.value; var wrappedAwait = value instanceof _AwaitValue; Promise.resolve(wrappedAwait ? value.wrapped : value).then(function (arg) { if (wrappedAwait) { resume(key === "return" ? "return" : "next", arg); return; } settle(result.done ? "return" : "normal", arg); }, function (err) { resume("throw", err); }); } catch (err) { settle("throw", err); } } function settle(type, value) { switch (type) { case "return": front.resolve({ value: value, done: true }); break; case "throw": front.reject(value); break; default: front.resolve({ value: value, done: false }); break; } front = front.next; if (front) { resume(front.key, front.arg); } else { back = null; } } this._invoke = send; if (typeof gen["return"] !== "function") { this["return"] = undefined; } } if (typeof Symbol === "function" && Symbol.asyncIterator) { _AsyncGenerator.prototype[Symbol.asyncIterator] = function () { return this; }; } diff --git a/packages/babel-preset-env/test/fixtures/corejs3/usage-regenerator-used-async/output.mjs b/packages/babel-preset-env/test/fixtures/corejs3/usage-regenerator-used-async/output.mjs index eb8cf268903d..5a7ce6455fa7 100644 --- a/packages/babel-preset-env/test/fixtures/corejs3/usage-regenerator-used-async/output.mjs +++ b/packages/babel-preset-env/test/fixtures/corejs3/usage-regenerator-used-async/output.mjs @@ -2,27 +2,14 @@ import "core-js/modules/es.object.to-string.js"; import "core-js/modules/es.promise.js"; import "regenerator-runtime/runtime.js"; -function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } } - -function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; } - function a() { - return _a.apply(this, arguments); -} - -function _a() { - _a = _asyncToGenerator( - /*#__PURE__*/ - regeneratorRuntime.mark(function _callee() { - return regeneratorRuntime.wrap(function _callee$(_context) { - while (1) { - switch (_context.prev = _context.next) { - case 0: - case "end": - return _context.stop(); - } + return regeneratorRuntime.async(function a$(_context) { + while (1) { + switch (_context.prev = _context.next) { + case 0: + case "end": + return _context.stop(); } - }, _callee); - })); - return _a.apply(this, arguments); + } + }); } diff --git a/packages/babel-preset-env/test/fixtures/debug/corejs-without-usebuiltins/stdout.txt b/packages/babel-preset-env/test/fixtures/debug/corejs-without-usebuiltins/stdout.txt index dd2af17fc22d..d263c3020966 100644 --- a/packages/babel-preset-env/test/fixtures/debug/corejs-without-usebuiltins/stdout.txt +++ b/packages/babel-preset-env/test/fixtures/debug/corejs-without-usebuiltins/stdout.txt @@ -30,7 +30,6 @@ Using plugins: transform-new-target {} transform-regenerator {} transform-exponentiation-operator {} - transform-async-to-generator {} proposal-async-generator-functions {} proposal-object-rest-spread {} proposal-unicode-property-regex {} diff --git a/packages/babel-preset-env/test/fixtures/debug/entry-corejs2-android/stdout.txt b/packages/babel-preset-env/test/fixtures/debug/entry-corejs2-android/stdout.txt index d4cb727787d8..b2d6215dfff4 100644 --- a/packages/babel-preset-env/test/fixtures/debug/entry-corejs2-android/stdout.txt +++ b/packages/babel-preset-env/test/fixtures/debug/entry-corejs2-android/stdout.txt @@ -30,7 +30,6 @@ Using plugins: transform-new-target { "android":"4" } transform-regenerator { "android":"4" } transform-exponentiation-operator { "android":"4" } - transform-async-to-generator { "android":"4" } proposal-async-generator-functions { "android":"4" } proposal-object-rest-spread { "android":"4" } proposal-unicode-property-regex { "android":"4" } diff --git a/packages/babel-preset-env/test/fixtures/debug/entry-corejs2-electron/stdout.txt b/packages/babel-preset-env/test/fixtures/debug/entry-corejs2-electron/stdout.txt index c3c18fa3a051..bfc587d621ae 100644 --- a/packages/babel-preset-env/test/fixtures/debug/entry-corejs2-electron/stdout.txt +++ b/packages/babel-preset-env/test/fixtures/debug/entry-corejs2-electron/stdout.txt @@ -25,7 +25,6 @@ Using plugins: transform-block-scoping { "electron":"0.36" } transform-regenerator { "electron":"0.36" } transform-exponentiation-operator { "electron":"0.36" } - transform-async-to-generator { "electron":"0.36" } proposal-async-generator-functions { "electron":"0.36" } proposal-object-rest-spread { "electron":"0.36" } proposal-unicode-property-regex { "electron":"0.36" } diff --git a/packages/babel-preset-env/test/fixtures/debug/entry-corejs2-force-all-transforms/stdout.txt b/packages/babel-preset-env/test/fixtures/debug/entry-corejs2-force-all-transforms/stdout.txt index 32637c13542d..f5645e48ccb3 100644 --- a/packages/babel-preset-env/test/fixtures/debug/entry-corejs2-force-all-transforms/stdout.txt +++ b/packages/babel-preset-env/test/fixtures/debug/entry-corejs2-force-all-transforms/stdout.txt @@ -30,7 +30,6 @@ Using plugins: transform-new-target {} transform-regenerator {} transform-exponentiation-operator {} - transform-async-to-generator {} proposal-async-generator-functions { "chrome":"55" } proposal-object-rest-spread { "chrome":"55" } proposal-unicode-property-regex { "chrome":"55" } diff --git a/packages/babel-preset-env/test/fixtures/debug/entry-corejs2-proposals/stdout.txt b/packages/babel-preset-env/test/fixtures/debug/entry-corejs2-proposals/stdout.txt index e5a186c32135..bea5ddcef506 100644 --- a/packages/babel-preset-env/test/fixtures/debug/entry-corejs2-proposals/stdout.txt +++ b/packages/babel-preset-env/test/fixtures/debug/entry-corejs2-proposals/stdout.txt @@ -28,7 +28,6 @@ Using plugins: transform-new-target {} transform-regenerator {} transform-exponentiation-operator {} - transform-async-to-generator {} proposal-async-generator-functions {} proposal-object-rest-spread {} proposal-unicode-property-regex {} diff --git a/packages/babel-preset-env/test/fixtures/debug/entry-corejs2-shippedProposals/stdout.txt b/packages/babel-preset-env/test/fixtures/debug/entry-corejs2-shippedProposals/stdout.txt index cbffdcc578f3..bc8c000777a8 100644 --- a/packages/babel-preset-env/test/fixtures/debug/entry-corejs2-shippedProposals/stdout.txt +++ b/packages/babel-preset-env/test/fixtures/debug/entry-corejs2-shippedProposals/stdout.txt @@ -28,7 +28,6 @@ Using plugins: transform-new-target {} transform-regenerator {} transform-exponentiation-operator {} - transform-async-to-generator {} proposal-async-generator-functions {} proposal-object-rest-spread {} proposal-unicode-property-regex {} diff --git a/packages/babel-preset-env/test/fixtures/debug/entry-corejs2-specific-targets/stdout.txt b/packages/babel-preset-env/test/fixtures/debug/entry-corejs2-specific-targets/stdout.txt index 16202760ee72..fd3e8b442630 100644 --- a/packages/babel-preset-env/test/fixtures/debug/entry-corejs2-specific-targets/stdout.txt +++ b/packages/babel-preset-env/test/fixtures/debug/entry-corejs2-specific-targets/stdout.txt @@ -35,7 +35,6 @@ Using plugins: transform-new-target { "edge":"13", "ie":"10", "ios":"9", "safari":"7" } transform-regenerator { "firefox":"49", "ie":"10", "ios":"9", "safari":"7" } transform-exponentiation-operator { "edge":"13", "firefox":"49", "ie":"10", "ios":"9", "safari":"7" } - transform-async-to-generator { "chrome":"54", "edge":"13", "firefox":"49", "ie":"10", "ios":"9", "safari":"7" } proposal-async-generator-functions { "chrome":"54", "edge":"13", "firefox":"49", "ie":"10", "ios":"9", "safari":"7" } proposal-object-rest-spread { "chrome":"54", "edge":"13", "firefox":"49", "ie":"10", "ios":"9", "safari":"7" } proposal-unicode-property-regex { "chrome":"54", "edge":"13", "firefox":"49", "ie":"10", "ios":"9", "safari":"7" } diff --git a/packages/babel-preset-env/test/fixtures/debug/entry-corejs2-versions-decimals/stdout.txt b/packages/babel-preset-env/test/fixtures/debug/entry-corejs2-versions-decimals/stdout.txt index 63ba5e06fce5..afe468aa8aba 100644 --- a/packages/babel-preset-env/test/fixtures/debug/entry-corejs2-versions-decimals/stdout.txt +++ b/packages/babel-preset-env/test/fixtures/debug/entry-corejs2-versions-decimals/stdout.txt @@ -41,7 +41,6 @@ Using plugins: transform-new-target { "ie":"10" } transform-regenerator { "electron":"0.36", "ie":"10" } transform-exponentiation-operator { "electron":"0.36", "ie":"10", "node":"6.1" } - transform-async-to-generator { "chrome":"54", "electron":"0.36", "ie":"10", "node":"6.1" } proposal-async-generator-functions { "chrome":"54", "electron":"0.36", "ie":"10", "node":"6.1" } proposal-object-rest-spread { "chrome":"54", "electron":"0.36", "ie":"10", "node":"6.1" } proposal-unicode-property-regex { "chrome":"54", "electron":"0.36", "ie":"10", "node":"6.1" } diff --git a/packages/babel-preset-env/test/fixtures/debug/entry-corejs2-versions-strings/stdout.txt b/packages/babel-preset-env/test/fixtures/debug/entry-corejs2-versions-strings/stdout.txt index ae6350c447da..c14636d386e1 100644 --- a/packages/babel-preset-env/test/fixtures/debug/entry-corejs2-versions-strings/stdout.txt +++ b/packages/babel-preset-env/test/fixtures/debug/entry-corejs2-versions-strings/stdout.txt @@ -32,7 +32,6 @@ Using plugins: transform-new-target { "ie":"10" } transform-regenerator { "ie":"10" } transform-exponentiation-operator { "ie":"10", "node":"6.10" } - transform-async-to-generator { "chrome":"54", "ie":"10", "node":"6.10" } proposal-async-generator-functions { "chrome":"54", "ie":"10", "node":"6.10" } proposal-object-rest-spread { "chrome":"54", "ie":"10", "node":"6.10" } proposal-unicode-property-regex { "chrome":"54", "ie":"10", "node":"6.10" } diff --git a/packages/babel-preset-env/test/fixtures/debug/entry-corejs2/stdout.txt b/packages/babel-preset-env/test/fixtures/debug/entry-corejs2/stdout.txt index 4b45c43d32d2..14ad1ce4b6cd 100644 --- a/packages/babel-preset-env/test/fixtures/debug/entry-corejs2/stdout.txt +++ b/packages/babel-preset-env/test/fixtures/debug/entry-corejs2/stdout.txt @@ -32,7 +32,6 @@ Using plugins: transform-new-target { "ie":"10" } transform-regenerator { "ie":"10" } transform-exponentiation-operator { "ie":"10", "node":"6" } - transform-async-to-generator { "chrome":"54", "ie":"10", "node":"6" } proposal-async-generator-functions { "chrome":"54", "ie":"10", "node":"6" } proposal-object-rest-spread { "chrome":"54", "ie":"10", "node":"6" } proposal-unicode-property-regex { "chrome":"54", "ie":"10", "node":"6" } diff --git a/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-all/stdout.txt b/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-all/stdout.txt index 0d0f575f70c3..38e834034f84 100644 --- a/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-all/stdout.txt +++ b/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-all/stdout.txt @@ -28,7 +28,6 @@ Using plugins: transform-new-target {} transform-regenerator {} transform-exponentiation-operator {} - transform-async-to-generator {} proposal-async-generator-functions {} proposal-object-rest-spread {} proposal-unicode-property-regex {} diff --git a/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-android/stdout.txt b/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-android/stdout.txt index 42d9f81c58b4..684f0ebd9aa1 100644 --- a/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-android/stdout.txt +++ b/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-android/stdout.txt @@ -30,7 +30,6 @@ Using plugins: transform-new-target { "android":"4" } transform-regenerator { "android":"4" } transform-exponentiation-operator { "android":"4" } - transform-async-to-generator { "android":"4" } proposal-async-generator-functions { "android":"4" } proposal-object-rest-spread { "android":"4" } proposal-unicode-property-regex { "android":"4" } diff --git a/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-babel-polyfill/stdout.txt b/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-babel-polyfill/stdout.txt index a900b4720ab0..e730eb6421ca 100644 --- a/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-babel-polyfill/stdout.txt +++ b/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-babel-polyfill/stdout.txt @@ -28,7 +28,6 @@ Using plugins: transform-new-target {} transform-regenerator {} transform-exponentiation-operator {} - transform-async-to-generator {} proposal-async-generator-functions {} proposal-object-rest-spread {} proposal-unicode-property-regex {} diff --git a/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-electron/stdout.txt b/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-electron/stdout.txt index 85026b3df8e2..32c6a7530002 100644 --- a/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-electron/stdout.txt +++ b/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-electron/stdout.txt @@ -25,7 +25,6 @@ Using plugins: transform-block-scoping { "electron":"0.36" } transform-regenerator { "electron":"0.36" } transform-exponentiation-operator { "electron":"0.36" } - transform-async-to-generator { "electron":"0.36" } proposal-async-generator-functions { "electron":"0.36" } proposal-object-rest-spread { "electron":"0.36" } proposal-unicode-property-regex { "electron":"0.36" } diff --git a/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-es-proposals/stdout.txt b/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-es-proposals/stdout.txt index 07743893310e..39b7566a4edc 100644 --- a/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-es-proposals/stdout.txt +++ b/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-es-proposals/stdout.txt @@ -28,7 +28,6 @@ Using plugins: transform-new-target {} transform-regenerator {} transform-exponentiation-operator {} - transform-async-to-generator {} proposal-async-generator-functions {} proposal-object-rest-spread {} proposal-unicode-property-regex {} diff --git a/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-es/stdout.txt b/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-es/stdout.txt index f6c3da52ca39..cf8816e74969 100644 --- a/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-es/stdout.txt +++ b/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-es/stdout.txt @@ -28,7 +28,6 @@ Using plugins: transform-new-target {} transform-regenerator {} transform-exponentiation-operator {} - transform-async-to-generator {} proposal-async-generator-functions {} proposal-object-rest-spread {} proposal-unicode-property-regex {} diff --git a/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-force-all-transforms/stdout.txt b/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-force-all-transforms/stdout.txt index dbc3ba935e3e..2733197a3382 100644 --- a/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-force-all-transforms/stdout.txt +++ b/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-force-all-transforms/stdout.txt @@ -30,7 +30,6 @@ Using plugins: transform-new-target {} transform-regenerator {} transform-exponentiation-operator {} - transform-async-to-generator {} proposal-async-generator-functions { "chrome":"55" } proposal-object-rest-spread { "chrome":"55" } proposal-unicode-property-regex { "chrome":"55" } diff --git a/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-proposals/stdout.txt b/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-proposals/stdout.txt index 2d70ebb4d616..b400e3b3da64 100644 --- a/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-proposals/stdout.txt +++ b/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-proposals/stdout.txt @@ -28,7 +28,6 @@ Using plugins: transform-new-target {} transform-regenerator {} transform-exponentiation-operator {} - transform-async-to-generator {} proposal-async-generator-functions {} proposal-object-rest-spread {} proposal-unicode-property-regex {} diff --git a/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-specific-entries/stdout.txt b/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-specific-entries/stdout.txt index 237cf943f7c3..9b8ceb81a002 100644 --- a/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-specific-entries/stdout.txt +++ b/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-specific-entries/stdout.txt @@ -28,7 +28,6 @@ Using plugins: transform-new-target {} transform-regenerator {} transform-exponentiation-operator {} - transform-async-to-generator {} proposal-async-generator-functions {} proposal-object-rest-spread {} proposal-unicode-property-regex {} diff --git a/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-specific-targets/stdout.txt b/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-specific-targets/stdout.txt index a1a20c2c2999..2229f64bab90 100644 --- a/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-specific-targets/stdout.txt +++ b/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-specific-targets/stdout.txt @@ -35,7 +35,6 @@ Using plugins: transform-new-target { "edge":"13", "ie":"10", "ios":"9", "safari":"7" } transform-regenerator { "firefox":"49", "ie":"10", "ios":"9", "safari":"7" } transform-exponentiation-operator { "edge":"13", "firefox":"49", "ie":"10", "ios":"9", "safari":"7" } - transform-async-to-generator { "chrome":"54", "edge":"13", "firefox":"49", "ie":"10", "ios":"9", "safari":"7" } proposal-async-generator-functions { "chrome":"54", "edge":"13", "firefox":"49", "ie":"10", "ios":"9", "safari":"7" } proposal-object-rest-spread { "chrome":"54", "edge":"13", "firefox":"49", "ie":"10", "ios":"9", "safari":"7" } proposal-unicode-property-regex { "chrome":"54", "edge":"13", "firefox":"49", "ie":"10", "ios":"9", "safari":"7" } @@ -246,7 +245,7 @@ Using polyfills with `entry` option: es.weak-set { "edge":"13", "firefox":"49", "ie":"10", "ios":"9", "safari":"7" } web.dom-collections.for-each { "chrome":"54", "edge":"13", "firefox":"49", "ie":"10", "ios":"9", "safari":"7" } web.dom-collections.iterator { "chrome":"54", "edge":"13", "firefox":"49", "ie":"10", "ios":"9", "safari":"7" } - web.immediate { "chrome":"54", "firefox":"49", "ios":"9", "safari":"7" } + web.immediate { "chrome":"54", "edge":"13", "firefox":"49", "ios":"9", "safari":"7" } web.queue-microtask { "chrome":"54", "edge":"13", "firefox":"49", "ie":"10", "ios":"9", "safari":"7" } web.url { "chrome":"54", "edge":"13", "firefox":"49", "ie":"10", "ios":"9", "safari":"7" } web.url.to-json { "chrome":"54", "edge":"13", "firefox":"49", "ie":"10", "ios":"9", "safari":"7" } diff --git a/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-stable/stdout.txt b/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-stable/stdout.txt index 38e8356a3478..223ef746fda9 100644 --- a/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-stable/stdout.txt +++ b/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-stable/stdout.txt @@ -28,7 +28,6 @@ Using plugins: transform-new-target {} transform-regenerator {} transform-exponentiation-operator {} - transform-async-to-generator {} proposal-async-generator-functions {} proposal-object-rest-spread {} proposal-unicode-property-regex {} diff --git a/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-stage/stdout.txt b/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-stage/stdout.txt index 5380e1c89aa6..9cee893f2a2e 100644 --- a/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-stage/stdout.txt +++ b/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-stage/stdout.txt @@ -28,7 +28,6 @@ Using plugins: transform-new-target {} transform-regenerator {} transform-exponentiation-operator {} - transform-async-to-generator {} proposal-async-generator-functions {} proposal-object-rest-spread {} proposal-unicode-property-regex {} diff --git a/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-versions-decimals/stdout.txt b/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-versions-decimals/stdout.txt index efcedad873c6..ad6cde3c24aa 100644 --- a/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-versions-decimals/stdout.txt +++ b/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-versions-decimals/stdout.txt @@ -41,7 +41,6 @@ Using plugins: transform-new-target { "ie":"10" } transform-regenerator { "electron":"0.36", "ie":"10" } transform-exponentiation-operator { "electron":"0.36", "ie":"10", "node":"6.1" } - transform-async-to-generator { "chrome":"54", "electron":"0.36", "ie":"10", "node":"6.1" } proposal-async-generator-functions { "chrome":"54", "electron":"0.36", "ie":"10", "node":"6.1" } proposal-object-rest-spread { "chrome":"54", "electron":"0.36", "ie":"10", "node":"6.1" } proposal-unicode-property-regex { "chrome":"54", "electron":"0.36", "ie":"10", "node":"6.1" } diff --git a/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-versions-strings-minor-3.0/stdout.txt b/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-versions-strings-minor-3.0/stdout.txt index af5f0f9ffe87..8d8cf7fe2333 100644 --- a/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-versions-strings-minor-3.0/stdout.txt +++ b/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-versions-strings-minor-3.0/stdout.txt @@ -32,7 +32,6 @@ Using plugins: transform-new-target { "ie":"10" } transform-regenerator { "ie":"10" } transform-exponentiation-operator { "ie":"10", "node":"6.10" } - transform-async-to-generator { "chrome":"54", "ie":"10", "node":"6.10" } proposal-async-generator-functions { "chrome":"54", "ie":"10", "node":"6.10" } proposal-object-rest-spread { "chrome":"54", "ie":"10", "node":"6.10" } proposal-unicode-property-regex { "chrome":"54", "ie":"10", "node":"6.10" } diff --git a/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-versions-strings-minor-3.1/stdout.txt b/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-versions-strings-minor-3.1/stdout.txt index c74e3e37cb55..31c21bace19c 100644 --- a/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-versions-strings-minor-3.1/stdout.txt +++ b/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-versions-strings-minor-3.1/stdout.txt @@ -32,7 +32,6 @@ Using plugins: transform-new-target { "ie":"10" } transform-regenerator { "ie":"10" } transform-exponentiation-operator { "ie":"10", "node":"6.10" } - transform-async-to-generator { "chrome":"54", "ie":"10", "node":"6.10" } proposal-async-generator-functions { "chrome":"54", "ie":"10", "node":"6.10" } proposal-object-rest-spread { "chrome":"54", "ie":"10", "node":"6.10" } proposal-unicode-property-regex { "chrome":"54", "ie":"10", "node":"6.10" } diff --git a/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-versions-strings/stdout.txt b/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-versions-strings/stdout.txt index caff30ef4984..74c154a2b26d 100644 --- a/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-versions-strings/stdout.txt +++ b/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-versions-strings/stdout.txt @@ -32,7 +32,6 @@ Using plugins: transform-new-target { "ie":"10" } transform-regenerator { "ie":"10" } transform-exponentiation-operator { "ie":"10", "node":"6.10" } - transform-async-to-generator { "chrome":"54", "ie":"10", "node":"6.10" } proposal-async-generator-functions { "chrome":"54", "ie":"10", "node":"6.10" } proposal-object-rest-spread { "chrome":"54", "ie":"10", "node":"6.10" } proposal-unicode-property-regex { "chrome":"54", "ie":"10", "node":"6.10" } diff --git a/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-web/stdout.txt b/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-web/stdout.txt index 9dea1a0f8905..d92ec30279e3 100644 --- a/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-web/stdout.txt +++ b/packages/babel-preset-env/test/fixtures/debug/entry-corejs3-web/stdout.txt @@ -28,7 +28,6 @@ Using plugins: transform-new-target {} transform-regenerator {} transform-exponentiation-operator {} - transform-async-to-generator {} proposal-async-generator-functions {} proposal-object-rest-spread {} proposal-unicode-property-regex {} diff --git a/packages/babel-preset-env/test/fixtures/debug/entry-corejs3/stdout.txt b/packages/babel-preset-env/test/fixtures/debug/entry-corejs3/stdout.txt index b337515f602d..a35cd149137c 100644 --- a/packages/babel-preset-env/test/fixtures/debug/entry-corejs3/stdout.txt +++ b/packages/babel-preset-env/test/fixtures/debug/entry-corejs3/stdout.txt @@ -32,7 +32,6 @@ Using plugins: transform-new-target { "ie":"10" } transform-regenerator { "ie":"10" } transform-exponentiation-operator { "ie":"10", "node":"6" } - transform-async-to-generator { "chrome":"54", "ie":"10", "node":"6" } proposal-async-generator-functions { "chrome":"54", "ie":"10", "node":"6" } proposal-object-rest-spread { "chrome":"54", "ie":"10", "node":"6" } proposal-unicode-property-regex { "chrome":"54", "ie":"10", "node":"6" } diff --git a/packages/babel-preset-env/test/fixtures/debug/entry-no-corejs-shippedProposals/stdout.txt b/packages/babel-preset-env/test/fixtures/debug/entry-no-corejs-shippedProposals/stdout.txt index 621161013483..e28519a1f6ad 100644 --- a/packages/babel-preset-env/test/fixtures/debug/entry-no-corejs-shippedProposals/stdout.txt +++ b/packages/babel-preset-env/test/fixtures/debug/entry-no-corejs-shippedProposals/stdout.txt @@ -28,7 +28,6 @@ Using plugins: transform-new-target {} transform-regenerator {} transform-exponentiation-operator {} - transform-async-to-generator {} proposal-async-generator-functions {} proposal-object-rest-spread {} proposal-unicode-property-regex {} diff --git a/packages/babel-preset-env/test/fixtures/debug/entry-no-corejs-uglify/stdout.txt b/packages/babel-preset-env/test/fixtures/debug/entry-no-corejs-uglify/stdout.txt index c773b35d1314..d051b5019f6b 100644 --- a/packages/babel-preset-env/test/fixtures/debug/entry-no-corejs-uglify/stdout.txt +++ b/packages/babel-preset-env/test/fixtures/debug/entry-no-corejs-uglify/stdout.txt @@ -33,7 +33,6 @@ Using plugins: transform-new-target {} transform-regenerator {} transform-exponentiation-operator {} - transform-async-to-generator {} proposal-async-generator-functions { "chrome":"55" } proposal-object-rest-spread { "chrome":"55" } proposal-unicode-property-regex { "chrome":"55" } diff --git a/packages/babel-preset-env/test/fixtures/debug/entry-no-corejs/stdout.txt b/packages/babel-preset-env/test/fixtures/debug/entry-no-corejs/stdout.txt index b070fd82ae2c..596d823fbcd7 100644 --- a/packages/babel-preset-env/test/fixtures/debug/entry-no-corejs/stdout.txt +++ b/packages/babel-preset-env/test/fixtures/debug/entry-no-corejs/stdout.txt @@ -32,7 +32,6 @@ Using plugins: transform-new-target { "ie":"10" } transform-regenerator { "ie":"10" } transform-exponentiation-operator { "ie":"10", "node":"6" } - transform-async-to-generator { "chrome":"54", "ie":"10", "node":"6" } proposal-async-generator-functions { "chrome":"54", "ie":"10", "node":"6" } proposal-object-rest-spread { "chrome":"54", "ie":"10", "node":"6" } proposal-unicode-property-regex { "chrome":"54", "ie":"10", "node":"6" } diff --git a/packages/babel-preset-env/test/fixtures/debug/usage-corejs2-1/stdout.txt b/packages/babel-preset-env/test/fixtures/debug/usage-corejs2-1/stdout.txt index 10a416642303..3a4742537bf8 100644 --- a/packages/babel-preset-env/test/fixtures/debug/usage-corejs2-1/stdout.txt +++ b/packages/babel-preset-env/test/fixtures/debug/usage-corejs2-1/stdout.txt @@ -31,7 +31,6 @@ Using plugins: transform-new-target { "ie":"11" } transform-regenerator { "firefox":"50", "ie":"11" } transform-exponentiation-operator { "firefox":"50", "ie":"11" } - transform-async-to-generator { "chrome":"52", "firefox":"50", "ie":"11" } proposal-async-generator-functions { "chrome":"52", "firefox":"50", "ie":"11" } proposal-object-rest-spread { "chrome":"52", "firefox":"50", "ie":"11" } proposal-unicode-property-regex { "chrome":"52", "firefox":"50", "ie":"11" } diff --git a/packages/babel-preset-env/test/fixtures/debug/usage-corejs2-2/stdout.txt b/packages/babel-preset-env/test/fixtures/debug/usage-corejs2-2/stdout.txt index c6bd456f09c6..7337bd97a95e 100644 --- a/packages/babel-preset-env/test/fixtures/debug/usage-corejs2-2/stdout.txt +++ b/packages/babel-preset-env/test/fixtures/debug/usage-corejs2-2/stdout.txt @@ -31,7 +31,6 @@ Using plugins: transform-new-target { "ie":"11" } transform-regenerator { "firefox":"50", "ie":"11" } transform-exponentiation-operator { "firefox":"50", "ie":"11" } - transform-async-to-generator { "chrome":"52", "firefox":"50", "ie":"11" } proposal-async-generator-functions { "chrome":"52", "firefox":"50", "ie":"11" } proposal-object-rest-spread { "chrome":"52", "firefox":"50", "ie":"11" } proposal-unicode-property-regex { "chrome":"52", "firefox":"50", "ie":"11" } diff --git a/packages/babel-preset-env/test/fixtures/debug/usage-corejs2-none-1/stdout.txt b/packages/babel-preset-env/test/fixtures/debug/usage-corejs2-none-1/stdout.txt index 83701579d0ee..f17969a7c09a 100644 --- a/packages/babel-preset-env/test/fixtures/debug/usage-corejs2-none-1/stdout.txt +++ b/packages/babel-preset-env/test/fixtures/debug/usage-corejs2-none-1/stdout.txt @@ -31,7 +31,6 @@ Using plugins: transform-new-target { "ie":"11" } transform-regenerator { "firefox":"50", "ie":"11" } transform-exponentiation-operator { "firefox":"50", "ie":"11" } - transform-async-to-generator { "chrome":"52", "firefox":"50", "ie":"11" } proposal-async-generator-functions { "chrome":"52", "firefox":"50", "ie":"11" } proposal-object-rest-spread { "chrome":"52", "firefox":"50", "ie":"11" } proposal-unicode-property-regex { "chrome":"52", "firefox":"50", "ie":"11" } diff --git a/packages/babel-preset-env/test/fixtures/debug/usage-corejs2-none-2/stdout.txt b/packages/babel-preset-env/test/fixtures/debug/usage-corejs2-none-2/stdout.txt index d0cc380462d3..0c1cce6bfe7d 100644 --- a/packages/babel-preset-env/test/fixtures/debug/usage-corejs2-none-2/stdout.txt +++ b/packages/babel-preset-env/test/fixtures/debug/usage-corejs2-none-2/stdout.txt @@ -31,7 +31,6 @@ Using plugins: transform-new-target { "ie":"11" } transform-regenerator { "firefox":"50", "ie":"11" } transform-exponentiation-operator { "firefox":"50", "ie":"11" } - transform-async-to-generator { "chrome":"52", "firefox":"50", "ie":"11" } proposal-async-generator-functions { "chrome":"52", "firefox":"50", "ie":"11" } proposal-object-rest-spread { "chrome":"52", "firefox":"50", "ie":"11" } proposal-unicode-property-regex { "chrome":"52", "firefox":"50", "ie":"11" } diff --git a/packages/babel-preset-env/test/fixtures/debug/usage-corejs2-proposals-1/stdout.txt b/packages/babel-preset-env/test/fixtures/debug/usage-corejs2-proposals-1/stdout.txt index f7f567c4c47a..54f7d2b6892c 100644 --- a/packages/babel-preset-env/test/fixtures/debug/usage-corejs2-proposals-1/stdout.txt +++ b/packages/babel-preset-env/test/fixtures/debug/usage-corejs2-proposals-1/stdout.txt @@ -31,7 +31,6 @@ Using plugins: transform-new-target { "ie":"11" } transform-regenerator { "firefox":"50", "ie":"11" } transform-exponentiation-operator { "firefox":"50", "ie":"11" } - transform-async-to-generator { "chrome":"52", "firefox":"50", "ie":"11" } proposal-async-generator-functions { "chrome":"52", "firefox":"50", "ie":"11" } proposal-object-rest-spread { "chrome":"52", "firefox":"50", "ie":"11" } proposal-unicode-property-regex { "chrome":"52", "firefox":"50", "ie":"11" } diff --git a/packages/babel-preset-env/test/fixtures/debug/usage-corejs2-proposals-2/stdout.txt b/packages/babel-preset-env/test/fixtures/debug/usage-corejs2-proposals-2/stdout.txt index 8f4c5e1df667..f251da3a1fb9 100644 --- a/packages/babel-preset-env/test/fixtures/debug/usage-corejs2-proposals-2/stdout.txt +++ b/packages/babel-preset-env/test/fixtures/debug/usage-corejs2-proposals-2/stdout.txt @@ -31,7 +31,6 @@ Using plugins: transform-new-target { "ie":"11" } transform-regenerator { "firefox":"50", "ie":"11" } transform-exponentiation-operator { "firefox":"50", "ie":"11" } - transform-async-to-generator { "chrome":"52", "firefox":"50", "ie":"11" } proposal-async-generator-functions { "chrome":"52", "firefox":"50", "ie":"11" } proposal-object-rest-spread { "chrome":"52", "firefox":"50", "ie":"11" } proposal-unicode-property-regex { "chrome":"52", "firefox":"50", "ie":"11" } diff --git a/packages/babel-preset-env/test/fixtures/debug/usage-corejs2-shippedProposals-1/stdout.txt b/packages/babel-preset-env/test/fixtures/debug/usage-corejs2-shippedProposals-1/stdout.txt index f456fc31c325..65b636097824 100644 --- a/packages/babel-preset-env/test/fixtures/debug/usage-corejs2-shippedProposals-1/stdout.txt +++ b/packages/babel-preset-env/test/fixtures/debug/usage-corejs2-shippedProposals-1/stdout.txt @@ -31,7 +31,6 @@ Using plugins: transform-new-target { "ie":"11" } transform-regenerator { "firefox":"50", "ie":"11" } transform-exponentiation-operator { "firefox":"50", "ie":"11" } - transform-async-to-generator { "chrome":"52", "firefox":"50", "ie":"11" } proposal-async-generator-functions { "chrome":"52", "firefox":"50", "ie":"11" } proposal-object-rest-spread { "chrome":"52", "firefox":"50", "ie":"11" } proposal-unicode-property-regex { "chrome":"52", "firefox":"50", "ie":"11" } diff --git a/packages/babel-preset-env/test/fixtures/debug/usage-corejs2-shippedProposals-2/stdout.txt b/packages/babel-preset-env/test/fixtures/debug/usage-corejs2-shippedProposals-2/stdout.txt index 14c735dcba8c..baea99e275f5 100644 --- a/packages/babel-preset-env/test/fixtures/debug/usage-corejs2-shippedProposals-2/stdout.txt +++ b/packages/babel-preset-env/test/fixtures/debug/usage-corejs2-shippedProposals-2/stdout.txt @@ -31,7 +31,6 @@ Using plugins: transform-new-target { "ie":"11" } transform-regenerator { "firefox":"50", "ie":"11" } transform-exponentiation-operator { "firefox":"50", "ie":"11" } - transform-async-to-generator { "chrome":"52", "firefox":"50", "ie":"11" } proposal-async-generator-functions { "chrome":"52", "firefox":"50", "ie":"11" } proposal-object-rest-spread { "chrome":"52", "firefox":"50", "ie":"11" } proposal-unicode-property-regex { "chrome":"52", "firefox":"50", "ie":"11" } diff --git a/packages/babel-preset-env/test/fixtures/debug/usage-corejs3-1/stdout.txt b/packages/babel-preset-env/test/fixtures/debug/usage-corejs3-1/stdout.txt index ce78b1615fa3..5420011af7ff 100644 --- a/packages/babel-preset-env/test/fixtures/debug/usage-corejs3-1/stdout.txt +++ b/packages/babel-preset-env/test/fixtures/debug/usage-corejs3-1/stdout.txt @@ -31,7 +31,6 @@ Using plugins: transform-new-target { "ie":"11" } transform-regenerator { "firefox":"50", "ie":"11" } transform-exponentiation-operator { "firefox":"50", "ie":"11" } - transform-async-to-generator { "chrome":"52", "firefox":"50", "ie":"11" } proposal-async-generator-functions { "chrome":"52", "firefox":"50", "ie":"11" } proposal-object-rest-spread { "chrome":"52", "firefox":"50", "ie":"11" } proposal-unicode-property-regex { "chrome":"52", "firefox":"50", "ie":"11" } diff --git a/packages/babel-preset-env/test/fixtures/debug/usage-corejs3-2/stdout.txt b/packages/babel-preset-env/test/fixtures/debug/usage-corejs3-2/stdout.txt index 4545ec9ddac5..51c71b8b36d6 100644 --- a/packages/babel-preset-env/test/fixtures/debug/usage-corejs3-2/stdout.txt +++ b/packages/babel-preset-env/test/fixtures/debug/usage-corejs3-2/stdout.txt @@ -31,7 +31,6 @@ Using plugins: transform-new-target { "ie":"11" } transform-regenerator { "firefox":"50", "ie":"11" } transform-exponentiation-operator { "firefox":"50", "ie":"11" } - transform-async-to-generator { "chrome":"52", "firefox":"50", "ie":"11" } proposal-async-generator-functions { "chrome":"52", "firefox":"50", "ie":"11" } proposal-object-rest-spread { "chrome":"52", "firefox":"50", "ie":"11" } proposal-unicode-property-regex { "chrome":"52", "firefox":"50", "ie":"11" } diff --git a/packages/babel-preset-env/test/fixtures/debug/usage-corejs3-none-1/stdout.txt b/packages/babel-preset-env/test/fixtures/debug/usage-corejs3-none-1/stdout.txt index 5effbeed1198..0cb836caf43e 100644 --- a/packages/babel-preset-env/test/fixtures/debug/usage-corejs3-none-1/stdout.txt +++ b/packages/babel-preset-env/test/fixtures/debug/usage-corejs3-none-1/stdout.txt @@ -31,7 +31,6 @@ Using plugins: transform-new-target { "ie":"11" } transform-regenerator { "firefox":"50", "ie":"11" } transform-exponentiation-operator { "firefox":"50", "ie":"11" } - transform-async-to-generator { "chrome":"52", "firefox":"50", "ie":"11" } proposal-async-generator-functions { "chrome":"52", "firefox":"50", "ie":"11" } proposal-object-rest-spread { "chrome":"52", "firefox":"50", "ie":"11" } proposal-unicode-property-regex { "chrome":"52", "firefox":"50", "ie":"11" } diff --git a/packages/babel-preset-env/test/fixtures/debug/usage-corejs3-none-2/stdout.txt b/packages/babel-preset-env/test/fixtures/debug/usage-corejs3-none-2/stdout.txt index 999084137006..0ca472fb637f 100644 --- a/packages/babel-preset-env/test/fixtures/debug/usage-corejs3-none-2/stdout.txt +++ b/packages/babel-preset-env/test/fixtures/debug/usage-corejs3-none-2/stdout.txt @@ -31,7 +31,6 @@ Using plugins: transform-new-target { "ie":"11" } transform-regenerator { "firefox":"50", "ie":"11" } transform-exponentiation-operator { "firefox":"50", "ie":"11" } - transform-async-to-generator { "chrome":"52", "firefox":"50", "ie":"11" } proposal-async-generator-functions { "chrome":"52", "firefox":"50", "ie":"11" } proposal-object-rest-spread { "chrome":"52", "firefox":"50", "ie":"11" } proposal-unicode-property-regex { "chrome":"52", "firefox":"50", "ie":"11" } diff --git a/packages/babel-preset-env/test/fixtures/debug/usage-corejs3-proposals-1/stdout.txt b/packages/babel-preset-env/test/fixtures/debug/usage-corejs3-proposals-1/stdout.txt index 4f5e93bc1d2a..a1c85b5f240b 100644 --- a/packages/babel-preset-env/test/fixtures/debug/usage-corejs3-proposals-1/stdout.txt +++ b/packages/babel-preset-env/test/fixtures/debug/usage-corejs3-proposals-1/stdout.txt @@ -31,7 +31,6 @@ Using plugins: transform-new-target { "ie":"11" } transform-regenerator { "firefox":"50", "ie":"11" } transform-exponentiation-operator { "firefox":"50", "ie":"11" } - transform-async-to-generator { "chrome":"52", "firefox":"50", "ie":"11" } proposal-async-generator-functions { "chrome":"52", "firefox":"50", "ie":"11" } proposal-object-rest-spread { "chrome":"52", "firefox":"50", "ie":"11" } proposal-unicode-property-regex { "chrome":"52", "firefox":"50", "ie":"11" } diff --git a/packages/babel-preset-env/test/fixtures/debug/usage-corejs3-proposals-2/stdout.txt b/packages/babel-preset-env/test/fixtures/debug/usage-corejs3-proposals-2/stdout.txt index c7b2d3da53a4..d21f014f1314 100644 --- a/packages/babel-preset-env/test/fixtures/debug/usage-corejs3-proposals-2/stdout.txt +++ b/packages/babel-preset-env/test/fixtures/debug/usage-corejs3-proposals-2/stdout.txt @@ -31,7 +31,6 @@ Using plugins: transform-new-target { "ie":"11" } transform-regenerator { "firefox":"50", "ie":"11" } transform-exponentiation-operator { "firefox":"50", "ie":"11" } - transform-async-to-generator { "chrome":"52", "firefox":"50", "ie":"11" } proposal-async-generator-functions { "chrome":"52", "firefox":"50", "ie":"11" } proposal-object-rest-spread { "chrome":"52", "firefox":"50", "ie":"11" } proposal-unicode-property-regex { "chrome":"52", "firefox":"50", "ie":"11" } diff --git a/packages/babel-preset-env/test/fixtures/debug/usage-corejs3-shippedProposals-1/stdout.txt b/packages/babel-preset-env/test/fixtures/debug/usage-corejs3-shippedProposals-1/stdout.txt index 3186c00e2458..56aa662832b0 100644 --- a/packages/babel-preset-env/test/fixtures/debug/usage-corejs3-shippedProposals-1/stdout.txt +++ b/packages/babel-preset-env/test/fixtures/debug/usage-corejs3-shippedProposals-1/stdout.txt @@ -31,7 +31,6 @@ Using plugins: transform-new-target { "ie":"11" } transform-regenerator { "firefox":"50", "ie":"11" } transform-exponentiation-operator { "firefox":"50", "ie":"11" } - transform-async-to-generator { "chrome":"52", "firefox":"50", "ie":"11" } proposal-async-generator-functions { "chrome":"52", "firefox":"50", "ie":"11" } proposal-object-rest-spread { "chrome":"52", "firefox":"50", "ie":"11" } proposal-unicode-property-regex { "chrome":"52", "firefox":"50", "ie":"11" } diff --git a/packages/babel-preset-env/test/fixtures/debug/usage-corejs3-shippedProposals-2/stdout.txt b/packages/babel-preset-env/test/fixtures/debug/usage-corejs3-shippedProposals-2/stdout.txt index ed270ec46b29..848d033d61be 100644 --- a/packages/babel-preset-env/test/fixtures/debug/usage-corejs3-shippedProposals-2/stdout.txt +++ b/packages/babel-preset-env/test/fixtures/debug/usage-corejs3-shippedProposals-2/stdout.txt @@ -31,7 +31,6 @@ Using plugins: transform-new-target { "ie":"11" } transform-regenerator { "firefox":"50", "ie":"11" } transform-exponentiation-operator { "firefox":"50", "ie":"11" } - transform-async-to-generator { "chrome":"52", "firefox":"50", "ie":"11" } proposal-async-generator-functions { "chrome":"52", "firefox":"50", "ie":"11" } proposal-object-rest-spread { "chrome":"52", "firefox":"50", "ie":"11" } proposal-unicode-property-regex { "chrome":"52", "firefox":"50", "ie":"11" } diff --git a/packages/babel-preset-env/test/fixtures/debug/usage-corejs3-versions-strings-minor-3.0-1/stdout.txt b/packages/babel-preset-env/test/fixtures/debug/usage-corejs3-versions-strings-minor-3.0-1/stdout.txt index 1fcbf70cef28..d7384c46888d 100644 --- a/packages/babel-preset-env/test/fixtures/debug/usage-corejs3-versions-strings-minor-3.0-1/stdout.txt +++ b/packages/babel-preset-env/test/fixtures/debug/usage-corejs3-versions-strings-minor-3.0-1/stdout.txt @@ -31,7 +31,6 @@ Using plugins: transform-new-target { "ie":"11" } transform-regenerator { "firefox":"50", "ie":"11" } transform-exponentiation-operator { "firefox":"50", "ie":"11" } - transform-async-to-generator { "chrome":"52", "firefox":"50", "ie":"11" } proposal-async-generator-functions { "chrome":"52", "firefox":"50", "ie":"11" } proposal-object-rest-spread { "chrome":"52", "firefox":"50", "ie":"11" } proposal-unicode-property-regex { "chrome":"52", "firefox":"50", "ie":"11" } diff --git a/packages/babel-preset-env/test/fixtures/debug/usage-corejs3-versions-strings-minor-3.0-2/stdout.txt b/packages/babel-preset-env/test/fixtures/debug/usage-corejs3-versions-strings-minor-3.0-2/stdout.txt index 1b7bf00896fb..3897ddf434ae 100644 --- a/packages/babel-preset-env/test/fixtures/debug/usage-corejs3-versions-strings-minor-3.0-2/stdout.txt +++ b/packages/babel-preset-env/test/fixtures/debug/usage-corejs3-versions-strings-minor-3.0-2/stdout.txt @@ -31,7 +31,6 @@ Using plugins: transform-new-target { "ie":"11" } transform-regenerator { "firefox":"50", "ie":"11" } transform-exponentiation-operator { "firefox":"50", "ie":"11" } - transform-async-to-generator { "chrome":"52", "firefox":"50", "ie":"11" } proposal-async-generator-functions { "chrome":"52", "firefox":"50", "ie":"11" } proposal-object-rest-spread { "chrome":"52", "firefox":"50", "ie":"11" } proposal-unicode-property-regex { "chrome":"52", "firefox":"50", "ie":"11" } diff --git a/packages/babel-preset-env/test/fixtures/debug/usage-corejs3-versions-strings-minor-3.1-1/stdout.txt b/packages/babel-preset-env/test/fixtures/debug/usage-corejs3-versions-strings-minor-3.1-1/stdout.txt index 7df78cdbe879..31bc70824f26 100644 --- a/packages/babel-preset-env/test/fixtures/debug/usage-corejs3-versions-strings-minor-3.1-1/stdout.txt +++ b/packages/babel-preset-env/test/fixtures/debug/usage-corejs3-versions-strings-minor-3.1-1/stdout.txt @@ -31,7 +31,6 @@ Using plugins: transform-new-target { "ie":"11" } transform-regenerator { "firefox":"50", "ie":"11" } transform-exponentiation-operator { "firefox":"50", "ie":"11" } - transform-async-to-generator { "chrome":"52", "firefox":"50", "ie":"11" } proposal-async-generator-functions { "chrome":"52", "firefox":"50", "ie":"11" } proposal-object-rest-spread { "chrome":"52", "firefox":"50", "ie":"11" } proposal-unicode-property-regex { "chrome":"52", "firefox":"50", "ie":"11" } diff --git a/packages/babel-preset-env/test/fixtures/debug/usage-corejs3-versions-strings-minor-3.1-2/stdout.txt b/packages/babel-preset-env/test/fixtures/debug/usage-corejs3-versions-strings-minor-3.1-2/stdout.txt index 2dba4464ffa8..29b751d07ae8 100644 --- a/packages/babel-preset-env/test/fixtures/debug/usage-corejs3-versions-strings-minor-3.1-2/stdout.txt +++ b/packages/babel-preset-env/test/fixtures/debug/usage-corejs3-versions-strings-minor-3.1-2/stdout.txt @@ -31,7 +31,6 @@ Using plugins: transform-new-target { "ie":"11" } transform-regenerator { "firefox":"50", "ie":"11" } transform-exponentiation-operator { "firefox":"50", "ie":"11" } - transform-async-to-generator { "chrome":"52", "firefox":"50", "ie":"11" } proposal-async-generator-functions { "chrome":"52", "firefox":"50", "ie":"11" } proposal-object-rest-spread { "chrome":"52", "firefox":"50", "ie":"11" } proposal-unicode-property-regex { "chrome":"52", "firefox":"50", "ie":"11" } diff --git a/packages/babel-preset-env/test/fixtures/debug/usage-no-corejs-1/stdout.txt b/packages/babel-preset-env/test/fixtures/debug/usage-no-corejs-1/stdout.txt index 211854dc7a12..eb4cf5b632c2 100644 --- a/packages/babel-preset-env/test/fixtures/debug/usage-no-corejs-1/stdout.txt +++ b/packages/babel-preset-env/test/fixtures/debug/usage-no-corejs-1/stdout.txt @@ -31,7 +31,6 @@ Using plugins: transform-new-target { "ie":"11" } transform-regenerator { "firefox":"50", "ie":"11" } transform-exponentiation-operator { "firefox":"50", "ie":"11" } - transform-async-to-generator { "chrome":"52", "firefox":"50", "ie":"11" } proposal-async-generator-functions { "chrome":"52", "firefox":"50", "ie":"11" } proposal-object-rest-spread { "chrome":"52", "firefox":"50", "ie":"11" } proposal-unicode-property-regex { "chrome":"52", "firefox":"50", "ie":"11" } diff --git a/packages/babel-preset-env/test/fixtures/debug/usage-no-corejs-2/stdout.txt b/packages/babel-preset-env/test/fixtures/debug/usage-no-corejs-2/stdout.txt index 90c9d87ef822..77a2227dde4e 100644 --- a/packages/babel-preset-env/test/fixtures/debug/usage-no-corejs-2/stdout.txt +++ b/packages/babel-preset-env/test/fixtures/debug/usage-no-corejs-2/stdout.txt @@ -31,7 +31,6 @@ Using plugins: transform-new-target { "ie":"11" } transform-regenerator { "firefox":"50", "ie":"11" } transform-exponentiation-operator { "firefox":"50", "ie":"11" } - transform-async-to-generator { "chrome":"52", "firefox":"50", "ie":"11" } proposal-async-generator-functions { "chrome":"52", "firefox":"50", "ie":"11" } proposal-object-rest-spread { "chrome":"52", "firefox":"50", "ie":"11" } proposal-unicode-property-regex { "chrome":"52", "firefox":"50", "ie":"11" } diff --git a/packages/babel-preset-env/test/fixtures/debug/usage-no-corejs-none-1/stdout.txt b/packages/babel-preset-env/test/fixtures/debug/usage-no-corejs-none-1/stdout.txt index 6afbb5cd98f5..d2f78b1901c6 100644 --- a/packages/babel-preset-env/test/fixtures/debug/usage-no-corejs-none-1/stdout.txt +++ b/packages/babel-preset-env/test/fixtures/debug/usage-no-corejs-none-1/stdout.txt @@ -31,7 +31,6 @@ Using plugins: transform-new-target { "ie":"11" } transform-regenerator { "firefox":"50", "ie":"11" } transform-exponentiation-operator { "firefox":"50", "ie":"11" } - transform-async-to-generator { "chrome":"52", "firefox":"50", "ie":"11" } proposal-async-generator-functions { "chrome":"52", "firefox":"50", "ie":"11" } proposal-object-rest-spread { "chrome":"52", "firefox":"50", "ie":"11" } proposal-unicode-property-regex { "chrome":"52", "firefox":"50", "ie":"11" } diff --git a/packages/babel-preset-env/test/fixtures/debug/usage-no-corejs-none-2/stdout.txt b/packages/babel-preset-env/test/fixtures/debug/usage-no-corejs-none-2/stdout.txt index 5d3445c8f14f..cc7e91a5d56d 100644 --- a/packages/babel-preset-env/test/fixtures/debug/usage-no-corejs-none-2/stdout.txt +++ b/packages/babel-preset-env/test/fixtures/debug/usage-no-corejs-none-2/stdout.txt @@ -31,7 +31,6 @@ Using plugins: transform-new-target { "ie":"11" } transform-regenerator { "firefox":"50", "ie":"11" } transform-exponentiation-operator { "firefox":"50", "ie":"11" } - transform-async-to-generator { "chrome":"52", "firefox":"50", "ie":"11" } proposal-async-generator-functions { "chrome":"52", "firefox":"50", "ie":"11" } proposal-object-rest-spread { "chrome":"52", "firefox":"50", "ie":"11" } proposal-unicode-property-regex { "chrome":"52", "firefox":"50", "ie":"11" } diff --git a/packages/babel-preset-env/test/fixtures/dynamic-import/auto-esm-unsupported-import-unsupported/output.js b/packages/babel-preset-env/test/fixtures/dynamic-import/auto-esm-unsupported-import-unsupported/output.js index d71f23bfef4b..a7f2edabb858 100644 --- a/packages/babel-preset-env/test/fixtures/dynamic-import/auto-esm-unsupported-import-unsupported/output.js +++ b/packages/babel-preset-env/test/fixtures/dynamic-import/auto-esm-unsupported-import-unsupported/output.js @@ -4,7 +4,7 @@ function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterat function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; } -function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; if (obj != null) { var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; } +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; } Promise.resolve().then(function () { return _interopRequireWildcard(require("foo")); diff --git a/packages/babel-preset-env/test/fixtures/dynamic-import/modules-amd/output.js b/packages/babel-preset-env/test/fixtures/dynamic-import/modules-amd/output.js index 000247047cd4..f1ca949bbcb1 100644 --- a/packages/babel-preset-env/test/fixtures/dynamic-import/modules-amd/output.js +++ b/packages/babel-preset-env/test/fixtures/dynamic-import/modules-amd/output.js @@ -3,7 +3,7 @@ define(["require"], function (_require) { function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; } - function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; if (obj != null) { var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; } + function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; } new Promise(function (_resolve, _reject) { return _require(["foo"], function (imported) { diff --git a/packages/babel-preset-env/test/fixtures/dynamic-import/modules-cjs/output.js b/packages/babel-preset-env/test/fixtures/dynamic-import/modules-cjs/output.js index d71f23bfef4b..a7f2edabb858 100644 --- a/packages/babel-preset-env/test/fixtures/dynamic-import/modules-cjs/output.js +++ b/packages/babel-preset-env/test/fixtures/dynamic-import/modules-cjs/output.js @@ -4,7 +4,7 @@ function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterat function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; } -function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; if (obj != null) { var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; } +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; } Promise.resolve().then(function () { return _interopRequireWildcard(require("foo")); diff --git a/packages/babel-preset-env/test/fixtures/dynamic-import/modules-umd/output.js b/packages/babel-preset-env/test/fixtures/dynamic-import/modules-umd/output.js index f66adb1fb317..f4b267b43c0b 100644 --- a/packages/babel-preset-env/test/fixtures/dynamic-import/modules-umd/output.js +++ b/packages/babel-preset-env/test/fixtures/dynamic-import/modules-umd/output.js @@ -10,7 +10,7 @@ factory(); global.input = mod.exports; } -})(this, function () { +})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function () { "use strict"; import("foo"); // warns diff --git a/packages/babel-preset-env/test/fixtures/modules/modules-umd/output.js b/packages/babel-preset-env/test/fixtures/modules/modules-umd/output.js index 231614902dde..f4afd867e11a 100644 --- a/packages/babel-preset-env/test/fixtures/modules/modules-umd/output.js +++ b/packages/babel-preset-env/test/fixtures/modules/modules-umd/output.js @@ -10,7 +10,7 @@ factory(global.a); global.input = mod.exports; } -})(this, function (_a) { +})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_a) { "use strict"; _a = _interopRequireDefault(_a); diff --git a/packages/babel-preset-env/test/fixtures/plugins-integration/issue-10662/input.mjs b/packages/babel-preset-env/test/fixtures/plugins-integration/issue-10662/input.mjs new file mode 100644 index 000000000000..99f2bc766393 --- /dev/null +++ b/packages/babel-preset-env/test/fixtures/plugins-integration/issue-10662/input.mjs @@ -0,0 +1,2 @@ +var globalThis = {}; +typeof globalThis; diff --git a/packages/babel-preset-env/test/fixtures/plugins-integration/issue-10662/options.json b/packages/babel-preset-env/test/fixtures/plugins-integration/issue-10662/options.json new file mode 100644 index 000000000000..00fdf1fb5d98 --- /dev/null +++ b/packages/babel-preset-env/test/fixtures/plugins-integration/issue-10662/options.json @@ -0,0 +1,14 @@ +{ + "presets": [ + [ + "env", + { + "modules": "umd", + "targets": [ + "Safari 8", + "IE 11" + ] + } + ] + ] +} diff --git a/packages/babel-preset-env/test/fixtures/plugins-integration/issue-10662/output.js b/packages/babel-preset-env/test/fixtures/plugins-integration/issue-10662/output.js new file mode 100644 index 000000000000..e13f6d324d73 --- /dev/null +++ b/packages/babel-preset-env/test/fixtures/plugins-integration/issue-10662/output.js @@ -0,0 +1,21 @@ +(function (global, factory) { + if (typeof define === "function" && define.amd) { + define([], factory); + } else if (typeof exports !== "undefined") { + factory(); + } else { + var mod = { + exports: {} + }; + factory(); + global.input = mod.exports; + } +})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function () { + "use strict"; + + function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + + var globalThis = {}; + + _typeof(globalThis); +}); diff --git a/packages/babel-preset-env/test/fixtures/plugins-integration/issue-8951/exec.js b/packages/babel-preset-env/test/fixtures/plugins-integration/issue-8951/exec.js new file mode 100644 index 000000000000..0372fa5d04ee --- /dev/null +++ b/packages/babel-preset-env/test/fixtures/plugins-integration/issue-8951/exec.js @@ -0,0 +1,3 @@ +expect(/.(?\p{ASCII})/su.exec("\nA").groups).toEqual({ + code: "A" +}); diff --git a/packages/babel-preset-env/test/fixtures/plugins-integration/issue-8951/options.json b/packages/babel-preset-env/test/fixtures/plugins-integration/issue-8951/options.json new file mode 100644 index 000000000000..26bf537b2805 --- /dev/null +++ b/packages/babel-preset-env/test/fixtures/plugins-integration/issue-8951/options.json @@ -0,0 +1,4 @@ +{ + "plugins": [], + "presets": ["../../../../lib"] +} diff --git a/packages/babel-preset-env/test/fixtures/plugins-integration/issue-9892/exec.js b/packages/babel-preset-env/test/fixtures/plugins-integration/issue-9892/exec.js new file mode 100644 index 000000000000..dad5dc1ba34f --- /dev/null +++ b/packages/babel-preset-env/test/fixtures/plugins-integration/issue-9892/exec.js @@ -0,0 +1 @@ +expect(/[\p{L}\d_]+/u.test('ŁŻŹĆ')).toBe(true); diff --git a/packages/babel-preset-env/test/fixtures/plugins-integration/issue-9892/options.json b/packages/babel-preset-env/test/fixtures/plugins-integration/issue-9892/options.json new file mode 100644 index 000000000000..26bf537b2805 --- /dev/null +++ b/packages/babel-preset-env/test/fixtures/plugins-integration/issue-9892/options.json @@ -0,0 +1,4 @@ +{ + "plugins": [], + "presets": ["../../../../lib"] +} diff --git a/packages/babel-preset-env/test/fixtures/plugins-overlapping/chrome-49/input.js b/packages/babel-preset-env/test/fixtures/plugins-overlapping/chrome-49/input.js new file mode 100644 index 000000000000..9604ae0250bb --- /dev/null +++ b/packages/babel-preset-env/test/fixtures/plugins-overlapping/chrome-49/input.js @@ -0,0 +1 @@ +async function foo() {} \ No newline at end of file diff --git a/packages/babel-preset-env/test/fixtures/plugins-overlapping/chrome-49/options.json b/packages/babel-preset-env/test/fixtures/plugins-overlapping/chrome-49/options.json new file mode 100644 index 000000000000..41ee66e16cc0 --- /dev/null +++ b/packages/babel-preset-env/test/fixtures/plugins-overlapping/chrome-49/options.json @@ -0,0 +1,11 @@ +{ + "plugins": [], + "presets": [ + [ + "../../../../lib", + { + "targets": { "chrome": "49" } + } + ] + ] +} diff --git a/packages/babel-preset-env/test/fixtures/plugins-overlapping/chrome-49/output.js b/packages/babel-preset-env/test/fixtures/plugins-overlapping/chrome-49/output.js new file mode 100644 index 000000000000..19684e4a4db3 --- /dev/null +++ b/packages/babel-preset-env/test/fixtures/plugins-overlapping/chrome-49/output.js @@ -0,0 +1,9 @@ +function foo() { + return regeneratorRuntime.async(function foo$(_context) { + while (1) switch (_context.prev = _context.next) { + case 0: + case "end": + return _context.stop(); + } + }); +} diff --git a/packages/babel-preset-env/test/fixtures/plugins-overlapping/chrome-50/input.js b/packages/babel-preset-env/test/fixtures/plugins-overlapping/chrome-50/input.js new file mode 100644 index 000000000000..9604ae0250bb --- /dev/null +++ b/packages/babel-preset-env/test/fixtures/plugins-overlapping/chrome-50/input.js @@ -0,0 +1 @@ +async function foo() {} \ No newline at end of file diff --git a/packages/babel-preset-env/test/fixtures/plugins-overlapping/chrome-50/options.json b/packages/babel-preset-env/test/fixtures/plugins-overlapping/chrome-50/options.json new file mode 100644 index 000000000000..df56e583e65b --- /dev/null +++ b/packages/babel-preset-env/test/fixtures/plugins-overlapping/chrome-50/options.json @@ -0,0 +1,11 @@ +{ + "plugins": [], + "presets": [ + [ + "../../../../lib", + { + "targets": { "chrome": "50" } + } + ] + ] +} diff --git a/packages/babel-preset-env/test/fixtures/plugins-overlapping/chrome-50/output.js b/packages/babel-preset-env/test/fixtures/plugins-overlapping/chrome-50/output.js new file mode 100644 index 000000000000..d69b16f0660c --- /dev/null +++ b/packages/babel-preset-env/test/fixtures/plugins-overlapping/chrome-50/output.js @@ -0,0 +1,12 @@ +function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } } + +function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; } + +function foo() { + return _foo.apply(this, arguments); +} + +function _foo() { + _foo = _asyncToGenerator(function* () {}); + return _foo.apply(this, arguments); +} diff --git a/packages/babel-preset-env/test/fixtures/plugins-overlapping/chrome-54/input.js b/packages/babel-preset-env/test/fixtures/plugins-overlapping/chrome-54/input.js new file mode 100644 index 000000000000..9604ae0250bb --- /dev/null +++ b/packages/babel-preset-env/test/fixtures/plugins-overlapping/chrome-54/input.js @@ -0,0 +1 @@ +async function foo() {} \ No newline at end of file diff --git a/packages/babel-preset-env/test/fixtures/plugins-overlapping/chrome-54/options.json b/packages/babel-preset-env/test/fixtures/plugins-overlapping/chrome-54/options.json new file mode 100644 index 000000000000..d76f324a91bb --- /dev/null +++ b/packages/babel-preset-env/test/fixtures/plugins-overlapping/chrome-54/options.json @@ -0,0 +1,11 @@ +{ + "plugins": [], + "presets": [ + [ + "../../../../lib", + { + "targets": { "chrome": "54" } + } + ] + ] +} diff --git a/packages/babel-preset-env/test/fixtures/plugins-overlapping/chrome-54/output.js b/packages/babel-preset-env/test/fixtures/plugins-overlapping/chrome-54/output.js new file mode 100644 index 000000000000..d69b16f0660c --- /dev/null +++ b/packages/babel-preset-env/test/fixtures/plugins-overlapping/chrome-54/output.js @@ -0,0 +1,12 @@ +function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } } + +function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; } + +function foo() { + return _foo.apply(this, arguments); +} + +function _foo() { + _foo = _asyncToGenerator(function* () {}); + return _foo.apply(this, arguments); +} diff --git a/packages/babel-preset-env/test/fixtures/plugins-overlapping/chrome-55/input.js b/packages/babel-preset-env/test/fixtures/plugins-overlapping/chrome-55/input.js new file mode 100644 index 000000000000..9604ae0250bb --- /dev/null +++ b/packages/babel-preset-env/test/fixtures/plugins-overlapping/chrome-55/input.js @@ -0,0 +1 @@ +async function foo() {} \ No newline at end of file diff --git a/packages/babel-preset-env/test/fixtures/plugins-overlapping/chrome-55/options.json b/packages/babel-preset-env/test/fixtures/plugins-overlapping/chrome-55/options.json new file mode 100644 index 000000000000..c08a917cbc95 --- /dev/null +++ b/packages/babel-preset-env/test/fixtures/plugins-overlapping/chrome-55/options.json @@ -0,0 +1,11 @@ +{ + "plugins": [], + "presets": [ + [ + "../../../../lib", + { + "targets": { "chrome": "55" } + } + ] + ] +} diff --git a/packages/babel-preset-env/test/fixtures/plugins-overlapping/chrome-55/output.js b/packages/babel-preset-env/test/fixtures/plugins-overlapping/chrome-55/output.js new file mode 100644 index 000000000000..f9df9686dd67 --- /dev/null +++ b/packages/babel-preset-env/test/fixtures/plugins-overlapping/chrome-55/output.js @@ -0,0 +1 @@ +async function foo() {} diff --git a/packages/babel-preset-env/test/fixtures/preset-options/shippedProposals/output.js b/packages/babel-preset-env/test/fixtures/preset-options/shippedProposals/output.js index 4719ee3716e8..36fd231345ab 100644 --- a/packages/babel-preset-env/test/fixtures/preset-options/shippedProposals/output.js +++ b/packages/babel-preset-env/test/fixtures/preset-options/shippedProposals/output.js @@ -1,6 +1,6 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } -function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } @@ -12,7 +12,7 @@ function _awaitAsyncGenerator(value) { return new _AwaitValue(value); } function _wrapAsyncGenerator(fn) { return function () { return new _AsyncGenerator(fn.apply(this, arguments)); }; } -function _AsyncGenerator(gen) { var front, back; function send(key, arg) { return new Promise(function (resolve, reject) { var request = { key: key, arg: arg, resolve: resolve, reject: reject, next: null }; if (back) { back = back.next = request; } else { front = back = request; resume(key, arg); } }); } function resume(key, arg) { try { var result = gen[key](arg); var value = result.value; var wrappedAwait = value instanceof _AwaitValue; Promise.resolve(wrappedAwait ? value.wrapped : value).then(function (arg) { if (wrappedAwait) { resume("next", arg); return; } settle(result.done ? "return" : "normal", arg); }, function (err) { resume("throw", err); }); } catch (err) { settle("throw", err); } } function settle(type, value) { switch (type) { case "return": front.resolve({ value: value, done: true }); break; case "throw": front.reject(value); break; default: front.resolve({ value: value, done: false }); break; } front = front.next; if (front) { resume(front.key, front.arg); } else { back = null; } } this._invoke = send; if (typeof gen["return"] !== "function") { this["return"] = undefined; } } +function _AsyncGenerator(gen) { var front, back; function send(key, arg) { return new Promise(function (resolve, reject) { var request = { key: key, arg: arg, resolve: resolve, reject: reject, next: null }; if (back) { back = back.next = request; } else { front = back = request; resume(key, arg); } }); } function resume(key, arg) { try { var result = gen[key](arg); var value = result.value; var wrappedAwait = value instanceof _AwaitValue; Promise.resolve(wrappedAwait ? value.wrapped : value).then(function (arg) { if (wrappedAwait) { resume(key === "return" ? "return" : "next", arg); return; } settle(result.done ? "return" : "normal", arg); }, function (err) { resume("throw", err); }); } catch (err) { settle("throw", err); } } function settle(type, value) { switch (type) { case "return": front.resolve({ value: value, done: true }); break; case "throw": front.reject(value); break; default: front.resolve({ value: value, done: false }); break; } front = front.next; if (front) { resume(front.key, front.arg); } else { back = null; } } this._invoke = send; if (typeof gen["return"] !== "function") { this["return"] = undefined; } } if (typeof Symbol === "function" && Symbol.asyncIterator) { _AsyncGenerator.prototype[Symbol.asyncIterator] = function () { return this; }; } diff --git a/packages/babel-preset-env/test/fixtures/preset-options/unicode-property-regex-chrome-49/input.js b/packages/babel-preset-env/test/fixtures/preset-options/unicode-property-regex-chrome-49/input.js new file mode 100644 index 000000000000..4dc88814e7a9 --- /dev/null +++ b/packages/babel-preset-env/test/fixtures/preset-options/unicode-property-regex-chrome-49/input.js @@ -0,0 +1 @@ +/\p{Script_Extensions=Greek}/u; diff --git a/packages/babel-preset-env/test/fixtures/preset-options/unicode-property-regex-chrome-49/options.json b/packages/babel-preset-env/test/fixtures/preset-options/unicode-property-regex-chrome-49/options.json new file mode 100644 index 000000000000..0594e8b2ce13 --- /dev/null +++ b/packages/babel-preset-env/test/fixtures/preset-options/unicode-property-regex-chrome-49/options.json @@ -0,0 +1,10 @@ +{ + "presets": [ + [ + "../../../../lib", + { + "targets": "chrome 49" + } + ] + ] +} diff --git a/packages/babel-preset-env/test/fixtures/preset-options/unicode-property-regex-chrome-49/output.js b/packages/babel-preset-env/test/fixtures/preset-options/unicode-property-regex-chrome-49/output.js new file mode 100644 index 000000000000..ca4cbfc0fb21 --- /dev/null +++ b/packages/babel-preset-env/test/fixtures/preset-options/unicode-property-regex-chrome-49/output.js @@ -0,0 +1 @@ +/(?:[\u0342\u0345\u0370-\u0373\u0375-\u0377\u037A-\u037D\u037F\u0384\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03E1\u03F0-\u03FF\u1D26-\u1D2A\u1D5D-\u1D61\u1D66-\u1D6A\u1DBF-\u1DC1\u1F00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FC4\u1FC6-\u1FD3\u1FD6-\u1FDB\u1FDD-\u1FEF\u1FF2-\u1FF4\u1FF6-\u1FFE\u2126\uAB65]|\uD800[\uDD40-\uDD8E\uDDA0]|\uD834[\uDE00-\uDE45])/; diff --git a/packages/babel-preset-env/test/fixtures/top-level-await/supported/input.mjs b/packages/babel-preset-env/test/fixtures/top-level-await/supported/input.mjs new file mode 100644 index 000000000000..d8ddd6c0ad0b --- /dev/null +++ b/packages/babel-preset-env/test/fixtures/top-level-await/supported/input.mjs @@ -0,0 +1 @@ +await 0; \ No newline at end of file diff --git a/packages/babel-preset-env/test/fixtures/top-level-await/supported/options.json b/packages/babel-preset-env/test/fixtures/top-level-await/supported/options.json new file mode 100644 index 000000000000..9307569540d9 --- /dev/null +++ b/packages/babel-preset-env/test/fixtures/top-level-await/supported/options.json @@ -0,0 +1,8 @@ +{ + "caller": { + "name": "test-fixture", + "supportsStaticESM": true, + "supportsTopLevelAwait": true + }, + "presets": ["env"] +} diff --git a/packages/babel-preset-env/test/fixtures/top-level-await/supported/output.mjs b/packages/babel-preset-env/test/fixtures/top-level-await/supported/output.mjs new file mode 100644 index 000000000000..0a5e432fc91c --- /dev/null +++ b/packages/babel-preset-env/test/fixtures/top-level-await/supported/output.mjs @@ -0,0 +1 @@ +await 0; diff --git a/packages/babel-preset-env/test/fixtures/top-level-await/unsupported/input.mjs b/packages/babel-preset-env/test/fixtures/top-level-await/unsupported/input.mjs new file mode 100644 index 000000000000..0a5e432fc91c --- /dev/null +++ b/packages/babel-preset-env/test/fixtures/top-level-await/unsupported/input.mjs @@ -0,0 +1 @@ +await 0; diff --git a/packages/babel-preset-env/test/fixtures/top-level-await/unsupported/options.json b/packages/babel-preset-env/test/fixtures/top-level-await/unsupported/options.json new file mode 100644 index 000000000000..65ac70b9a5f7 --- /dev/null +++ b/packages/babel-preset-env/test/fixtures/top-level-await/unsupported/options.json @@ -0,0 +1,9 @@ +{ + "caller": { + "name": "test-fixture", + "supportsStaticESM": true, + "supportsTopLevelAwait": false + }, + "presets": ["env"], + "throws": "Can not use keyword 'await' outside an async function (1:0)" +} diff --git a/packages/babel-preset-react/package.json b/packages/babel-preset-react/package.json index f7a255aa8adb..2793bfb44bc6 100644 --- a/packages/babel-preset-react/package.json +++ b/packages/babel-preset-react/package.json @@ -1,6 +1,6 @@ { "name": "@babel/preset-react", - "version": "7.6.3", + "version": "7.7.0", "description": "Babel preset for all React plugins.", "author": "Sebastian McKenzie ", "homepage": "https://babeljs.io/", @@ -13,7 +13,7 @@ "dependencies": { "@babel/helper-plugin-utils": "^7.0.0", "@babel/plugin-transform-react-display-name": "^7.0.0", - "@babel/plugin-transform-react-jsx": "^7.0.0", + "@babel/plugin-transform-react-jsx": "^7.7.0", "@babel/plugin-transform-react-jsx-self": "^7.0.0", "@babel/plugin-transform-react-jsx-source": "^7.0.0" }, @@ -21,7 +21,7 @@ "@babel/core": "^7.0.0-0" }, "devDependencies": { - "@babel/core": "^7.6.3", + "@babel/core": "^7.7.0", "@babel/helper-plugin-test-runner": "^7.0.0", "@babel/helper-transform-fixture-test-runner": "^7.6.3" } diff --git a/packages/babel-preset-react/src/index.js b/packages/babel-preset-react/src/index.js index f99fe36e0b1c..aaf358ea5979 100644 --- a/packages/babel-preset-react/src/index.js +++ b/packages/babel-preset-react/src/index.js @@ -13,6 +13,7 @@ export default declare((api, opts) => { opts.throwIfNamespace === undefined ? true : !!opts.throwIfNamespace; const development = !!opts.development; const useBuiltIns = !!opts.useBuiltIns; + const { useSpread } = opts; if (typeof development !== "boolean") { throw new Error( @@ -24,7 +25,7 @@ export default declare((api, opts) => { plugins: [ [ transformReactJSX, - { pragma, pragmaFrag, throwIfNamespace, useBuiltIns }, + { pragma, pragmaFrag, throwIfNamespace, useBuiltIns, useSpread }, ], transformReactDisplayName, diff --git a/packages/babel-preset-typescript/package.json b/packages/babel-preset-typescript/package.json index fb48e54dc063..fa98c56cd283 100644 --- a/packages/babel-preset-typescript/package.json +++ b/packages/babel-preset-typescript/package.json @@ -1,6 +1,6 @@ { "name": "@babel/preset-typescript", - "version": "7.6.0", + "version": "7.7.2", "description": "Babel preset for TypeScript.", "repository": "https://github.com/babel/babel/tree/master/packages/babel-preset-typescript", "license": "MIT", @@ -14,13 +14,13 @@ ], "dependencies": { "@babel/helper-plugin-utils": "^7.0.0", - "@babel/plugin-transform-typescript": "^7.6.0" + "@babel/plugin-transform-typescript": "^7.7.2" }, "peerDependencies": { "@babel/core": "^7.0.0-0" }, "devDependencies": { - "@babel/core": "^7.6.0", + "@babel/core": "^7.7.2", "@babel/helper-plugin-test-runner": "^7.0.0" } } diff --git a/packages/babel-preset-typescript/src/index.js b/packages/babel-preset-typescript/src/index.js index bb1687e623c4..f3159543f66d 100644 --- a/packages/babel-preset-typescript/src/index.js +++ b/packages/babel-preset-typescript/src/index.js @@ -4,13 +4,20 @@ import transformTypeScript from "@babel/plugin-transform-typescript"; export default declare( ( api, - { jsxPragma, allExtensions = false, isTSX = false, allowNamespaces }, + { + jsxPragma, + allExtensions = false, + isTSX = false, + allowNamespaces, + allowDeclareFields, + }, ) => { api.assertVersion(7); if (typeof allExtensions !== "boolean") { throw new Error(".allExtensions must be a boolean, or undefined"); } + if (typeof isTSX !== "boolean") { throw new Error(".isTSX must be a boolean, or undefined"); } @@ -19,13 +26,18 @@ export default declare( throw new Error("isTSX:true requires allExtensions:true"); } + const pluginOptions = isTSX => ({ + jsxPragma, + isTSX, + allowNamespaces, + allowDeclareFields, + }); + return { overrides: allExtensions ? [ { - plugins: [ - [transformTypeScript, { jsxPragma, isTSX, allowNamespaces }], - ], + plugins: [[transformTypeScript, pluginOptions(isTSX)]], }, ] : [ @@ -33,18 +45,13 @@ export default declare( // Only set 'test' if explicitly requested, since it requires that // Babel is being called` test: /\.ts$/, - plugins: [[transformTypeScript, { jsxPragma, allowNamespaces }]], + plugins: [[transformTypeScript, pluginOptions(false)]], }, { // Only set 'test' if explicitly requested, since it requires that // Babel is being called` test: /\.tsx$/, - plugins: [ - [ - transformTypeScript, - { jsxPragma, isTSX: true, allowNamespaces }, - ], - ], + plugins: [[transformTypeScript, pluginOptions(true)]], }, ], }; diff --git a/packages/babel-preset-typescript/test/fixtures/jsx-compat/ts-invalid/options.json b/packages/babel-preset-typescript/test/fixtures/jsx-compat/ts-invalid/options.json index 4c0aa124656f..c11cb6fdfbdf 100644 --- a/packages/babel-preset-typescript/test/fixtures/jsx-compat/ts-invalid/options.json +++ b/packages/babel-preset-typescript/test/fixtures/jsx-compat/ts-invalid/options.json @@ -1,3 +1,3 @@ { - "throws": "Unexpected token, expected \"/<=/>=\" (1:6)" + "throws": "Unexpected token, expected \",\" (1:6)" } diff --git a/packages/babel-register/package.json b/packages/babel-register/package.json index 6a768833622d..5edcac8d4e97 100644 --- a/packages/babel-register/package.json +++ b/packages/babel-register/package.json @@ -1,6 +1,6 @@ { "name": "@babel/register", - "version": "7.6.2", + "version": "7.7.0", "description": "babel require hook", "license": "MIT", "publishConfig": { @@ -15,15 +15,15 @@ "dependencies": { "find-cache-dir": "^2.0.0", "lodash": "^4.17.13", - "mkdirp": "^0.5.1", + "make-dir": "^2.1.0", "pirates": "^4.0.0", - "source-map-support": "^0.5.9" + "source-map-support": "^0.5.16" }, "peerDependencies": { "@babel/core": "^7.0.0-0" }, "devDependencies": { - "@babel/core": "^7.6.2", + "@babel/core": "^7.7.0", "default-require-extensions": "^2.0.0" } } diff --git a/packages/babel-register/src/cache.js b/packages/babel-register/src/cache.js index 0a2983b89aa2..b505bb4943c7 100644 --- a/packages/babel-register/src/cache.js +++ b/packages/babel-register/src/cache.js @@ -1,7 +1,7 @@ import path from "path"; import fs from "fs"; import os from "os"; -import { sync as mkdirpSync } from "mkdirp"; +import { sync as makeDirSync } from "make-dir"; import * as babel from "@babel/core"; import findCacheDir from "find-cache-dir"; @@ -39,7 +39,7 @@ export function save() { } try { - mkdirpSync(path.dirname(FILENAME)); + makeDirSync(path.dirname(FILENAME)); fs.writeFileSync(FILENAME, serialised); } catch (e) { switch (e.code) { diff --git a/packages/babel-runtime-corejs2/package.json b/packages/babel-runtime-corejs2/package.json index 3b2a4defd8c7..d5bc51194622 100644 --- a/packages/babel-runtime-corejs2/package.json +++ b/packages/babel-runtime-corejs2/package.json @@ -1,6 +1,6 @@ { "name": "@babel/runtime-corejs2", - "version": "7.6.3", + "version": "7.7.2", "description": "babel's modular runtime helpers with core-js@2 polyfilling", "license": "MIT", "publishConfig": { @@ -13,6 +13,6 @@ "regenerator-runtime": "^0.13.2" }, "devDependencies": { - "@babel/helpers": "^7.6.2" + "@babel/helpers": "^7.7.0" } } diff --git a/packages/babel-runtime-corejs3/package.json b/packages/babel-runtime-corejs3/package.json index 55b4e26b6571..1aff3a832aa7 100644 --- a/packages/babel-runtime-corejs3/package.json +++ b/packages/babel-runtime-corejs3/package.json @@ -1,6 +1,6 @@ { "name": "@babel/runtime-corejs3", - "version": "7.6.3", + "version": "7.7.2", "description": "babel's modular runtime helpers with core-js@3 polyfilling", "license": "MIT", "publishConfig": { diff --git a/packages/babel-runtime/package.json b/packages/babel-runtime/package.json index afdb001717db..d0dc352d9599 100644 --- a/packages/babel-runtime/package.json +++ b/packages/babel-runtime/package.json @@ -1,14 +1,14 @@ { "name": "@babel/runtime", - "version": "7.6.3", + "version": "7.7.2", "description": "babel's modular runtime helpers", "license": "MIT", "publishConfig": { "access": "public" }, "repository": { - "type" : "git", - "url" : "https://github.com/babel/babel.git", + "type": "git", + "url": "https://github.com/babel/babel.git", "directory": "packages/babel-runtime" }, "homepage": "https://babeljs.io/docs/en/next/babel-runtime", @@ -17,6 +17,6 @@ "regenerator-runtime": "^0.13.2" }, "devDependencies": { - "@babel/helpers": "^7.6.2" + "@babel/helpers": "^7.7.0" } } diff --git a/packages/babel-standalone/package.json b/packages/babel-standalone/package.json index bfed051647ec..3f7831157508 100644 --- a/packages/babel-standalone/package.json +++ b/packages/babel-standalone/package.json @@ -1,6 +1,6 @@ { "name": "@babel/standalone", - "version": "7.6.4", + "version": "7.7.3", "description": "Standalone build of Babel for use in non-Node.js environments.", "main": "babel.js", "files": [ @@ -12,17 +12,17 @@ "prepublishOnly": "cd ../.. && make prepublish-build-standalone" }, "devDependencies": { - "@babel/core": "^7.6.4", + "@babel/core": "^7.7.2", "@babel/helper-plugin-utils": "^7.0.0", "@babel/plugin-external-helpers": "^7.2.0", - "@babel/plugin-proposal-async-generator-functions": "^7.2.0", - "@babel/plugin-proposal-class-properties": "^7.5.5", - "@babel/plugin-proposal-decorators": "^7.6.0", + "@babel/plugin-proposal-async-generator-functions": "^7.7.0", + "@babel/plugin-proposal-class-properties": "^7.7.0", + "@babel/plugin-proposal-decorators": "^7.7.0", "@babel/plugin-proposal-do-expressions": "^7.6.0", "@babel/plugin-proposal-export-default-from": "^7.5.2", "@babel/plugin-proposal-export-namespace-from": "^7.5.2", "@babel/plugin-proposal-function-bind": "^7.2.0", - "@babel/plugin-proposal-function-sent": "^7.5.0", + "@babel/plugin-proposal-function-sent": "^7.7.0", "@babel/plugin-proposal-json-strings": "^7.2.0", "@babel/plugin-proposal-logical-assignment-operators": "^7.2.0", "@babel/plugin-proposal-nullish-coalescing-operator": "^7.4.4", @@ -33,7 +33,7 @@ "@babel/plugin-proposal-pipeline-operator": "^7.5.0", "@babel/plugin-proposal-private-methods": "^7.6.0", "@babel/plugin-proposal-throw-expressions": "^7.2.0", - "@babel/plugin-proposal-unicode-property-regex": "^7.6.2", + "@babel/plugin-proposal-unicode-property-regex": "^7.7.0", "@babel/plugin-syntax-async-generators": "^7.2.0", "@babel/plugin-syntax-class-properties": "^7.2.0", "@babel/plugin-syntax-decorators": "^7.2.0", @@ -41,7 +41,7 @@ "@babel/plugin-syntax-dynamic-import": "^7.2.0", "@babel/plugin-syntax-export-default-from": "^7.2.0", "@babel/plugin-syntax-export-namespace-from": "^7.2.0", - "@babel/plugin-syntax-flow": "^7.2.0", + "@babel/plugin-syntax-flow": "^7.7.0", "@babel/plugin-syntax-function-bind": "^7.2.0", "@babel/plugin-syntax-function-sent": "^7.2.0", "@babel/plugin-syntax-import-meta": "^7.2.0", @@ -51,27 +51,27 @@ "@babel/plugin-syntax-pipeline-operator": "^7.5.0", "@babel/plugin-syntax-typescript": "^7.3.3", "@babel/plugin-transform-arrow-functions": "^7.2.0", - "@babel/plugin-transform-async-to-generator": "^7.5.0", + "@babel/plugin-transform-async-to-generator": "^7.7.0", "@babel/plugin-transform-block-scoped-functions": "^7.2.0", "@babel/plugin-transform-block-scoping": "^7.6.3", - "@babel/plugin-transform-classes": "^7.5.5", + "@babel/plugin-transform-classes": "^7.7.0", "@babel/plugin-transform-computed-properties": "^7.2.0", "@babel/plugin-transform-destructuring": "^7.6.0", - "@babel/plugin-transform-dotall-regex": "^7.6.2", + "@babel/plugin-transform-dotall-regex": "^7.7.0", "@babel/plugin-transform-duplicate-keys": "^7.5.0", "@babel/plugin-transform-exponentiation-operator": "^7.2.0", "@babel/plugin-transform-flow-comments": "^7.6.3", "@babel/plugin-transform-flow-strip-types": "^7.6.3", "@babel/plugin-transform-for-of": "^7.4.4", - "@babel/plugin-transform-function-name": "^7.4.4", + "@babel/plugin-transform-function-name": "^7.7.0", "@babel/plugin-transform-instanceof": "^7.5.5", "@babel/plugin-transform-jscript": "^7.2.0", "@babel/plugin-transform-literals": "^7.2.0", "@babel/plugin-transform-member-expression-literals": "^7.2.0", "@babel/plugin-transform-modules-amd": "^7.5.0", - "@babel/plugin-transform-modules-commonjs": "^7.6.0", - "@babel/plugin-transform-modules-systemjs": "^7.5.0", - "@babel/plugin-transform-modules-umd": "^7.2.0", + "@babel/plugin-transform-modules-commonjs": "^7.7.0", + "@babel/plugin-transform-modules-systemjs": "^7.7.0", + "@babel/plugin-transform-modules-umd": "^7.7.0", "@babel/plugin-transform-new-target": "^7.4.4", "@babel/plugin-transform-object-assign": "^7.2.0", "@babel/plugin-transform-object-set-prototype-of-to-assign": "^7.2.0", @@ -83,11 +83,11 @@ "@babel/plugin-transform-react-constant-elements": "^7.6.3", "@babel/plugin-transform-react-display-name": "^7.2.0", "@babel/plugin-transform-react-inline-elements": "^7.2.0", - "@babel/plugin-transform-react-jsx": "^7.3.0", + "@babel/plugin-transform-react-jsx": "^7.7.0", "@babel/plugin-transform-react-jsx-compat": "^7.2.0", "@babel/plugin-transform-react-jsx-self": "^7.2.0", "@babel/plugin-transform-react-jsx-source": "^7.5.0", - "@babel/plugin-transform-regenerator": "^7.4.5", + "@babel/plugin-transform-regenerator": "^7.7.0", "@babel/plugin-transform-reserved-words": "^7.2.0", "@babel/plugin-transform-runtime": "^7.6.2", "@babel/plugin-transform-shorthand-properties": "^7.2.0", @@ -96,11 +96,11 @@ "@babel/plugin-transform-strict-mode": "^7.2.0", "@babel/plugin-transform-template-literals": "^7.4.4", "@babel/plugin-transform-typeof-symbol": "^7.2.0", - "@babel/plugin-transform-typescript": "^7.6.3", - "@babel/plugin-transform-unicode-regex": "^7.6.2", + "@babel/plugin-transform-typescript": "^7.7.2", + "@babel/plugin-transform-unicode-regex": "^7.7.0", "@babel/preset-flow": "^7.0.0", - "@babel/preset-react": "^7.6.3", - "@babel/preset-typescript": "^7.6.0" + "@babel/preset-react": "^7.7.0", + "@babel/preset-typescript": "^7.7.2" }, "keywords": [ "babel", diff --git a/packages/babel-standalone/src/preset-stage-1.js b/packages/babel-standalone/src/preset-stage-1.js index 0018a48f4334..4f9d6029912b 100644 --- a/packages/babel-standalone/src/preset-stage-1.js +++ b/packages/babel-standalone/src/preset-stage-1.js @@ -21,9 +21,7 @@ export default (_: any, opts: Object = {}) => { plugins: [ babelPlugins.proposalExportDefaultFrom, babelPlugins.proposalLogicalAssignmentOperators, - [babelPlugins.proposalOptionalChaining, { loose }], [babelPlugins.proposalPipelineOperator, { proposal: pipelineProposal }], - [babelPlugins.proposalNullishCoalescingOperator, { loose }], babelPlugins.proposalDoExpressions, ], }; diff --git a/packages/babel-standalone/src/preset-stage-3.js b/packages/babel-standalone/src/preset-stage-3.js index 6885719f2fd2..11e9c3833b66 100644 --- a/packages/babel-standalone/src/preset-stage-3.js +++ b/packages/babel-standalone/src/preset-stage-3.js @@ -12,6 +12,8 @@ export default (_: any, opts: Object) => { plugins: [ babelPlugins.syntaxDynamicImport, babelPlugins.syntaxImportMeta, + [babelPlugins.proposalOptionalChaining, { loose }], + [babelPlugins.proposalNullishCoalescingOperator, { loose }], [babelPlugins.proposalClassProperties, { loose }], babelPlugins.proposalJsonStrings, [babelPlugins.proposalPrivateMethods, { loose }], diff --git a/packages/babel-template/package.json b/packages/babel-template/package.json index cc599610aa84..bf01d6cc6f06 100644 --- a/packages/babel-template/package.json +++ b/packages/babel-template/package.json @@ -1,6 +1,6 @@ { "name": "@babel/template", - "version": "7.6.0", + "version": "7.7.0", "description": "Generate an AST from a string template.", "author": "Sebastian McKenzie ", "homepage": "https://babeljs.io/", @@ -12,7 +12,7 @@ "main": "lib/index.js", "dependencies": { "@babel/code-frame": "^7.0.0", - "@babel/parser": "^7.6.0", - "@babel/types": "^7.6.3" + "@babel/parser": "^7.7.0", + "@babel/types": "^7.7.0" } } diff --git a/packages/babel-traverse/package.json b/packages/babel-traverse/package.json index 049b656f17f2..ee21b6e83e09 100644 --- a/packages/babel-traverse/package.json +++ b/packages/babel-traverse/package.json @@ -1,6 +1,6 @@ { "name": "@babel/traverse", - "version": "7.6.3", + "version": "7.7.2", "description": "The Babel Traverse module maintains the overall tree state, and is responsible for replacing, removing, and adding nodes", "author": "Sebastian McKenzie ", "homepage": "https://babeljs.io/", @@ -12,11 +12,11 @@ "main": "lib/index.js", "dependencies": { "@babel/code-frame": "^7.5.5", - "@babel/generator": "^7.6.3", - "@babel/helper-function-name": "^7.1.0", - "@babel/helper-split-export-declaration": "^7.4.4", - "@babel/parser": "^7.6.3", - "@babel/types": "^7.6.3", + "@babel/generator": "^7.7.2", + "@babel/helper-function-name": "^7.7.0", + "@babel/helper-split-export-declaration": "^7.7.0", + "@babel/parser": "^7.7.2", + "@babel/types": "^7.7.2", "debug": "^4.1.0", "globals": "^11.1.0", "lodash": "^4.17.13" diff --git a/packages/babel-traverse/src/index.js b/packages/babel-traverse/src/index.js index fa0306e07cd0..da880632ad40 100644 --- a/packages/babel-traverse/src/index.js +++ b/packages/babel-traverse/src/index.js @@ -31,6 +31,10 @@ export default function traverse( } } + if (!t.VISITOR_KEYS[parent.type]) { + return; + } + visitors.explode(opts); traverse.node(parent, opts, scope, state, parentPath); diff --git a/packages/babel-traverse/src/path/context.js b/packages/babel-traverse/src/path/context.js index 47c8f831f429..4a8c54197bb7 100644 --- a/packages/babel-traverse/src/path/context.js +++ b/packages/babel-traverse/src/path/context.js @@ -1,6 +1,7 @@ // This file contains methods responsible for maintaining a TraversalContext. import traverse from "../index"; +import { SHOULD_SKIP, SHOULD_STOP } from "./index"; export function call(key): boolean { const opts = this.opts; @@ -43,7 +44,8 @@ export function _call(fns?: Array): boolean { // node has been replaced, it will have been requeued if (this.node !== node) return true; - if (this.shouldStop || this.shouldSkip || this.removed) return true; + // this.shouldSkip || this.shouldStop || this.removed + if (this._traverseFlags > 0) return true; } return false; @@ -97,12 +99,15 @@ export function skip() { } export function skipKey(key) { + if (this.skipKeys == null) { + this.skipKeys = {}; + } this.skipKeys[key] = true; } export function stop() { - this.shouldStop = true; - this.shouldSkip = true; + // this.shouldSkip = true; this.shouldStop = true; + this._traverseFlags |= SHOULD_SKIP | SHOULD_STOP; } export function setScope() { @@ -122,10 +127,11 @@ export function setScope() { } export function setContext(context) { - this.shouldSkip = false; - this.shouldStop = false; - this.removed = false; - this.skipKeys = {}; + if (this.skipKeys != null) { + this.skipKeys = {}; + } + // this.shouldSkip = false; this.shouldStop = false; this.removed = false; + this._traverseFlags = 0; if (context) { this.context = context; @@ -220,9 +226,7 @@ export function pushContext(context) { } export function setup(parentPath, container, listKey, key) { - this.inList = !!listKey; this.listKey = listKey; - this.parentKey = listKey || key; this.container = container; this.parentPath = parentPath || this.parentPath; diff --git a/packages/babel-traverse/src/path/index.js b/packages/babel-traverse/src/path/index.js index a1be4f5d8d00..79ef05092857 100644 --- a/packages/babel-traverse/src/path/index.js +++ b/packages/babel-traverse/src/path/index.js @@ -23,15 +23,18 @@ import * as NodePath_comments from "./comments"; const debug = buildDebug("babel"); +export const REMOVED = 1 << 0; +export const SHOULD_STOP = 1 << 1; +export const SHOULD_SKIP = 1 << 2; + export default class NodePath { constructor(hub: HubInterface, parent: Object) { this.parent = parent; this.hub = hub; this.contexts = []; - this.data = Object.create(null); - this.shouldSkip = false; - this.shouldStop = false; - this.removed = false; + this.data = null; + // this.shouldSkip = false; this.shouldStop = false; this.removed = false; + this._traverseFlags = 0; this.state = null; this.opts = null; this.skipKeys = null; @@ -39,13 +42,10 @@ export default class NodePath { this.context = null; this.container = null; this.listKey = null; - this.inList = false; - this.parentKey = null; this.key = null; this.node = null; this.scope = null; this.type = null; - this.typeAnnotation = null; } parent: Object; @@ -57,18 +57,16 @@ export default class NodePath { removed: boolean; state: any; opts: ?Object; + _traverseFlags: number; skipKeys: ?Object; parentPath: ?NodePath; context: TraversalContext; container: ?Object | Array; listKey: ?string; - inList: boolean; - parentKey: ?string; key: ?string; node: ?Object; scope: Scope; type: ?string; - typeAnnotation: ?Object; static get({ hub, parentPath, parent, container, listKey, key }): NodePath { if (!hub && parentPath) { @@ -111,10 +109,16 @@ export default class NodePath { } setData(key: string, val: any): any { + if (this.data == null) { + this.data = Object.create(null); + } return (this.data[key] = val); } getData(key: string, def?: any): any { + if (this.data == null) { + this.data = Object.create(null); + } let val = this.data[key]; if (val === undefined && def !== undefined) val = this.data[key] = def; return val; @@ -152,6 +156,56 @@ export default class NodePath { toString() { return generator(this.node).code; } + + get inList() { + return !!this.listKey; + } + + set inList(inList) { + if (!inList) { + this.listKey = null; + } + // ignore inList = true as it should depend on `listKey` + } + + get parentKey() { + return this.listKey || this.key; + } + + get shouldSkip() { + return !!(this._traverseFlags & SHOULD_SKIP); + } + + set shouldSkip(v) { + if (v) { + this._traverseFlags |= SHOULD_SKIP; + } else { + this._traverseFlags &= ~SHOULD_SKIP; + } + } + + get shouldStop() { + return !!(this._traverseFlags & SHOULD_STOP); + } + + set shouldStop(v) { + if (v) { + this._traverseFlags |= SHOULD_STOP; + } else { + this._traverseFlags &= ~SHOULD_STOP; + } + } + + get removed() { + return !!(this._traverseFlags & REMOVED); + } + set removed(v) { + if (v) { + this._traverseFlags |= REMOVED; + } else { + this._traverseFlags &= ~REMOVED; + } + } } Object.assign( diff --git a/packages/babel-traverse/src/path/modification.js b/packages/babel-traverse/src/path/modification.js index 6039a94c6090..1f6d2a0b32db 100644 --- a/packages/babel-traverse/src/path/modification.js +++ b/packages/babel-traverse/src/path/modification.js @@ -115,7 +115,9 @@ export function insertAfter(nodes) { }), ); } else if ( - (this.isNodeType("Expression") && !this.isJSXElement()) || + (this.isNodeType("Expression") && + !this.isJSXElement() && + !parentPath.isJSXElement()) || (parentPath.isForStatement() && this.key === "init") ) { if (this.node) { diff --git a/packages/babel-traverse/src/path/removal.js b/packages/babel-traverse/src/path/removal.js index b4d1330b256d..9ddf0a201448 100644 --- a/packages/babel-traverse/src/path/removal.js +++ b/packages/babel-traverse/src/path/removal.js @@ -1,6 +1,7 @@ // This file contains methods responsible for removing a node. import { hooks } from "./lib/removal-hooks"; +import { REMOVED, SHOULD_SKIP } from "./index"; export function remove() { this._assertUnremoved(); @@ -39,8 +40,8 @@ export function _remove() { } export function _markRemoved() { - this.shouldSkip = true; - this.removed = true; + // this.shouldSkip = true; this.removed = true; + this._traverseFlags |= SHOULD_SKIP | REMOVED; this.node = null; } diff --git a/packages/babel-traverse/test/replacement.js b/packages/babel-traverse/test/replacement.js index 3454937fe506..6d54972611f2 100644 --- a/packages/babel-traverse/test/replacement.js +++ b/packages/babel-traverse/test/replacement.js @@ -1,5 +1,6 @@ import traverse from "../lib"; import { parse } from "@babel/parser"; +import generate from "@babel/generator"; import * as t from "@babel/types"; describe("path/replacement", function() { @@ -97,4 +98,19 @@ describe("path/replacement", function() { ); }); }); + describe("replaceWithMultiple", () => { + it("does not add extra parentheses for a JSXElement with a JSXElement parent", () => { + const ast = parse(`

`, { + plugins: ["jsx"], + }); + traverse(ast, { + JSXElement: path => { + if (path.node.openingElement.name.name === "span") { + path.replaceWithMultiple(path.node.children.filter(t.isJSXElement)); + } + }, + }); + expect(generate(ast).code).toBe("

;"); + }); + }); }); diff --git a/packages/babel-types/package.json b/packages/babel-types/package.json index 75b54493ee97..04946bc67d68 100644 --- a/packages/babel-types/package.json +++ b/packages/babel-types/package.json @@ -1,6 +1,6 @@ { "name": "@babel/types", - "version": "7.6.3", + "version": "7.7.2", "description": "Babel Types is a Lodash-esque utility library for AST nodes", "author": "Sebastian McKenzie ", "homepage": "https://babeljs.io/", @@ -17,7 +17,7 @@ "to-fast-properties": "^2.0.0" }, "devDependencies": { - "@babel/generator": "^7.6.3", - "@babel/parser": "^7.6.3" + "@babel/generator": "^7.7.2", + "@babel/parser": "^7.7.2" } } diff --git a/packages/babel-types/src/asserts/generated/index.js b/packages/babel-types/src/asserts/generated/index.js index 60a91b88178d..4fb0fd754a15 100644 --- a/packages/babel-types/src/asserts/generated/index.js +++ b/packages/babel-types/src/asserts/generated/index.js @@ -584,6 +584,39 @@ export function assertVoidTypeAnnotation( ): void { assert("VoidTypeAnnotation", node, opts); } +export function assertEnumDeclaration(node: Object, opts?: Object = {}): void { + assert("EnumDeclaration", node, opts); +} +export function assertEnumBooleanBody(node: Object, opts?: Object = {}): void { + assert("EnumBooleanBody", node, opts); +} +export function assertEnumNumberBody(node: Object, opts?: Object = {}): void { + assert("EnumNumberBody", node, opts); +} +export function assertEnumStringBody(node: Object, opts?: Object = {}): void { + assert("EnumStringBody", node, opts); +} +export function assertEnumSymbolBody(node: Object, opts?: Object = {}): void { + assert("EnumSymbolBody", node, opts); +} +export function assertEnumBooleanMember( + node: Object, + opts?: Object = {}, +): void { + assert("EnumBooleanMember", node, opts); +} +export function assertEnumNumberMember(node: Object, opts?: Object = {}): void { + assert("EnumNumberMember", node, opts); +} +export function assertEnumStringMember(node: Object, opts?: Object = {}): void { + assert("EnumStringMember", node, opts); +} +export function assertEnumDefaultedMember( + node: Object, + opts?: Object = {}, +): void { + assert("EnumDefaultedMember", node, opts); +} export function assertJSXAttribute(node: Object, opts?: Object = {}): void { assert("JSXAttribute", node, opts); } @@ -1139,6 +1172,12 @@ export function assertFlowDeclaration(node: Object, opts?: Object = {}): void { export function assertFlowPredicate(node: Object, opts?: Object = {}): void { assert("FlowPredicate", node, opts); } +export function assertEnumBody(node: Object, opts?: Object = {}): void { + assert("EnumBody", node, opts); +} +export function assertEnumMember(node: Object, opts?: Object = {}): void { + assert("EnumMember", node, opts); +} export function assertJSX(node: Object, opts?: Object = {}): void { assert("JSX", node, opts); } diff --git a/packages/babel-types/src/builders/generated/index.js b/packages/babel-types/src/builders/generated/index.js index 2cb9d5490c9d..fe7f320d028a 100644 --- a/packages/babel-types/src/builders/generated/index.js +++ b/packages/babel-types/src/builders/generated/index.js @@ -517,6 +517,42 @@ export function VoidTypeAnnotation(...args: Array): Object { return builder("VoidTypeAnnotation", ...args); } export { VoidTypeAnnotation as voidTypeAnnotation }; +export function EnumDeclaration(...args: Array): Object { + return builder("EnumDeclaration", ...args); +} +export { EnumDeclaration as enumDeclaration }; +export function EnumBooleanBody(...args: Array): Object { + return builder("EnumBooleanBody", ...args); +} +export { EnumBooleanBody as enumBooleanBody }; +export function EnumNumberBody(...args: Array): Object { + return builder("EnumNumberBody", ...args); +} +export { EnumNumberBody as enumNumberBody }; +export function EnumStringBody(...args: Array): Object { + return builder("EnumStringBody", ...args); +} +export { EnumStringBody as enumStringBody }; +export function EnumSymbolBody(...args: Array): Object { + return builder("EnumSymbolBody", ...args); +} +export { EnumSymbolBody as enumSymbolBody }; +export function EnumBooleanMember(...args: Array): Object { + return builder("EnumBooleanMember", ...args); +} +export { EnumBooleanMember as enumBooleanMember }; +export function EnumNumberMember(...args: Array): Object { + return builder("EnumNumberMember", ...args); +} +export { EnumNumberMember as enumNumberMember }; +export function EnumStringMember(...args: Array): Object { + return builder("EnumStringMember", ...args); +} +export { EnumStringMember as enumStringMember }; +export function EnumDefaultedMember(...args: Array): Object { + return builder("EnumDefaultedMember", ...args); +} +export { EnumDefaultedMember as enumDefaultedMember }; export function JSXAttribute(...args: Array): Object { return builder("JSXAttribute", ...args); } diff --git a/packages/babel-types/src/constants/generated/index.js b/packages/babel-types/src/constants/generated/index.js index eedb7038ed28..1f4b576a87b6 100644 --- a/packages/babel-types/src/constants/generated/index.js +++ b/packages/babel-types/src/constants/generated/index.js @@ -45,6 +45,8 @@ export const FLOWBASEANNOTATION_TYPES = FLIPPED_ALIAS_KEYS["FlowBaseAnnotation"]; export const FLOWDECLARATION_TYPES = FLIPPED_ALIAS_KEYS["FlowDeclaration"]; export const FLOWPREDICATE_TYPES = FLIPPED_ALIAS_KEYS["FlowPredicate"]; +export const ENUMBODY_TYPES = FLIPPED_ALIAS_KEYS["EnumBody"]; +export const ENUMMEMBER_TYPES = FLIPPED_ALIAS_KEYS["EnumMember"]; export const JSX_TYPES = FLIPPED_ALIAS_KEYS["JSX"]; export const PRIVATE_TYPES = FLIPPED_ALIAS_KEYS["Private"]; export const TSTYPEELEMENT_TYPES = FLIPPED_ALIAS_KEYS["TSTypeElement"]; diff --git a/packages/babel-types/src/definitions/core.js b/packages/babel-types/src/definitions/core.js index 09c41c9119a9..973c3bfa67c8 100644 --- a/packages/babel-types/src/definitions/core.js +++ b/packages/babel-types/src/definitions/core.js @@ -407,7 +407,7 @@ defineType("Identifier", { name: { validate: chain(function(node, key, val) { if (!isValidIdentifier(val)) { - // throw new TypeError(`"${val}" is not a valid identifer name`); + // throw new TypeError(`"${val}" is not a valid identifier name`); } }, assertValueType("string")), }, diff --git a/packages/babel-types/src/definitions/experimental.js b/packages/babel-types/src/definitions/experimental.js index d344630dcc75..f4e110e1002f 100644 --- a/packages/babel-types/src/definitions/experimental.js +++ b/packages/babel-types/src/definitions/experimental.js @@ -67,6 +67,10 @@ defineType("ClassProperty", { validate: assertValueType("boolean"), optional: true, }, + declare: { + validate: assertValueType("boolean"), + optional: true, + }, }, }); diff --git a/packages/babel-types/src/definitions/flow.js b/packages/babel-types/src/definitions/flow.js index 75f6c8801966..68560582605f 100644 --- a/packages/babel-types/src/definitions/flow.js +++ b/packages/babel-types/src/definitions/flow.js @@ -4,6 +4,7 @@ import defineType, { assertOneOf, assertValueType, validate, + validateArrayOfType, validateOptional, validateOptionalType, validateType, @@ -464,3 +465,88 @@ defineType("Variance", { defineType("VoidTypeAnnotation", { aliases: ["Flow", "FlowType", "FlowBaseAnnotation"], }); + +// Enums +defineType("EnumDeclaration", { + alises: ["Declaration"], + visitor: ["id", "body"], + fields: { + id: validateType("Identifier"), + body: validateType([ + "EnumBooleanBody", + "EnumNumberBody", + "EnumStringBody", + "EnumSymbolBody", + ]), + }, +}); + +defineType("EnumBooleanBody", { + aliases: ["EnumBody"], + visitor: ["members"], + fields: { + explicit: validate(assertValueType("boolean")), + members: validateArrayOfType("EnumBooleanMember"), + }, +}); + +defineType("EnumNumberBody", { + aliases: ["EnumBody"], + visitor: ["members"], + fields: { + explicit: validate(assertValueType("boolean")), + members: validateArrayOfType("EnumNumberMember"), + }, +}); + +defineType("EnumStringBody", { + aliases: ["EnumBody"], + visitor: ["members"], + fields: { + explicit: validate(assertValueType("boolean")), + members: validateArrayOfType(["EnumStringMember", "EnumDefaultedMember"]), + }, +}); + +defineType("EnumSymbolBody", { + aliases: ["EnumBody"], + visitor: ["members"], + fields: { + members: validateArrayOfType("EnumDefaultedMember"), + }, +}); + +defineType("EnumBooleanMember", { + aliases: ["EnumMember"], + visitor: ["id"], + fields: { + id: validateType("Identifier"), + init: validateType("BooleanLiteral"), + }, +}); + +defineType("EnumNumberMember", { + aliases: ["EnumMember"], + visitor: ["id", "init"], + fields: { + id: validateType("Identifier"), + init: validateType("NumericLiteral"), + }, +}); + +defineType("EnumStringMember", { + aliases: ["EnumMember"], + visitor: ["id", "init"], + fields: { + id: validateType("Identifier"), + init: validateType("StringLiteral"), + }, +}); + +defineType("EnumDefaultedMember", { + aliases: ["EnumMember"], + visitor: ["id"], + fields: { + id: validateType("Identifier"), + }, +}); diff --git a/packages/babel-types/src/definitions/typescript.js b/packages/babel-types/src/definitions/typescript.js index af34dbfc6255..608ea8ab2207 100644 --- a/packages/babel-types/src/definitions/typescript.js +++ b/packages/babel-types/src/definitions/typescript.js @@ -176,9 +176,11 @@ defineType("TSTypeReference", { defineType("TSTypePredicate", { aliases: ["TSType"], visitor: ["parameterName", "typeAnnotation"], + builder: ["parameterName", "typeAnnotation", "asserts"], fields: { parameterName: validateType(["Identifier", "TSThisType"]), - typeAnnotation: validateType("TSTypeAnnotation"), + typeAnnotation: validateOptionalType("TSTypeAnnotation"), + asserts: validateOptional(bool), }, }); diff --git a/packages/babel-types/src/validators/generated/index.js b/packages/babel-types/src/validators/generated/index.js index 84f44ef882cd..13ac0be73ac4 100644 --- a/packages/babel-types/src/validators/generated/index.js +++ b/packages/babel-types/src/validators/generated/index.js @@ -1866,6 +1866,132 @@ export function isVoidTypeAnnotation(node: ?Object, opts?: Object): boolean { return false; } +export function isEnumDeclaration(node: ?Object, opts?: Object): boolean { + if (!node) return false; + + const nodeType = node.type; + if (nodeType === "EnumDeclaration") { + if (typeof opts === "undefined") { + return true; + } else { + return shallowEqual(node, opts); + } + } + + return false; +} +export function isEnumBooleanBody(node: ?Object, opts?: Object): boolean { + if (!node) return false; + + const nodeType = node.type; + if (nodeType === "EnumBooleanBody") { + if (typeof opts === "undefined") { + return true; + } else { + return shallowEqual(node, opts); + } + } + + return false; +} +export function isEnumNumberBody(node: ?Object, opts?: Object): boolean { + if (!node) return false; + + const nodeType = node.type; + if (nodeType === "EnumNumberBody") { + if (typeof opts === "undefined") { + return true; + } else { + return shallowEqual(node, opts); + } + } + + return false; +} +export function isEnumStringBody(node: ?Object, opts?: Object): boolean { + if (!node) return false; + + const nodeType = node.type; + if (nodeType === "EnumStringBody") { + if (typeof opts === "undefined") { + return true; + } else { + return shallowEqual(node, opts); + } + } + + return false; +} +export function isEnumSymbolBody(node: ?Object, opts?: Object): boolean { + if (!node) return false; + + const nodeType = node.type; + if (nodeType === "EnumSymbolBody") { + if (typeof opts === "undefined") { + return true; + } else { + return shallowEqual(node, opts); + } + } + + return false; +} +export function isEnumBooleanMember(node: ?Object, opts?: Object): boolean { + if (!node) return false; + + const nodeType = node.type; + if (nodeType === "EnumBooleanMember") { + if (typeof opts === "undefined") { + return true; + } else { + return shallowEqual(node, opts); + } + } + + return false; +} +export function isEnumNumberMember(node: ?Object, opts?: Object): boolean { + if (!node) return false; + + const nodeType = node.type; + if (nodeType === "EnumNumberMember") { + if (typeof opts === "undefined") { + return true; + } else { + return shallowEqual(node, opts); + } + } + + return false; +} +export function isEnumStringMember(node: ?Object, opts?: Object): boolean { + if (!node) return false; + + const nodeType = node.type; + if (nodeType === "EnumStringMember") { + if (typeof opts === "undefined") { + return true; + } else { + return shallowEqual(node, opts); + } + } + + return false; +} +export function isEnumDefaultedMember(node: ?Object, opts?: Object): boolean { + if (!node) return false; + + const nodeType = node.type; + if (nodeType === "EnumDefaultedMember") { + if (typeof opts === "undefined") { + return true; + } else { + return shallowEqual(node, opts); + } + } + + return false; +} export function isJSXAttribute(node: ?Object, opts?: Object): boolean { if (!node) return false; @@ -4276,6 +4402,46 @@ export function isFlowPredicate(node: ?Object, opts?: Object): boolean { return false; } +export function isEnumBody(node: ?Object, opts?: Object): boolean { + if (!node) return false; + + const nodeType = node.type; + if ( + nodeType === "EnumBody" || + "EnumBooleanBody" === nodeType || + "EnumNumberBody" === nodeType || + "EnumStringBody" === nodeType || + "EnumSymbolBody" === nodeType + ) { + if (typeof opts === "undefined") { + return true; + } else { + return shallowEqual(node, opts); + } + } + + return false; +} +export function isEnumMember(node: ?Object, opts?: Object): boolean { + if (!node) return false; + + const nodeType = node.type; + if ( + nodeType === "EnumMember" || + "EnumBooleanMember" === nodeType || + "EnumNumberMember" === nodeType || + "EnumStringMember" === nodeType || + "EnumDefaultedMember" === nodeType + ) { + if (typeof opts === "undefined") { + return true; + } else { + return shallowEqual(node, opts); + } + } + + return false; +} export function isJSX(node: ?Object, opts?: Object): boolean { if (!node) return false; diff --git a/scripts/integration-tests/e2e-babel.sh b/scripts/integration-tests/e2e-babel.sh new file mode 100755 index 000000000000..d295a9416c55 --- /dev/null +++ b/scripts/integration-tests/e2e-babel.sh @@ -0,0 +1,29 @@ +#!/bin/bash + +#==============================================================================# +# SETUP # +#==============================================================================# + +# Start in scripts/integration-tests/ even if run from root directory +cd "$(dirname "$0")" + +source utils/local-registry.sh +source utils/cleanup.sh + +# Echo every command being executed +set -x + +# Go to the root of the monorepo +cd ../.. + +#==============================================================================# +# TEST # +#==============================================================================# + +startLocalRegistry "$PWD"/scripts/integration-tests/verdaccio-config.yml +yarn upgrade --scope @babel + +# Test +make test-ci + +cleanup diff --git a/scripts/integration-tests/publish-local.sh b/scripts/integration-tests/publish-local.sh new file mode 100755 index 000000000000..d16f123512a5 --- /dev/null +++ b/scripts/integration-tests/publish-local.sh @@ -0,0 +1,33 @@ +#!/bin/bash + +#==============================================================================# +# SETUP # +#==============================================================================# + +# Start in scripts/integration-tests/ even if run from root directory +cd "$(dirname "$0")" + +source utils/local-registry.sh +source utils/git.sh +source utils/cleanup.sh + +# Echo every command being executed +set -x + +# Go to the root of the monorepo +cd ../.. + +initializeE2Egit + +#==============================================================================# +# PUBLISH # +#==============================================================================# + +make bootstrap-only + +startLocalRegistry "$PWD"/scripts/integration-tests/verdaccio-config.yml +loginLocalRegistry + +I_AM_USING_VERDACCIO=I_AM_SURE make publish-test + +cleanup diff --git a/scripts/integration-tests/utils/cleanup.sh b/scripts/integration-tests/utils/cleanup.sh new file mode 100755 index 000000000000..0a578b79fdc7 --- /dev/null +++ b/scripts/integration-tests/utils/cleanup.sh @@ -0,0 +1,30 @@ +#!/bin/bash + +function cleanup { + echo "Cleaning up." + stopLocalRegistry + + if [ -n "$GIT_E2E_SETUP" ]; then + cleanupE2Egit + fi +} + +# Error messages are redirected to stderr +function handle_error { + echo "$(basename $0): ERROR! An error was encountered executing line $1." 1>&2; + cleanup + echo "Exiting with error." 1>&2; + exit 1 +} + +function handle_exit { + cleanup + echo "Exiting without error." 1>&2; + exit +} + +# Exit the script with a helpful error message when any error is encountered +trap 'set +x; handle_error $LINENO $BASH_COMMAND' ERR + +# Cleanup before exit on any termination signal +trap 'set +x; handle_exit' SIGQUIT SIGTERM SIGINT SIGKILL SIGHUP diff --git a/scripts/integration-tests/utils/git.sh b/scripts/integration-tests/utils/git.sh new file mode 100755 index 000000000000..2cce5ee99077 --- /dev/null +++ b/scripts/integration-tests/utils/git.sh @@ -0,0 +1,29 @@ +#!/bin/bash + +original_git_branch=`git rev-parse --abbrev-ref HEAD` +tmp_branch_name="integration-tests-$(date +'%F-%H-%M-%N')" +original_user_name=`git config user.name` +original_user_email=`git config user.email` + +export GIT_E2E_SETUP="true" + +function initializeE2Egit { + git checkout -b $tmp_branch_name + + # This is needed by lerna, which commits when publishing + git config user.name "Babel E2E Test" + git config user.email "babel-e2e@example.com" +} + +function cleanupE2Egit { + # Delete release tags + git tag -d $(git tag -l "version-e2e-test-*") + + # Checkout the previous branch + git checkout -f $original_git_branch + git branch -D $tmp_branch_name + + # Restore git user + git config user.name "$original_user_name" + git config user.email "$original_user_email" +} diff --git a/scripts/integration-tests/utils/local-registry.sh b/scripts/integration-tests/utils/local-registry.sh new file mode 100755 index 000000000000..e0212d2529b3 --- /dev/null +++ b/scripts/integration-tests/utils/local-registry.sh @@ -0,0 +1,34 @@ +#!/bin/bash + +# Copied from https://github.com/facebook/create-react-app/blob/053f9774d3f592c17741d2a86de66a7ca58f90c0/tasks/local-registry.sh + +custom_registry_url=http://localhost:4873 +original_npm_registry_url=`npm get registry` +original_yarn_registry_url=`yarn config get registry` +default_verdaccio_package=verdaccio@~4.3.3 + +function startLocalRegistry { + # Start local registry + tmp_registry_log=`mktemp` + echo "Registry output file: $tmp_registry_log" + (cd && nohup npx ${VERDACCIO_PACKAGE:-$default_verdaccio_package} -c $1 &>$tmp_registry_log &) + + # Wait for Verdaccio to boot + grep -q "http address" <(tail -f $tmp_registry_log) + + # Set registry to local registry + npm set registry "$custom_registry_url" + yarn config set registry "$custom_registry_url" +} + +function loginLocalRegistry { + # Login so we can publish packages + (cd && npx npm-auth-to-token@1.0.0 -u user -p password -e user@example.com -r "$custom_registry_url") +} + +function stopLocalRegistry { + # Restore the original NPM and Yarn registry URLs and stop Verdaccio + fuser -k 4873/tcp + npm set registry "$original_npm_registry_url" + yarn config set registry "$original_yarn_registry_url" +} diff --git a/scripts/integration-tests/verdaccio-config.yml b/scripts/integration-tests/verdaccio-config.yml new file mode 100755 index 000000000000..69d210aa3933 --- /dev/null +++ b/scripts/integration-tests/verdaccio-config.yml @@ -0,0 +1,61 @@ +# +# This is the default config file. It allows all users to do anything, +# so don't use it on production systems. +# +# Look here for more config file examples: +# https://github.com/verdaccio/verdaccio/tree/master/conf +# + +# path to a directory with all packages +storage: /tmp/verdaccio-workspace/storage + +auth: + htpasswd: + file: /tmp/verdaccio-workspace/htpasswd + # Maximum amount of users allowed to register, defaults to "+inf". + # You can set this to -1 to disable registration. + # max_users: 1000 + +# a list of other known repositories we can talk to +uplinks: + npmjs: + url: https://registry.npmjs.org/ + +packages: + '@*/*': + # scoped packages + access: $all + publish: $all + unpublish: $all + proxy: npmjs + + '**': + # allow all users (including non-authenticated users) to read and + # publish all packages + # + # you can specify usernames/groupnames (depending on your auth plugin) + # and three keywords: "$all", "$anonymous", "$authenticated" + access: $all + publish: $all + unpublish: $all + + # if package is not available locally, proxy requests to 'npmjs' registry + proxy: npmjs + +# You can specify HTTP/1.1 server keep alive timeout in seconds for incoming connections. +# A value of 0 makes the http server behave similarly to Node.js versions prior to 8.0.0, which did not have a keep-alive timeout. +# WORKAROUND: Through given configuration you can workaround following issue https://github.com/verdaccio/verdaccio/issues/301. Set to 0 in case 60 is not enough. +server: + keepAliveTimeout: 60 + +middlewares: + audit: + enabled: true + +# log settings +logs: + - { type: stdout, format: pretty, level: http } + #- {type: file, path: verdaccio.log, level: info} +#experiments: +# # support for npm token command +# token: false diff --git a/scripts/tests/test262/run_babel_parser_test262_utils.js b/scripts/tests/test262/run_babel_parser_test262_utils.js index 1434eedfd629..2c35d0ed5933 100644 --- a/scripts/tests/test262/run_babel_parser_test262_utils.js +++ b/scripts/tests/test262/run_babel_parser_test262_utils.js @@ -123,6 +123,7 @@ const featuresToPlugins = { "import.meta": "importMeta", "numeric-separator-literal": "numericSeparator", "optional-chaining": "optionalChaining", + "top-level-await": "topLevelAwait", }; function getPlugins(features) { diff --git a/scripts/tests/test262/test262_whitelist.txt b/scripts/tests/test262/test262_whitelist.txt index 8ed606443333..1e21dcd228dc 100644 --- a/scripts/tests/test262/test262_whitelist.txt +++ b/scripts/tests/test262/test262_whitelist.txt @@ -98,458 +98,6 @@ language/module-code/privatename-not-valid-earlyerr-module-3.js(default) language/module-code/privatename-not-valid-earlyerr-module-3.js(strict mode) language/module-code/privatename-not-valid-earlyerr-module-4.js(default) language/module-code/privatename-not-valid-earlyerr-module-4.js(strict mode) -language/module-code/top-level-await/await-awaits-thenable-not-callable.js(default) -language/module-code/top-level-await/await-awaits-thenable-not-callable.js(strict mode) -language/module-code/top-level-await/await-awaits-thenables-that-throw.js(default) -language/module-code/top-level-await/await-awaits-thenables-that-throw.js(strict mode) -language/module-code/top-level-await/await-awaits-thenables.js(default) -language/module-code/top-level-await/await-awaits-thenables.js(strict mode) -language/module-code/top-level-await/await-dynamic-import-rejection.js(default) -language/module-code/top-level-await/await-dynamic-import-rejection.js(strict mode) -language/module-code/top-level-await/await-dynamic-import-resolution.js(default) -language/module-code/top-level-await/await-dynamic-import-resolution.js(strict mode) -language/module-code/top-level-await/await-expr-func-expression.js(default) -language/module-code/top-level-await/await-expr-func-expression.js(strict mode) -language/module-code/top-level-await/await-expr-new-expr-reject.js(default) -language/module-code/top-level-await/await-expr-new-expr-reject.js(strict mode) -language/module-code/top-level-await/await-expr-new-expr.js(default) -language/module-code/top-level-await/await-expr-new-expr.js(strict mode) -language/module-code/top-level-await/await-expr-regexp.js(default) -language/module-code/top-level-await/await-expr-regexp.js(strict mode) -language/module-code/top-level-await/await-expr-reject-throws.js(default) -language/module-code/top-level-await/await-expr-reject-throws.js(strict mode) -language/module-code/top-level-await/await-expr-resolution.js(default) -language/module-code/top-level-await/await-expr-resolution.js(strict mode) -language/module-code/top-level-await/await-void-expr.js(default) -language/module-code/top-level-await/await-void-expr.js(strict mode) -language/module-code/top-level-await/if-await-expr.js(default) -language/module-code/top-level-await/if-await-expr.js(strict mode) -language/module-code/top-level-await/module-async-import-async-resolution-ticks.js(default) -language/module-code/top-level-await/module-async-import-async-resolution-ticks.js(strict mode) -language/module-code/top-level-await/module-import-unwrapped.js(default) -language/module-code/top-level-await/module-import-unwrapped.js(strict mode) -language/module-code/top-level-await/module-self-import-async-resolution-ticks.js(default) -language/module-code/top-level-await/module-self-import-async-resolution-ticks.js(strict mode) -language/module-code/top-level-await/syntax/await-expr-dyn-import.js(default) -language/module-code/top-level-await/syntax/await-expr-dyn-import.js(strict mode) -language/module-code/top-level-await/syntax/block-await-expr-array-literal.js(default) -language/module-code/top-level-await/syntax/block-await-expr-array-literal.js(strict mode) -language/module-code/top-level-await/syntax/block-await-expr-func-expression.js(default) -language/module-code/top-level-await/syntax/block-await-expr-func-expression.js(strict mode) -language/module-code/top-level-await/syntax/block-await-expr-identifier.js(default) -language/module-code/top-level-await/syntax/block-await-expr-identifier.js(strict mode) -language/module-code/top-level-await/syntax/block-await-expr-literal-number.js(default) -language/module-code/top-level-await/syntax/block-await-expr-literal-number.js(strict mode) -language/module-code/top-level-await/syntax/block-await-expr-literal-string.js(default) -language/module-code/top-level-await/syntax/block-await-expr-literal-string.js(strict mode) -language/module-code/top-level-await/syntax/block-await-expr-nested.js(default) -language/module-code/top-level-await/syntax/block-await-expr-nested.js(strict mode) -language/module-code/top-level-await/syntax/block-await-expr-new-expr.js(default) -language/module-code/top-level-await/syntax/block-await-expr-new-expr.js(strict mode) -language/module-code/top-level-await/syntax/block-await-expr-null.js(default) -language/module-code/top-level-await/syntax/block-await-expr-null.js(strict mode) -language/module-code/top-level-await/syntax/block-await-expr-obj-literal.js(default) -language/module-code/top-level-await/syntax/block-await-expr-obj-literal.js(strict mode) -language/module-code/top-level-await/syntax/block-await-expr-regexp.js(default) -language/module-code/top-level-await/syntax/block-await-expr-regexp.js(strict mode) -language/module-code/top-level-await/syntax/block-await-expr-template-literal.js(default) -language/module-code/top-level-await/syntax/block-await-expr-template-literal.js(strict mode) -language/module-code/top-level-await/syntax/block-await-expr-this.js(default) -language/module-code/top-level-await/syntax/block-await-expr-this.js(strict mode) -language/module-code/top-level-await/syntax/catch-parameter.js(default) -language/module-code/top-level-await/syntax/catch-parameter.js(strict mode) -language/module-code/top-level-await/syntax/export-class-decl-await-expr-array-literal.js(default) -language/module-code/top-level-await/syntax/export-class-decl-await-expr-array-literal.js(strict mode) -language/module-code/top-level-await/syntax/export-class-decl-await-expr-func-expression.js(default) -language/module-code/top-level-await/syntax/export-class-decl-await-expr-func-expression.js(strict mode) -language/module-code/top-level-await/syntax/export-class-decl-await-expr-identifier.js(default) -language/module-code/top-level-await/syntax/export-class-decl-await-expr-identifier.js(strict mode) -language/module-code/top-level-await/syntax/export-class-decl-await-expr-literal-number.js(default) -language/module-code/top-level-await/syntax/export-class-decl-await-expr-literal-number.js(strict mode) -language/module-code/top-level-await/syntax/export-class-decl-await-expr-literal-string.js(default) -language/module-code/top-level-await/syntax/export-class-decl-await-expr-literal-string.js(strict mode) -language/module-code/top-level-await/syntax/export-class-decl-await-expr-nested.js(default) -language/module-code/top-level-await/syntax/export-class-decl-await-expr-nested.js(strict mode) -language/module-code/top-level-await/syntax/export-class-decl-await-expr-new-expr.js(default) -language/module-code/top-level-await/syntax/export-class-decl-await-expr-new-expr.js(strict mode) -language/module-code/top-level-await/syntax/export-class-decl-await-expr-null.js(default) -language/module-code/top-level-await/syntax/export-class-decl-await-expr-null.js(strict mode) -language/module-code/top-level-await/syntax/export-class-decl-await-expr-obj-literal.js(default) -language/module-code/top-level-await/syntax/export-class-decl-await-expr-obj-literal.js(strict mode) -language/module-code/top-level-await/syntax/export-class-decl-await-expr-regexp.js(default) -language/module-code/top-level-await/syntax/export-class-decl-await-expr-regexp.js(strict mode) -language/module-code/top-level-await/syntax/export-class-decl-await-expr-template-literal.js(default) -language/module-code/top-level-await/syntax/export-class-decl-await-expr-template-literal.js(strict mode) -language/module-code/top-level-await/syntax/export-class-decl-await-expr-this.js(default) -language/module-code/top-level-await/syntax/export-class-decl-await-expr-this.js(strict mode) -language/module-code/top-level-await/syntax/export-dflt-assign-expr-await-expr-array-literal.js(default) -language/module-code/top-level-await/syntax/export-dflt-assign-expr-await-expr-array-literal.js(strict mode) -language/module-code/top-level-await/syntax/export-dflt-assign-expr-await-expr-func-expression.js(default) -language/module-code/top-level-await/syntax/export-dflt-assign-expr-await-expr-func-expression.js(strict mode) -language/module-code/top-level-await/syntax/export-dflt-assign-expr-await-expr-identifier.js(default) -language/module-code/top-level-await/syntax/export-dflt-assign-expr-await-expr-identifier.js(strict mode) -language/module-code/top-level-await/syntax/export-dflt-assign-expr-await-expr-literal-number.js(default) -language/module-code/top-level-await/syntax/export-dflt-assign-expr-await-expr-literal-number.js(strict mode) -language/module-code/top-level-await/syntax/export-dflt-assign-expr-await-expr-literal-string.js(default) -language/module-code/top-level-await/syntax/export-dflt-assign-expr-await-expr-literal-string.js(strict mode) -language/module-code/top-level-await/syntax/export-dflt-assign-expr-await-expr-nested.js(default) -language/module-code/top-level-await/syntax/export-dflt-assign-expr-await-expr-nested.js(strict mode) -language/module-code/top-level-await/syntax/export-dflt-assign-expr-await-expr-new-expr.js(default) -language/module-code/top-level-await/syntax/export-dflt-assign-expr-await-expr-new-expr.js(strict mode) -language/module-code/top-level-await/syntax/export-dflt-assign-expr-await-expr-null.js(default) -language/module-code/top-level-await/syntax/export-dflt-assign-expr-await-expr-null.js(strict mode) -language/module-code/top-level-await/syntax/export-dflt-assign-expr-await-expr-obj-literal.js(default) -language/module-code/top-level-await/syntax/export-dflt-assign-expr-await-expr-obj-literal.js(strict mode) -language/module-code/top-level-await/syntax/export-dflt-assign-expr-await-expr-regexp.js(default) -language/module-code/top-level-await/syntax/export-dflt-assign-expr-await-expr-regexp.js(strict mode) -language/module-code/top-level-await/syntax/export-dflt-assign-expr-await-expr-template-literal.js(default) -language/module-code/top-level-await/syntax/export-dflt-assign-expr-await-expr-template-literal.js(strict mode) -language/module-code/top-level-await/syntax/export-dflt-assign-expr-await-expr-this.js(default) -language/module-code/top-level-await/syntax/export-dflt-assign-expr-await-expr-this.js(strict mode) -language/module-code/top-level-await/syntax/export-dft-class-decl-await-expr-array-literal.js(default) -language/module-code/top-level-await/syntax/export-dft-class-decl-await-expr-array-literal.js(strict mode) -language/module-code/top-level-await/syntax/export-dft-class-decl-await-expr-func-expression.js(default) -language/module-code/top-level-await/syntax/export-dft-class-decl-await-expr-func-expression.js(strict mode) -language/module-code/top-level-await/syntax/export-dft-class-decl-await-expr-identifier.js(default) -language/module-code/top-level-await/syntax/export-dft-class-decl-await-expr-identifier.js(strict mode) -language/module-code/top-level-await/syntax/export-dft-class-decl-await-expr-literal-number.js(default) -language/module-code/top-level-await/syntax/export-dft-class-decl-await-expr-literal-number.js(strict mode) -language/module-code/top-level-await/syntax/export-dft-class-decl-await-expr-literal-string.js(default) -language/module-code/top-level-await/syntax/export-dft-class-decl-await-expr-literal-string.js(strict mode) -language/module-code/top-level-await/syntax/export-dft-class-decl-await-expr-nested.js(default) -language/module-code/top-level-await/syntax/export-dft-class-decl-await-expr-nested.js(strict mode) -language/module-code/top-level-await/syntax/export-dft-class-decl-await-expr-new-expr.js(default) -language/module-code/top-level-await/syntax/export-dft-class-decl-await-expr-new-expr.js(strict mode) -language/module-code/top-level-await/syntax/export-dft-class-decl-await-expr-null.js(default) -language/module-code/top-level-await/syntax/export-dft-class-decl-await-expr-null.js(strict mode) -language/module-code/top-level-await/syntax/export-dft-class-decl-await-expr-obj-literal.js(default) -language/module-code/top-level-await/syntax/export-dft-class-decl-await-expr-obj-literal.js(strict mode) -language/module-code/top-level-await/syntax/export-dft-class-decl-await-expr-regexp.js(default) -language/module-code/top-level-await/syntax/export-dft-class-decl-await-expr-regexp.js(strict mode) -language/module-code/top-level-await/syntax/export-dft-class-decl-await-expr-template-literal.js(default) -language/module-code/top-level-await/syntax/export-dft-class-decl-await-expr-template-literal.js(strict mode) -language/module-code/top-level-await/syntax/export-dft-class-decl-await-expr-this.js(default) -language/module-code/top-level-await/syntax/export-dft-class-decl-await-expr-this.js(strict mode) -language/module-code/top-level-await/syntax/export-lex-decl-await-expr-array-literal.js(default) -language/module-code/top-level-await/syntax/export-lex-decl-await-expr-array-literal.js(strict mode) -language/module-code/top-level-await/syntax/export-lex-decl-await-expr-func-expression.js(default) -language/module-code/top-level-await/syntax/export-lex-decl-await-expr-func-expression.js(strict mode) -language/module-code/top-level-await/syntax/export-lex-decl-await-expr-identifier.js(default) -language/module-code/top-level-await/syntax/export-lex-decl-await-expr-identifier.js(strict mode) -language/module-code/top-level-await/syntax/export-lex-decl-await-expr-literal-number.js(default) -language/module-code/top-level-await/syntax/export-lex-decl-await-expr-literal-number.js(strict mode) -language/module-code/top-level-await/syntax/export-lex-decl-await-expr-literal-string.js(default) -language/module-code/top-level-await/syntax/export-lex-decl-await-expr-literal-string.js(strict mode) -language/module-code/top-level-await/syntax/export-lex-decl-await-expr-nested.js(default) -language/module-code/top-level-await/syntax/export-lex-decl-await-expr-nested.js(strict mode) -language/module-code/top-level-await/syntax/export-lex-decl-await-expr-new-expr.js(default) -language/module-code/top-level-await/syntax/export-lex-decl-await-expr-new-expr.js(strict mode) -language/module-code/top-level-await/syntax/export-lex-decl-await-expr-null.js(default) -language/module-code/top-level-await/syntax/export-lex-decl-await-expr-null.js(strict mode) -language/module-code/top-level-await/syntax/export-lex-decl-await-expr-obj-literal.js(default) -language/module-code/top-level-await/syntax/export-lex-decl-await-expr-obj-literal.js(strict mode) -language/module-code/top-level-await/syntax/export-lex-decl-await-expr-regexp.js(default) -language/module-code/top-level-await/syntax/export-lex-decl-await-expr-regexp.js(strict mode) -language/module-code/top-level-await/syntax/export-lex-decl-await-expr-template-literal.js(default) -language/module-code/top-level-await/syntax/export-lex-decl-await-expr-template-literal.js(strict mode) -language/module-code/top-level-await/syntax/export-lex-decl-await-expr-this.js(default) -language/module-code/top-level-await/syntax/export-lex-decl-await-expr-this.js(strict mode) -language/module-code/top-level-await/syntax/export-var-await-expr-array-literal.js(default) -language/module-code/top-level-await/syntax/export-var-await-expr-array-literal.js(strict mode) -language/module-code/top-level-await/syntax/export-var-await-expr-func-expression.js(default) -language/module-code/top-level-await/syntax/export-var-await-expr-func-expression.js(strict mode) -language/module-code/top-level-await/syntax/export-var-await-expr-identifier.js(default) -language/module-code/top-level-await/syntax/export-var-await-expr-identifier.js(strict mode) -language/module-code/top-level-await/syntax/export-var-await-expr-literal-number.js(default) -language/module-code/top-level-await/syntax/export-var-await-expr-literal-number.js(strict mode) -language/module-code/top-level-await/syntax/export-var-await-expr-literal-string.js(default) -language/module-code/top-level-await/syntax/export-var-await-expr-literal-string.js(strict mode) -language/module-code/top-level-await/syntax/export-var-await-expr-nested.js(default) -language/module-code/top-level-await/syntax/export-var-await-expr-nested.js(strict mode) -language/module-code/top-level-await/syntax/export-var-await-expr-new-expr.js(default) -language/module-code/top-level-await/syntax/export-var-await-expr-new-expr.js(strict mode) -language/module-code/top-level-await/syntax/export-var-await-expr-null.js(default) -language/module-code/top-level-await/syntax/export-var-await-expr-null.js(strict mode) -language/module-code/top-level-await/syntax/export-var-await-expr-obj-literal.js(default) -language/module-code/top-level-await/syntax/export-var-await-expr-obj-literal.js(strict mode) -language/module-code/top-level-await/syntax/export-var-await-expr-regexp.js(default) -language/module-code/top-level-await/syntax/export-var-await-expr-regexp.js(strict mode) -language/module-code/top-level-await/syntax/export-var-await-expr-template-literal.js(default) -language/module-code/top-level-await/syntax/export-var-await-expr-template-literal.js(strict mode) -language/module-code/top-level-await/syntax/export-var-await-expr-this.js(default) -language/module-code/top-level-await/syntax/export-var-await-expr-this.js(strict mode) -language/module-code/top-level-await/syntax/for-await-await-expr-array-literal.js(default) -language/module-code/top-level-await/syntax/for-await-await-expr-array-literal.js(strict mode) -language/module-code/top-level-await/syntax/for-await-await-expr-func-expression.js(default) -language/module-code/top-level-await/syntax/for-await-await-expr-func-expression.js(strict mode) -language/module-code/top-level-await/syntax/for-await-await-expr-identifier.js(default) -language/module-code/top-level-await/syntax/for-await-await-expr-identifier.js(strict mode) -language/module-code/top-level-await/syntax/for-await-await-expr-literal-number.js(default) -language/module-code/top-level-await/syntax/for-await-await-expr-literal-number.js(strict mode) -language/module-code/top-level-await/syntax/for-await-await-expr-literal-string.js(default) -language/module-code/top-level-await/syntax/for-await-await-expr-literal-string.js(strict mode) -language/module-code/top-level-await/syntax/for-await-await-expr-nested.js(default) -language/module-code/top-level-await/syntax/for-await-await-expr-nested.js(strict mode) -language/module-code/top-level-await/syntax/for-await-await-expr-new-expr.js(default) -language/module-code/top-level-await/syntax/for-await-await-expr-new-expr.js(strict mode) -language/module-code/top-level-await/syntax/for-await-await-expr-null.js(default) -language/module-code/top-level-await/syntax/for-await-await-expr-null.js(strict mode) -language/module-code/top-level-await/syntax/for-await-await-expr-obj-literal.js(default) -language/module-code/top-level-await/syntax/for-await-await-expr-obj-literal.js(strict mode) -language/module-code/top-level-await/syntax/for-await-await-expr-regexp.js(default) -language/module-code/top-level-await/syntax/for-await-await-expr-regexp.js(strict mode) -language/module-code/top-level-await/syntax/for-await-await-expr-template-literal.js(default) -language/module-code/top-level-await/syntax/for-await-await-expr-template-literal.js(strict mode) -language/module-code/top-level-await/syntax/for-await-await-expr-this.js(default) -language/module-code/top-level-await/syntax/for-await-await-expr-this.js(strict mode) -language/module-code/top-level-await/syntax/for-await-expr-array-literal.js(default) -language/module-code/top-level-await/syntax/for-await-expr-array-literal.js(strict mode) -language/module-code/top-level-await/syntax/for-await-expr-func-expression.js(default) -language/module-code/top-level-await/syntax/for-await-expr-func-expression.js(strict mode) -language/module-code/top-level-await/syntax/for-await-expr-identifier.js(default) -language/module-code/top-level-await/syntax/for-await-expr-identifier.js(strict mode) -language/module-code/top-level-await/syntax/for-await-expr-literal-number.js(default) -language/module-code/top-level-await/syntax/for-await-expr-literal-number.js(strict mode) -language/module-code/top-level-await/syntax/for-await-expr-literal-string.js(default) -language/module-code/top-level-await/syntax/for-await-expr-literal-string.js(strict mode) -language/module-code/top-level-await/syntax/for-await-expr-nested.js(default) -language/module-code/top-level-await/syntax/for-await-expr-nested.js(strict mode) -language/module-code/top-level-await/syntax/for-await-expr-new-expr.js(default) -language/module-code/top-level-await/syntax/for-await-expr-new-expr.js(strict mode) -language/module-code/top-level-await/syntax/for-await-expr-null.js(default) -language/module-code/top-level-await/syntax/for-await-expr-null.js(strict mode) -language/module-code/top-level-await/syntax/for-await-expr-obj-literal.js(default) -language/module-code/top-level-await/syntax/for-await-expr-obj-literal.js(strict mode) -language/module-code/top-level-await/syntax/for-await-expr-regexp.js(default) -language/module-code/top-level-await/syntax/for-await-expr-regexp.js(strict mode) -language/module-code/top-level-await/syntax/for-await-expr-template-literal.js(default) -language/module-code/top-level-await/syntax/for-await-expr-template-literal.js(strict mode) -language/module-code/top-level-await/syntax/for-await-expr-this.js(default) -language/module-code/top-level-await/syntax/for-await-expr-this.js(strict mode) -language/module-code/top-level-await/syntax/for-in-await-expr-array-literal.js(default) -language/module-code/top-level-await/syntax/for-in-await-expr-array-literal.js(strict mode) -language/module-code/top-level-await/syntax/for-in-await-expr-func-expression.js(default) -language/module-code/top-level-await/syntax/for-in-await-expr-func-expression.js(strict mode) -language/module-code/top-level-await/syntax/for-in-await-expr-identifier.js(default) -language/module-code/top-level-await/syntax/for-in-await-expr-identifier.js(strict mode) -language/module-code/top-level-await/syntax/for-in-await-expr-literal-number.js(default) -language/module-code/top-level-await/syntax/for-in-await-expr-literal-number.js(strict mode) -language/module-code/top-level-await/syntax/for-in-await-expr-literal-string.js(default) -language/module-code/top-level-await/syntax/for-in-await-expr-literal-string.js(strict mode) -language/module-code/top-level-await/syntax/for-in-await-expr-nested.js(default) -language/module-code/top-level-await/syntax/for-in-await-expr-nested.js(strict mode) -language/module-code/top-level-await/syntax/for-in-await-expr-new-expr.js(default) -language/module-code/top-level-await/syntax/for-in-await-expr-new-expr.js(strict mode) -language/module-code/top-level-await/syntax/for-in-await-expr-null.js(default) -language/module-code/top-level-await/syntax/for-in-await-expr-null.js(strict mode) -language/module-code/top-level-await/syntax/for-in-await-expr-obj-literal.js(default) -language/module-code/top-level-await/syntax/for-in-await-expr-obj-literal.js(strict mode) -language/module-code/top-level-await/syntax/for-in-await-expr-regexp.js(default) -language/module-code/top-level-await/syntax/for-in-await-expr-regexp.js(strict mode) -language/module-code/top-level-await/syntax/for-in-await-expr-template-literal.js(default) -language/module-code/top-level-await/syntax/for-in-await-expr-template-literal.js(strict mode) -language/module-code/top-level-await/syntax/for-in-await-expr-this.js(default) -language/module-code/top-level-await/syntax/for-in-await-expr-this.js(strict mode) -language/module-code/top-level-await/syntax/for-of-await-expr-array-literal.js(default) -language/module-code/top-level-await/syntax/for-of-await-expr-array-literal.js(strict mode) -language/module-code/top-level-await/syntax/for-of-await-expr-func-expression.js(default) -language/module-code/top-level-await/syntax/for-of-await-expr-func-expression.js(strict mode) -language/module-code/top-level-await/syntax/for-of-await-expr-identifier.js(default) -language/module-code/top-level-await/syntax/for-of-await-expr-identifier.js(strict mode) -language/module-code/top-level-await/syntax/for-of-await-expr-literal-number.js(default) -language/module-code/top-level-await/syntax/for-of-await-expr-literal-number.js(strict mode) -language/module-code/top-level-await/syntax/for-of-await-expr-literal-string.js(default) -language/module-code/top-level-await/syntax/for-of-await-expr-literal-string.js(strict mode) -language/module-code/top-level-await/syntax/for-of-await-expr-nested.js(default) -language/module-code/top-level-await/syntax/for-of-await-expr-nested.js(strict mode) -language/module-code/top-level-await/syntax/for-of-await-expr-new-expr.js(default) -language/module-code/top-level-await/syntax/for-of-await-expr-new-expr.js(strict mode) -language/module-code/top-level-await/syntax/for-of-await-expr-null.js(default) -language/module-code/top-level-await/syntax/for-of-await-expr-null.js(strict mode) -language/module-code/top-level-await/syntax/for-of-await-expr-obj-literal.js(default) -language/module-code/top-level-await/syntax/for-of-await-expr-obj-literal.js(strict mode) -language/module-code/top-level-await/syntax/for-of-await-expr-regexp.js(default) -language/module-code/top-level-await/syntax/for-of-await-expr-regexp.js(strict mode) -language/module-code/top-level-await/syntax/for-of-await-expr-template-literal.js(default) -language/module-code/top-level-await/syntax/for-of-await-expr-template-literal.js(strict mode) -language/module-code/top-level-await/syntax/for-of-await-expr-this.js(default) -language/module-code/top-level-await/syntax/for-of-await-expr-this.js(strict mode) -language/module-code/top-level-await/syntax/if-block-await-expr-array-literal.js(default) -language/module-code/top-level-await/syntax/if-block-await-expr-array-literal.js(strict mode) -language/module-code/top-level-await/syntax/if-block-await-expr-func-expression.js(default) -language/module-code/top-level-await/syntax/if-block-await-expr-func-expression.js(strict mode) -language/module-code/top-level-await/syntax/if-block-await-expr-identifier.js(default) -language/module-code/top-level-await/syntax/if-block-await-expr-identifier.js(strict mode) -language/module-code/top-level-await/syntax/if-block-await-expr-literal-number.js(default) -language/module-code/top-level-await/syntax/if-block-await-expr-literal-number.js(strict mode) -language/module-code/top-level-await/syntax/if-block-await-expr-literal-string.js(default) -language/module-code/top-level-await/syntax/if-block-await-expr-literal-string.js(strict mode) -language/module-code/top-level-await/syntax/if-block-await-expr-nested.js(default) -language/module-code/top-level-await/syntax/if-block-await-expr-nested.js(strict mode) -language/module-code/top-level-await/syntax/if-block-await-expr-new-expr.js(default) -language/module-code/top-level-await/syntax/if-block-await-expr-new-expr.js(strict mode) -language/module-code/top-level-await/syntax/if-block-await-expr-null.js(default) -language/module-code/top-level-await/syntax/if-block-await-expr-null.js(strict mode) -language/module-code/top-level-await/syntax/if-block-await-expr-obj-literal.js(default) -language/module-code/top-level-await/syntax/if-block-await-expr-obj-literal.js(strict mode) -language/module-code/top-level-await/syntax/if-block-await-expr-regexp.js(default) -language/module-code/top-level-await/syntax/if-block-await-expr-regexp.js(strict mode) -language/module-code/top-level-await/syntax/if-block-await-expr-template-literal.js(default) -language/module-code/top-level-await/syntax/if-block-await-expr-template-literal.js(strict mode) -language/module-code/top-level-await/syntax/if-block-await-expr-this.js(default) -language/module-code/top-level-await/syntax/if-block-await-expr-this.js(strict mode) -language/module-code/top-level-await/syntax/if-expr-await-expr-array-literal.js(default) -language/module-code/top-level-await/syntax/if-expr-await-expr-array-literal.js(strict mode) -language/module-code/top-level-await/syntax/if-expr-await-expr-func-expression.js(default) -language/module-code/top-level-await/syntax/if-expr-await-expr-func-expression.js(strict mode) -language/module-code/top-level-await/syntax/if-expr-await-expr-identifier.js(default) -language/module-code/top-level-await/syntax/if-expr-await-expr-identifier.js(strict mode) -language/module-code/top-level-await/syntax/if-expr-await-expr-literal-number.js(default) -language/module-code/top-level-await/syntax/if-expr-await-expr-literal-number.js(strict mode) -language/module-code/top-level-await/syntax/if-expr-await-expr-literal-string.js(default) -language/module-code/top-level-await/syntax/if-expr-await-expr-literal-string.js(strict mode) -language/module-code/top-level-await/syntax/if-expr-await-expr-nested.js(default) -language/module-code/top-level-await/syntax/if-expr-await-expr-nested.js(strict mode) -language/module-code/top-level-await/syntax/if-expr-await-expr-new-expr.js(default) -language/module-code/top-level-await/syntax/if-expr-await-expr-new-expr.js(strict mode) -language/module-code/top-level-await/syntax/if-expr-await-expr-null.js(default) -language/module-code/top-level-await/syntax/if-expr-await-expr-null.js(strict mode) -language/module-code/top-level-await/syntax/if-expr-await-expr-obj-literal.js(default) -language/module-code/top-level-await/syntax/if-expr-await-expr-obj-literal.js(strict mode) -language/module-code/top-level-await/syntax/if-expr-await-expr-regexp.js(default) -language/module-code/top-level-await/syntax/if-expr-await-expr-regexp.js(strict mode) -language/module-code/top-level-await/syntax/if-expr-await-expr-template-literal.js(default) -language/module-code/top-level-await/syntax/if-expr-await-expr-template-literal.js(strict mode) -language/module-code/top-level-await/syntax/if-expr-await-expr-this.js(default) -language/module-code/top-level-await/syntax/if-expr-await-expr-this.js(strict mode) -language/module-code/top-level-await/syntax/top-level-await-expr-array-literal.js(default) -language/module-code/top-level-await/syntax/top-level-await-expr-array-literal.js(strict mode) -language/module-code/top-level-await/syntax/top-level-await-expr-func-expression.js(default) -language/module-code/top-level-await/syntax/top-level-await-expr-func-expression.js(strict mode) -language/module-code/top-level-await/syntax/top-level-await-expr-identifier.js(default) -language/module-code/top-level-await/syntax/top-level-await-expr-identifier.js(strict mode) -language/module-code/top-level-await/syntax/top-level-await-expr-literal-number.js(default) -language/module-code/top-level-await/syntax/top-level-await-expr-literal-number.js(strict mode) -language/module-code/top-level-await/syntax/top-level-await-expr-literal-string.js(default) -language/module-code/top-level-await/syntax/top-level-await-expr-literal-string.js(strict mode) -language/module-code/top-level-await/syntax/top-level-await-expr-nested.js(default) -language/module-code/top-level-await/syntax/top-level-await-expr-nested.js(strict mode) -language/module-code/top-level-await/syntax/top-level-await-expr-new-expr.js(default) -language/module-code/top-level-await/syntax/top-level-await-expr-new-expr.js(strict mode) -language/module-code/top-level-await/syntax/top-level-await-expr-null.js(default) -language/module-code/top-level-await/syntax/top-level-await-expr-null.js(strict mode) -language/module-code/top-level-await/syntax/top-level-await-expr-obj-literal.js(default) -language/module-code/top-level-await/syntax/top-level-await-expr-obj-literal.js(strict mode) -language/module-code/top-level-await/syntax/top-level-await-expr-regexp.js(default) -language/module-code/top-level-await/syntax/top-level-await-expr-regexp.js(strict mode) -language/module-code/top-level-await/syntax/top-level-await-expr-template-literal.js(default) -language/module-code/top-level-await/syntax/top-level-await-expr-template-literal.js(strict mode) -language/module-code/top-level-await/syntax/top-level-await-expr-this.js(default) -language/module-code/top-level-await/syntax/top-level-await-expr-this.js(strict mode) -language/module-code/top-level-await/syntax/try-await-expr-array-literal.js(default) -language/module-code/top-level-await/syntax/try-await-expr-array-literal.js(strict mode) -language/module-code/top-level-await/syntax/try-await-expr-func-expression.js(default) -language/module-code/top-level-await/syntax/try-await-expr-func-expression.js(strict mode) -language/module-code/top-level-await/syntax/try-await-expr-identifier.js(default) -language/module-code/top-level-await/syntax/try-await-expr-identifier.js(strict mode) -language/module-code/top-level-await/syntax/try-await-expr-literal-number.js(default) -language/module-code/top-level-await/syntax/try-await-expr-literal-number.js(strict mode) -language/module-code/top-level-await/syntax/try-await-expr-literal-string.js(default) -language/module-code/top-level-await/syntax/try-await-expr-literal-string.js(strict mode) -language/module-code/top-level-await/syntax/try-await-expr-nested.js(default) -language/module-code/top-level-await/syntax/try-await-expr-nested.js(strict mode) -language/module-code/top-level-await/syntax/try-await-expr-new-expr.js(default) -language/module-code/top-level-await/syntax/try-await-expr-new-expr.js(strict mode) -language/module-code/top-level-await/syntax/try-await-expr-null.js(default) -language/module-code/top-level-await/syntax/try-await-expr-null.js(strict mode) -language/module-code/top-level-await/syntax/try-await-expr-obj-literal.js(default) -language/module-code/top-level-await/syntax/try-await-expr-obj-literal.js(strict mode) -language/module-code/top-level-await/syntax/try-await-expr-regexp.js(default) -language/module-code/top-level-await/syntax/try-await-expr-regexp.js(strict mode) -language/module-code/top-level-await/syntax/try-await-expr-template-literal.js(default) -language/module-code/top-level-await/syntax/try-await-expr-template-literal.js(strict mode) -language/module-code/top-level-await/syntax/try-await-expr-this.js(default) -language/module-code/top-level-await/syntax/try-await-expr-this.js(strict mode) -language/module-code/top-level-await/syntax/typeof-await-expr-array-literal.js(default) -language/module-code/top-level-await/syntax/typeof-await-expr-array-literal.js(strict mode) -language/module-code/top-level-await/syntax/typeof-await-expr-func-expression.js(default) -language/module-code/top-level-await/syntax/typeof-await-expr-func-expression.js(strict mode) -language/module-code/top-level-await/syntax/typeof-await-expr-identifier.js(default) -language/module-code/top-level-await/syntax/typeof-await-expr-identifier.js(strict mode) -language/module-code/top-level-await/syntax/typeof-await-expr-literal-number.js(default) -language/module-code/top-level-await/syntax/typeof-await-expr-literal-number.js(strict mode) -language/module-code/top-level-await/syntax/typeof-await-expr-literal-string.js(default) -language/module-code/top-level-await/syntax/typeof-await-expr-literal-string.js(strict mode) -language/module-code/top-level-await/syntax/typeof-await-expr-nested.js(default) -language/module-code/top-level-await/syntax/typeof-await-expr-nested.js(strict mode) -language/module-code/top-level-await/syntax/typeof-await-expr-new-expr.js(default) -language/module-code/top-level-await/syntax/typeof-await-expr-new-expr.js(strict mode) -language/module-code/top-level-await/syntax/typeof-await-expr-null.js(default) -language/module-code/top-level-await/syntax/typeof-await-expr-null.js(strict mode) -language/module-code/top-level-await/syntax/typeof-await-expr-obj-literal.js(default) -language/module-code/top-level-await/syntax/typeof-await-expr-obj-literal.js(strict mode) -language/module-code/top-level-await/syntax/typeof-await-expr-regexp.js(default) -language/module-code/top-level-await/syntax/typeof-await-expr-regexp.js(strict mode) -language/module-code/top-level-await/syntax/typeof-await-expr-template-literal.js(default) -language/module-code/top-level-await/syntax/typeof-await-expr-template-literal.js(strict mode) -language/module-code/top-level-await/syntax/typeof-await-expr-this.js(default) -language/module-code/top-level-await/syntax/typeof-await-expr-this.js(strict mode) -language/module-code/top-level-await/syntax/void-await-expr-array-literal.js(default) -language/module-code/top-level-await/syntax/void-await-expr-array-literal.js(strict mode) -language/module-code/top-level-await/syntax/void-await-expr-func-expression.js(default) -language/module-code/top-level-await/syntax/void-await-expr-func-expression.js(strict mode) -language/module-code/top-level-await/syntax/void-await-expr-identifier.js(default) -language/module-code/top-level-await/syntax/void-await-expr-identifier.js(strict mode) -language/module-code/top-level-await/syntax/void-await-expr-literal-number.js(default) -language/module-code/top-level-await/syntax/void-await-expr-literal-number.js(strict mode) -language/module-code/top-level-await/syntax/void-await-expr-literal-string.js(default) -language/module-code/top-level-await/syntax/void-await-expr-literal-string.js(strict mode) -language/module-code/top-level-await/syntax/void-await-expr-nested.js(default) -language/module-code/top-level-await/syntax/void-await-expr-nested.js(strict mode) -language/module-code/top-level-await/syntax/void-await-expr-new-expr.js(default) -language/module-code/top-level-await/syntax/void-await-expr-new-expr.js(strict mode) -language/module-code/top-level-await/syntax/void-await-expr-null.js(default) -language/module-code/top-level-await/syntax/void-await-expr-null.js(strict mode) -language/module-code/top-level-await/syntax/void-await-expr-obj-literal.js(default) -language/module-code/top-level-await/syntax/void-await-expr-obj-literal.js(strict mode) -language/module-code/top-level-await/syntax/void-await-expr-regexp.js(default) -language/module-code/top-level-await/syntax/void-await-expr-regexp.js(strict mode) -language/module-code/top-level-await/syntax/void-await-expr-template-literal.js(default) -language/module-code/top-level-await/syntax/void-await-expr-template-literal.js(strict mode) -language/module-code/top-level-await/syntax/void-await-expr-this.js(default) -language/module-code/top-level-await/syntax/void-await-expr-this.js(strict mode) -language/module-code/top-level-await/syntax/while-await-expr-array-literal.js(default) -language/module-code/top-level-await/syntax/while-await-expr-array-literal.js(strict mode) -language/module-code/top-level-await/syntax/while-await-expr-func-expression.js(default) -language/module-code/top-level-await/syntax/while-await-expr-func-expression.js(strict mode) -language/module-code/top-level-await/syntax/while-await-expr-identifier.js(default) -language/module-code/top-level-await/syntax/while-await-expr-identifier.js(strict mode) -language/module-code/top-level-await/syntax/while-await-expr-literal-number.js(default) -language/module-code/top-level-await/syntax/while-await-expr-literal-number.js(strict mode) -language/module-code/top-level-await/syntax/while-await-expr-literal-string.js(default) -language/module-code/top-level-await/syntax/while-await-expr-literal-string.js(strict mode) -language/module-code/top-level-await/syntax/while-await-expr-nested.js(default) -language/module-code/top-level-await/syntax/while-await-expr-nested.js(strict mode) -language/module-code/top-level-await/syntax/while-await-expr-new-expr.js(default) -language/module-code/top-level-await/syntax/while-await-expr-new-expr.js(strict mode) -language/module-code/top-level-await/syntax/while-await-expr-null.js(default) -language/module-code/top-level-await/syntax/while-await-expr-null.js(strict mode) -language/module-code/top-level-await/syntax/while-await-expr-obj-literal.js(default) -language/module-code/top-level-await/syntax/while-await-expr-obj-literal.js(strict mode) -language/module-code/top-level-await/syntax/while-await-expr-regexp.js(default) -language/module-code/top-level-await/syntax/while-await-expr-regexp.js(strict mode) -language/module-code/top-level-await/syntax/while-await-expr-template-literal.js(default) -language/module-code/top-level-await/syntax/while-await-expr-template-literal.js(strict mode) -language/module-code/top-level-await/syntax/while-await-expr-this.js(default) -language/module-code/top-level-await/syntax/while-await-expr-this.js(strict mode) -language/module-code/top-level-await/top-level-ticks-2.js(default) -language/module-code/top-level-await/top-level-ticks-2.js(strict mode) -language/module-code/top-level-await/top-level-ticks.js(default) -language/module-code/top-level-await/top-level-ticks.js(strict mode) -language/module-code/top-level-await/void-await-expr.js(default) -language/module-code/top-level-await/void-await-expr.js(strict mode) -language/module-code/top-level-await/while-dynamic-evaluation.js(default) -language/module-code/top-level-await/while-dynamic-evaluation.js(strict mode) language/statements/class/elements/fields-duplicate-privatenames.js(default) language/statements/class/elements/fields-duplicate-privatenames.js(strict mode) language/statements/class/elements/privatename-not-valid-earlyerr-script-1.js(default) diff --git a/yarn.lock b/yarn.lock index 17d850dc2850..95eb973a33d3 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2,18 +2,17 @@ # yarn lockfile v1 -"@babel/cli@^7.6.0": - version "7.6.0" - resolved "https://registry.yarnpkg.com/@babel/cli/-/cli-7.6.0.tgz#1470a04394eaf37862989ea4912adf440fa6ff8d" - integrity sha512-1CTDyGUjQqW3Mz4gfKZ04KGOckyyaNmKneAMlABPS+ZyuxWv3FrVEVz7Ag08kNIztVx8VaJ8YgvYLSNlMKAT5Q== +"@babel/cli@^7.7.0": + version "7.7.0" + resolved "https://registry.yarnpkg.com/@babel/cli/-/cli-7.7.0.tgz#8d10c9acb2acb362d7614a9493e1791c69100d89" + integrity sha512-jECEqAq6Ngf3pOhLSg7od9WKyrIacyh1oNNYtRXNn+ummSHCTXBamGywOAtiae34Vk7zKuQNnLvo2BKTMCoV4A== dependencies: commander "^2.8.1" convert-source-map "^1.1.0" fs-readdir-recursive "^1.1.0" glob "^7.0.0" lodash "^4.17.13" - mkdirp "^0.5.1" - output-file-sync "^2.0.0" + make-dir "^2.1.0" slash "^2.0.0" source-map "^0.5.0" optionalDependencies: @@ -26,19 +25,19 @@ dependencies: "@babel/highlight" "^7.0.0" -"@babel/core@^7.1.0", "@babel/core@^7.6.0": - version "7.6.0" - resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.6.0.tgz#9b00f73554edd67bebc86df8303ef678be3d7b48" - integrity sha512-FuRhDRtsd6IptKpHXAa+4WPZYY2ZzgowkbLBecEDDSje1X/apG7jQM33or3NdOmjXBKWGOg4JmSiRfUfuTtHXw== +"@babel/core@^7.1.0", "@babel/core@^7.7.2": + version "7.7.2" + resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.7.2.tgz#ea5b99693bcfc058116f42fa1dd54da412b29d91" + integrity sha512-eeD7VEZKfhK1KUXGiyPFettgF3m513f8FoBSWiQ1xTvl1RAopLs42Wp9+Ze911I6H0N9lNqJMDgoZT7gHsipeQ== dependencies: "@babel/code-frame" "^7.5.5" - "@babel/generator" "^7.6.0" - "@babel/helpers" "^7.6.0" - "@babel/parser" "^7.6.0" - "@babel/template" "^7.6.0" - "@babel/traverse" "^7.6.0" - "@babel/types" "^7.6.0" - convert-source-map "^1.1.0" + "@babel/generator" "^7.7.2" + "@babel/helpers" "^7.7.0" + "@babel/parser" "^7.7.2" + "@babel/template" "^7.7.0" + "@babel/traverse" "^7.7.2" + "@babel/types" "^7.7.2" + convert-source-map "^1.7.0" debug "^4.1.0" json5 "^2.1.0" lodash "^4.17.13" @@ -51,23 +50,22 @@ resolved "https://registry.yarnpkg.com/@babel/eslint-plugin-development/-/eslint-plugin-development-1.0.1.tgz#1f5206ae95795db09b65e7dbc2b158d66497a44c" integrity sha512-ioEhN8HgKr4Yx8ef+XryNpKN4FimSFceb0qVVxvoUzpFn3xyq17MlY5AquEqtXObE7Nu7WKq7QL9INzjCrugyw== -"@babel/generator@^7.4.0", "@babel/generator@^7.6.0": - version "7.6.0" - resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.6.0.tgz#e2c21efbfd3293ad819a2359b448f002bfdfda56" - integrity sha512-Ms8Mo7YBdMMn1BYuNtKuP/z0TgEIhbcyB8HVR6PPNYp4P61lMsABiS4A3VG1qznjXVCf3r+fVHhm4efTYVsySA== +"@babel/generator@^7.4.0", "@babel/generator@^7.7.2": + version "7.7.2" + resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.7.2.tgz#2f4852d04131a5e17ea4f6645488b5da66ebf3af" + integrity sha512-WthSArvAjYLz4TcbKOi88me+KmDJdKSlfwwN8CnUYn9jBkzhq0ZEPuBfkAWIvjJ3AdEV1Cf/+eSQTnp3IDJKlQ== dependencies: - "@babel/types" "^7.6.0" + "@babel/types" "^7.7.2" jsesc "^2.5.1" lodash "^4.17.13" source-map "^0.5.0" - trim-right "^1.0.1" -"@babel/helper-annotate-as-pure@^7.0.0": - version "7.0.0" - resolved "https://registry.yarnpkg.com/@babel/helper-annotate-as-pure/-/helper-annotate-as-pure-7.0.0.tgz#323d39dd0b50e10c7c06ca7d7638e6864d8c5c32" - integrity sha512-3UYcJUj9kvSLbLbUIfQTqzcy5VX7GRZ/CCDrnOaZorFFM01aXp1+GJwuFGV4NDDoAS+mOUyHcO6UD/RfqOks3Q== +"@babel/helper-annotate-as-pure@^7.0.0", "@babel/helper-annotate-as-pure@^7.7.0": + version "7.7.0" + resolved "https://registry.yarnpkg.com/@babel/helper-annotate-as-pure/-/helper-annotate-as-pure-7.7.0.tgz#efc54032d43891fe267679e63f6860aa7dbf4a5e" + integrity sha512-k50CQxMlYTYo+GGyUGFwpxKVtxVJi9yh61sXZji3zYHccK9RYliZGSTOgci85T+r+0VFN2nWbGM04PIqwfrpMg== dependencies: - "@babel/types" "^7.0.0" + "@babel/types" "^7.7.0" "@babel/helper-builder-binary-assignment-operator-visitor@^7.1.0": version "7.1.0" @@ -86,25 +84,33 @@ "@babel/traverse" "^7.4.4" "@babel/types" "^7.4.4" -"@babel/helper-create-class-features-plugin@^7.5.5": - version "7.6.0" - resolved "https://registry.yarnpkg.com/@babel/helper-create-class-features-plugin/-/helper-create-class-features-plugin-7.6.0.tgz#769711acca889be371e9bc2eb68641d55218021f" - integrity sha512-O1QWBko4fzGju6VoVvrZg0RROCVifcLxiApnGP3OWfWzvxRZFCoBD81K5ur5e3bVY2Vf/5rIJm8cqPKn8HUJng== +"@babel/helper-create-class-features-plugin@^7.7.0": + version "7.7.0" + resolved "https://registry.yarnpkg.com/@babel/helper-create-class-features-plugin/-/helper-create-class-features-plugin-7.7.0.tgz#bcdc223abbfdd386f94196ae2544987f8df775e8" + integrity sha512-MZiB5qvTWoyiFOgootmRSDV1udjIqJW/8lmxgzKq6oDqxdmHUjeP2ZUOmgHdYjmUVNABqRrHjYAYRvj8Eox/UA== dependencies: - "@babel/helper-function-name" "^7.1.0" - "@babel/helper-member-expression-to-functions" "^7.5.5" - "@babel/helper-optimise-call-expression" "^7.0.0" + "@babel/helper-function-name" "^7.7.0" + "@babel/helper-member-expression-to-functions" "^7.7.0" + "@babel/helper-optimise-call-expression" "^7.7.0" "@babel/helper-plugin-utils" "^7.0.0" - "@babel/helper-replace-supers" "^7.5.5" - "@babel/helper-split-export-declaration" "^7.4.4" + "@babel/helper-replace-supers" "^7.7.0" + "@babel/helper-split-export-declaration" "^7.7.0" -"@babel/helper-define-map@^7.5.5": - version "7.5.5" - resolved "https://registry.yarnpkg.com/@babel/helper-define-map/-/helper-define-map-7.5.5.tgz#3dec32c2046f37e09b28c93eb0b103fd2a25d369" - integrity sha512-fTfxx7i0B5NJqvUOBBGREnrqbTxRh7zinBANpZXAVDlsZxYdclDp467G1sQ8VZYMnAURY3RpBUAgOYT9GfzHBg== +"@babel/helper-create-regexp-features-plugin@^7.7.0": + version "7.7.0" + resolved "https://registry.yarnpkg.com/@babel/helper-create-regexp-features-plugin/-/helper-create-regexp-features-plugin-7.7.0.tgz#2e8badfe201cfafb5d930f46cf1e0b6f1cdcab23" + integrity sha512-ZhagAAVGD3L6MPM9/zZi7RRteonfBFLVUz3kjsnYsMAtr9hOJCKI9BAKIMpqn3NyWicPieoX779UL+7/3BEAOA== + dependencies: + "@babel/helper-regex" "^7.4.4" + regexpu-core "^4.6.0" + +"@babel/helper-define-map@^7.7.0": + version "7.7.0" + resolved "https://registry.yarnpkg.com/@babel/helper-define-map/-/helper-define-map-7.7.0.tgz#60b0e9fd60def9de5054c38afde8c8ee409c7529" + integrity sha512-kPKWPb0dMpZi+ov1hJiwse9dWweZsz3V9rP4KdytnX1E7z3cTNmFGglwklzFPuqIcHLIY3bgKSs4vkwXXdflQA== dependencies: - "@babel/helper-function-name" "^7.1.0" - "@babel/types" "^7.5.5" + "@babel/helper-function-name" "^7.7.0" + "@babel/types" "^7.7.0" lodash "^4.17.13" "@babel/helper-explode-assignable-expression@^7.1.0": @@ -115,61 +121,61 @@ "@babel/traverse" "^7.1.0" "@babel/types" "^7.0.0" -"@babel/helper-function-name@^7.1.0": - version "7.1.0" - resolved "https://registry.yarnpkg.com/@babel/helper-function-name/-/helper-function-name-7.1.0.tgz#a0ceb01685f73355d4360c1247f582bfafc8ff53" - integrity sha512-A95XEoCpb3TO+KZzJ4S/5uW5fNe26DjBGqf1o9ucyLyCmi1dXq/B3c8iaWTfBk3VvetUxl16e8tIrd5teOCfGw== +"@babel/helper-function-name@^7.7.0": + version "7.7.0" + resolved "https://registry.yarnpkg.com/@babel/helper-function-name/-/helper-function-name-7.7.0.tgz#44a5ad151cfff8ed2599c91682dda2ec2c8430a3" + integrity sha512-tDsJgMUAP00Ugv8O2aGEua5I2apkaQO7lBGUq1ocwN3G23JE5Dcq0uh3GvFTChPa4b40AWiAsLvCZOA2rdnQ7Q== dependencies: - "@babel/helper-get-function-arity" "^7.0.0" - "@babel/template" "^7.1.0" - "@babel/types" "^7.0.0" + "@babel/helper-get-function-arity" "^7.7.0" + "@babel/template" "^7.7.0" + "@babel/types" "^7.7.0" -"@babel/helper-get-function-arity@^7.0.0": - version "7.0.0" - resolved "https://registry.yarnpkg.com/@babel/helper-get-function-arity/-/helper-get-function-arity-7.0.0.tgz#83572d4320e2a4657263734113c42868b64e49c3" - integrity sha512-r2DbJeg4svYvt3HOS74U4eWKsUAMRH01Z1ds1zx8KNTPtpTL5JAsdFv8BNyOpVqdFhHkkRDIg5B4AsxmkjAlmQ== +"@babel/helper-get-function-arity@^7.0.0", "@babel/helper-get-function-arity@^7.7.0": + version "7.7.0" + resolved "https://registry.yarnpkg.com/@babel/helper-get-function-arity/-/helper-get-function-arity-7.7.0.tgz#c604886bc97287a1d1398092bc666bc3d7d7aa2d" + integrity sha512-tLdojOTz4vWcEnHWHCuPN5P85JLZWbm5Fx5ZsMEMPhF3Uoe3O7awrbM2nQ04bDOUToH/2tH/ezKEOR8zEYzqyw== dependencies: - "@babel/types" "^7.0.0" + "@babel/types" "^7.7.0" -"@babel/helper-hoist-variables@^7.4.4": - version "7.4.4" - resolved "https://registry.yarnpkg.com/@babel/helper-hoist-variables/-/helper-hoist-variables-7.4.4.tgz#0298b5f25c8c09c53102d52ac4a98f773eb2850a" - integrity sha512-VYk2/H/BnYbZDDg39hr3t2kKyifAm1W6zHRfhx8jGjIHpQEBv9dry7oQ2f3+J703TLu69nYdxsovl0XYfcnK4w== +"@babel/helper-hoist-variables@^7.4.4", "@babel/helper-hoist-variables@^7.7.0": + version "7.7.0" + resolved "https://registry.yarnpkg.com/@babel/helper-hoist-variables/-/helper-hoist-variables-7.7.0.tgz#b4552e4cfe5577d7de7b183e193e84e4ec538c81" + integrity sha512-LUe/92NqsDAkJjjCEWkNe+/PcpnisvnqdlRe19FahVapa4jndeuJ+FBiTX1rcAKWKcJGE+C3Q3tuEuxkSmCEiQ== dependencies: - "@babel/types" "^7.4.4" + "@babel/types" "^7.7.0" -"@babel/helper-member-expression-to-functions@^7.5.5": - version "7.5.5" - resolved "https://registry.yarnpkg.com/@babel/helper-member-expression-to-functions/-/helper-member-expression-to-functions-7.5.5.tgz#1fb5b8ec4453a93c439ee9fe3aeea4a84b76b590" - integrity sha512-5qZ3D1uMclSNqYcXqiHoA0meVdv+xUEex9em2fqMnrk/scphGlGgg66zjMrPJESPwrFJ6sbfFQYUSa0Mz7FabA== +"@babel/helper-member-expression-to-functions@^7.7.0": + version "7.7.0" + resolved "https://registry.yarnpkg.com/@babel/helper-member-expression-to-functions/-/helper-member-expression-to-functions-7.7.0.tgz#472b93003a57071f95a541ea6c2b098398bcad8a" + integrity sha512-QaCZLO2RtBcmvO/ekOLp8p7R5X2JriKRizeDpm5ChATAFWrrYDcDxPuCIBXKyBjY+i1vYSdcUTMIb8psfxHDPA== dependencies: - "@babel/types" "^7.5.5" + "@babel/types" "^7.7.0" -"@babel/helper-module-imports@^7.0.0": - version "7.0.0" - resolved "https://registry.yarnpkg.com/@babel/helper-module-imports/-/helper-module-imports-7.0.0.tgz#96081b7111e486da4d2cd971ad1a4fe216cc2e3d" - integrity sha512-aP/hlLq01DWNEiDg4Jn23i+CXxW/owM4WpDLFUbpjxe4NS3BhLVZQ5i7E0ZrxuQ/vwekIeciyamgB1UIYxxM6A== +"@babel/helper-module-imports@^7.0.0", "@babel/helper-module-imports@^7.7.0": + version "7.7.0" + resolved "https://registry.yarnpkg.com/@babel/helper-module-imports/-/helper-module-imports-7.7.0.tgz#99c095889466e5f7b6d66d98dffc58baaf42654d" + integrity sha512-Dv3hLKIC1jyfTkClvyEkYP2OlkzNvWs5+Q8WgPbxM5LMeorons7iPP91JM+DU7tRbhqA1ZeooPaMFvQrn23RHw== dependencies: - "@babel/types" "^7.0.0" + "@babel/types" "^7.7.0" -"@babel/helper-module-transforms@^7.1.0", "@babel/helper-module-transforms@^7.4.4": - version "7.5.5" - resolved "https://registry.yarnpkg.com/@babel/helper-module-transforms/-/helper-module-transforms-7.5.5.tgz#f84ff8a09038dcbca1fd4355661a500937165b4a" - integrity sha512-jBeCvETKuJqeiaCdyaheF40aXnnU1+wkSiUs/IQg3tB85up1LyL8x77ClY8qJpuRJUcXQo+ZtdNESmZl4j56Pw== +"@babel/helper-module-transforms@^7.1.0", "@babel/helper-module-transforms@^7.7.0": + version "7.7.0" + resolved "https://registry.yarnpkg.com/@babel/helper-module-transforms/-/helper-module-transforms-7.7.0.tgz#154a69f0c5b8fd4d39e49750ff7ac4faa3f36786" + integrity sha512-rXEefBuheUYQyX4WjV19tuknrJFwyKw0HgzRwbkyTbB+Dshlq7eqkWbyjzToLrMZk/5wKVKdWFluiAsVkHXvuQ== dependencies: - "@babel/helper-module-imports" "^7.0.0" - "@babel/helper-simple-access" "^7.1.0" - "@babel/helper-split-export-declaration" "^7.4.4" - "@babel/template" "^7.4.4" - "@babel/types" "^7.5.5" + "@babel/helper-module-imports" "^7.7.0" + "@babel/helper-simple-access" "^7.7.0" + "@babel/helper-split-export-declaration" "^7.7.0" + "@babel/template" "^7.7.0" + "@babel/types" "^7.7.0" lodash "^4.17.13" -"@babel/helper-optimise-call-expression@^7.0.0": - version "7.0.0" - resolved "https://registry.yarnpkg.com/@babel/helper-optimise-call-expression/-/helper-optimise-call-expression-7.0.0.tgz#a2920c5702b073c15de51106200aa8cad20497d5" - integrity sha512-u8nd9NQePYNQV8iPWu/pLLYBqZBa4ZaY1YWRFMuxrid94wKI1QNt67NEZ7GAe5Kc/0LLScbim05xZFWkAdrj9g== +"@babel/helper-optimise-call-expression@^7.7.0": + version "7.7.0" + resolved "https://registry.yarnpkg.com/@babel/helper-optimise-call-expression/-/helper-optimise-call-expression-7.7.0.tgz#4f66a216116a66164135dc618c5d8b7a959f9365" + integrity sha512-48TeqmbazjNU/65niiiJIJRc5JozB8acui1OS7bSd6PgxfuovWsvjfWSzlgx+gPFdVveNzUdpdIg5l56Pl5jqg== dependencies: - "@babel/types" "^7.0.0" + "@babel/types" "^7.7.0" "@babel/helper-plugin-utils@^7.0.0": version "7.0.0" @@ -183,60 +189,60 @@ dependencies: lodash "^4.17.13" -"@babel/helper-remap-async-to-generator@^7.1.0": - version "7.1.0" - resolved "https://registry.yarnpkg.com/@babel/helper-remap-async-to-generator/-/helper-remap-async-to-generator-7.1.0.tgz#361d80821b6f38da75bd3f0785ece20a88c5fe7f" - integrity sha512-3fOK0L+Fdlg8S5al8u/hWE6vhufGSn0bN09xm2LXMy//REAF8kDCrYoOBKYmA8m5Nom+sV9LyLCwrFynA8/slg== - dependencies: - "@babel/helper-annotate-as-pure" "^7.0.0" - "@babel/helper-wrap-function" "^7.1.0" - "@babel/template" "^7.1.0" - "@babel/traverse" "^7.1.0" - "@babel/types" "^7.0.0" - -"@babel/helper-replace-supers@^7.5.5": - version "7.5.5" - resolved "https://registry.yarnpkg.com/@babel/helper-replace-supers/-/helper-replace-supers-7.5.5.tgz#f84ce43df031222d2bad068d2626cb5799c34bc2" - integrity sha512-XvRFWrNnlsow2u7jXDuH4jDDctkxbS7gXssrP4q2nUD606ukXHRvydj346wmNg+zAgpFx4MWf4+usfC93bElJg== - dependencies: - "@babel/helper-member-expression-to-functions" "^7.5.5" - "@babel/helper-optimise-call-expression" "^7.0.0" - "@babel/traverse" "^7.5.5" - "@babel/types" "^7.5.5" - -"@babel/helper-simple-access@^7.1.0": - version "7.1.0" - resolved "https://registry.yarnpkg.com/@babel/helper-simple-access/-/helper-simple-access-7.1.0.tgz#65eeb954c8c245beaa4e859da6188f39d71e585c" - integrity sha512-Vk+78hNjRbsiu49zAPALxTb+JUQCz1aolpd8osOF16BGnLtseD21nbHgLPGUwrXEurZgiCOUmvs3ExTu4F5x6w== - dependencies: - "@babel/template" "^7.1.0" - "@babel/types" "^7.0.0" - -"@babel/helper-split-export-declaration@^7.4.4": - version "7.4.4" - resolved "https://registry.yarnpkg.com/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.4.4.tgz#ff94894a340be78f53f06af038b205c49d993677" - integrity sha512-Ro/XkzLf3JFITkW6b+hNxzZ1n5OQ80NvIUdmHspih1XAhtN3vPTuUFT4eQnela+2MaZ5ulH+iyP513KJrxbN7Q== - dependencies: - "@babel/types" "^7.4.4" - -"@babel/helper-wrap-function@^7.1.0": - version "7.2.0" - resolved "https://registry.yarnpkg.com/@babel/helper-wrap-function/-/helper-wrap-function-7.2.0.tgz#c4e0012445769e2815b55296ead43a958549f6fa" - integrity sha512-o9fP1BZLLSrYlxYEYyl2aS+Flun5gtjTIG8iln+XuEzQTs0PLagAGSXUcqruJwD5fM48jzIEggCKpIfWTcR7pQ== - dependencies: - "@babel/helper-function-name" "^7.1.0" - "@babel/template" "^7.1.0" - "@babel/traverse" "^7.1.0" - "@babel/types" "^7.2.0" - -"@babel/helpers@^7.6.0": - version "7.6.0" - resolved "https://registry.yarnpkg.com/@babel/helpers/-/helpers-7.6.0.tgz#21961d16c6a3c3ab597325c34c465c0887d31c6e" - integrity sha512-W9kao7OBleOjfXtFGgArGRX6eCP0UEcA2ZWEWNkJdRZnHhW4eEbeswbG3EwaRsnQUAEGWYgMq1HsIXuNNNy2eQ== - dependencies: - "@babel/template" "^7.6.0" - "@babel/traverse" "^7.6.0" - "@babel/types" "^7.6.0" +"@babel/helper-remap-async-to-generator@^7.7.0": + version "7.7.0" + resolved "https://registry.yarnpkg.com/@babel/helper-remap-async-to-generator/-/helper-remap-async-to-generator-7.7.0.tgz#4d69ec653e8bff5bce62f5d33fc1508f223c75a7" + integrity sha512-pHx7RN8X0UNHPB/fnuDnRXVZ316ZigkO8y8D835JlZ2SSdFKb6yH9MIYRU4fy/KPe5sPHDFOPvf8QLdbAGGiyw== + dependencies: + "@babel/helper-annotate-as-pure" "^7.7.0" + "@babel/helper-wrap-function" "^7.7.0" + "@babel/template" "^7.7.0" + "@babel/traverse" "^7.7.0" + "@babel/types" "^7.7.0" + +"@babel/helper-replace-supers@^7.5.5", "@babel/helper-replace-supers@^7.7.0": + version "7.7.0" + resolved "https://registry.yarnpkg.com/@babel/helper-replace-supers/-/helper-replace-supers-7.7.0.tgz#d5365c8667fe7cbd13b8ddddceb9bd7f2b387512" + integrity sha512-5ALYEul5V8xNdxEeWvRsBzLMxQksT7MaStpxjJf9KsnLxpAKBtfw5NeMKZJSYDa0lKdOcy0g+JT/f5mPSulUgg== + dependencies: + "@babel/helper-member-expression-to-functions" "^7.7.0" + "@babel/helper-optimise-call-expression" "^7.7.0" + "@babel/traverse" "^7.7.0" + "@babel/types" "^7.7.0" + +"@babel/helper-simple-access@^7.7.0": + version "7.7.0" + resolved "https://registry.yarnpkg.com/@babel/helper-simple-access/-/helper-simple-access-7.7.0.tgz#97a8b6c52105d76031b86237dc1852b44837243d" + integrity sha512-AJ7IZD7Eem3zZRuj5JtzFAptBw7pMlS3y8Qv09vaBWoFsle0d1kAn5Wq6Q9MyBXITPOKnxwkZKoAm4bopmv26g== + dependencies: + "@babel/template" "^7.7.0" + "@babel/types" "^7.7.0" + +"@babel/helper-split-export-declaration@^7.7.0": + version "7.7.0" + resolved "https://registry.yarnpkg.com/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.7.0.tgz#1365e74ea6c614deeb56ebffabd71006a0eb2300" + integrity sha512-HgYSI8rH08neWlAH3CcdkFg9qX9YsZysZI5GD8LjhQib/mM0jGOZOVkoUiiV2Hu978fRtjtsGsW6w0pKHUWtqA== + dependencies: + "@babel/types" "^7.7.0" + +"@babel/helper-wrap-function@^7.7.0": + version "7.7.0" + resolved "https://registry.yarnpkg.com/@babel/helper-wrap-function/-/helper-wrap-function-7.7.0.tgz#15af3d3e98f8417a60554acbb6c14e75e0b33b74" + integrity sha512-sd4QjeMgQqzshSjecZjOp8uKfUtnpmCyQhKQrVJBBgeHAB/0FPi33h3AbVlVp07qQtMD4QgYSzaMI7VwncNK/w== + dependencies: + "@babel/helper-function-name" "^7.7.0" + "@babel/template" "^7.7.0" + "@babel/traverse" "^7.7.0" + "@babel/types" "^7.7.0" + +"@babel/helpers@^7.7.0": + version "7.7.0" + resolved "https://registry.yarnpkg.com/@babel/helpers/-/helpers-7.7.0.tgz#359bb5ac3b4726f7c1fde0ec75f64b3f4275d60b" + integrity sha512-VnNwL4YOhbejHb7x/b5F39Zdg5vIQpUUNzJwx0ww1EcVRt41bbGRZWhAURrfY32T5zTT3qwNOQFWpn+P0i0a2g== + dependencies: + "@babel/template" "^7.7.0" + "@babel/traverse" "^7.7.0" + "@babel/types" "^7.7.0" "@babel/highlight@^7.0.0": version "7.5.0" @@ -247,32 +253,32 @@ esutils "^2.0.2" js-tokens "^4.0.0" -"@babel/parser@^7.0.0", "@babel/parser@^7.1.0", "@babel/parser@^7.4.3", "@babel/parser@^7.6.0": - version "7.6.0" - resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.6.0.tgz#3e05d0647432a8326cb28d0de03895ae5a57f39b" - integrity sha512-+o2q111WEx4srBs7L9eJmcwi655eD8sXniLqMB93TBK9GrNzGrxDWSjiqz2hLU0Ha8MTXFIP0yd9fNdP+m43ZQ== +"@babel/parser@^7.0.0", "@babel/parser@^7.1.0", "@babel/parser@^7.4.3", "@babel/parser@^7.7.0", "@babel/parser@^7.7.2": + version "7.7.2" + resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.7.2.tgz#ea8334dc77416bfd9473eb470fd00d8245b3943b" + integrity sha512-DDaR5e0g4ZTb9aP7cpSZLkACEBdoLGwJDWgHtBhrGX7Q1RjhdoMOfexICj5cqTAtpowjGQWfcvfnQG7G2kAB5w== -"@babel/plugin-proposal-async-generator-functions@^7.2.0": - version "7.2.0" - resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-async-generator-functions/-/plugin-proposal-async-generator-functions-7.2.0.tgz#b289b306669dce4ad20b0252889a15768c9d417e" - integrity sha512-+Dfo/SCQqrwx48ptLVGLdE39YtWRuKc/Y9I5Fy0P1DDBB9lsAHpjcEJQt+4IifuSOSTLBKJObJqMvaO1pIE8LQ== +"@babel/plugin-proposal-async-generator-functions@^7.7.0": + version "7.7.0" + resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-async-generator-functions/-/plugin-proposal-async-generator-functions-7.7.0.tgz#83ef2d6044496b4c15d8b4904e2219e6dccc6971" + integrity sha512-ot/EZVvf3mXtZq0Pd0+tSOfGWMizqmOohXmNZg6LNFjHOV+wOPv7BvVYh8oPR8LhpIP3ye8nNooKL50YRWxpYA== dependencies: "@babel/helper-plugin-utils" "^7.0.0" - "@babel/helper-remap-async-to-generator" "^7.1.0" + "@babel/helper-remap-async-to-generator" "^7.7.0" "@babel/plugin-syntax-async-generators" "^7.2.0" -"@babel/plugin-proposal-class-properties@^7.5.5": - version "7.5.5" - resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-class-properties/-/plugin-proposal-class-properties-7.5.5.tgz#a974cfae1e37c3110e71f3c6a2e48b8e71958cd4" - integrity sha512-AF79FsnWFxjlaosgdi421vmYG6/jg79bVD0dpD44QdgobzHKuLZ6S3vl8la9qIeSwGi8i1fS0O1mfuDAAdo1/A== +"@babel/plugin-proposal-class-properties@^7.7.0": + version "7.7.0" + resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-class-properties/-/plugin-proposal-class-properties-7.7.0.tgz#ac54e728ecf81d90e8f4d2a9c05a890457107917" + integrity sha512-tufDcFA1Vj+eWvwHN+jvMN6QsV5o+vUlytNKrbMiCeDL0F2j92RURzUsUMWE5EJkLyWxjdUslCsMQa9FWth16A== dependencies: - "@babel/helper-create-class-features-plugin" "^7.5.5" + "@babel/helper-create-class-features-plugin" "^7.7.0" "@babel/helper-plugin-utils" "^7.0.0" -"@babel/plugin-proposal-dynamic-import@^7.5.0": - version "7.5.0" - resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-dynamic-import/-/plugin-proposal-dynamic-import-7.5.0.tgz#e532202db4838723691b10a67b8ce509e397c506" - integrity sha512-x/iMjggsKTFHYC6g11PL7Qy58IK8H5zqfm9e6hu4z1iH2IRyAp9u9dL80zA6R76yFovETFLKz2VJIC2iIPBuFw== +"@babel/plugin-proposal-dynamic-import@^7.7.0": + version "7.7.0" + resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-dynamic-import/-/plugin-proposal-dynamic-import-7.7.0.tgz#dc02a8bad8d653fb59daf085516fa416edd2aa7f" + integrity sha512-7poL3Xi+QFPC7sGAzEIbXUyYzGJwbc2+gSD0AkiC5k52kH2cqHdqxm5hNFfLW3cRSTcx9bN0Fl7/6zWcLLnKAQ== dependencies: "@babel/helper-plugin-utils" "^7.0.0" "@babel/plugin-syntax-dynamic-import" "^7.2.0" @@ -309,10 +315,10 @@ "@babel/helper-plugin-utils" "^7.0.0" "@babel/plugin-syntax-numeric-separator" "^7.2.0" -"@babel/plugin-proposal-object-rest-spread@^7.5.5": - version "7.5.5" - resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-object-rest-spread/-/plugin-proposal-object-rest-spread-7.5.5.tgz#61939744f71ba76a3ae46b5eea18a54c16d22e58" - integrity sha512-F2DxJJSQ7f64FyTVl5cw/9MWn6naXGdk3Q3UhDbFEEHv+EilCPoeRD3Zh/Utx1CJz4uyKlQ4uH+bJPbEhMV7Zw== +"@babel/plugin-proposal-object-rest-spread@^7.6.2": + version "7.6.2" + resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-object-rest-spread/-/plugin-proposal-object-rest-spread-7.6.2.tgz#8ffccc8f3a6545e9f78988b6bf4fe881b88e8096" + integrity sha512-LDBXlmADCsMZV1Y9OQwMc0MyGZ8Ta/zlD9N67BfQT8uYwkRswiu2hU6nJKrjrt/58aH/vqfQlR/9yId/7A2gWw== dependencies: "@babel/helper-plugin-utils" "^7.0.0" "@babel/plugin-syntax-object-rest-spread" "^7.2.0" @@ -333,14 +339,13 @@ "@babel/helper-plugin-utils" "^7.0.0" "@babel/plugin-syntax-optional-chaining" "^7.2.0" -"@babel/plugin-proposal-unicode-property-regex@^7.4.4": - version "7.4.4" - resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-unicode-property-regex/-/plugin-proposal-unicode-property-regex-7.4.4.tgz#501ffd9826c0b91da22690720722ac7cb1ca9c78" - integrity sha512-j1NwnOqMG9mFUOH58JTFsA/+ZYzQLUZ/drqWUqxCYLGeu2JFZL8YrNC9hBxKmWtAuOCHPcRpgv7fhap09Fb4kA== +"@babel/plugin-proposal-unicode-property-regex@^7.7.0": + version "7.7.0" + resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-unicode-property-regex/-/plugin-proposal-unicode-property-regex-7.7.0.tgz#549fe1717a1bd0a2a7e63163841cb37e78179d5d" + integrity sha512-mk34H+hp7kRBWJOOAR0ZMGCydgKMD4iN9TpDRp3IIcbunltxEY89XSimc6WbtSLCDrwcdy/EEw7h5CFCzxTchw== dependencies: + "@babel/helper-create-regexp-features-plugin" "^7.7.0" "@babel/helper-plugin-utils" "^7.0.0" - "@babel/helper-regex" "^7.4.4" - regexpu-core "^4.5.4" "@babel/plugin-syntax-async-generators@^7.2.0": version "7.2.0" @@ -412,6 +417,13 @@ dependencies: "@babel/helper-plugin-utils" "^7.0.0" +"@babel/plugin-syntax-top-level-await@^7.7.0": + version "7.7.0" + resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-top-level-await/-/plugin-syntax-top-level-await-7.7.0.tgz#f5699549f50bbe8d12b1843a4e82f0a37bb65f4d" + integrity sha512-hi8FUNiFIY1fnUI2n1ViB1DR0R4QeK4iHcTlW6aJkrPoTdb8Rf1EMQ6GT3f67DDkYyWgew9DFoOZ6gOoEsdzTA== + dependencies: + "@babel/helper-plugin-utils" "^7.0.0" + "@babel/plugin-transform-arrow-functions@^7.2.0": version "7.2.0" resolved "https://registry.yarnpkg.com/@babel/plugin-transform-arrow-functions/-/plugin-transform-arrow-functions-7.2.0.tgz#9aeafbe4d6ffc6563bf8f8372091628f00779550" @@ -419,14 +431,14 @@ dependencies: "@babel/helper-plugin-utils" "^7.0.0" -"@babel/plugin-transform-async-to-generator@^7.5.0": - version "7.5.0" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-async-to-generator/-/plugin-transform-async-to-generator-7.5.0.tgz#89a3848a0166623b5bc481164b5936ab947e887e" - integrity sha512-mqvkzwIGkq0bEF1zLRRiTdjfomZJDV33AH3oQzHVGkI2VzEmXLpKKOBvEVaFZBJdN0XTyH38s9j/Kiqr68dggg== +"@babel/plugin-transform-async-to-generator@^7.7.0": + version "7.7.0" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-async-to-generator/-/plugin-transform-async-to-generator-7.7.0.tgz#e2b84f11952cf5913fe3438b7d2585042772f492" + integrity sha512-vLI2EFLVvRBL3d8roAMqtVY0Bm9C1QzLkdS57hiKrjUBSqsQYrBsMCeOg/0KK7B0eK9V71J5mWcha9yyoI2tZw== dependencies: - "@babel/helper-module-imports" "^7.0.0" + "@babel/helper-module-imports" "^7.7.0" "@babel/helper-plugin-utils" "^7.0.0" - "@babel/helper-remap-async-to-generator" "^7.1.0" + "@babel/helper-remap-async-to-generator" "^7.7.0" "@babel/plugin-transform-block-scoped-functions@^7.2.0": version "7.2.0" @@ -435,26 +447,26 @@ dependencies: "@babel/helper-plugin-utils" "^7.0.0" -"@babel/plugin-transform-block-scoping@^7.6.0": - version "7.6.0" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-block-scoping/-/plugin-transform-block-scoping-7.6.0.tgz#c49e21228c4bbd4068a35667e6d951c75439b1dc" - integrity sha512-tIt4E23+kw6TgL/edACZwP1OUKrjOTyMrFMLoT5IOFrfMRabCgekjqFd5o6PaAMildBu46oFkekIdMuGkkPEpA== +"@babel/plugin-transform-block-scoping@^7.6.3": + version "7.6.3" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-block-scoping/-/plugin-transform-block-scoping-7.6.3.tgz#6e854e51fbbaa84351b15d4ddafe342f3a5d542a" + integrity sha512-7hvrg75dubcO3ZI2rjYTzUrEuh1E9IyDEhhB6qfcooxhDA33xx2MasuLVgdxzcP6R/lipAC6n9ub9maNW6RKdw== dependencies: "@babel/helper-plugin-utils" "^7.0.0" lodash "^4.17.13" -"@babel/plugin-transform-classes@^7.5.5": - version "7.5.5" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-classes/-/plugin-transform-classes-7.5.5.tgz#d094299d9bd680a14a2a0edae38305ad60fb4de9" - integrity sha512-U2htCNK/6e9K7jGyJ++1p5XRU+LJjrwtoiVn9SzRlDT2KubcZ11OOwy3s24TjHxPgxNwonCYP7U2K51uVYCMDg== +"@babel/plugin-transform-classes@^7.7.0": + version "7.7.0" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-classes/-/plugin-transform-classes-7.7.0.tgz#b411ecc1b8822d24b81e5d184f24149136eddd4a" + integrity sha512-/b3cKIZwGeUesZheU9jNYcwrEA7f/Bo4IdPmvp7oHgvks2majB5BoT5byAql44fiNQYOPzhk2w8DbgfuafkMoA== dependencies: - "@babel/helper-annotate-as-pure" "^7.0.0" - "@babel/helper-define-map" "^7.5.5" - "@babel/helper-function-name" "^7.1.0" - "@babel/helper-optimise-call-expression" "^7.0.0" + "@babel/helper-annotate-as-pure" "^7.7.0" + "@babel/helper-define-map" "^7.7.0" + "@babel/helper-function-name" "^7.7.0" + "@babel/helper-optimise-call-expression" "^7.7.0" "@babel/helper-plugin-utils" "^7.0.0" - "@babel/helper-replace-supers" "^7.5.5" - "@babel/helper-split-export-declaration" "^7.4.4" + "@babel/helper-replace-supers" "^7.7.0" + "@babel/helper-split-export-declaration" "^7.7.0" globals "^11.1.0" "@babel/plugin-transform-computed-properties@^7.2.0": @@ -471,14 +483,13 @@ dependencies: "@babel/helper-plugin-utils" "^7.0.0" -"@babel/plugin-transform-dotall-regex@^7.4.4": - version "7.4.4" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-dotall-regex/-/plugin-transform-dotall-regex-7.4.4.tgz#361a148bc951444312c69446d76ed1ea8e4450c3" - integrity sha512-P05YEhRc2h53lZDjRPk/OektxCVevFzZs2Gfjd545Wde3k+yFDbXORgl2e0xpbq8mLcKJ7Idss4fAg0zORN/zg== +"@babel/plugin-transform-dotall-regex@^7.7.0": + version "7.7.0" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-dotall-regex/-/plugin-transform-dotall-regex-7.7.0.tgz#c5c9ecacab3a5e0c11db6981610f0c32fd698b3b" + integrity sha512-3QQlF7hSBnSuM1hQ0pS3pmAbWLax/uGNCbPBND9y+oJ4Y776jsyujG2k0Sn2Aj2a0QwVOiOFL5QVPA7spjvzSA== dependencies: + "@babel/helper-create-regexp-features-plugin" "^7.7.0" "@babel/helper-plugin-utils" "^7.0.0" - "@babel/helper-regex" "^7.4.4" - regexpu-core "^4.5.4" "@babel/plugin-transform-duplicate-keys@^7.5.0": version "7.5.0" @@ -510,12 +521,12 @@ dependencies: "@babel/helper-plugin-utils" "^7.0.0" -"@babel/plugin-transform-function-name@^7.4.4": - version "7.4.4" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-function-name/-/plugin-transform-function-name-7.4.4.tgz#e1436116abb0610c2259094848754ac5230922ad" - integrity sha512-iU9pv7U+2jC9ANQkKeNF6DrPy4GBa4NWQtl6dHB4Pb3izX2JOEvDTFarlNsBj/63ZEzNNIAMs3Qw4fNCcSOXJA== +"@babel/plugin-transform-function-name@^7.7.0": + version "7.7.0" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-function-name/-/plugin-transform-function-name-7.7.0.tgz#0fa786f1eef52e3b7d4fc02e54b2129de8a04c2a" + integrity sha512-P5HKu0d9+CzZxP5jcrWdpe7ZlFDe24bmqP6a6X8BHEBl/eizAsY8K6LX8LASZL0Jxdjm5eEfzp+FIrxCm/p8bA== dependencies: - "@babel/helper-function-name" "^7.1.0" + "@babel/helper-function-name" "^7.7.0" "@babel/helper-plugin-utils" "^7.0.0" "@babel/plugin-transform-literals@^7.2.0": @@ -541,39 +552,39 @@ "@babel/helper-plugin-utils" "^7.0.0" babel-plugin-dynamic-import-node "^2.3.0" -"@babel/plugin-transform-modules-commonjs@^7.6.0": - version "7.6.0" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-modules-commonjs/-/plugin-transform-modules-commonjs-7.6.0.tgz#39dfe957de4420445f1fcf88b68a2e4aa4515486" - integrity sha512-Ma93Ix95PNSEngqomy5LSBMAQvYKVe3dy+JlVJSHEXZR5ASL9lQBedMiCyVtmTLraIDVRE3ZjTZvmXXD2Ozw3g== +"@babel/plugin-transform-modules-commonjs@^7.7.0": + version "7.7.0" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-modules-commonjs/-/plugin-transform-modules-commonjs-7.7.0.tgz#3e5ffb4fd8c947feede69cbe24c9554ab4113fe3" + integrity sha512-KEMyWNNWnjOom8vR/1+d+Ocz/mILZG/eyHHO06OuBQ2aNhxT62fr4y6fGOplRx+CxCSp3IFwesL8WdINfY/3kg== dependencies: - "@babel/helper-module-transforms" "^7.4.4" + "@babel/helper-module-transforms" "^7.7.0" "@babel/helper-plugin-utils" "^7.0.0" - "@babel/helper-simple-access" "^7.1.0" + "@babel/helper-simple-access" "^7.7.0" babel-plugin-dynamic-import-node "^2.3.0" -"@babel/plugin-transform-modules-systemjs@^7.5.0": - version "7.5.0" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-modules-systemjs/-/plugin-transform-modules-systemjs-7.5.0.tgz#e75266a13ef94202db2a0620977756f51d52d249" - integrity sha512-Q2m56tyoQWmuNGxEtUyeEkm6qJYFqs4c+XyXH5RAuYxObRNz9Zgj/1g2GMnjYp2EUyEy7YTrxliGCXzecl/vJg== +"@babel/plugin-transform-modules-systemjs@^7.7.0": + version "7.7.0" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-modules-systemjs/-/plugin-transform-modules-systemjs-7.7.0.tgz#9baf471213af9761c1617bb12fd278e629041417" + integrity sha512-ZAuFgYjJzDNv77AjXRqzQGlQl4HdUM6j296ee4fwKVZfhDR9LAGxfvXjBkb06gNETPnN0sLqRm9Gxg4wZH6dXg== dependencies: - "@babel/helper-hoist-variables" "^7.4.4" + "@babel/helper-hoist-variables" "^7.7.0" "@babel/helper-plugin-utils" "^7.0.0" babel-plugin-dynamic-import-node "^2.3.0" -"@babel/plugin-transform-modules-umd@^7.2.0": - version "7.2.0" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-modules-umd/-/plugin-transform-modules-umd-7.2.0.tgz#7678ce75169f0877b8eb2235538c074268dd01ae" - integrity sha512-BV3bw6MyUH1iIsGhXlOK6sXhmSarZjtJ/vMiD9dNmpY8QXFFQTj+6v92pcfy1iqa8DeAfJFwoxcrS/TUZda6sw== +"@babel/plugin-transform-modules-umd@^7.7.0": + version "7.7.0" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-modules-umd/-/plugin-transform-modules-umd-7.7.0.tgz#d62c7da16670908e1d8c68ca0b5d4c0097b69966" + integrity sha512-u7eBA03zmUswQ9LQ7Qw0/ieC1pcAkbp5OQatbWUzY1PaBccvuJXUkYzoN1g7cqp7dbTu6Dp9bXyalBvD04AANA== dependencies: - "@babel/helper-module-transforms" "^7.1.0" + "@babel/helper-module-transforms" "^7.7.0" "@babel/helper-plugin-utils" "^7.0.0" -"@babel/plugin-transform-named-capturing-groups-regex@^7.6.0": - version "7.6.0" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-named-capturing-groups-regex/-/plugin-transform-named-capturing-groups-regex-7.6.0.tgz#1e6e663097813bb4f53d42df0750cf28ad3bb3f1" - integrity sha512-jem7uytlmrRl3iCAuQyw8BpB4c4LWvSpvIeXKpMb+7j84lkx4m4mYr5ErAcmN5KM7B6BqrAvRGjBIbbzqCczew== +"@babel/plugin-transform-named-capturing-groups-regex@^7.7.0": + version "7.7.0" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-named-capturing-groups-regex/-/plugin-transform-named-capturing-groups-regex-7.7.0.tgz#358e6fd869b9a4d8f5cbc79e4ed4fc340e60dcaf" + integrity sha512-+SicSJoKouPctL+j1pqktRVCgy+xAch1hWWTMy13j0IflnyNjaoskj+DwRQFimHbLqO3sq2oN2CXMvXq3Bgapg== dependencies: - regexp-tree "^0.1.13" + "@babel/helper-create-regexp-features-plugin" "^7.7.0" "@babel/plugin-transform-new-target@^7.4.4": version "7.4.4" @@ -606,10 +617,10 @@ dependencies: "@babel/helper-plugin-utils" "^7.0.0" -"@babel/plugin-transform-regenerator@^7.4.5": - version "7.4.5" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-regenerator/-/plugin-transform-regenerator-7.4.5.tgz#629dc82512c55cee01341fb27bdfcb210354680f" - integrity sha512-gBKRh5qAaCWntnd09S8QC7r3auLCqq5DI6O0DlfoyDjslSBVqBibrMdsqO+Uhmx3+BlOmE/Kw1HFxmGbv0N9dA== +"@babel/plugin-transform-regenerator@^7.7.0": + version "7.7.0" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-regenerator/-/plugin-transform-regenerator-7.7.0.tgz#f1b20b535e7716b622c99e989259d7dd942dd9cc" + integrity sha512-AXmvnC+0wuj/cFkkS/HFHIojxH3ffSXE+ttulrqWjZZRaUOonfJc60e1wSNT4rV8tIunvu/R3wCp71/tLAa9xg== dependencies: regenerator-transform "^0.14.0" @@ -620,10 +631,10 @@ dependencies: "@babel/helper-plugin-utils" "^7.0.0" -"@babel/plugin-transform-runtime@^7.6.0": - version "7.6.0" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-runtime/-/plugin-transform-runtime-7.6.0.tgz#85a3cce402b28586138e368fce20ab3019b9713e" - integrity sha512-Da8tMf7uClzwUm/pnJ1S93m/aRXmoYNDD7TkHua8xBDdaAs54uZpTWvEt6NGwmoVMb9mZbntfTqmG2oSzN/7Vg== +"@babel/plugin-transform-runtime@^7.6.2": + version "7.6.2" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-runtime/-/plugin-transform-runtime-7.6.2.tgz#2669f67c1fae0ae8d8bf696e4263ad52cb98b6f8" + integrity sha512-cqULw/QB4yl73cS5Y0TZlQSjDvNkzDbu0FurTZyHlJpWE5T3PCMdnyV+xXoH1opr1ldyHODe3QAX3OMAii5NxA== dependencies: "@babel/helper-module-imports" "^7.0.0" "@babel/helper-plugin-utils" "^7.0.0" @@ -637,10 +648,10 @@ dependencies: "@babel/helper-plugin-utils" "^7.0.0" -"@babel/plugin-transform-spread@^7.2.0": - version "7.2.2" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-spread/-/plugin-transform-spread-7.2.2.tgz#3103a9abe22f742b6d406ecd3cd49b774919b406" - integrity sha512-KWfky/58vubwtS0hLqEnrWJjsMGaOeSBn90Ezn5Jeg9Z8KKHmELbP1yGylMlm5N6TPKeY9A2+UaSYLdxahg01w== +"@babel/plugin-transform-spread@^7.6.2": + version "7.6.2" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-spread/-/plugin-transform-spread-7.6.2.tgz#fc77cf798b24b10c46e1b51b1b88c2bf661bb8dd" + integrity sha512-DpSvPFryKdK1x+EDJYCy28nmAaIMdxmhot62jAXF/o99iA33Zj2Lmcp3vDmz+MUh0LNYVPvfj5iC3feb3/+PFg== dependencies: "@babel/helper-plugin-utils" "^7.0.0" @@ -667,65 +678,65 @@ dependencies: "@babel/helper-plugin-utils" "^7.0.0" -"@babel/plugin-transform-unicode-regex@^7.4.4": - version "7.4.4" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-unicode-regex/-/plugin-transform-unicode-regex-7.4.4.tgz#ab4634bb4f14d36728bf5978322b35587787970f" - integrity sha512-il+/XdNw01i93+M9J9u4T7/e/Ue/vWfNZE4IRUQjplu2Mqb/AFTDimkw2tdEdSH50wuQXZAbXSql0UphQke+vA== +"@babel/plugin-transform-unicode-regex@^7.7.0": + version "7.7.0" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-unicode-regex/-/plugin-transform-unicode-regex-7.7.0.tgz#743d9bcc44080e3cc7d49259a066efa30f9187a3" + integrity sha512-RrThb0gdrNwFAqEAAx9OWgtx6ICK69x7i9tCnMdVrxQwSDp/Abu9DXFU5Hh16VP33Rmxh04+NGW28NsIkFvFKA== dependencies: + "@babel/helper-create-regexp-features-plugin" "^7.7.0" "@babel/helper-plugin-utils" "^7.0.0" - "@babel/helper-regex" "^7.4.4" - regexpu-core "^4.5.4" -"@babel/preset-env@^7.6.0": - version "7.6.0" - resolved "https://registry.yarnpkg.com/@babel/preset-env/-/preset-env-7.6.0.tgz#aae4141c506100bb2bfaa4ac2a5c12b395619e50" - integrity sha512-1efzxFv/TcPsNXlRhMzRnkBFMeIqBBgzwmZwlFDw5Ubj0AGLeufxugirwZmkkX/ayi3owsSqoQ4fw8LkfK9SYg== +"@babel/preset-env@^7.7.1": + version "7.7.1" + resolved "https://registry.yarnpkg.com/@babel/preset-env/-/preset-env-7.7.1.tgz#04a2ff53552c5885cf1083e291c8dd5490f744bb" + integrity sha512-/93SWhi3PxcVTDpSqC+Dp4YxUu3qZ4m7I76k0w73wYfn7bGVuRIO4QUz95aJksbS+AD1/mT1Ie7rbkT0wSplaA== dependencies: - "@babel/helper-module-imports" "^7.0.0" + "@babel/helper-module-imports" "^7.7.0" "@babel/helper-plugin-utils" "^7.0.0" - "@babel/plugin-proposal-async-generator-functions" "^7.2.0" - "@babel/plugin-proposal-dynamic-import" "^7.5.0" + "@babel/plugin-proposal-async-generator-functions" "^7.7.0" + "@babel/plugin-proposal-dynamic-import" "^7.7.0" "@babel/plugin-proposal-json-strings" "^7.2.0" - "@babel/plugin-proposal-object-rest-spread" "^7.5.5" + "@babel/plugin-proposal-object-rest-spread" "^7.6.2" "@babel/plugin-proposal-optional-catch-binding" "^7.2.0" - "@babel/plugin-proposal-unicode-property-regex" "^7.4.4" + "@babel/plugin-proposal-unicode-property-regex" "^7.7.0" "@babel/plugin-syntax-async-generators" "^7.2.0" "@babel/plugin-syntax-dynamic-import" "^7.2.0" "@babel/plugin-syntax-json-strings" "^7.2.0" "@babel/plugin-syntax-object-rest-spread" "^7.2.0" "@babel/plugin-syntax-optional-catch-binding" "^7.2.0" + "@babel/plugin-syntax-top-level-await" "^7.7.0" "@babel/plugin-transform-arrow-functions" "^7.2.0" - "@babel/plugin-transform-async-to-generator" "^7.5.0" + "@babel/plugin-transform-async-to-generator" "^7.7.0" "@babel/plugin-transform-block-scoped-functions" "^7.2.0" - "@babel/plugin-transform-block-scoping" "^7.6.0" - "@babel/plugin-transform-classes" "^7.5.5" + "@babel/plugin-transform-block-scoping" "^7.6.3" + "@babel/plugin-transform-classes" "^7.7.0" "@babel/plugin-transform-computed-properties" "^7.2.0" "@babel/plugin-transform-destructuring" "^7.6.0" - "@babel/plugin-transform-dotall-regex" "^7.4.4" + "@babel/plugin-transform-dotall-regex" "^7.7.0" "@babel/plugin-transform-duplicate-keys" "^7.5.0" "@babel/plugin-transform-exponentiation-operator" "^7.2.0" "@babel/plugin-transform-for-of" "^7.4.4" - "@babel/plugin-transform-function-name" "^7.4.4" + "@babel/plugin-transform-function-name" "^7.7.0" "@babel/plugin-transform-literals" "^7.2.0" "@babel/plugin-transform-member-expression-literals" "^7.2.0" "@babel/plugin-transform-modules-amd" "^7.5.0" - "@babel/plugin-transform-modules-commonjs" "^7.6.0" - "@babel/plugin-transform-modules-systemjs" "^7.5.0" - "@babel/plugin-transform-modules-umd" "^7.2.0" - "@babel/plugin-transform-named-capturing-groups-regex" "^7.6.0" + "@babel/plugin-transform-modules-commonjs" "^7.7.0" + "@babel/plugin-transform-modules-systemjs" "^7.7.0" + "@babel/plugin-transform-modules-umd" "^7.7.0" + "@babel/plugin-transform-named-capturing-groups-regex" "^7.7.0" "@babel/plugin-transform-new-target" "^7.4.4" "@babel/plugin-transform-object-super" "^7.5.5" "@babel/plugin-transform-parameters" "^7.4.4" "@babel/plugin-transform-property-literals" "^7.2.0" - "@babel/plugin-transform-regenerator" "^7.4.5" + "@babel/plugin-transform-regenerator" "^7.7.0" "@babel/plugin-transform-reserved-words" "^7.2.0" "@babel/plugin-transform-shorthand-properties" "^7.2.0" - "@babel/plugin-transform-spread" "^7.2.0" + "@babel/plugin-transform-spread" "^7.6.2" "@babel/plugin-transform-sticky-regex" "^7.2.0" "@babel/plugin-transform-template-literals" "^7.4.4" "@babel/plugin-transform-typeof-symbol" "^7.2.0" - "@babel/plugin-transform-unicode-regex" "^7.4.4" - "@babel/types" "^7.6.0" + "@babel/plugin-transform-unicode-regex" "^7.7.0" + "@babel/types" "^7.7.1" browserslist "^4.6.0" core-js-compat "^3.1.1" invariant "^2.2.2" @@ -740,52 +751,52 @@ "@babel/helper-plugin-utils" "^7.0.0" "@babel/plugin-transform-flow-strip-types" "^7.0.0" -"@babel/register@^7.6.0": - version "7.6.0" - resolved "https://registry.yarnpkg.com/@babel/register/-/register-7.6.0.tgz#76b6f466714680f4becafd45beeb2a7b87431abf" - integrity sha512-78BomdN8el+x/nkup9KwtjJXuptW5oXMFmP11WoM2VJBjxrKv4grC3qjpLL8RGGUYUGsm57xnjYFM2uom+jWUQ== +"@babel/register@^7.7.0": + version "7.7.0" + resolved "https://registry.yarnpkg.com/@babel/register/-/register-7.7.0.tgz#4e23ecf840296ef79c605baaa5c89e1a2426314b" + integrity sha512-HV3GJzTvSoyOMWGYn2TAh6uL6g+gqKTgEZ99Q3+X9UURT1VPT/WcU46R61XftIc5rXytcOHZ4Z0doDlsjPomIg== dependencies: find-cache-dir "^2.0.0" lodash "^4.17.13" - mkdirp "^0.5.1" + make-dir "^2.1.0" pirates "^4.0.0" - source-map-support "^0.5.9" + source-map-support "^0.5.16" -"@babel/runtime@^7.6.0": - version "7.6.0" - resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.6.0.tgz#4fc1d642a9fd0299754e8b5de62c631cf5568205" - integrity sha512-89eSBLJsxNxOERC0Op4vd+0Bqm6wRMqMbFtV3i0/fbaWw/mJ8Q3eBvgX0G4SyrOOLCtbu98HspF8o09MRT+KzQ== +"@babel/runtime@^7.7.2": + version "7.7.2" + resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.7.2.tgz#111a78002a5c25fc8e3361bedc9529c696b85a6a" + integrity sha512-JONRbXbTXc9WQE2mAZd1p0Z3DZ/6vaQIkgYMSTP3KjRCyd7rCZCcfhCyX+YjwcKxcZ82UrxbRD358bpExNgrjw== dependencies: regenerator-runtime "^0.13.2" -"@babel/template@^7.1.0", "@babel/template@^7.4.0", "@babel/template@^7.4.4", "@babel/template@^7.6.0": - version "7.6.0" - resolved "https://registry.yarnpkg.com/@babel/template/-/template-7.6.0.tgz#7f0159c7f5012230dad64cca42ec9bdb5c9536e6" - integrity sha512-5AEH2EXD8euCk446b7edmgFdub/qfH1SN6Nii3+fyXP807QRx9Q73A2N5hNwRRslC2H9sNzaFhsPubkS4L8oNQ== +"@babel/template@^7.4.0", "@babel/template@^7.7.0": + version "7.7.0" + resolved "https://registry.yarnpkg.com/@babel/template/-/template-7.7.0.tgz#4fadc1b8e734d97f56de39c77de76f2562e597d0" + integrity sha512-OKcwSYOW1mhWbnTBgQY5lvg1Fxg+VyfQGjcBduZFljfc044J5iDlnDSfhQ867O17XHiSCxYHUxHg2b7ryitbUQ== dependencies: "@babel/code-frame" "^7.0.0" - "@babel/parser" "^7.6.0" - "@babel/types" "^7.6.0" + "@babel/parser" "^7.7.0" + "@babel/types" "^7.7.0" -"@babel/traverse@^7.0.0", "@babel/traverse@^7.1.0", "@babel/traverse@^7.4.3", "@babel/traverse@^7.4.4", "@babel/traverse@^7.5.5", "@babel/traverse@^7.6.0": - version "7.6.0" - resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.6.0.tgz#389391d510f79be7ce2ddd6717be66d3fed4b516" - integrity sha512-93t52SaOBgml/xY74lsmt7xOR4ufYvhb5c5qiM6lu4J/dWGMAfAh6eKw4PjLes6DI6nQgearoxnFJk60YchpvQ== +"@babel/traverse@^7.0.0", "@babel/traverse@^7.1.0", "@babel/traverse@^7.4.3", "@babel/traverse@^7.4.4", "@babel/traverse@^7.7.0", "@babel/traverse@^7.7.2": + version "7.7.2" + resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.7.2.tgz#ef0a65e07a2f3c550967366b3d9b62a2dcbeae09" + integrity sha512-TM01cXib2+rgIZrGJOLaHV/iZUAxf4A0dt5auY6KNZ+cm6aschuJGqKJM3ROTt3raPUdIDk9siAufIFEleRwtw== dependencies: "@babel/code-frame" "^7.5.5" - "@babel/generator" "^7.6.0" - "@babel/helper-function-name" "^7.1.0" - "@babel/helper-split-export-declaration" "^7.4.4" - "@babel/parser" "^7.6.0" - "@babel/types" "^7.6.0" + "@babel/generator" "^7.7.2" + "@babel/helper-function-name" "^7.7.0" + "@babel/helper-split-export-declaration" "^7.7.0" + "@babel/parser" "^7.7.2" + "@babel/types" "^7.7.2" debug "^4.1.0" globals "^11.1.0" lodash "^4.17.13" -"@babel/types@^7.0.0", "@babel/types@^7.2.0", "@babel/types@^7.3.0", "@babel/types@^7.4.0", "@babel/types@^7.4.4", "@babel/types@^7.5.5", "@babel/types@^7.6.0": - version "7.6.1" - resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.6.1.tgz#53abf3308add3ac2a2884d539151c57c4b3ac648" - integrity sha512-X7gdiuaCmA0uRjCmRtYJNAVCc/q+5xSgsfKJHqMN4iNLILX39677fJE1O40arPMh0TTtS9ItH67yre6c7k6t0g== +"@babel/types@^7.0.0", "@babel/types@^7.3.0", "@babel/types@^7.4.0", "@babel/types@^7.4.4", "@babel/types@^7.7.0", "@babel/types@^7.7.1", "@babel/types@^7.7.2": + version "7.7.2" + resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.7.2.tgz#550b82e5571dcd174af576e23f0adba7ffc683f7" + integrity sha512-YTf6PXoh3+eZgRCBzzP25Bugd2ngmpQVrk7kXX0i5N9BO7TFBtIgZYs7WtxtOGs8e6A4ZI7ECkbBCEHeXocvOA== dependencies: esutils "^2.0.2" lodash "^4.17.13" @@ -3505,10 +3516,10 @@ conventional-recommended-bump@^5.0.0: meow "^4.0.0" q "^1.5.1" -convert-source-map@^1.1.0, convert-source-map@^1.4.0, convert-source-map@^1.5.0: - version "1.6.0" - resolved "https://registry.yarnpkg.com/convert-source-map/-/convert-source-map-1.6.0.tgz#51b537a8c43e0f04dec1993bffcdd504e758ac20" - integrity sha512-eFu7XigvxdZ1ETfbgPBohgyQ/Z++C0eEhTor0qRwBw9unw+L0/6V8wkSuGgzdThkiS5lSpdptOQPD8Ak40a+7A== +convert-source-map@^1.1.0, convert-source-map@^1.4.0, convert-source-map@^1.5.0, convert-source-map@^1.7.0: + version "1.7.0" + resolved "https://registry.yarnpkg.com/convert-source-map/-/convert-source-map-1.7.0.tgz#17a2cb882d7f77d3490585e2ce6c524424a3a442" + integrity sha512-4FJkXzKXEDB1snCFZlLP4gpC3JILicCpGbzG9f9G7tGqGCzETQ2hWPrcinA9oU4wtf2biUaEH5065UnMeR33oA== dependencies: safe-buffer "~5.1.1" @@ -6782,9 +6793,9 @@ json5@^1.0.1: minimist "^1.2.0" json5@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/json5/-/json5-2.1.0.tgz#e7a0c62c48285c628d20a10b85c89bb807c32850" - integrity sha512-8Mh9h6xViijj36g7Dxi+Y4S6hNGV96vcJZr/SrlHh1LR/pEn/8j/+qIBbs44YKl69Lrfctp4QD+AdWLTMqEZAQ== + version "2.1.1" + resolved "https://registry.yarnpkg.com/json5/-/json5-2.1.1.tgz#81b6cb04e9ba496f1c7005d07b4368a2638f90b6" + integrity sha512-l+3HXD0GEI3huGq1njuqtzYK8OYJyXMkOLtQ53pjWh89tvWS2h6l+1zMkYWqlb57+SiQodKZyvMEFb2X+KrFhQ== dependencies: minimist "^1.2.0" @@ -9175,17 +9186,12 @@ regex-not@^1.0.0, regex-not@^1.0.2: extend-shallow "^3.0.2" safe-regex "^1.1.0" -regexp-tree@^0.1.13: - version "0.1.13" - resolved "https://registry.yarnpkg.com/regexp-tree/-/regexp-tree-0.1.13.tgz#5b19ab9377edc68bc3679256840bb29afc158d7f" - integrity sha512-hwdV/GQY5F8ReLZWO+W1SRoN5YfpOKY6852+tBFcma72DKBIcHjPRIlIvQN35bCOljuAfP2G2iB0FC/w236mUw== - regexpp@^2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/regexpp/-/regexpp-2.0.1.tgz#8d19d31cf632482b589049f8281f93dbcba4d07f" integrity sha512-lv0M6+TkDVniA3aD1Eg0DVpfU/booSu7Eev3TDO/mZKHBfVjgCGTV4t4buppESEYDtkArYFOxTJWv6S5C+iaNw== -regexpu-core@^4.5.4: +regexpu-core@^4.6.0: version "4.6.0" resolved "https://registry.yarnpkg.com/regexpu-core/-/regexpu-core-4.6.0.tgz#2037c18b327cfce8a6fea2a4ec441f2432afb8b6" integrity sha512-YlVaefl8P5BnFYOITTNzDvan1ulLOiXJzCNZxduTIosN17b87h3bvG9yHMoHaRuo88H4mQ06Aodj5VtYGGGiTg== @@ -9754,10 +9760,10 @@ source-map-resolve@^0.5.0: source-map-url "^0.4.0" urix "^0.1.0" -source-map-support@^0.5.6, source-map-support@^0.5.9: - version "0.5.13" - resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.13.tgz#31b24a9c2e73c2de85066c0feb7d44767ed52932" - integrity sha512-SHSKFHadjVA5oR4PPqhtAVdcBWwRYVd6g6cAXnIbRiIwc2EhPrTuKUBdSLvlEKyIP3GCf89fltvcZiP9MMFA1w== +source-map-support@^0.5.16, source-map-support@^0.5.6: + version "0.5.16" + resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.16.tgz#0ae069e7fe3ba7538c64c98515e35339eac5a042" + integrity sha512-efyLRJDr68D9hBBNIPWFjhpFzURh+KJykQwvMyW5UiZzYwoF6l4YMMDIJJEyFWxWCqfyxLzz6tSfUFR+kXXsVQ== dependencies: buffer-from "^1.0.0" source-map "^0.6.0" @@ -10441,11 +10447,6 @@ trim-off-newlines@^1.0.0: resolved "https://registry.yarnpkg.com/trim-off-newlines/-/trim-off-newlines-1.0.1.tgz#9f9ba9d9efa8764c387698bcbfeb2c848f11adb3" integrity sha1-n5up2e+odkw4dpi8v+sshI8RrbM= -trim-right@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/trim-right/-/trim-right-1.0.1.tgz#cb2e1203067e0c8de1f614094b9fe45704ea6003" - integrity sha1-yy4SAwZ+DI3h9hQJS5/kVwTqYAM= - tslib@^1.9.0: version "1.10.0" resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.10.0.tgz#c3c19f95973fb0a62973fb09d90d961ee43e5c8a"