Last change
on this file since fa375fe was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
958 bytes
|
Line | |
---|
1 | "use strict";
|
---|
2 |
|
---|
3 | Object.defineProperty(exports, "__esModule", {
|
---|
4 | value: true
|
---|
5 | });
|
---|
6 | exports.default = void 0;
|
---|
7 |
|
---|
8 | var _helperPluginUtils = require("@babel/helper-plugin-utils");
|
---|
9 |
|
---|
10 | var _helperFunctionName = require("@babel/helper-function-name");
|
---|
11 |
|
---|
12 | var _default = (0, _helperPluginUtils.declare)(api => {
|
---|
13 | api.assertVersion(7);
|
---|
14 | return {
|
---|
15 | name: "transform-function-name",
|
---|
16 | visitor: {
|
---|
17 | FunctionExpression: {
|
---|
18 | exit(path) {
|
---|
19 | if (path.key !== "value" && !path.parentPath.isObjectProperty()) {
|
---|
20 | const replacement = (0, _helperFunctionName.default)(path);
|
---|
21 | if (replacement) path.replaceWith(replacement);
|
---|
22 | }
|
---|
23 | }
|
---|
24 |
|
---|
25 | },
|
---|
26 |
|
---|
27 | ObjectProperty(path) {
|
---|
28 | const value = path.get("value");
|
---|
29 |
|
---|
30 | if (value.isFunction()) {
|
---|
31 | const newNode = (0, _helperFunctionName.default)(value);
|
---|
32 | if (newNode) value.replaceWith(newNode);
|
---|
33 | }
|
---|
34 | }
|
---|
35 |
|
---|
36 | }
|
---|
37 | };
|
---|
38 | });
|
---|
39 |
|
---|
40 | exports.default = _default; |
---|
Note:
See
TracBrowser
for help on using the repository browser.