13 Commits

Author SHA1 Message Date
Nicolò Ribaudo
695abb8dfc
Set correct path.context un push/unshiftContainer (#12394) 2020-11-25 16:51:58 +01: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
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
b706e34fc8 [decorators] Correctly insert _initialize(this) after super(). (#8970)
* [decorators] Correctly insert `_initialize(this)` after `super()`.

This commit fixes to problem:
1) After `super();` statements, `_initialize(this)` was inserted without
   a trailing semicolon.
2) `(0, super())` causes an infinite recursion.

* Fix tests

* Add test
2018-11-06 21:58:09 -08:00
Kevin Thomas
842c164be5 Insertafter jsx fix (#8833)
* Add check for JSXElement

* Add test
2018-10-10 10:10:20 -06:00
Chaitanya Kumar Kamatham
daf0ca8680 Rename "babylon" to "@babel/parser" (#7937) 🎉 2018-05-19 00:03:05 -04:00
Deven Bansod
8b57a3e3b9 Migrate a few packages' tests to use Jest Expect (see below)
* Migrate the following packages' tests:
    * babel-helper-annotate-as-pure
    * babel-helper-module-imports
    * babel-helper-transform-fixture-test-runner
    * babel-highlight
    * babel-node
    * babel-plugin-transform-modules-commonjs
    * babel-preset-env-standalone
    * babel-preset-env
    * babel-preset-es2015
    * babel-preset-react
    * babel-standalone
    * babel-template
    * babel-traverse
    * babel-types
2018-03-24 16:22:10 +05:30
Nicolò Ribaudo
2297e2d764
Fix a regression introduced in #7040 (#7116) 2017-12-28 22:15:53 +01:00
Nicolò Ribaudo
68476b6ddd
Make .insert{Before,After} work by default when the parent is an eport declaration (#7040) 2017-12-19 00:05:29 +01:00
Henry Zhu
691f90a774 Scoped: change test imports to @babel/ [skip ci] 2017-10-16 22:49:56 -04:00
Abhilash Singh
6230855b71 unshiftContainer seems to incorrectly handle function params #6150 (#6354) 2017-09-30 09:14:51 -04:00
Justin Ridgewell
4daf11528c Return inserted/replaced paths (#5710)
* Return inserted/replaced paths

This gives `Path`’s replacement and insertion methods a consistent
return value: the inserted/replaced paths.

Before, they could return `undefined`, a `node`, or a the current path
inside an array. It was kinda pointless.  But now they always return an
array of paths, which is useful for solving
https://github.com/babel/babel/pull/4935#discussion_r96151368.

* Return inserted nodes and not BlockStatement

Addded test for bug #4363

* Cleanups

- `#replaceWith` will now return the current path if it's the same node
- `#insertAfter` and `#insertBefore` use public Path APIs now
- Makes container insertion faster (single splice call)
- Use public APIs in container insertion
- Replacing a statement with an expression returns the expression's path
- Replacing an expression with multiple statements returns the inserted
  closure's body's paths.
2017-09-11 16:07:04 -04:00
Justin Ridgewell
63204ae51e Remove maybePopFromStatements (#5945)
It prevented you from pushing into the `params` of a function.

```js
fnpath.pushContainer("params", t.identifier("memo"))
```
2017-07-18 14:55:33 -04:00