@babel/traverse 7.16.7 → 7.16.8

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.

package/lib/index.js CHANGED
@@ -23,8 +23,6 @@ Object.defineProperty(exports, "Scope", {
23
23
  });
24
24
  exports.visitors = exports.default = void 0;
25
25
 
26
- var _context = require("./context");
27
-
28
26
  var visitors = require("./visitors");
29
27
 
30
28
  exports.visitors = visitors;
@@ -33,6 +31,8 @@ var _t = require("@babel/types");
33
31
 
34
32
  var cache = require("./cache");
35
33
 
34
+ var _traverseNode = require("./traverse-node");
35
+
36
36
  var _path = require("./path");
37
37
 
38
38
  var _scope = require("./scope");
@@ -59,7 +59,7 @@ function traverse(parent, opts = {}, scope, state, parentPath) {
59
59
  }
60
60
 
61
61
  visitors.explode(opts);
62
- traverse.node(parent, opts, scope, state, parentPath);
62
+ (0, _traverseNode.traverseNode)(parent, opts, scope, state, parentPath);
63
63
  }
64
64
 
65
65
  var _default = traverse;
@@ -72,15 +72,8 @@ traverse.cheap = function (node, enter) {
72
72
  return traverseFast(node, enter);
73
73
  };
74
74
 
75
- traverse.node = function (node, opts, scope, state, parentPath, skipKeys) {
76
- const keys = VISITOR_KEYS[node.type];
77
- if (!keys) return;
78
- const context = new _context.default(scope, opts, state, parentPath);
79
-
80
- for (const key of keys) {
81
- if (skipKeys && skipKeys[key]) continue;
82
- if (context.visit(node, key)) return;
83
- }
75
+ traverse.node = function (node, opts, scope, state, path, skipKeys) {
76
+ (0, _traverseNode.traverseNode)(node, opts, scope, state, path, skipKeys);
84
77
  };
85
78
 
86
79
  traverse.clearNode = function (node, opts) {
@@ -24,9 +24,9 @@ exports.skipKey = skipKey;
24
24
  exports.stop = stop;
25
25
  exports.visit = visit;
26
26
 
27
- var _index = require("../index");
27
+ var _traverseNode = require("../traverse-node");
28
28
 
29
- var _index2 = require("./index");
29
+ var _index = require("./index");
30
30
 
31
31
  function call(key) {
32
32
  const opts = this.opts;
@@ -104,9 +104,7 @@ function visit() {
104
104
 
105
105
  restoreContext(this, currentContext);
106
106
  this.debug("Recursing into...");
107
-
108
- _index.default.node(this.node, this.opts, this.scope, this.state, this, this.skipKeys);
109
-
107
+ this.shouldStop = (0, _traverseNode.traverseNode)(this.node, this.opts, this.scope, this.state, this, this.skipKeys);
110
108
  restoreContext(this, currentContext);
111
109
  this.call("exit");
112
110
  return this.shouldStop;
@@ -125,7 +123,7 @@ function skipKey(key) {
125
123
  }
126
124
 
127
125
  function stop() {
128
- this._traverseFlags |= _index2.SHOULD_SKIP | _index2.SHOULD_STOP;
126
+ this._traverseFlags |= _index.SHOULD_SKIP | _index.SHOULD_STOP;
129
127
  }
130
128
 
131
129
  function setScope() {
@@ -467,7 +467,7 @@ class Scope {
467
467
  checkBlockScopedCollisions(local, kind, name, id) {
468
468
  if (kind === "param") return;
469
469
  if (local.kind === "local") return;
470
- const duplicate = kind === "let" || local.kind === "let" || local.kind === "const" || local.kind === "module" || local.kind === "param" && (kind === "let" || kind === "const");
470
+ const duplicate = kind === "let" || local.kind === "let" || local.kind === "const" || local.kind === "module" || local.kind === "param" && kind === "const";
471
471
 
472
472
  if (duplicate) {
473
473
  throw this.hub.buildError(id, `Duplicate declaration "${name}"`, TypeError);
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.traverseNode = traverseNode;
7
+
8
+ var _context = require("./context");
9
+
10
+ var _t = require("@babel/types");
11
+
12
+ const {
13
+ VISITOR_KEYS
14
+ } = _t;
15
+
16
+ function traverseNode(node, opts, scope, state, path, skipKeys) {
17
+ const keys = VISITOR_KEYS[node.type];
18
+ if (!keys) return false;
19
+ const context = new _context.default(scope, opts, state, path);
20
+
21
+ for (const key of keys) {
22
+ if (skipKeys && skipKeys[key]) continue;
23
+
24
+ if (context.visit(node, key)) {
25
+ return true;
26
+ }
27
+ }
28
+
29
+ return false;
30
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@babel/traverse",
3
- "version": "7.16.7",
3
+ "version": "7.16.8",
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.16.7",
20
+ "@babel/generator": "^7.16.8",
21
21
  "@babel/helper-environment-visitor": "^7.16.7",
22
22
  "@babel/helper-function-name": "^7.16.7",
23
23
  "@babel/helper-hoist-variables": "^7.16.7",
24
24
  "@babel/helper-split-export-declaration": "^7.16.7",
25
- "@babel/parser": "^7.16.7",
26
- "@babel/types": "^7.16.7",
25
+ "@babel/parser": "^7.16.8",
26
+ "@babel/types": "^7.16.8",
27
27
  "debug": "^4.1.0",
28
28
  "globals": "^11.1.0"
29
29
  },