Skip to content

Commit 9d5b261

Browse files
committed
Merge pull request #49 from csscomb/m.readme
README: Describe all of the options (Close #42)
2 parents 6baf145 + f9e2f76 commit 9d5b261

File tree

1 file changed

+165
-5
lines changed

1 file changed

+165
-5
lines changed

README.md

Lines changed: 165 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
# CSSCOMB [![Build Status](https://secure.travis-ci.org/csscomb/csscomb.js.png?branch=master)](http://travis-ci.org/csscomb/csscomb.js)
22

33
CSSComb is a coding style formatter for CSS.
4+
You can easily write your own [configuration](#configuration) to make your style sheets beautiful and consistent.
5+
6+
The main feature is the [sorting properties](#sort-order) in specific order.
7+
It was inspired by the same-named [@miripiruni](https://github.com/miripiruni)'s [PHP-based tool](https://github.com/csscomb/csscomb).
8+
This is the new JavaScript version, based on powerful CSS parser [Gonzales](https://github.com/css/gonzales).
49

510
## Installation
611

@@ -28,7 +33,7 @@ To run `csscomb`, you can use the following command from the project root:
2833
2934
## Configuration
3035
31-
`csscomb` is configured using `.csscomb.json` file, located in the project root.
36+
`csscomb` is configured using [.csscomb.json](https://github.com/csscomb/csscomb.js/blob/master/.csscomb.json) file, located in the project root.
3237
3338
Example configuration:
3439
```json
@@ -54,6 +59,7 @@ Example configuration:
5459
Available value: `{Boolean}` true
5560
5661
Example: `{ "always-semicolon": true }`
62+
5763
```css
5864
/* before */
5965
a { color: red }
@@ -64,25 +70,31 @@ a { color: red; }
6470
6571
### block-indent
6672
73+
**Note**: better to use with [rule-indent](#rule-indent)
74+
6775
Available values:
68-
* `{Boolean}` true
76+
* `{Boolean}` true (means 4 spaces)
6977
* `{Number}` of spaces
70-
* `{String}` of space characters (`/[ \t]*`)
78+
* `{String}` of whitespace characters (`/[ \t]*/`)
7179
7280
Example: `{ "block-indent": 2 }`
81+
7382
```css
7483
/* before */
7584
a { color: red }
7685
@media all { a { color: green } }
7786
7887
/* after */
79-
a { color: red }
88+
a { color: red
89+
}
8090
@media all {
81-
a { color: green }
91+
a { color: green
92+
}
8293
}
8394
```
8495
8596
### colon-space
97+
8698
Available values:
8799
* `{Boolean}` true (means `after`)
88100
* `{String}`: `before`, `after`, `both` or any combination of whitespaces
@@ -123,6 +135,154 @@ a { color: red }
123135
a { color:red }
124136
```
125137
138+
### color-case
139+
140+
Available values: `{String}` `lower` or `upper`
141+
142+
Example: `{ "color-case": "lower" }`
143+
144+
```css
145+
/* before */
146+
a { color: #FFF }
147+
148+
/* after */
149+
a { color: #fff }
150+
```
151+
152+
### color-shorthand
153+
154+
Available values: `{Boolean}` `true` or `false`
155+
156+
Example: `{ "color-shorthand": true }`
157+
158+
```css
159+
/* before */
160+
b { color: #ffcc00 }
161+
162+
/* after */
163+
b { color: #fc0 }
164+
```
165+
166+
### leading-zero
167+
168+
Available values: `{Boolean}` `true` or `false`
169+
170+
Example: `{ "leading-zero": false }`
171+
172+
```css
173+
/* before */
174+
p { padding: 0.5em }
175+
176+
/* after */
177+
p { padding: .5em }
178+
```
179+
180+
### rule-indent
181+
182+
**Note**: better to use with [block-indent](#block-indent)
183+
184+
Available values:
185+
* `{Boolean}` true (means 4 spaces)
186+
* `{Number}` of spaces
187+
* `{String}` of whitespace characters (`/[ \t]*/`)
188+
189+
Example: `{ "rule-indent": 2 }`
190+
191+
```css
192+
/* before */
193+
a { color:red; margin:0 }
194+
195+
/* after */
196+
a {
197+
color:red;
198+
margin:0 }
199+
```
200+
201+
### sort-order
202+
203+
**Note**: you can use an example of [.csscomb.json](https://github.com/csscomb/csscomb.js/blob/master/.csscomb.json) to set your own sort order
204+
205+
Available values:
206+
* `{Array}` of rules
207+
* `{Array}` of arrays of rules for groups separation
208+
209+
Example: `{ "sort-order": [ "margin", "padding" ] }`
210+
211+
```css
212+
/* before */
213+
p {
214+
padding: 0;
215+
margin: 0;
216+
}
217+
218+
/* after */
219+
p {
220+
margin: 0;
221+
padding: 0;
222+
}
223+
```
224+
225+
Example: `{ "sort-order": [ [ "margin", "padding" ], [ "border", "background" ] ] }`
226+
227+
```css
228+
/* before */
229+
p {
230+
background: none;
231+
border: 0;
232+
margin: 0;
233+
padding: 0;
234+
}
235+
236+
/* after */
237+
p {
238+
margin: 0;
239+
padding: 0;
240+
241+
border: 0;
242+
background: none;
243+
}
244+
```
245+
246+
### stick-brace
247+
248+
Available values:
249+
* `{Boolean}` true (means 1 spaces)
250+
* `{String}` of whitespace characters (`/[ \t\n]*/`)
251+
252+
Example: `{ "stick-brace": "\n" }`
253+
254+
```css
255+
/* before */
256+
a { color:red }
257+
258+
/* after */
259+
a
260+
{ color:red }
261+
```
262+
263+
### strip-spaces
264+
265+
Available value: `{Boolean}` true
266+
267+
Example: `{ "strip-spaces": true }`
268+
269+
Before: `a { color: red } \nb { font-weight: normal }`
270+
After: `a { color: red }\nb { font-weight: normal }\n`
271+
272+
### unitless-zero
273+
274+
Available value: `{Boolean}` `true`
275+
276+
Example: `{ "unitless-zero": true }`
277+
278+
```css
279+
/* before */
280+
img { border: 0px }
281+
282+
/* after */
283+
img { border: 0 }
284+
```
285+
126286
## Tests
127287
128288
Run `npm test` for tests.

0 commit comments

Comments
 (0)