@babel/traverse 7.0.0-beta.5 → 7.0.0-beta.53

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.

@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
 
3
- exports.__esModule = true;
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
4
6
  exports.call = call;
5
7
  exports._call = _call;
6
8
  exports.isBlacklisted = isBlacklisted;
@@ -27,7 +29,7 @@ var _index = _interopRequireDefault(require("../index"));
27
29
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
28
30
 
29
31
  function call(key) {
30
- var opts = this.opts;
32
+ const opts = this.opts;
31
33
  this.debug(key);
32
34
 
33
35
  if (this.node) {
@@ -44,27 +46,18 @@ function call(key) {
44
46
  function _call(fns) {
45
47
  if (!fns) return false;
46
48
 
47
- for (var _iterator = fns, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
48
- var _ref;
49
-
50
- if (_isArray) {
51
- if (_i >= _iterator.length) break;
52
- _ref = _iterator[_i++];
53
- } else {
54
- _i = _iterator.next();
55
- if (_i.done) break;
56
- _ref = _i.value;
57
- }
58
-
59
- var _fn = _ref;
60
- if (!_fn) continue;
61
- var node = this.node;
49
+ for (const fn of fns) {
50
+ if (!fn) continue;
51
+ const node = this.node;
62
52
  if (!node) return true;
53
+ const ret = fn.call(this.state, this, this.state);
63
54
 
64
- var ret = _fn.call(this.state, this, this.state);
55
+ if (ret && typeof ret === "object" && typeof ret.then === "function") {
56
+ throw new Error(`You appear to be using a plugin with an async traversal visitor, ` + `which your current version of Babel does not support.` + `If you're using a published plugin, you may need to upgrade ` + `your @babel/core version.`);
57
+ }
65
58
 
66
59
  if (ret) {
67
- throw new Error("Unexpected return value from visitor method " + _fn);
60
+ throw new Error(`Unexpected return value from visitor method ${fn}`);
68
61
  }
69
62
 
70
63
  if (this.node !== node) return true;
@@ -75,7 +68,7 @@ function _call(fns) {
75
68
  }
76
69
 
77
70
  function isBlacklisted() {
78
- var blacklist = this.opts.blacklist;
71
+ const blacklist = this.opts.blacklist;
79
72
  return blacklist && blacklist.indexOf(this.node.type) > -1;
80
73
  }
81
74
 
@@ -120,8 +113,8 @@ function stop() {
120
113
 
121
114
  function setScope() {
122
115
  if (this.opts && this.opts.noScope) return;
123
- var path = this.parentPath;
124
- var target;
116
+ let path = this.parentPath;
117
+ let target;
125
118
 
126
119
  while (path && !target) {
127
120
  if (path.opts && path.opts.noScope) return;
@@ -170,13 +163,13 @@ function _resyncKey() {
170
163
  if (this.node === this.container[this.key]) return;
171
164
 
172
165
  if (Array.isArray(this.container)) {
173
- for (var i = 0; i < this.container.length; i++) {
166
+ for (let i = 0; i < this.container.length; i++) {
174
167
  if (this.container[i] === this.node) {
175
168
  return this.setKey(i);
176
169
  }
177
170
  }
178
171
  } else {
179
- for (var key in this.container) {
172
+ for (const key in this.container) {
180
173
  if (this.container[key] === this.node) {
181
174
  return this.setKey(key);
182
175
  }
@@ -188,7 +181,7 @@ function _resyncKey() {
188
181
 
189
182
  function _resyncList() {
190
183
  if (!this.parent || !this.inList) return;
191
- var newContainer = this.parent[this.listKey];
184
+ const newContainer = this.parent[this.listKey];
192
185
  if (this.container === newContainer) return;
193
186
  this.container = newContainer || null;
194
187
  }
@@ -229,35 +222,18 @@ function setKey(key) {
229
222
  this.type = this.node && this.node.type;
230
223
  }
231
224
 
232
- function requeue(pathToQueue) {
233
- if (pathToQueue === void 0) {
234
- pathToQueue = this;
235
- }
236
-
225
+ function requeue(pathToQueue = this) {
237
226
  if (pathToQueue.removed) return;
238
- var contexts = this.contexts;
239
-
240
- for (var _iterator2 = contexts, _isArray2 = Array.isArray(_iterator2), _i2 = 0, _iterator2 = _isArray2 ? _iterator2 : _iterator2[Symbol.iterator]();;) {
241
- var _ref2;
242
-
243
- if (_isArray2) {
244
- if (_i2 >= _iterator2.length) break;
245
- _ref2 = _iterator2[_i2++];
246
- } else {
247
- _i2 = _iterator2.next();
248
- if (_i2.done) break;
249
- _ref2 = _i2.value;
250
- }
251
-
252
- var _context = _ref2;
227
+ const contexts = this.contexts;
253
228
 
254
- _context.maybeQueue(pathToQueue);
229
+ for (const context of contexts) {
230
+ context.maybeQueue(pathToQueue);
255
231
  }
256
232
  }
257
233
 
258
234
  function _getQueueContexts() {
259
- var path = this;
260
- var contexts = this.contexts;
235
+ let path = this;
236
+ let contexts = this.contexts;
261
237
 
262
238
  while (!contexts.length) {
263
239
  path = path.parentPath;