@babel/traverse 7.17.12 → 7.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of @babel/traverse might be problematic. Click here for more details.

@@ -94,9 +94,12 @@ function isCompletionRecord(allowInsideFunction) {
94
94
  let first = true;
95
95
 
96
96
  do {
97
- const container = path.container;
97
+ const {
98
+ type,
99
+ container
100
+ } = path;
98
101
 
99
- if (path.isFunction() && !first) {
102
+ if (!first && (path.isFunction() || type === "StaticBlock")) {
100
103
  return !!allowInsideFunction;
101
104
  }
102
105
 
@@ -105,7 +108,7 @@ function isCompletionRecord(allowInsideFunction) {
105
108
  if (Array.isArray(container) && path.key !== container.length - 1) {
106
109
  return false;
107
110
  }
108
- } while ((path = path.parentPath) && !path.isProgram());
111
+ } while ((path = path.parentPath) && !path.isProgram() && !path.isDoExpression());
109
112
 
110
113
  return true;
111
114
  }
@@ -854,7 +854,9 @@ class Scope {
854
854
  push(opts) {
855
855
  let path = this.path;
856
856
 
857
- if (!path.isBlockStatement() && !path.isProgram()) {
857
+ if (path.isPattern()) {
858
+ path = this.getPatternParent().path;
859
+ } else if (!path.isBlockStatement() && !path.isProgram()) {
858
860
  path = this.getBlockParent().path;
859
861
  }
860
862
 
@@ -921,6 +923,18 @@ class Scope {
921
923
  throw new Error("We couldn't find a BlockStatement, For, Switch, Function, Loop or Program...");
922
924
  }
923
925
 
926
+ getPatternParent() {
927
+ let scope = this;
928
+
929
+ do {
930
+ if (!scope.path.isPattern()) {
931
+ return scope.getBlockParent();
932
+ }
933
+ } while (scope = scope.parent.parent);
934
+
935
+ throw new Error("We couldn't find a BlockStatement, For, Switch, Function, Loop or Program...");
936
+ }
937
+
924
938
  getAllBindings() {
925
939
  const ids = Object.create(null);
926
940
  let scope = this;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@babel/traverse",
3
- "version": "7.17.12",
3
+ "version": "7.18.0",
4
4
  "description": "The Babel Traverse module maintains the overall tree state, and is responsible for replacing, removing, and adding nodes",
5
5
  "author": "The Babel Team (https://babel.dev/team)",
6
6
  "homepage": "https://babel.dev/docs/en/next/babel-traverse",
@@ -17,13 +17,13 @@
17
17
  "main": "./lib/index.js",
18
18
  "dependencies": {
19
19
  "@babel/code-frame": "^7.16.7",
20
- "@babel/generator": "^7.17.12",
20
+ "@babel/generator": "^7.18.0",
21
21
  "@babel/helper-environment-visitor": "^7.16.7",
22
22
  "@babel/helper-function-name": "^7.17.9",
23
23
  "@babel/helper-hoist-variables": "^7.16.7",
24
24
  "@babel/helper-split-export-declaration": "^7.16.7",
25
- "@babel/parser": "^7.17.12",
26
- "@babel/types": "^7.17.12",
25
+ "@babel/parser": "^7.18.0",
26
+ "@babel/types": "^7.18.0",
27
27
  "debug": "^4.1.0",
28
28
  "globals": "^11.1.0"
29
29
  },