Just a few weeks until the 2021 JavaScript Full-Stack Bootcamp opens.
Signup to the waiting list!
What can you do to disable one ESLint rule that is perhaps set automatically by your tooling?
Consider the case where your tooling set the no-debugger
and no-console
rules.
There might be a valid reason for production code, but in development mode, having the ability to access the browser debugger and the Console API is essential.
You can disable one or more specific ESLint rules for a whole file by adding on a few lines:
/* eslint-disable no-debugger, no-console */
console.log('test')
or you can just do so in a block, re-enabling it afterwards:
/* eslint-disable no-debugger, no-console */
console.log('test')
/* eslint-enable no-alert, no-console */
Or you can disable the rule on a specific line:
console.log('test') // eslint-disable-line no-console
debugger // eslint-disable-line no-debugger
alert('test') // eslint-disable-line no-alert
Another way is to disable it globally for the project.
In package.json
you can find the eslintConfig
rule, which might have some content already, like this:
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
Here you can disable the rules you want to disable:
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
],
"rules": {
"no-unused-vars": "off"
}
},
The 2021 JavaScript Full-Stack Bootcamp will start at the end of March 2021. Don't miss this opportunity, signup to the waiting list!
More devtools tutorials:
- Introduction to Yeoman
- Bower, the browser package manager
- Introduction to Frontend Testing
- Using node-webkit to create a Desktop App
- VS Code: use language-specific settings
- Introduction to Webpack
- A short and simple guide to Babel
- An introduction to Yarn
- Overview of the Browser DevTools
- Format your code with Prettier
- Keep your code clean with ESLint
- A list of cool Chrome DevTools Tips and Tricks
- Testing JavaScript with Jest
- How to use Visual Studio Code
- Introduction to Electron
- Parcel, a simpler webpack
- An Emmet reference for HTML
- The V8 JavaScript Engine
- Configuring VS Code
- Configuring the macOS command line
- How to disable an ESLint rule
- How to open VS Code from the command line
- How to set up hot reload on Electron