Posts

Showing posts from January, 2020

Enable console.log and alert statements in LWC

Hello, This post is about a very small and somewhat confusing error that you come across when you are doing LWC development.  Unexpected console statement. eslint(no-console) Unexpected console statement. eslint(no-alert) Why does this error occur? -       This is because ESLint(Linter tool which analyzes code and throws error, when it finds programmatical bugs, syntactical errors, etc.,) considers using console statements or alert statement as a bad practice -       It is considered as bad practice as console and alert statements are used for debugging purpose and they should not be shipped to the client. What is the solution? To overcome this there are 2 ways: 1.    You can disable ESLint’s rule for the whole JS file export default class accountComponent extends LightningElement { /* eslint-disable no-console */ /* eslint-disable no-alert */ handleClick(event){ console.log('Eve...