仅针对特定 functions/variables 禁用 "unused property" 的警告?
Disable warning for "unused property" only for specific functions/variables?
原题:
我有一些 JavaScript 函数只能从我的项目外部引用。有什么办法可以告诉 WebStorm 不要警告那些但仍然警告其他人?也许使用 JSDoc 或类似的语法?
示例:
function externallyCalled() {
//this should not show a warning if not used
}
function internalFunction() {
//this should show a warning if it's not used
}
这可能吗?
编辑:
根据 Vipin 的回答,// noinspection JSUnusedGlobalSymbols
在闭包外工作但在闭包内不工作:
我已经打开https://youtrack.jetbrains.com/issue/WI-39066并接受了@Vipin的回答
您可以添加 // noinspection JSUnusedGlobalSymbols
在您想要取消警告的地方,如下所示
// 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
}
快速修复菜单
已编辑:
对于关闭,一种方法是在 return
之上添加 // noinspection JSUnusedGlobalSymbols
,如下所示
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
}
}
})();
这将禁用返回对象的所有 public properties/methods 上的警告。
原题:
我有一些 JavaScript 函数只能从我的项目外部引用。有什么办法可以告诉 WebStorm 不要警告那些但仍然警告其他人?也许使用 JSDoc 或类似的语法?
示例:
function externallyCalled() {
//this should not show a warning if not used
}
function internalFunction() {
//this should show a warning if it's not used
}
这可能吗?
编辑:
根据 Vipin 的回答,// noinspection JSUnusedGlobalSymbols
在闭包外工作但在闭包内不工作:
我已经打开https://youtrack.jetbrains.com/issue/WI-39066并接受了@Vipin的回答
您可以添加 // noinspection JSUnusedGlobalSymbols
在您想要取消警告的地方,如下所示
// 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
}
快速修复菜单
已编辑:
对于关闭,一种方法是在 return
之上添加 // noinspection JSUnusedGlobalSymbols
,如下所示
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
}
}
})();
这将禁用返回对象的所有 public properties/methods 上的警告。