ESLint Snippets To Disable Linting
I love a good bit of linting. ESlint is a pluggable linter tool for JavaScript frameworks.
This short bit of content is about how to disable eslint, in the chance that you don’t need linting in a specific file, line or project. They help you selectively disable ESlint.
These eslint snippets always slip my mind. Hopefully they help!
ESLint Disable 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 */
ESLint Disable a Specific Line
Wanting to turn off eslint rule for 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
ESLint 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.