I love a good bit of linting. But what I don’t love is having to remember 101 (exaggeration maybe) little bits of code to easily navigate my JS environments. Thankfully this is where this blog comes in use!
These snippets are the ones that although simple, always slip my mind. They are not tough, or complex. But they just don’t stay in there.
Disable ESLint in a File
Sometimes you need to ignore a whole file. You can do that with the following comment. Add this at the very top of the page and it will stop the file file being checked.
/* eslint-disable */
This method is also great if you need to disable a chunk of code. All you need to do it re-enabled it after the section.
/* eslint-disable */ console.log('console log is bad lol'); /* eslint-enable */
Disable a Specific Line
You can use the following ESLint command to disable one line.
Console.log(‘console log is bad lol); // eslint-disable-line
On top of that, you can focus the disable on a specific line for a specific rule. This means that if anything goes wrong, you are able to see the errors or warnings.
console.log('console log is bad lol'); // eslint-disable-line no-console
Disable the Next Line
You can use the following ESLint commant to disable the next line.
// eslint-disable-next-line console.log('console log is bad lol');
You can use the specific rule here as well.
// eslint-disable-next-line no-console console.log('console log is bad lol');
These three rules always slip my mind. Hopefully they help you out as well.