no-unnecessary-polyfills
March 27, 2026 ยท View on GitHub
๐ Enforce the use of built-in methods instead of unnecessary polyfills.
๐ผ This rule is enabled in the following configs: โ
recommended, โ๏ธ unopinionated.
This rule helps to use existing methods instead of using extra polyfills.
Examples
package.json
// package.json
{
"engines": {
"node": ">=8"
}
}
// โ
import assign from 'object-assign';
// package.json
{
"engines": {
"node": "4"
}
}
// โ
import assign from 'object-assign'; // Passes as Object.assign is not supported
Options
Type: object
targets
Type: string | string[] | object
Specify the target versions, which could be a Browserslist query or a targets object. See the core-js-compat targets option for more info.
If the option is not specified, the target versions are defined using the browserslist field in package.json, or as a last resort, the engines field in package.json.
"unicorn/no-unnecessary-polyfills": [
"error",
{
"targets": "node >=12"
}
]
"unicorn/no-unnecessary-polyfills": [
"error",
{
"targets": [
"node 14.1.0",
"chrome 95"
]
}
]
"unicorn/no-unnecessary-polyfills": [
"error",
{
"targets": {
"node": "current",
"firefox": "15"
}
}
]