@babel/traverse 7.0.0-rc.1 → 7.0.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.

package/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2014-2018 Sebastian McKenzie <sebmck@gmail.com>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/lib/hub.js CHANGED
@@ -6,8 +6,16 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.default = void 0;
7
7
 
8
8
  class Hub {
9
- constructor(file) {
10
- this.file = file;
9
+ getCode() {}
10
+
11
+ getScope() {}
12
+
13
+ addHelper() {
14
+ throw new Error("Helpers are not supported by the default hub.");
15
+ }
16
+
17
+ buildError(node, msg, Error = TypeError) {
18
+ return new Error(msg);
11
19
  }
12
20
 
13
21
  }
@@ -130,7 +130,7 @@ function arrowFunctionToExpression({
130
130
  });
131
131
  }
132
132
 
133
- this.get("body").unshiftContainer("body", t().expressionStatement(t().callExpression(this.hub.file.addHelper("newArrowCheck"), [t().thisExpression(), checkBinding ? t().identifier(checkBinding.name) : t().identifier(thisBinding)])));
133
+ this.get("body").unshiftContainer("body", t().expressionStatement(t().callExpression(this.hub.addHelper("newArrowCheck"), [t().thisExpression(), checkBinding ? t().identifier(checkBinding.name) : t().identifier(thisBinding)])));
134
134
  this.replaceWith(t().callExpression(t().memberExpression((0, _helperFunctionName().default)(this, true) || this.node, t().identifier("bind")), [checkBinding ? t().identifier(checkBinding.name) : t().thisExpression()]));
135
135
  }
136
136
  }
package/lib/path/index.js CHANGED
@@ -154,7 +154,7 @@ class NodePath {
154
154
  }
155
155
 
156
156
  buildCodeFrameError(msg, Error = SyntaxError) {
157
- return this.hub.file.buildCodeFrameError(this.node, msg, Error);
157
+ return this.hub.buildError(this.node, msg, Error);
158
158
  }
159
159
 
160
160
  traverse(visitor, state) {
@@ -161,10 +161,11 @@ function getSource() {
161
161
  const node = this.node;
162
162
 
163
163
  if (node.end) {
164
- return this.hub.file.code.slice(node.start, node.end);
165
- } else {
166
- return "";
164
+ const code = this.hub.getCode();
165
+ if (code) return code.slice(node.start, node.end);
167
166
  }
167
+
168
+ return "";
168
169
  }
169
170
 
170
171
  function willIMaybeExecuteBefore(target) {
@@ -344,7 +344,7 @@ class Scope {
344
344
  const duplicate = kind === "let" || local.kind === "let" || local.kind === "const" || local.kind === "module" || local.kind === "param" && (kind === "let" || kind === "const");
345
345
 
346
346
  if (duplicate) {
347
- throw this.hub.file.buildCodeFrameError(id, `Duplicate declaration "${name}"`, TypeError);
347
+ throw this.hub.buildError(id, `Duplicate declaration "${name}"`, TypeError);
348
348
  }
349
349
  }
350
350
 
@@ -387,8 +387,6 @@ class Scope {
387
387
  }
388
388
 
389
389
  toArray(node, i) {
390
- const file = this.hub.file;
391
-
392
390
  if (t().isIdentifier(node)) {
393
391
  const binding = this.getBinding(node.name);
394
392
 
@@ -419,7 +417,7 @@ class Scope {
419
417
  helperName = "toArray";
420
418
  }
421
419
 
422
- return t().callExpression(file.addHelper(helperName), args);
420
+ return t().callExpression(this.hub.addHelper(helperName), args);
423
421
  }
424
422
 
425
423
  hasLabel(name) {
@@ -110,7 +110,7 @@ class Renamer {
110
110
  const parentDeclar = path.find(path => path.isDeclaration() || path.isFunctionExpression() || path.isClassExpression());
111
111
 
112
112
  if (parentDeclar) {
113
- const bindingIds = parentDeclar.getBindingIdentifiers();
113
+ const bindingIds = parentDeclar.getOuterBindingIdentifiers();
114
114
 
115
115
  if (bindingIds[oldName] === binding.identifier) {
116
116
  this.maybeConvertFromExportDeclaration(parentDeclar);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@babel/traverse",
3
- "version": "7.0.0-rc.1",
3
+ "version": "7.0.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": "Sebastian McKenzie <sebmck@gmail.com>",
6
6
  "homepage": "https://babeljs.io/",
@@ -8,17 +8,17 @@
8
8
  "repository": "https://github.com/babel/babel/tree/master/packages/babel-traverse",
9
9
  "main": "lib/index.js",
10
10
  "dependencies": {
11
- "@babel/code-frame": "7.0.0-rc.1",
12
- "@babel/generator": "7.0.0-rc.1",
13
- "@babel/helper-function-name": "7.0.0-rc.1",
14
- "@babel/helper-split-export-declaration": "7.0.0-rc.1",
15
- "@babel/parser": "7.0.0-rc.1",
16
- "@babel/types": "7.0.0-rc.1",
11
+ "@babel/code-frame": "^7.0.0",
12
+ "@babel/generator": "^7.0.0",
13
+ "@babel/helper-function-name": "^7.0.0",
14
+ "@babel/helper-split-export-declaration": "^7.0.0",
15
+ "@babel/parser": "^7.0.0",
16
+ "@babel/types": "^7.0.0",
17
17
  "debug": "^3.1.0",
18
18
  "globals": "^11.1.0",
19
19
  "lodash": "^4.17.10"
20
20
  },
21
21
  "devDependencies": {
22
- "@babel/helper-plugin-test-runner": "7.0.0-rc.1"
22
+ "@babel/helper-plugin-test-runner": "^7.0.0"
23
23
  }
24
24
  }