Skip to content

Latest commit

 

History

History
91 lines (68 loc) · 1.69 KB

no-unnecessary-polyfills.md

File metadata and controls

91 lines (68 loc) · 1.69 KB

Enforce the use of built-in methods instead of unnecessary polyfills

💼 This rule is enabled in the ✅ recommended config.

This rule is part of the recommended config.

This rules helps to use existing methods instead of using extra polyfills.

Fail

package.json

{
	"engines": {
		"node": ">=8"
	}
}
const assign = require('object-assign');

Pass

package.json

{
	"engines": {
		"node": "4"
	}
}
const assign = require('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 Browserlist 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 browserlist 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"
		}
	}
]