Skip to content

Commit

Permalink
Merge pull request sasstools#189 from bgriffith/hotfix/issue-with-ext…
Browse files Browse the repository at this point in the history
…end-rules-sass-syntax

Hotfix master - with extend rules sass syntax
  • Loading branch information
DanPurdy committed Sep 19, 2015
2 parents 4d90b0c + 99e96ea commit 3d1706c
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions lib/rules/extends-before-declarations.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,25 @@ module.exports = {

ast.traverseByType('block', function (block) {
var lastDeclaration = null;
block.traverse(function (item, j) {
if (item.type === 'extend') {
if (j > lastDeclaration && lastDeclaration !== null) {
item.forEach('simpleSelector', function () {
error = {
'ruleId': parser.rule.name,
'line': item.start.line,
'column': item.start.column,
'message': 'Extends should come before declarations',
'severity': parser.severity
};
result = helpers.addUnique(result, error);
});

block.forEach(function (item, j) {
if (item.type === 'include' || item.type === 'extend') {
if (item.first('atkeyword').first('ident').content === 'extend') {
if (j > lastDeclaration && lastDeclaration !== null) {
item.forEach('simpleSelector', function () {
error = {
'ruleId': parser.rule.name,
'line': item.start.line,
'column': item.start.column,
'message': 'Extends should come before declarations',
'severity': parser.severity
};
result = helpers.addUnique(result, error);
});
}
}
}

if (item.type === 'declaration') {
lastDeclaration = j;
}
Expand Down

0 comments on commit 3d1706c

Please sign in to comment.