source: trip-planner-front/node_modules/@babel/plugin-transform-shorthand-properties/lib/index.js@ fa375fe

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: 1.5 KB
Line 
1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.default = void 0;
7
8var _helperPluginUtils = require("@babel/helper-plugin-utils");
9
10var _core = require("@babel/core");
11
12var _default = (0, _helperPluginUtils.declare)(api => {
13 api.assertVersion(7);
14 return {
15 name: "transform-shorthand-properties",
16 visitor: {
17 ObjectMethod(path) {
18 const {
19 node
20 } = path;
21
22 if (node.kind === "method") {
23 const func = _core.types.functionExpression(null, node.params, node.body, node.generator, node.async);
24
25 func.returnType = node.returnType;
26
27 const computedKey = _core.types.toComputedKey(node);
28
29 if (_core.types.isStringLiteral(computedKey, {
30 value: "__proto__"
31 })) {
32 path.replaceWith(_core.types.objectProperty(computedKey, func, true));
33 } else {
34 path.replaceWith(_core.types.objectProperty(node.key, func, node.computed));
35 }
36 }
37 },
38
39 ObjectProperty(path) {
40 const {
41 node
42 } = path;
43
44 if (node.shorthand) {
45 const computedKey = _core.types.toComputedKey(node);
46
47 if (_core.types.isStringLiteral(computedKey, {
48 value: "__proto__"
49 })) {
50 path.replaceWith(_core.types.objectProperty(computedKey, node.value, true));
51 } else {
52 node.shorthand = false;
53 }
54 }
55 }
56
57 }
58 };
59});
60
61exports.default = _default;
Note: See TracBrowser for help on using the repository browser.