stylelint
  • User guide
  • Rules
  • Plugins
  • Developer guide
  • Demo
  • GitHub
  • Twitter

›Rules

Overview

  • Home
  • Vision
  • Changelog
  • Contributing

For users

  • User guide
  • FAQ
  • About rules
  • Semantic versioning policy
  • Configuration
  • Rules
  • Plugins
  • Processors
  • Example config
  • CSS processors
  • Command Line Interface (CLI)
  • The stylelint Node.js API
  • The stylelint PostCSS plugin
  • Complementary tools
  • Articles

Rules

  • at-rule-blacklist
  • at-rule-empty-line-before
  • at-rule-name-case
  • at-rule-name-newline-after
  • at-rule-name-space-after
  • at-rule-no-unknown
  • at-rule-no-vendor-prefix
  • at-rule-property-requirelist
  • at-rule-semicolon-newline-after
  • at-rule-semicolon-space-before
  • at-rule-whitelist
  • block-closing-brace-empty-line-before
  • block-closing-brace-newline-after
  • block-closing-brace-newline-before
  • block-closing-brace-space-after
  • block-closing-brace-space-before
  • block-no-empty
  • block-opening-brace-newline-after
  • block-opening-brace-newline-before
  • block-opening-brace-space-after
  • block-opening-brace-space-before
  • color-hex-case
  • color-hex-length
  • color-named
  • color-no-hex
  • color-no-invalid-hex
  • comment-empty-line-before
  • comment-no-empty
  • comment-whitespace-inside
  • comment-word-blacklist
  • custom-media-pattern
  • custom-property-empty-line-before
  • custom-property-pattern
  • declaration-bang-space-after
  • declaration-bang-space-before
  • declaration-block-no-duplicate-properties
  • declaration-block-no-redundant-longhand-properties
  • declaration-block-no-shorthand-property-overrides
  • declaration-block-semicolon-newline-after
  • declaration-block-semicolon-newline-before
  • declaration-block-semicolon-space-after
  • declaration-block-semicolon-space-before
  • declaration-block-single-line-max-declarations
  • declaration-block-trailing-semicolon
  • declaration-colon-newline-after
  • declaration-colon-space-after
  • declaration-colon-space-before
  • declaration-empty-line-before
  • declaration-no-important
  • declaration-property-unit-blacklist
  • declaration-property-unit-whitelist
  • declaration-property-value-blacklist
  • declaration-property-value-whitelist
  • font-family-name-quotes
  • font-family-no-duplicate-names
  • font-family-no-missing-generic-family-keyword
  • font-weight-notation
  • function-blacklist
  • function-calc-no-invalid
  • function-calc-no-unspaced-operator
  • function-comma-newline-after
  • function-comma-newline-before
  • function-comma-space-after
  • function-comma-space-before
  • function-linear-gradient-no-nonstandard-direction
  • function-max-empty-lines
  • function-name-case
  • function-parentheses-newline-inside
  • function-parentheses-space-inside
  • function-url-no-scheme-relative
  • function-url-quotes
  • function-url-scheme-blacklist
  • function-url-scheme-whitelist
  • function-whitelist
  • function-whitespace-after
  • indentation
  • keyframe-declaration-no-important
  • keyframes-name-pattern
  • length-zero-no-unit
  • linebreaks
  • max-empty-lines
  • max-line-length
  • max-nesting-depth
  • media-feature-colon-space-after
  • media-feature-colon-space-before
  • media-feature-name-blacklist
  • media-feature-name-case
  • media-feature-name-no-unknown
  • media-feature-name-no-vendor-prefix
  • media-feature-name-value-whitelist
  • media-feature-name-whitelist
  • media-feature-parentheses-space-inside
  • media-feature-range-operator-space-after
  • media-feature-range-operator-space-before
  • media-query-list-comma-newline-after
  • media-query-list-comma-newline-before
  • media-query-list-comma-space-after
  • media-query-list-comma-space-before
  • no-descending-specificity
  • no-duplicate-at-import-rules
  • no-duplicate-selectors
  • no-empty-first-line
  • no-empty-source
  • no-eol-whitespace
  • no-extra-semicolons
  • no-invalid-double-slash-comments
  • no-missing-end-of-source-newline
  • no-unknown-animations
  • number-leading-zero
  • number-max-precision
  • number-no-trailing-zeros
  • property-blacklist
  • property-case
  • property-no-unknown
  • property-no-vendor-prefix
  • property-whitelist
  • rule-empty-line-before
  • selector-attribute-brackets-space-inside
  • selector-attribute-operator-blacklist
  • selector-attribute-operator-space-after
  • selector-attribute-operator-space-before
  • selector-attribute-operator-whitelist
  • selector-attribute-quotes
  • selector-class-pattern
  • selector-combinator-blacklist
  • selector-combinator-space-after
  • selector-combinator-space-before
  • selector-combinator-whitelist
  • selector-descendant-combinator-no-non-space
  • selector-id-pattern
  • selector-list-comma-newline-after
  • selector-list-comma-newline-before
  • selector-list-comma-space-after
  • selector-list-comma-space-before
  • selector-max-attribute
  • selector-max-class
  • selector-max-combinators
  • selector-max-compound-selectors
  • selector-max-empty-lines
  • selector-max-id
  • selector-max-pseudo-class
  • selector-max-specificity
  • selector-max-type
  • selector-max-universal
  • selector-nested-pattern
  • selector-no-qualifying-type
  • selector-no-vendor-prefix
  • selector-pseudo-class-blacklist
  • selector-pseudo-class-case
  • selector-pseudo-class-no-unknown
  • selector-pseudo-class-parentheses-space-inside
  • selector-pseudo-class-whitelist
  • selector-pseudo-element-blacklist
  • selector-pseudo-element-case
  • selector-pseudo-element-colon-notation
  • selector-pseudo-element-no-unknown
  • selector-pseudo-element-whitelist
  • selector-type-case
  • selector-type-no-unknown
  • shorthand-property-no-redundant-values
  • string-no-newline
  • string-quotes
  • time-min-milliseconds
  • unicode-bom
  • unit-blacklist
  • unit-case
  • unit-no-unknown
  • unit-whitelist
  • value-keyword-case
  • value-list-comma-newline-after
  • value-list-comma-newline-before
  • value-list-comma-space-after
  • value-list-comma-space-before
  • value-list-max-empty-lines
  • value-no-vendor-prefix

For developers

  • Developer guide
  • Prerequisites to contributing
  • Working on rules
  • Writing plugins
  • Writing processors
  • Writing formatters
  • Performing releases
  • Reviewing pull requests
  • Managing issues
Edit

selector-max-id

Limit the number of ID selectors in a selector.

    #foo {}
/** ↑
 * This type of selector */

This rule resolves nested selectors before counting the number of ID selectors. Each selector in a selector list is evaluated separately.

The :not() pseudo-class is also evaluated separately. The rule processes the argument as if it were an independent selector, and the result does not count toward the total for the entire selector.

Options

int: Maximum universal selectors allowed.

For example, with 2:

The following patterns are considered violations:

#foo #bar #baz {}
#foo #bar {
  & #baz {}
}
#foo #bar {
  & > #bar {}
}

The following patterns are not considered violations:

#foo {}
#foo #bar {}
.foo #foo {}
#foo.foo #bar {}
/* each selector in a selector list is evaluated separately */
#foo,
#baz #quux {}
/* `#bar` is inside `:not()`, so it is evaluated separately */
#foo #bar:not(#baz) {}
← selector-max-empty-linesselector-max-pseudo-class →
  • Options
Copyright © 2019 stylelint