Javascript Meteor eslint配置,用于使用globale命名空间导出进行包开发

Javascript Meteor eslint配置,用于使用globale命名空间导出进行包开发,javascript,meteor,package,eslint,Javascript,Meteor,Package,Eslint,在开发Meteor软件包时,我可以选择使用 api.export('VariableName'); api.addFiles('main.js'); 包中的相应变量必须声明为“全局”以匹配此定义(在main.js中): 但是,这会导致eslint在使用此变量的每一行上抛出no undef: 1:1 error 'VariableName' is not defined no-undef .... 141:1 error 'VariableName' is not defined

在开发Meteor软件包时,我可以选择使用

api.export('VariableName');
api.addFiles('main.js');
包中的相应变量必须声明为“全局”以匹配此定义(在
main.js
中):

但是,这会导致eslint在使用此变量的每一行上抛出
no undef

1:1   error  'VariableName' is not defined  no-undef
....
141:1   error  'VariableName' is not defined  no-undef
no undef
切换到
off
不是选项,因为它是eslint发现未使用变量的最好工具之一

如何在不将规则切换为off和不在变量前的每行上放置异常的情况下抑制此错误


编辑: 通过添加全局规则
/*全局变量name*/
我将收到一个只读错误:

Read-only global 'VariableName' should not be modified  no-global-assign
我忘了提到,这个包导入了一个外部npm包,修改了它的一些功能以与Meteor的环境兼容,然后再次导出它

所以代码实际上是:

VariableName = require('packageName');

您可以指定某些变量为全局变量,这将专门针对这些变量禁用此错误,但不会针对任何其他变量

例如,将以下代码放在出现此错误的文件的顶部:

/* global VariableName:true */

@Jankapunkt像我一样编辑了我的答案-在评论中添加
:true
/* global VariableName:true */