Skip to content

Commit

Permalink
Minor lint tweaks.
Browse files Browse the repository at this point in the history
  • Loading branch information
XhmikosR committed Jul 15, 2016
1 parent dadda82 commit c15f49a
Show file tree
Hide file tree
Showing 22 changed files with 304 additions and 210 deletions.
2 changes: 1 addition & 1 deletion dist/cli.js
@@ -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
Expand Down
83 changes: 49 additions & 34 deletions dist/csslint-node.js
@@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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$");
Expand All @@ -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]);
}

Expand Down Expand Up @@ -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)) {
Expand Down Expand Up @@ -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: []
};
}
Expand Down Expand Up @@ -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
};
}
});

Expand Down Expand Up @@ -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);
}
}
Expand Down Expand Up @@ -1320,11 +1331,9 @@ CSSLint.addRule({
"border-bottom": 1,
"border-left": 1,
"background-color": 1
},
properties;
};

function startRule() {
properties = {};
lastProperty = null;
}

Expand Down Expand Up @@ -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
});
}
}
}
Expand Down Expand Up @@ -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);
}
}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -2742,7 +2758,7 @@ CSSLint.addRule({
return "";
}

return str.replace(/[\"&><]/g, function(match) {
return str.replace(/["&><]/g, function(match) {
switch (match) {
case "\"":
return "&quot;";
Expand Down Expand Up @@ -2813,7 +2829,6 @@ CSSLint.addRule({
};



if (messages.length > 0) {
output.push("<file name=\""+filename+"\">");
CSSLint.Util.forEach(messages, function (message) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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;");

};

Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit c15f49a

Please sign in to comment.