Closed
Description
Same as the no-unsupported-features
rule: https://github.com/mysticatea/eslint-plugin-node/blob/master/docs/rules/no-unsupported-features/es-syntax.md#configured-nodejs-version-range
If my package has "engines": { "node": ">=6" }
it should not show:
assert.deepEqual was deprecated since v10.0.0. Use assert.deepStrictEqual or assert.strict.deepEqual instead. node/no-deprecated-api
As there's no way for me to use the new API, since it's only available in Node.js 10 and I need to support Node.js 6 users. It should only become an error when my engine
is >=10
.
Activity
mysticatea commentedon Nov 5, 2018
Thank you for the report.
This is intentional.
If you don't care the future deprecated APIs, you can disable the rule because the deprecated APIs will not be deleted on the current version.
In
assert.deepEqual
case, you can useassert.deepStrictEqual
. The deprecated APIs are the fourassert.deepEqual
,assert.equal
,assert.notDeepEqual
, andassert.notEqual
.sindresorhus commentedon Nov 5, 2018
Then I think you should add another metadata field of when the replacement API was added, so you at least don't report the error if it's impossible to switch.
For example, with:
I now have to manually look up when each of these APIs were introduced. Would be nice if either:
engine
target, and if none, don't show the message.For example, in this case,
assert.strict.deepEqual
was introduced in Node.js 9, so it would not be shown in the message, since my target is>=6
.mysticatea commentedon Nov 5, 2018
That makes sense.
pward123 commentedon Dec 9, 2018
+1 for Only show the replacement methods that works for my engine target, and if none, don't show the message.
julien-f commentedon Mar 27, 2019
Hi, would be nice if this would get fixed.
I'm not familiar with ESLint nor eslint-plugin-node code's but it looks like it shouldn't be too hard, simply enhance this check to compare it to current target Node version:
eslint-plugin-node/lib/rules/no-deprecated-api.js
Line 541 in 0e63e86
@mysticatea do you have any pointers?
mysticatea commentedon Mar 29, 2019
Hi. Thank you to be interested in.
Yes. You are right. I think this feature needs two steps to implement:
replacedBy
property such as lib/rules/no-deprecated-api.js#L18-L19 to an array that has objects that has a display name and supported version.replacedBy
array by the configured versions.julien-f commentedon Apr 8, 2019
@mysticatea I'm sorry I don't have the time to do this for now, I'll take a look when I can if no one have have take care of this yet.
no-deprecated-api
adheres to targeted node version #164✨ `no-deprecated-api` adheres to targeted node version (fixes #141) (#…