关闭特定文件的eslint规则 [英] Turning off eslint rule for a specific file

查看:698
本文介绍了关闭特定文件的eslint规则的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以关闭整个文件的eslint规则?例如:

Is it possible to turn off the eslint rule for the whole file? Something such as:

// eslint-disable-file no-use-before-define 

(类似于eslint-disable-line。)它经常发生在我身上,在某个文件中,我打破了一个特定的对于该文件被认为是正常的许多地方的规则,但我不想禁用整个项目的规则,也不想禁用该特定文件的其他规则。

(Analogous to eslint-disable-line.) It happens to me quite often, that in a certain file, I'm breaking a specific rule on many places which is considered OK for that file, but I don't want to disable the rule for the whole project nor do I want to disable other rules for that specific file.

推荐答案

您可以通过将配置置于文件顶部来关闭/更改文件的特定规则。

You can turn off/change a particular rule for a file by putting the configurations at the top of the file.

/* eslint no-use-before-define: 0 */  // --> OFF

or

/* eslint no-use-before-define: 2 */  // --> ON

更多信息: http://eslint.org/docs/user-guide/configuring.html#configuring-rules

这篇关于关闭特定文件的eslint规则的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆