Gathering detailed insights and metrics for postcss-plugin-sorting
Gathering detailed insights and metrics for postcss-plugin-sorting
Gathering detailed insights and metrics for postcss-plugin-sorting
Gathering detailed insights and metrics for postcss-plugin-sorting
postcss-sorting
PostCSS plugin to keep rules and at-rules content in order.
postcss-sort-media-queries
PostCSS plugin for sorting and combining CSS media queries with mobile first / **desktop first methodologies
postcss-sort
PostCSS plugin for sorting properties
postcss-custom-prop-sorting
Adds custom properties to the start of a declaration block and sorts them.
PostCSS plugin to keep rules and at-rules content in order.
npm install postcss-plugin-sorting
Typescript
Module System
Node Version
NPM Version
72.1
Supply Chain
99.4
Quality
75.3
Maintenance
100
Vulnerability
100
License
JavaScript (71.35%)
CSS (28.04%)
HTML (0.61%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
524 Stars
322 Commits
32 Forks
7 Watchers
2 Branches
13 Contributors
Updated on Jun 11, 2025
Latest Version
7.0.2
Package Id
postcss-plugin-sorting@7.0.2
Unpacked Size
47.57 kB
Size
12.71 kB
File Count
31
NPM Version
8.1.0
Node Version
16.13.0
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
PostCSS plugin to keep rules and atrule content in order.
Lint and autofix stylesheet order with stylelint-order.
1npm install --save-dev postcss postcss-sorting
The plugin has no default options. Everything is disabled by default.
order
: Specify the order of content within declaration blocks.properties-order
: Specify the order of properties within declaration blocks.unspecified-properties-position
: Specify position for properties not specified in properties-order
.throw-validate-errors
: Throw config validation errors instead of showing and ignoring them. Defaults to false
.Comments that are before node and on a separate line linked to that node. Shared-line comments are also linked to that node. Shared-line comments are comments which are located after a node and on the same line as a node.
1a { 2 top: 5px; /* shared-line comment belongs to `top` */ 3 /* comment belongs to `bottom` */ 4 /* comment belongs to `bottom` */ 5 bottom: 15px; /* shared-line comment belongs to `bottom` */ 6}
Some atrule, like control and function directives in Sass, are ignored. It means rules won't touch content inside these atrule, as doing so could change or break functionality.
Plugin will ignore rules, which have template literal interpolation, to avoid breaking the logic:
1const Component = styled.div` 2 /* The following properties WILL NOT be sorted, because interpolation is on properties level */ 3 z-index: 1; 4 top: 1px; 5 ${props => props.great && 'color: red'}; 6 position: absolute; 7 display: block; 8 9 div { 10 /* The following properties WILL be sorted, because interpolation for property value only */ 11 z-index: 2; 12 position: static; 13 top: ${2 + 10}px; 14 display: inline-block; 15 } 16`;
See PostCSS docs for more examples.
Add postcss-cli and PostCSS Sorting to your project:
1npm install postcss postcss-cli postcss-sorting --save-dev
Create a postcss.config.js
with PostCSS Sorting configuration:
1module.exports = { 2 plugins: [ 3 'postcss-sorting': { 4 order: [ 5 'custom-properties', 6 'dollar-variables', 7 'declarations', 8 'atrule', 9 'rules', 10 ], 11 12 'properties-order': 'alphabetical', 13 14 'unspecified-properties-position': 'bottom', 15 }, 16 ], 17};
Or, add the 'postcss-sorting'
section to your existing postcss-cli
configuration file.
Next execute:
1npx postcss --no-map --replace your-css-file.css
For more information and options, please consult the postcss-cli docs.
Add gulp-postcss and PostCSS Sorting to your build tool:
1npm install postcss gulp-postcss postcss-sorting --save-dev
Enable PostCSS Sorting within your Gulpfile:
1let gulp = require('gulp'); 2let postcss = require('gulp-postcss'); 3let sorting = require('postcss-sorting'); 4 5exports['sort-css'] = () => { 6 return gulp 7 .src('./css/src/*.css') 8 .pipe( 9 postcss([ 10 sorting({ 11 /* options */ 12 }), 13 ]) 14 ) 15 .pipe(gulp.dest('./css/src')); 16};
This plugin available as Sublime Text, Atom, VS Code, and Emacs plugin. Though, seems all these plugins are not maintained.
stylelint and stylelint-order help lint stylesheets and let you know if stylesheet order is correct. Also, they could autofix stylesheets.
I recommend Prettier for formatting stylesheets.
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
1 existing vulnerabilities detected
Details
Reason
dependency not pinned by hash detected -- score normalized to 3
Details
Reason
Found 4/28 approved changesets -- score normalized to 1
Reason
1 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
security policy file not detected
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More