Skip to content

Latest commit

 

History

History
87 lines (64 loc) · 2.63 KB

ignore-code.md

File metadata and controls

87 lines (64 loc) · 2.63 KB

Ignoring code

You can ignore:

  • within files
  • files entirely

Within files

You can temporarily turn off rules using special comments in your CSS. For example, you can either turn all the rules off:

/* stylelint-disable */
a {}
/* stylelint-enable */

Or you can turn off individual rules:

/* stylelint-disable selector-max-id, declaration-no-important */
#id {
  color: pink !important;
}
/* stylelint-enable selector-max-id, declaration-no-important */

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:

#id { /* stylelint-disable-line */
  color: pink !important; /* stylelint-disable-line declaration-no-important */
}

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:

#id {
  /* stylelint-disable-next-line declaration-no-important */
  color: pink !important;
}

Stylelint supports complex, overlapping disabling & enabling patterns:

/* stylelint-disable */
/* stylelint-enable foo */
/* stylelint-disable foo */
/* stylelint-enable */
/* stylelint-disable foo, bar */
/* stylelint-disable baz */
/* stylelint-enable baz, bar */
/* stylelint-enable foo */

Caveat: Comments within selector and value lists are currently ignored.

You may also include a description at the end of the comment, after two hyphens:

/* stylelint-disable -- Reason for disabling Stylelint. */
/* stylelint-disable foo -- Reason for disabling the foo rule. */
/* stylelint-disable foo, bar -- Reason for disabling the foo and bar rules. */

Important: There must be a space on both sides of the hyphens.

Files entirely

You can use a .stylelintignore file to ignore specific files. For example:

vendor/**/*.css

The patterns in your .stylelintignore file must match .gitignore syntax. (Behind the scenes, node-ignore parses your patterns.) Your patterns in .stylelintignore are always analyzed relative to process.cwd().

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.

Alternatively, you can add an ignoreFiles property within your configuration object.