Skip to content

lvjiaxuan/vscode-eslint-disable

Repository files navigation

vscode-eslint-disable


Intelligently disable ESLint rules for VS Code.

Visual Studio Marketplace Version Visual Studio Marketplace Installs GitHub Repo stars

Usage

  1. Place the cursor on the problem line at any position.
  2. Press ctrl + alt + d to insert // eslint-disable-next-line "explicit rule(s)".

For multiple lines, it inserts block comments:

/* eslint-disable no-console */
console.log('hello')
console.log('world')
/* eslint-enable no-console */

Tip

For multiple lines, you don't need to select the full text of lines. Just ensure the selection ranges cover the problem lines.

More usages

  1. ctrl + alt + e: disable rule(s) of line(s) for entire file.
  2. ctrl + alt + a: disable all rule(s) for entire file.

Motivation

The official ESLint extension has few steps to disable rules as:

  1. Place cursor on the problem line - (It doesn't support for multiple lines.).
  2. Press ctrl + . to open the Quick Fix menu.
  3. Select which rule to disable - (It doesn't support for multiple rules).

With this ext, you can disable multiple rules for multiple lines with one step.

Preview

Single line.

single

Multiple lines, you can press ctrl + d to select another pair of rule(s) on the other side.

multiple