Disable ESLint at Specific Lines

Created at

2025.2.17

If you write comments to specify target lines and rules, these line are ignored by ESLint (but the warning message is displayed.)

How to specify the lines

  1. At the same line: eslint-disable-line
  2. At the next line: eslint-disable-next-line
  3. Surrounded lines: eslint-disable

Example

For instance, the following error is occurred if you don't use the variable you have already defined.

23:11 Error: 'xxx' is assigned a value but never used. @typescript-eslint/no-unused-vars

As you write a comment on the source, ESLint ignores the error that the error message and the specified rule is same. In this case, the rule is @typescript-eslint/no-unused-vars.

sample.js
// 1
const xxx = 'xxx' // eslint-disable-line @typescript-eslint/no-unused-vars

// 2
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const xxx = 'xxx'

// 3
/* eslint-disable @typescript-eslint/no-unused-vars */
const xxx = 'xxx'
const yyy = 'yyy'
/* eslint-disable @typescript-eslint/no-unused-vars */

mktia's note

Research & Engineering / Blockchain / Web Dev

© 2017-2025 mktia. All rights reserved.