Security News
Input Validation Vulnerabilities Dominate MITRE's 2024 CWE Top 25 List
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
babel-preset-zillow
Advanced tools
A Babel preset for transpiling JavaScript following our code conventions
A Babel preset for transpiling JavaScript following our code conventions
Currently contains transforms for all stage 4 (ES2018) and stage 3 syntax that is permitted in the Zillow Style Guide. Please note that if usage of a stage 3 proposal is not explicitly mentioned in the Zillow Style Guide, then it will not be enabled here. Additionally, stage 4 syntax that is excluded is as follows:
regenerator-runtime
is too heavyweight for our use.SIMD
: this is a performance feature, so is pretty pointless to polyfill/transpile.Additionally, we also transpile the following:
npm install --save-dev babel-preset-zillow
.babelrc
(Recommended).babelrc
{
"presets": ["babel-preset-zillow"]
}
babel script.js --presets zillow
require("babel-core").transform("code", {
presets: ["babel-preset-zillow"]
});
This module uses @babel/preset-env
to target specific environments.
Please refer to babel-preset-env#targets for a list of available options.
For a list of browsers please see browserlist.
You may override our default list of targets by providing your own targets
key.
{
"presets": [["babel-preset-zillow", {
"targets": {
"chrome": 50,
"explorer": 11,
"firefox": 45
}
}]]
}
The following transpiles only for Node v8.
{
"presets": [["babel-preset-zillow", {
"targets": {
"node": 8
}
}]]
}
If you wish, you can also inherit our default list of browsers and extend them using additionalTargets
.
{
"presets": [["babel-preset-zillow", {
"additionalTargets": {
"chrome": 42,
"explorer": 8
}
}]]
}
This preset also supports passing additional options directly to @babel/preset-env
:
These options are best suited for applications, not libraries, as they require additional dependencies (like core-js) that are not recommended for libraries.
For example, the following config would provide all global polyfills necessary for IE11 in an application, based on usage:
{
"presets": [["babel-preset-zillow", {
"useBuiltIns": "usage",
"corejs": 3
}]]
}
For more examples, please consult the core-js docs.
In some rare cases, it is necessary to explicitly exclude certain transforms that would otherwise be included by @babel/preset-env
.
To accomplish this goal, this preset's default exclusions can be extended with the additionalExcludes
array.
{
"presets": [["babel-preset-zillow", {
"additionalExcludes": [
"@babel/plugin-transform-classes"
]
}]]
}
You should always pass the fully-qualified transform name, not the shorthand.
When targets.node
is configured no exclusions are allowed, as they are generally not necessary anyway.
For advanced use cases, configuration for many of the presets and plugins employed by this module can be passed as sub-keys of the top-level options object. These configuration objects are spread into the internal configuration objects, overriding any keys already set. The currently supported preset option keys are:
{
"presets": [["babel-preset-zillow", {
"preset-env": {
"loose": true
},
"preset-react": {
"runtime": "automatic"
},
"styled-components": {
"pure": true
},
"object-rest-spread": {
"useBuiltIns": false
}
}]]
}
Note: Any options passed under the preset-env
key will override top-level options such as modules
, additionalExcludes
or additionalTargets
(as both of the "additional" keys are extending the non-prefixed option name). For the time being, you should use one or the other configuration patterns, not both.
You may override our default debug option by providing your own debug
key.
{
"presets": [["babel-preset-zillow", {
"debug": true
}]]
}
By default, this preset will remove data-testid
attributes from JSX elements in non-test builds and remove propTypes
definitions (via wrapping) from React components in production builds. To explicitly customize this behavior, either pass false
(to disable) or a config object.
Disable both optimizations:
{
"presets": [["babel-preset-zillow", {
"removeDataTestId": false,
"removePropTypes": false
}]]
}
Replace the attributes targeted by remove-data-test-id:
{
"presets": [["babel-preset-zillow", {
"removeDataTestId": {
"attributes": ["data-selenium-id"]
}
}]]
}
Change the mode
option of remove-prop-types:
{
"presets": [["babel-preset-zillow", {
"removePropTypes": {
"mode": "remove",
"removeImport": true
}
}]]
}
By default, this preset will compile as many modules as possible in loose mode. Normal mode is safer, but adds to bundle size and runtime overhead. We have options to selectively opt out of loose mode for applicable features. These options are:
looseClasses
looseComputedProperties
looseParameters
looseTemplateLiterals
For example, disable all loose compilation options:
{
"presets": [["babel-preset-zillow", {
"looseClasses": false,
"looseComputedProperties": false,
"looseParameters": false,
"looseTemplateLiterals": false
}]]
}
FAQs
A Babel preset for transpiling JavaScript following our code conventions
We found that babel-preset-zillow demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.