When to Disable Rules
You'll learn when disabling a linting rule is justified—and when it's a red flag pointing to deeper design issues.
The Core Idea
ESLint's eslint-disable comments are an escape hatch, not a default strategy. While linters enforce best practices, legitimate exceptions exist. The key is distinguishing between "this rule doesn't apply here" and "I'm ignoring a real problem."
Valid Reasons to Disable Rules
Sometimes a rule's advice genuinely doesn't fit:
- Third-party code patterns: A library requires a specific structure that triggers warnings (e.g., console statements in a debug wrapper)
- Edge cases the rule can't understand: Complex logic where the linter lacks context (certain intentional fall-throughs in switch statements)
- Generated code: Build outputs or auto-generated files you don't control
- Unavoidable browser quirks: Working around platform-specific issues that look like anti-patterns
Think of it like breaking traffic laws for an ambulance—the rule is good, but context overrides it.
When Disabling Signals a Problem
Frequent disabling often means:
- Fighting your configuration: If you disable the same rule everywhere, remove it from your config instead
- Poorly structured code: Needing to disable
max-linesorcomplexityrepeatedly suggests functions doing too much - Missing understanding: Disabling rules you don't understand kicks problems down the road
- Team disagreement: Patchwork disabling indicates your team needs to align on standards
If you're typing eslint-disable more than once a week, something deeper needs fixing—either your rules or your code.
The Discipline
Always add a comment explaining why. Treat disabling as technical debt: documented, justified, and rare.
Key Takeaway: Disable rules sparingly when context genuinely overrides the rule's intent, but treat frequent disabling as a symptom that your configuration or code structure needs attention.