4611 Commits

Author SHA1 Message Date
Tan Li Hau
b0acfb24dd add scope to TSModuleDeclaration (#10119) 2019-10-08 19:35:40 +02:00
Huáng Jùnliàng
0856618ed5 perf: replace lookahead by lookaheadCharCode (#10371)
* perf: replace lookahead by lookaheadCharCode

* fix: flow ignore

* refactor: add nextTokenStart method

* refactor: duplicated isNewLine code

* refactor: remove lookahead usage from babylon core
2019-10-08 19:09:05 +02:00
Jessica Franco
bc0966a46f Add declarations for more of @babel/types exports (#10504)
This adds lots of missing declarations to the types of @babel/types,
including many utility functions useful to plugin authors.

With the typescript types, I tried to make them as useful as possible
for control flow analysis / inference, but Flow doesn't seem to
support overloads and I'm not as familiar with it anyway so it has
simpler types.
2019-10-08 19:07:57 +02:00
Nicolò Ribaudo
3498195ae2
Do not hoist jsx referencing a mutable binding (#10529) 2019-10-08 18:50:03 +02:00
Brian Ng
57ae306457
Bump flow@0.108.0 (#10516) 2019-10-02 12:13:58 -05:00
David J. Hamilton
fa5a40c8d5 assertNoDuplicates throw with more context (#10419)
When users see errors like

```
Duplicate plugin/preset detected.
If you'd like to use two separate instances of a plugin,
they need separate names, e.g.

  plugins: [
    ['some-plugin', {}],
    ['some-plugin', {}, 'some unique name'],
  ]
```

It can be difficult to determine the source of the conflict, especially
in a larger build system.

This commit outputs what is known about the plugins that actually
conflict, which can be helpful for users to determine the root cause of
the conflict.

Partially addresses #9778
2019-10-02 16:45:03 +02:00
Nicolò Ribaudo
a219b6de7a
Disallow await inside async arrow params (#10469)
* Disallow await inside async arrow params

* Use -1 as default for awaitPos/yieldPos
2019-10-02 07:37:40 +02:00
Huáng Jùnliàng
fa5057f9fb Flow: interface identifier should be declared in the scope (#10220)
* fix: typo

* declare name for flow interface

* add test case for export overload function, typescript

* test: add test

Fixes #10044

* test: update test

* test(flow): add multiple declarations regression test

* re-enable flow test case

# Conflicts:
#	packages/babel-plugin-transform-flow-strip-types/test/fixtures/strip-types/def-site-variance/input.js
#	packages/babel-plugin-transform-flow-strip-types/test/fixtures/strip-types/strip-declare-statements/input.js
#	packages/babel-plugin-transform-flow-strip-types/test/fixtures/strip-types/strip-interfaces-module-and-script/input.js
#	packages/babel-plugin-transform-flow-strip-types/test/fixtures/strip-types/strip-iterator/input.js

* test: disable two flow dupl-decl test

* fix: do not declare name for declare function until we figure out a better way

* test: duplicate declare function and function would not throw
2019-10-02 07:32:42 +02:00
Huáng Jùnliàng
298c9a6c33 Add filename to transform error (#10511)
* polish: use “unknown” as a default filename in buildCodeFrameError

* feat: add filename to transform error

* fix: incorrect warning message

* fix: add filename to generate phrase error message

* address review comment from Nicolò
2019-10-01 17:19:29 +02:00
Nicolò Ribaudo
80d99b4d4e
Do not allow member expressions to start async arrows (#10332)
* Do not allow member expressions to start async arrows

* Boolean -> boolean
2019-10-01 11:40:42 +02:00
Nicolò Ribaudo
b459f6a0a4
Add windows to travis (#10249)
* Add windows to travis

* Update

* Do not use sh file on windows

* Fix whitespace

* Unify command

* ./ doesn't work on windows

* Remove all ./ usages

* Run windows test before others

* fix: normalize filename when generating sources

sources should be URL.

* fix: replace normalized path to cwd

* chore: add nodePlatform task options

* fix: normalize preset-env filename output

* chore: replace normalized path to CWD on win32 platform

* limit transform-react-source to run on linux and darwin

* test: escapeRegExp on testcases

* test: add test for babel --filename on windows

* test: double babel-node/cli test timeout

* chore: workaround windows build does not stop

* chore: remove redundant condition

* refactor: rename `nodePlatform` to `os`
2019-09-26 20:59:17 +02:00
Michael J. Currie
66062c2a8c Template literal validation (#10492)
* add template literal validation

* avoid null/undefined error when validating

* simplify validation logic and fix tests

Co-authored-by: Michael J. Currie <michaeljcurrie136@gmail.com>
2019-09-26 19:58:36 +02:00
Gonzalo Rodríguez
490798a26d [parser] Disallow numeric separators in legacy octal like inte… (#10493)
* Disallow numeric separators in lols

* Update whitelist

* Rename test

* Better syntax when checking
2019-09-25 01:32:50 +02:00
Nicolò Ribaudo
0e9502685a
[parser] Don't crash on comment after trailing comma after eli… (#10490) 2019-09-24 17:08:58 +02:00
Huáng Jùnliàng
26be14b24d chore: add access: public where missing (#10489) [skip ci]
* @babel/types
* @babel/plugin-transform-named-capturing-groups-regex
2019-09-24 14:04:54 +02:00
Huáng Jùnliàng
6f3460c767 chore: add access: public to babel parser publish config (#10487) [skip ci] 2019-09-24 10:03:07 +02:00
Corey Farrell
cc080417b9 chore: Upgrade source-map to 0.6.1 (#10446) 2019-09-24 02:01:32 +02:00
Nicolò Ribaudo
b9cb4af953
v7.6.2 2019-09-23 23:14:37 +02:00
Gonzalo Rodríguez
69d00dc5b0 [parser] Invalid NonOctal Decimal (#10467)
* Add test

* Add nonOctalDecimal verification

* Update regex and code style

* Refactor non octal detection

* Add numeric separator test

* Disallow numeric separators in non octals

* Update whitelist

* Better test naming

* Disallow numeric separators in non oct for all numbers

* Specific error above the general error

* Add test for invalid leading zero in num separator

* Add start position to error
2019-09-23 23:07:52 +02:00
Ivan Medina
f339d2d034 [parser] Disallow numeric separator in unicode scape sequences (#10468)
* [parser] Disallow numeric separator in unicode scape sequences (#10460)

* raise error only when numeric separator plugin is set

* Adds argument for checking numeric separator

* Fix condition for readability

* Add test for hex escape sequence and rephrase error message

* Remove exposure for allowNumSeparator in readHexChar method
2019-09-23 22:47:18 +02:00
Nicolò Ribaudo
3069747a81
Leave trailing comments after handling a possible trailing com… (#10445)
* Leave trailing comments aftre handling a possible trailing comma

* perf
2019-09-23 19:14:43 +02:00
Tomer Aberbach
962015f7e7 docs: updates docs of findParent and find (#10479) [skip ci]
Makes the documentation of `findParent` and `find` consistent and documents their `null` cases.
2019-09-22 23:00:13 +02:00
Vivek Nayyar
b7333ea97a added check to disallow super.private variable access and test case added (#10472)
* 🚀 added check to disallow super.private variable access and test case added

* ♻️ change the other linting change back to how it was

* ♻️ change the other linting change back to how it was

* ♻️ added newline at the end test output.json file

* ♻️ changed the linting style to the way it was

* ♻️ updated error message, removed super private member access test cases from whitelist of flow and test 262 suite

* ♻️ added newline in output.json
2019-09-21 00:22:37 +02:00
Guy Waldman
9c1ad0a9f7 [parser] Disallow static fields named constructor (#10461)
* Disallow static fields named `constructor` in a class

    - Disallowed static fields named `constructor` in a class (previously only non-static were disallowed)
    - Updated the text for the error for one consolidated warning, for both static and non-static fields
    - Added a test
    - Updated an existing test in the `flow` test suite of the parser to reflect the parse error.
  Strangely, the test used to pass and started failing when inlining the `isNonstaticConstructor` method, without any changes.
  In that test, `constructor` was a field, so in theory it should never have passed.
  Would appreciate some feedback on this, as I'm not 100% sure if this is somehow related to Flow

* Update test262 whitelist

* Add comment and fix && operator
2019-09-18 01:19:45 +02:00
Huáng Jùnliàng
87dc201411 refactor: replace regexp-tree by regexpu (#10430) 2019-09-17 17:38:15 -05:00
Nicolò Ribaudo
cb881e6b3f
[parser] Report escapes in kws only if they won't be used as i… (#10455)
We can do it by tokenizing escaped keywords as normal identifiers, so that they won't
be accidentally used as real keywords.
2019-09-18 00:13:51 +02:00
Huáng Jùnliàng
256fa5aa04 chore: bump regexpu-core to version 4.6.0 (#10439)
* chore: update test fixtures

* chore: test against regexpu-core 4.6.0

* chore: bump regexpu-core dependency
2019-09-13 17:51:24 +02:00
Huáng Jùnliàng
1b352ca8a1 chore: remove tryResolve dependency (#10428) 2019-09-11 12:25:18 +02:00
Huáng Jùnliàng
53af9e8b7a fix: allow the process to exit naturally (#10400) 2019-09-11 12:24:44 +02:00
Huáng Jùnliàng
af04f40ee0 fix: pass optionLoc when validating plugin object (#10402) 2019-09-11 12:23:20 +02:00
Bryan Wain
98b14843ba Remove babel polyfill dependency of babel-node (#10429) 2019-09-11 01:57:44 +02:00
Huáng Jùnliàng
4395c22f3a Miscellaneous perf tweak (#10421)
* refactor: early return on hot path

* refactor: read next2 only when next is dot

* perf: mini refactor
2019-09-10 19:47:52 +02:00
Nicolò Ribaudo
610d6bdc62
Do not guess relative execution status for exported fns (#10417) 2019-09-10 19:47:27 +02:00
Tan Li Hau
8027dca501 fix object rest in array pattern (#10275)
* fix object rest in array pattern

* update test fixtures

* early return

* use path.stop() at the right path
2019-09-10 15:18:45 +02:00
Huáng Jùnliàng
81831032c3 chore: remove trim-right dependency (#10420) 2019-09-10 15:17:22 +02:00
FND
daf25af47c Fix typo in changelog (#10409) [skip ci]
s/compliancy/compliancy/g - seems both correct and consistent with more
recent occurrences
2019-09-09 09:22:33 +02:00
Nicolò Ribaudo
6a5cee8f27
Remove circular dependency (#10405)
* Remove circular dependency

* Move @babel/runtime test to @babel/runtime
2019-09-08 22:53:42 +02:00
Nicolò Ribaudo
2096d0cfcb
Update @babel deps (#10407)
* Update @babel deps

* Add core-js to transform-named-capturing-groups-regex devDeps

* Don't use fixed deps (they were added by yarn)

* Lockfile
2019-09-08 22:53:20 +02:00
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
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
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