简体   繁体   English

如何允许 console.info()/warn()/error() 并禁用 eslint 配置文件中的所有其他内容?

[英]How to allow console.info()/warn()/error() and disable everything else in eslint config file?

I had .eslintrc file without "no-console" rules, and it by default errored on all console.*() calls.我有没有"no-console"规则的.eslintrc文件,默认情况下它在所有console.*()调用上都会出错。

I need to allow console.info() , console.warn() and console.error() , so I added no-console rule to my .eslintrc :我需要允许console.info()console.warn()console.error() ,所以我在.eslintrc中添加了no-console规则:

{
  "root": true,
  "no-console": [
    "error",
    {
      "allow": ["info", "warn", "error"]
    }
  ],
  "parser": "babel-eslint",
  "extends": ["eslint:recommended"],
  "env": {
    "browser": true,
    "node": true
  }
}

Now eslint doesn't complain on "info", "warn", "error", but it doesn't complain on "log" either.现在 eslint 不会抱怨“信息”、“警告”、“错误”,但它也不会抱怨“日志”。

What am I missing?我错过了什么?

Your config is invalid, so ESLint is not working properly.您的配置无效,因此 ESLint 无法正常工作。 Use no-console in rules :rules中使用no-console

{
    "rules": {
        "no-console": [ ... ]
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM