Turn valid member expression property literals into plain identifiers
In
obj["foo"] = "isValid";
obj.const = "isKeyword";
obj["var"] = "isKeyword";
Out
obj.foo = "isValid";
obj["const"] = "isKeyword";
obj["var"] = "isKeyword";
npm install babel-plugin-transform-member-expression-literals --save-dev
.babelrc
{
"plugins": ["transform-member-expression-literals"]
}
babel --plugins transform-member-expression-literals script.js
require("@babel/core").transform("code", {
plugins: ["transform-member-expression-literals"]
});