Skip to content

Commit b2fdf0b

Browse files
committed
v0.0.12
2 parents 153a248 + d9cbac1 commit b2fdf0b

File tree

13 files changed

+297
-37
lines changed

13 files changed

+297
-37
lines changed

.csscomb.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"colon-space": true,
99
"color-case": "lower",
1010
"color-shorthand": true,
11+
"combinator-space": true,
1112
"element-case": "lower",
1213
"leading-zero": false,
1314
"rule-indent": true,
@@ -174,7 +175,6 @@
174175
"-ms-animation-iteration-count",
175176
"-o-animation-iteration-count",
176177
"animation-iteration-count",
177-
"animation-iteration-count",
178178
"-webkit-animation-direction",
179179
"-moz-animation-direction",
180180
"-ms-animation-direction",
@@ -195,7 +195,6 @@
195195
"text-indent",
196196
"-ms-text-justify",
197197
"text-justify",
198-
"text-transform",
199198
"letter-spacing",
200199
"word-spacing",
201200
"-ms-writing-mode",
@@ -225,7 +224,6 @@
225224
"-ms-interpolation-mode",
226225
"color",
227226
"border",
228-
"border-collapse",
229227
"border-width",
230228
"border-style",
231229
"border-color",

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
11
node_modules
2+
3+
.idea
4+
*.iml

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## 0.0.12 - 2013-09-11
4+
- Option: combinator-space
5+
- Readme update
6+
- Some CLI fixes
7+
- Contributor added: @anton-rudeshko
8+
39
## 0.0.11 - 2013-09-10
410
- Option: element-case
511
- Fixed block-indent bug with space after at-rule opening brace

CONTRIBUTE.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ git checkout -b <topic-branch-name>
2828
4. Patches and features will not be accepted without tests.
2929
Run `npm test` to check that all tests pass after you've made changes.
3030

31-
5. Locally rebase the upstream development branch into your topic branch:
31+
5. Update the `README.md` if there were corresponding changes or new options.
32+
33+
6. Locally rebase the upstream development branch into your topic branch:
3234
```bash
3335
git pull --rebase upstream dev
3436
```
@@ -38,7 +40,7 @@ git pull --rebase upstream dev
3840
git push origin <topic-branch-name>
3941
```
4042

41-
8. [Open a Pull Request](https://help.github.com/articles/using-pull-requests/) with a clear title and description.
43+
8. [Open a Pull Request](https://help.github.com/articles/using-pull-requests/) to a `dev` branch with a clear title and description.
4244

4345
<a name="maintainers"></a>
4446
## Maintainers

README.md

Lines changed: 44 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
# CSSCOMB [![Build Status](https://secure.travis-ci.org/csscomb/csscomb.js.png?branch=master)](http://travis-ci.org/csscomb/csscomb.js)
1+
# CSSComb [![CSSComb](logo.png)](http://csscomb.com/)
2+
[![Build Status](https://secure.travis-ci.org/csscomb/csscomb.js.png?branch=master)](http://travis-ci.org/csscomb/csscomb.js)
23

34
CSSComb is a coding style formatter for CSS.
45
You can easily write your own [configuration](#configuration) to make your style sheets beautiful and consistent.
@@ -164,6 +165,44 @@ b { color: #ffcc00 }
164165
b { color: #fc0 }
165166
```
166167
168+
### combinator-space
169+
170+
Available values:
171+
* `{Boolean}`: `true` sets one space, `false` removes the spaces.
172+
* `{String}`: any combination of whitespaces.
173+
* `{Array}` with two `{String}` values: for setting left and right whitespace.
174+
175+
Example: `{ "combinator-space": true }`
176+
177+
```css
178+
/* before */
179+
a>b { color: red }
180+
181+
/* after */
182+
a > b { color: red }
183+
```
184+
185+
Example: `{ "combinator-space": "" }`
186+
187+
```css
188+
/* before */
189+
a > b { color: red }
190+
191+
/* after */
192+
a>b { color: red }
193+
```
194+
195+
Example: `{ "combinator-space": [" ", "\n"] }`
196+
197+
```css
198+
/* before */
199+
a>b { color: red }
200+
201+
/* after */
202+
a >
203+
b { color: red }
204+
```
205+
167206
### element-case
168207
169208
Available values: `{String}` `lower` or `upper`
@@ -281,8 +320,8 @@ Available value: `{Boolean}` true
281320
282321
Example: `{ "strip-spaces": true }`
283322
284-
Before:
285-
```a { color: red } \nb { font-weight: normal }\n\n\n`
323+
Before: `a { color: red } \nb { font-weight: normal }\n\n\n`
324+
286325
After: `a { color: red }\nb { font-weight: normal }\n`
287326
288327
### unitless-zero
@@ -318,7 +357,8 @@ Thanks for assistance and contributions:
318357
[@puzankov](https://github.com/puzankov),
319358
[@L0stSoul](https://github.com/L0stSoul),
320359
[@ignovak](https://github.com/ignovak),
321-
[@kizu](https://github.com/kizu)
360+
[@kizu](https://github.com/kizu),
361+
[@anton-rudeshko](https://github.com/anton-rudeshko)
322362
323363
## License
324364

lib/cli.js

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Command line implementation for CSScomb
2+
* Command line implementation for CSSComb
33
*
44
* Usage example:
55
* ./node_modules/.bin/csscomb file1 [dir1 [fileN [dirN]]]
@@ -15,19 +15,22 @@ program
1515
.option('-c, --config [path]', 'configuration file path')
1616
.parse(process.argv);
1717

18-
var comb = new Comb();
18+
if (!program.args.length) {
19+
console.log('No input paths specified');
20+
program.help();
21+
}
22+
1923
var configPath = program.config || (process.cwd() + '/.csscomb.json');
2024

2125
if (fs.existsSync(configPath)) {
26+
var comb = new Comb();
2227
comb.configure(require(configPath));
23-
if (program.args.length > 0) {
24-
vow.all(program.args.map(function(path) {
25-
return comb.processPath(path);
26-
})).fail(function(e) {
27-
console.log('stack: ', e.stack);
28-
process.exit(1);
29-
});
30-
}
28+
vow.all(program.args.map(function(path) {
29+
return comb.processPath(path);
30+
})).fail(function(e) {
31+
console.log('stack: ', e.stack);
32+
process.exit(1);
33+
});
3134
} else {
3235
console.log('Configuration file ' + configPath + ' was not found.');
3336
process.exit(1);

lib/csscomb.js

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ var vfs = require('vow-fs');
66
/**
77
* Starts Code Style processing process.
88
*
9+
* @constructor
910
* @name Comb
1011
*/
1112
var Comb = function() {
12-
this._handlers;
1313
this._options = [
1414
'always-semicolon',
1515
'color-case',
@@ -19,12 +19,12 @@ var Comb = function() {
1919
'strip-spaces',
2020
'stick-brace',
2121
'colon-space',
22+
'combinator-space',
2223
'rule-indent',
2324
'block-indent',
2425
'unitless-zero',
2526
'sort-order'
2627
];
27-
this._config = {};
2828
this._exclude = null;
2929
};
3030

@@ -37,17 +37,18 @@ Comb.prototype = {
3737
* @param {Object} config
3838
*/
3939
configure: function(config) {
40-
var _this = this;
4140
this._handlers = [];
4241
this._options.forEach(function(option) {
43-
if (config[option] !== undefined) {
44-
try {
45-
var handler = require('./options/' + option).setValue(config[option]);
46-
handler && _this._handlers.push(handler);
47-
} catch (e) {
48-
}
42+
if (typeof config[option] === 'undefined') return;
43+
44+
try {
45+
var handler = require('./options/' + option).setValue(config[option]);
46+
handler && this._handlers.push(handler);
47+
} catch (e) {
48+
console.warn('Error loading "%s" handler: %s', option, e.message);
4949
}
50-
});
50+
}, this);
51+
5152
this._exclude = (config.exclude || []).map(function(pattern) {
5253
return new minimatch.Minimatch(pattern);
5354
});
@@ -151,7 +152,7 @@ Comb.prototype = {
151152
},
152153

153154
/**
154-
* Processs directory or file.
155+
* Process directory or file.
155156
*
156157
* @param {String} path
157158
*/
@@ -177,7 +178,7 @@ Comb.prototype = {
177178
},
178179

179180
/**
180-
* Returns true if specified path is not in exluded list.
181+
* Returns true if specified path is not in excluded list.
181182
*
182183
* @returns {Boolean}
183184
*/

lib/options/combinator-space.js

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
module.exports = {
2+
3+
/**
4+
* Sets handler value.
5+
*
6+
* @param {String|Boolean|Array} value Option value
7+
* @returns {Object}
8+
*/
9+
setValue: function(value) {
10+
this._value = false;
11+
if (value === true) value = ' ';
12+
if (value === false) value = '';
13+
if (typeof value === 'string' && value.match(/^[ \t\n]*$/)) {
14+
this._value = [value, value];
15+
}
16+
if (value.constructor === Array) this._value = value;
17+
if (!this._value) return;
18+
return this;
19+
},
20+
21+
/**
22+
* Processes tree node.
23+
* @param {String} nodeType
24+
* @param {node} node
25+
*/
26+
process: function(nodeType, node) {
27+
if (nodeType === 'selector') {
28+
for (var i = node.length; i--;) {
29+
var subSelector = node[i];
30+
for (var j = subSelector.length; j--;) {
31+
if (subSelector[j][0] === 'combinator') {
32+
// Working with the whitespace after the combinator
33+
if (subSelector[j + 1][0] === 's') {
34+
subSelector[j + 1][1] = this._value[1];
35+
} else {
36+
subSelector.splice(j + 1, 0, ['s', this._value[1]]);
37+
}
38+
// Working with the whitespace before the combinator
39+
if (subSelector[j - 1][0] === 's') {
40+
subSelector[j - 1][1] = this._value[0];
41+
} else {
42+
subSelector.splice(j, 0, ['s', this._value[0]]);
43+
}
44+
}
45+
}
46+
}
47+
}
48+
}
49+
50+
};

logo.png

4.15 KB
Loading

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "csscomb",
3-
"description": "Tool for beautify CSS",
4-
"version": "0.0.11",
3+
"description": "CSS coding style formatter",
4+
"version": "0.0.12",
55
"homepage": "http://csscomb.com/",
66
"author": "Mikhail Troshev <mishanga@yandex-team.ru>",
77
"repository": "https://github.com/csscomb/csscomb.js",

0 commit comments

Comments
 (0)