Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
312 views
in Technique[技术] by (71.8m points)

eclipse - JavaScript deprecation warnings?

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...