524 Commits

Author SHA1 Message Date
Nicolò Ribaudo
75767d87cb v7.7.4 2019-11-23 00:05:58 +01:00
Kenza Houmani
2b082601a7 Fix parentheses on replaceWithMultiple for JSX (#10598)
* Closes #9851 Fix parentheses on replaceWithMultiple for JSX

* Rename test

* Use generate(ast) directly
2019-11-11 12:36:17 +03:00
Nicolò Ribaudo
35f4d12763 v7.7.2 2019-11-07 02:20:52 +03:00
Huáng Jùnliàng
0f949990c3
fix: add inList setter for compatibility with babel-minify (#10656) 2019-11-05 12:28:16 -05:00
Nicolò Ribaudo
97faa83953 v7.7.0 2019-11-05 11:27:14 +01:00
Huáng Jùnliàng
b114486bc1 Traverse performance (#10480)
* perf: remove this.inList assignment

* perf: convert NodePath.parentKey into accessor function

* perf: compress shouldSkip/shouldStop/removed traverse flags

* perf: lazy initialize this.skipKeys

* perf: lazily initialize NodePath.data

* add code comments before bit operations

* remove unused typeAnnotation property

# Conflicts:
#	packages/babel-traverse/src/path/index.js

* early return when visitor keys are empty
2019-11-05 11:11:58 +01:00
Nicolò Ribaudo
43b623c1f1
[traverse] Allow skipping nodes inserted with .replaceWith() (#9777)
* Avoid regression
2019-10-18 00:16:35 +02:00
Nicolò Ribaudo
99035ca96e
Don't use args rest/spread to hoist super method calls (#9939)
* Don't use args rest/spread to hoist super method calls

* Hoist this in hoisted super method calls

* Make the code more readable

Review by edoardocavazza
2019-10-11 10:18:54 +02:00
Nicolò Ribaudo
d329156ebc
v7.6.3 2019-10-08 21:31:40 +02:00
Nicolò Ribaudo
3498195ae2
Do not hoist jsx referencing a mutable binding (#10529) 2019-10-08 18:50:03 +02:00
Nicolò Ribaudo
b9cb4af953
v7.6.2 2019-09-23 23:14:37 +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
Nicolò Ribaudo
610d6bdc62
Do not guess relative execution status for exported fns (#10417) 2019-09-10 19:47:27 +02:00
Nicolò Ribaudo
cbd5a26e57
v7.6.0 2019-09-06 19:25:16 +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
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
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
0407f034f0
v7.5.5 2019-07-17 23:08:08 +02:00
cybai
42000b9907 Upgrade lodash to 4.17.13 (#10191) 2019-07-12 10:29:06 +02:00
Nicolò Ribaudo
49da9a07c8
v7.5.0 2019-07-04 14:52:17 +02:00
Tan Li Hau
d50e78d45b fix await and yield for do expression (#10072) 2019-07-03 09:54:39 -05:00
Min ho Kim
0bf0ae3410 Fix typos (#10153) 2019-07-03 15:51:48 +02:00
Tan Li Hau
b4c9cb0222 Fixed computed keys for class expression (#10029)
* test case for insertBefore for jsx

* fix unshiftContainer and insertBefore

* use path.scope.push

* add test making sure computedKeys var declaration at the right block

* add comment

* nit [skip ci]
2019-05-28 23:07:55 +02:00
Nicolò Ribaudo
33ab4f1661
v7.4.5 2019-05-21 19:38:26 +02:00
Pablo Navarro
16e17c560b Add missing space in error messages (#9909) 2019-04-29 19:52:13 +02:00
Nicolò Ribaudo
2c88694388
v7.4.4 2019-04-26 23:00:07 +02:00
Daniel Tschinder
bf17871b82 Fix flow types in traverse/path/family and enable flow (#9870) 2019-04-23 10:46:55 -04:00
Nicolò Ribaudo
508fde4009
v7.4.3 2019-04-02 21:36:09 +02:00
Grégoire Geis
72161a64b2 @babel/traverse: Fix NodePath.getData (#9415)
* @babel/traverse: Fix NodePath.getData

Currently, if the obtained value is `false`, it will be replaced by the given default value, which is invalid. This makes sure that we only set the default value when the value is `undefined`, instead of falsy.

* Add test and fix object protoype

* Allow false as default value
2019-03-26 16:58:38 -07:00
Nicolò Ribaudo
f1328fb913
v7.4.0 2019-03-19 21:27:16 +01:00
Pelle Nielsen
a35e5a314a Fix TSFunctionType visitors definition (#9692)
When traversing a tree parsing for TypeScript syntax and hitting a `TSFunctionType` node, the `typeParameters` and `typeAnnotation` fields are correctly visited but the `parameters` field isn't. As a result visitors by default don't visit `foo` below:

```
var x: (foo) => void; // foo is never visited
```
```
module.exports = function() {
  return {
    visitor: {
      Identifier(path) {
        if (path.node.name == "foo") {
          // Never hit because it's nested within TSFunctionType.parameters
          path.node.name = "bar";
        }
      }
    }
  };
}
```

It appears to be a bug in babel-types/src/definitions/typescript.js which omits `parameters` in the visitors list for `fnOrCtr`. Fixed by adding it.
2019-03-16 09:24:23 +01:00
Erik Arvidsson
fba5655a44 Parenthesized expressions (#8025)
* Add parser createParenthesizedExpressions option  …

When set to `true` we create `ParenthesizedExpression` nodes instead of
setting `extra.parenthesized`.

* Also update babel-parser.d.ts
2019-03-06 22:43:36 +01:00
Nicolò Ribaudo
f195daa092
Don't add params of anonymous exported function decls to the outer scope (#9613)
* Don't add params of anonymous exported function decls to the outer scope

* Test
2019-03-01 00:09:49 +01:00
Nicolò Ribaudo
5c8cc0d536
Mark FOO in "var { x: FOO }˝ as a binding, not as a reference (#9492) 2019-02-27 00:17:11 +01: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
Nicolò Ribaudo
1f6454cc90
v7.3.4 2019-02-25 19:29:12 +01:00
Justin Ridgewell
fc1ea7f496 Revert "Parenthesized expressions (#8025)"
This reverts commit dd8b700a2c4c975584c7b2ea43023aa275c16167.
2019-02-25 19:03:00 +01:00
Nicolò Ribaudo
0b01b5217b
Use correct "this" in static fields (#9508) 2019-02-24 08:14:49 +01:00
Erik Arvidsson
dd8b700a2c Parenthesized expressions (#8025)
* Add parser createParenthesizedExpressions option  …

When set to `true` we create `ParenthesizedExpression` nodes instead of
setting `extra.parenthesized`.

* Also update babel-parser.d.ts
2019-02-23 02:45:25 -05:00
Daniel Tschinder
b32d271fee
Migrate some duplicate binding tests to traverse (#9532)
* Migrate try-catch duplicate error

* Remove exception for functions and let in the same scope

* Migrate duplicate bindings tests to traverse

* Add test for subscope and let/const

* Add more test cases
2019-02-19 21:25:49 -08:00
Daniel Tschinder
a1ea765b95
Make tests spec compliant and avoid duplicate declarations in input files (#9522) 2019-02-18 16:14:35 -08:00
Alec
85ea5b0b50 Version bump of lodash (#9500)
https://tools.cisco.com/security/center/viewAlert.x?alertId=59546
2019-02-13 16:17:39 +01:00
Nicolò Ribaudo
0bb720401b v7.2.3 2018-12-20 12:18:31 +01:00
Nicolò Ribaudo
911c2d0bf4
Use @babel/eslint-plugin-developement (#9206) 2018-12-18 22:59:43 +01:00
Nicolò Ribaudo
c1499b13ac v7.2.2 2018-12-15 10:59:56 +01:00
Joel Denning
d305419da6 Not depending on return value of super(). Fixes #9020. (#9060)
* Not depending on return value of super(). Fixes #9020.

* Feedback from nicolo-ribaudo

* Feedback -- fixing bad call to replaceWithMultiple
2018-12-04 21:50:17 +01:00
Nicolò Ribaudo
4e1d6e7ff4 v7.1.6 2018-11-13 22:10:06 +01:00
Daniel Tschinder
74f969b603 Update debug dependency (#8989) 2018-11-09 16:27:41 +01:00