eslinteslintrcbabel-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.

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?


Solution

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

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