[英]ESLint no-undef rule: many of functions in another file
The question is about.. how to tell eslint not to show error if the function is in another file? 问题是关于..如果函数在另一个文件中,如何告诉eslint不显示错误? Example:
例:
--- core.js --- some core code without utils definitions --- core.js ---一些没有utils定义的核心代码
function draw() {
const color = getRandomColor();
canvasClear();
drawNode();
drawLevel();
drawLine();
drawCaption();
}
--- draw-utils.js --- function declarations --- draw-utils.js ---函数声明
function getRandomColor() {...};
function canvasClear() {...};
function drawNode() {...};
function drawLevel() {...};
function drawLine() {...};
function drawCaption() {...};
Of course there are many of eslint 'no-undef' errors, because there is no all of this functions's declarations. 当然,有很多eslint'no-undef'错误,因为没有所有这些函数的声明。 The second file is also full of 'no-unused-vars'.
第二个文件也充满了“ no-unused-vars”。
Is there a way to tell them about themselves? 有没有办法告诉他们关于自己的事情? Without 'globals' section in .eslint.json
.eslint.json中没有 “ globals”部分
See the documentation for no-undef . 请参阅文档no-undef 。 Add a
globals
section to the JS file itself. 将
globals
部分添加到JS文件本身。
/*global someFunction b:true*/ /*eslint no-undef: "error"*/ var a = someFunction(); b = 10;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.