Skip to content

Commit 9b80f0b

Browse files
committed
stick-brace: stick closing brace with line-break
1 parent 9d34b32 commit 9b80f0b

File tree

4 files changed

+30
-32
lines changed

4 files changed

+30
-32
lines changed

lib/csscomb.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ var vfs = require('vow-fs');
1111
var Comb = function() {
1212
this._handlers;
1313
this._options = [
14+
'always-semicolon',
1415
'strip-spaces',
1516
'stick-brace',
1617
'colon-space',
17-
'always-semicolon',
1818
'rule-indent',
1919
'sort-order'
2020
];

lib/options/stick-brace.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ module.exports = {
3030
}
3131
}
3232
}
33+
34+
if (nodeType === 'block' || nodeType === 'atrulers') {
35+
if (node[node.length - 1][0] === 's') node.pop();
36+
node.push(['s', '\n']);
37+
}
3338
}
3439

3540
};

test/integral.expect.css

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ a, b, i /* foobar */
33
{
44
padding: 0;
55
margin: 0;
6-
}
6+
}
77
div p
88
{
99
font-size: 1px;
1010
top: 0;
11-
}
11+
}
1212
div p em
1313
{
1414
font-style: italic;
@@ -25,7 +25,8 @@ a, b, i /* foobar */
2525
position: relative;
2626
width: 100%;
2727
z-index: 3;
28-
}}
28+
}
29+
}
2930

3031
@media screen and (min-width: 35em) /* screen */,
3132
print and (min-width: 40em) /* print */
@@ -51,12 +52,12 @@ div
5152
{
5253
font-size: 1px;
5354
top: 0;
54-
}
55+
}
5556
div p em
5657
{
5758
font-style: italic;/* inline comment*/
5859
border-bottom: 1px solid red;
59-
}
60+
}
6061

6162
/* Фигурные скобки. Вариант 3 */
6263
div
@@ -68,20 +69,22 @@ div
6869
{
6970
font-size: 1px;
7071
top: 0;
71-
}
72+
}
7273
div p em
7374
{
7475
/* upline comment*/
7576
font-style: italic;
7677

7778
border-bottom: 1px solid red; /* trololo */ /* trololo */
78-
}
79+
}
7980

8081
a
8182
{
8283
top: 0;/* ololo */
83-
margin: 0;}
84+
margin: 0;
85+
}
8486
b
8587
{
8688
top: 0/* trololo */;
87-
margin: 0;}
89+
margin: 0;
90+
}

test/stick-brace.js

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -16,35 +16,25 @@ describe('options/stick-brace', function() {
1616
it('True Boolean value should set 1 space after brace', function() {
1717
comb.configure({ 'stick-brace': true });
1818
assert.equal(
19-
comb.processString(
20-
'a { color: red }' +
21-
'a,\nb /* i */\n{ color: red }' +
22-
'a{color:red}' +
23-
'a \t\t \n{color:red}' +
24-
'a /* foo */ {color:red}'
25-
),
26-
'a { color: red }' +
27-
'a,\nb /* i */ { color: red }' +
28-
'a {color:red}' +
29-
'a {color:red}' +
30-
'a /* foo */ {color:red}'
19+
comb.processString('a{color:red }'),
20+
'a {color:red \n}'
3121
);
3222
});
3323
it('Valid String value should set equal space after brace', function() {
3424
comb.configure({ 'stick-brace': '\n' });
3525
assert.equal(
3626
comb.processString(
37-
'a { color: red }' +
38-
'a, b /* i */ { color: red }' +
39-
'a{color:red}' +
40-
'a \t\t \n{color:red}' +
41-
'a /* foo */ {color:red}'
27+
'a{ color: red }' +
28+
'a, b /* i */ { color: red; }' +
29+
'a \t\t \n{color:red\n \n}' +
30+
'a /* foo */ {color:red ; \n \n\t}' +
31+
'@media all { .input__control { color: #000;\n \n }\t}'
4232
),
43-
'a\n{ color: red }' +
44-
'a, b /* i */\n{ color: red }' +
45-
'a\n{color:red}' +
46-
'a\n{color:red}' +
47-
'a /* foo */\n{color:red}'
33+
'a\n{ color: red \n}' +
34+
'a, b /* i */\n{ color: red;\n}' +
35+
'a\n{color:red\n \n\n}' +
36+
'a /* foo */\n{color:red ;\n}' +
37+
'@media all\n{ .input__control\n{ color: #000;\n}\n}'
4838
);
4939
});
5040
});

0 commit comments

Comments
 (0)