1 | # Ignoring code
|
2 |
|
3 | You can ignore:
|
4 |
|
5 | - within files
|
6 | - files entirely
|
7 |
|
8 | ## Within files
|
9 |
|
10 | You can temporarily turn off rules using special comments in your CSS. For example, you can either turn all the rules off:
|
11 |
|
12 |
|
13 | ```css
|
14 | /* stylelint-disable */
|
15 | a {}
|
16 | /* stylelint-enable */
|
17 | ```
|
18 |
|
19 | Or you can turn off individual rules:
|
20 |
|
21 |
|
22 | ```css
|
23 | /* stylelint-disable selector-no-id, declaration-no-important */
|
24 | #id {
|
25 | color: pink !important;
|
26 | }
|
27 | /* stylelint-enable selector-no-id, declaration-no-important */
|
28 | ```
|
29 |
|
30 | You can turn off rules for individual lines with a `/* stylelint-disable-line */` comment, after which you do not need to explicitly re-enable them:
|
31 |
|
32 |
|
33 | ```css
|
34 | #id { /* stylelint-disable-line */
|
35 | color: pink !important; /* stylelint-disable-line declaration-no-important */
|
36 | }
|
37 | ```
|
38 |
|
39 | You can also turn off rules for _the next line only_ with a `/* stylelint-disable-next-line */` comment, after which you do not need to explicitly re-enable them:
|
40 |
|
41 |
|
42 | ```css
|
43 | #id {
|
44 | /* stylelint-disable-next-line declaration-no-important */
|
45 | color: pink !important;
|
46 | }
|
47 | ```
|
48 |
|
49 | stylelint supports complex, overlapping disabling & enabling patterns:
|
50 |
|
51 |
|
52 | ```css
|
53 | /* stylelint-disable */
|
54 | /* stylelint-enable foo */
|
55 | /* stylelint-disable foo */
|
56 | /* stylelint-enable */
|
57 | /* stylelint-disable foo, bar */
|
58 | /* stylelint-disable baz */
|
59 | /* stylelint-enable baz, bar */
|
60 | /* stylelint-enable foo */
|
61 | ```
|
62 |
|
63 | **Caveat:** Comments within _selector and value lists_ are currently ignored.
|
64 |
|
65 | ## Files entirely
|
66 |
|
67 | You can use a `.stylelintignore` file to ignore specific files. For example:
|
68 |
|
69 | ```
|
70 | **/*.js
|
71 | vendor/**/*.css
|
72 | ```
|
73 |
|
74 | The patterns in your `.stylelintignore` file must match [`.gitignore` syntax](https://git-scm.com/docs/gitignore). (Behind the scenes, [`node-ignore`](https://github.com/kaelzhang/node-ignore) parses your patterns.) _Your patterns in `.stylelintignore` are always analyzed relative to `process.cwd()`._
|
75 |
|
76 | stylelint looks for a `.stylelintignore` file in `process.cwd()`. You can also specify a path to your ignore patterns file (absolute or relative to `process.cwd()`) using the `--ignore-path` (in the CLI) and `ignorePath` (in JS) options.
|
77 |
|
78 | Alternatively, you can add an [`ignoreFiles` property](configure.md#ignorefiles) within your configuration object.
|