Skip to content

Commit 2a75bf9

Browse files
committed
Order Aphabetical: Add listeners for at-rules
Viewport was completely missing, but the others were also not reporting at the end of the rule scope
1 parent 2174e86 commit 2a75bf9

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

src/rules/order-alphabetical.js

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,21 @@ CSSLint.addRule({
2020
properties = [];
2121
};
2222

23+
var endRule = function(event){
24+
var currentProperties = properties.join(","),
25+
expectedProperties = properties.sort().join(",");
26+
27+
if (currentProperties !== expectedProperties){
28+
reporter.report("Rule doesn't have all its properties in alphabetical ordered.", event.line, event.col, rule);
29+
}
30+
};
31+
2332
parser.addListener("startrule", startRule);
2433
parser.addListener("startfontface", startRule);
2534
parser.addListener("startpage", startRule);
2635
parser.addListener("startpagemargin", startRule);
2736
parser.addListener("startkeyframerule", startRule);
37+
parser.addListener("startviewport", startRule);
2838

2939
parser.addListener("property", function(event){
3040
var name = event.property.text,
@@ -33,14 +43,12 @@ CSSLint.addRule({
3343
properties.push(lowerCasePrefixLessName);
3444
});
3545

36-
parser.addListener("endrule", function(event){
37-
var currentProperties = properties.join(","),
38-
expectedProperties = properties.sort().join(",");
39-
40-
if (currentProperties !== expectedProperties){
41-
reporter.report("Rule doesn't have all its properties in alphabetical ordered.", event.line, event.col, rule);
42-
}
43-
});
46+
parser.addListener("endrule", endRule);
47+
parser.addListener("endfontface", endRule);
48+
parser.addListener("endpage", endRule);
49+
parser.addListener("endpagemargin", endRule);
50+
parser.addListener("endkeyframerule", endRule);
51+
parser.addListener("endviewport", endRule);
4452
}
4553

4654
});

0 commit comments

Comments
 (0)