Reputation:
Original Question:
I have some JavaScript functions that are only referenced from outside of my project. Is there any way to tell WebStorm not to warn on those but still warn on others? Perhaps with JSDoc or similar syntax?
Example:
function externallyCalled() {
//this should not show a warning if not used
}
function internalFunction() {
//this should show a warning if it's not used
}
Is this possible?
edit:
Based on Vipin's answer, // noinspection JSUnusedGlobalSymbols
works outside of a closure but not inside:
I have opened https://youtrack.jetbrains.com/issue/WI-39066 and accepted @Vipin's answer.
Upvotes: 0
Views: 2143
Reputation: 6546
You can add // noinspection JSUnusedGlobalSymbols
where you want to suppress the warning like below
// noinspection JSUnusedGlobalSymbols
function externallyCalled() {
//this should not show a warning if not used
}
// noinspection JSUnusedGlobalSymbols
function internalFunction() {
//this should show a warning if it's not used
}
Edited:
For closure, one way is to add // noinspection JSUnusedGlobalSymbols
on top of return
like below
var app = (function () {
// noinspection JSUnusedGlobalSymbols
return {
externallyCalled: function () {
//this should not show a warning if not used
},
internalFunction: function () {
//this should show a warning if it's not used
}
}
})();
This will disable the warnings on all the public properties/methods of returned object.
Upvotes: 3