Commit modules

This commit is contained in:
Federico Grandi
2019-12-14 23:17:51 +01:00
parent 8063b07a5a
commit a88246a48b
4243 changed files with 1074761 additions and 0 deletions

View File

@@ -0,0 +1,30 @@
"use strict";
const _require = require("./property-name"),
reduceStaticPropertyNameES5 = _require.reduceStaticPropertyNameES5;
module.exports = function ({
types: t
}) {
return {
name: "transform-property-literals",
visitor: {
// { 'foo': 'bar' } -> { foo: 'bar' }
ObjectProperty: {
exit(path) {
const key = path.get("key");
if (!key.isStringLiteral()) {
return;
}
const newNode = t.clone(path.node);
newNode.key = reduceStaticPropertyNameES5(t, key.node);
newNode.computed = false;
path.replaceWith(newNode);
}
}
}
};
};