Skip to content

Commit c15f49a

Browse files
committed
Minor lint tweaks.
1 parent dadda82 commit c15f49a

22 files changed

+304
-210
lines changed

dist/cli.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env node
22
/*!
3-
CSSLint v0.10.0
3+
CSSLint v1.0.0
44
Copyright (c) 2016 Nicole Sullivan and Nicholas C. Zakas. All rights reserved.
55
66
Permission is hereby granted, free of charge, to any person obtaining a copy

dist/csslint-node.js

Lines changed: 49 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
CSSLint v0.10.0
2+
CSSLint v1.0.0
33
Copyright (c) 2016 Nicole Sullivan and Nicholas C. Zakas. All rights reserved.
44
55
Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -41,7 +41,7 @@ var CSSLint = (function() {
4141
embeddedRuleset = /\/\*\s*csslint([^\*]*)\*\//,
4242
api = new parserlib.util.EventTarget();
4343

44-
api.version = "0.10.0";
44+
api.version = "1.0.0";
4545

4646
//-------------------------------------------------------------------------
4747
// Rule Management
@@ -205,8 +205,12 @@ var CSSLint = (function() {
205205
allow = {},
206206
ignore = [],
207207
report,
208-
parser = new parserlib.css.Parser({ starHack: true, ieFilters: true,
209-
underscoreHack: true, strict: false });
208+
parser = new parserlib.css.Parser({
209+
starHack: true,
210+
ieFilters: true,
211+
underscoreHack: true,
212+
strict: false
213+
});
210214

211215
// normalize line endings
212216
lines = text.replace(/\n\r?/g, "$split$").split("$split$");
@@ -231,22 +235,22 @@ var CSSLint = (function() {
231235
ignoreEnd = null;
232236
CSSLint.Util.forEach(lines, function (line, lineno) {
233237
// Keep oldest, "unclosest" ignore:start
234-
if (null === ignoreStart && line.match(/\/\*[ \t]*csslint[ \t]+ignore:start[ \t]*\*\//i)) {
238+
if (ignoreStart === null && line.match(/\/\*[ \t]*csslint[ \t]+ignore:start[ \t]*\*\//i)) {
235239
ignoreStart = lineno;
236240
}
237241

238242
if (line.match(/\/\*[ \t]*csslint[ \t]+ignore:end[ \t]*\*\//i)) {
239243
ignoreEnd = lineno;
240244
}
241245

242-
if (null !== ignoreStart && null !== ignoreEnd) {
246+
if (ignoreStart !== null && ignoreEnd !== null) {
243247
ignore.push([ignoreStart, ignoreEnd]);
244248
ignoreStart = ignoreEnd = null;
245249
}
246250
});
247251

248252
// Close remaining ignore block, if any
249-
if (null !== ignoreStart) {
253+
if (ignoreStart !== null) {
250254
ignore.push([ignoreStart, lines.length]);
251255
}
252256

@@ -709,7 +713,11 @@ CSSLint.addRule({
709713

710714
if (heightProperties[name] || widthProperties[name]) {
711715
if (!/^0\S*$/.test(event.value) && !(name === "border" && event.value.toString() === "none")) {
712-
properties[name] = { line: event.property.line, col: event.property.col, value: event.value };
716+
properties[name] = {
717+
line: event.property.line,
718+
col: event.property.col,
719+
value: event.value
720+
};
713721
}
714722
} else {
715723
if (/^(width|height)/i.test(name) && /^(length|percentage)/.test(event.value.parts[0].type)) {
@@ -982,8 +990,8 @@ CSSLint.addRule({
982990
if (CSSLint.Util.indexOf(variations, name.text) > -1) {
983991
if (!propertyGroups[prop]) {
984992
propertyGroups[prop] = {
985-
full : variations.slice(0),
986-
actual : [],
993+
full: variations.slice(0),
994+
actual: [],
987995
actualNodes: []
988996
};
989997
}
@@ -1125,7 +1133,11 @@ CSSLint.addRule({
11251133
var name = event.property.text.toLowerCase();
11261134

11271135
if (propertiesToCheck[name]) {
1128-
properties[name] = { value: event.value.text, line: event.property.line, col: event.property.col };
1136+
properties[name] = {
1137+
value: event.value.text,
1138+
line: event.property.line,
1139+
col: event.property.col
1140+
};
11291141
}
11301142
});
11311143

@@ -1169,8 +1181,7 @@ CSSLint.addRule({
11691181
if (value.parts[i].type === "uri") {
11701182
if (typeof stack[value.parts[i].uri] === "undefined") {
11711183
stack[value.parts[i].uri] = event;
1172-
}
1173-
else {
1184+
} else {
11741185
reporter.report("Background image '" + value.parts[i].uri + "' was used multiple times, first declared at line " + stack[value.parts[i].uri].line + ", col " + stack[value.parts[i].uri].col + ".", event.line, event.col, rule);
11751186
}
11761187
}
@@ -1320,11 +1331,9 @@ CSSLint.addRule({
13201331
"border-bottom": 1,
13211332
"border-left": 1,
13221333
"background-color": 1
1323-
},
1324-
properties;
1334+
};
13251335

13261336
function startRule() {
1327-
properties = {};
13281337
lastProperty = null;
13291338
}
13301339

@@ -1914,7 +1923,10 @@ CSSLint.addRule({
19141923
if (!classes[modifier]) {
19151924
classes[modifier] = [];
19161925
}
1917-
classes[modifier].push({ modifier: modifier, part: part });
1926+
classes[modifier].push({
1927+
modifier: modifier,
1928+
part: part
1929+
});
19181930
}
19191931
}
19201932
}
@@ -2013,7 +2025,7 @@ CSSLint.addRule({
20132025
for (k=0; k < part.modifiers.length; k++) {
20142026
modifier = part.modifiers[k];
20152027
if (modifier.type === "attribute") {
2016-
if (/([\~\|\^\$\*]=)/.test(modifier)) {
2028+
if (/([~\|\^\$\*]=)/.test(modifier)) {
20172029
reporter.report("Attribute selectors with " + RegExp.$1 + " are slow!", modifier.line, modifier.col, rule);
20182030
}
20192031
}
@@ -2604,18 +2616,18 @@ CSSLint.addRule({
26042616
"-moz-box-shadow": "box-shadow",
26052617
"-webkit-box-shadow": "box-shadow",
26062618

2607-
"-moz-transform" : "transform",
2608-
"-webkit-transform" : "transform",
2609-
"-o-transform" : "transform",
2610-
"-ms-transform" : "transform",
2619+
"-moz-transform": "transform",
2620+
"-webkit-transform": "transform",
2621+
"-o-transform": "transform",
2622+
"-ms-transform": "transform",
26112623

2612-
"-moz-transform-origin" : "transform-origin",
2613-
"-webkit-transform-origin" : "transform-origin",
2614-
"-o-transform-origin" : "transform-origin",
2615-
"-ms-transform-origin" : "transform-origin",
2624+
"-moz-transform-origin": "transform-origin",
2625+
"-webkit-transform-origin": "transform-origin",
2626+
"-o-transform-origin": "transform-origin",
2627+
"-ms-transform-origin": "transform-origin",
26162628

2617-
"-moz-box-sizing" : "box-sizing",
2618-
"-webkit-box-sizing" : "box-sizing"
2629+
"-moz-box-sizing": "box-sizing",
2630+
"-webkit-box-sizing": "box-sizing"
26192631
};
26202632

26212633
// event handler for beginning of rules
@@ -2672,7 +2684,11 @@ CSSLint.addRule({
26722684
properties[name] = [];
26732685
}
26742686

2675-
properties[name].push({ name: event.property, value : event.value, pos:num++ });
2687+
properties[name].push({
2688+
name: event.property,
2689+
value: event.value,
2690+
pos: num++
2691+
});
26762692
});
26772693

26782694
parser.addListener("endrule", endRule);
@@ -2742,7 +2758,7 @@ CSSLint.addRule({
27422758
return "";
27432759
}
27442760

2745-
return str.replace(/[\"&><]/g, function(match) {
2761+
return str.replace(/["&><]/g, function(match) {
27462762
switch (match) {
27472763
case "\"":
27482764
return "&quot;";
@@ -2813,7 +2829,6 @@ CSSLint.addRule({
28132829
};
28142830

28152831

2816-
28172832
if (messages.length > 0) {
28182833
output.push("<file name=\""+filename+"\">");
28192834
CSSLint.Util.forEach(messages, function (message) {
@@ -2945,7 +2960,7 @@ CSSLint.addFormatter({
29452960
if (!str || str.constructor !== String) {
29462961
return "";
29472962
}
2948-
return str.replace(/\"/g, "'").replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
2963+
return str.replace(/"/g, "'").replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
29492964
};
29502965

29512966
if (messages.length > 0) {
@@ -3089,7 +3104,7 @@ CSSLint.addFormatter({
30893104
return "";
30903105
}
30913106

3092-
return str.replace(/\"/g, "'").replace(/</g, "&lt;").replace(/>/g, "&gt;");
3107+
return str.replace(/"/g, "'").replace(/</g, "&lt;").replace(/>/g, "&gt;");
30933108

30943109
};
30953110

@@ -3177,7 +3192,7 @@ CSSLint.addFormatter({
31773192
if (!str || str.constructor !== String) {
31783193
return "";
31793194
}
3180-
return str.replace(/\"/g, "'").replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
3195+
return str.replace(/"/g, "'").replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
31813196
};
31823197

31833198
if (messages.length > 0) {

0 commit comments

Comments
 (0)