Skip to content

Commit

Permalink
Merge pull request #359 from bgriffith/hotfix/fix-property-nesting
Browse files Browse the repository at this point in the history
Hotfix master - Fix trailing-semicolon issue with nested properties
  • Loading branch information
DanPurdy committed Oct 28, 2015
2 parents d705fe5 + bb223f8 commit d653c97
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 28 deletions.
56 changes: 31 additions & 25 deletions lib/rules/trailing-semicolon.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,38 +23,44 @@ module.exports = {
}

block.forEach('declaration', function (item, i, parent) {
if (helpers.isEqual(last, item)) {
next = parent.content[i + 1];

if (next.type === 'declarationDelimiter') {
if (!parser.options.include) {
result = helpers.addUnique(result, {
'ruleId': parser.rule.name,
'severity': parser.severity,
'line': item.end.line,
'column': item.end.column,
'message': 'No trailing semicolons allowed'
});
}
}
else {
if (parser.options.include) {
result = helpers.addUnique(result, {
'ruleId': parser.rule.name,
'severity': parser.severity,
'line': item.last('value').start.line,
'column': item.last('value').start.column,
'message': 'Trailing semicolons required'
});
if (item.contains('value')) {
var valueNode = item.last('value').content[0];

if (!valueNode.is('block')) {
if (helpers.isEqual(last, item)) {
if (parent.content[i + 1]) {
next = parent.content[i + 1];

if (next.is('declarationDelimiter')) {
if (!parser.options.include) {
result = helpers.addUnique(result, {
'ruleId': parser.rule.name,
'severity': parser.severity,
'line': item.end.line,
'column': item.end.column,
'message': 'No trailing semicolons allowed'
});
}
}
else {
if (parser.options.include) {
result = helpers.addUnique(result, {
'ruleId': parser.rule.name,
'severity': parser.severity,
'line': item.last('value').start.line,
'column': item.last('value').start.column,
'message': 'Trailing semicolons required'
});
}
}
}
}
}
}

});
});
}


return result;
}
};
16 changes: 15 additions & 1 deletion tests/rules/trailing-semicolon.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,21 @@ describe('trailing semicolon - scss', function () {
lint.test(file, {
'trailing-semicolon': 1
}, function (data) {
lint.assert.equal(2, data.warningCount);
lint.assert.equal(5, data.warningCount);
done();
});
});

it('[include: false]', function (done) {
lint.test(file, {
'trailing-semicolon': [
1,
{
'include': false
}
]
}, function (data) {
lint.assert.equal(1, data.warningCount);
done();
});
});
Expand Down
32 changes: 30 additions & 2 deletions tests/sass/trailing-semicolon.scss
Original file line number Diff line number Diff line change
@@ -1,12 +1,40 @@
.foo {
content: 'bar';
content: 'bar'
}

.bar {
content: 'qux';
content: 'baz', 'fail'
padding: 0

.qux {
content: 'waldo'
}
}

.qux {
font: {
family: 'Arial';
weight: bold;
size: 2rem;
}
}

.baz {
font: {
family: 'Arial';
weight: bold;
size: 2rem
}
}

.norf {
border: {
top: {
color: red;

left: {
radius: 5px
}
}
}
}

0 comments on commit d653c97

Please sign in to comment.