如何在一个文件中禁用ESLint警告?

6

我刚开始使用代码检查工具,目前正在使用linter-eslint插件将JavaScript代码检查集成到我的首选IDE中Atom中。

现在,ESLint给我发出了一个警告,针对我当前项目目录中的.atom-build.js文件:

File ignored by default. Use a negated ignore pattern to override.

我希望能消除这个警告,因为虽然其他一切正常,但Atom左下角仍有这个红色的“X”让我感到困扰。

我尝试添加以下代码:

/* eslint-disable */

我将代码移到文件顶部,但是警告并没有消失。

/* eslint-disable */ > File ignored by default. Use a negated ignore pattern to override.
(来源: cubeupload.com)


请参考以下链接中的“duplicate”:https://dev59.com/sFoU5IYBdhLWcg3wAjcs - Charles Merriam
1个回答

2

我相信你只需要在你的.eslintignore文件中添加以下一行,就可以取消对该文件的默认忽略。

!.atom-build.js

由于该文件默认情况下被忽略,我认为在头部加上注释不会有任何变化。


.eslintignore文件需要放在项目的根目录下吗? - theonlygusti
@theonlygusti 是的。 - Alexander O'Mara
好的,我现在会尝试。 - theonlygusti
有没有一种方法可以使用.eslintrc.json文件来实现类似的事情?因为我已经有一个这样的文件了... - theonlygusti
@theonlygusti 我不这么认为,它在这里没有列出来:http://eslint.org/docs/user-guide/configuring - Alexander O'Mara
糟糕,这没起作用!我必须先保存未更改的文件,以便进行代码检查更新... - theonlygusti

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接