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