tslint says calls to console.log are not allowed - How do I allow this?
up vote
27
down vote
favorite
I just started using create-react-app with typescript
create-react-app my-app --scripts-version=react-scripts-ts
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:
"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.
reactjs typescript create-react-app tslint
add a comment |
up vote
27
down vote
favorite
I just started using create-react-app with typescript
create-react-app my-app --scripts-version=react-scripts-ts
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:
"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.
reactjs typescript create-react-app tslint
add a comment |
up vote
27
down vote
favorite
up vote
27
down vote
favorite
I just started using create-react-app with typescript
create-react-app my-app --scripts-version=react-scripts-ts
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:
"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.
reactjs typescript create-react-app tslint
I just started using create-react-app with typescript
create-react-app my-app --scripts-version=react-scripts-ts
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:
"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.
reactjs typescript create-react-app tslint
reactjs typescript create-react-app tslint
edited Sep 3 at 12:13
Lee Brindley
3,17111944
3,17111944
asked Apr 23 at 21:54
PatS
6612921
6612921
add a comment |
add a comment |
3 Answers
3
active
oldest
votes
up vote
62
down vote
accepted
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
}
}
4
I'm not sure what happened but now "no-console": false is not working for me. I've found a work around is to put// tslint:disable:no-console
at the top of the file.
– PatS
Apr 26 at 17:07
5
"no-console": false works for me, but I have to restart "npm start" for it to take effect.
– jlb
May 21 at 19:56
2
"no-console": false
doesn't work for me, even withnpm run start
.
– Eric Fulmer
May 22 at 18:16
13
@EricFulmer put that in the "jsRules" node. "jsRules": { "no-console": false },
– billb
May 25 at 16:26
@billb That works -- thank you!
– Eric Fulmer
May 25 at 23:06
|
show 1 more comment
up vote
11
down vote
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
}
}
add a comment |
up vote
2
down vote
According to the docs: https://eslint.org/docs/user-guide/getting-started#configuration
- "off" or 0 - turn the rule off
- "warn" or 1 - turn the rule on as a warning (doesn’t affect exit code)
- "error" or 2 - turn the rule on as an error (exit code will be 1)
By the way, your correct setup would be
{
"rules": {
"no-console": false
}
}
add a comment |
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
62
down vote
accepted
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
}
}
4
I'm not sure what happened but now "no-console": false is not working for me. I've found a work around is to put// tslint:disable:no-console
at the top of the file.
– PatS
Apr 26 at 17:07
5
"no-console": false works for me, but I have to restart "npm start" for it to take effect.
– jlb
May 21 at 19:56
2
"no-console": false
doesn't work for me, even withnpm run start
.
– Eric Fulmer
May 22 at 18:16
13
@EricFulmer put that in the "jsRules" node. "jsRules": { "no-console": false },
– billb
May 25 at 16:26
@billb That works -- thank you!
– Eric Fulmer
May 25 at 23:06
|
show 1 more comment
up vote
62
down vote
accepted
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
}
}
4
I'm not sure what happened but now "no-console": false is not working for me. I've found a work around is to put// tslint:disable:no-console
at the top of the file.
– PatS
Apr 26 at 17:07
5
"no-console": false works for me, but I have to restart "npm start" for it to take effect.
– jlb
May 21 at 19:56
2
"no-console": false
doesn't work for me, even withnpm run start
.
– Eric Fulmer
May 22 at 18:16
13
@EricFulmer put that in the "jsRules" node. "jsRules": { "no-console": false },
– billb
May 25 at 16:26
@billb That works -- thank you!
– Eric Fulmer
May 25 at 23:06
|
show 1 more comment
up vote
62
down vote
accepted
up vote
62
down vote
accepted
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
}
}
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
}
}
edited Apr 25 at 22:00
answered Apr 23 at 22:02
Christian Ivicevic
3,16652549
3,16652549
4
I'm not sure what happened but now "no-console": false is not working for me. I've found a work around is to put// tslint:disable:no-console
at the top of the file.
– PatS
Apr 26 at 17:07
5
"no-console": false works for me, but I have to restart "npm start" for it to take effect.
– jlb
May 21 at 19:56
2
"no-console": false
doesn't work for me, even withnpm run start
.
– Eric Fulmer
May 22 at 18:16
13
@EricFulmer put that in the "jsRules" node. "jsRules": { "no-console": false },
– billb
May 25 at 16:26
@billb That works -- thank you!
– Eric Fulmer
May 25 at 23:06
|
show 1 more comment
4
I'm not sure what happened but now "no-console": false is not working for me. I've found a work around is to put// tslint:disable:no-console
at the top of the file.
– PatS
Apr 26 at 17:07
5
"no-console": false works for me, but I have to restart "npm start" for it to take effect.
– jlb
May 21 at 19:56
2
"no-console": false
doesn't work for me, even withnpm run start
.
– Eric Fulmer
May 22 at 18:16
13
@EricFulmer put that in the "jsRules" node. "jsRules": { "no-console": false },
– billb
May 25 at 16:26
@billb That works -- thank you!
– Eric Fulmer
May 25 at 23:06
4
4
I'm not sure what happened but now "no-console": false is not working for me. I've found a work around is to put
// tslint:disable:no-console
at the top of the file.– PatS
Apr 26 at 17:07
I'm not sure what happened but now "no-console": false is not working for me. I've found a work around is to put
// tslint:disable:no-console
at the top of the file.– PatS
Apr 26 at 17:07
5
5
"no-console": false works for me, but I have to restart "npm start" for it to take effect.
– jlb
May 21 at 19:56
"no-console": false works for me, but I have to restart "npm start" for it to take effect.
– jlb
May 21 at 19:56
2
2
"no-console": false
doesn't work for me, even with npm run start
.– Eric Fulmer
May 22 at 18:16
"no-console": false
doesn't work for me, even with npm run start
.– Eric Fulmer
May 22 at 18:16
13
13
@EricFulmer put that in the "jsRules" node. "jsRules": { "no-console": false },
– billb
May 25 at 16:26
@EricFulmer put that in the "jsRules" node. "jsRules": { "no-console": false },
– billb
May 25 at 16:26
@billb That works -- thank you!
– Eric Fulmer
May 25 at 23:06
@billb That works -- thank you!
– Eric Fulmer
May 25 at 23:06
|
show 1 more comment
up vote
11
down vote
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
}
}
add a comment |
up vote
11
down vote
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
}
}
add a comment |
up vote
11
down vote
up vote
11
down vote
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
}
}
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
}
}
edited Nov 11 at 22:20
answered Sep 3 at 12:12
Lee Brindley
3,17111944
3,17111944
add a comment |
add a comment |
up vote
2
down vote
According to the docs: https://eslint.org/docs/user-guide/getting-started#configuration
- "off" or 0 - turn the rule off
- "warn" or 1 - turn the rule on as a warning (doesn’t affect exit code)
- "error" or 2 - turn the rule on as an error (exit code will be 1)
By the way, your correct setup would be
{
"rules": {
"no-console": false
}
}
add a comment |
up vote
2
down vote
According to the docs: https://eslint.org/docs/user-guide/getting-started#configuration
- "off" or 0 - turn the rule off
- "warn" or 1 - turn the rule on as a warning (doesn’t affect exit code)
- "error" or 2 - turn the rule on as an error (exit code will be 1)
By the way, your correct setup would be
{
"rules": {
"no-console": false
}
}
add a comment |
up vote
2
down vote
up vote
2
down vote
According to the docs: https://eslint.org/docs/user-guide/getting-started#configuration
- "off" or 0 - turn the rule off
- "warn" or 1 - turn the rule on as a warning (doesn’t affect exit code)
- "error" or 2 - turn the rule on as an error (exit code will be 1)
By the way, your correct setup would be
{
"rules": {
"no-console": false
}
}
According to the docs: https://eslint.org/docs/user-guide/getting-started#configuration
- "off" or 0 - turn the rule off
- "warn" or 1 - turn the rule on as a warning (doesn’t affect exit code)
- "error" or 2 - turn the rule on as an error (exit code will be 1)
By the way, your correct setup would be
{
"rules": {
"no-console": false
}
}
answered Jun 4 at 15:27
loretoparisi
7,54554770
7,54554770
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f49990513%2ftslint-says-calls-to-console-log-are-not-allowed-how-do-i-allow-this%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown