Skip to content

Commit f44a216

Browse files
authored
Merge pull request #1131 from sasstools/feature/ignore-interpolation-class-names
Feature/ignore interpolation class names
2 parents 72f4cad + 24ef9ba commit f44a216

File tree

4 files changed

+58
-17
lines changed

4 files changed

+58
-17
lines changed

lib/helpers.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,10 @@ helpers.attemptTraversal = function (node, traversalPath) {
309309
currentNodeList = [],
310310
processChildNode = function processChildNode (child) {
311311
child.forEach(traversalPath[i], function (n) {
312-
nextNodeList.push(n);
312+
if (n.content && typeof n.content !== 'string' && n.contains('interpolation')) {
313+
return false;
314+
}
315+
return nextNodeList.push(n);
313316
});
314317
};
315318

tests/rules/class-name-format.js

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ describe('class name format - scss', function () {
1212
lint.test(file, {
1313
'class-name-format': 1
1414
}, function (data) {
15-
lint.assert.equal(31, data.warningCount);
15+
lint.assert.equal(33, data.warningCount);
1616
done();
1717
});
1818
});
@@ -26,7 +26,7 @@ describe('class name format - scss', function () {
2626
}
2727
]
2828
}, function (data) {
29-
lint.assert.equal(30, data.warningCount);
29+
lint.assert.equal(32, data.warningCount);
3030
done();
3131
});
3232
});
@@ -40,7 +40,7 @@ describe('class name format - scss', function () {
4040
}
4141
]
4242
}, function (data) {
43-
lint.assert.equal(40, data.warningCount);
43+
lint.assert.equal(42, data.warningCount);
4444
done();
4545
});
4646
});
@@ -54,7 +54,7 @@ describe('class name format - scss', function () {
5454
}
5555
]
5656
}, function (data) {
57-
lint.assert.equal(40, data.warningCount);
57+
lint.assert.equal(43, data.warningCount);
5858
done();
5959
});
6060
});
@@ -68,7 +68,7 @@ describe('class name format - scss', function () {
6868
}
6969
]
7070
}, function (data) {
71-
lint.assert.equal(36, data.warningCount);
71+
lint.assert.equal(37, data.warningCount);
7272
done();
7373
});
7474
});
@@ -82,7 +82,7 @@ describe('class name format - scss', function () {
8282
}
8383
]
8484
}, function (data) {
85-
lint.assert.equal(17, data.warningCount);
85+
lint.assert.equal(18, data.warningCount);
8686
done();
8787
});
8888
});
@@ -110,7 +110,7 @@ describe('class name format - scss', function () {
110110
}
111111
]
112112
}, function (data) {
113-
lint.assert.equal(42, data.warningCount);
113+
lint.assert.equal(45, data.warningCount);
114114
done();
115115
});
116116
});
@@ -126,7 +126,7 @@ describe('class name format - scss', function () {
126126
}
127127
]
128128
}, function (data) {
129-
lint.assert.equal(38, data.warningCount);
129+
lint.assert.equal(41, data.warningCount);
130130
lint.assert.equal(data.messages[0].message, message);
131131
done();
132132
});
@@ -143,7 +143,7 @@ describe('class name format - sass', function () {
143143
lint.test(file, {
144144
'class-name-format': 1
145145
}, function (data) {
146-
lint.assert.equal(31, data.warningCount);
146+
lint.assert.equal(33, data.warningCount);
147147
done();
148148
});
149149
});
@@ -157,7 +157,7 @@ describe('class name format - sass', function () {
157157
}
158158
]
159159
}, function (data) {
160-
lint.assert.equal(30, data.warningCount);
160+
lint.assert.equal(32, data.warningCount);
161161
done();
162162
});
163163
});
@@ -171,7 +171,7 @@ describe('class name format - sass', function () {
171171
}
172172
]
173173
}, function (data) {
174-
lint.assert.equal(40, data.warningCount);
174+
lint.assert.equal(42, data.warningCount);
175175
done();
176176
});
177177
});
@@ -185,7 +185,7 @@ describe('class name format - sass', function () {
185185
}
186186
]
187187
}, function (data) {
188-
lint.assert.equal(40, data.warningCount);
188+
lint.assert.equal(43, data.warningCount);
189189
done();
190190
});
191191
});
@@ -199,7 +199,7 @@ describe('class name format - sass', function () {
199199
}
200200
]
201201
}, function (data) {
202-
lint.assert.equal(36, data.warningCount);
202+
lint.assert.equal(37, data.warningCount);
203203
done();
204204
});
205205
});
@@ -213,7 +213,7 @@ describe('class name format - sass', function () {
213213
}
214214
]
215215
}, function (data) {
216-
lint.assert.equal(17, data.warningCount);
216+
lint.assert.equal(18, data.warningCount);
217217
done();
218218
});
219219
});
@@ -241,7 +241,7 @@ describe('class name format - sass', function () {
241241
}
242242
]
243243
}, function (data) {
244-
lint.assert.equal(42, data.warningCount);
244+
lint.assert.equal(45, data.warningCount);
245245
done();
246246
});
247247
});
@@ -257,7 +257,7 @@ describe('class name format - sass', function () {
257257
}
258258
]
259259
}, function (data) {
260-
lint.assert.equal(38, data.warningCount);
260+
lint.assert.equal(41, data.warningCount);
261261
lint.assert.equal(data.messages[0].message, message);
262262
done();
263263
});

tests/sass/class-name-format.sass

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,3 +94,20 @@
9494

9595
.strict-bem__elem_key--fail
9696
color: red
97+
98+
99+
// Issue #988 - Fix interpolation in class names
100+
101+
.#{$primary-class}--small
102+
color: red
103+
104+
&__child
105+
color: red
106+
107+
.test
108+
&#{$primary-class}
109+
color: red
110+
111+
&__block
112+
&--mod
113+
color: blue

tests/sass/class-name-format.scss

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,3 +133,24 @@
133133
.strict-bem__elem_key--fail {
134134
color: red;
135135
}
136+
137+
// Issue #988 - Fix interpolation in class names
138+
139+
.#{$primary-class}--small {
140+
color: red;
141+
&__child {
142+
color: red;
143+
}
144+
}
145+
146+
.test {
147+
&#{$primary-class} {
148+
color: red;
149+
}
150+
151+
&__block {
152+
&--mod {
153+
color: blue;
154+
}
155+
}
156+
}

0 commit comments

Comments
 (0)