Skip to content

Commit

Permalink
Merge branch '852-lint-double-semi-colons' of https://github.com/Jord…
Browse files Browse the repository at this point in the history
…anDDisch/sass-lint into JordanDDisch-852-lint-double-semi-colons
  • Loading branch information
DanPurdy committed Aug 26, 2017
2 parents b5aebda + 1ec22b1 commit 5ca8e7b
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
16 changes: 16 additions & 0 deletions lib/rules/trailing-semicolon.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,21 @@ module.exports = {
'detect': function (ast, parser) {
var result = [];

var hasDoubleSemiColon = function (tree) {

tree.traverseByType('declarationDelimiter', function (node, index, parent) {
if (parent.content[index + 1].is('declarationDelimiter')) {
result = helpers.addUnique(result, {
'ruleId': parser.rule.name,
'severity': parser.severity,
'line': parent.content[index + 1].start.line,
'column': parent.content[index + 1].start.column,
'message': 'No double semicolons allowed'
});
}
});
};

if (ast.syntax !== 'sass') {
ast.traverseByType('block', function (block) {
var last,
Expand Down Expand Up @@ -53,6 +68,7 @@ module.exports = {
});
}
}
hasDoubleSemiColon(parent);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions tests/rules/trailing-semicolon.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ describe('trailing semicolon - scss', function () {
lint.test(file, {
'trailing-semicolon': 1
}, function (data) {
lint.assert.equal(5, data.warningCount);
lint.assert.equal(8, data.warningCount);
done();
});
});
Expand All @@ -26,7 +26,7 @@ describe('trailing semicolon - scss', function () {
}
]
}, function (data) {
lint.assert.equal(1, data.warningCount);
lint.assert.equal(4, data.warningCount);
done();
});
});
Expand Down
7 changes: 4 additions & 3 deletions tests/sass/trailing-semicolon.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
}

.bar {
content: 'qux';
content: 'qux';;
padding: 0

.qux {
float: left;;
content: 'waldo'
}
}
Expand All @@ -21,7 +22,7 @@

.baz {
font: {
family: 'Arial';
family: 'Arial';;
weight: bold;
size: 2rem
}
Expand All @@ -30,7 +31,7 @@
.norf {
border: {
top: {
color: red;
color: red;;

left: {
radius: 5px
Expand Down

0 comments on commit 5ca8e7b

Please sign in to comment.