Skip to content

Commit bdc2d36

Browse files
committed
Fixed improper newline remover and a small codestyle fix
1 parent 5008ebc commit bdc2d36

6 files changed

Lines changed: 29 additions & 10 deletions

File tree

lib/options/block-indent.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ module.exports = {
8181
var result = null;
8282
if (nodeType === 'atrulers' || nodeType === 'block') {
8383
if (node[node.length - 1][0] === 's' && level > 0) {
84-
result = node[node.length - 1][1].replace(/\n/g, '');
84+
result = node[node.length - 1][1].replace(/\s*\n/g, '');
8585

8686
if (this._prev !== undefined && this._prev[0] < level) {
8787
result = result.replace(result.replace(this._prev[1], ''), '');

lib/options/combinator-space.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ module.exports = {
5656
detect: function(nodeType, node) {
5757
if (nodeType === 'selector') {
5858
var variants = {};
59-
var best_guess = null;
59+
var bestGuess = null;
6060
var maximum = 0;
6161
for (var i = node.length; i--;) {
6262
var subSelector = node[i];
@@ -85,13 +85,13 @@ module.exports = {
8585
}
8686
if (variants[result] > maximum) {
8787
maximum = variants[result];
88-
best_guess = result;
88+
bestGuess = result;
8989
}
9090
}
9191
}
9292
}
93-
if (best_guess) {
94-
return best_guess;
93+
if (bestGuess) {
94+
return bestGuess;
9595
}
9696
}
9797
}

lib/options/element-case.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ module.exports = {
4242
detect: function(nodeType, node) {
4343
if (nodeType === 'simpleselector') {
4444
var variants = {};
45-
var best_guess = null;
45+
var bestGuess = null;
4646
var maximum = 0;
4747
for (var i = node.length; i--;) {
4848
var nodeItem = node[i];
@@ -62,13 +62,13 @@ module.exports = {
6262
}
6363
if (variants[result] > maximum) {
6464
maximum = variants[result];
65-
best_guess = result;
65+
bestGuess = result;
6666
}
6767
}
6868
}
6969
}
70-
if (best_guess) {
71-
return best_guess;
70+
if (bestGuess) {
71+
return bestGuess;
7272
}
7373
}
7474
}

lib/options/rule-indent.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ module.exports = {
5656

5757
if (nodeType === 'declaration') {
5858
if (this._prev !== undefined) {
59-
result = this._prev.replace(/\n/g, '');
59+
result = this._prev.replace(/\s*\n/g, '');
6060
if (level > 0) {
6161
result = result.substr(0, parseInt(result.length / (level + 1), 10));
6262
}

test/block-indent.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,4 +88,13 @@ describe('options/block-indent', function() {
8888
}
8989
);
9090
});
91+
it('Should detect the block-indent option in a complex case', function() {
92+
should_detect(
93+
['block-indent'],
94+
'a { color: red \n}\n@media all {\n\t.input__control\n\t{ color: #000;\n\t\n\t\n\t\n\t}\n}',
95+
{
96+
'block-indent': '\t'
97+
}
98+
);
99+
});
91100
});

test/rule-indent.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,4 +104,14 @@ describe('options/rule-indent', function() {
104104
}
105105
);
106106
});
107+
108+
it('Should detect the rule-indent option equal to a tab with a lot of whitespaces', function() {
109+
should_detect(
110+
['rule-indent'],
111+
'a{\n\t\n\tcolor: red\n}',
112+
{
113+
'rule-indent': '\t'
114+
}
115+
);
116+
});
107117
});

0 commit comments

Comments
 (0)