In eslint(v7.19.0)/eclipse(2020-12[4.18.0])/chromium(90.0.4416.0)/firefox(85.0)/etc Is there a way to warn when a deprecated native function is used?
For example using the deprecated form of RTCPeerConnection.createOffer fails to produce a warning in the above mentioned tools.
@howlger said that's deprecated parameters and maybe that's technically true in JavaScript (unlike Java which cares about function signatures) so another example is window.forward which eslint/eclipse fail to pick up on but browsers say "is not a function" because it's been deprecated and removed.
Maybe that's also "unclear" so Date.getYear is a 3rd example which works in browsers, produces no warnings and is deprecated.
Granted JavaScript is fluid and a project may implement a function anywhere named almost anything but linters should highlight that sort of bad practice encouraging coders to use function names that have not been built-in deprecated at any point.
Here is a minimal reproducible test;
# eslint test.js
# eslint --env-info
Environment Info:
Node version: v10.19.0
npm version: v7.5.3
Local ESLint version: v7.19.0 (Currently used)
Global ESLint version: Not found
# cat test.js
/**
* @deprecated test
*/
function b() {
new Date().getYear();
}
function a() {
b();
window.forward();
}
question from:
https://stackoverflow.com/questions/66051568/javascript-deprecation-warnings 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…