简体   繁体   中英

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.

I need to allow console.info() , console.warn() and console.error() , so I added no-console rule to my .eslintrc :

{
  "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.

What am I missing?

Your config is invalid, so ESLint is not working properly. Use no-console in rules :

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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