Huáng Jùnliàng
92434269af
fix: do not eat get/set after async is parsed ( #11916 )
2020-08-05 08:19:59 -05:00
Huáng Jùnliàng
a4ebe29b3f
Parser refactoring ( #11871 )
...
* refactor: parseMaybeUnary => parseUnary
* refactor: extract shouldExitDescending method
* refactor: add parseUpdate
* refactor: avoid comparing with hardcoded token value
* refactor: add ParseNewOrNewTarget
* refactor: add parseCoverCallAndAsyncArrowHead
* add parseBind
* refactor: polish parseTaggedTemplateExpression interface
* refactor: add parseMember method
* refactor: add parseSuper method
* refactor: add parseAsyncArrowUnaryFunction method
* fix: disallow line break before async binding arrow
* refactor: simplify tt.name logic
* refactor: add parseDo method
* refactor: misc
* refactor: rename parseObjectMember by parsePropertyDefinition
* refactor: unify set/get/async keyword parsing in ObjectMethod
* refactor: misc
* refactor: add parseArrayLike method
* refactor: move fsharp epilogure and prologue inside parseObjectLike
* fixup
* refactor: rename parseFunctionExpression to parseFunctionOrFunctionSent
* refactor: remove redundant logic
* refactor: rename parseClassPropertyName by parseClassElementName
* refactor: avoid unecessary lookahead when parsing tt._export
* fix: export-default-from should support escaped async as export binding
* address review comments
* parseUnary -> parseMaybeUnary
2020-07-31 20:36:04 -04:00
Huáng Jùnliàng
01d4625412
Correctly check reserved word for PropertyDefinition: IdentifierReference ( #11862 )
...
* fix: check IdentifierReference in PropertyDefinition
* chore: add more test cases
* fix: incorrect test title
2020-07-29 19:40:52 -04:00
Vahagn Aharonian
b651a6f6ab
Enable logical assignment by default in @babel/parser ( #11860 ) ( #11869 )
2020-07-29 18:32:12 -04:00
Huáng Jùnliàng
059e9124ff
Add decimal parsing support ( #11640 )
...
* docs: add DecimalLiteral to AST spec
* add decimal support
* fix: throw invalid decimal on start
* add DecimalLiteral type definitions
* update parser typings
* add generator support
* add syntax-decimal plugin
* Add syntax-decimal to babel-standalone
* add syntax-decimal to missing plugin helpers
* fix incorrect test macro
2020-07-29 16:43:15 -04:00
Huáng Jùnliàng
f4eeff947d
fix: correctly set innerEndPos in CoverParenthesizedExpressionAndArrowParameterList ( #11847 )
2020-07-16 17:11:06 -05:00
Huáng Jùnliàng
02c8fd92bd
fix: add optional: false to chained optional call expression ( #11814 )
2020-07-09 20:33:50 -04:00
Huáng Jùnliàng
d67629b114
fix: throw expect jsx plugin error when an idStart or > is seen ( #11774 )
...
* fix: throw expect jsx plugin error when an idStart or > is seen
* fix: avoid throwing undefined
* add test case
2020-07-01 15:17:05 -04:00
Kai Cataldo
75c2300c28
Add @babel/eslint-plugin-development-internal ( #11376 )
...
* Add @babel/eslint-plugin-internal
* Add dry-error-messages rule
* Address feedback
* Enable new rule
* fix author field
* Fix errors
* Add readme
* Add example configuration
* Handle directories
* run make bootstrap
* More updates!
* Fix errors
* Update tests
* Fix CI race condition
2020-06-22 19:43:29 -04:00
Jorge Henriquez
beca7e2d8e
Add better parser error when using jsx ( #11722 )
...
* Add "<" parser tests
* No {jsx,flow,typescript} plugin
* Type parameter
* Valid JS Code
* Add: better parser error when using jsx
Address #11499
* Add: babel parser test
Test parser with no plugins and when jsx is given with a js expression
* Add: no flow but with typescript test
* Add: type paramter test with no plugins (no flow)
* Add: unclosed jsx element test
2020-06-22 18:12:52 -04:00
Huáng Jùnliàng
30835f14db
fix: implement early errors for record and tuple ( #11652 )
2020-06-20 02:35:27 +02:00
Huáng Jùnliàng
b5c4a46a69
refactor: split locationParser into ParserErrors and error message ( #11653 )
2020-05-30 15:05:42 -04:00
Justin Ridgewell
bda759ac3d
Handle private access chained on an optional chain ( #11248 )
...
Co-authored-by: Nicolò Ribaudo <nicolo.ribaudo@gmail.com>
Co-authored-by: Huáng Jùnliàng <jlhwung@gmail.com>
2020-05-26 22:18:17 +02:00
Justin Ridgewell
7459038db8
Add private-property-in-object support ( #11372 )
...
https://github.com/tc39/proposal-private-fields-in-in
Co-Authored-By: Nicolò Ribaudo <nicolo.ribaudo@gmail.com>
Co-Authored-By: Huáng Jùnliàng <jlhwung@gmail.com>
2020-05-26 22:18:17 +02:00
Vivek Nayyar
66b86e088c
added basic support for module attributes and tests updated ( #10962 )
...
Co-Authored-By: Nicolò Ribaudo <nicolo.ribaudo@gmail.com>
2020-05-25 01:26:28 +02:00
Kiko Estrada
5dd7f438c9
Enable import.meta by default in @babel/parser ( #11406 )
2020-05-24 22:57:34 +02:00
Huáng Jùnliàng
2f31ecf85d
fix: allow bigInt in method name and TSLiteralType ( #11547 )
...
* refactor: add isLiteralPropertyName to parser utils
* address review comments [skip-ci]
* refactor: keyword is valid identifierName
* fix: allow bigint in TSLiteralType
* update typescript test whitelist
2020-05-14 18:40:52 -04:00
Nicolò Ribaudo
31b361b736
Use ?. where it represents the intended semantics ( #11512 )
2020-05-09 23:31:50 +02:00
Huáng Jùnliàng
8b976b0670
fix: do not push new token context when function is following dot/questionDot ( #11388 )
...
* fix: do not push new token context when function is following dot/questionDot
* more cautiously poping context
2020-04-08 10:10:36 -04:00
Vedant Roy
0e5c1da659
fix: async arrow functions should not be allowed after binary… ( #11284 )
...
* Forbid async arrow functions after binary operator.
This commit makes Babel throw an error when parsing
code like "3 + async() => 2".
* Make atPossibleAsync more accurate
* Change atPossibleAsync to atPossibleAsyncArrow
Add an extra test to atPossibleAsync and refactor it to
atPossibleAsyncArrow. This also fixes a bug in the Typescript plugin,
so a new test has been added.
* Add test for async arrow after unary operator
2020-03-21 19:38:36 +01:00
Rick Button
3ce7c2e394
Added support for record and tuple syntax. ( #10865 )
...
* Added support for record and tuple syntax.
This commit adds support for both the hash #{} and bar {||}
syntaxes to babel-parser, as well as adds the supporting
babel-plugin-syntax-record-and-tuple plugin to enable support
for the syntax. Does not include any transform for records and
tuples.
* typo
* added check to ensure recordAndTuple in babel-parser
* switched to syntaxType option instead of explicit entries for each record and tuple type
* switched to using recordAndTupleSyntaxType for generator options instead of adding to node
* added tests for generator option recordAndTupleSyntaxType
* added test for record and tuple bar syntax with flow typings
* added tests for invalid/missing recordAndTuple syntaxType parser option
* fixed flowcheck errors
* fix merge with class privates in tokenizer
* Update packages/babel-parser/src/types.js
Co-Authored-By: Nicolò Ribaudo <nicolo.ribaudo@gmail.com>
* improved recordAndTuple generator error message, added tests for invalid,missing options
* updated error messages for invalid parser syntaxType option
* updated error message
* added better error messages for when the recordAndTuple syntaxType is doesn't match the syntax used
* updated record and tuple support to use new error message templates
* added recordAndTuple to missing plugin helpers
* Fix linting
Co-authored-by: Nicolò Ribaudo <nicolo.ribaudo@gmail.com>
2020-03-16 23:57:44 +01:00
Arun Kumar Mohan
84a9ea455b
Allow await when it is not in AsyncArrowHead ( #11148 )
2020-03-16 22:26:48 +01:00
Kai Cataldo
2057d2b159
fix: non-directive "use strict" should not enable parsing in strict mode ( #11188 )
...
* fix: non-directive "use strict" should not enable parsing in strict mode
* Remove dead code
* Add stricter type annotations
* set oldStrict explicitly to null
* Fix error
* label callback argument
* update comment
* Address feedback
* Remove this.state.octalPosition
* Add additional tests
* Revert "Remove this.state.octalPosition"
This reverts commit bcc78c9530f8c840f85e86053b75efce662f34d1.
* Remove containsOctal
* Report multiple octal literals in single token
* Fix comments
* remove Array.prototype.flat()
2020-03-05 17:34:27 -05:00
Huáng Jùnliàng
21c9141872
Refactor: add parser message template ( #11192 )
...
* refactor: add raiseWithData method
* refactor: error message template
* fix missing plugin error structure
* fix flow errors
* refactor: use error message template in eslint plugin
* refacotr: use error message template in flow plugin
* refactor: use error message template in typescript plugin
* refactor: use error message template in jsx plugin
* address review comments
* Update packages/babel-parser/src/parser/location.js
Co-Authored-By: Nicolò Ribaudo <nicolo.ribaudo@gmail.com>
Co-authored-by: Nicolò Ribaudo <nicolo.ribaudo@gmail.com>
2020-03-03 14:06:05 -05:00
Huáng Jùnliàng
38529699d6
Refactor await/yield production parameter tracking ( #10956 )
...
* test: add test fixtures
* refactor: track AWAIT and YIELD in separate handler
* fix flow errors
* add flow type annotation to production-parameter
* address review comments
* refactor: track [Return] parameter
2020-02-09 15:31:29 +01:00
Nicolò Ribaudo
8ab27c8ffe
Wrap type-only class fields in flow comments ( #11096 )
...
* Wrap type-only class fields in flow comments
* Fix
2020-02-09 11:45:42 +01:00
Huáng Jùnliàng
0b3dea8f54
Turn on no-fallthrough rule ( #11093 )
...
* chore: turn on no-fallthrough
* chore: fix no-fallthrough errors
2020-02-07 22:05:19 +01:00
Huáng Jùnliàng
43b23e0869
refactor: simplify toAssignable routine ( #11032 )
...
* refactor: remove isBinding parameter
* remove unused contextDescription
* refactor: remove unnecessary nullish check
* refactor: simplify toAssignable on ParenthesizedExpression
* tests: categorize createParenthesizedExpression tests
2020-01-20 21:04:16 +01:00
Vedant Roy
341964bd4e
fix: properly parse member expression after property initializ… ( #11031 )
...
Fixes issue 10989 where the only the identifier in a member expression that is the value of an object property would be parsed. Removing checkExpressionErrors in parseExprSubscripts results in the subscript also being parsed.
2020-01-20 00:33:09 +01:00
Huáng Jùnliàng
45301c5304
Update coalesce precedence ( #11017 )
...
* refactor: reimplement nullish coalescing precedence tracking
Co-authored-by: Toru Nagashima <public@mysticatea.dev>
* fix: Coalesce has same precedence with LogicalOR
* fix flow errors
Co-authored-by: Toru Nagashima <public@mysticatea.dev>
2020-01-17 20:57:07 +01:00
Huáng Jùnliàng
a1063d2583
fix: triple __proto__ in object patterns should be allowed ( #11009 )
2020-01-16 09:34:47 -05:00
Huáng Jùnliàng
9df70b4505
Duplicate __proto__ key should be allowed in object patterns ( #10987 )
...
* refactor: replace refShorthandDefaultPos by refExpressionErrors
* fix: duplicate __proto__ keys should be allowed in patterns
* docs: add comments for ExpressionErrors.doubleProto [ci-skip]
* test: add more test for coverage
2020-01-14 22:53:45 -05:00
Huáng Jùnliàng
81c5f1f22d
Disallow private name in object elements and TS type elements ( #10980 )
...
* fix: disallow private name in object member and TS type elements
* chore: update test262 whitelist
* chore: make flow happy
* Update packages/babel-parser/src/parser/expression.js
Co-Authored-By: Nicolò Ribaudo <nicolo.ribaudo@gmail.com>
* chore: update test fixtures
* Update packages/babel-parser/src/parser/expression.js
Co-Authored-By: Brian Ng <bng412@gmail.com>
* chore: update test fixtures
Co-authored-by: Nicolò Ribaudo <nicolo.ribaudo@gmail.com>
Co-authored-by: Brian Ng <bng412@gmail.com>
2020-01-11 11:26:10 -05:00
jack
5f807ae45b
Enable optional chaining by default in @babel/parser ( #10817 )
2020-01-10 03:09:39 +01:00
Oleksandr Fediashov
c3388ea42f
Enable nullish coalescing by default in @babel/parser ( #10819 )
...
* move files, remove hasPlugin() & expectPlugin()
* restore permissions
2020-01-10 02:52:53 +01:00
Abdul Ali
5b907e9bb7
[parser] enable dynamic import by default ( #10843 )
...
* [parser] enable dynamic import by default
* chore: add back babel-core api test
2020-01-10 02:28:52 +01:00
Nicolò Ribaudo
771c730fda
[parser] Disallow duplicate and undeclared private names ( #10456 )
...
* [parser] Add private names tracking to Scope
- Disallow duplicate private names
- Disallow undeclared private names
* Update tests
* Test all possible duplications
* Test undeclared private names
* Better error message for top-level private names
* Fix flow
* Update test262 whitelist
* Update fixtures
* Update flow whitelist
* Remove old output.json
* Move ClassScopeHandler to a separate class
* Make the code readable
2020-01-10 02:22:05 +01:00
Huáng Jùnliàng
8fd532db39
LiteralPropertyName should allow BigIntLiteral ( #10955 )
...
* fix: property name should allow BigIntLiteral
* test: add non decimal test case
* add bigintIndex to whitelist
2020-01-07 10:23:50 -05:00
Huáng Jùnliàng
455d782ef0
test: add invalid-lone-import test ( #10950 )
...
* test: add lone import test
* polish: raise recoverable error
2020-01-03 23:08:59 +01:00
Huáng Jùnliàng
a28353703f
fix: check await when parsing AsyncArrowBindingIdentifier ( #10953 )
2020-01-03 23:08:28 +01:00
Huáng Jùnliàng
6ee8c97e6a
Fix: TopLevelAwait should respect await identifiers defined in… ( #10947 )
2020-01-03 23:07:11 +01:00
Huáng Jùnliàng
0238244268
refactor: remove unecessary checkYieldAwaitInDefaultParams ( #10936 )
2019-12-30 16:12:09 -05:00
Huáng Jùnliàng
2f3f77926d
refactor: remove unused invalidTemplateEscapePosition tokenizer state ( #10935 )
...
* refactor: remove unused invalidTemplateEscapePosition tokenizer state
* fix flow error
2019-12-30 16:11:56 -05:00
Huáng Jùnliàng
30449fe05d
Refactor parseSubscript ( #10937 )
...
* refactor: unify optionalMemberExpression generation
* test: add optional calls invalid typecasts
* fix: do not parse async arrow when call is optional
* test: update test fixtures
2019-12-30 16:11:39 -05:00
Huáng Jùnliàng
197a8da04d
Remove unused parser methods ( #10942 )
...
* chore: remove unused isStrictBody
* chore: remove unused eatRelational
2019-12-30 16:09:50 -05:00
Huáng Jùnliàng
a18166d2a9
refactor: remove inClassProperty parser state ( #10906 )
2019-12-24 11:43:39 +01:00
Kai Cataldo
7b54a94389
@babel/eslint-parser: fix ImportExpression node to match ESTree spec ( #10828 )
...
* @babel/eslint-parser: fix ImportExpression node to match ESTree spec
* Update caller name for @babel/core.parseSync
* Move logic into estree plugin
* Add estree plugin tests
* Fix Flow error
* Fix flow
* Remove extra properties on ImportExpression node
* Incorporate review feedback
2019-12-11 11:13:57 +01:00
Bowei Han
20e43ad103
validate parentheses in the left-hand side of assignment expressions ( #10576 )
...
* invalid left-hand assignments based on parenthesis
* validate against nested ParenthesizedExpressions
2019-12-09 20:29:02 -05:00
Huáng Jùnliàng
c6e966cac9
[parser] Use scope flags to check arguments ( #10801 )
...
* chore: add test case
Co-authored-by: Jens Maier<jens@elberet.de>
* use scope flags to check arguments
2019-12-05 08:23:53 +01:00
Nicolò Ribaudo
5440ae1cae
Correctly disambiguate / after async fuctions ( #10475 )
...
* Correctly disambiguate / after async fuctions
2019-12-02 22:41:39 +01:00