Skip to content

Commit

Permalink
🐛 Fix at-root in space after colon
Browse files Browse the repository at this point in the history
  • Loading branch information
DanPurdy committed Sep 2, 2017
1 parent 658f4c4 commit 94ad31e
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 24 deletions.
45 changes: 23 additions & 22 deletions lib/rules/space-after-colon.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,29 +11,30 @@ module.exports = {
var result = [];

ast.traverseByTypes(['propertyDelimiter', 'operator'], function (delimiter, i, parent) {
if (delimiter.content === ':') {
var next = parent.content[i + 1];

if (next && next.is('space')) {
if (!parser.options.include) {
result = helpers.addUnique(result, {
'ruleId': parser.rule.name,
'line': next.start.line,
'column': next.start.column,
'message': 'No space allowed after `:`',
'severity': parser.severity
});
if (!parent.is('atrule')) {
if (delimiter.content === ':') {
var next = parent.content[i + 1];
if (next && next.is('space')) {
if (!parser.options.include) {
result = helpers.addUnique(result, {
'ruleId': parser.rule.name,
'line': next.start.line,
'column': next.start.column,
'message': 'No space allowed after `:`',
'severity': parser.severity
});
}
}
}
else {
if (parser.options.include) {
result = helpers.addUnique(result, {
'ruleId': parser.rule.name,
'line': delimiter.start.line,
'column': delimiter.start.column,
'message': 'Space expected after `:`',
'severity': parser.severity
});
else {
if (parser.options.include) {
result = helpers.addUnique(result, {
'ruleId': parser.rule.name,
'line': delimiter.start.line,
'column': delimiter.start.column,
'message': 'Space expected after `:`',
'severity': parser.severity
});
}
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions tests/rules/space-after-colon.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ describe('space after colon - scss', function () {
lint.test(file, {
'space-after-colon': 1
}, function (data) {
lint.assert.equal(3, data.warningCount);
lint.assert.equal(4, data.warningCount);
done();
});
});
Expand All @@ -26,7 +26,7 @@ describe('space after colon - scss', function () {
}
]
}, function (data) {
lint.assert.equal(4, data.warningCount);
lint.assert.equal(6, data.warningCount);
done();
});
});
Expand Down
6 changes: 6 additions & 0 deletions tests/sass/space-after-colon.sass
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,9 @@

$qux: 'qux'
$norf:'norf'

.foo
@at-root button#{&}:hover

.foo:hover
+test
14 changes: 14 additions & 0 deletions tests/sass/space-after-colon.scss
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,17 @@

$qux: 'qux';
$norf:'norf';

.foo {
@at-root button#{&}:hover {
}
}

.foo:hover {
@include test;
}

$map: {
test:'red',
other: blue,
}

0 comments on commit 94ad31e

Please sign in to comment.