Compare commits

...

93 Commits

Author SHA1 Message Date
Nicolò Ribaudo
381b066bd0 v7.6.1 2019-09-06 22:50:54 +02:00
Matt Forster
15b63bc89e fix(types): correct typescript function headers (#10404)
Flow maybe types state;

> Maybe types accept the provided type as well as null or undefined. So ?number would mean number, null, or undefined.

So in this case, explicitly allow the type, null, or undefined in the
typescript definition.

Fixes #10403
2019-09-06 22:38:21 +02:00
Dword
fc8e14264c Remove process.exit(1) from babel-node (#9758)
Because it breaked graceful shutdown of the sub process.
2019-09-06 14:32:45 -04:00
Babel Bot
7e4f48139c Add v7.6.0 to CHANGELOG.md [skip ci] 2019-09-06 17:36:19 +00:00
Nicolò Ribaudo
cbd5a26e57 v7.6.0 2019-09-06 19:25:16 +02:00
Nicolò Ribaudo
42e5974fd4 Remove old uglify option
It's false by default
2019-09-06 19:24:15 +02:00
Nicolò Ribaudo
735abc0ed8 Update lerna
v3.16 includes https://github.com/lerna/lerna/pull/2185,
which fixes an issue we had in the v7.5 releases
2019-09-06 18:40:06 +02:00
Corey Farrell
aa7678f32a Remove core-js from @babel/register. (#9847)
This module doesn't use core-js at all.
2019-09-06 18:11:38 +02:00
Huáng Jùnliàng
b64cb9aaf1 fix: early return when instance is not iterable (#10396)
* fix: early return when instance is not iterable

* chore: update test fixtures

* fix: gaurd against arguments for old browsers
2019-09-06 18:09:57 +02:00
Huáng Jùnliàng
8da9d8b4b8 feat(errors): validate preset when filename is absent (#10181)
* feat(errors): validate preset when filename is absent

Closes #10154

* fix: test overrides for filename compulsory

* docs: rewrite validate error message

per https://github.com/babel/babel/pull/10181#discussion_r301607986

* polish error message
2019-09-06 18:09:19 +02:00
Tim McClure
3e4889d649 Class Private Static Accessors (#10217)
* Remove error for static private accessors

* Private static accessors strict

* Add loose mode support

* Move `value` decl for early return

* Reuse getter/setter template

* Reuse getter/setter templates

* Use `buildUndefinedNode` in accessor templates

* Extract `isAccessor` variable
2019-09-06 18:08:10 +02:00
Huáng Jùnliàng
da0af5fd99 V8intrinsic syntax plugin (#10148)
* feat: v8intrinsic syntax plugin

Implement V8 Intrinsic Syntax Extension. Here we check the execution branch inside the parseSubscript to make sure the V8IntrinsicIdentifier is immediately followed by a call expression.

* feat: disable combining placeholders and v8intrisic

per https://github.com/babel/babel/issues/10104#issuecomment-506950969

* test: add more error cases

* refactor: parse v8 intrinsic in parseExprAtom

This approach is identical to V8’s implementation. Move the test cases as the behaviour changes.

* fix: plugin-name typo

* test: add yield-expression test case

* feat: require startsExpr on modulo for v8intrinsic

* perf: skip eof and braceR check as they must return false

* Print V8IntrinsicIdentifier

* feat: add v8intrinsic to parser typings

* Add generated type helpers

* fix: incorrect type definition

* fix: allow V8IntrinsicIdentifier to be callee
2019-09-06 17:43:19 +02:00
Vivek Nayyar
b02e35c19a Fix parenthesis for nullish coalescing (#10269)
* ♻️ added condition to check for left and right of nullish coalescing operator and if any is a logical expression without a paren then throw an error

* 🐛 bugs fixed and test cases updated for babel parser

* ♻️ code comments added

* 🐛 spell error rectified

* ♻️ failing test updated

* 🐛 push tests after make build

* Skip nullish-coalescing flow precedence tests

They're now incorrect

* ♻️ error message updated, binop priority of other logical operators +1 from ?? and

* ♻️ increaed the binOp for in and instanceOf, added logic to print the brackets in an ?? && || expression, test cases added

* 🐛 failing test fixed and comments updated

* ♻️ new lines added between tests

* ♻️ basic tests for checking the binOp of instanceOf, in and relational operators to be equal added

* ♻️ new lines added in between tests
2019-09-06 17:35:44 +02:00
Nicolò Ribaudo
3e8a5c5e28 Use "validateLogs" for preset-env's debug fixtures (#10401)
* Add ability to ignore output to the test runner

* Use normal fixtures instead of custom debug-fixtures in preset-env
2019-09-06 17:32:20 +02:00
Bin Xin
8769903284 Add supports for polyfill computed methods (#10398) 2019-09-06 01:35:03 +02:00
Bin Xin
5c859b1117 Don't polyfill if evaluation is not confident (#10397) 2019-09-06 00:29:19 +02:00
Huáng Jùnliàng
2e7bea4a6a fix: transform name capturing regex once (#10395)
* fix: transform name capturing regex once

* refactor: early return when pattern contains only lookbehind

* chore: simplify test regex

* chore: run test on >=8.0.0
2019-09-05 17:35:57 +02:00
Bin Xin
29734b924a Don't allow instance properties transformation on namespace (#10372) 2019-09-05 10:32:57 -05:00
Huáng Jùnliàng
6813ee02d7 chore: update regexp-tree to version 0.1.13 (#10376) 2019-09-05 10:07:18 -05:00
Adam Ramberg
fcb77de901 [preset-env] Include / exclude module plugins properly (#10218)
* Include / exclude module plugins properly

* Use filter-items to excl / incl module plugins

* Move transform selection to getModulesPluginNames

* Remove unnecessary spread operator

Co-Authored-By: Nicolò Ribaudo <nicolo.ribaudo@gmail.com>

* Adjust tests to changes in #10218
2019-09-05 15:58:29 +02:00
Ajay Sagar
d05bd9edc8 Bumped chokidar dependency of babel-cli to 2.1.8 (#10394) 2019-09-04 21:33:31 -04:00
Nicolò Ribaudo
27ba292774 Silence remaining test warnings (#10392) 2019-09-04 22:56:47 +02:00
Tan Li Hau
a08e856804 fix typescript for babel-types (#10098)
* fix typescript for babel-types

* fix missing typescript/flow types for babel-types

* Add cloneNode to flow.js

* Add cloneNode to typescript.js
2019-09-04 15:35:19 +02:00
Shrey Banga
c0e3fa0081 Refactor trailing comma comment adjustment (#10380)
* Refactor trailing comment adjustment

Following up from https://github.com/babel/babel/pull/10369

- Unify the logic for adjusting trailing comments into a separate
  function
- Use it for all three cases, which fixes a bug for ObjectExpressions
  and CallExpressions
- Update tests to check for the fixed bug

* Fix tests

- Only modify trailingComments if necessary
- Update snapshots of a couple of affected tests

* Drop the underscore in adjustCommentsAfterTrailingComma_

* Handle ArrayPattern

* Handle ObjectPattern

* Handle import and export declarations

These have to be handled a bit differently, because the  node is visited after the  and before the declaration. So we intercept when we are going from the last specifier to the source node.

* Remove unnecessary check
2019-09-02 20:35:15 -04:00
Dylan Kirkby
e5afa57cca Allow setting 'allowNamespaces' in typescript preset (#10382)
* Support 'allowNamespaces' in typescript preset

* Remove default for allowNamespaces
2019-09-02 20:33:01 -04:00
Thiago Arrais
e7fa566442 Includes test for #8354 (#10385) 2019-09-02 21:58:54 +02:00
Nicolò Ribaudo
7c0333e12a Move preset-env old changelog
Fixes #9730
2019-09-02 12:41:55 +02:00
Shrey Banga
8a775a32ba Retain trailing comments in array expressions (#10369)
* Retain trailing comments in array expressions

This is a proposed fix for https://github.com/babel/babel/issues/10368
with a simple test.

* Move lastElement in the block where it's used

* Test trailing comment after array expression

* Don't move comments after the array expression

* Retain trailing comment after the array expression
2019-08-28 14:03:37 -04:00
dependabot[bot]
94e47c30a9 Bump eslint-utils from 1.4.0 to 1.4.2 (#10370)
Bumps [eslint-utils](https://github.com/mysticatea/eslint-utils) from 1.4.0 to 1.4.2.
- [Release notes](https://github.com/mysticatea/eslint-utils/releases)
- [Commits](https://github.com/mysticatea/eslint-utils/compare/v1.4.0...v1.4.2)

Signed-off-by: dependabot[bot] <support@github.com>
2019-08-27 09:50:33 +02:00
Justin Ridgewell
1664cce681 Don't allow JSXNamespacedName to chain (#10366)
Eg, `namespace:foo.bar` used to parse but is invalid in the [spec](https://facebook.github.io/jsx/).

Also, allow `JSXNamespacedName` in the `JSXOpeningElement`/`JSXClosingElement` builders.
2019-08-26 13:16:22 -04:00
Nicolò Ribaudo
a2bf68981f Add TSBigIntKeyword to @babel/types (#10341) 2019-08-20 17:31:45 -05:00
Nicolò Ribaudo
15aa511b8e Do not register ambient classes to the TS scope (#10352) 2019-08-20 17:22:47 -05:00
Henry Zhu
11ed2e2bf5 readme: links/contributing updates (#10206) [skip ci]
* readme: links/contributing updates

* Update README.md
2019-08-19 09:31:37 +02:00
Even Alander
eb3767d58b Add a builder definition including name for tsTypeParameter (#10319) 2019-08-15 19:59:08 +02:00
Nicolò Ribaudo
f0c2364d01 Do not delete "fake" source map comments from strings (#9960)
Instead of using `convert-source-map`'s `removeComments` method before
parsing the file, we can first parse the file with `@babel/parser` and then
analyze the comments.
This is needed because it is not possible to reliabily detect comments in
JavaScript without fully parsing the file:
https://github.com/thlorenz/convert-source-map/issues/63
2019-08-14 17:05:55 +02:00
Huáng Jùnliàng
ee344c3e4c Revert "chore: remove FORCE_COLOR workaround" (#10336)
This reverts commit 347ee036becdca3c9e158311d44a48ed89df9a94.
2019-08-14 16:58:01 +02:00
Ziad El Khoury Hanna
64041e1669 Fix flow comments plugin issues (#10329)
* Fix issues in flow-comments to preserve comments and there order (fixes #10324)

* Add support in flow-comments for extends in class declarations (fixes #10323, #10321)

* Refactoring and cleanup of flow-comments plugin

* Fix comments preservation logic of flow-comments

* Fix flow-comments where comments are class identifier and extends keyword
2019-08-14 15:46:26 +02:00
Nicolò Ribaudo
469a5a71cd Allow testing logs with @babel/helper-transform-fixture-test-runner (#10326)
* Add support for logs to transform-fixture-test-runner

* Test some warnings

* Use stderr/stdout, and add a validateLogs test option

* Normalize CWD in logs and rename vars

* Silence preset-env tests

* Restore old methods
2019-08-14 08:03:03 +02:00
Huáng Jùnliàng
75090f10e5 fix: assign comment to ObjectProperty only when inside an ObjectExpression (#10292)
Fixes #10230
2019-08-13 13:49:16 -05:00
Huáng Jùnliàng
22df2ae244 Commit generated code (#10331)
* update prettier generated artifacts

* chore: sync babel-helpers to artifacts
2019-08-13 16:31:28 +02:00
Nicolò Ribaudo
051965052c Update @lerna/collect-updates git hash 2019-08-13 12:03:34 +02:00
Thiago Arrais
ee397ff107 Adds note about two approval policy to PR template (#10313)
* Adds note about two approval policy to PR template

* Adds qualifier to approval policy

Because, although two approvals is the general case, some PRs maybe merged with more or fewer approvals

[skip ci]
2019-08-12 17:32:31 +02:00
Huáng Jùnliàng
15535cf52c Update preset-env text fixtures (#10318)
* chore: update preset-env text fixtures

* chore: remove FORCE_COLOR workaround
2019-08-12 00:55:27 +02:00
README Bot
682d9f9f09 Add CodeTriage badge to babel/babel (#10088) [skip ci]
Adds a badge showing the number of people helping this repo on CodeTriage.

[![Open Source Helpers](https://www.codetriage.com/babel/babel/badges/users.svg)](https://www.codetriage.com/babel/babel)

## What is CodeTriage?

CodeTriage is an Open Source app that is designed to make contributing to Open Source projects easier. It works by sending subscribers a few open issues in their inbox. If subscribers get busy, there is an algorithm that backs off issue load so they do not get overwhelmed

[Read more about the CodeTriage project](https://www.codetriage.com/what).

## Why am I getting this PR?

Your project was picked by the human, @schneems. They selected it from the projects submitted to https://www.codetriage.com and hand edited the PR. How did your project get added to [CodeTriage](https://www.codetriage.com/what)? Roughly over 3 years ago, [iamsolankiamit](https://github.com/iamsolankiamit) added this project to CodeTriage in order to start contributing. Since then, 94 people have subscribed to help this repo.

## What does adding a badge accomplish?

Adding a badge invites people to help contribute to your project. It also lets developers know that others are invested in the longterm success and maintainability of the project.

You can see an example of a CodeTriage badge on these popular OSS READMEs:

- [![Email clients like GMAIL do not render SVG images](https://www.codetriage.com/rails/rails/badges/users.svg)](https://www.codetriage.com/rails/rails) https://github.com/rails/rails
- [![Email clients like GMAIL do not render SVG images](https://www.codetriage.com/crystal-lang/crystal/badges/users.svg)](https://www.codetriage.com/crystal-lang/crystal) https://github.com/crystal-lang/crystal

## Have a question or comment?

While I am a bot, this PR was manually reviewed and monitored by a human - @schneems. My job is writing commit messages and handling PR logistics.

If you have any questions, you can reply back to this PR and they will be answered by @schneems. If you do not want a badge right now, no worries, close the PR, you will not hear from me again.

Thanks for making your project Open Source! Any feedback is greatly appreciated.
2019-08-09 19:18:18 +02:00
Serge Havas
a112be2fa0 [fix] jsx helper calls order (#10307)
imitate properly react createElement calls order
2019-08-08 22:43:57 +02:00
ifsnow
9ec26a7d3e Improves the logic to import objects in helpers (#10161)
* Improves the logic to import objects in helpers

* Modified to work with more cases.

* Modified by considering exception cases

* Fixed not using bundler's polyfill

Co-Authored-By: Jordan Harband <ljharb@gmail.com>

* Updated test output files

* Changes to cache logic

* Modified to use if statement
2019-08-08 11:11:50 +02:00
Thiago Arrais
ba2c0f7adf fix: register inserted class declaration (#10302)
* Decorators legacy: register inserted declaration

For compatibility with the Typescript plugin

Fixes #10264

* Register declaration but also keep replaceWithMultiple
2019-08-08 07:14:23 +02:00
Huáng Jùnliàng
5fb4d84a33 perf: always return void 0 as undefined node (#10243) 2019-08-01 09:53:40 +02:00
Tan Li Hau
3e4a9d588b Do expressions transform for switch statements (#10070)
* lint fix

* switch inside do expression

* review comments

* review comments

* make min diff

* adding more test

* review changes

* review changes

* handle block statement and added more test cases

* fix implementation and add more test cases

* fix last swtich case

* disable block fallthrough case

* fix nitpick reviews
2019-08-01 09:36:35 +02:00
Tan Li Hau
be2cbde560 remove finally from completion record in trystatement (#10277) 2019-08-01 09:24:08 +02:00
Ashwin Ramaswami
66727632e8 fix: replace es.string.reverse with es.array.reverse (#10284) 2019-08-01 09:20:52 +02:00
Brian Donovan
ba28f462bc Fix typo "to" → "so". (#10288) 2019-07-31 16:04:53 -04:00
Huáng Jùnliàng
f08062b1de chore: fix ESLint errors (#10278) 2019-07-29 10:14:11 -05:00
Daniel Tschinder
4f0840ab88 Update dev dependencies and fix linting errors (#10228)
* chore: Uppate dev dependencies

* chore: Fix lint errors

* chore: Format options.json files

* chore: Fix stupid flow errors

* Update test262 whitelist

Seems test262-stream was updated and now these tests work.
2019-07-27 15:09:30 +02:00
Tan Li Hau
6a9d2538e0 fix capturing group for matchAll (#10136)
* fix capturing group for matchAll

* update test case

* add core-js/features/string/match-all to test
2019-07-26 18:53:22 -04:00
Letladi Sebesho
f160522ab0 updated ParsePlugin type definition (#10259)
* added 'placeholders', 'logicalAssignment', 'partialApplication' to the ParserPlugin type. closes #10186

* put the ParserPlugin names in alphabetical order
2019-07-26 10:22:23 +02:00
Serhii Muryhin
4d30379d36 Add ";" token to the end of TS construct & call signature declaration (#10258)
* Add ";" token to the end of TS construct signature declaration

* Add ";" token to the end of TS call signature declaration. Update construct signature test fixtures
2019-07-25 10:14:35 +02:00
Letladi Sebesho
4d12c8971b added flow to babel cli (#10244)
* added flow to babel cli

* added 'SourceMapGenerator' as a argument to 'fromObject'
2019-07-25 09:59:41 +02:00
Yuri Karadzhov
4506590557 Add static parameter to class property builder (#10248) 2019-07-25 09:55:03 +02:00
Brian Donovan
1e7ed5c461 Add allowUndeclaredExports option to typings. (#10263)
This should have been included in https://github.com/babel/babel/pull/9864 but was not.
2019-07-25 09:53:56 +02:00
Nicolò Ribaudo
fced5cea43 Fix tdz checks in transform-block-scoping plugin (#9498)
* Better tdz tests

- Use jest's expect.toThrow/expect.not.toThrow
- Add input/output tests

* Fix basic tdz (a = 2; let a)

Fixes #6848

* Make _guessExecutionStatusRelativeTo more robust

* Add tests

* Return less "unkown" execution status

* "function" execution status does not exist

* Fix recursive functions

* Update helper version

* "finally" blocks are always executed

* Typo
2019-07-21 06:34:43 +02:00
Nicolò Ribaudo
9bc9571381 Extract release actions to babel/actions 2019-07-20 16:43:22 +02:00
Nicolò Ribaudo
fb910e063c [gh action] Release on tag push 2019-07-20 16:39:10 +02:00
Daniel Tschinder
3b4a86aea4 Separate workflows as otherwise they interfere with eachother 2019-07-20 15:26:52 +02:00
Daniel Tschinder
94b678c949 Fix workflow 2019-07-20 15:22:21 +02:00
Daniel Tschinder
c84a4c8bfa Use latest version of filter action 2019-07-20 15:14:07 +02:00
Daniel Tschinder
dfd59c183e Add 'Needs Info' workflow 2019-07-20 15:13:29 +02:00
Nicolò Ribaudo
718017d896 Use "release" event instead of "push" 2019-07-20 14:30:33 +02:00
Daniel Tschinder
a0cb7b1ab1 Rename github action 2019-07-19 15:46:51 +02:00
Daniel Tschinder
0b886418c8 Use github actions for welcome comment 2019-07-19 14:44:40 +02:00
Babel Bot
0371979a3e Add v7.5.5 to CHANGELOG.md [skip ci] 2019-07-17 21:29:47 +00:00
Nicolò Ribaudo
0407f034f0 v7.5.5 2019-07-17 23:08:08 +02:00
Nicolò Ribaudo
d919ecd254 Move lerna fork to the babel org 2019-07-17 00:02:41 +02:00
Daniel Tschinder
d8da63c929 Use correct extension for typescript fixtures (#10014)
* Use correct extension for typescript fixtures

* Change transform fixtures

* Adjust editorconfig for ts files

* Rename new tests

Co-authored-by: Nicolò Ribaudo (nicolo.ribaudo@gmail.com)
2019-07-15 22:46:03 +02:00
Tan Li Hau
eb3230f9db fix code-frame marker with highlighting (#10211) 2019-07-15 21:16:18 +02:00
Nicolò Ribaudo
7dc5fdb390 Workaround #10179 in proposal-object-rest-spread (#10200) 2019-07-15 19:01:29 +02:00
Tan Li Hau
ee68d6d1b0 add assertShape to validate templateElement (#10198)
* add assertShape to validate templateElement

* Update packages/babel-types/src/definitions/utils.js

Co-Authored-By: Nicolò Ribaudo <nicolo.ribaudo@gmail.com>

* templateElement optional cooked
2019-07-15 01:03:50 +02:00
Tan Li Hau
d3fe22f0e1 destructuring private fields with array pattern / object patte… (#10017)
* destructuring private fields with array pattern / object pattern

* wip: new test cases

* destrucuring and rest for private properties

* test case for loose private-loose

* add transform-desturcturing for exec

* update test case

* remove getPrototypeOf imports from get and set

* wip: destructure super assignment

* throw "Destructuring to a super field is not supported yet."

* fix tests and fix assignment pattern

* remove CallExpression from AssignmentPattern
2019-07-15 01:00:20 +02:00
James DiGioia
7f47cb65d0 Add Pipeline nodes to ast.spec [skip ci] (#10214) 2019-07-13 19:11:51 +02:00
Tan Li Hau
8b9af1be2f fix transform-flow-comments for import types (#9901)
* fix transform-flow-comments for import types

* update: dependencies
2019-07-13 16:06:42 +02:00
Tan Li Hau
f5ca0587d1 always throw when add missing helpers (#10208) 2019-07-12 12:53:55 -05:00
Sagiv ben giat
a9660cf559 resolve #10205 (#10207) 2019-07-12 11:00:25 -05:00
dependabot[bot]
8107a6faa2 Bump lodash.template from 4.4.0 to 4.5.0 (#10204)
Bumps [lodash.template](https://github.com/lodash/lodash) from 4.4.0 to 4.5.0.
- [Release notes](https://github.com/lodash/lodash/releases)
- [Commits](https://github.com/lodash/lodash/compare/4.4.0...4.5.0)

Signed-off-by: dependabot[bot] <support@github.com>
2019-07-12 10:29:48 +02:00
cybai
42000b9907 Upgrade lodash to 4.17.13 (#10191) 2019-07-12 10:29:06 +02:00
Huáng Jùnliàng
5d9a786b2f perf: match ownKeys perf to the one of objectSpread (#10189) 2019-07-10 21:03:01 -05:00
Huáng Jùnliàng
e88a569e83 fix: custom instOfHandler result should be cast to boolean (#10197) 2019-07-10 23:38:46 +02:00
Babel Bot
4eab157502 Add v7.5.4 to CHANGELOG.md [skip ci] 2019-07-09 18:58:16 +00:00
Nicolò Ribaudo
a9a7f4e690 v7.5.4 2019-07-09 20:52:37 +02:00
Nicolò Ribaudo
fa5ec75c43 Fix _objectSpread2 for real (#10188)
* Fix _objectSpread2 for real

* Tests

* Test 2
2019-07-09 20:50:07 +02:00
Babel Bot
b961d39a4d Add v7.5.3 to CHANGELOG.md [skip ci] 2019-07-09 14:52:52 +00:00
Nicolò Ribaudo
759ff4d6df v7.5.3 2019-07-09 16:41:44 +02:00
Nicolò Ribaudo
9e65472377 [_objectSpread2] Do not use hoisted var from prev iteration (#10180) 2019-07-09 16:38:40 +02:00
Babel Bot
25f040caa4 Add v7.5.2 to CHANGELOG.md [skip ci] 2019-07-08 19:53:06 +00:00
1422 changed files with 14660 additions and 5643 deletions

View File

@@ -6,7 +6,7 @@ charset = utf-8
trim_trailing_whitespace = true
end_of_line = lf
[*.{js,json}]
[*.{js,json,ts,tsx}]
indent_style = space
indent_size = 2

View File

@@ -2,6 +2,8 @@
Before making a PR, please read our contributing guidelines
https://github.com/babel/babel/blob/master/CONTRIBUTING.md
Please note that the Babel Team requires two approvals before merging most PRs.
For issue references: Add a comma-separated list of a [closing word](https://help.github.com/articles/closing-issues-via-commit-messages/) followed by the ticket number fixed by the PR. (it should be underlined in the preview if done correctly)
If you are making a change that should have a docs update: submit another PR to https://github.com/babel/website

View File

@@ -1,16 +0,0 @@
FROM debian:stable-slim
LABEL "name"="create-release-tag"
LABEL "version"="0.0.1"
LABEL "com.github.actions.name"="Create release tag"
LABEL "com.github.actions.description"="Creates a release tag equal to the last commit message"
LABEL "com.github.actions.icon"="tag"
LABEL "com.github.actions.color"="gray-dark"
ADD entrypoint.sh /action/entrypoint.sh
RUN chmod +x /action/entrypoint.sh
RUN apt-get update && apt-get install -y --no-install-recommends git
ENTRYPOINT ["/action/entrypoint.sh"]

View File

@@ -1,14 +0,0 @@
#!/bin/sh
set -e
# GitHub doesn't support running actions on new tags yet: we need to run it on the commit.
# For this reason, we can't be sure that the tag already exists. We can use the commit
# message to create the tag. If the tag already exists locally, they won't conflict because
# they have the same name and are on the same commit.
echo "INFO: Getting release version..."
tag_name=$(git log --oneline --format=%B -1 $GITHUB_SHA)
echo "INFO: Creating new tag..."
(git tag $tag_name $GITHUB_SHA) || echo "INFO: Tag already exists"

View File

@@ -1,16 +0,0 @@
FROM debian:stable-slim
LABEL "name"="filter"
LABEL "version"="1.1.0"
LABEL "com.github.actions.name"="Filter commit message"
LABEL "com.github.actions.description"="Stop a workflow if the message of the current commit doesn't match the pattern"
LABEL "com.github.actions.icon"="filter"
LABEL "com.github.actions.color"="gray-dark"
ADD entrypoint.sh /action/entrypoint.sh
RUN chmod +x /action/entrypoint.sh
RUN apt-get update && apt-get install -y --no-install-recommends git
ENTRYPOINT ["/action/entrypoint.sh"]

View File

@@ -1,15 +0,0 @@
#!/bin/sh
set -e
pattern=$1
message=$(git log --oneline --format=%B -1 $GITHUB_SHA)
if echo "$message" | grep -Pq "$pattern"; then
echo "INFO: $message matches $pattern"
exit 0
else
echo "INFO: $message does not match $pattern"
# 78 is the "neutral" exit status
exit 78
fi

View File

@@ -1,19 +0,0 @@
FROM node:10
LABEL "name" = "trigger-github-release"
LABEL "version" = "0.0.1"
LABEL "com.github.actions.name" = "Trigger GitHub release"
LABEL "com.github.actions.description" = "Trigger a new GitHub release and generate the changelog using lerna-changelog."
LABEL "com.github.actions.icon" = "tag"
LABEL "com.github.actions.color" = "yellow"
ADD entrypoint.sh /action/entrypoint.sh
ADD package.json /action/package.json
ADD package-lock.json /action/package-lock.json
ADD release.js /action/release.js
ADD update-changelog.js /action/update-changelog.js
RUN chmod +x /action/entrypoint.sh
ENTRYPOINT ["/action/entrypoint.sh"]

View File

@@ -1,38 +0,0 @@
#!/bin/sh
set -e
echo "INFO: Installing action dependencies..."
(cd /action; npm ci)
echo "INFO: Getting release version..."
current_tag=$(git describe --abbrev=0 --tags $GITHUB_SHA)
last_tag=$(git describe --abbrev=0 --tags $current_tag^)
echo "INFO: New version is $current_tag; last version is $last_tag."
echo "INFO: Generating the changelog..."
# lerna-changelog expects the token to be provided as GITHUB_AUTH,
# but GitHub actions don't allow to predefine custom env vars prefixed with
# GITHUB_. We need to define it here.
changelog=$(
GITHUB_AUTH="$GITHUB_TOKEN" \
node /action/node_modules/.bin/lerna-changelog --tag-from $last_tag --tag-to $current_tag
)
echo "INFO: Publishing the new GitHub release..."
echo "$changelog" | node /action/release $current_tag
echo "INFO: Updating CHANGELOG.md..."
echo "$changelog" | node /action/update-changelog
echo "INFO: Committing changelog..."
git add CHANGELOG.md
git -c user.name="$COMMIT_AUTHOR_NAME" -c user.email="$COMMIT_AUTHOR_EMAIL" \
commit -m "Add $current_tag to CHANGELOG.md [skip ci]" --no-verify --quiet
echo "INFO: Pushing updates..."
git push "https://${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" master
echo "INFO: Done! Don't forget to thank new contributors :)"

File diff suppressed because it is too large Load Diff

View File

@@ -1,12 +0,0 @@
{
"private": true,
"name": "@internal/trigger-github-release",
"version": "0.0.1",
"author": "Nicolò Ribaudo <nicolo.ribaudo@gmail.com>",
"license": "MIT",
"dependencies": {
"@octokit/rest": "^16.3.0",
"get-stdin": "^6.0.0",
"lerna-changelog": "^0.8.2"
}
}

View File

@@ -1,26 +0,0 @@
"use strict";
const [ /* node */, /* file */, tag ] = process.argv;
const getStdin = require("get-stdin");
const octokit = require("@octokit/rest")();
octokit.authenticate({
type: "token",
token: process.env.GITHUB_TOKEN
});
const [ repoOwner, repoName ] = process.env.GITHUB_REPOSITORY.split("/");
getStdin()
.then(changelog => octokit.repos.createRelease({
owner: repoOwner,
repo: repoName,
tag_name: tag,
body: changelog,
draft: true,
}))
.catch(err => {
console.error(err);
process.exit(1);
});

View File

@@ -1,31 +0,0 @@
"use strict";
const getStdin = require("get-stdin");
const fs = require("fs").promises;
const path = require("path");
const { GITHUB_WORKSPACE } = process.env;
const INSERTION_POINT = "<!-- insert-new-changelog-here -->";
const CHANGELOG = path.resolve(GITHUB_WORKSPACE, "CHANGELOG.md");
main();
async function main() {
let [stdin, changelog] = await Promise.all([
getStdin(),
fs.readFile(CHANGELOG, "utf8"),
]);
if (!changelog.includes(INSERTION_POINT)) {
throw new Error(`Missing "${INSERTION_POINT}" in CHANGELOG.md`);
}
// Remove committers
stdin = stdin.split("\n\n#### Committers")[0];
changelog = changelog.replace(
INSERTION_POINT,
INSERTION_POINT + "\n" + stdin
);
await fs.writeFile(CHANGELOG, changelog);
}

93
.github/main.workflow vendored
View File

@@ -1,53 +1,76 @@
workflow "Release" {
on = "push"
resolves = [
"Trigger GitHub release",
# GitHub actions are too slow for this, it takes more than 15 mins.
# Publishing to npm from GH actions is a cool idea, but it's a lot faster to
# publish locally.
# "Publish to npm",
]
resolves = ["Trigger GitHub release"]
}
action "Is version tag" {
uses = "actions/bin/filter@0dbb077f64d0ec1068a644d25c71b1db66148a24"
args = "tag v*"
}
action "Is tag from master" {
uses = "babel/actions/commit-matches-branch@master"
needs = [
"Is version tag",
]
args = "master"
}
action "Trigger GitHub release" {
uses = "./.github/actions/trigger-github-release/"
uses = "babel/actions/trigger-github-release@master"
secrets = ["GITHUB_TOKEN"]
env = {
COMMIT_AUTHOR_NAME = "Babel Bot"
COMMIT_AUTHOR_EMAIL = "babel-bot@users.noreply.github.com"
}
needs = ["Create release tag"]
}
action "Publish to npm" {
uses = "docker://node:10"
secrets = ["NPM_TOKEN"]
runs = "make"
args = "publish-ci"
env = {
CI = "true"
}
needs = ["Create release tag"]
}
# When GitHub Actions will support the "release" event for public
# repositories, we won't need this checks anymore.
action "Create release tag" {
uses = "./.github/actions/create-release-tag"
needs = [
"Is version commit",
"On master branch",
"Is version tag",
"Is tag from master",
]
}
action "Is version commit" {
uses = "./.github/actions/filter-commit-message"
# This regex is run using "grep -P".
# The (-\\S+) part is for 7.0.0-beta.1 releases.
args = "^v(\\d+\\.){2}\\d+(-\\S+)?$"
workflow "Welcome" {
resolves = [
"Create Welcome Comment"
]
on = "issues"
}
action "On master branch" {
action "Is action 'opened'" {
uses = "actions/bin/filter@master"
args = "branch master"
args = "action opened"
}
action "Create Welcome Comment" {
uses = "babel/actions/create-welcome-comment@master"
secrets = ["GITHUB_TOKEN", "BOT_TOKEN"]
needs = ["Is action 'opened'"]
}
workflow "Needs Info" {
resolves = [
"Create Needs Info Comment"
]
on = "issues"
}
action "Is action 'labeled'" {
uses = "actions/bin/filter@master"
args = "action labeled"
}
action "Has label 'Needs Info'" {
uses = "actions/bin/filter@master"
needs = [
"Is action 'labeled'"
]
args = "label 'Needs Info'"
}
action "Create Needs Info Comment" {
uses = "babel/actions/create-needs-info-comment@master"
needs = [
"Has label 'Needs Info'",
]
secrets = ["BOT_TOKEN", "GITHUB_TOKEN"]
}

View File

@@ -18,6 +18,143 @@ See [Babylon's CHANGELOG](packages/babylon/CHANGELOG.md) for the Babylon pre-7.0
<!-- DO NOT CHANGE THESE COMMENTS - See .github/actions/trigger-github-release/update-changelog.js -->
<!-- insert-new-changelog-here -->
## v7.6.0 (2019-09-06)
#### :eyeglasses: Spec Compliance
* `babel-generator`, `babel-parser`
* [#10269](https://github.com/babel/babel/pull/10269) Fix parenthesis for nullish coalescing ([@vivek12345](https://github.com/vivek12345))
* `babel-helpers`, `babel-plugin-transform-block-scoping`, `babel-traverse`
* [#9498](https://github.com/babel/babel/pull/9498) Fix tdz checks in transform-block-scoping plugin ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
#### :rocket: New Feature
* `babel-core`
* [#10181](https://github.com/babel/babel/pull/10181) feat(errors): validate preset when filename is absent ([@JLHwung](https://github.com/JLHwung))
* `babel-helper-create-class-features-plugin`, `babel-helpers`, `babel-plugin-proposal-private-methods`
* [#10217](https://github.com/babel/babel/pull/10217) Class Private Static Accessors ([@tim-mc](https://github.com/tim-mc))
* `babel-generator`, `babel-parser`, `babel-types`
* [#10148](https://github.com/babel/babel/pull/10148) V8intrinsic syntax plugin ([@JLHwung](https://github.com/JLHwung))
* `babel-preset-typescript`
* [#10382](https://github.com/babel/babel/pull/10382) Allow setting 'allowNamespaces' in typescript preset ([@dsgkirkby](https://github.com/dsgkirkby))
* `babel-parser`
* [#10352](https://github.com/babel/babel/pull/10352) Do not register ambient classes to the TS scope ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
* `babel-types`
* [#10248](https://github.com/babel/babel/pull/10248) Add static to class property builder ([@yuri-karadzhov](https://github.com/yuri-karadzhov))
#### :bug: Bug Fix
* `babel-helpers`, `babel-plugin-transform-destructuring`, `babel-plugin-transform-modules-commonjs`, `babel-preset-env`
* [#10396](https://github.com/babel/babel/pull/10396) fix: early return when instance is not iterable ([@JLHwung](https://github.com/JLHwung))
* `babel-plugin-transform-runtime`
* [#10398](https://github.com/babel/babel/pull/10398) Add supports for polyfill computed methods ([@rhyzx](https://github.com/rhyzx))
* `babel-preset-env`
* [#10397](https://github.com/babel/babel/pull/10397) Don't polyfill when evaluation is not confident ([@rhyzx](https://github.com/rhyzx))
* [#10218](https://github.com/babel/babel/pull/10218) [preset-env] Include / exclude module plugins properly ([@AdamRamberg](https://github.com/AdamRamberg))
* [#10284](https://github.com/babel/babel/pull/10284) Replace es.string.reverse with es.array.reverse ([@epicfaace](https://github.com/epicfaace))
* `babel-plugin-transform-named-capturing-groups-regex`
* [#10395](https://github.com/babel/babel/pull/10395) fix: transform name capturing regex once ([@JLHwung](https://github.com/JLHwung))
* `babel-types`
* [#10098](https://github.com/babel/babel/pull/10098) fix typescript for babel-types ([@tanhauhau](https://github.com/tanhauhau))
* [#10319](https://github.com/babel/babel/pull/10319) Add a builder definition including name for tsTypeParameter ([@deificx](https://github.com/deificx))
* `babel-parser`
* [#10380](https://github.com/babel/babel/pull/10380) Refactor trailing comment adjustment ([@banga](https://github.com/banga))
* [#10369](https://github.com/babel/babel/pull/10369) Retain trailing comments in array expressions ([@banga](https://github.com/banga))
* [#10292](https://github.com/babel/babel/pull/10292) fix: assign trailing comment to ObjectProperty only when inside an ObjectExpression ([@JLHwung](https://github.com/JLHwung))
* `babel-parser`, `babel-types`
* [#10366](https://github.com/babel/babel/pull/10366) Don't allow JSXNamespacedName to chain ([@jridgewell](https://github.com/jridgewell))
* `babel-generator`, `babel-plugin-transform-typescript`, `babel-types`
* [#10341](https://github.com/babel/babel/pull/10341) Add TSBigIntKeyword to @babel/types ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
* `babel-core`, `babel-types`
* [#9960](https://github.com/babel/babel/pull/9960) Do not delete "fake" source map comments from strings ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
* `babel-plugin-transform-flow-comments`
* [#10329](https://github.com/babel/babel/pull/10329) Fix flow comments plugin issues ([@zaygraveyard](https://github.com/zaygraveyard))
* `babel-helpers`, `babel-plugin-transform-react-constant-elements`
* [#10307](https://github.com/babel/babel/pull/10307) [fix] jsx helper calls order ([@Sinewyk](https://github.com/Sinewyk))
* `babel-plugin-proposal-decorators`
* [#10302](https://github.com/babel/babel/pull/10302) fix: register inserted class declaration ([@thiagoarrais](https://github.com/thiagoarrais))
* `babel-plugin-proposal-do-expressions`, `babel-traverse`
* [#10070](https://github.com/babel/babel/pull/10070) Do expressions transform for switch statements ([@tanhauhau](https://github.com/tanhauhau))
* [#10277](https://github.com/babel/babel/pull/10277) remove finally from completion record in try statement ([@tanhauhau](https://github.com/tanhauhau))
* `babel-helpers`, `babel-plugin-transform-named-capturing-groups-regex`
* [#10136](https://github.com/babel/babel/pull/10136) fix capturing group for matchAll ([@tanhauhau](https://github.com/tanhauhau))
#### :nail_care: Polish
* `babel-plugin-transform-runtime`, `babel-preset-env`
* [#10372](https://github.com/babel/babel/pull/10372) Don't allow instance properties transformation on namespace ([@rhyzx](https://github.com/rhyzx))
#### :memo: Documentation
* [#10313](https://github.com/babel/babel/pull/10313) Adds note about two approval policy to PR template ([@thiagoarrais](https://github.com/thiagoarrais))
#### :house: Internal
* `babel-register`
* [#9847](https://github.com/babel/babel/pull/9847) Remove core-js dependency from @babel/register ([@coreyfarrell](https://github.com/coreyfarrell))
* `babel-helper-fixtures`, `babel-helper-transform-fixture-test-runner`, `babel-preset-env`
* [#10401](https://github.com/babel/babel/pull/10401) Use "validateLogs" for preset-env's debug fixtures ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
* `babel-parser`
* [#10380](https://github.com/babel/babel/pull/10380) Refactor trailing comment adjustment ([@banga](https://github.com/banga))
* `babel-helper-fixtures`, `babel-helper-transform-fixture-test-runner`, `babel-plugin-proposal-dynamic-import`, `babel-preset-env`
* [#10326](https://github.com/babel/babel/pull/10326) Allow testing logs with `@babel/helper-transform-fixture-test-runner` ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
* `babel-runtime-corejs2`, `babel-runtime`, `babel-types`
* [#10331](https://github.com/babel/babel/pull/10331) Commit generated code ([@JLHwung](https://github.com/JLHwung))
* `babel-cli`, `babel-core`, `babel-generator`, `babel-helper-create-class-features-plugin`, `babel-helper-fixtures`, `babel-node`, `babel-parser`, `babel-plugin-proposal-do-expressions`, `babel-plugin-proposal-pipeline-operator`, `babel-plugin-transform-modules-commonjs`, `babel-plugin-transform-runtime`, `babel-preset-env`, `babel-standalone`, `babel-template`, `babel-traverse`, `babel-types`
* [#10228](https://github.com/babel/babel/pull/10228) Update dev dependencies and fix linting errors ([@danez](https://github.com/danez))
* `babel-cli`
* [#10244](https://github.com/babel/babel/pull/10244) added flow to babel cli ([@Letladi](https://github.com/Letladi))
#### :running_woman: Performance
* `babel-helpers`, `babel-plugin-transform-modules-commonjs`, `babel-preset-env`
* [#10161](https://github.com/babel/babel/pull/10161) Improves the logic to import objects in helpers ([@ifsnow](https://github.com/ifsnow))
* `babel-traverse`
* [#10243](https://github.com/babel/babel/pull/10243) perf: always return `void 0` as undefined node ([@JLHwung](https://github.com/JLHwung))
## v7.5.5 (2019-07-17)
#### :bug: Bug Fix
* `babel-code-frame`
* [#10211](https://github.com/babel/babel/pull/10211) fix code-frame marker with highlighting ([@tanhauhau](https://github.com/tanhauhau))
* `babel-plugin-proposal-object-rest-spread`
* [#10200](https://github.com/babel/babel/pull/10200) Workaround #10179 in proposal-object-rest-spread ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
* `babel-types`
* [#10198](https://github.com/babel/babel/pull/10198) add assertShape to validate templateElement ([@tanhauhau](https://github.com/tanhauhau))
* `babel-helper-create-class-features-plugin`, `babel-helper-member-expression-to-functions`, `babel-helper-replace-supers`, `babel-helpers`, `babel-plugin-proposal-class-properties`, `babel-plugin-transform-classes`, `babel-plugin-transform-object-super`, `babel-types`
* [#10017](https://github.com/babel/babel/pull/10017) destructuring private fields with array pattern / object pattern ([@tanhauhau](https://github.com/tanhauhau))
* `babel-plugin-transform-flow-comments`
* [#9901](https://github.com/babel/babel/pull/9901) fix transform-flow-comments for import types ([@tanhauhau](https://github.com/tanhauhau))
* `babel-core`, `babel-helpers`
* [#10208](https://github.com/babel/babel/pull/10208) always throw when add missing helpers ([@tanhauhau](https://github.com/tanhauhau))
* `babel-plugin-transform-runtime`
* [#10207](https://github.com/babel/babel/pull/10207) Closes [#10205](https://github.com/babel/babel/issues/10205) ([@sag1v](https://github.com/sag1v))
* `babel-helpers`, `babel-plugin-transform-instanceof`
* [#10197](https://github.com/babel/babel/pull/10197) fix: custom instOfHandler result should be cast to boolean ([@JLHwung](https://github.com/JLHwung))
#### :house: Internal
* `babel-parser`, `babel-plugin-transform-typescript`
* [#10014](https://github.com/babel/babel/pull/10014) Use correct extension for typescript fixtures ([@danez](https://github.com/danez))
#### :running_woman: Performance
* `babel-helpers`, `babel-plugin-proposal-object-rest-spread`, `babel-preset-env`
* [#10189](https://github.com/babel/babel/pull/10189) perf: match ownKeys perf to the one of objectSpread ([@JLHwung](https://github.com/JLHwung))
## v7.5.4 (2019-07-09)
#### :bug: Bug Fix
* `babel-helpers`, `babel-plugin-proposal-object-rest-spread`, `babel-preset-env`
* [#10188](https://github.com/babel/babel/pull/10188) Fix _objectSpread2 for real ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
## v7.5.3 (2019-07-09)
#### :bug: Bug Fix
* `babel-helpers`, `babel-plugin-proposal-object-rest-spread`, `babel-preset-env`
* [#10180](https://github.com/babel/babel/pull/10180) [_objectSpread2] Do not use hoisted var from prev iteration ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
## v7.5.2 (2019-07-08)
#### :bug: Bug Fix
* `babel-plugin-transform-typescript`
* [#10174](https://github.com/babel/babel/pull/10174) Do not trust Scope when removing TypeScript types ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
* `babel-helpers`, `babel-plugin-proposal-object-rest-spread`, `babel-preset-env`
* [#10171](https://github.com/babel/babel/pull/10171) Don't rely on getOwnPropertyDescriptors in objectSpread2 ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
* `babel-plugin-proposal-export-default-from`, `babel-plugin-proposal-export-namespace-from`
* [#10172](https://github.com/babel/babel/pull/10172) fix: register injected importDeclaration ([@JLHwung](https://github.com/JLHwung))
## v7.5.1 (2019-07-06)
#### :bug: Bug Fix

View File

@@ -32,6 +32,7 @@ contributing, please read the
- Follow along with what we are working on by joining our [Slack](https://babeljs.slack.com) (you can sign-up [here](https://slack.babeljs.io/)
for an invite), following our announcements on [Twitter](https://twitter.com/babeljs), and reading (or participating!) in our [meeting notes](https://github.com/babel/notes).
- Check out our [website](http://babeljs.io/) and the [repo](https://github.com/babel/website)
- You can contribute by triaging issues which may include reproducing bug reports or asking for vital information, such as version numbers or reproduction instructions. If you would like to start triaging issues, one easy way to get started is to [subscribe to babel on CodeTriage](https://www.codetriage.com/babel/babel). [![Open Source Helpers](https://www.codetriage.com/babel/babel/badges/users.svg)](https://www.codetriage.com/babel/babel)
## Chat

View File

@@ -80,14 +80,14 @@ Try it out at our [REPL](https://babeljs.io/repl/build/master#?code_lz=NoRgNATGD
Mostly a handful of volunteers, funded by you! Please check out our [team page](https://babeljs.io/team)!
### Looking for support?
For questions and support please join our [Slack Community](https://slack.babeljs.io/) (you can sign-up [here](https://slack.babeljs.io/) for an invite), ask a question on [Stack Overflow](https://stackoverflow.com/questions/tagged/babeljs), or ping us on [Twitter](https://twitter.com/babeljs).
### Is there a Babel song?
I'm so glad you asked: [Hallelujah —— In Praise of Babel](SONG.md) by [@angus-c](https://github.com/angus-c), [audio version](https://youtu.be/40abpedBKK8) by [@swyx](https://twitter.com/@swyx). Tweet us your recordings!
### Looking for support?
For questions and support please join our [Slack Community](https://slack.babeljs.io/) (you can sign-up [here](https://slack.babeljs.io/) for an invite), ask a question on [Stack Overflow](https://stackoverflow.com/questions/tagged/babeljs), or ping us on [Twitter](https://twitter.com/babeljs).
### Where are the docs?
Check out our website: [babeljs.io](https://babeljs.io/), and report issues/features at [babel/website](https://github.com/babel/website/issues).
@@ -98,12 +98,19 @@ Please read through our [CONTRIBUTING.md](CONTRIBUTING.md) and fill out the issu
### Want to contribute to Babel?
Check out our [CONTRIBUTING.md](CONTRIBUTING.md) to get started with setting up the repo.
Check out:
- If you have already joined Slack, join our [#development](https://babeljs.slack.com/messages/development) channel and say hi!
- Check out the issues with the [good first issue](https://github.com/babel/babel/labels/good%20first%20issue) and [help wanted](https://github.com/babel/babel/labels/help%20wanted) label. We suggest also looking at the closed ones to get a sense of the kinds of issues you can tackle.
- Our [#development](https://babeljs.slack.com/messages/development) Slack channel and say hi ([signup](https://slack.babeljs.io))!
- Issues with the [good first issue](https://github.com/babel/babel/labels/good%20first%20issue) and [help wanted](https://github.com/babel/babel/labels/help%20wanted) label. We suggest also looking at the [closed ones](https://github.com/babel/babel/issues?utf8=%E2%9C%93&q=is%3Aclosed+label%3A%22good+first+issue%22) to get a sense of the kinds of issues you can tackle.
Some resources:
- Our [CONTRIBUTING.md](CONTRIBUTING.md) to get started with setting up the repo.
- Our discussions/notes/roadmap: [babel/notes](https://github.com/babel/notes)
- Our progress on TC39 proposals: [babel/proposals](https://github.com/babel/proposals)
- Our blog which contains release posts and explainations: [/blog](https://babeljs.io/blog)
- Our videos page with talks about open source and Babel: [/videos](https://babeljs.io/videos)
- Our [podcast](https://podcast.babeljs.io)
### How is the repo structured?

View File

@@ -1,5 +1,5 @@
{
"version": "7.5.2",
"version": "7.6.1",
"changelog": {
"repo": "babel/babel",
"cacheDir": ".changelog",

View File

@@ -165,7 +165,7 @@ declare module "source-map" {
}
declare module "convert-source-map" {
import type { SourceMap } from "source-map";
import type { SourceMap, SourceMapGenerator } from "source-map";
declare class Converter {
toJSON(): string;
@@ -177,11 +177,11 @@ declare module "convert-source-map" {
declare module.exports: {
SourceMap: SourceMap,
Converter: Converter,
fromObject(obj: SourceMap): Converter,
fromObject(obj: SourceMap | SourceMapGenerator): Converter,
fromJSON(str: string): Converter,
fromBase64(str: string): Converter,
fromComment(str: string): Converter,
fromMapFileComment(str: string): Converter,
fromMapFileComment(str: string, dir: string): Converter,
fromSource(str: string): Converter,
fromMapFileSource(str: string, dir: string): Converter,
removeComments(str: string): string,

View File

@@ -32,13 +32,13 @@
"derequire": "^2.0.2",
"duplicate-package-checker-webpack-plugin": "^2.1.0",
"enhanced-resolve": "^3.0.0",
"eslint": "^5.16.0",
"eslint": "^6.0.1",
"eslint-config-babel": "^9.0.0",
"eslint-plugin-flowtype": "^3.8.2",
"eslint-plugin-import": "^2.17.2",
"eslint-plugin-prettier": "^3.1.0",
"fancy-log": "^1.3.3",
"flow-bin": "^0.94.0",
"flow-bin": "^0.102.0",
"graceful-fs": "^4.1.15",
"gulp": "^4.0.2",
"gulp-babel": "^8.0.0",
@@ -48,12 +48,12 @@
"gulp-rename": "^1.4.0",
"gulp-uglify": "^3.0.2",
"gulp-watch": "^5.0.1",
"husky": "^2.3.0",
"husky": "^3.0.0",
"jest": "^24.8.0",
"lerna": "^3.14.2",
"lerna": "^3.16.0",
"lerna-changelog": "^0.5.0",
"lint-staged": "^8.1.7",
"lodash": "^4.17.11",
"lint-staged": "^9.2.0",
"lodash": "^4.17.13",
"merge-stream": "^1.0.1",
"output-file-sync": "^2.0.0",
"prettier": "^1.17.1",
@@ -71,7 +71,7 @@
"webpack-stream": "^4.0.0"
},
"resolutions": {
"@lerna/**/@lerna/collect-updates": "https://github.com/nicolo-ribaudo/lerna.git#babel-collect-updates"
"@lerna/**/@lerna/collect-updates": "https://github.com/babel/lerna.git#babel-collect-updates"
},
"engines": {
"node": ">= 6.9.0 < 13.0.0",
@@ -134,6 +134,5 @@
"moduleNameMapper": {
"^@babel/([a-zA-Z0-9_-]+)$": "<rootDir>/packages/babel-$1/"
}
},
"dependencies": {}
}
}

View File

@@ -1,6 +1,6 @@
{
"name": "@babel/cli",
"version": "7.5.0",
"version": "7.6.0",
"description": "Babel command line.",
"author": "Sebastian McKenzie <sebmck@gmail.com>",
"homepage": "https://babeljs.io/",
@@ -23,21 +23,21 @@
"convert-source-map": "^1.1.0",
"fs-readdir-recursive": "^1.1.0",
"glob": "^7.0.0",
"lodash": "^4.17.11",
"lodash": "^4.17.13",
"mkdirp": "^0.5.1",
"output-file-sync": "^2.0.0",
"slash": "^2.0.0",
"source-map": "^0.5.0"
},
"optionalDependencies": {
"chokidar": "^2.0.4"
"chokidar": "^2.1.8"
},
"peerDependencies": {
"@babel/core": "^7.0.0-0"
},
"devDependencies": {
"@babel/core": "^7.5.0",
"@babel/helper-fixtures": "^7.4.4"
"@babel/core": "^7.6.0",
"@babel/helper-fixtures": "^7.6.0"
},
"bin": {
"babel": "./bin/babel.js",

View File

@@ -1,7 +1,12 @@
// @flow
import commander from "commander";
import { buildExternalHelpers } from "@babel/core";
function collect(value, previousValue): Array<string> {
function collect(
value: string | any,
previousValue: Array<string>,
): Array<string> {
// If the user passed the option with no value, like "babel-external-helpers --whitelist", do nothing.
if (typeof value !== "string") return previousValue;

View File

@@ -1,3 +1,5 @@
// @flow
import defaults from "lodash/defaults";
import outputFileSync from "output-file-sync";
import { sync as mkdirpSync } from "mkdirp";
@@ -6,11 +8,15 @@ import path from "path";
import fs from "fs";
import * as util from "./util";
import { type CmdOptions } from "./options";
export default async function({ cliOptions, babelOptions }) {
export default async function({
cliOptions,
babelOptions,
}: CmdOptions): Promise<void> {
const filenames = cliOptions.filenames;
async function write(src, base) {
async function write(src: string, base: string): Promise<boolean> {
let relative = path.relative(base, src);
if (!util.isCompilableExtension(relative, cliOptions.extensions)) {
@@ -65,14 +71,14 @@ export default async function({ cliOptions, babelOptions }) {
}
}
function getDest(filename, base) {
function getDest(filename: string, base: string): string {
if (cliOptions.relative) {
return path.join(base, cliOptions.outDir, filename);
}
return path.join(cliOptions.outDir, filename);
}
async function handleFile(src, base) {
async function handleFile(src: string, base: string): Promise<boolean> {
const written = await write(src, base);
if (!written && cliOptions.copyFiles) {
@@ -84,7 +90,7 @@ export default async function({ cliOptions, babelOptions }) {
return written;
}
async function handle(filenameOrDir) {
async function handle(filenameOrDir: string): Promise<number> {
if (!fs.existsSync(filenameOrDir)) return 0;
const stat = fs.statSync(filenameOrDir);

View File

@@ -1,3 +1,5 @@
// @flow
import convertSourceMap from "convert-source-map";
import defaults from "lodash/defaults";
import sourceMap from "source-map";
@@ -6,9 +8,18 @@ import path from "path";
import fs from "fs";
import * as util from "./util";
import { type CmdOptions } from "./options";
export default async function({ cliOptions, babelOptions }) {
function buildResult(fileResults) {
type CompilationOutput = {
code: string,
map: Object,
};
export default async function({
cliOptions,
babelOptions,
}: CmdOptions): Promise<void> {
function buildResult(fileResults: Array<Object>): CompilationOutput {
const map = new sourceMap.SourceMapGenerator({
file:
cliOptions.sourceMapTarget ||
@@ -74,7 +85,7 @@ export default async function({ cliOptions, babelOptions }) {
};
}
function output(fileResults) {
function output(fileResults: Array<string>): void {
const result = buildResult(fileResults);
if (cliOptions.outFile) {
@@ -91,14 +102,15 @@ export default async function({ cliOptions, babelOptions }) {
}
}
function readStdin() {
return new Promise((resolve, reject) => {
function readStdin(): Promise<string> {
return new Promise((resolve: Function, reject: Function): void => {
let code = "";
process.stdin.setEncoding("utf8");
process.stdin.on("readable", function() {
const chunk = process.stdin.read();
// $FlowIgnore
if (chunk !== null) code += chunk;
});
@@ -109,7 +121,7 @@ export default async function({ cliOptions, babelOptions }) {
});
}
async function stdin() {
async function stdin(): Promise<void> {
const code = await readStdin();
const res = await util.transform(
@@ -126,7 +138,7 @@ export default async function({ cliOptions, babelOptions }) {
output([res]);
}
async function walk(filenames) {
async function walk(filenames: Array<string>): Promise<void> {
const _filenames = [];
filenames.forEach(function(filename) {
@@ -151,7 +163,7 @@ export default async function({ cliOptions, babelOptions }) {
});
const results = await Promise.all(
_filenames.map(async function(filename) {
_filenames.map(async function(filename: string): Promise<Object> {
let sourceFilename = filename;
if (cliOptions.outFile) {
sourceFilename = path.relative(
@@ -168,7 +180,7 @@ export default async function({ cliOptions, babelOptions }) {
{
sourceFileName: sourceFilename,
// Since we're compiling everything to be merged together,
// "inline" applies to the final output file, but to the individual
// "inline" applies to the final output file, but not to the individual
// files being concatenated.
sourceMaps:
babelOptions.sourceMaps === "inline"
@@ -192,7 +204,7 @@ export default async function({ cliOptions, babelOptions }) {
output(results);
}
async function files(filenames) {
async function files(filenames: Array<string>): Promise<void> {
if (!cliOptions.skipInitialBuild) {
await walk(filenames);
}
@@ -208,7 +220,7 @@ export default async function({ cliOptions, babelOptions }) {
pollInterval: 10,
},
})
.on("all", function(type, filename) {
.on("all", function(type: string, filename: string) {
if (!util.isCompilableExtension(filename, cliOptions.extensions)) {
return;
}

View File

@@ -1,3 +1,5 @@
// @flow
import fs from "fs";
import commander from "commander";
@@ -151,7 +153,12 @@ commander.option(
commander.version(pkg.version + " (@babel/core " + version + ")");
commander.usage("[options] <files ...>");
export default function parseArgv(args: Array<string>) {
export type CmdOptions = {
babelOptions: Object,
cliOptions: Object,
};
export default function parseArgv(args: Array<string>): CmdOptions {
//
commander.parse(args);

View File

@@ -1,10 +1,12 @@
// @flow
import readdirRecursive from "fs-readdir-recursive";
import * as babel from "@babel/core";
import includes from "lodash/includes";
import path from "path";
import fs from "fs";
export function chmod(src, dest) {
export function chmod(src: string, dest: string): void {
fs.chmodSync(dest, fs.statSync(src).mode);
}
@@ -13,8 +15,8 @@ type ReaddirFilter = (filename: string) => boolean;
export function readdir(
dirname: string,
includeDotfiles: boolean,
filter: ReaddirFilter,
) {
filter?: ReaddirFilter,
): Array<string> {
return readdirRecursive(dirname, (filename, _index, currentDirectory) => {
const stat = fs.statSync(path.join(currentDirectory, filename));
@@ -30,7 +32,7 @@ export function readdirForCompilable(
dirname: string,
includeDotfiles: boolean,
altExts?: Array<string>,
) {
): Array<string> {
return readdir(dirname, includeDotfiles, function(filename) {
return isCompilableExtension(filename, altExts);
});
@@ -48,7 +50,7 @@ export function isCompilableExtension(
return includes(exts, ext);
}
export function addSourceMappingUrl(code, loc) {
export function addSourceMappingUrl(code: string, loc: string): string {
return code + "\n//# sourceMappingURL=" + path.basename(loc);
}
@@ -56,7 +58,11 @@ const CALLER = {
name: "@babel/cli",
};
export function transform(filename, code, opts) {
export function transform(
filename: string,
code: string,
opts: Object,
): Promise<Object> {
opts = {
...opts,
caller: CALLER,
@@ -71,7 +77,10 @@ export function transform(filename, code, opts) {
});
}
export function compile(filename, opts) {
export function compile(
filename: string,
opts: Object | Function,
): Promise<Object> {
opts = {
...opts,
caller: CALLER,
@@ -85,7 +94,7 @@ export function compile(filename, opts) {
});
}
export function deleteDir(path) {
export function deleteDir(path: string): void {
if (fs.existsSync(path)) {
fs.readdirSync(path).forEach(function(file) {
const curPath = path + "/" + file;
@@ -106,7 +115,7 @@ process.on("uncaughtException", function(err) {
process.exit(1);
});
export function requireChokidar() {
export function requireChokidar(): Object {
try {
return require("chokidar");
} catch (err) {
@@ -118,7 +127,10 @@ export function requireChokidar() {
}
}
export function adjustRelative(relative, keepFileExtension) {
export function adjustRelative(
relative: string,
keepFileExtension: boolean,
): string {
if (keepFileExtension) {
return relative;
}

View File

@@ -92,7 +92,7 @@ const assertTest = function(stdout, stderr, opts, cwd) {
if (
// saveInFiles always creates an empty .babelrc, so lets exclude for now
filename !== ".babelrc" &&
!opts.inFiles.hasOwnProperty(filename)
!Object.prototype.hasOwnProperty.call(opts.inFiles, filename)
) {
const expected = opts.outFiles[filename];
const actual = actualFiles[filename];

View File

@@ -1,6 +1,6 @@
{
"name": "@babel/code-frame",
"version": "7.0.0",
"version": "7.5.5",
"description": "Generate errors that contain a code frame that point to source locations.",
"author": "Sebastian McKenzie <sebmck@gmail.com>",
"homepage": "https://babeljs.io/",

View File

@@ -76,7 +76,7 @@ function getMarkerLines(
} else if (i === 0) {
const sourceLength = source[lineNumber - 1].length;
markerLines[lineNumber] = [startColumn, sourceLength - startColumn];
markerLines[lineNumber] = [startColumn, sourceLength - startColumn + 1];
} else if (i === lineDiff) {
markerLines[lineNumber] = [0, endColumn];
} else {
@@ -112,15 +112,16 @@ export function codeFrameColumns(
const maybeHighlight = (chalkFn, string) => {
return highlighted ? chalkFn(string) : string;
};
if (highlighted) rawLines = highlight(rawLines, opts);
const lines = rawLines.split(NEWLINE);
const { start, end, markerLines } = getMarkerLines(loc, lines, opts);
const hasColumns = loc.start && typeof loc.start.column === "number";
const numberMaxWidth = String(end).length;
let frame = lines
const highlightedLines = highlighted ? highlight(rawLines, opts) : rawLines;
let frame = highlightedLines
.split(NEWLINE)
.slice(start, end)
.map((line, index) => {
const number = start + 1 + index;

View File

@@ -102,6 +102,45 @@ describe("@babel/code-frame", function() {
);
});
test("opts.highlightCode with multiple columns and lines", function() {
// prettier-ignore
const rawLines = [
"function a(b, c) {",
" return b + c;",
"}"
].join("\n");
const result = codeFrameColumns(
rawLines,
{
start: {
line: 1,
column: 1,
},
end: {
line: 3,
column: 1,
},
},
{
highlightCode: true,
message: "Message about things",
},
);
const stripped = stripAnsi(result);
expect(stripped).toEqual(
// prettier-ignore
[
"> 1 | function a(b, c) {",
" | ^^^^^^^^^^^^^^^^^^",
"> 2 | return b + c;",
" | ^^^^^^^^^^^^^^^",
"> 3 | }",
" | ^ Message about things",
].join('\n'),
);
});
test("opts.linesAbove", function() {
const rawLines = [
"/**",

View File

@@ -1,6 +1,6 @@
{
"name": "@babel/core",
"version": "7.5.0",
"version": "7.6.0",
"description": "Babel compiler core.",
"main": "lib/index.js",
"author": "Sebastian McKenzie <sebmck@gmail.com>",
@@ -33,23 +33,23 @@
"./lib/transform-file.js": "./lib/transform-file-browser.js"
},
"dependencies": {
"@babel/code-frame": "^7.0.0",
"@babel/generator": "^7.5.0",
"@babel/helpers": "^7.5.0",
"@babel/parser": "^7.5.0",
"@babel/template": "^7.4.4",
"@babel/traverse": "^7.5.0",
"@babel/types": "^7.5.0",
"@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",
"debug": "^4.1.0",
"json5": "^2.1.0",
"lodash": "^4.17.11",
"lodash": "^4.17.13",
"resolve": "^1.3.2",
"semver": "^5.4.1",
"source-map": "^0.5.0"
},
"devDependencies": {
"@babel/helper-transform-fixture-test-runner": "^7.5.0",
"@babel/register": "^7.4.4"
"@babel/helper-transform-fixture-test-runner": "^7.6.0",
"@babel/register": "^7.6.0"
}
}

View File

@@ -268,13 +268,11 @@ function babelrcLoadEnabled(
});
}
const validateConfigFile = makeWeakCache(
(file: ConfigFile): ValidatedFile => ({
filepath: file.filepath,
dirname: file.dirname,
options: validate("configfile", file.options),
}),
);
const validateConfigFile = makeWeakCache((file: ConfigFile): ValidatedFile => ({
filepath: file.filepath,
dirname: file.dirname,
options: validate("configfile", file.options),
}));
const validateBabelrcFile = makeWeakCache(
(file: ConfigFile): ValidatedFile => ({
@@ -284,13 +282,11 @@ const validateBabelrcFile = makeWeakCache(
}),
);
const validateExtendFile = makeWeakCache(
(file: ConfigFile): ValidatedFile => ({
filepath: file.filepath,
dirname: file.dirname,
options: validate("extendsfile", file.options),
}),
);
const validateExtendFile = makeWeakCache((file: ConfigFile): ValidatedFile => ({
filepath: file.filepath,
dirname: file.dirname,
options: validate("extendsfile", file.options),
}));
/**
* Build a config chain for just the programmatic options passed into Babel.
@@ -549,7 +545,7 @@ function normalizeOptions(opts: ValidatedOptions): ValidatedOptions {
// "sourceMap" is just aliased to sourceMap, so copy it over as
// we merge the options together.
if (options.hasOwnProperty("sourceMap")) {
if (Object.prototype.hasOwnProperty.call(options, "sourceMap")) {
options.sourceMaps = options.sourceMap;
delete options.sourceMap;
}

View File

@@ -18,6 +18,7 @@ import { validatePluginObject } from "./validation/plugins";
import makeAPI from "./helpers/config-api";
import loadPrivatePartialConfig from "./partial";
import type { ValidatedOptions } from "./validation/options";
type LoadedDescriptor = {
value: {},
@@ -278,6 +279,42 @@ const instantiatePlugin = makeWeakCache(
},
);
const validateIfOptionNeedsFilename = (
options: ValidatedOptions,
descriptor: UnloadedDescriptor,
): void => {
if (options.test || options.include || options.exclude) {
const formattedPresetName = descriptor.name
? `"${descriptor.name}"`
: "/* your preset */";
throw new Error(
[
`Preset ${formattedPresetName} requires a filename to be set when babel is called directly,`,
`\`\`\``,
`babel.transform(code, { filename: 'file.ts', presets: [${formattedPresetName}] });`,
`\`\`\``,
`See https://babeljs.io/docs/en/options#filename for more information.`,
].join("\n"),
);
}
};
const validatePreset = (
preset: PresetInstance,
context: ConfigContext,
descriptor: UnloadedDescriptor,
): void => {
if (!context.filename) {
const { options } = preset;
validateIfOptionNeedsFilename(options, descriptor);
if (options.overrides) {
options.overrides.forEach(overrideOptions =>
validateIfOptionNeedsFilename(overrideOptions, descriptor),
);
}
}
};
/**
* Generate a config object that will act as the root of a new nested config.
*/
@@ -285,10 +322,9 @@ const loadPresetDescriptor = (
descriptor: UnloadedDescriptor,
context: ConfigContext,
): ConfigChain | null => {
return buildPresetChain(
instantiatePreset(loadDescriptor(descriptor, context)),
context,
);
const preset = instantiatePreset(loadDescriptor(descriptor, context));
validatePreset(preset, context, descriptor);
return buildPresetChain(preset, context);
};
const instantiatePreset = makeWeakCache(

View File

@@ -278,7 +278,7 @@ export function assertConfigFileSearch(
) {
throw new Error(
`${msg(loc)} must be a undefined, a boolean, a string, ` +
`got ${JSON.stringify(value)}`,
`got ${JSON.stringify((value: any))}`,
);
}
@@ -302,7 +302,7 @@ export function assertBabelrcSearch(
} else if (!checkValidTest(value)) {
throw new Error(
`${msg(loc)} must be a undefined, a boolean, a string/Function/RegExp ` +
`or an array of those, got ${JSON.stringify(value)}`,
`or an array of those, got ${JSON.stringify((value: any))}`,
);
}
return (value: any);

View File

@@ -203,6 +203,9 @@ export default class File {
if (res) return res;
}
// make sure that the helper exists
helpers.ensure(name);
const uid = (this.declarations[name] = this.scope.generateUidIdentifier(
name,
));

View File

@@ -1,7 +1,7 @@
// @flow
import type { PluginPasses } from "../../config";
import convertSourceMap, { type SourceMap } from "convert-source-map";
import convertSourceMap, { typeof SourceMap } from "convert-source-map";
import generate from "@babel/generator";
import type File from "./file";

View File

@@ -1,6 +1,6 @@
// @flow
import type { SourceMap } from "convert-source-map";
import typeof { SourceMap } from "convert-source-map";
import sourceMap from "source-map";
export default function mergeSourceMap(

View File

@@ -1,6 +1,6 @@
// @flow
import traverse from "@babel/traverse";
import type { SourceMap } from "convert-source-map";
import typeof { SourceMap } from "convert-source-map";
import type { ResolvedConfig, PluginPasses } from "../config";

View File

@@ -27,49 +27,6 @@ export default function normalizeFile(
): File {
code = `${code || ""}`;
let inputMap = null;
if (options.inputSourceMap !== false) {
// If an explicit object is passed in, it overrides the processing of
// source maps that may be in the file itself.
if (typeof options.inputSourceMap === "object") {
inputMap = convertSourceMap.fromObject(options.inputSourceMap);
}
if (!inputMap) {
try {
inputMap = convertSourceMap.fromSource(code);
if (inputMap) {
code = convertSourceMap.removeComments(code);
}
} catch (err) {
debug("discarding unknown inline input sourcemap", err);
code = convertSourceMap.removeComments(code);
}
}
if (!inputMap) {
if (typeof options.filename === "string") {
try {
inputMap = convertSourceMap.fromMapFileSource(
code,
path.dirname(options.filename),
);
if (inputMap) {
code = convertSourceMap.removeMapFileComments(code);
}
} catch (err) {
debug("discarding unknown file input sourcemap", err);
code = convertSourceMap.removeMapFileComments(code);
}
} else {
debug("discarding un-loadable file input sourcemap");
code = convertSourceMap.removeMapFileComments(code);
}
}
}
if (ast) {
if (ast.type === "Program") {
ast = t.file(ast, [], []);
@@ -84,6 +41,42 @@ export default function normalizeFile(
ast = parser(pluginPasses, options, code);
}
let inputMap = null;
if (options.inputSourceMap !== false) {
// If an explicit object is passed in, it overrides the processing of
// source maps that may be in the file itself.
if (typeof options.inputSourceMap === "object") {
inputMap = convertSourceMap.fromObject(options.inputSourceMap);
}
if (!inputMap) {
const lastComment = extractComments(INLINE_SOURCEMAP_REGEX, ast);
if (lastComment) {
try {
inputMap = convertSourceMap.fromComment(lastComment);
} catch (err) {
debug("discarding unknown inline input sourcemap", err);
}
}
}
if (!inputMap) {
const lastComment = extractComments(EXTERNAL_SOURCEMAP_REGEX, ast);
if (typeof options.filename === "string" && lastComment) {
try {
inputMap = convertSourceMap.fromMapFileComment(
lastComment,
path.dirname(options.filename),
);
} catch (err) {
debug("discarding unknown file input sourcemap", err);
}
} else if (lastComment) {
debug("discarding un-loadable file input sourcemap");
}
}
}
return new File(options, {
code,
ast,
@@ -156,3 +149,48 @@ function parser(
throw err;
}
}
// These regexps are copied from the convert-source-map package,
// but without // or /* at the beginning of the comment.
// 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]*$/;
function extractCommentsFromList(regex, comments, lastComment) {
if (comments) {
comments = comments.filter(({ value }) => {
if (regex.test(value)) {
lastComment = value;
return false;
}
return true;
});
}
return [comments, lastComment];
}
function extractComments(regex, ast) {
let lastComment = null;
t.traverseFast(ast, node => {
// $FlowIgnore destructuring with expressions is not supported
[node.leadingComments, lastComment] = extractCommentsFromList(
regex,
node.leadingComments,
lastComment,
);
// $FlowIgnore destructuring with expressions is not supported
[node.innerComments, lastComment] = extractCommentsFromList(
regex,
node.innerComments,
lastComment,
);
// $FlowIgnore destructuring with expressions is not supported
[node.trailingComments, lastComment] = extractCommentsFromList(
regex,
node.trailingComments,
lastComment,
);
});
return lastComment;
}

View File

@@ -788,4 +788,28 @@ describe("api", function() {
);
});
});
describe("missing helpers", function() {
it("should always throw", function() {
expect(() =>
babel.transformSync(``, {
configFile: false,
plugins: [
function() {
return {
visitor: {
Program(path) {
try {
path.pushContainer("body", this.addHelper("fooBar"));
} catch {}
path.pushContainer("body", this.addHelper("fooBar"));
},
},
};
},
],
}),
).toThrow();
});
});
});

View File

@@ -1049,5 +1049,27 @@ describe("buildConfigChain", function() {
loadOptions({ filename, cwd: path.dirname(filename) }),
).toThrow(/Error while parsing JSON - /);
});
it("should throw when `test` presents but `filename` is not passed", () => {
expect(() => loadOptions({ test: /\.ts$/, plugins: [] })).toThrow(
/Configuration contains string\/RegExp pattern/,
);
});
it("should throw when `preset` requires `filename` but it was not passed", () => {
expect(() => {
loadOptions({
presets: [require("./fixtures/config-loading/preset4")],
});
}).toThrow(/Preset \/\* your preset \*\/ requires a filename/);
});
it("should throw when `preset.overrides` requires `filename` but it was not passed", () => {
expect(() => {
loadOptions({
presets: [require("./fixtures/config-loading/preset5")],
});
}).toThrow(/Preset \/\* your preset \*\/ requires a filename/);
});
});
});

View File

@@ -0,0 +1,6 @@
module.exports = function() {
return {
test: /\.ts$/,
plugins: []
}
};

View File

@@ -0,0 +1,8 @@
module.exports = function() {
return {
overrides: [{
test: /\.ts$/,
plugins: []
}]
}
};

View File

@@ -0,0 +1,8 @@
// https://github.com/babel/babel/issues/9790
const comment = `//# sourceMappingURL=${path.basename(
sourceMapFilename
)}`
// https://github.com/babel/babel/issues/9956
this.shadowRoot.innerHTML = `<style>div{display:block}
/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZmllbGQuaHRtbCIsInNvdXJjZXMiOlsiZmllbGQuaHRtbCJdLCJzb3VyY2VzQ29udGVudCI6WyI8c3ZlbHRlOm9wdGlvbnMgdGFnPVwiZGxzLWZpZWxkXCIgLz5cblxuPHN0eWxlPlxuICBkaXYgeyBkaXNwbGF5OiBibG9jazsgfVxuPC9zdHlsZT5cblxuPGRpdiBjbGFzcz1cImZpZWxkXCI+XG4gIDxkaXYgY2xhc3M9XCJfZmllbGRMYWJlbExheW91dFwiPlxuICAgIDxkaXYgY2xhc3M9XCJmaWVsZExhYmVsXCI+XG4gICAgICA8c2xvdCBuYW1lPVwiZmllbGQtbGFiZWxcIj48L3Nsb3Q+XG4gICAgPC9kaXY+XG4gICAgPGRpdiBjbGFzcz1cImZpZWxkT3B0aW9uYWxcIiBjbGFzczpvcHRpb25hbD5cbiAgICAgIE9wdGlvbmFsXG4gICAgPC9kaXY+XG4gIDwvZGl2PlxuICA8ZGl2IGNsYXNzPVwiZmllbGREZXRhaWxcIj5cbiAgICA8c2xvdCBuYW1lPVwiZmllbGQtZGV0YWlsXCI+PC9zbG90PlxuICA8L2Rpdj5cbiAgPGRpdiBjbGFzcz1cImZpZWxkQ29udHJvbFwiPlxuICAgIDxzbG90IG5hbWU9XCJmaWVsZC1jb250cm9sXCI+PC9zbG90PlxuICAgIDxzbG90Pjwvc2xvdD5cbiAgPC9kaXY+XG4gIDxkaXYgY2xhc3M9XCJmaWVsZE1lc3NhZ2VcIj5cbiAgICA8c2xvdCBuYW1lPVwiZmllbGQtbWVzc2FnZVwiPjwvc2xvdD5cbiAgPC9kaXY+XG48L2Rpdj5cblxuPHNjcmlwdD5cbiAgZXhwb3J0IGxldCB0aGVtZSA9ICcnO1xuICBleHBvcnQgbGV0IG9wdGlvbmFsID0gZmFsc2U7XG48L3NjcmlwdD5cbiJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFHRSxHQUFHLEFBQUMsQ0FBQyxBQUFDLE9BQU8sQ0FBRSxLQUFLLEFBQUUsQ0FBQyJ9 */</style>`;

View File

@@ -0,0 +1,3 @@
{
"inputSourceMap": true
}

View File

@@ -0,0 +1,5 @@
// https://github.com/babel/babel/issues/9790
const comment = `//# sourceMappingURL=${path.basename(sourceMapFilename)}`; // https://github.com/babel/babel/issues/9956
this.shadowRoot.innerHTML = `<style>div{display:block}
/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZmllbGQuaHRtbCIsInNvdXJjZXMiOlsiZmllbGQuaHRtbCJdLCJzb3VyY2VzQ29udGVudCI6WyI8c3ZlbHRlOm9wdGlvbnMgdGFnPVwiZGxzLWZpZWxkXCIgLz5cblxuPHN0eWxlPlxuICBkaXYgeyBkaXNwbGF5OiBibG9jazsgfVxuPC9zdHlsZT5cblxuPGRpdiBjbGFzcz1cImZpZWxkXCI+XG4gIDxkaXYgY2xhc3M9XCJfZmllbGRMYWJlbExheW91dFwiPlxuICAgIDxkaXYgY2xhc3M9XCJmaWVsZExhYmVsXCI+XG4gICAgICA8c2xvdCBuYW1lPVwiZmllbGQtbGFiZWxcIj48L3Nsb3Q+XG4gICAgPC9kaXY+XG4gICAgPGRpdiBjbGFzcz1cImZpZWxkT3B0aW9uYWxcIiBjbGFzczpvcHRpb25hbD5cbiAgICAgIE9wdGlvbmFsXG4gICAgPC9kaXY+XG4gIDwvZGl2PlxuICA8ZGl2IGNsYXNzPVwiZmllbGREZXRhaWxcIj5cbiAgICA8c2xvdCBuYW1lPVwiZmllbGQtZGV0YWlsXCI+PC9zbG90PlxuICA8L2Rpdj5cbiAgPGRpdiBjbGFzcz1cImZpZWxkQ29udHJvbFwiPlxuICAgIDxzbG90IG5hbWU9XCJmaWVsZC1jb250cm9sXCI+PC9zbG90PlxuICAgIDxzbG90Pjwvc2xvdD5cbiAgPC9kaXY+XG4gIDxkaXYgY2xhc3M9XCJmaWVsZE1lc3NhZ2VcIj5cbiAgICA8c2xvdCBuYW1lPVwiZmllbGQtbWVzc2FnZVwiPjwvc2xvdD5cbiAgPC9kaXY+XG48L2Rpdj5cblxuPHNjcmlwdD5cbiAgZXhwb3J0IGxldCB0aGVtZSA9ICcnO1xuICBleHBvcnQgbGV0IG9wdGlvbmFsID0gZmFsc2U7XG48L3NjcmlwdD5cbiJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFHRSxHQUFHLEFBQUMsQ0FBQyxBQUFDLE9BQU8sQ0FBRSxLQUFLLEFBQUUsQ0FBQyJ9 */</style>`;

View File

@@ -1,6 +1,6 @@
{
"name": "@babel/generator",
"version": "7.5.0",
"version": "7.6.0",
"description": "Turns an AST into code.",
"author": "Sebastian McKenzie <sebmck@gmail.com>",
"homepage": "https://babeljs.io/",
@@ -14,14 +14,14 @@
"lib"
],
"dependencies": {
"@babel/types": "^7.5.0",
"@babel/types": "^7.6.0",
"jsesc": "^2.5.1",
"lodash": "^4.17.11",
"lodash": "^4.17.13",
"source-map": "^0.5.0",
"trim-right": "^1.0.1"
},
"devDependencies": {
"@babel/helper-fixtures": "^7.4.4",
"@babel/parser": "^7.5.0"
"@babel/helper-fixtures": "^7.6.0",
"@babel/parser": "^7.6.0"
}
}

View File

@@ -264,3 +264,8 @@ export function PrivateName(node: Object) {
this.token("#");
this.print(node.id, node);
}
export function V8IntrinsicIdentifier(node: Object) {
this.token("%");
this.word(node.name);
}

View File

@@ -67,12 +67,14 @@ export function TSQualifiedName(node) {
export function TSCallSignatureDeclaration(node) {
this.tsPrintSignatureDeclarationBase(node);
this.token(";");
}
export function TSConstructSignatureDeclaration(node) {
this.word("new");
this.space();
this.tsPrintSignatureDeclarationBase(node);
this.token(";");
}
export function TSPropertySignature(node) {
@@ -127,6 +129,9 @@ export function TSIndexSignature(node) {
export function TSAnyKeyword() {
this.word("any");
}
export function TSBigIntKeyword() {
this.word("bigint");
}
export function TSUnknownKeyword() {
this.word("unknown");
}

View File

@@ -97,5 +97,18 @@ export function needsParens(node, parent, printStack) {
if (isOrHasCallExpression(node)) return true;
}
/* this check is for NullishCoalescing being used with LogicalOperators like && and ||
* For example when someone creates an ast programmaticaly like this
* t.logicalExpression(
* "??",
* t.logicalExpression("||", t.identifier("a"), t.identifier("b")),
* t.identifier("c"),
* );
* In the example above the AST is equivalent to writing a || b ?? c
* This is incorrect because NullishCoalescing when used with LogicalExpressions should have parenthesis
* The correct syntax is (a || b) ?? c, that is why we need parenthesis in this case
*/
if (t.isLogicalExpression(node) && parent.operator === "??") return true;
return find(expandedParens, node, parent, printStack);
}

View File

@@ -1,3 +1,3 @@
{
"parserOpts": {"createParenthesizedExpressions": true}
"parserOpts": { "createParenthesizedExpressions": true }
}

View File

@@ -0,0 +1 @@
%DebugPrint(foo);

View File

@@ -0,0 +1,3 @@
{
"plugins": ["v8intrinsic"]
}

View File

@@ -0,0 +1 @@
%DebugPrint(foo);

View File

@@ -1,4 +1,5 @@
foo ||bar;
(x => x)|| bar;
(function a(x){return x;})|| 2;
0||(function(){return alpha;});
0||(function(){return alpha;});
a ?? (b || c);

View File

@@ -0,0 +1,3 @@
{
"plugins": ["nullishCoalescingOperator"]
}

View File

@@ -7,4 +7,6 @@ foo || bar;
0 || function () {
return alpha;
};
};
a ?? (b || c);

View File

@@ -1,3 +1,4 @@
interface I {
(x: number): void;
(x: string): void;
}

View File

@@ -1,3 +1,4 @@
interface I {
(x: number): void
}
(x: number): void;
(x: string): void;
}

View File

@@ -1,3 +1,4 @@
interface I {
new (x: number): void;
new (x: string): void;
}

View File

@@ -1,3 +1,4 @@
interface I {
new (x: number): void
}
new (x: number): void;
new (x: string): void;
}

View File

@@ -298,6 +298,31 @@ describe("generation", function() {
});
describe("programmatic generation", function() {
it("should add parenthesis when NullishCoalescing is used along with ||", function() {
// https://github.com/babel/babel/issues/10260
const nullishCoalesc = t.logicalExpression(
"??",
t.logicalExpression("||", t.identifier("a"), t.identifier("b")),
t.identifier("c"),
);
const output = generate(nullishCoalesc).code;
expect(output).toBe(`(a || b) ?? c`);
});
it("should add parenthesis when NullishCoalesing is used with &&", function() {
const nullishCoalesc = t.logicalExpression(
"??",
t.identifier("a"),
t.logicalExpression(
"&&",
t.identifier("b"),
t.logicalExpression("&&", t.identifier("c"), t.identifier("d")),
),
);
const output = generate(nullishCoalesc).code;
expect(output).toBe(`a ?? (b && c && d)`);
});
it("numeric member expression", function() {
// Should not generate `0.foo`
const mem = t.memberExpression(

View File

@@ -1,6 +1,6 @@
{
"name": "@babel/helper-create-class-features-plugin",
"version": "7.5.0",
"version": "7.6.0",
"author": "The Babel Team (https://babeljs.io/team)",
"license": "MIT",
"description": "Compile class public and private fields, private methods and decorators to ES6",
@@ -15,17 +15,17 @@
],
"dependencies": {
"@babel/helper-function-name": "^7.1.0",
"@babel/helper-member-expression-to-functions": "^7.0.0",
"@babel/helper-member-expression-to-functions": "^7.5.5",
"@babel/helper-optimise-call-expression": "^7.0.0",
"@babel/helper-plugin-utils": "^7.0.0",
"@babel/helper-replace-supers": "^7.4.4",
"@babel/helper-replace-supers": "^7.5.5",
"@babel/helper-split-export-declaration": "^7.4.4"
},
"peerDependencies": {
"@babel/core": "^7.0.0"
},
"devDependencies": {
"@babel/core": "^7.5.0",
"@babel/core": "^7.6.0",
"@babel/helper-plugin-test-runner": "^7.0.0"
}
}

View File

@@ -66,12 +66,6 @@ export function verifyUsedFeatures(path, file) {
if (!hasFeature(file, FEATURES.privateMethods)) {
throw path.buildCodeFrameError("Class private methods are not enabled.");
}
if (path.node.static && path.node.kind !== "method") {
throw path.buildCodeFrameError(
"@babel/plugin-class-features doesn't support class static private accessors yet.",
);
}
}
if (

View File

@@ -44,6 +44,7 @@ export function buildPrivateNamesNodes(privateNamesMap, loose, state) {
// because static fields are directly assigned to a variable in the
// buildPrivateStaticFieldInitSpec function.
const { id, static: isStatic, method: isMethod, getId, setId } = value;
const isAccessor = getId || setId;
if (loose) {
initNodes.push(
template.statement.ast`
@@ -51,7 +52,7 @@ export function buildPrivateNamesNodes(privateNamesMap, loose, state) {
`,
);
} else if (isMethod && !isStatic) {
if (getId || setId) {
if (isAccessor) {
initNodes.push(template.statement.ast`var ${id} = new WeakMap();`);
} else {
initNodes.push(template.statement.ast`var ${id} = new WeakSet();`);
@@ -140,11 +141,13 @@ const privateNameHandlerSpec = {
getId,
setId,
} = privateNamesMap.get(name);
const isAccessor = getId || setId;
if (isStatic) {
const helperName = isMethod
? "classStaticPrivateMethodGet"
: "classStaticPrivateFieldSpecGet";
const helperName =
isMethod && !isAccessor
? "classStaticPrivateMethodGet"
: "classStaticPrivateFieldSpecGet";
return t.callExpression(file.addHelper(helperName), [
this.receiver(member),
@@ -154,7 +157,7 @@ const privateNameHandlerSpec = {
}
if (isMethod) {
if (getId || setId) {
if (isAccessor) {
return t.callExpression(file.addHelper("classPrivateFieldGet"), [
this.receiver(member),
t.cloneNode(id),
@@ -180,12 +183,15 @@ const privateNameHandlerSpec = {
static: isStatic,
method: isMethod,
setId,
getId,
} = privateNamesMap.get(name);
const isAccessor = getId || setId;
if (isStatic) {
const helperName = isMethod
? "classStaticPrivateMethodSet"
: "classStaticPrivateFieldSpecSet";
const helperName =
isMethod && !isAccessor
? "classStaticPrivateMethodSet"
: "classStaticPrivateFieldSpecSet";
return t.callExpression(file.addHelper(helperName), [
this.receiver(member),
@@ -211,6 +217,19 @@ const privateNameHandlerSpec = {
]);
},
destructureSet(member) {
const { privateNamesMap, file } = this;
const { name } = member.node.property.id;
const { id } = privateNamesMap.get(name);
return t.memberExpression(
t.callExpression(file.addHelper("classPrivateFieldDestructureSet"), [
this.receiver(member),
t.cloneNode(id),
]),
t.identifier("value"),
);
},
call(member, args) {
// The first access (the get) should do the memo assignment.
this.memoise(member, 1);
@@ -287,9 +306,30 @@ function buildPrivateInstanceFieldInitSpec(ref, prop, privateNamesMap) {
}
function buildPrivateStaticFieldInitSpec(prop, privateNamesMap) {
const { id } = privateNamesMap.get(prop.node.key.id.name);
const value = prop.node.value || prop.scope.buildUndefinedNode();
const privateName = privateNamesMap.get(prop.node.key.id.name);
const { id, getId, setId, initAdded } = privateName;
const isAccessor = getId || setId;
if (!prop.isProperty() && (initAdded || !isAccessor)) return;
if (isAccessor) {
privateNamesMap.set(prop.node.key.id.name, {
...privateName,
initAdded: true,
});
return template.statement.ast`
var ${id.name} = {
// configurable is false by default
// enumerable is false by default
// writable is false by default
get: ${getId ? getId.name : prop.scope.buildUndefinedNode()},
set: ${setId ? setId.name : prop.scope.buildUndefinedNode()}
}
`;
}
const value = prop.node.value || prop.scope.buildUndefinedNode();
return template.statement.ast`
var ${id} = {
// configurable is false by default
@@ -315,76 +355,44 @@ function buildPrivateMethodInitLoose(ref, prop, privateNamesMap) {
});
`;
}
if (getId || setId) {
const isAccessor = getId || setId;
if (isAccessor) {
privateNamesMap.set(prop.node.key.id.name, {
...privateName,
initAdded: true,
});
if (getId && setId) {
return template.statement.ast`
Object.defineProperty(${ref}, ${id}, {
// configurable is false by default
// enumerable is false by default
// writable is false by default
get: ${getId.name},
set: ${setId.name}
});
`;
} else if (getId && !setId) {
return template.statement.ast`
Object.defineProperty(${ref}, ${id}, {
// configurable is false by default
// enumerable is false by default
// writable is false by default
get: ${getId.name}
});
`;
} else if (!getId && setId) {
return template.statement.ast`
Object.defineProperty(${ref}, ${id}, {
// configurable is false by default
// enumerable is false by default
// writable is false by default
set: ${setId.name}
});
`;
}
return template.statement.ast`
Object.defineProperty(${ref}, ${id}, {
// configurable is false by default
// enumerable is false by default
// writable is false by default
get: ${getId ? getId.name : prop.scope.buildUndefinedNode()},
set: ${setId ? setId.name : prop.scope.buildUndefinedNode()}
});
`;
}
}
function buildPrivateInstanceMethodInitSpec(ref, prop, privateNamesMap) {
const privateName = privateNamesMap.get(prop.node.key.id.name);
const { id, getId, setId, initAdded } = privateName;
if (initAdded) return;
if (getId || setId) {
const isAccessor = getId || setId;
if (isAccessor) {
privateNamesMap.set(prop.node.key.id.name, {
...privateName,
initAdded: true,
});
if (getId && setId) {
return template.statement.ast`
${id}.set(${ref}, {
get: ${getId.name},
set: ${setId.name}
});
`;
} else if (getId && !setId) {
return template.statement.ast`
${id}.set(${ref}, {
get: ${getId.name}
});
`;
} else if (!getId && setId) {
return template.statement.ast`
${id}.set(${ref}, {
set: ${setId.name}
});
`;
}
return template.statement.ast`
${id}.set(${ref}, {
get: ${getId ? getId.name : prop.scope.buildUndefinedNode()},
set: ${setId ? setId.name : prop.scope.buildUndefinedNode()}
});
`;
}
return template.statement.ast`${id}.add(${ref})`;
}
@@ -416,7 +424,29 @@ function buildPublicFieldInitSpec(ref, prop, state) {
}
function buildPrivateStaticMethodInitLoose(ref, prop, state, privateNamesMap) {
const { id, methodId } = privateNamesMap.get(prop.node.key.id.name);
const privateName = privateNamesMap.get(prop.node.key.id.name);
const { id, methodId, getId, setId, initAdded } = privateName;
if (initAdded) return;
const isAccessor = getId || setId;
if (isAccessor) {
privateNamesMap.set(prop.node.key.id.name, {
...privateName,
initAdded: true,
});
return template.statement.ast`
Object.defineProperty(${ref}, ${id}, {
// configurable is false by default
// enumerable is false by default
// writable is false by default
get: ${getId ? getId.name : prop.scope.buildUndefinedNode()},
set: ${setId ? setId.name : prop.scope.buildUndefinedNode()}
})
`;
}
return template.statement.ast`
Object.defineProperty(${ref}, ${id}, {
// configurable is false by default
@@ -602,14 +632,14 @@ export function buildFieldsInitNodes(
case isStatic && isPrivate && isMethod && !loose:
needsClassRef = true;
staticNodes.push(
buildPrivateStaticFieldInitSpec(prop, privateNamesMap),
);
staticNodes.unshift(
buildPrivateMethodDeclaration(prop, privateNamesMap, loose),
);
break;
case isStatic && isPrivate && isMethod && loose:
needsClassRef = true;
staticNodes.push(
buildPrivateMethodDeclaration(prop, privateNamesMap, loose),
);
staticNodes.push(
buildPrivateStaticMethodInitLoose(
t.cloneNode(ref),
@@ -618,6 +648,9 @@ export function buildFieldsInitNodes(
privateNamesMap,
),
);
staticNodes.unshift(
buildPrivateMethodDeclaration(prop, privateNamesMap, loose),
);
break;
case isInstance && isPublic && isField && loose:
instanceNodes.push(buildPublicFieldInitLoose(t.thisExpression(), prop));
@@ -633,7 +666,7 @@ export function buildFieldsInitNodes(
}
return {
staticNodes,
staticNodes: staticNodes.filter(Boolean),
instanceNodes: instanceNodes.filter(Boolean),
wrapClass(path) {
for (const prop of props) {

View File

@@ -1,5 +1,3 @@
{
"plugins": [
["proposal-private-methods", { "loose": false }]
]
"plugins": [["proposal-private-methods", { "loose": false }]]
}

View File

@@ -1,5 +1,3 @@
{
"plugins": [
["proposal-private-methods", { "loose": true }]
]
"plugins": [["proposal-private-methods", { "loose": true }]]
}

View File

@@ -1,6 +1,6 @@
{
"name": "@babel/helper-define-map",
"version": "7.4.4",
"version": "7.5.5",
"description": "Helper function to define a map",
"repository": "https://github.com/babel/babel/tree/master/packages/babel-helper-define-map",
"license": "MIT",
@@ -10,7 +10,7 @@
"main": "lib/index.js",
"dependencies": {
"@babel/helper-function-name": "^7.1.0",
"@babel/types": "^7.4.4",
"lodash": "^4.17.11"
"@babel/types": "^7.5.5",
"lodash": "^4.17.13"
}
}

View File

@@ -1,6 +1,6 @@
{
"name": "@babel/helper-fixtures",
"version": "7.4.4",
"version": "7.6.0",
"description": "Helper function to support fixtures",
"author": "Sebastian McKenzie <sebmck@gmail.com>",
"license": "MIT",
@@ -10,7 +10,7 @@
"repository": "https://github.com/babel/babel/tree/master/packages/babel-helper-fixtures",
"main": "lib/index.js",
"dependencies": {
"lodash": "^4.17.11",
"lodash": "^4.17.13",
"semver": "^5.3.0",
"try-resolve": "^1.0.0"
}

View File

@@ -120,6 +120,8 @@ export default function get(entryLoc): Array<Suite> {
const expectLoc =
findFile(taskDir + "/output", true /* allowJSON */) ||
taskDir + "/output.js";
const stdoutLoc = taskDir + "/stdout.txt";
const stderrLoc = taskDir + "/stderr.txt";
const actualLocAlias =
suiteName + "/" + taskName + "/" + path.basename(actualLoc);
@@ -146,6 +148,10 @@ export default function get(entryLoc): Array<Suite> {
title: humanize(taskName, true),
disabled: taskName[0] === ".",
options: taskOpts,
validateLogs: taskOpts.validateLogs,
ignoreOutput: taskOpts.ignoreOutput,
stdout: { loc: stdoutLoc, code: readFile(stdoutLoc) },
stderr: { loc: stderrLoc, code: readFile(stderrLoc) },
exec: {
loc: execLoc,
code: readFile(execLoc),
@@ -169,9 +175,7 @@ export default function get(entryLoc): Array<Suite> {
if (minimumVersion == null) {
throw new Error(
`'minNodeVersion' has invalid semver format: ${
taskOpts.minNodeVersion
}`,
`'minNodeVersion' has invalid semver format: ${taskOpts.minNodeVersion}`,
);
}
@@ -224,6 +228,30 @@ export default function get(entryLoc): Array<Suite> {
);
}
}
if (!test.validateLogs && (test.stdout.code || test.stderr.code)) {
throw new Error(
"stdout.txt and stderr.txt are only allowed when the 'validateLogs' option is enabled: " +
(test.stdout.code ? stdoutLoc : stderrLoc),
);
}
if (test.options.ignoreOutput) {
if (test.expect.code) {
throw new Error(
"Test cannot ignore its output and also validate it: " + expectLoc,
);
}
if (!test.validateLogs) {
throw new Error(
"ignoreOutput can only be used when validateLogs is true: " +
taskOptsLoc,
);
}
}
// Delete to avoid option validation error
delete test.options.validateLogs;
delete test.options.ignoreOutput;
}
}

View File

@@ -1,6 +1,6 @@
{
"name": "@babel/helper-member-expression-to-functions",
"version": "7.0.0",
"version": "7.5.5",
"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 <justin@ridgewell.name>",
"dependencies": {
"@babel/types": "^7.0.0"
"@babel/types": "^7.5.5"
}
}

View File

@@ -100,6 +100,34 @@ const handle = {
return;
}
// { KEY: MEMBER } = OBJ -> { KEY: _destructureSet(MEMBER) } = OBJ
// { KEY: MEMBER = _VALUE } = OBJ -> { KEY: _destructureSet(MEMBER) = _VALUE } = OBJ
// {...MEMBER} -> {..._destructureSet(MEMBER)}
//
// [MEMBER] = ARR -> [_destructureSet(MEMBER)] = ARR
// [MEMBER = _VALUE] = ARR -> [_destructureSet(MEMBER) = _VALUE] = ARR
// [...MEMBER] -> [..._destructureSet(MEMBER)]
if (
// { KEY: MEMBER } = OBJ
(parentPath.isObjectProperty({ value: node }) &&
parentPath.parentPath.isObjectPattern()) ||
// { KEY: MEMBER = _VALUE } = OBJ
(parentPath.isAssignmentPattern({ left: node }) &&
parentPath.parentPath.isObjectProperty({ value: parent }) &&
parentPath.parentPath.parentPath.isObjectPattern()) ||
// [MEMBER] = ARR
parentPath.isArrayPattern() ||
// [MEMBER = _VALUE] = ARR
(parentPath.isAssignmentPattern({ left: node }) &&
parentPath.parentPath.isArrayPattern()) ||
// {...MEMBER}
// [...MEMBER]
parentPath.isRestElement()
) {
member.replaceWith(this.destructureSet(member));
return;
}
// MEMBER -> _get(MEMBER)
member.replaceWith(this.get(member));
},

View File

@@ -1,6 +1,6 @@
{
"name": "@babel/helper-module-transforms",
"version": "7.4.4",
"version": "7.5.5",
"description": "Babel helper functions for implementing ES6 module transformations",
"author": "Logan Smyth <loganfsmyth@gmail.com>",
"homepage": "https://babeljs.io/",
@@ -15,7 +15,7 @@
"@babel/helper-simple-access": "^7.1.0",
"@babel/helper-split-export-declaration": "^7.4.4",
"@babel/template": "^7.4.4",
"@babel/types": "^7.4.4",
"lodash": "^4.17.11"
"@babel/types": "^7.5.5",
"lodash": "^4.17.13"
}
}

View File

@@ -1,6 +1,6 @@
{
"name": "@babel/helper-regex",
"version": "7.4.4",
"version": "7.5.5",
"description": "Helper function to check for literal RegEx",
"repository": "https://github.com/babel/babel/tree/master/packages/babel-helper-regex",
"license": "MIT",
@@ -9,6 +9,6 @@
},
"main": "lib/index.js",
"dependencies": {
"lodash": "^4.17.11"
"lodash": "^4.17.13"
}
}

View File

@@ -1,6 +1,6 @@
{
"name": "@babel/helper-replace-supers",
"version": "7.4.4",
"version": "7.5.5",
"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.0.0",
"@babel/helper-member-expression-to-functions": "^7.5.5",
"@babel/helper-optimise-call-expression": "^7.0.0",
"@babel/traverse": "^7.4.4",
"@babel/types": "^7.4.4"
"@babel/traverse": "^7.5.5",
"@babel/types": "^7.5.5"
}
}

View File

@@ -125,6 +125,12 @@ const specHandlers = {
]);
},
destructureSet(superMember) {
throw superMember.buildCodeFrameError(
`Destructuring to a super field is not supported yet.`,
);
},
call(superMember, args) {
return optimiseCall(this.get(superMember), t.thisExpression(), args);
},
@@ -174,6 +180,13 @@ const looseHandlers = {
value,
);
},
destructureSet(superMember) {
const { computed } = superMember.node;
const prop = this.prop(superMember);
return t.memberExpression(t.thisExpression(), prop, computed);
},
};
export default class ReplaceSupers {

View File

@@ -1,6 +1,6 @@
{
"name": "@babel/helper-transform-fixture-test-runner",
"version": "7.5.0",
"version": "7.6.0",
"description": "Transform test runner for @babel/helper-fixtures module",
"author": "Sebastian McKenzie <sebmck@gmail.com>",
"homepage": "https://babeljs.io/",
@@ -11,14 +11,14 @@
"repository": "https://github.com/babel/babel/tree/master/packages/babel-helper-transform-fixture-test-runner",
"main": "lib/index.js",
"dependencies": {
"@babel/code-frame": "^7.0.0",
"@babel/core": "^7.5.0",
"@babel/helper-fixtures": "^7.4.4",
"@babel/polyfill": "^7.4.4",
"@babel/code-frame": "^7.5.5",
"@babel/core": "^7.6.0",
"@babel/helper-fixtures": "^7.6.0",
"@babel/polyfill": "^7.6.0",
"babel-check-duplicated-nodes": "^1.0.0",
"jest": "^24.8.0",
"jest-diff": "^24.8.0",
"lodash": "^4.17.11",
"lodash": "^4.17.13",
"resolve": "^1.3.2",
"source-map": "^0.5.0"
}

View File

@@ -131,11 +131,17 @@ function wrapPackagesArray(type, names, optionsDir) {
}
function run(task) {
const actual = task.actual;
const expected = task.expect;
const exec = task.exec;
const opts = task.options;
const optionsDir = task.optionsDir;
const {
actual,
expect: expected,
exec,
options: opts,
optionsDir,
validateLogs,
ignoreOutput,
stdout,
stderr,
} = task;
function getOpts(self) {
const newOpts = merge(
@@ -191,56 +197,67 @@ function run(task) {
}
}
let actualCode = actual.code;
const expectCode = expected.code;
if (!execCode || actualCode) {
result = babel.transform(actualCode, getOpts(actual));
const expectedCode = result.code.replace(
escapeRegExp(path.resolve(__dirname, "../../../")),
"<CWD>",
);
const inputCode = actual.code;
const expectedCode = expected.code;
if (!execCode || inputCode) {
const actualLogs = { stdout: "", stderr: "" };
let restoreSpies = null;
if (validateLogs) {
const spy1 = jest.spyOn(console, "log").mockImplementation(msg => {
actualLogs.stdout += `${msg}\n`;
});
const spy2 = jest.spyOn(console, "warn").mockImplementation(msg => {
actualLogs.stderr += `${msg}\n`;
});
restoreSpies = () => {
spy1.mockRestore();
spy2.mockRestore();
};
}
result = babel.transform(inputCode, getOpts(actual));
if (restoreSpies) restoreSpies();
const outputCode = normalizeOutput(result.code);
checkDuplicatedNodes(babel, result.ast);
if (
!expected.code &&
expectedCode &&
!opts.throws &&
fs.statSync(path.dirname(expected.loc)).isDirectory() &&
!process.env.CI
) {
const expectedFile = expected.loc.replace(
/\.m?js$/,
result.sourceType === "module" ? ".mjs" : ".js",
);
console.log(`New test file created: ${expectedFile}`);
fs.writeFileSync(expectedFile, `${expectedCode}\n`);
if (expected.loc !== expectedFile) {
try {
fs.unlinkSync(expected.loc);
} catch (e) {}
}
} else {
actualCode = expectedCode.trim();
try {
expect(actualCode).toEqualFile({
filename: expected.loc,
code: expectCode,
});
} catch (e) {
if (!process.env.OVERWRITE) throw e;
console.log(`Updated test file: ${expected.loc}`);
fs.writeFileSync(expected.loc, `${expectedCode}\n`);
}
if (actualCode) {
expect(expected.loc).toMatch(
result.sourceType === "module" ? /\.mjs$/ : /\.js$/,
if (!ignoreOutput) {
if (
!expected.code &&
outputCode &&
!opts.throws &&
fs.statSync(path.dirname(expected.loc)).isDirectory() &&
!process.env.CI
) {
const expectedFile = expected.loc.replace(
/\.m?js$/,
result.sourceType === "module" ? ".mjs" : ".js",
);
console.log(`New test file created: ${expectedFile}`);
fs.writeFileSync(expectedFile, `${outputCode}\n`);
if (expected.loc !== expectedFile) {
try {
fs.unlinkSync(expected.loc);
} catch (e) {}
}
} else {
validateFile(outputCode, expected.loc, expectedCode);
if (inputCode) {
expect(expected.loc).toMatch(
result.sourceType === "module" ? /\.mjs$/ : /\.js$/,
);
}
}
}
if (validateLogs) {
validateFile(normalizeOutput(actualLogs.stdout), stdout.loc, stdout.code);
validateFile(normalizeOutput(actualLogs.stderr), stderr.loc, stderr.code);
}
}
if (task.sourceMap) {
@@ -263,6 +280,29 @@ function run(task) {
}
}
function validateFile(actualCode, expectedLoc, expectedCode) {
try {
expect(actualCode).toEqualFile({
filename: expectedLoc,
code: expectedCode,
});
} catch (e) {
if (!process.env.OVERWRITE) throw e;
console.log(`Updated test file: ${expectedLoc}`);
fs.writeFileSync(expectedLoc, `${actualCode}\n`);
}
}
function normalizeOutput(code) {
return code
.trim()
.replace(
new RegExp(escapeRegExp(path.resolve(__dirname, "../../../")), "g"),
"<CWD>",
);
}
const toEqualFile = () => ({
compare: (actual, { filename, code }) => {
const pass = actual === code;

View File

@@ -1,6 +1,6 @@
{
"name": "@babel/helpers",
"version": "7.5.2",
"version": "7.6.0",
"description": "Collection of helper functions used by Babel transforms.",
"author": "Sebastian McKenzie <sebmck@gmail.com>",
"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.4.4",
"@babel/traverse": "^7.5.0",
"@babel/types": "^7.5.0"
"@babel/template": "^7.6.0",
"@babel/traverse": "^7.6.0",
"@babel/types": "^7.6.0"
},
"devDependencies": {
"@babel/helper-plugin-test-runner": "^7.0.0"

View File

@@ -47,15 +47,6 @@ helpers.jsx = helper("7.0.0-beta.0")`
children: void 0,
};
}
if (props && defaultProps) {
for (var propName in defaultProps) {
if (props[propName] === void 0) {
props[propName] = defaultProps[propName];
}
}
} else if (!props) {
props = defaultProps || {};
}
if (childrenLength === 1) {
props.children = children;
@@ -67,6 +58,16 @@ helpers.jsx = helper("7.0.0-beta.0")`
props.children = childArray;
}
if (props && defaultProps) {
for (var propName in defaultProps) {
if (props[propName] === void 0) {
props[propName] = defaultProps[propName];
}
}
} else if (!props) {
props = defaultProps || {};
}
return {
$$typeof: REACT_ELEMENT_TYPE,
type: type,
@@ -409,32 +410,37 @@ helpers.objectSpread = helper("7.0.0-beta.0")`
helpers.objectSpread2 = helper("7.5.0")`
import defineProperty from "defineProperty";
// This function is different to "Reflect.ownKeys". The enumerableOnly
// filters on symbol properties only. Returned string properties are always
// enumerable. It is good to use in objectSpread.
function ownKeys(object, enumerableOnly) {
var keys = Object.keys(object);
if (Object.getOwnPropertySymbols) {
keys.push.apply(keys, Object.getOwnPropertySymbols(object));
var symbols = Object.getOwnPropertySymbols(object);
if (enumerableOnly) symbols = symbols.filter(function (sym) {
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
});
keys.push.apply(keys, symbols);
}
if (enumerableOnly) keys = keys.filter(function (sym) {
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
});
return keys;
}
export default function _objectSpread2(target) {
for (var i = 1; i < arguments.length; i++) {
var source = (arguments[i] != null) ? arguments[i] : {};
if (i % 2) {
var source = (arguments[i] != null) ? arguments[i] : {};
ownKeys(source, true).forEach(function (key) {
defineProperty(target, key, source[key]);
});
} else if (Object.getOwnPropertyDescriptors) {
Object.defineProperties(target, Object.getOwnPropertyDescriptors(arguments[i]));
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
} else {
ownKeys(source).forEach(function (key) {
Object.defineProperty(
target,
key,
Object.getOwnPropertyDescriptor(arguments[i], key)
Object.getOwnPropertyDescriptor(source, key)
);
});
}
@@ -587,7 +593,7 @@ helpers.wrapNativeSuper = helper("7.0.0-beta.0")`
helpers.instanceof = helper("7.0.0-beta.0")`
export default function _instanceof(left, right) {
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
return right[Symbol.hasInstance](left);
return !!right[Symbol.hasInstance](left);
} else {
return left instanceof right;
}
@@ -601,28 +607,45 @@ helpers.interopRequireDefault = helper("7.0.0-beta.0")`
`;
helpers.interopRequireWildcard = helper("7.0.0-beta.0")`
function _getRequireWildcardCache() {
if (typeof WeakMap !== "function") return null;
var cache = new WeakMap();
_getRequireWildcardCache = function () { return cache; };
return cache;
}
export default function _interopRequireWildcard(obj) {
if (obj && obj.__esModule) {
return obj;
} else {
var newObj = {};
if (obj != null) {
for (var key in obj) {
if (Object.prototype.hasOwnProperty.call(obj, key)) {
var desc = Object.defineProperty && Object.getOwnPropertyDescriptor
? Object.getOwnPropertyDescriptor(obj, key)
: {};
if (desc.get || desc.set) {
Object.defineProperty(newObj, key, desc);
} else {
newObj[key] = obj[key];
}
}
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;
return newObj;
}
newObj.default = obj;
if (cache) {
cache.set(obj, newObj);
}
return newObj;
}
`;
@@ -715,7 +738,6 @@ helpers.superPropBase = helper("7.0.0-beta.0")`
`;
helpers.get = helper("7.0.0-beta.0")`
import getPrototypeOf from "getPrototypeOf";
import superPropBase from "superPropBase";
export default function _get(target, property, receiver) {
@@ -740,7 +762,6 @@ helpers.get = helper("7.0.0-beta.0")`
`;
helpers.set = helper("7.0.0-beta.0")`
import getPrototypeOf from "getPrototypeOf";
import superPropBase from "superPropBase";
import defineProperty from "defineProperty";
@@ -814,18 +835,6 @@ helpers.taggedTemplateLiteralLoose = helper("7.0.0-beta.0")`
}
`;
helpers.temporalRef = helper("7.0.0-beta.0")`
import undef from "temporalUndefined";
export default function _temporalRef(val, name) {
if (val === undef) {
throw new ReferenceError(name + " is not defined - temporal dead zone");
} else {
return val;
}
}
`;
helpers.readOnlyError = helper("7.0.0-beta.0")`
export default function _readOnlyError(name) {
throw new Error("\\"" + name + "\\" is read-only");
@@ -839,7 +848,24 @@ helpers.classNameTDZError = helper("7.0.0-beta.0")`
`;
helpers.temporalUndefined = helper("7.0.0-beta.0")`
export default {};
// This function isn't mean to be called, but to be used as a reference.
// We can't use a normal object because it isn't hoisted.
export default function _temporalUndefined() {}
`;
helpers.tdz = helper("7.5.5")`
export default function _tdzError(name) {
throw new ReferenceError(name + " is not defined - temporal dead zone");
}
`;
helpers.temporalRef = helper("7.0.0-beta.0")`
import undef from "temporalUndefined";
import err from "tdz";
export default function _temporalRef(val, name) {
return val === undef ? err(name) : val;
}
`;
helpers.slicedToArray = helper("7.0.0-beta.0")`
@@ -917,7 +943,9 @@ helpers.iterableToArrayLimit = helper("7.0.0-beta.0")`
// _e = _iteratorError
// _i = _iterator
// _s = _step
if (!(
Symbol.iterator in Object(arr) || Object.prototype.toString.call(arr) === "[object Arguments]"
)) { return }
var _arr = [];
var _n = true;
var _d = false;
@@ -943,6 +971,9 @@ helpers.iterableToArrayLimit = helper("7.0.0-beta.0")`
helpers.iterableToArrayLimitLoose = helper("7.0.0-beta.0")`
export default function _iterableToArrayLimitLoose(arr, i) {
if (!(
Symbol.iterator in Object(arr) || Object.prototype.toString.call(arr) === "[object Arguments]"
)) { return }
var _arr = [];
for (var _iterator = arr[Symbol.iterator](), _step; !(_step = _iterator.next()).done;) {
_arr.push(_step.value);
@@ -1118,11 +1149,42 @@ helpers.classPrivateFieldSet = helper("7.0.0-beta.0")`
}
`;
helpers.classPrivateFieldDestructureSet = helper("7.4.4")`
export default function _classPrivateFieldDestructureSet(receiver, privateMap) {
if (!privateMap.has(receiver)) {
throw new TypeError("attempted to set private field on non-instance");
}
var descriptor = privateMap.get(receiver);
if (descriptor.set) {
if (!("__destrObj" in descriptor)) {
descriptor.__destrObj = {
set value(v) {
descriptor.set.call(receiver, v)
},
};
}
return descriptor.__destrObj;
} else {
if (!descriptor.writable) {
// This should only throw in strict mode, but class bodies are
// always strict and private fields can only be used inside
// class bodies.
throw new TypeError("attempted to set read only private field");
}
return descriptor;
}
}
`;
helpers.classStaticPrivateFieldSpecGet = helper("7.0.2")`
export default function _classStaticPrivateFieldSpecGet(receiver, classConstructor, descriptor) {
if (receiver !== classConstructor) {
throw new TypeError("Private static access of wrong provenance");
}
if (descriptor.get) {
return descriptor.get.call(receiver);
}
return descriptor.value;
}
`;
@@ -1132,13 +1194,18 @@ helpers.classStaticPrivateFieldSpecSet = helper("7.0.2")`
if (receiver !== classConstructor) {
throw new TypeError("Private static access of wrong provenance");
}
if (!descriptor.writable) {
// This should only throw in strict mode, but class bodies are
// always strict and private fields can only be used inside
// class bodies.
throw new TypeError("attempted to set read only private field");
if (descriptor.set) {
descriptor.set.call(receiver, value);
} else {
if (!descriptor.writable) {
// This should only throw in strict mode, but class bodies are
// always strict and private fields can only be used inside
// class bodies.
throw new TypeError("attempted to set read only private field");
}
descriptor.value = value;
}
descriptor.value = value;
return value;
}
`;
@@ -1855,16 +1922,17 @@ helpers.wrapRegExp = helper("7.2.6")`
export default function _wrapRegExp(re, groups) {
_wrapRegExp = function(re, groups) {
return new BabelRegExp(re, groups);
return new BabelRegExp(re, undefined, groups);
};
var _RegExp = wrapNativeSuper(RegExp);
var _super = RegExp.prototype;
var _groups = new WeakMap();
function BabelRegExp(re, groups) {
var _this = _RegExp.call(this, re);
_groups.set(_this, groups);
function BabelRegExp(re, flags, groups) {
var _this = _RegExp.call(this, re, flags);
// if the regex is recreated with 'g' flag
_groups.set(_this, groups || _groups.get(re));
return _this;
}
inherits(BabelRegExp, _RegExp);

View File

@@ -280,6 +280,10 @@ export function getDependencies(name: string): $ReadOnlyArray<string> {
return Array.from(loadHelper(name).dependencies.values());
}
export function ensure(name: string) {
loadHelper(name);
}
export const list = Object.keys(helpers)
.map(name => name.replace(/^_/, ""))
.filter(name => name !== "__esModule");

View File

@@ -1,6 +1,6 @@
{
"name": "@babel/node",
"version": "7.5.0",
"version": "7.6.1",
"description": "Babel command line",
"author": "Sebastian McKenzie <sebmck@gmail.com>",
"homepage": "https://babeljs.io/",
@@ -19,10 +19,10 @@
"compiler"
],
"dependencies": {
"@babel/polyfill": "^7.0.0",
"@babel/register": "^7.0.0",
"@babel/polyfill": "^7.6.0",
"@babel/register": "^7.6.0",
"commander": "^2.8.1",
"lodash": "^4.17.11",
"lodash": "^4.17.13",
"node-environment-flags": "^1.0.5",
"v8flags": "^3.1.1"
},
@@ -30,8 +30,8 @@
"@babel/core": "^7.0.0-0"
},
"devDependencies": {
"@babel/core": "^7.5.0",
"@babel/helper-fixtures": "^7.2.0",
"@babel/core": "^7.6.0",
"@babel/helper-fixtures": "^7.6.0",
"fs-readdir-recursive": "^1.0.0",
"output-file-sync": "^2.0.0"
},

View File

@@ -93,9 +93,6 @@ getV8Flags(function(err, v8Flags) {
}
});
});
process.on("SIGINT", () => {
proc.kill("SIGINT");
process.exit(1);
});
process.on("SIGINT", () => proc.kill("SIGINT"));
}
});

View File

@@ -77,7 +77,7 @@ const assertTest = function(stdout, stderr, opts) {
const actualFiles = readDir(path.join(tmpLoc));
Object.keys(actualFiles).forEach(function(filename) {
if (!opts.inFiles.hasOwnProperty(filename)) {
if (!Object.prototype.hasOwnProperty.call(opts.inFiles, filename)) {
const expected = opts.outFiles[filename];
const actual = actualFiles[filename];

View File

@@ -898,6 +898,54 @@ interface BindExpression <: Expression {
If `object` is `null`, then `callee` should be a `MemberExpression`.
### Pipeline
These nodes are used by the Smart Pipeline to determine the type of the expression in a Pipeline Operator Expression. The F# Pipeline uses simple `BinaryExpression`s.
#### PipelineBody
```js
interface PipelineBody <: NodeBase {
type: "PipelineBody";
}
```
#### PipelineBareFunctionBody
```js
interface PipelineBody <: NodeBase {
type: "PipelineBareFunctionBody";
callee: Expression;
}
```
#### PipelineBareConstructorBody
```js
interface PipelineBareConstructorBody <: NodeBase {
type: "PipelineBareConstructorBody";
callee: Expression;
}
```
#### PipelineBareAwaitedFunctionBody
```js
interface PipelineBareConstructorBody <: NodeBase {
type: "PipelineTopicBody";
expression: Expression;
}
```
#### PipelineTopicBody
```js
interface PipelineBareConstructorBody <: NodeBase {
type: "PipelineBareAwaitedFunctionBody";
callee: Expression;
}
```
## ConditionalExpression
```js

View File

@@ -1,6 +1,6 @@
{
"name": "@babel/parser",
"version": "7.5.0",
"version": "7.6.0",
"description": "A JavaScript parser",
"author": "Sebastian McKenzie <sebmck@gmail.com>",
"homepage": "https://babeljs.io/",
@@ -28,8 +28,8 @@
"node": ">=6.0.0"
},
"devDependencies": {
"@babel/code-frame": "^7.0.0",
"@babel/helper-fixtures": "^7.4.4",
"@babel/code-frame": "^7.5.5",
"@babel/helper-fixtures": "^7.6.0",
"charcodes": "^0.2.0",
"unicode-12.0.0": "^0.7.9"
},

View File

@@ -38,6 +38,45 @@ export default class CommentsParser extends BaseParser {
this.state.leadingComments.push(comment);
}
adjustCommentsAfterTrailingComma(node: Node, elements: Node[]) {
if (elements.length === 0) {
return;
}
if (this.state.leadingComments.length === 0) {
return;
}
const lastElement = last(elements);
for (let j = 0; j < this.state.leadingComments.length; j++) {
if (
this.state.leadingComments[j].end < this.state.commentPreviousNode.end
) {
this.state.leadingComments.splice(j, 1);
j--;
}
}
const newTrailingComments = [];
while (this.state.leadingComments.length) {
const leadingComment = this.state.leadingComments.shift();
if (leadingComment.end < node.end) {
newTrailingComments.push(leadingComment);
} else {
if (node.trailingComments === undefined) {
node.trailingComments = [];
}
node.trailingComments.push(leadingComment);
}
}
if (newTrailingComments.length > 0) {
lastElement.trailingComments = newTrailingComments;
} else if (lastElement.trailingComments !== undefined) {
lastElement.trailingComments = [];
}
}
processComment(node: Node): void {
if (node.type === "Program" && node.body.length > 0) return;
@@ -84,60 +123,33 @@ export default class CommentsParser extends BaseParser {
if (!lastChild && firstChild) lastChild = firstChild;
// Attach comments that follow a trailing comma on the last
// property in an object literal or a trailing comma in function arguments
// as trailing comments
if (firstChild && this.state.leadingComments.length > 0) {
const lastComment = last(this.state.leadingComments);
if (firstChild.type === "ObjectProperty") {
if (lastComment.start >= node.start) {
if (this.state.commentPreviousNode) {
for (j = 0; j < this.state.leadingComments.length; j++) {
if (
this.state.leadingComments[j].end <
this.state.commentPreviousNode.end
) {
this.state.leadingComments.splice(j, 1);
j--;
}
}
if (this.state.leadingComments.length > 0) {
firstChild.trailingComments = this.state.leadingComments;
this.state.leadingComments = [];
}
}
}
} else if (
node.type === "CallExpression" &&
node.arguments &&
node.arguments.length
) {
const lastArg = last(node.arguments);
if (
lastArg &&
lastComment.start >= lastArg.start &&
lastComment.end <= node.end
) {
if (this.state.commentPreviousNode) {
for (j = 0; j < this.state.leadingComments.length; j++) {
if (
this.state.leadingComments[j].end <
this.state.commentPreviousNode.end
) {
this.state.leadingComments.splice(j, 1);
j--;
}
}
if (this.state.leadingComments.length > 0) {
lastArg.trailingComments = this.state.leadingComments;
this.state.leadingComments = [];
}
}
}
// Adjust comments that follow a trailing comma on the last element in a
// comma separated list of nodes to be the trailing comments on the last
// element
if (firstChild) {
switch (node.type) {
case "ObjectExpression":
case "ObjectPattern":
this.adjustCommentsAfterTrailingComma(node, node.properties);
break;
case "CallExpression":
this.adjustCommentsAfterTrailingComma(node, node.arguments);
break;
case "ArrayExpression":
case "ArrayPattern":
this.adjustCommentsAfterTrailingComma(node, node.elements);
break;
}
} else if (
this.state.commentPreviousNode &&
((this.state.commentPreviousNode.type === "ImportSpecifier" &&
node.type !== "ImportSpecifier") ||
(this.state.commentPreviousNode.type === "ExportSpecifier" &&
node.type !== "ExportSpecifier"))
) {
this.adjustCommentsAfterTrailingComma(node, [
this.state.commentPreviousNode,
]);
}
if (lastChild) {

View File

@@ -380,6 +380,39 @@ export default class ExpressionParser extends LValParser {
node.right = this.parseExprOpRightExpr(op, prec, noIn);
/* this check is for all ?? operators
* a ?? b && c for this example
* b && c => This is considered as a logical expression in the ast tree
* a => Identifier
* 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
* 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
*/
if (op === tt.nullishCoalescing) {
if (
left.type === "LogicalExpression" &&
left.operator !== "??" &&
!(left.extra && left.extra.parenthesized)
) {
throw this.raise(
left.start,
`Nullish coalescing operator(??) requires parens when mixing with logical operators`,
);
} else if (
node.right.type === "LogicalExpression" &&
node.right.operator !== "??" &&
!(node.right.extra && node.right.extra.parenthesized)
) {
throw this.raise(
node.right.start,
`Nullish coalescing operator(??) requires parens when mixing with logical operators`,
);
}
}
this.finishNode(
node,
op === tt.logicalOR ||
@@ -1137,9 +1170,7 @@ export default class ExpressionParser extends LValParser {
if (node.property.name !== propertyName || containsEsc) {
this.raise(
node.property.start,
`The only valid meta property for ${meta.name} is ${
meta.name
}.${propertyName}`,
`The only valid meta property for ${meta.name} is ${meta.name}.${propertyName}`,
);
}
@@ -2160,7 +2191,7 @@ export default class ExpressionParser extends LValParser {
if (
this.match(tt.semi) ||
(!this.match(tt.star) && !this.state.type.startsExpr) ||
this.canInsertSemicolon()
this.hasPrecedingLineBreak()
) {
node.delegate = false;
node.argument = null;

View File

@@ -20,6 +20,7 @@ import {
SCOPE_OTHER,
SCOPE_SIMPLE_CATCH,
SCOPE_SUPER,
type BindingTypes,
} from "../util/scopeflags";
const loopLabel = { kind: "loop" },
@@ -1611,11 +1612,12 @@ export default class StatementParser extends ExpressionParser {
node: N.Class,
isStatement: boolean,
optionalId: ?boolean,
bindingType: BindingTypes = BIND_CLASS,
): void {
if (this.match(tt.name)) {
node.id = this.parseIdentifier();
if (isStatement) {
this.checkLVal(node.id, BIND_CLASS, undefined, "class name");
this.checkLVal(node.id, bindingType, undefined, "class name");
}
} else {
if (optionalId || !isStatement) {

View File

@@ -69,6 +69,10 @@ export function validatePlugins(plugins: PluginList) {
throw new Error("Cannot combine flow and typescript plugins.");
}
if (hasPlugin(plugins, "placeholders") && hasPlugin(plugins, "v8intrinsic")) {
throw new Error("Cannot combine placeholders and v8intrinsic plugins.");
}
if (
hasPlugin(plugins, "pipelineOperator") &&
!PIPELINE_PROPOSALS.includes(
@@ -89,6 +93,7 @@ import flow from "./plugins/flow";
import jsx from "./plugins/jsx";
import typescript from "./plugins/typescript";
import placeholders from "./plugins/placeholders";
import v8intrinsic from "./plugins/v8intrinsic";
// NOTE: order is important. estree must come first; placeholders must come last.
export const mixinPlugins: { [name: string]: MixinPlugin } = {
@@ -96,6 +101,7 @@ export const mixinPlugins: { [name: string]: MixinPlugin } = {
jsx,
flow,
typescript,
v8intrinsic,
placeholders,
};

View File

@@ -250,10 +250,16 @@ export default (superClass: Class<Parser>): Class<Parser> =>
// Parses element name in any form - namespaced, member
// or single identifier.
jsxParseElementName(): N.JSXNamespacedName | N.JSXMemberExpression {
jsxParseElementName():
| N.JSXIdentifier
| N.JSXNamespacedName
| N.JSXMemberExpression {
const startPos = this.state.start;
const startLoc = this.state.startLoc;
let node = this.jsxParseNamespacedName();
if (node.type === "JSXNamespacedName") {
return node;
}
while (this.eat(tt.dot)) {
const newNode = this.startNodeAt(startPos, startLoc);
newNode.object = node;

View File

@@ -14,8 +14,9 @@ import {
BIND_TS_CONST_ENUM,
BIND_TS_TYPE,
BIND_TS_INTERFACE,
BIND_TS_FN_TYPE,
BIND_TS_AMBIENT,
BIND_TS_NAMESPACE,
BIND_CLASS,
} from "../../util/scopeflags";
import TypeScriptScopeHandler from "./scope";
@@ -369,9 +370,8 @@ export default (superClass: Class<Parser>): Class<Parser> =>
) {
throw this.unexpected(
pattern.start,
`Name in a signature must be an Identifier, ObjectPattern or ArrayPattern, instead got ${
pattern.type
}`,
"Name in a signature must be an Identifier, ObjectPattern or ArrayPattern," +
`instead got ${pattern.type}`,
);
}
return pattern;
@@ -1279,6 +1279,9 @@ export default (superClass: Class<Parser>): Class<Parser> =>
/* declarationPosition */ true,
);
case tt._class:
// While this is also set by tsParseExpressionStatement, we need to set it
// before parsing the class declaration to now how to register it in the scope.
nany.declare = true;
return this.parseClass(
nany,
/* isStatement */ true,
@@ -1553,7 +1556,7 @@ export default (superClass: Class<Parser>): Class<Parser> =>
checkFunctionStatementId(node: N.Function): void {
if (!node.body && node.id) {
this.checkLVal(node.id, BIND_TS_FN_TYPE, null, "function name");
this.checkLVal(node.id, BIND_TS_AMBIENT, null, "function name");
} else {
super.checkFunctionStatementId(...arguments);
}
@@ -1989,7 +1992,12 @@ export default (superClass: Class<Parser>): Class<Parser> =>
return;
}
super.parseClassId(...arguments);
super.parseClassId(
node,
isStatement,
optionalId,
(node: any).declare ? BIND_TS_AMBIENT : BIND_CLASS,
);
const typeParameters = this.tsTryParseTypeParameters();
if (typeParameters) node.typeParameters = typeParameters;
}

View File

@@ -25,7 +25,7 @@ class TypeScriptScope extends Scope {
// classes (which are also in .lexical) and interface (which are also in .types)
classes: string[] = [];
// namespaces and bodyless-functions are too difficult to track,
// namespaces and ambient functions (or classes) are too difficult to track,
// especially without type analysis.
// We need to track them anyway, to avoid "X is not defined" errors
// when exporting them.

View File

@@ -0,0 +1,32 @@
import type Parser from "../parser";
import { types as tt } from "../tokenizer/types";
import * as N from "../types";
export default (superClass: Class<Parser>): Class<Parser> =>
class extends superClass {
parseV8Intrinsic(): N.Expression {
if (this.match(tt.modulo)) {
const v8IntrinsicStart = this.state.start;
// let the `loc` of Identifier starts from `%`
const node = this.startNode();
this.eat(tt.modulo);
if (this.match(tt.name)) {
const name = this.parseIdentifierName(this.state.start);
const identifier = this.createIdentifier(node, name);
identifier.type = "V8IntrinsicIdentifier";
if (this.match(tt.parenL)) {
return identifier;
}
}
this.unexpected(v8IntrinsicStart);
}
}
/* ============================================================ *
* parser/expression.js *
* ============================================================ */
parseExprAtom(): N.Expression {
return this.parseV8Intrinsic() || super.parseExprAtom(...arguments);
}
};

View File

@@ -139,21 +139,22 @@ export const types: { [name: string]: TokenType } = {
tilde: new TokenType("~", { beforeExpr, prefix, startsExpr }),
pipeline: createBinop("|>", 0),
nullishCoalescing: createBinop("??", 1),
logicalOR: createBinop("||", 1),
logicalAND: createBinop("&&", 2),
bitwiseOR: createBinop("|", 3),
bitwiseXOR: createBinop("^", 4),
bitwiseAND: createBinop("&", 5),
equality: createBinop("==/!=/===/!==", 6),
relational: createBinop("</>/<=/>=", 7),
bitShift: createBinop("<</>>/>>>", 8),
plusMin: new TokenType("+/-", { beforeExpr, binop: 9, prefix, startsExpr }),
modulo: createBinop("%", 10),
star: createBinop("*", 10),
slash: createBinop("/", 10),
logicalOR: createBinop("||", 2),
logicalAND: createBinop("&&", 3),
bitwiseOR: createBinop("|", 4),
bitwiseXOR: createBinop("^", 5),
bitwiseAND: createBinop("&", 6),
equality: createBinop("==/!=/===/!==", 7),
relational: createBinop("</>/<=/>=", 8),
bitShift: createBinop("<</>>/>>>", 9),
plusMin: new TokenType("+/-", { beforeExpr, binop: 10, prefix, startsExpr }),
// startsExpr: required by v8intrinsic plugin
modulo: new TokenType("%", { beforeExpr, binop: 11, startsExpr }),
star: createBinop("*", 11),
slash: createBinop("/", 11),
exponent: new TokenType("**", {
beforeExpr,
binop: 11,
binop: 12,
rightAssociative: true,
}),
@@ -188,8 +189,8 @@ export const types: { [name: string]: TokenType } = {
_null: createKeyword("null", { startsExpr }),
_true: createKeyword("true", { startsExpr }),
_false: createKeyword("false", { startsExpr }),
_in: createKeyword("in", { beforeExpr, binop: 7 }),
_instanceof: createKeyword("instanceof", { beforeExpr, binop: 7 }),
_in: createKeyword("in", { beforeExpr, binop: 8 }),
_instanceof: createKeyword("instanceof", { beforeExpr, binop: 8 }),
_typeof: createKeyword("typeof", { beforeExpr, prefix, startsExpr }),
_void: createKeyword("void", { beforeExpr, prefix, startsExpr }),
_delete: createKeyword("delete", { beforeExpr, prefix, startsExpr }),

View File

@@ -62,14 +62,14 @@ export const BIND_CLASS = BIND_KIND_VALUE | BIND_KIND_TYPE | BIND_SCOPE_
BIND_TS_INTERFACE = 0 | BIND_KIND_TYPE | 0 | BIND_FLAGS_CLASS ,
BIND_TS_TYPE = 0 | BIND_KIND_TYPE | 0 | 0 ,
BIND_TS_ENUM = BIND_KIND_VALUE | BIND_KIND_TYPE | BIND_SCOPE_LEXICAL | BIND_FLAGS_TS_ENUM,
BIND_TS_FN_TYPE = 0 | 0 | 0 | BIND_FLAGS_TS_EXPORT_ONLY,
BIND_TS_AMBIENT = 0 | 0 | 0 | BIND_FLAGS_TS_EXPORT_ONLY,
// These bindings don't introduce anything in the scope. They are used for assignments and
// function expressions IDs.
BIND_NONE = 0 | 0 | 0 | BIND_FLAGS_NONE ,
BIND_OUTSIDE = BIND_KIND_VALUE | 0 | 0 | BIND_FLAGS_NONE ,
BIND_TS_CONST_ENUM = BIND_TS_ENUM | BIND_FLAGS_TS_CONST_ENUM,
BIND_TS_NAMESPACE = BIND_TS_FN_TYPE;
BIND_TS_NAMESPACE = 0 | 0 | 0 | BIND_FLAGS_TS_EXPORT_ONLY;
export type BindingTypes =
| typeof BIND_NONE
@@ -81,5 +81,5 @@ export type BindingTypes =
| typeof BIND_TS_INTERFACE
| typeof BIND_TS_TYPE
| typeof BIND_TS_ENUM
| typeof BIND_TS_FN_TYPE
| typeof BIND_TS_AMBIENT
| typeof BIND_TS_NAMESPACE;

View File

@@ -0,0 +1,18 @@
const nonTrailing = [
"One", // One
// Two
"Two" // Three
// Four
]
const trailingAfterComma = [
"One", // One
// Two
"Two", // Three
// Four
]
const trailingAfterArray = [
"One", // One
// Two
] // Three

View File

@@ -0,0 +1,702 @@
{
"type": "File",
"start": 0,
"end": 229,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 18,
"column": 10
}
},
"program": {
"type": "Program",
"start": 0,
"end": 229,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 18,
"column": 10
}
},
"sourceType": "script",
"interpreter": null,
"body": [
{
"type": "VariableDeclaration",
"start": 0,
"end": 76,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 6,
"column": 1
}
},
"declarations": [
{
"type": "VariableDeclarator",
"start": 6,
"end": 76,
"loc": {
"start": {
"line": 1,
"column": 6
},
"end": {
"line": 6,
"column": 1
}
},
"id": {
"type": "Identifier",
"start": 6,
"end": 17,
"loc": {
"start": {
"line": 1,
"column": 6
},
"end": {
"line": 1,
"column": 17
},
"identifierName": "nonTrailing"
},
"name": "nonTrailing"
},
"init": {
"type": "ArrayExpression",
"start": 20,
"end": 76,
"loc": {
"start": {
"line": 1,
"column": 20
},
"end": {
"line": 6,
"column": 1
}
},
"elements": [
{
"type": "StringLiteral",
"start": 24,
"end": 29,
"loc": {
"start": {
"line": 2,
"column": 2
},
"end": {
"line": 2,
"column": 7
}
},
"extra": {
"rawValue": "One",
"raw": "\"One\""
},
"value": "One"
},
{
"type": "StringLiteral",
"start": 50,
"end": 55,
"loc": {
"start": {
"line": 4,
"column": 2
},
"end": {
"line": 4,
"column": 7
}
},
"extra": {
"rawValue": "Two",
"raw": "\"Two\""
},
"value": "Two",
"leadingComments": [
{
"type": "CommentLine",
"value": " One",
"start": 31,
"end": 37,
"loc": {
"start": {
"line": 2,
"column": 9
},
"end": {
"line": 2,
"column": 15
}
}
},
{
"type": "CommentLine",
"value": " Two",
"start": 41,
"end": 47,
"loc": {
"start": {
"line": 3,
"column": 3
},
"end": {
"line": 3,
"column": 9
}
}
}
],
"trailingComments": [
{
"type": "CommentLine",
"value": " Three",
"start": 56,
"end": 64,
"loc": {
"start": {
"line": 4,
"column": 8
},
"end": {
"line": 4,
"column": 16
}
}
},
{
"type": "CommentLine",
"value": " Four",
"start": 67,
"end": 74,
"loc": {
"start": {
"line": 5,
"column": 2
},
"end": {
"line": 5,
"column": 9
}
}
}
]
}
]
}
}
],
"kind": "const"
},
{
"type": "VariableDeclaration",
"start": 78,
"end": 162,
"loc": {
"start": {
"line": 8,
"column": 0
},
"end": {
"line": 13,
"column": 1
}
},
"declarations": [
{
"type": "VariableDeclarator",
"start": 84,
"end": 162,
"loc": {
"start": {
"line": 8,
"column": 6
},
"end": {
"line": 13,
"column": 1
}
},
"id": {
"type": "Identifier",
"start": 84,
"end": 102,
"loc": {
"start": {
"line": 8,
"column": 6
},
"end": {
"line": 8,
"column": 24
},
"identifierName": "trailingAfterComma"
},
"name": "trailingAfterComma"
},
"init": {
"type": "ArrayExpression",
"start": 105,
"end": 162,
"loc": {
"start": {
"line": 8,
"column": 27
},
"end": {
"line": 13,
"column": 1
}
},
"elements": [
{
"type": "StringLiteral",
"start": 109,
"end": 114,
"loc": {
"start": {
"line": 9,
"column": 2
},
"end": {
"line": 9,
"column": 7
}
},
"extra": {
"rawValue": "One",
"raw": "\"One\""
},
"value": "One"
},
{
"type": "StringLiteral",
"start": 135,
"end": 140,
"loc": {
"start": {
"line": 11,
"column": 2
},
"end": {
"line": 11,
"column": 7
}
},
"extra": {
"rawValue": "Two",
"raw": "\"Two\""
},
"value": "Two",
"leadingComments": [
{
"type": "CommentLine",
"value": " One",
"start": 116,
"end": 122,
"loc": {
"start": {
"line": 9,
"column": 9
},
"end": {
"line": 9,
"column": 15
}
}
},
{
"type": "CommentLine",
"value": " Two",
"start": 126,
"end": 132,
"loc": {
"start": {
"line": 10,
"column": 3
},
"end": {
"line": 10,
"column": 9
}
}
}
],
"trailingComments": [
{
"type": "CommentLine",
"value": " Three",
"start": 142,
"end": 150,
"loc": {
"start": {
"line": 11,
"column": 9
},
"end": {
"line": 11,
"column": 17
}
}
},
{
"type": "CommentLine",
"value": " Four",
"start": 153,
"end": 160,
"loc": {
"start": {
"line": 12,
"column": 2
},
"end": {
"line": 12,
"column": 9
}
}
}
]
}
]
}
}
],
"kind": "const"
},
{
"type": "VariableDeclaration",
"start": 164,
"end": 220,
"loc": {
"start": {
"line": 15,
"column": 0
},
"end": {
"line": 18,
"column": 1
}
},
"declarations": [
{
"type": "VariableDeclarator",
"start": 170,
"end": 220,
"loc": {
"start": {
"line": 15,
"column": 6
},
"end": {
"line": 18,
"column": 1
}
},
"id": {
"type": "Identifier",
"start": 170,
"end": 188,
"loc": {
"start": {
"line": 15,
"column": 6
},
"end": {
"line": 15,
"column": 24
},
"identifierName": "trailingAfterArray"
},
"name": "trailingAfterArray"
},
"init": {
"type": "ArrayExpression",
"start": 191,
"end": 220,
"loc": {
"start": {
"line": 15,
"column": 27
},
"end": {
"line": 18,
"column": 1
}
},
"elements": [
{
"type": "StringLiteral",
"start": 195,
"end": 200,
"loc": {
"start": {
"line": 16,
"column": 2
},
"end": {
"line": 16,
"column": 7
}
},
"extra": {
"rawValue": "One",
"raw": "\"One\""
},
"value": "One",
"trailingComments": [
{
"type": "CommentLine",
"value": " One",
"start": 202,
"end": 208,
"loc": {
"start": {
"line": 16,
"column": 9
},
"end": {
"line": 16,
"column": 15
}
}
},
{
"type": "CommentLine",
"value": " Two",
"start": 212,
"end": 218,
"loc": {
"start": {
"line": 17,
"column": 3
},
"end": {
"line": 17,
"column": 9
}
}
}
]
}
]
}
}
],
"kind": "const",
"trailingComments": [
{
"type": "CommentLine",
"value": " Three",
"start": 221,
"end": 229,
"loc": {
"start": {
"line": 18,
"column": 2
},
"end": {
"line": 18,
"column": 10
}
}
}
]
}
],
"directives": []
},
"comments": [
{
"type": "CommentLine",
"value": " One",
"start": 31,
"end": 37,
"loc": {
"start": {
"line": 2,
"column": 9
},
"end": {
"line": 2,
"column": 15
}
}
},
{
"type": "CommentLine",
"value": " Two",
"start": 41,
"end": 47,
"loc": {
"start": {
"line": 3,
"column": 3
},
"end": {
"line": 3,
"column": 9
}
}
},
{
"type": "CommentLine",
"value": " Three",
"start": 56,
"end": 64,
"loc": {
"start": {
"line": 4,
"column": 8
},
"end": {
"line": 4,
"column": 16
}
}
},
{
"type": "CommentLine",
"value": " Four",
"start": 67,
"end": 74,
"loc": {
"start": {
"line": 5,
"column": 2
},
"end": {
"line": 5,
"column": 9
}
}
},
{
"type": "CommentLine",
"value": " One",
"start": 116,
"end": 122,
"loc": {
"start": {
"line": 9,
"column": 9
},
"end": {
"line": 9,
"column": 15
}
}
},
{
"type": "CommentLine",
"value": " Two",
"start": 126,
"end": 132,
"loc": {
"start": {
"line": 10,
"column": 3
},
"end": {
"line": 10,
"column": 9
}
}
},
{
"type": "CommentLine",
"value": " Three",
"start": 142,
"end": 150,
"loc": {
"start": {
"line": 11,
"column": 9
},
"end": {
"line": 11,
"column": 17
}
}
},
{
"type": "CommentLine",
"value": " Four",
"start": 153,
"end": 160,
"loc": {
"start": {
"line": 12,
"column": 2
},
"end": {
"line": 12,
"column": 9
}
}
},
{
"type": "CommentLine",
"value": " One",
"start": 202,
"end": 208,
"loc": {
"start": {
"line": 16,
"column": 9
},
"end": {
"line": 16,
"column": 15
}
}
},
{
"type": "CommentLine",
"value": " Two",
"start": 212,
"end": 218,
"loc": {
"start": {
"line": 17,
"column": 3
},
"end": {
"line": 17,
"column": 9
}
}
},
{
"type": "CommentLine",
"value": " Three",
"start": 221,
"end": 229,
"loc": {
"start": {
"line": 18,
"column": 2
},
"end": {
"line": 18,
"column": 10
}
}
}
]
}

View File

@@ -0,0 +1,6 @@
const [
/* One */
x
/* Two */,
/* Three */
] /* Four */ = [];

View File

@@ -0,0 +1,254 @@
{
"type": "File",
"start": 0,
"end": 69,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 6,
"column": 18
}
},
"program": {
"type": "Program",
"start": 0,
"end": 69,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 6,
"column": 18
}
},
"sourceType": "script",
"interpreter": null,
"body": [
{
"type": "VariableDeclaration",
"start": 0,
"end": 69,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 6,
"column": 18
}
},
"declarations": [
{
"type": "VariableDeclarator",
"start": 6,
"end": 68,
"loc": {
"start": {
"line": 1,
"column": 6
},
"end": {
"line": 6,
"column": 17
}
},
"id": {
"type": "ArrayPattern",
"start": 6,
"end": 52,
"loc": {
"start": {
"line": 1,
"column": 6
},
"end": {
"line": 6,
"column": 1
}
},
"elements": [
{
"type": "Identifier",
"start": 22,
"end": 23,
"loc": {
"start": {
"line": 3,
"column": 2
},
"end": {
"line": 3,
"column": 3
},
"identifierName": "x"
},
"name": "x",
"leadingComments": [
{
"type": "CommentBlock",
"value": " One ",
"start": 10,
"end": 19,
"loc": {
"start": {
"line": 2,
"column": 2
},
"end": {
"line": 2,
"column": 11
}
}
}
],
"trailingComments": [
{
"type": "CommentBlock",
"value": " Two ",
"start": 26,
"end": 35,
"loc": {
"start": {
"line": 4,
"column": 2
},
"end": {
"line": 4,
"column": 11
}
}
},
{
"type": "CommentBlock",
"value": " Three ",
"start": 39,
"end": 50,
"loc": {
"start": {
"line": 5,
"column": 2
},
"end": {
"line": 5,
"column": 13
}
}
}
]
}
],
"trailingComments": [
{
"type": "CommentBlock",
"value": " Four ",
"start": 53,
"end": 63,
"loc": {
"start": {
"line": 6,
"column": 2
},
"end": {
"line": 6,
"column": 12
}
}
}
]
},
"init": {
"type": "ArrayExpression",
"start": 66,
"end": 68,
"loc": {
"start": {
"line": 6,
"column": 15
},
"end": {
"line": 6,
"column": 17
}
},
"elements": []
}
}
],
"kind": "const"
}
],
"directives": []
},
"comments": [
{
"type": "CommentBlock",
"value": " One ",
"start": 10,
"end": 19,
"loc": {
"start": {
"line": 2,
"column": 2
},
"end": {
"line": 2,
"column": 11
}
}
},
{
"type": "CommentBlock",
"value": " Two ",
"start": 26,
"end": 35,
"loc": {
"start": {
"line": 4,
"column": 2
},
"end": {
"line": 4,
"column": 11
}
}
},
{
"type": "CommentBlock",
"value": " Three ",
"start": 39,
"end": 50,
"loc": {
"start": {
"line": 5,
"column": 2
},
"end": {
"line": 5,
"column": 13
}
}
},
{
"type": "CommentBlock",
"value": " Four ",
"start": 53,
"end": 63,
"loc": {
"start": {
"line": 6,
"column": 2
},
"end": {
"line": 6,
"column": 12
}
}
}
]
}

Some files were not shown because too many files have changed in this diff Show More