如何禁用ESLint规则

What can you do to disable one ESLint rule that is perhaps set automatically by your tooling?

如何禁用可能由您的工具自动设置的一个ESLint规则?

Consider the case where your tooling set the no-debugger and no-console rules.

考虑一下您的工具设置no-debugger规则和no-console规则的情况。

There might be a valid reason for production code, but in development mode, having the ability to access the browser debugger and the Console API is essential.

生产代码可能有正当的理由,但是在开发模式下,具有访问浏览器调试器Console API的能力至关重要。

You can disable one or more specific ESLint rules for a whole file by adding on a few lines:

您可以通过添加以下几行来为整个文件禁用一个或多个特定的ESLint规则:

/* eslint-disable no-debugger, no-console */
console.log('test')

or you can just do so in a block, re-enabling it afterwards:

或者,您可以在一个代码块中这样做,然后再启用它:

/* eslint-disable no-debugger, no-console */
console.log('test')
/* eslint-enable no-alert, no-console */

Or you can disable the rule on a specific line:

或者,您可以在特定行上禁用该规则:

console.log('test') // eslint-disable-line no-console
debugger // eslint-disable-line no-debugger
alert('test') // eslint-disable-line no-alert

翻译自: https://flaviocopes.com/how-to-disable-eslint-rule/

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值