forked from daren.hsu/line_push
update
This commit is contained in:
+24
-5
@@ -23,15 +23,34 @@ var _default = (0, _helperPluginUtils.declare)(api => {
|
||||
const func = _core.types.functionExpression(null, node.params, node.body, node.generator, node.async);
|
||||
|
||||
func.returnType = node.returnType;
|
||||
path.replaceWith(_core.types.objectProperty(node.key, func, node.computed));
|
||||
|
||||
const computedKey = _core.types.toComputedKey(node);
|
||||
|
||||
if (_core.types.isStringLiteral(computedKey, {
|
||||
value: "__proto__"
|
||||
})) {
|
||||
path.replaceWith(_core.types.objectProperty(computedKey, func, true));
|
||||
} else {
|
||||
path.replaceWith(_core.types.objectProperty(node.key, func, node.computed));
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
ObjectProperty({
|
||||
node
|
||||
}) {
|
||||
ObjectProperty(path) {
|
||||
const {
|
||||
node
|
||||
} = path;
|
||||
|
||||
if (node.shorthand) {
|
||||
node.shorthand = false;
|
||||
const computedKey = _core.types.toComputedKey(node);
|
||||
|
||||
if (_core.types.isStringLiteral(computedKey, {
|
||||
value: "__proto__"
|
||||
})) {
|
||||
path.replaceWith(_core.types.objectProperty(computedKey, node.value, true));
|
||||
} else {
|
||||
node.shorthand = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user