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

查看:53
本文介绍了关闭特定文件的 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

更多信息

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

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