Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

postcss-sorting

Package Overview
Dependencies
Maintainers
1
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

postcss-sorting - npm Package Compare versions

Comparing version 1.4.1 to 1.5.0

3

CHANGELOG.md

@@ -5,2 +5,5 @@ # Change Log

## 1.5.0
* Add `empty-lines-before-comment` and `empty-lines-after-comment`, which add empty lines before and after a comment or a group of comments.
## 1.4.1

@@ -7,0 +10,0 @@ * Fix issue with a rule content starting with a comment and follow by a rule. Error happens if config has any option except `sort-order`. #21

@@ -14,2 +14,4 @@ var postcss = require('postcss');

options['preserve-empty-lines-between-children-rules'] = options['preserve-empty-lines-between-children-rules'] || false;
options['empty-lines-before-comment'] = options['empty-lines-before-comment'] || 0;
options['empty-lines-after-comment'] = options['empty-lines-after-comment'] || 0;

@@ -221,2 +223,4 @@ return options;

var preserveLinesBetweenChildren = opts['preserve-empty-lines-between-children-rules'];
var linesBeforeComment = opts['empty-lines-before-comment'];
var linesAfterComment = opts['empty-lines-after-comment'];

@@ -321,3 +325,3 @@ css.walk(function (rule) {

) {
applicableNode.raws.before = createLineBreaks(linesBetweenChildrenRules) + applicableNode.raws.before;
applicableNode.raws.before = createLineBreaks(linesBetweenChildrenRules - countEmptyLines(applicableNode.raws.before)) + applicableNode.raws.before;
}

@@ -333,5 +337,27 @@ }

if (applicableNode) {
applicableNode.raws.before = createLineBreaks(linesBetweenMediaRules) + applicableNode.raws.before;
applicableNode.raws.before = createLineBreaks(linesBetweenMediaRules - countEmptyLines(applicableNode.raws.before)) + applicableNode.raws.before;
}
}
// Insert empty lines before comment
if (
linesBeforeComment &&
node.type === 'comment' &&
(prevNode.type !== 'comment' || prevNode.raws.before.indexOf('\n') === -1) && // prevNode it's not a comment or it's an inline comment
node.raws.before.indexOf('\n') >= 0 && // this isn't an inline comment
countEmptyLines(node.raws.before) < linesBeforeComment
) {
node.raws.before = createLineBreaks(linesBeforeComment - countEmptyLines(node.raws.before)) + node.raws.before;
}
// Insert empty lines after comment
if (
linesAfterComment &&
node.type !== 'comment' &&
prevNode.type === 'comment' &&
prevNode.raws.before.indexOf('\n') >= 0 && // this isn't an inline comment
countEmptyLines(node.raws.before) < linesAfterComment
) {
node.raws.before = createLineBreaks(linesAfterComment - countEmptyLines(node.raws.before)) + node.raws.before;
}
}

@@ -338,0 +364,0 @@ });

2

package.json
{
"name": "postcss-sorting",
"version": "1.4.1",
"version": "1.5.0",
"description": "PostCSS plugin to sort rules content with specified order.",

@@ -5,0 +5,0 @@ "keywords": [

@@ -33,2 +33,4 @@ # PostCSS Sorting [![Build Status][ci-img]][ci]

* [`preserve-empty-lines-between-children-rules`](#preserve-empty-lines-between-children-rules)
* [`empty-lines-before-comment`](#empty-lines-before-comment)
* [`empty-lines-after-comment`](#empty-lines-after-comment)
* [Migration from CSSComb](#migration-from-csscomb)

@@ -382,2 +384,126 @@ * [Usage](#usage)

### `empty-lines-before-comment`
Set a number of empty lines before comment or comments group, which on separate lines. By default, there are no empty lines before comment.
Acceptable value: `{Number}` of empty lines
Example: `{ "empty-lines-before-comment": 2, "sort-order": [ "..." ] }`
```scss
/* before */
.hello {
display: inline-block;
/* upline comment 1 */
/* upline comment 2 */
font-style: italic;
border-bottom: 1px solid red; /* trololo 1 */ /* trololo 2 */
/* arrow */
&:before {
/* yeah */
content: "";
}
/* thing */
&:after {
/* joy */
display: none;
}
&__element {
/* sdfsf */
}
}
/* after */
.hello {
display: inline-block;
/* upline comment 1 */
/* upline comment 2 */
font-style: italic;
border-bottom: 1px solid red; /* trololo 1 */ /* trololo 2 */
/* arrow */
&:before {
/* yeah */
content: "";
}
/* thing */
&:after {
/* joy */
display: none;
}
&__element {
/* sdfsf */
}
}
```
### `empty-lines-after-comment`
Set a number of empty lines after comment or comments group, which on separate lines. By default, there are no empty lines after comment.
Acceptable value: `{Number}` of empty lines
Example: `{ "empty-lines-after-comment": 2, "sort-order": [ "..." ] }`
```scss
/* before */
.hello {
display: inline-block;
/* upline comment 1 */
/* upline comment 2 */
font-style: italic;
border-bottom: 1px solid red; /* trololo 1 */ /* trololo 2 */
/* arrow */
&:before {
/* yeah */
content: "";
}
/* thing */
&:after {
/* joy */
display: none;
}
&__element {
/* sdfsf */
}
}
/* after */
.hello {
display: inline-block;
/* upline comment 1 */
/* upline comment 2 */
font-style: italic;
border-bottom: 1px solid red; /* trololo 1 */ /* trololo 2 */
/* arrow */
&:before {
/* yeah */
content: "";
}
/* thing */
&:after {
/* joy */
display: none;
}
&__element {
/* sdfsf */
}
}
```
### Migration from CSSComb

@@ -384,0 +510,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc