跳到主要内容

Errors & warnings

In addition to rule problems, Stylelint surfaces the following errors and warnings:

CSS syntax error

The CSS parser built into Stylelint, or the chosen custom syntax, could not parse your code.

Unclosed block

You should balance your curly braces, typically of declaration blocks.

For example:

- a { color: red;
+ a { color: red; }

Unclosed bracket

You should balance your square brackets, typically of attribute selectors and grid names.

For example:

- a[foo { grid: [bar; }
+ a[foo] { grid: [bar]; }

Unclosed string

You should balance your quotation marks.

For example:

- a { content: " }
+ a { content: "" }

Unknown word

You should:

  • hyphenate properties
  • separate property and value pairs with colons
  • separate declarations with semicolons
  • pair selectors with declaration blocks in rules

For example:

a {
- margin top: 1px
- color red
+ margin-top: 1px;
+ color: red
}

Parse error

The CSS parser built into Stylelint (or the chosen custom syntax) successfully parsed your code, but one of the construct-specific parsers failed to parse either a media query, selector or value within that source.

The construct-specific parsers are:

  • @csstools/media-query-list-parser
  • postcss-selector-parser
  • postcss-value-parser

You should check that your constructs are wellformed, e.g. parentheses are balanced.

Unknown rule error

There is an unknown rule in the configuration object.

You should:

  • install the latest version of Stylelint (npm i --save-dev stylelint), as we may have recently added the rule
  • check that the rule exists and is correctly named by searching the list of rules

Deprecation warning

There is a deprecated rule in the configuration object.

You should:

  • identify in the CHANGELOG which release deprecated the rule
  • take the action suggested there

Invalid option warning

There is a misconfigured rule in the configuration object.

You should:

  • install the latest version of Stylelint (npm i --save-dev stylelint), as we may have recently added the option
  • check that the option exists and is correctly named by reading the rule's README
  • correctly configure the rules property in the configuration object