-
-
Notifications
You must be signed in to change notification settings - Fork 927
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
a25bc38
Add rule-empty-line-before rule
jeddy3 b08f549
Add except after rule option
jeddy3 9c49130
Re add rules to list
jeddy3 002de7a
Add nested tests
jeddy3 a3ac755
Update multi-line examples
jeddy3 aa23206
Tweak examples
jeddy3 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,252 @@ | ||
# 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 { | ||
color: red; | ||
} | ||
b { | ||
color: blue; | ||
} | ||
``` | ||
|
||
The following patterns are *not* considered warnings: | ||
|
||
```css | ||
a { | ||
color: red; | ||
} | ||
|
||
b { | ||
color: blue; | ||
} | ||
``` | ||
|
||
### `"never-multi-line"` | ||
|
||
There *must never* be an empty line before multi-line rules. | ||
|
||
The following patterns are considered warnings: | ||
|
||
```css | ||
a { | ||
color: red; | ||
} | ||
|
||
b { | ||
color: blue; | ||
} | ||
``` | ||
|
||
The following patterns are *not* considered warnings: | ||
|
||
```css | ||
a { | ||
color: red; | ||
} | ||
b { | ||
color: blue; | ||
} | ||
``` | ||
|
||
## Optional secondary options | ||
|
||
### `except: ["after-rule", "after-single-line-comment", "inside-block-and-after-rule", "first-nested"]` | ||
|
||
#### `"after-rule"` | ||
|
||
Reverse the primary option if the rule comes after another rule. | ||
|
||
For example, with `"always"`: | ||
|
||
The following patterns are considered warnings: | ||
|
||
```css | ||
a {} | ||
|
||
b {} | ||
``` | ||
|
||
The following patterns are *not* considered warnings: | ||
|
||
```css | ||
a {} | ||
b {} | ||
``` | ||
|
||
#### `"after-single-line-comment"` | ||
|
||
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 {} | ||
} | ||
``` |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.