New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Docs: clarify usage of inline disable comments (fixes #6335) #6347
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -349,12 +349,11 @@ In these configuration files, the rule `plugin1/rule1` comes from the plugin nam | |
|
||
## Disabling Rules with Inline Comments | ||
|
||
To temporarily disable rule warnings in your file use the following format: | ||
To temporarily disable rule warnings in your file, use block comments in the following format: | ||
|
||
```js | ||
/* eslint-disable */ | ||
|
||
// Disables all rules between comments | ||
alert('foo'); | ||
|
||
/* eslint-enable */ | ||
|
@@ -365,32 +364,29 @@ You can also disable or enable warnings for specific rules: | |
```js | ||
/* eslint-disable no-alert, no-console */ | ||
|
||
// Disables no-alert and no-console warnings between comments | ||
alert('foo'); | ||
console.log('bar'); | ||
|
||
/* eslint-enable no-alert, no-console */ | ||
``` | ||
|
||
To disable rule warnings in an entire file, put `/* eslint-disable */` at the top of the file: | ||
To disable rule warnings in an entire file, put a `/* eslint-disable */` block comment at the top of the file: | ||
|
||
```js | ||
/* eslint-disable */ | ||
|
||
// Disables all rules for the rest of the file | ||
alert('foo'); | ||
``` | ||
|
||
You can also disable specific rules for an entire file: | ||
You can also disable or enable specific rules for an entire file: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Keeping the wording consistent |
||
|
||
```js | ||
/* eslint-disable no-alert */ | ||
|
||
// Disables no-alert for the rest of the file | ||
alert('foo'); | ||
``` | ||
|
||
To disable all rules on a specific line: | ||
To disable all rules on a specific line, use a line comment in one of the following formats: | ||
|
||
```js | ||
alert('foo'); // eslint-disable-line | ||
|
@@ -417,7 +413,7 @@ alert('foo'); // eslint-disable-line no-alert, quotes, semi | |
alert('foo'); | ||
``` | ||
|
||
**Note:** Comments that disable warnings for a portion of a file tell ESLint not to report rule violations for the disabled code. ESLint parses the entire file, so disabled code still needs to be syntactically valid JavaScript. | ||
**Note:** Comments that disable warnings for a portion of a file tell ESLint not to report rule violations for the disabled code. ESLint still parses the entire file, however, so disabled code still needs to be syntactically valid JavaScript. | ||
|
||
## Adding Shared Settings | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After looking at this again, having these explanation comments is REALLY confusing when we're telling users to look at how to format comments to disable rules inline. I think it's clearer with them gone.