[英]Eslint disable no console not working
I am trying to log to console something by disabling the no console rule in eslint like this:我试图通过禁用 eslint 中的 no console 规则来登录到控制台,如下所示:
// eslint-disable-next-line no-console
console.log(props.hasSubmittedForm);
But, I get an error:但是,我收到一个错误:
Module build failed模块构建失败
unexpected token意料之外的令牌
For the dot the console.log.对于点console.log。 Why can't I log to the console like that?为什么我不能像这样登录到控制台?
You can wrap your code with /* eslint-disable no-console */
in order to disable eslint just for that part:您可以使用/* eslint-disable no-console */
包装您的代码,以便仅为该部分禁用 eslint:
/* eslint-disable no-console */
console.log(props.hasSubmittedForm);
/* eslint-enable no-console */
Interestingly for me when I switch from eslint-disable-next-line
to eslint-disable
I have to also change the comment from //
to /* */
.有趣的是,当我从eslint-disable-next-line
切换到eslint-disable
我还必须将注释从//
更改为/* */
。
This didn't work:这不起作用:
// eslint-disable no-console
This worked:这有效:
/* eslint-disable no-console */
Perhaps you didn't stage the eslint-disable...
change?也许你没有上演eslint-disable...
改变? My code failed running the pre-commit
hook, after staging the eslint-disable...
change, it passed the hook.我的代码运行pre-commit
钩子失败,在暂存eslint-disable...
更改后,它通过了钩子。
Instead of wrapping (which is using two lines), or disable the whole file, you can simply use above the concerned line:您可以简单地在相关行上方使用,而不是换行(使用两行)或禁用整个文件:
// eslint-disable-next-line no-console
console.log("I am ignored");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.