New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add rule-empty-line-before rule #2309
Changes from 1 commit
a25bc38
b08f549
9c49130
002de7a
a3ac755
aa23206
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,223 @@ | ||
# rule-empty-line-before | ||
|
||
Require or disallow an empty line before rules. | ||
|
||
```css | ||
a {} | ||
/* ← */ | ||
b {} /* ↑ */ | ||
/** ↑ | ||
* This line */ | ||
``` | ||
|
||
If the rule is the very first node in a stylesheet then it is ignored. | ||
|
||
## Options | ||
|
||
`string`: `"always"|"never"|"always-multi-line"|"never-multi-line"` | ||
|
||
### `"always"` | ||
|
||
There *must always* be an empty line before rules. | ||
|
||
The following patterns are considered warnings: | ||
|
||
```css | ||
a {} b {} | ||
``` | ||
|
||
```css | ||
a {} | ||
b {} | ||
``` | ||
|
||
The following patterns are *not* considered warnings: | ||
|
||
```css | ||
a {} | ||
|
||
b {} | ||
``` | ||
|
||
### `"never"` | ||
|
||
There *must never* be an empty line before rules. | ||
|
||
The following patterns are considered warnings: | ||
|
||
```css | ||
a {} | ||
|
||
b {} | ||
``` | ||
|
||
The following patterns are *not* considered warnings: | ||
|
||
```css | ||
a {} b {} | ||
``` | ||
|
||
```css | ||
a {} | ||
b {} | ||
``` | ||
|
||
### `"always-multi-line"` | ||
|
||
There *must always* be an empty line before multi-line rules. | ||
|
||
The following patterns are considered warnings: | ||
|
||
```css | ||
a | ||
{} | ||
b | ||
{} | ||
``` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think these are confusing examples. Multi-line rules typically manifest as multiple lines of declarations — that's what people will recognize. Let's do that. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done, or did you mean actually put a declaration inside the block? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @jeddy3 As a user I would have better understanding if there would be declarations. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thing is, "multi-line" doesn't necessarily mean multiple declarations. This is multi-line:
i.e. the rule spans multiple lines. Perhaps a single declaration is the clearest? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. From a user perspective your example with a single declaration isn't always a multi-line rule :) User might assume that this is single-line rule. In fact you're right, of course. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @jeddy3 You're right: that seems fine to me, too. |
||
|
||
The following patterns are *not* considered warnings: | ||
|
||
```css | ||
a | ||
{} | ||
|
||
b | ||
{} | ||
``` | ||
|
||
### `"never-multi-line"` | ||
|
||
There *must never* be an empty line before multi-line rules. | ||
|
||
The following patterns are considered warnings: | ||
|
||
```css | ||
a | ||
{} | ||
|
||
b | ||
{} | ||
``` | ||
|
||
The following patterns are *not* considered warnings: | ||
|
||
```css | ||
a | ||
{} | ||
b | ||
{} | ||
``` | ||
|
||
## Optional secondary options | ||
|
||
### `except: ["after-single-line-comment", "inside-block-and-after-rule", "first-nested"]` | ||
|
||
#### `"after-single-line-comment"` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why it's explicitly for a single-line comment? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This rule mimics the options from the previous two rules. Only the |
||
|
||
Reverse the primary option if the rule comes after a single-line comment. | ||
|
||
For example, with `"always"`: | ||
|
||
The following patterns are considered warnings: | ||
|
||
```css | ||
/* comment */ | ||
|
||
a {} | ||
``` | ||
|
||
The following patterns are *not* considered warnings: | ||
|
||
```css | ||
/* comment */ | ||
a {} | ||
``` | ||
|
||
#### `"inside-block-and-after-rule"` | ||
|
||
Reverse the primary option if the rule is inside a block and comes after another rule. | ||
|
||
For example, with `"always"`: | ||
|
||
The following patterns are considered warnings: | ||
|
||
```css | ||
@media { | ||
|
||
a {} | ||
|
||
b {} | ||
} | ||
``` | ||
|
||
The following patterns are *not* considered warnings: | ||
|
||
```css | ||
@media { | ||
a {} | ||
b {} | ||
} | ||
``` | ||
|
||
#### `"first-nested"` | ||
|
||
Reverse the primary option if the rule is the first in a block. | ||
|
||
For example, with `"always"`: | ||
|
||
The following patterns are considered warnings: | ||
|
||
```css | ||
@media { | ||
|
||
a {} | ||
|
||
b {} | ||
} | ||
``` | ||
|
||
The following patterns are *not* considered warnings: | ||
|
||
```css | ||
@media { | ||
a {} | ||
|
||
b {} | ||
} | ||
``` | ||
|
||
### `ignore: ["after-comment", "inside-block"]` | ||
|
||
#### `"after-comment"` | ||
|
||
Ignore rules that come after a comment. | ||
|
||
For example, with `"always"`: | ||
|
||
The following patterns are *not* considered warnings: | ||
|
||
```css | ||
/* comment */ | ||
a {} | ||
``` | ||
|
||
#### `"inside-block"` | ||
|
||
Ignore rules that are inside a block. | ||
|
||
For example, with `"always"`: | ||
|
||
The following patterns are *not* considered warnings: | ||
|
||
```css | ||
@media { | ||
a {} | ||
} | ||
``` | ||
|
||
```css | ||
@media { | ||
a {} | ||
b {} | ||
} | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you think it's a good idea delete links to docs? These rules still in stylelint, despite the fact they are deprecated. When user will see a deprecation message, she may want to read what this rule for. But it will be very difficult to find.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point.
Can you create a PR that adds them back in for the other 13 deprecated rules? Please append "(deprecated)." to the end of the description.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will do today.