Skip to content

Commit 8b67eaf

Browse files
committed
Gonzales 3.0: Update space-after-opening-brace
1 parent ebc032f commit 8b67eaf

2 files changed

Lines changed: 15 additions & 13 deletions

File tree

lib/options/space-after-opening-brace.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
var gonzales = require('gonzales-pe');
2+
13
module.exports = {
24
name: 'space-after-opening-brace',
35

@@ -13,19 +15,19 @@ module.exports = {
1315
/**
1416
* Processes tree node.
1517
*
16-
* @param {String} nodeType
1718
* @param {node} node
1819
*/
19-
process: function(nodeType, node) {
20+
process: function(node) {
2021
// If found block node stop at the next one for space check
21-
if (nodeType !== 'block' && nodeType !== 'atrulers') return;
22+
if (!node.is('block') && !node.is('atrulers')) return;
2223

2324
var value = this.getValue('space-after-opening-brace');
2425

25-
if (node[0][0] === 's') {
26-
node[0][1] = value;
26+
if (node.content[0].is('s')) {
27+
node.content[0].content = value;
2728
} else if (value !== '') {
28-
node.unshift(['s', value]);
29+
var space = gonzales.createNode({ type: 's', content: value });
30+
node.content.unshift(space);
2931
}
3032
},
3133

test/options/space-after-opening-brace/test.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
describe.skip('options/space-after-opening-brace:', function() {
1+
describe('options/space-after-opening-brace:', function() {
22
it('Array value => should not change anything', function() {
33
this.comb.configure({ 'space-after-opening-brace': ['', ' '] });
44
this.shouldBeEqual('test.css');
@@ -29,47 +29,47 @@ describe.skip('options/space-after-opening-brace:', function() {
2929
this.shouldBeEqual('test.css', 'test-3.expected.css');
3030
});
3131

32-
it('Should detect no whitespace', function() {
32+
it.skip('Should detect no whitespace', function() {
3333
this.shouldDetect(
3434
['space-after-opening-brace'],
3535
'a{top:0}',
3636
{ 'space-after-opening-brace': '' }
3737
);
3838
});
3939

40-
it('Should detect whitespace', function() {
40+
it.skip('Should detect whitespace', function() {
4141
this.shouldDetect(
4242
['space-after-opening-brace'],
4343
'a{\n\ttop:0}',
4444
{ 'space-after-opening-brace': '\n\t' }
4545
);
4646
});
4747

48-
it('Should detect no whitespace (2 blocks)', function() {
48+
it.skip('Should detect no whitespace (2 blocks)', function() {
4949
this.shouldDetect(
5050
['space-after-opening-brace'],
5151
'a{top:0} b{\n left:0}',
5252
{ 'space-after-opening-brace': '' }
5353
);
5454
});
5555

56-
it('Should detect whitespace (2 blocks)', function() {
56+
it.skip('Should detect whitespace (2 blocks)', function() {
5757
this.shouldDetect(
5858
['space-after-opening-brace'],
5959
'a{ top:0 } b{left:0}',
6060
{ 'space-after-opening-brace': ' ' }
6161
);
6262
});
6363

64-
it('Should detect no whitespace (3 blocks)', function() {
64+
it.skip('Should detect no whitespace (3 blocks)', function() {
6565
this.shouldDetect(
6666
['space-after-opening-brace'],
6767
'a{top:0} b { left: 0 } c{\n\tright:0}',
6868
{ 'space-after-opening-brace': '' }
6969
);
7070
});
7171

72-
it('Should detect whitespace (3 blocks)', function() {
72+
it.skip('Should detect whitespace (3 blocks)', function() {
7373
this.shouldDetect(
7474
['space-after-opening-brace'],
7575
'a{\ntop:0} b{\nleft:0} c{\n right:0}',

0 commit comments

Comments
 (0)