Based on the number of rules you want to ignore (All, or Some), and the scope of disabling it (Line(s), File(s), Everywhere), we have 2 × 3 = 6 cases.
1) Disabling "All rules"
Case 1.1: You want to disable "All Rules" for "One or more Lines"
Two ways you can do this:
- Put
/* eslint-disable-line */
at the end of the line(s),
- or
/* eslint-disable-next-line */
right before the line.
Case 1.2: You want to disable "All Rules" for "One File"
- Put the comment of
/* eslint-disable */
at the top of the file.
Case 1.3: You want to disable "All rules" for "Some Files"
There are 3 ways you can do this:
- You can go with 1.2 and add
/* eslint-disable */
on top of the files, one by one.
- You can put the file name(s) in
.eslintignore
. This works well especially if you have a path that you want to be ignored. (e.g. apidoc/**
)
- Alternatively, if you don't want to have a separate
.eslintignore
file, you can add
"eslintIgnore": ["file1.js", "file2.js"]
in package.json
as
instructed here.
2) Disabling "Some Rules"
Case 2.1: You want to disable "Some Rules" for "One or more Lines"
Two ways you can do this:
You can put /* eslint-disable-line quotes */
(replace quotes
with your rules) at the end of the line(s),
or /* eslint-disable-next-line no-alert, quotes, semi */
before the line.
Case 2.2: You want to disable "Some Rules" for "One File"
- Put the
/* eslint-disable no-use-before-define */
comment at the top of the file.
More examples here.
Case 2.3: You want to disable "Some Rules" for "Some files"
- This is less straight-forward. You should put them in
"excludedFiles"
object of "overrides"
section of your .eslintrc
as instructed here.
/* eslint-disable */
answers except the first one that would be nice – Tofandel