@babel/traverse 7.7.4 → 7.8.6

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.

@@ -25,9 +25,9 @@ function shareCommentsWithSiblings() {
25
25
  const hasPrev = Boolean(prev.node);
26
26
  const hasNext = Boolean(next.node);
27
27
 
28
- if (hasPrev && hasNext) {} else if (hasPrev) {
28
+ if (hasPrev && !hasNext) {
29
29
  prev.addComments("trailing", trailing);
30
- } else if (hasNext) {
30
+ } else if (hasNext && !hasPrev) {
31
31
  next.addComments("leading", leading);
32
32
  }
33
33
  }
@@ -98,7 +98,7 @@ const Expression = {
98
98
  };
99
99
  exports.Expression = Expression;
100
100
  const Scope = {
101
- types: ["Scopable"],
101
+ types: ["Scopable", "Pattern"],
102
102
 
103
103
  checkPath(path) {
104
104
  return t.isScope(path.node, path.parent);
@@ -19,7 +19,9 @@ function remove() {
19
19
 
20
20
  this.resync();
21
21
 
22
- this._removeFromScope();
22
+ if (!this.opts || !this.opts.noScope) {
23
+ this._removeFromScope();
24
+ }
23
25
 
24
26
  if (this._callRemovalHooks()) {
25
27
  this._markRemoved();
@@ -146,14 +146,14 @@ const collectorVisitor = {
146
146
  BlockScoped(path) {
147
147
  let scope = path.scope;
148
148
  if (scope.path === path) scope = scope.parent;
149
- scope.getBlockParent().registerDeclaration(path);
150
- },
149
+ const parent = scope.getBlockParent();
150
+ parent.registerDeclaration(path);
151
151
 
152
- ClassDeclaration(path) {
153
- const id = path.node.id;
154
- if (!id) return;
155
- const name = id.name;
156
- path.scope.bindings[name] = path.scope.getBinding(name);
152
+ if (path.isClassDeclaration() && path.node.id) {
153
+ const id = path.node.id;
154
+ const name = id.name;
155
+ path.scope.bindings[name] = path.scope.parent.getBinding(name);
156
+ }
157
157
  },
158
158
 
159
159
  Block(path) {
@@ -774,10 +774,18 @@ class Scope {
774
774
 
775
775
  getBinding(name) {
776
776
  let scope = this;
777
+ let previousPath;
777
778
 
778
779
  do {
779
780
  const binding = scope.getOwnBinding(name);
780
- if (binding) return binding;
781
+
782
+ if (binding) {
783
+ if (previousPath && previousPath.isPattern() && previousPath.parentPath.isFunction() && binding.kind !== "param") {} else {
784
+ return binding;
785
+ }
786
+ }
787
+
788
+ previousPath = scope.path;
781
789
  } while (scope = scope.parent);
782
790
  }
783
791
 
package/lib/visitors.js CHANGED
@@ -184,6 +184,10 @@ function wrapWithStateOrWrapper(oldVisitor, state, wrapper) {
184
184
  newFn = wrapper(state.key, key, newFn);
185
185
  }
186
186
 
187
+ if (newFn !== fn) {
188
+ newFn.toString = () => fn.toString();
189
+ }
190
+
187
191
  return newFn;
188
192
  });
189
193
  newVisitor[key] = fns;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@babel/traverse",
3
- "version": "7.7.4",
3
+ "version": "7.8.6",
4
4
  "description": "The Babel Traverse module maintains the overall tree state, and is responsible for replacing, removing, and adding nodes",
5
5
  "author": "Sebastian McKenzie <sebmck@gmail.com>",
6
6
  "homepage": "https://babeljs.io/",
@@ -11,18 +11,18 @@
11
11
  "repository": "https://github.com/babel/babel/tree/master/packages/babel-traverse",
12
12
  "main": "lib/index.js",
13
13
  "dependencies": {
14
- "@babel/code-frame": "^7.5.5",
15
- "@babel/generator": "^7.7.4",
16
- "@babel/helper-function-name": "^7.7.4",
17
- "@babel/helper-split-export-declaration": "^7.7.4",
18
- "@babel/parser": "^7.7.4",
19
- "@babel/types": "^7.7.4",
14
+ "@babel/code-frame": "^7.8.3",
15
+ "@babel/generator": "^7.8.6",
16
+ "@babel/helper-function-name": "^7.8.3",
17
+ "@babel/helper-split-export-declaration": "^7.8.3",
18
+ "@babel/parser": "^7.8.6",
19
+ "@babel/types": "^7.8.6",
20
20
  "debug": "^4.1.0",
21
21
  "globals": "^11.1.0",
22
22
  "lodash": "^4.17.13"
23
23
  },
24
24
  "devDependencies": {
25
- "@babel/helper-plugin-test-runner": "^7.7.4"
25
+ "@babel/helper-plugin-test-runner": "^7.8.3"
26
26
  },
27
- "gitHead": "75767d87cb147709b9bd9b99bf44daa6688874a9"
27
+ "gitHead": "750d3dde3bd2d390819820fd22c05441da78751b"
28
28
  }