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
- At the same line:
eslint-disable-line
- At the next line:
eslint-disable-next-line
- 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 */