eslint-plugin-node icon indicating copy to clipboard operation
eslint-plugin-node copied to clipboard

node/no-deprecated-api doesn't respect Node.js version from package.json

Open watson opened this issue 5 years ago • 5 comments
trafficstars

In our package.json we have the following:

  "engines": {
    "node": "10.15.2"
  }

But node/no-deprecated-api still errors on deprecations that were added in Node.js 11.

watson avatar Dec 04 '19 11:12 watson

Thank you for your report.

However, this is intentional.

If you don't care about the future versions, you can disable node/no-deprecated-api rule safely. Because existing APIs are never removed without major version up.

If you care about the future versions, the rule should report deprecations in the future versions.

mysticatea avatar Dec 08 '19 10:12 mysticatea

I think this is problematic when the recommended replacement is not available in your target version, for example url.parse is deprecated as of Node11 in favour of new url.URL (introduced in Node10), but if your target engine is Node 8 you will get the warning with nothing you can do to fix it.

edg2s avatar Jun 12 '20 15:06 edg2s

You can use a third-party package (e.g., whatwg-url) or just disable the rule by eslint-disable comment with the reason.

mysticatea avatar Jun 19 '20 11:06 mysticatea

Sure, but given we know the Node version and we know when each API was introduced, why not make feature of this? I think that would be more useful that having to add commented inline disables or introduce polyfills.

edg2s avatar Jun 20 '20 09:06 edg2s

No. That's false negative.

If you don't mind the deprecated feature in the future versions, you can disable this rule safely, because Node.js doesn't remove those in the major version series. On the other hand, if you mind the deprecated feature in the future versions, you have to mind those regardless of legacy Node.js's standard library has an alternative or not.

mysticatea avatar Jun 21 '20 04:06 mysticatea