Rules: Errors, Warnings, and Off
What you'll learn: How to configure individual ESLint rules with different severity levels to match your project's code quality standards.
Understanding Rule Severity
Every ESLint rule can be set to one of three severity levels, giving you precise control over how your linter responds to different code patterns:
"error"(or2): Violations will fail the linting process and exit with an error code. This stops builds and blocks commits if you've set up pre-commit hooks."warn"(or1): Violations are reported but won't fail the process. You'll see yellow warnings in your editor, but your code will still run."off"(or0): The rule is completely disabled and won't check anything.
When to Use Each Level
Think of these severity levels like traffic signals:
Red (error) is for rules that catch bugs or enforce critical team standards. Use errors for things like no-undef (undefined variables) or no-unused-vars — issues that often indicate real problems.
Yellow (warn) is for style preferences or potential improvements that aren't dealbreakers. Perfect for rules you're introducing gradually or issues that need context to judge.
Green (off) is for rules that don't fit your project or conflict with your team's conventions.
Configuring Rule Severity
In your .eslintrc file:
{
"rules": {
"semi": "error",
"no-console": "warn",
"no-debugger": "error",
"quotes": "off"
}
}
You can also use numeric values:
{
"rules": {
"semi": 2,
"no-console": 1,
"quotes": 0
}
}
Key Takeaway: ESLint's three severity levels (error, warn, off) let you enforce critical rules, surface concerns without blocking development, and disable rules that don't serve your project's needs.