tslint says calls to console.log are not allowed - How do I allow this?

Solution 1:

Add // tslint:disable-next-line:no-console in the line right before your calls to console.log to prevent the error message only once.

If you want to disable the rule entirely add the following to your tslint.json (most likely in your root folder):

{
    "rules": {
        "no-console": false
    }
}

Solution 2:

For those of you coming here with a mixed codebase of javascript and typescript.

You may need to define the 'no-console' option in jsRules, jslints rules object for javascript files, i.e. there are separate rules objects for javascript and typescript.

//tslint.json

{
  "extends": ["tslint:recommended", "tslint-react", "tslint-config-prettier"], //Example... 
  "rules": {
    "no-console": false //Disable for typescript
  },
  "jsRules": {
    "no-console": false //Disable for javascript
  }
}

Solution 3:

Add the following to your tslint.json

{
   "rules": {
      "no-console": {
         "severity": "warning",
      } 
   }
}

Solution 4:

This is the correct syntax to define the no-console rule (or any other rule for that matter) but only with a warning rather than an error (obviously change the options to whatever you want)

"no-console": {
    "severity": "warning",
    "options": [
        "log",
        "error",
        "debug",
        "info",
        "time",
        "timeEnd",
        "trace"
    ]
},