diff --git a/lib/rules/trailing-semicolon.js b/lib/rules/trailing-semicolon.js index ee072e56..ed9c419f 100644 --- a/lib/rules/trailing-semicolon.js +++ b/lib/rules/trailing-semicolon.js @@ -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; } }; diff --git a/tests/rules/trailing-semicolon.js b/tests/rules/trailing-semicolon.js index 5b5410c8..34a05efe 100644 --- a/tests/rules/trailing-semicolon.js +++ b/tests/rules/trailing-semicolon.js @@ -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(); }); }); diff --git a/tests/sass/trailing-semicolon.scss b/tests/sass/trailing-semicolon.scss index 30625d4b..c92a00fa 100644 --- a/tests/sass/trailing-semicolon.scss +++ b/tests/sass/trailing-semicolon.scss @@ -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 + } + } + } +}