Skip to content
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
merged 1 commit into from Jun 10, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 5 additions & 9 deletions docs/user-guide/configuring.md
Expand Up @@ -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');
Copy link
Member Author

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.


/* eslint-enable */
Expand All @@ -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:
Copy link
Member Author

Choose a reason for hiding this comment

The 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
Expand All @@ -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

Expand Down