|
Last change
on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 13 days ago |
|
Fix frontend appearance
|
-
Property mode
set to
100644
|
|
File size:
1.1 KB
|
| Line | |
|---|
| 1 | 'use strict';
|
|---|
| 2 |
|
|---|
| 3 | Object.defineProperty(exports, '__esModule', { value: true });
|
|---|
| 4 |
|
|---|
| 5 | var helperPluginUtils = require('@babel/helper-plugin-utils');
|
|---|
| 6 |
|
|---|
| 7 | function 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 |
|
|---|
| 27 | var 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 |
|
|---|
| 46 | exports.default = index;
|
|---|
| 47 | //# sourceMappingURL=index.js.map
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.