[英]Eslint (no-unused-vars) can't properly detect unused variable at Vue factory pattern
Code Example:代码示例:
Please see this minimum code below请参阅下面的最低代码
import Vue from "vue";
const makeComponent = () => {
let isMounted = false; // eslint yells
return Vue.extend({
name: "App",
mounted() {
isMounted = true;
},
destroyed() {
isMounted = false;
}
});
};
export default makeComponent();
As you can see, I have properly use the isMounted
value, but ESLint can't recognize it.如您所见,我正确使用了
isMounted
值,但 ESLint 无法识别它。
I have reload the editor, it didn't help.我已经重新加载编辑器,它没有帮助。
This happens at codesandbox and my local editor.这发生在 codeandbox 和我的本地编辑器中。
Currently you are only assigning values to the variable, but never actually using it.目前,您只是为变量赋值,但从未实际使用它。 The documentation for no-unused-vars covers this nicely.
no-unused-vars的文档很好地涵盖了这一点。
A variable is not considered to be used if it is only ever declared (var foo = 5) or assigned to (foo = 7).
如果变量仅被声明 (var foo = 5) 或分配给 (foo = 7),则不会认为该变量被使用。
Here is an example of the variable being used in your example:这是您的示例中使用的变量的示例:
I should probably include the correct way to go about going what you're trying to do:我可能应该包括正确的方法来去做你想做的事情:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.