Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
vorant authored Nov 28, 2017
1 parent 5d5ac10 commit 6e0173a
Showing 1 changed file with 62 additions and 2 deletions.
64 changes: 62 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,65 @@ HTML styles [instruction](https://github.com/vorant/eslint-codestyle/blob/master
### Use in Sublime
Read [instruction](http://jonathancreamer.com/setup-eslint-with-es6-in-sublime-text/)

## Ignore ESLint rules
Sometimes we need to skip some rules. [This article](https://eslint.org/docs/user-guide/configuring#disabling-rules-with-inline-comments) describes you how to do it
## Disabling Rules with Inline Comments
Sometimes we need to skip some rules.

To temporarily disable rule warnings in your file, use block comments in the following format:

```
/* eslint-disable */
alert('foo');
/* eslint-enable */
```

You can also disable or enable warnings for specific rules:
```
/* eslint-disable no-alert, no-console */
alert('foo');
console.log('bar');
/* eslint-enable no-alert, no-console */
```
To disable rule warnings in an entire file, put a /* eslint-disable */ block comment at the top of the file:
```
/* eslint-disable */
alert('foo');
```
You can also disable or enable specific rules for an entire file:
```
/* eslint-disable no-alert */
alert('foo');
```
To disable all rules on a specific line, use a line comment in one of the following formats:
```
alert('foo'); // eslint-disable-line
// eslint-disable-next-line
alert('foo');
```
To disable a specific rule on a specific line:
```
alert('foo'); // eslint-disable-line no-alert
// eslint-disable-next-line no-alert
alert('foo');
```
To disable multiple rules on a specific line:
```
alert('foo'); // eslint-disable-line no-alert, quotes, semi
// eslint-disable-next-line no-alert, quotes, semi
alert('foo');
```
All of the above methods also work for plugin rules. For example, to disable `eslint-plugin-example`’s `rule-name` rule, combine the plugin’s name (`example`) and the rule’s name (`rule-name`) into `example/rule-name`:
```
foo(); // eslint-disable-line example/rule-name
```
*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.


0 comments on commit 6e0173a

Please sign in to comment.