Skip to content

Commit

Permalink
Merge pull request #203 from bgriffith/hotfix/fix-sass-extend-before-…
Browse files Browse the repository at this point in the history
…mixin-master

Hotfix master - Fix Sass extends-before-mixins bug
  • Loading branch information
DanPurdy committed Sep 22, 2015
2 parents 152c95b + 9f3c423 commit 97403b4
Showing 1 changed file with 23 additions and 10 deletions.
33 changes: 23 additions & 10 deletions lib/rules/extends-before-mixins.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,35 @@ module.exports = {

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

block.forEach(function (item, j) {
if (item.type === 'include' || item.type === 'extend') {
if (item.first('atkeyword')) {
var atkeyword = item.first('atkeyword');

if (atkeyword.first('ident')) {
var ident = atkeyword.first('ident');

if (ident.content === 'extend') {
if (j > lastMixin && lastMixin !== null) {
result = helpers.addUnique(result, {
'ruleId': parser.rule.name,
'line': item.start.line,
'column': item.start.column,
'message': 'Extends should come before mixins',
'severity': parser.severity
});
}
}
}
}
}

if (item.type === 'include') {
lastMixin = j;
}
});

lastMixin = null;
});

Expand Down

0 comments on commit 97403b4

Please sign in to comment.