Log to console in a Lightning Web Component












3















I am attempting to write a Lightning Web Component, but continually run into errors in my Javascript that I can't debug.



I've been trying to log my error but when I put console.log() anywhere in the methods that are failing, I get the error:




Unexpected console statement.











share|improve this question




















  • 1





    Surprisingly console.log() work in playground

    – Pranay Jaiswal
    1 hour ago






  • 1





    That must be the ESLint error. You can still use console.log() or say alert() statements for any debugging purposes (I can confirm this as I have used this in couple of my LWCs).

    – Jayant Das
    1 hour ago











  • @JayantDas anything to supress linter error?

    – Pranay Jaiswal
    1 hour ago











  • @PranayJaiswal I have utilized it right within the editor by suppressing those. But there must be a config file to do it globally though.

    – Jayant Das
    1 hour ago






  • 1





    @PranayJaiswal Looks like there's one for such cases.

    – Jayant Das
    1 hour ago


















3















I am attempting to write a Lightning Web Component, but continually run into errors in my Javascript that I can't debug.



I've been trying to log my error but when I put console.log() anywhere in the methods that are failing, I get the error:




Unexpected console statement.











share|improve this question




















  • 1





    Surprisingly console.log() work in playground

    – Pranay Jaiswal
    1 hour ago






  • 1





    That must be the ESLint error. You can still use console.log() or say alert() statements for any debugging purposes (I can confirm this as I have used this in couple of my LWCs).

    – Jayant Das
    1 hour ago











  • @JayantDas anything to supress linter error?

    – Pranay Jaiswal
    1 hour ago











  • @PranayJaiswal I have utilized it right within the editor by suppressing those. But there must be a config file to do it globally though.

    – Jayant Das
    1 hour ago






  • 1





    @PranayJaiswal Looks like there's one for such cases.

    – Jayant Das
    1 hour ago
















3












3








3








I am attempting to write a Lightning Web Component, but continually run into errors in my Javascript that I can't debug.



I've been trying to log my error but when I put console.log() anywhere in the methods that are failing, I get the error:




Unexpected console statement.











share|improve this question
















I am attempting to write a Lightning Web Component, but continually run into errors in my Javascript that I can't debug.



I've been trying to log my error but when I put console.log() anywhere in the methods that are failing, I get the error:




Unexpected console statement.








error console lightning-web-components






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 59 mins ago









Jayant Das

15.2k2824




15.2k2824










asked 1 hour ago









BlondeSwanBlondeSwan

905




905








  • 1





    Surprisingly console.log() work in playground

    – Pranay Jaiswal
    1 hour ago






  • 1





    That must be the ESLint error. You can still use console.log() or say alert() statements for any debugging purposes (I can confirm this as I have used this in couple of my LWCs).

    – Jayant Das
    1 hour ago











  • @JayantDas anything to supress linter error?

    – Pranay Jaiswal
    1 hour ago











  • @PranayJaiswal I have utilized it right within the editor by suppressing those. But there must be a config file to do it globally though.

    – Jayant Das
    1 hour ago






  • 1





    @PranayJaiswal Looks like there's one for such cases.

    – Jayant Das
    1 hour ago
















  • 1





    Surprisingly console.log() work in playground

    – Pranay Jaiswal
    1 hour ago






  • 1





    That must be the ESLint error. You can still use console.log() or say alert() statements for any debugging purposes (I can confirm this as I have used this in couple of my LWCs).

    – Jayant Das
    1 hour ago











  • @JayantDas anything to supress linter error?

    – Pranay Jaiswal
    1 hour ago











  • @PranayJaiswal I have utilized it right within the editor by suppressing those. But there must be a config file to do it globally though.

    – Jayant Das
    1 hour ago






  • 1





    @PranayJaiswal Looks like there's one for such cases.

    – Jayant Das
    1 hour ago










1




1





Surprisingly console.log() work in playground

– Pranay Jaiswal
1 hour ago





Surprisingly console.log() work in playground

– Pranay Jaiswal
1 hour ago




1




1





That must be the ESLint error. You can still use console.log() or say alert() statements for any debugging purposes (I can confirm this as I have used this in couple of my LWCs).

– Jayant Das
1 hour ago





That must be the ESLint error. You can still use console.log() or say alert() statements for any debugging purposes (I can confirm this as I have used this in couple of my LWCs).

– Jayant Das
1 hour ago













@JayantDas anything to supress linter error?

– Pranay Jaiswal
1 hour ago





@JayantDas anything to supress linter error?

– Pranay Jaiswal
1 hour ago













@PranayJaiswal I have utilized it right within the editor by suppressing those. But there must be a config file to do it globally though.

– Jayant Das
1 hour ago





@PranayJaiswal I have utilized it right within the editor by suppressing those. But there must be a config file to do it globally though.

– Jayant Das
1 hour ago




1




1





@PranayJaiswal Looks like there's one for such cases.

– Jayant Das
1 hour ago







@PranayJaiswal Looks like there's one for such cases.

– Jayant Das
1 hour ago












1 Answer
1






active

oldest

votes


















5














You are most likely encountering ESLint errors in VS Code.



As an example below is how my code looks like with those warnings. However I am still able to save the component and utilize alert or console.log statements specifically for debugging purposes.



You can also choose to suppress those warnings by right clicking on those warnings



OR



By editing the .eslintrc.json available in your project by adding the below rules:



"rules": {
"no-console": "off",
"no-alert": "off"
}




Console showing errors



enter image description here





Option to disable the rules by right clicking on the alert



enter image description here






share|improve this answer


























  • +1. Thanks. I tried same in Illuminated Cloud for LWC, it showed SUCCEEDED_PARTIAL

    – Pranay Jaiswal
    1 hour ago






  • 2





    @PranayJaiswal I updated my answer to include how to add the rules in .eslintrc.json in VS Code.

    – Jayant Das
    55 mins ago











  • @JayantDas thanks. btw, thanks for all your help. I don't mean to be a bug asking all these questions, it's just hard finding documentation for non-aura components.

    – BlondeSwan
    49 mins ago











  • @BlondeSwan You have been helping me/us to learn/know all this! So equally thanks to you :)

    – Jayant Das
    48 mins ago






  • 2





    Thanks Jayant. Much appreciated

    – Pranay Jaiswal
    38 mins ago











Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "459"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsalesforce.stackexchange.com%2fquestions%2f251270%2flog-to-console-in-a-lightning-web-component%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









5














You are most likely encountering ESLint errors in VS Code.



As an example below is how my code looks like with those warnings. However I am still able to save the component and utilize alert or console.log statements specifically for debugging purposes.



You can also choose to suppress those warnings by right clicking on those warnings



OR



By editing the .eslintrc.json available in your project by adding the below rules:



"rules": {
"no-console": "off",
"no-alert": "off"
}




Console showing errors



enter image description here





Option to disable the rules by right clicking on the alert



enter image description here






share|improve this answer


























  • +1. Thanks. I tried same in Illuminated Cloud for LWC, it showed SUCCEEDED_PARTIAL

    – Pranay Jaiswal
    1 hour ago






  • 2





    @PranayJaiswal I updated my answer to include how to add the rules in .eslintrc.json in VS Code.

    – Jayant Das
    55 mins ago











  • @JayantDas thanks. btw, thanks for all your help. I don't mean to be a bug asking all these questions, it's just hard finding documentation for non-aura components.

    – BlondeSwan
    49 mins ago











  • @BlondeSwan You have been helping me/us to learn/know all this! So equally thanks to you :)

    – Jayant Das
    48 mins ago






  • 2





    Thanks Jayant. Much appreciated

    – Pranay Jaiswal
    38 mins ago
















5














You are most likely encountering ESLint errors in VS Code.



As an example below is how my code looks like with those warnings. However I am still able to save the component and utilize alert or console.log statements specifically for debugging purposes.



You can also choose to suppress those warnings by right clicking on those warnings



OR



By editing the .eslintrc.json available in your project by adding the below rules:



"rules": {
"no-console": "off",
"no-alert": "off"
}




Console showing errors



enter image description here





Option to disable the rules by right clicking on the alert



enter image description here






share|improve this answer


























  • +1. Thanks. I tried same in Illuminated Cloud for LWC, it showed SUCCEEDED_PARTIAL

    – Pranay Jaiswal
    1 hour ago






  • 2





    @PranayJaiswal I updated my answer to include how to add the rules in .eslintrc.json in VS Code.

    – Jayant Das
    55 mins ago











  • @JayantDas thanks. btw, thanks for all your help. I don't mean to be a bug asking all these questions, it's just hard finding documentation for non-aura components.

    – BlondeSwan
    49 mins ago











  • @BlondeSwan You have been helping me/us to learn/know all this! So equally thanks to you :)

    – Jayant Das
    48 mins ago






  • 2





    Thanks Jayant. Much appreciated

    – Pranay Jaiswal
    38 mins ago














5












5








5







You are most likely encountering ESLint errors in VS Code.



As an example below is how my code looks like with those warnings. However I am still able to save the component and utilize alert or console.log statements specifically for debugging purposes.



You can also choose to suppress those warnings by right clicking on those warnings



OR



By editing the .eslintrc.json available in your project by adding the below rules:



"rules": {
"no-console": "off",
"no-alert": "off"
}




Console showing errors



enter image description here





Option to disable the rules by right clicking on the alert



enter image description here






share|improve this answer















You are most likely encountering ESLint errors in VS Code.



As an example below is how my code looks like with those warnings. However I am still able to save the component and utilize alert or console.log statements specifically for debugging purposes.



You can also choose to suppress those warnings by right clicking on those warnings



OR



By editing the .eslintrc.json available in your project by adding the below rules:



"rules": {
"no-console": "off",
"no-alert": "off"
}




Console showing errors



enter image description here





Option to disable the rules by right clicking on the alert



enter image description here







share|improve this answer














share|improve this answer



share|improve this answer








edited 49 mins ago

























answered 1 hour ago









Jayant DasJayant Das

15.2k2824




15.2k2824













  • +1. Thanks. I tried same in Illuminated Cloud for LWC, it showed SUCCEEDED_PARTIAL

    – Pranay Jaiswal
    1 hour ago






  • 2





    @PranayJaiswal I updated my answer to include how to add the rules in .eslintrc.json in VS Code.

    – Jayant Das
    55 mins ago











  • @JayantDas thanks. btw, thanks for all your help. I don't mean to be a bug asking all these questions, it's just hard finding documentation for non-aura components.

    – BlondeSwan
    49 mins ago











  • @BlondeSwan You have been helping me/us to learn/know all this! So equally thanks to you :)

    – Jayant Das
    48 mins ago






  • 2





    Thanks Jayant. Much appreciated

    – Pranay Jaiswal
    38 mins ago



















  • +1. Thanks. I tried same in Illuminated Cloud for LWC, it showed SUCCEEDED_PARTIAL

    – Pranay Jaiswal
    1 hour ago






  • 2





    @PranayJaiswal I updated my answer to include how to add the rules in .eslintrc.json in VS Code.

    – Jayant Das
    55 mins ago











  • @JayantDas thanks. btw, thanks for all your help. I don't mean to be a bug asking all these questions, it's just hard finding documentation for non-aura components.

    – BlondeSwan
    49 mins ago











  • @BlondeSwan You have been helping me/us to learn/know all this! So equally thanks to you :)

    – Jayant Das
    48 mins ago






  • 2





    Thanks Jayant. Much appreciated

    – Pranay Jaiswal
    38 mins ago

















+1. Thanks. I tried same in Illuminated Cloud for LWC, it showed SUCCEEDED_PARTIAL

– Pranay Jaiswal
1 hour ago





+1. Thanks. I tried same in Illuminated Cloud for LWC, it showed SUCCEEDED_PARTIAL

– Pranay Jaiswal
1 hour ago




2




2





@PranayJaiswal I updated my answer to include how to add the rules in .eslintrc.json in VS Code.

– Jayant Das
55 mins ago





@PranayJaiswal I updated my answer to include how to add the rules in .eslintrc.json in VS Code.

– Jayant Das
55 mins ago













@JayantDas thanks. btw, thanks for all your help. I don't mean to be a bug asking all these questions, it's just hard finding documentation for non-aura components.

– BlondeSwan
49 mins ago





@JayantDas thanks. btw, thanks for all your help. I don't mean to be a bug asking all these questions, it's just hard finding documentation for non-aura components.

– BlondeSwan
49 mins ago













@BlondeSwan You have been helping me/us to learn/know all this! So equally thanks to you :)

– Jayant Das
48 mins ago





@BlondeSwan You have been helping me/us to learn/know all this! So equally thanks to you :)

– Jayant Das
48 mins ago




2




2





Thanks Jayant. Much appreciated

– Pranay Jaiswal
38 mins ago





Thanks Jayant. Much appreciated

– Pranay Jaiswal
38 mins ago


















draft saved

draft discarded




















































Thanks for contributing an answer to Salesforce Stack Exchange!


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




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsalesforce.stackexchange.com%2fquestions%2f251270%2flog-to-console-in-a-lightning-web-component%23new-answer', 'question_page');
}
);

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







Popular posts from this blog

Wolfgang Unzicker

Unua mondmilito

Schloss Hohenburg (Lenggries)