Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc: Remove some Scope methods for Babel 8 #2935

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 30 additions & 3 deletions docs/v8-migration-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -307,14 +307,34 @@ Check out the [v8-migration guide](v8-migration.md) for other user-level changes
--- functionExpressionPath.is("id")
--- functionExpressionPath.has("id")
+++ functionExpressionPath.node.id

--- functionExpressionPath.has("arguments")
+++ !!functionExpressionPath.node.arguments.length

--- functionExpressionPath.isnt("async")
+++ !functionExpressionPath.node.async
```

- Remove `Scope.prototype.traverse`, `Scope#parentBlock` and `Scope#hub` ([#16705](https://github.com/babel/babel/pull/16705))

__Migration__: Use `scope.path` methods and properties instead:
```diff
--- scope.traverse(scopeRootNode, visitor, state)
+++ scope.path.traverse(visitor, state)

--- scope.parentBlock
+++ scope.path.parent

--- scope.hub
+++ scope.path.hub
```

- Remove `Scope.prototype.getAllBindingsOfKind` and `Scope.prototype.toArray`

These methods have been removed as they are not used anymore in our code base.

__Migration__: You can copy&paste them from Babel 7's source to your plugin.

![low](https://img.shields.io/badge/risk%20of%20breakage%3F-low-yellowgreen.svg)

- Remove `block` argument from `Scope#rename` ([#15288](https://github.com/babel/babel/pull/15288))
Expand All @@ -332,9 +352,12 @@ Check out the [v8-migration guide](v8-migration.md) for other user-level changes

__Migration__: Adapt to the new behaviour. You can use `NodePath#shouldSkip` to check whether a NodePath has been skipped before calling `NodePath#requeue()`.

- Remove methods starting with `_` ([#16504](https://github.com/babel/babel/pull/16504))
- Remove methods starting with `_` from `Scope` and `NodePath` ([#16504](https://github.com/babel/babel/pull/16504), [#16705](https://github.com/babel/babel/pull/16705))

```
These methods were meant to be private.

```js
// NodePath.prototype
_assertUnremoved
_call
_callRemovalHooks
Expand All @@ -355,6 +378,10 @@ Check out the [v8-migration guide](v8-migration.md) for other user-level changes
_resyncParent
_resyncRemoved
_verifyNodeList

// Scope.prototype
nicolo-ribaudo marked this conversation as resolved.
Show resolved Hide resolved
_renameFromMap
_generateUid
```

__Migration__: These methods are meant to be private so there is no real migration approach. But if your plugin / build is broken by this change, feel free to open an issue and tell us how you use these methods and we can see what we can do after Babel 8 is released.
Expand Down