20 Commits

Author SHA1 Message Date
Nicolò Ribaudo
2d989a983d
Run tests in a native Node.js ESM environment (#13966) 2021-12-03 15:32:58 +01:00
Stuart Cook
fa01fbe052
Parse for await (async of ...) (#13244) 2021-05-01 18:00:21 +02:00
Huáng Jùnliàng
0f2a1a8153
Add runFixtureTestsWithoutExactASTMatch in parser test runner (#13227) 2021-04-29 18:42:26 +02:00
Nicolò Ribaudo
d04842a700
Avoid using CJS globals in internal source files (#12963)
* Lint against CJS globals in modules

* Use `import.meta.url` instead of `__filename` in `src` files

* Prepare fixtures runner for `import.meta.url`

* Use `import.meta.url` instead of `__filename` in `test/index` files

* Remove `__dirname` from remaining test files

dirname

* Avoid using `module` in `src` files

* Avoid using `require` in `src` files

* Avoid using `require` in `test` files

* Update `@types/node`

* Compile dynamic import in `@babel/node`

* Fix windows

* Use `@babel/plugin-proposal-dynamic-import` from npm
2021-03-05 19:55:36 +01:00
Huáng Jùnliàng
3bd6a3d781
Make sure estree test should not throw if babel parser does not throw (#12443)
* test: run estree on tests that does not expect an errors

* fix: record the directive expression value to extra AST properties
2020-12-04 13:58:01 -05:00
Huáng Jùnliàng
8478027d1a
Make sure babel parser throws exactly same recoverable errors when estree plugin is enabled (#12375)
* refactor: introduce isPrivateName and getPrivateNameSV

* feat: check recoverable errors on estree-throw

* fix: pass through all params of parseBlockBody

* fix: set bigInt to null when invalid bigInt value is parsed

e.g. 0.1n

* fix: use string literal value in error message

When estree plugin is enabled, stringLiteral#extra.raw is not accessible. Use StringLiteral#value instead.

* refactor: introduce hasPropertyAsPrivateName

* fix: adapt to ChainExpression

* fix: port checkLVal early return for method in object pattern

* fix: throw new a?.() on estree

* fix: early return for __proto__ in accessors

* fix: test record element via isObjectProperty

* fix: pass through isLHS in toAssignable

* refactor: introduce isObjectMethod methods
2020-12-03 08:36:54 +00:00
Bogdan Savluk
4108524856
Update prettier to v2 (#11579)
Co-authored-by: Nicolò Ribaudo <nicolo.ribaudo@gmail.com>
2020-06-07 22:21:33 +02:00
Huáng Jùnliàng
dc7c5640e9
Compact parser fixture loc info (#11322)
* chore: compact loc information in parser fixtures

* chore: update test fixtures
2020-03-23 20:10:29 -04:00
Huáng Jùnliàng
6648d62f40
chore: use @babel/eslint-config-internal (#11026) 2020-01-17 07:57:25 -05:00
Nicolò Ribaudo
0b3f883ed1 Properly serialize non-json values in parser tests (#10858) 2019-12-12 10:22:17 +01:00
Nicolò Ribaudo
5156d3ea06
Restore @babel/parser tests (#10854)
* Make parser tests work again

* Update failing fixtures

* Fix serialization of BigInt

* Fix
2019-12-11 11:09:13 +01:00
Kai Cataldo
fb100eee41 @babel/eslint-parser: fix BigIntLiteral node to match ESTree spec (#10827)
* @babel/eslint-parser: fix BigIntLiteral node to match ESTree spec

* Move token conversion to @babel/eslint-parser

* Add estree plugin tests

* Update test helpers to handle BigInt serializing

* Update Literal union type to include BigIntLiteral

* Add FlowIgnore comment for BigInt
2019-12-08 02:59:18 +01:00
Nicolò Ribaudo
87feda7c2a
@babel/parser error recovery (#10363)
* Add error recovery support to @babel/parser

* Update @babel/parser tests to always recover from errors

* Update this.raise usage in @babel/parser:

- expression.js
- lval.js
- statement.js
- estree.js
- flow.js
- jsx/index.js
- tokenizer/index.js

* Update @babel/parser fixtures with recovered errors

* Fix tests out of @babel/parser

* Do not use try/catch for control flow

* Update invalid fixtures

* Do not report invalid lhs in toAssignable

* Do not validate function id multiple times

* Dedupe reserved await errors

* Remove duplicate errors about strict reserved bindings

* Remove duplicated error about yield/await inside params

* Don't error twice for methods in object patterns

* Don't report invalid super() twice

* Remove dup error about reserved param for expr arrows

* Remove double escapes in migrated tests

* Dedupe errors about invalid escapes in identifiers

* Remove duplicated error about decorated constructor

* Remove duplicated error about spread in flow class

* Don't throw for invalid super usage

* Don't fail for object decorators with stage 2

* Fix flow inexact type errors

* Fix flow

* Fix errors about escapes in keywords (ref: #10455)

* Update after rebase

* Fix todo

* Remove duplicated error when using += for defaults

* Remove unnecessary throw

* Nit: use ??
2019-11-05 10:15:00 +01:00
Daniel Tschinder
85432e2c44
Remove guardedHandlers from ASTs (#9979) 2019-05-15 03:37:22 -07:00
Daniel Tschinder
6bc9e7ebda
Correctly check for-in and for-of loop for invalid left-hand side (#9768)
* Correctly check for-in and for-of loop for invalid left-hand side

* Overwrite with env variable
2019-03-26 15:32:14 -07:00
Nicolò Ribaudo
0345c1bc1d
Use for..of Object.keys instead of for..in (#9518)
In https://github.com/babel/babel/issues/9511 (and #9495 is another symptom), @PavelKastornyy reported a node crash becaue the JavaScript heap run out of memory. The problem was that their code was adding enumerable properties to `Object.prototype`: it is something that shouldn't be done, but Babel shouldn't make node crash if someone adds them.
I reduced down the problem to `for...in` loops in `@babel/traverse` that grew the memory consumption exponentially because of that unexpected properties.
2019-02-26 20:09:02 +01:00
Daniel Tschinder
d349b74a4f
Better error output in parser tests (#9491) 2019-02-11 02:13:24 -08:00
Daniel Tschinder
0370af58f1 perf: Use strict equals 2019-01-17 16:15:03 -08:00
Ger Hobbelt
e86d1e0d6a babel/parser: test helpers: write expected throw message to options.json ~ complete jest -u functionality (#8178) [skip ci]
* babel/parser: test helpers: when test fails with an exception and both reference output file and options.json file do not exist, write a simple options.json with the error message to expect when such a file doesn't exist yet. This completes the `jest -u` capability for new tests which are expected to *fail*.
2018-06-15 10:27:19 -04:00
Chaitanya Kumar Kamatham
daf0ca8680 Rename "babylon" to "@babel/parser" (#7937) 🎉 2018-05-19 00:03:05 -04:00