Skip to content

Commit 0528cfc

Browse files
committed
Gonzales 3.0: Update space-before-colon
1 parent 010d399 commit 0528cfc

3 files changed

Lines changed: 17 additions & 15 deletions

File tree

lib/options/space-before-colon.js

Lines changed: 11 additions & 9 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-before-colon',
35

@@ -13,26 +15,26 @@ module.exports = {
1315
/**
1416
* Processes tree node.
1517
*
16-
* @param {String} nodeType
1718
* @param {node} node
1819
*/
19-
process: function(nodeType, node) {
20-
if (nodeType !== 'declaration') return;
20+
process: function(node) {
21+
if (!node.is('declaration')) return;
2122

2223
var value = this.getValue('space-before-colon');
2324

24-
for (var i = node.length; i--;) {
25-
if (node[i][0] !== 'propertyDelim') continue;
25+
for (var i = node.content.length; i--;) {
26+
if (!node.content[i].is('propertyDelim')) continue;
2627

27-
if (this.getSyntax() === 'sass' && !node[i - 1]) break;
28+
if (this.getSyntax() === 'sass' && !node.content[i - 1]) break;
2829

2930
// Remove any spaces before colon:
30-
if (node[i - 1][0] === 's') {
31-
node.splice(i - 1, 1);
31+
if (node.content[i - 1].is('s')) {
32+
node.content.splice(i - 1, 1);
3233
i--;
3334
}
3435
// If the value set in config is not empty, add spaces:
35-
if (value !== '') node.splice(i, 0, ['s', value]);
36+
var space = gonzales.createNode({ type: 's', content: value });
37+
if (value !== '') node.content.splice(i, 0, space);
3638

3739
break;
3840
}

test/options/space-before-colon-sass/test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
describe.skip('options/space-before-colon-sass:', function() {
1+
describe('options/space-before-colon-sass:', function() {
22
it('Should correct space', function() {
33
this.comb.configure({ 'space-before-colon': 1 });
44
this.shouldBeEqual('test.sass', 'test.expected.sass');

test/options/space-before-colon/test.js

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

32-
it('Should detect no whitespaces', function() {
32+
it.skip('Should detect no whitespaces', function() {
3333
this.shouldDetect(
3434
['space-before-colon'],
3535
'a { color:red }',
3636
{ 'space-before-colon': '' }
3737
);
3838
});
3939

40-
it('Should detect no space from two variants', function() {
40+
it.skip('Should detect no space from two variants', function() {
4141
this.shouldDetect(
4242
['space-before-colon'],
4343
'a { color: red; color :red }',
4444
{ 'space-before-colon': '' }
4545
);
4646
});
4747

48-
it('Should detect no whitespaces along three variants', function() {
48+
it.skip('Should detect no whitespaces along three variants', function() {
4949
this.shouldDetect(
5050
['space-before-colon'],
5151
'a { color: red; background :red } b { width:10px }',
5252
{ 'space-before-colon': '' }
5353
);
5454
});
5555

56-
it('Should detect space', function() {
56+
it.skip('Should detect space', function() {
5757
this.shouldDetect(
5858
['space-before-colon'],
5959
'a { color : red; background :red } b { width:10px }',

0 commit comments

Comments
 (0)