Skip to content

Commit 5534955

Browse files
committed
MDL-87988 [docs] Document disabling a rule for a whole file
1 parent 543456d commit 5534955

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

‎general/development/policies/codingstyle/typescript.md‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,20 @@ static Promise<T>(
138138
139139
Use a block (`eslint-disable` and `eslint-enable`) only when several lines in a row need the same exception, and give the reason on the opening comment.
140140
141+
### Disabling a rule for a whole file {/* #disabling-a-rule-for-a-whole-file */}
142+
143+
When a rule cannot apply anywhere in a file, such as generated code, disable it at the very top of the `.ts` or `.tsx` file, without an `eslint-enable`. Name each rule and give the reason, as for an inline disable. The rest of the rules still apply to the file.
144+
145+
<ValidExample>
146+
147+
```ts
148+
/* eslint-disable no-var -- Generated file. */
149+
```
150+
151+
</ValidExample>
152+
153+
XO rejects an `eslint-disable` that names no rule, because it would turn off every rule for the file. To skip a file entirely, list it in the plugin's `.eslintignore` instead, as described below.
154+
141155
## Excluding a file in a plugin {/* #excluding-a-file-in-a-plugin */}
142156
143157
A plugin can exclude whole files from linting with an `.eslintignore` file in its root. XO and ESLint both read it, so one list covers the TypeScript and the AMD sources. Use it for a file that cannot pass yet, such as generated code or a file you are still migrating, rather than turning linting off for the whole plugin.

0 commit comments

Comments
 (0)