Security News
ESLint is Now Language-Agnostic: Linting JSON, Markdown, and Beyond
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
@babel/plugin-transform-shorthand-properties
Advanced tools
Compile ES2015 shorthand properties to ES5
The @babel/plugin-transform-shorthand-properties package is a Babel plugin that transforms object literal shorthand syntax into regular object syntax. This is useful for ensuring compatibility with environments that do not support ES6 shorthand properties.
Transform shorthand properties
Converts shorthand object properties into regular object properties. For example, `{ foo }` becomes `{"foo": foo}`.
{"foo": foo}
Transform shorthand methods
Converts shorthand method definitions into regular function properties. For example, `{ foo() { return 'bar'; } }` becomes `{"foo": function() { return 'bar'; }}`.
{"foo": function() { return 'bar'; }}
This plugin transforms the ES6 spread syntax for arrays and objects, which is somewhat related to shorthand properties in that it's part of the object literal syntax enhancements introduced in ES6. However, it serves a different purpose by allowing an iterable to be expanded in places where zero or more arguments or elements are expected.
This plugin transforms destructuring assignments and rest properties, which are closely related to shorthand properties as they are part of the enhanced object literals in ES6. While @babel/plugin-transform-shorthand-properties focuses on the syntax within object literals, @babel/plugin-transform-destructuring focuses on the syntax used to extract data from arrays or objects.
This plugin adds support for the rest and spread properties for object literals to Babel. It is similar to @babel/plugin-transform-shorthand-properties in that it deals with object literals, but it focuses on the spread and rest properties rather than shorthand syntax.
Compile ES2015 shorthand properties to ES5
In
var o = { a, b, c };
Out
var o = { a: a, b: b, c: c };
In
var cat = {
getName() {
return name;
}
};
Out
var cat = {
getName: function () {
return name;
}
};
npm install --save-dev @babel/plugin-transform-shorthand-properties
.babelrc
(Recommended).babelrc
{
"plugins": ["@babel/plugin-transform-shorthand-properties"]
}
babel --plugins @babel/plugin-transform-shorthand-properties script.js
require("@babel/core").transform("code", {
plugins: ["@babel/plugin-transform-shorthand-properties"]
});
FAQs
Compile ES2015 shorthand properties to ES5
The npm package @babel/plugin-transform-shorthand-properties receives a total of 23,500,288 weekly downloads. As such, @babel/plugin-transform-shorthand-properties popularity was classified as popular.
We found that @babel/plugin-transform-shorthand-properties demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
Security News
Members Hub is conducting large-scale campaigns to artificially boost Discord server metrics, undermining community trust and platform integrity.
Security News
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.