|
7 | 7 | </div> |
8 | 8 |
|
9 | 9 | - [Usage](#usage) |
| 10 | +- [Disable ESLint](#disable-eslint) |
10 | 11 | - [Multiple scripts tags in a HTML file](#multiple-scripts-tags-in-a-html-file) |
11 | 12 | - [History](#history) |
12 | 13 | - [XML support](#xml-support) |
@@ -42,6 +43,32 @@ Example: |
42 | 43 | } |
43 | 44 | ``` |
44 | 45 |
|
| 46 | +## Disable ESLint |
| 47 | + |
| 48 | +To temporarily disable ESLint, use the `<!-- eslint-disable -->` HTML comment. Re-enable it with |
| 49 | +`<!-- eslint enable -->`. Example: |
| 50 | + |
| 51 | +```html |
| 52 | +<!-- eslint-disable --> |
| 53 | +<script> |
| 54 | + var foo = 1 |
| 55 | +</script> |
| 56 | +<!-- eslint-enable --> |
| 57 | +``` |
| 58 | + |
| 59 | +To disable ESLint for the next script tag only, use the `<!-- eslint-disable-next-script -->` HTML |
| 60 | +comment. Example: |
| 61 | + |
| 62 | +```html |
| 63 | +<!-- eslint-disable-next-script --> |
| 64 | +<script> |
| 65 | + var foo = 1 |
| 66 | +</script> |
| 67 | +``` |
| 68 | + |
| 69 | +Disabled script tags are completely ignored: their content will not be parsed as JavaScript. You can |
| 70 | +use this to disable script tags containing template syntax. |
| 71 | + |
45 | 72 | ## Multiple scripts tags in a HTML file |
46 | 73 |
|
47 | 74 | When linting a HTML with multiple script tags, this plugin tries to emulate the browser behavior by |
@@ -209,14 +236,17 @@ documentation](http://eslint.org/docs/user-guide/command-line-interface#ext). |
209 | 236 |
|
210 | 237 | `eslint-plugin-html` won't evaluate or remove your template markup. If you have template markup in |
211 | 238 | your script tags, the resulting script may not be valid JavaScript, so `ESLint` will fail to parse |
212 | | -it. |
| 239 | +it. Here are some workarounds: |
| 240 | + |
| 241 | +- You can use [HTML comments to disable ESLint](#disable-eslint) for specific script tags. |
213 | 242 |
|
214 | | -For PHP, you can use [`eslint-plugin-php-markup`](https://github.com/tengattack/eslint-plugin-php-markup) to |
215 | | -lint php files, it use a same way to process php markup like `eslint-plugin-html`. |
| 243 | +- For PHP, you can use |
| 244 | + [`eslint-plugin-php-markup`](https://github.com/tengattack/eslint-plugin-php-markup) to lint php |
| 245 | + files, it use a same way to process php markup like `eslint-plugin-html`. |
216 | 246 |
|
217 | | -Or another possible hacky workaround to make sure the code is valid JavaScript is to put your template |
218 | | -markup inside a comment. When the template is rendered, the generated JS code must start with a new |
219 | | -line, so it will be written below the comment. PHP example: |
| 247 | +- Another possible hacky workaround to make sure the code is valid JavaScript is to put your |
| 248 | + template markup inside a comment. When the template is rendered, the generated JS code must start |
| 249 | + with a new line, so it will be written below the comment. PHP example: |
220 | 250 |
|
221 | 251 | ```html |
222 | 252 | <script> |
|
0 commit comments