Skip to content

Commit

Permalink
🐛 ignore interpolation in class-name-format
Browse files Browse the repository at this point in the history
  • Loading branch information
DanPurdy committed Sep 2, 2017
1 parent ca0690b commit 6c8f13f
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 17 deletions.
5 changes: 4 additions & 1 deletion lib/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,10 @@ helpers.attemptTraversal = function (node, traversalPath) {
currentNodeList = [],
processChildNode = function processChildNode (child) {
child.forEach(traversalPath[i], function (n) {
nextNodeList.push(n);
if (n.content && n.content.some && n.contains('interpolation')) {
return false;
}
return nextNodeList.push(n);
});
};

Expand Down
32 changes: 16 additions & 16 deletions tests/rules/class-name-format.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ describe('class name format - scss', function () {
lint.test(file, {
'class-name-format': 1
}, function (data) {
lint.assert.equal(31, data.warningCount);
lint.assert.equal(33, data.warningCount);
done();
});
});
Expand All @@ -26,7 +26,7 @@ describe('class name format - scss', function () {
}
]
}, function (data) {
lint.assert.equal(30, data.warningCount);
lint.assert.equal(32, data.warningCount);
done();
});
});
Expand All @@ -40,7 +40,7 @@ describe('class name format - scss', function () {
}
]
}, function (data) {
lint.assert.equal(40, data.warningCount);
lint.assert.equal(42, data.warningCount);
done();
});
});
Expand All @@ -54,7 +54,7 @@ describe('class name format - scss', function () {
}
]
}, function (data) {
lint.assert.equal(40, data.warningCount);
lint.assert.equal(43, data.warningCount);
done();
});
});
Expand All @@ -68,7 +68,7 @@ describe('class name format - scss', function () {
}
]
}, function (data) {
lint.assert.equal(36, data.warningCount);
lint.assert.equal(37, data.warningCount);
done();
});
});
Expand All @@ -82,7 +82,7 @@ describe('class name format - scss', function () {
}
]
}, function (data) {
lint.assert.equal(17, data.warningCount);
lint.assert.equal(18, data.warningCount);
done();
});
});
Expand Down Expand Up @@ -110,7 +110,7 @@ describe('class name format - scss', function () {
}
]
}, function (data) {
lint.assert.equal(42, data.warningCount);
lint.assert.equal(45, data.warningCount);
done();
});
});
Expand All @@ -126,7 +126,7 @@ describe('class name format - scss', function () {
}
]
}, function (data) {
lint.assert.equal(38, data.warningCount);
lint.assert.equal(41, data.warningCount);
lint.assert.equal(data.messages[0].message, message);
done();
});
Expand All @@ -143,7 +143,7 @@ describe('class name format - sass', function () {
lint.test(file, {
'class-name-format': 1
}, function (data) {
lint.assert.equal(31, data.warningCount);
lint.assert.equal(33, data.warningCount);
done();
});
});
Expand All @@ -157,7 +157,7 @@ describe('class name format - sass', function () {
}
]
}, function (data) {
lint.assert.equal(30, data.warningCount);
lint.assert.equal(32, data.warningCount);
done();
});
});
Expand All @@ -171,7 +171,7 @@ describe('class name format - sass', function () {
}
]
}, function (data) {
lint.assert.equal(40, data.warningCount);
lint.assert.equal(42, data.warningCount);
done();
});
});
Expand All @@ -185,7 +185,7 @@ describe('class name format - sass', function () {
}
]
}, function (data) {
lint.assert.equal(40, data.warningCount);
lint.assert.equal(43, data.warningCount);
done();
});
});
Expand All @@ -199,7 +199,7 @@ describe('class name format - sass', function () {
}
]
}, function (data) {
lint.assert.equal(36, data.warningCount);
lint.assert.equal(37, data.warningCount);
done();
});
});
Expand All @@ -213,7 +213,7 @@ describe('class name format - sass', function () {
}
]
}, function (data) {
lint.assert.equal(17, data.warningCount);
lint.assert.equal(18, data.warningCount);
done();
});
});
Expand Down Expand Up @@ -241,7 +241,7 @@ describe('class name format - sass', function () {
}
]
}, function (data) {
lint.assert.equal(42, data.warningCount);
lint.assert.equal(45, data.warningCount);
done();
});
});
Expand All @@ -257,7 +257,7 @@ describe('class name format - sass', function () {
}
]
}, function (data) {
lint.assert.equal(38, data.warningCount);
lint.assert.equal(41, data.warningCount);
lint.assert.equal(data.messages[0].message, message);
done();
});
Expand Down
17 changes: 17 additions & 0 deletions tests/sass/class-name-format.sass
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,20 @@

.strict-bem__elem_key--fail
color: red


// Issue #988 - Fix interpolation in class names
.#{$primary-class}--small
color: red

&__child
color: red

.test
&#{$primary-class}
color: red

&__block
&--mod
color: blue
21 changes: 21 additions & 0 deletions tests/sass/class-name-format.scss
Original file line number Diff line number Diff line change
Expand Up @@ -133,3 +133,24 @@
.strict-bem__elem_key--fail {
color: red;
}

// Issue #988 - Fix interpolation in class names

.#{$primary-class}--small {
color: red;
&__child {
color: red;
}
}

.test {
&#{$primary-class} {
color: red;
}

&__block {
&--mod {
color: blue;
}
}
}

0 comments on commit 6c8f13f

Please sign in to comment.