Permalink
Browse files

Minor lint tweaks.

  • Loading branch information...
1 parent dadda82 commit c15f49ac965dcad8f69c3fc8951b290c0f494631 @XhmikosR XhmikosR committed Jul 15, 2016
View
@@ -1,6 +1,6 @@
#!/usr/bin/env node
/*!
-CSSLint v0.10.0
+CSSLint v1.0.0
Copyright (c) 2016 Nicole Sullivan and Nicholas C. Zakas. All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy
View
@@ -1,5 +1,5 @@
/*!
-CSSLint v0.10.0
+CSSLint v1.0.0
Copyright (c) 2016 Nicole Sullivan and Nicholas C. Zakas. All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -41,7 +41,7 @@ var CSSLint = (function() {
embeddedRuleset = /\/\*\s*csslint([^\*]*)\*\//,
api = new parserlib.util.EventTarget();
- api.version = "0.10.0";
+ api.version = "1.0.0";
//-------------------------------------------------------------------------
// Rule Management
@@ -205,8 +205,12 @@ var CSSLint = (function() {
allow = {},
ignore = [],
report,
- parser = new parserlib.css.Parser({ starHack: true, ieFilters: true,
- underscoreHack: true, strict: false });
+ parser = new parserlib.css.Parser({
+ starHack: true,
+ ieFilters: true,
+ underscoreHack: true,
+ strict: false
+ });
// normalize line endings
lines = text.replace(/\n\r?/g, "$split$").split("$split$");
@@ -231,22 +235,22 @@ var CSSLint = (function() {
ignoreEnd = null;
CSSLint.Util.forEach(lines, function (line, lineno) {
// Keep oldest, "unclosest" ignore:start
- if (null === ignoreStart && line.match(/\/\*[ \t]*csslint[ \t]+ignore:start[ \t]*\*\//i)) {
+ if (ignoreStart === null && line.match(/\/\*[ \t]*csslint[ \t]+ignore:start[ \t]*\*\//i)) {
ignoreStart = lineno;
}
if (line.match(/\/\*[ \t]*csslint[ \t]+ignore:end[ \t]*\*\//i)) {
ignoreEnd = lineno;
}
- if (null !== ignoreStart && null !== ignoreEnd) {
+ if (ignoreStart !== null && ignoreEnd !== null) {
ignore.push([ignoreStart, ignoreEnd]);
ignoreStart = ignoreEnd = null;
}
});
// Close remaining ignore block, if any
- if (null !== ignoreStart) {
+ if (ignoreStart !== null) {
ignore.push([ignoreStart, lines.length]);
}
@@ -709,7 +713,11 @@ CSSLint.addRule({
if (heightProperties[name] || widthProperties[name]) {
if (!/^0\S*$/.test(event.value) && !(name === "border" && event.value.toString() === "none")) {
- properties[name] = { line: event.property.line, col: event.property.col, value: event.value };
+ properties[name] = {
+ line: event.property.line,
+ col: event.property.col,
+ value: event.value
+ };
}
} else {
if (/^(width|height)/i.test(name) && /^(length|percentage)/.test(event.value.parts[0].type)) {
@@ -982,8 +990,8 @@ CSSLint.addRule({
if (CSSLint.Util.indexOf(variations, name.text) > -1) {
if (!propertyGroups[prop]) {
propertyGroups[prop] = {
- full : variations.slice(0),
- actual : [],
+ full: variations.slice(0),
+ actual: [],
actualNodes: []
};
}
@@ -1125,7 +1133,11 @@ CSSLint.addRule({
var name = event.property.text.toLowerCase();
if (propertiesToCheck[name]) {
- properties[name] = { value: event.value.text, line: event.property.line, col: event.property.col };
+ properties[name] = {
+ value: event.value.text,
+ line: event.property.line,
+ col: event.property.col
+ };
}
});
@@ -1169,8 +1181,7 @@ CSSLint.addRule({
if (value.parts[i].type === "uri") {
if (typeof stack[value.parts[i].uri] === "undefined") {
stack[value.parts[i].uri] = event;
- }
- else {
+ } else {
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);
}
}
@@ -1320,11 +1331,9 @@ CSSLint.addRule({
"border-bottom": 1,
"border-left": 1,
"background-color": 1
- },
- properties;
+ };
function startRule() {
- properties = {};
lastProperty = null;
}
@@ -1914,7 +1923,10 @@ CSSLint.addRule({
if (!classes[modifier]) {
classes[modifier] = [];
}
- classes[modifier].push({ modifier: modifier, part: part });
+ classes[modifier].push({
+ modifier: modifier,
+ part: part
+ });
}
}
}
@@ -2013,7 +2025,7 @@ CSSLint.addRule({
for (k=0; k < part.modifiers.length; k++) {
modifier = part.modifiers[k];
if (modifier.type === "attribute") {
- if (/([\~\|\^\$\*]=)/.test(modifier)) {
+ if (/([~\|\^\$\*]=)/.test(modifier)) {
reporter.report("Attribute selectors with " + RegExp.$1 + " are slow!", modifier.line, modifier.col, rule);
}
}
@@ -2604,18 +2616,18 @@ CSSLint.addRule({
"-moz-box-shadow": "box-shadow",
"-webkit-box-shadow": "box-shadow",
- "-moz-transform" : "transform",
- "-webkit-transform" : "transform",
- "-o-transform" : "transform",
- "-ms-transform" : "transform",
+ "-moz-transform": "transform",
+ "-webkit-transform": "transform",
+ "-o-transform": "transform",
+ "-ms-transform": "transform",
- "-moz-transform-origin" : "transform-origin",
- "-webkit-transform-origin" : "transform-origin",
- "-o-transform-origin" : "transform-origin",
- "-ms-transform-origin" : "transform-origin",
+ "-moz-transform-origin": "transform-origin",
+ "-webkit-transform-origin": "transform-origin",
+ "-o-transform-origin": "transform-origin",
+ "-ms-transform-origin": "transform-origin",
- "-moz-box-sizing" : "box-sizing",
- "-webkit-box-sizing" : "box-sizing"
+ "-moz-box-sizing": "box-sizing",
+ "-webkit-box-sizing": "box-sizing"
};
// event handler for beginning of rules
@@ -2672,7 +2684,11 @@ CSSLint.addRule({
properties[name] = [];
}
- properties[name].push({ name: event.property, value : event.value, pos:num++ });
+ properties[name].push({
+ name: event.property,
+ value: event.value,
+ pos: num++
+ });
});
parser.addListener("endrule", endRule);
@@ -2742,7 +2758,7 @@ CSSLint.addRule({
return "";
}
- return str.replace(/[\"&><]/g, function(match) {
+ return str.replace(/["&><]/g, function(match) {
switch (match) {
case "\"":
return "&quot;";
@@ -2813,7 +2829,6 @@ CSSLint.addRule({
};
-
if (messages.length > 0) {
output.push("<file name=\""+filename+"\">");
CSSLint.Util.forEach(messages, function (message) {
@@ -2945,7 +2960,7 @@ CSSLint.addFormatter({
if (!str || str.constructor !== String) {
return "";
}
- return str.replace(/\"/g, "'").replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
+ return str.replace(/"/g, "'").replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
};
if (messages.length > 0) {
@@ -3089,7 +3104,7 @@ CSSLint.addFormatter({
return "";
}
- return str.replace(/\"/g, "'").replace(/</g, "&lt;").replace(/>/g, "&gt;");
+ return str.replace(/"/g, "'").replace(/</g, "&lt;").replace(/>/g, "&gt;");
};
@@ -3177,7 +3192,7 @@ CSSLint.addFormatter({
if (!str || str.constructor !== String) {
return "";
}
- return str.replace(/\"/g, "'").replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
+ return str.replace(/"/g, "'").replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
};
if (messages.length > 0) {
Oops, something went wrong.

0 comments on commit c15f49a

Please sign in to comment.