source: imaps-frontend/node_modules/@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression/lib/index.js@ 79a0317

main
Last change on this file since 79a0317 was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 4 days ago

F4 Finalna Verzija

  • Property mode set to 100644
File size: 1.1 KB
RevLine 
[79a0317]1'use strict';
2
3Object.defineProperty(exports, '__esModule', { value: true });
4
5var helperPluginUtils = require('@babel/helper-plugin-utils');
6
7function shouldTransform(path) {
8 const {
9 node
10 } = path;
11 const functionId = node.id;
12 if (!functionId) return false;
13 const name = functionId.name;
14 const paramNameBinding = path.scope.getOwnBinding(name);
15 if (paramNameBinding === undefined) {
16 return false;
17 }
18 if (paramNameBinding.kind !== "param") {
19 return false;
20 }
21 if (paramNameBinding.identifier === paramNameBinding.path.node) {
22 return false;
23 }
24 return name;
25}
26
27var index = helperPluginUtils.declare(api => {
28 api.assertVersion("^7.16.0");
29 return {
30 name: "plugin-bugfix-safari-id-destructuring-collision-in-function-expression",
31 visitor: {
32 FunctionExpression(path) {
33 const name = shouldTransform(path);
34 if (name) {
35 const {
36 scope
37 } = path;
38 const newParamName = scope.generateUid(name);
39 scope.rename(name, newParamName);
40 }
41 }
42 }
43 };
44});
45
46exports.default = index;
47//# sourceMappingURL=index.js.map
Note: See TracBrowser for help on using the repository browser.