eslint-plugin-node
eslint-plugin-node copied to clipboard
node/no-deprecated-api doesn't respect Node.js version from package.json
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.
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.
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.
You can use a third-party package (e.g., whatwg-url) or just disable the rule by eslint-disable comment with the reason.
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.
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.