Disallow unsupported ECMAScript built-ins on the specified version (n/no-unsupported-features/es-builtins
)
💼 This rule is enabled in the following configs: ☑️ flat/recommended
, 🟢 flat/recommended-module
, ✅ flat/recommended-script
, ☑️ recommended
, 🟢 recommended-module
, ✅ recommended-script
.
ECMAScript standard is updating every two months. You can check node.green to know which Node.js version supports each ECMAScript feature.
This rule reports unsupported ECMAScript built-in variables on the configured Node.js version as lint errors. Editor integrations of ESLint would be useful to know it in real-time.
This rule supports ECMAScript 2019 and proposals that have been approved as Stage 4 by August 2019. See also TC39 finished proposals.
Configured Node.js version range
{
"n/no-unsupported-features/es-builtins": ["error", {
"version": ">=16.0.0",
"ignores": []
}]
}
As mentioned above, this rule reads the engines
field of package.json
.
But, you can overwrite the version by version
option.
The version
option accepts the valid version range of node-semver
.
If you are using transpilers, maybe you want to ignore the warnings about some features.
You can use this ignores
option to ignore the given features.
The "ignores"
option accepts an array of the following strings.
ES2021:
"AggregateError"
"Promise.any"
"WeakRef"
"FinalizationRegistry"
ES2020:
"BigInt"
"BigInt64Array"
"BigUint64Array"
"Promise.allSettled"
"globalThis"
ES2019:
"Object.fromEntries"
ES2017:
"Atomics"
"Object.values"
"Object.entries"
"Object.getOwnPropertyDescriptors"
"SharedArrayBuffer"
ES2015:
"Array.from"
"Array.of"
"Map"
"Math.acosh"
"Math.asinh"
"Math.atanh"
"Math.cbrt"
"Math.clz32"
"Math.cosh"
"Math.expm1"
"Math.fround"
"Math.hypot"
"Math.imul"
"Math.log10"
"Math.log1p"
"Math.log2"
"Math.sign"
"Math.sinh"
"Math.tanh"
"Math.trunc"
"Number.EPSILON"
"Number.isFinite"
"Number.isInteger"
"Number.isNaN"
"Number.isSafeInteger"
"Number.MAX_SAFE_INTEGER"
"Number.MIN_SAFE_INTEGER"
"Number.parseFloat"
"Number.parseInt"
"Object.assign"
"Object.getOwnPropertySymbols"
"Object.is"
"Object.setPrototypeOf"
"Promise"
"Proxy"
"Reflect"
"Set"
"String.fromCodePoint"
"String.raw"
"Symbol"
"Int8Array"
"Uint8Array"
"Uint8ClampedArray"
"Int16Array"
"Uint16Array"
"Int32Array"
"Uint32Array"
"Float32Array"
"Float64Array"
"DataView"
"WeakMap"
"WeakSet"
The following options can be set by shared settings. Several rules have the same option, but we can set this option at once.
version
For Example:
{
"settings": {
"node": {
"version": ">=16.0.0",
}
},
"rules": {
"n/no-unsupported-features/es-builtins": ["error", {
"ignores": []
}]
}
}
This rule cannot find non-static things. For example:
- New properties and methods of instances.
- New parameters of functions.
- New
options
properties of function parameters. - New events.