snippettypescriptreactCritical
tslint says calls to console.log are not allowed - How do I allow this?
Viewed 0 times
callshowareconsolelogtslintallowsaysnotthis
Problem
I just started using create-react-app with typescript
and the default tslint.json configuration does not allow console.log().
How can I (for now) enable console.log?
The docs for this are at https://palantir.github.io/tslint/rules/no-console/. But they don't say where to put this line:
I searched and found this tslint.json configuration file syntax, so I tried this:
In an attempt to get log messages that would just be warnings.
But that didn't work.
I've commented out the few console.log() lines I have but will want to be able to do this in the future.
create-react-app my-app --scripts-version=react-scripts-tsand the default tslint.json configuration does not allow console.log().
How can I (for now) enable console.log?
The docs for this are at https://palantir.github.io/tslint/rules/no-console/. But they don't say where to put this line:
"no-console": [true, "log", "error"]I searched and found this tslint.json configuration file syntax, so I tried this:
"rules": {
"no-console": [true, "warning"]
}In an attempt to get log messages that would just be warnings.
But that didn't work.
I've commented out the few console.log() lines I have but will want to be able to do this in the future.
Solution
Add
If you want to disable the rule entirely add the following to your
// 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
}
}Code Snippets
{
"rules": {
"no-console": false
}
}Context
Stack Overflow Q#49990513, score: 283
Revisions (0)
No revisions yet.