Skip to content

Commit f39c12d

Browse files
committed
Fix blockless at-rule false negative warning #26
1 parent c1ae549 commit f39c12d

File tree

3 files changed

+73
-1
lines changed

3 files changed

+73
-1
lines changed

rules/order/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ function createExpectedOrder(input) {
244244
}
245245
}
246246

247-
if (item.hasBlock) {
247+
if (!_.isUndefined(item.hasBlock)) {
248248
nodeData.hasBlock = item.hasBlock;
249249
}
250250

rules/order/tests/index.js

+68
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,74 @@ testRule(rule, {
350350
],
351351
});
352352

353+
testRule(rule, {
354+
ruleName,
355+
config: [[
356+
{
357+
type: 'at-rule',
358+
hasBlock: false,
359+
},
360+
'declarations',
361+
]],
362+
363+
accept: [
364+
{
365+
code: `
366+
a {
367+
@include hello;
368+
@include hello {
369+
display: block;
370+
}
371+
display: none;
372+
}
373+
`,
374+
},
375+
{
376+
code: `
377+
a {
378+
@include hello {
379+
display: block;
380+
}
381+
@include hello;
382+
display: none;
383+
}
384+
`,
385+
},
386+
{
387+
code: `
388+
a {
389+
@include hello;
390+
display: none;
391+
@include hello {
392+
display: block;
393+
}
394+
}
395+
`,
396+
},
397+
{
398+
code: `
399+
a {
400+
display: none;
401+
@include hello {
402+
display: block;
403+
}
404+
}
405+
`,
406+
},
407+
],
408+
409+
reject: [
410+
{
411+
code: `
412+
a {
413+
display: none;
414+
@include hello;
415+
}
416+
`,
417+
},
418+
],
419+
});
420+
353421
testRule(rule, {
354422
ruleName,
355423
config: [[

rules/order/tests/validate-options.js

+4
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ testConfig({
3535
type: 'at-rule',
3636
hasBlock: true,
3737
},
38+
{
39+
type: 'at-rule',
40+
hasBlock: false,
41+
},
3842
{
3943
type: 'at-rule',
4044
},

0 commit comments

Comments
 (0)