Skip to content

Commit 66c1baa

Browse files
committed
fix line and column numbers for compatible vendor prefixes rule (fixes #236)
1 parent 151a0eb commit 66c1baa

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

src/rules/compatible-vendor-prefixes.js

+10-8
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,8 @@ CSSLint.addRule({
102102
});
103103

104104
parser.addListener("property", function (event) {
105-
var name = event.property.text;
106-
if (CSSLint.Util.indexOf(applyTo, name) > -1) {
105+
var name = event.property;
106+
if (CSSLint.Util.indexOf(applyTo, name.text) > -1) {
107107
properties.push(name);
108108
}
109109
});
@@ -131,15 +131,17 @@ CSSLint.addRule({
131131
for (prop in compatiblePrefixes) {
132132
if (compatiblePrefixes.hasOwnProperty(prop)) {
133133
variations = compatiblePrefixes[prop];
134-
if (CSSLint.Util.indexOf(variations, name) > -1) {
135-
if (propertyGroups[prop] === undefined) {
134+
if (CSSLint.Util.indexOf(variations, name.text) > -1) {
135+
if (!propertyGroups[prop]) {
136136
propertyGroups[prop] = {
137137
full : variations.slice(0),
138-
actual : []
138+
actual : [],
139+
actualNodes: []
139140
};
140141
}
141-
if (CSSLint.Util.indexOf(propertyGroups[prop].actual, name) === -1) {
142-
propertyGroups[prop].actual.push(name);
142+
if (CSSLint.Util.indexOf(propertyGroups[prop].actual, name.text) === -1) {
143+
propertyGroups[prop].actual.push(name.text);
144+
propertyGroups[prop].actualNodes.push(name);
143145
}
144146
}
145147
}
@@ -157,7 +159,7 @@ CSSLint.addRule({
157159
item = full[i];
158160
if (CSSLint.Util.indexOf(actual, item) === -1) {
159161
propertiesSpecified = (actual.length === 1) ? actual[0] : (actual.length == 2) ? actual.join(" and ") : actual.join(", ");
160-
reporter.report("The property " + item + " is compatible with " + propertiesSpecified + " and should be included as well.", event.selectors[0].line, event.selectors[0].col, rule);
162+
reporter.report("The property " + item + " is compatible with " + propertiesSpecified + " and should be included as well.", value.actualNodes[0].line, value.actualNodes[0].col, rule);
161163
}
162164
}
163165

tests/rules/compatible-vendor-prefixes.js

+7
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,22 @@
1212
Assert.areEqual(1, result.messages.length);
1313
Assert.areEqual("warning", result.messages[0].type);
1414
Assert.areEqual("The property -moz-border-radius is compatible with -webkit-border-radius and should be included as well.", result.messages[0].message);
15+
Assert.areEqual(6, result.messages[0].col);
16+
Assert.areEqual(1, result.messages[0].line);
1517
},
1618

1719
"Using -webkit-transition and -moz-transition should warn to also include -o-transition and -ms-transition.": function(){
1820
var result = CSSLint.verify("h1 { -webkit-transition: height 20px 1s; -moz-transition: height 20px 1s; }", { "compatible-vendor-prefixes": 1 });
1921
Assert.areEqual(2, result.messages.length);
2022
Assert.areEqual("warning", result.messages[0].type);
2123
Assert.areEqual("The property -o-transition is compatible with -webkit-transition and -moz-transition and should be included as well.", result.messages[0].message);
24+
Assert.areEqual(6, result.messages[0].col);
25+
Assert.areEqual(1, result.messages[0].line);
2226
Assert.areEqual("warning", result.messages[1].type);
2327
Assert.areEqual("The property -ms-transition is compatible with -webkit-transition and -moz-transition and should be included as well.", result.messages[1].message);
28+
Assert.areEqual(6, result.messages[1].col);
29+
Assert.areEqual(1, result.messages[1].line);
30+
2431
},
2532

2633
"Using -webkit-transform should warn to also include -moz-transform, -ms-transform, and -o-transform.": function(){

0 commit comments

Comments
 (0)