Skip to content
This repository was archived by the owner on Apr 9, 2024. It is now read-only.

Commit a1ad625

Browse files
1.0.0
0 parents  commit a1ad625

File tree

10 files changed

+183
-0
lines changed

10 files changed

+183
-0
lines changed

.editorconfig

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
root = true
2+
3+
[*]
4+
indent_style = space
5+
indent_size = 4
6+
end_of_line = lf
7+
charset = utf-8
8+
trim_trailing_whitespace = true
9+
insert_final_newline = true
10+
11+
[*.{json,yml}]
12+
indent_size = 2

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules/
2+
npm-debug.log

.npmignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
.gitignore
2+
.editorconfig
3+
4+
node_modules/
5+
npm-debug.log
6+
7+
*.test.js
8+
.travis.yml

.travis.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
language: node_js
2+
cache: yarn
3+
node_js:
4+
- stable
5+
- "6"
6+
- "4"

CHANGELOG.md

Whitespace-only changes.

LICENSE

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
The MIT License (MIT)
2+
3+
Copyright 2016 AvraamMavridis <[email protected]>
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy of
6+
this software and associated documentation files (the "Software"), to deal in
7+
the Software without restriction, including without limitation the rights to
8+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9+
the Software, and to permit persons to whom the Software is furnished to do so,
10+
subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# PostCSS Sort Alphabetically [![Build Status][ci-img]][ci]
2+
3+
[PostCSS] plugin which sorts css properties alphabetically.
4+
5+
[PostCSS]: https://github.com/postcss/postcss
6+
[ci-img]: https://travis-ci.org/AvraamMavridis/postcss-sort-alphabetically.svg
7+
[ci]: https://travis-ci.org/AvraamMavridis/postcss-sort-alphabetically
8+
9+
```css
10+
.foo {
11+
/* Input example */
12+
}
13+
```
14+
15+
```css
16+
.foo {
17+
/* Output example */
18+
}
19+
```
20+
21+
## Usage
22+
23+
```js
24+
postcss([ require('postcss-sort-alphabetically') ])
25+
```
26+
27+
See [PostCSS] docs for examples for your environment.

index.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
var postcss = require('postcss');
2+
3+
module.exports = postcss.plugin('postcss-sort-alphabetically', function () {
4+
5+
// Work with options here
6+
7+
return function (root) {
8+
9+
root.walkRules(rule => {
10+
rule.nodes = rule.nodes.sort(function (a, b) {
11+
if (a < b) return -1;
12+
if (a > b) return 1;
13+
return 0;
14+
});
15+
});
16+
17+
};
18+
});

index.test.js

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
var postcss = require('postcss');
2+
3+
var plugin = require('./');
4+
5+
function run(input, output, opts) {
6+
return postcss([ plugin(opts) ]).process(input)
7+
.then(result => {
8+
expect(result.css).toEqual(output);
9+
expect(result.warnings().length).toBe(0);
10+
});
11+
}
12+
13+
14+
it('does something', () => {
15+
return run(`a{
16+
border: 1px solid black;
17+
color: red;
18+
background-color: red;
19+
}
20+
div{
21+
padding: 10px;
22+
margin: 20px;
23+
color: red;
24+
background-color: red;
25+
}
26+
.class {
27+
flex: 1;
28+
display-flex: 10px;
29+
}
30+
#some {
31+
background-image: url('something');
32+
align-items: center;
33+
}`,
34+
`a{
35+
background-color: red;
36+
border: 1px solid black;
37+
color: red;
38+
}
39+
div{
40+
background-color: red;
41+
color: red;
42+
margin: 20px;
43+
padding: 10px;
44+
}
45+
.class {
46+
display-flex: 10px;
47+
flex: 1;
48+
}
49+
#some {
50+
align-items: center;
51+
background-image: url('something');
52+
}`
53+
, { });
54+
});

package.json

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
"name": "postcss-sort-alphabetically",
3+
"version": "0.1.0",
4+
"description": "PostCSS plugin which sorts css properties alphabetically",
5+
"keywords": [
6+
"postcss",
7+
"css",
8+
"postcss-plugin",
9+
"sort",
10+
"alphabetically"
11+
],
12+
"author": "AvraamMavridis <[email protected]>",
13+
"license": "MIT",
14+
"repository": "AvraamMavridis/postcss-sort-alphabetically",
15+
"bugs": {
16+
"url": "https://github.com/AvraamMavridis/postcss-sort-alphabetically/issues"
17+
},
18+
"homepage": "https://github.com/AvraamMavridis/postcss-sort-alphabetically",
19+
"dependencies": {
20+
"postcss": "^5.2.6"
21+
},
22+
"devDependencies": {
23+
"eslint": "^3.12.2",
24+
"eslint-config-postcss": "^2.0.2",
25+
"jest": "^18.0.0"
26+
},
27+
"scripts": {
28+
"test": "jest && eslint *.js"
29+
},
30+
"eslintConfig": {
31+
"extends": "eslint-config-postcss/es5",
32+
"env": {
33+
"jest": true
34+
}
35+
}
36+
}

0 commit comments

Comments
 (0)