sindresorhus/eslint-plugin-unicorn

False positive: 'promise.withresolvers' in 'no-unnecessary-polyfills'

Closed

#2,404 opened on Jul 22, 2024

 (3 comments) (0 reactions) (0 assignees)JavaScript (468 forks)user submission
bughelp wanted

Repository metrics

Stars
 (5,022 stars)
PR merge metrics
 (Avg merge 1d 16h) (399 merged PRs in 30d)

Description

The no-unnecessary-polyfills rule complains about usage of promise.withresolvers package on Node.js 20 even though the native Promise.withResolvers is not available. According to MDN, it is only available since Node 22.0.0.

no-unnecessary-polyfills

Here's my rule config:

"unicorn/no-unnecessary-polyfills": [
    "error",
    { targets: "node 20.15.0" },
],

Here's the engines part on package.json:

    "engines": {
        "node": "^20.15.0",
        "pnpm": "^9.4.0"
    },

And there's a piece of code that triggers an error.

import withResolvers from "promise.withresolvers"; // Use built-in instead. eslint (unicorn/no-unnecessary-polyfills)

Contributor guide