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

declaration-empty-line-before

Require or disallow an empty line before declarations.

a {
  --foo: pink;
             /* ← */
  top: 15px; /* ↑ */
}            /* ↑ */
/**             ↑
 *      This line */

This rule only applies to standard property declarations. Use the custom-property-empty-line-before rule for custom property declarations.

The --fix option on the command line can automatically fix all of the problems reported by this rule. We recommend to enable indentation rule for better autofixing results with this rule.

Options

string: "always"|"never"

"always"

The following patterns are considered violations:

a {
  --foo: pink;
  top: 5px;
}
a {
  bottom: 15px;
  top: 5px;
}

The following patterns are not considered violations:

a {
  --foo: pink;

  top: 5px;
}
a {

  bottom: 15px;

  top: 5px;
}

"never"

The following patterns are considered violations:

a {
  --foo: pink;

  bottom: 15px;
}
a {

  bottom: 15px;

  top: 5px;
}

The following patterns are not considered violations:

a {
  --foo: pink;
  bottom: 15px;
}
a {
  bottom: 15px;
  top: 5px;
}

Optional secondary options

except: ["after-comment", "after-declaration", "first-nested"]

"after-comment"

Reverse the primary option for declarations that follow a comment.

Shared-line comments do not trigger this option.

For example, with "always":

The following patterns are considered violations:

a {
  /* comment */

  top: 5px;
}
a {
  bottom: 5px; /* comment */
  top: 5px;
}

The following patterns are not considered violations:

a {
  /* comment */
  top: 5px;
}

a {
  bottom: 5px; /* comment */

  top: 5px;
}

"after-declaration"

Reverse the primary option for declarations that follow another declaration.

Shared-line comments do not affect this option.

For example, with "always":

The following patterns are considered violations:

a {

  bottom: 15px;

  top: 5px;
}
a {

  bottom: 15px; /* comment */

  top: 5px;
}

The following patterns are not considered violations:

a {

  bottom: 15px;
  top: 5px;
}
a {

  bottom: 15px; /* comment */
  top: 5px;
}

"first-nested"

Reverse the primary option for declarations that are nested and the first child of their parent node.

For example, with "always":

The following patterns are considered violations:

a {

  bottom: 15px;

  top: 5px;
}

The following patterns are not considered violations:

a {
  bottom: 15px;

  top: 5px;
}

ignore: ["after-comment", "after-declaration", "first-nested", "inside-single-line-block"]

"after-comment"

Ignore declarations that follow a comment.

For example, with "always":

The following patterns are not considered violations:

a {
  /* comment */
  bottom: 15px;
}

"after-declaration"

Ignore declarations that follow another declaration.

For example, with "always":

The following patterns are not considered violations:

a {

  bottom: 15px;
  top: 15px;
}
a {

  bottom: 15px;

  top: 15px;
}
a {

  color: orange;
  text-decoration: none;

  bottom: 15px;
  top: 15px;
}

"first-nested"

Ignore declarations that are nested and the first child of their parent node.

For example, with "always":

The following patterns are not considered violations:

a {
  bottom: 15px;

  top: 5px;
}

"inside-single-line-block"

Ignore declarations that are inside single-line blocks.

For example, with "always":

The following patterns are not considered violations:

a { bottom: 15px; top: 5px; }
← declaration-colon-space-beforedeclaration-no-important →
  • Options
    • "always"
    • "never"
  • Optional secondary options
    • except: ["after-comment", "after-declaration", "first-nested"]
    • ignore: ["after-comment", "after-declaration", "first-nested", "inside-single-line-block"]
Copyright © 2019 stylelint