Course contentsShow
← JavaScript
Lesson 2591 of 2,72352. Linting and FormattingFree lesson

Disabling Rules Inline with Comments

Use eslint-disable comments to temporarily suppress specific linting rules when necessary.

Disabling Rules Inline with Comments

What you'll learn: How to strategically silence ESLint warnings in specific spots where the standard rules don't make sense.

When Rules Get in the Way

Sometimes a linting rule fires an alert for code that you've intentionally written a certain way—maybe you have a legitimate reason to use console.log() in production, or a third-party snippet requires eval(). Rather than disabling the rule project-wide, ESLint lets you turn it off precisely where needed using special comments.

The Core Syntax

Single-line suppression:

// eslint-disable-next-line no-console
console.log("This specific log is allowed");

Same-line suppression:

const data = eval(userInput); // eslint-disable-line no-eval

Block suppression:

/* eslint-disable no-console */
console.log("Start processing");
console.log("Processing complete");
/* eslint-enable no-console */

Disable all rules (use sparingly!):

// eslint-disable-next-line
const result = someUncheckedOperation();

Think of It Like a Permission Slip

These comments are like telling the linter: "I know what I'm doing here—trust me on this one." They override the ruleset temporarily, then normal checking resumes. Use them judiciously; overuse defeats the purpose of linting.

When to Use This

  • Debugging code you plan to remove
  • Third-party code snippets you can't rewrite
  • Edge cases where the rule's intent doesn't apply
  • Generated code that shouldn't be manually edited

Key Takeaway: Inline eslint-disable comments let you silence specific rules at the exact location where they're inappropriate, preserving linting everywhere else—precision control for real-world edge cases.