From c15f49ac965dcad8f69c3fc8951b290c0f494631 Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Fri, 15 Jul 2016 20:17:45 +0300 Subject: [PATCH] Minor lint tweaks. --- dist/cli.js | 2 +- dist/csslint-node.js | 83 +++++++++++++---------- dist/csslint-rhino.js | 83 +++++++++++++---------- dist/csslint-worker.js | 83 +++++++++++++---------- dist/csslint-wsh.js | 85 ++++++++++++++---------- dist/csslint.js | 83 +++++++++++++---------- src/cli/wsh.js | 2 +- src/core/CSSLint.js | 14 ++-- src/formatters/checkstyle-xml.js | 3 +- src/formatters/csslint-xml.js | 2 +- src/formatters/junit-xml.js | 2 +- src/formatters/lint-xml.js | 2 +- src/rules/box-model.js | 6 +- src/rules/compatible-vendor-prefixes.js | 4 +- src/rules/display-property-grouping.js | 6 +- src/rules/duplicate-background-images.js | 3 +- src/rules/fallback-colors.js | 4 +- src/rules/overqualified-elements.js | 5 +- src/rules/regex-selectors.js | 2 +- src/rules/vendor-prefix.js | 30 +++++---- tasks/changelog.js | 8 ++- tasks/yuitest.js | 2 +- 22 files changed, 304 insertions(+), 210 deletions(-) diff --git a/dist/cli.js b/dist/cli.js index e198ef3c..acad3cd7 100644 --- a/dist/cli.js +++ b/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 diff --git a/dist/csslint-node.js b/dist/csslint-node.js index f667be79..00130c67 100644 --- a/dist/csslint-node.js +++ b/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 @@ -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,7 +235,7 @@ 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; } @@ -239,14 +243,14 @@ var CSSLint = (function() { 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 """; @@ -2813,7 +2829,6 @@ CSSLint.addRule({ }; - if (messages.length > 0) { output.push(""); CSSLint.Util.forEach(messages, function (message) { @@ -2945,7 +2960,7 @@ CSSLint.addFormatter({ if (!str || str.constructor !== String) { return ""; } - return str.replace(/\"/g, "'").replace(/&/g, "&").replace(//g, ">"); + return str.replace(/"/g, "'").replace(/&/g, "&").replace(//g, ">"); }; if (messages.length > 0) { @@ -3089,7 +3104,7 @@ CSSLint.addFormatter({ return ""; } - return str.replace(/\"/g, "'").replace(//g, ">"); + return str.replace(/"/g, "'").replace(//g, ">"); }; @@ -3177,7 +3192,7 @@ CSSLint.addFormatter({ if (!str || str.constructor !== String) { return ""; } - return str.replace(/\"/g, "'").replace(/&/g, "&").replace(//g, ">"); + return str.replace(/"/g, "'").replace(/&/g, "&").replace(//g, ">"); }; if (messages.length > 0) { diff --git a/dist/csslint-rhino.js b/dist/csslint-rhino.js index 33820503..ae984abc 100644 --- a/dist/csslint-rhino.js +++ b/dist/csslint-rhino.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 @@ -7492,7 +7492,7 @@ var CSSLint = (function() { embeddedRuleset = /\/\*\s*csslint([^\*]*)\*\//, api = new parserlib.util.EventTarget(); - api.version = "0.10.0"; + api.version = "1.0.0"; //------------------------------------------------------------------------- // Rule Management @@ -7656,8 +7656,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$"); @@ -7682,7 +7686,7 @@ 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; } @@ -7690,14 +7694,14 @@ var CSSLint = (function() { 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]); } @@ -8160,7 +8164,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)) { @@ -8433,8 +8441,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: [] }; } @@ -8576,7 +8584,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 + }; } }); @@ -8620,8 +8632,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); } } @@ -8771,11 +8782,9 @@ CSSLint.addRule({ "border-bottom": 1, "border-left": 1, "background-color": 1 - }, - properties; + }; function startRule() { - properties = {}; lastProperty = null; } @@ -9365,7 +9374,10 @@ CSSLint.addRule({ if (!classes[modifier]) { classes[modifier] = []; } - classes[modifier].push({ modifier: modifier, part: part }); + classes[modifier].push({ + modifier: modifier, + part: part + }); } } } @@ -9464,7 +9476,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); } } @@ -10055,18 +10067,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 @@ -10123,7 +10135,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); @@ -10193,7 +10209,7 @@ CSSLint.addRule({ return ""; } - return str.replace(/[\"&><]/g, function(match) { + return str.replace(/["&><]/g, function(match) { switch (match) { case "\"": return """; @@ -10264,7 +10280,6 @@ CSSLint.addRule({ }; - if (messages.length > 0) { output.push(""); CSSLint.Util.forEach(messages, function (message) { @@ -10396,7 +10411,7 @@ CSSLint.addFormatter({ if (!str || str.constructor !== String) { return ""; } - return str.replace(/\"/g, "'").replace(/&/g, "&").replace(//g, ">"); + return str.replace(/"/g, "'").replace(/&/g, "&").replace(//g, ">"); }; if (messages.length > 0) { @@ -10540,7 +10555,7 @@ CSSLint.addFormatter({ return ""; } - return str.replace(/\"/g, "'").replace(//g, ">"); + return str.replace(/"/g, "'").replace(//g, ">"); }; @@ -10628,7 +10643,7 @@ CSSLint.addFormatter({ if (!str || str.constructor !== String) { return ""; } - return str.replace(/\"/g, "'").replace(/&/g, "&").replace(//g, ">"); + return str.replace(/"/g, "'").replace(/&/g, "&").replace(//g, ">"); }; if (messages.length > 0) { diff --git a/dist/csslint-worker.js b/dist/csslint-worker.js index 69065d2f..2e84ceda 100644 --- a/dist/csslint-worker.js +++ b/dist/csslint-worker.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 @@ -7488,7 +7488,7 @@ var CSSLint = (function() { embeddedRuleset = /\/\*\s*csslint([^\*]*)\*\//, api = new parserlib.util.EventTarget(); - api.version = "0.10.0"; + api.version = "1.0.0"; //------------------------------------------------------------------------- // Rule Management @@ -7652,8 +7652,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$"); @@ -7678,7 +7682,7 @@ 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; } @@ -7686,14 +7690,14 @@ var CSSLint = (function() { 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]); } @@ -8156,7 +8160,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)) { @@ -8429,8 +8437,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: [] }; } @@ -8572,7 +8580,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 + }; } }); @@ -8616,8 +8628,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); } } @@ -8767,11 +8778,9 @@ CSSLint.addRule({ "border-bottom": 1, "border-left": 1, "background-color": 1 - }, - properties; + }; function startRule() { - properties = {}; lastProperty = null; } @@ -9361,7 +9370,10 @@ CSSLint.addRule({ if (!classes[modifier]) { classes[modifier] = []; } - classes[modifier].push({ modifier: modifier, part: part }); + classes[modifier].push({ + modifier: modifier, + part: part + }); } } } @@ -9460,7 +9472,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); } } @@ -10051,18 +10063,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 @@ -10119,7 +10131,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); @@ -10189,7 +10205,7 @@ CSSLint.addRule({ return ""; } - return str.replace(/[\"&><]/g, function(match) { + return str.replace(/["&><]/g, function(match) { switch (match) { case "\"": return """; @@ -10260,7 +10276,6 @@ CSSLint.addRule({ }; - if (messages.length > 0) { output.push(""); CSSLint.Util.forEach(messages, function (message) { @@ -10392,7 +10407,7 @@ CSSLint.addFormatter({ if (!str || str.constructor !== String) { return ""; } - return str.replace(/\"/g, "'").replace(/&/g, "&").replace(//g, ">"); + return str.replace(/"/g, "'").replace(/&/g, "&").replace(//g, ">"); }; if (messages.length > 0) { @@ -10536,7 +10551,7 @@ CSSLint.addFormatter({ return ""; } - return str.replace(/\"/g, "'").replace(//g, ">"); + return str.replace(/"/g, "'").replace(//g, ">"); }; @@ -10624,7 +10639,7 @@ CSSLint.addFormatter({ if (!str || str.constructor !== String) { return ""; } - return str.replace(/\"/g, "'").replace(/&/g, "&").replace(//g, ">"); + return str.replace(/"/g, "'").replace(/&/g, "&").replace(//g, ">"); }; if (messages.length > 0) { diff --git a/dist/csslint-wsh.js b/dist/csslint-wsh.js index d546ce1a..26a83cd3 100644 --- a/dist/csslint-wsh.js +++ b/dist/csslint-wsh.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 @@ -7492,7 +7492,7 @@ var CSSLint = (function() { embeddedRuleset = /\/\*\s*csslint([^\*]*)\*\//, api = new parserlib.util.EventTarget(); - api.version = "0.10.0"; + api.version = "1.0.0"; //------------------------------------------------------------------------- // Rule Management @@ -7656,8 +7656,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$"); @@ -7682,7 +7686,7 @@ 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; } @@ -7690,14 +7694,14 @@ var CSSLint = (function() { 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]); } @@ -8160,7 +8164,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)) { @@ -8433,8 +8441,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: [] }; } @@ -8576,7 +8584,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 + }; } }); @@ -8620,8 +8632,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); } } @@ -8771,11 +8782,9 @@ CSSLint.addRule({ "border-bottom": 1, "border-left": 1, "background-color": 1 - }, - properties; + }; function startRule() { - properties = {}; lastProperty = null; } @@ -9365,7 +9374,10 @@ CSSLint.addRule({ if (!classes[modifier]) { classes[modifier] = []; } - classes[modifier].push({ modifier: modifier, part: part }); + classes[modifier].push({ + modifier: modifier, + part: part + }); } } } @@ -9464,7 +9476,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); } } @@ -10055,18 +10067,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 @@ -10123,7 +10135,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); @@ -10193,7 +10209,7 @@ CSSLint.addRule({ return ""; } - return str.replace(/[\"&><]/g, function(match) { + return str.replace(/["&><]/g, function(match) { switch (match) { case "\"": return """; @@ -10264,7 +10280,6 @@ CSSLint.addRule({ }; - if (messages.length > 0) { output.push(""); CSSLint.Util.forEach(messages, function (message) { @@ -10396,7 +10411,7 @@ CSSLint.addFormatter({ if (!str || str.constructor !== String) { return ""; } - return str.replace(/\"/g, "'").replace(/&/g, "&").replace(//g, ">"); + return str.replace(/"/g, "'").replace(/&/g, "&").replace(//g, ">"); }; if (messages.length > 0) { @@ -10540,7 +10555,7 @@ CSSLint.addFormatter({ return ""; } - return str.replace(/\"/g, "'").replace(//g, ">"); + return str.replace(/"/g, "'").replace(//g, ">"); }; @@ -10628,7 +10643,7 @@ CSSLint.addFormatter({ if (!str || str.constructor !== String) { return ""; } - return str.replace(/\"/g, "'").replace(/&/g, "&").replace(//g, ">"); + return str.replace(/"/g, "'").replace(/&/g, "&").replace(//g, ">"); }; if (messages.length > 0) { @@ -11173,7 +11188,7 @@ var wshapi = (function() { } if (!Array.prototype.indexOf) { - Array.prototype.indexOf = function (searchElement /*, fromIndex */ ) { + Array.prototype.indexOf = function (searchElement /*, fromIndex */) { if (this === void 0 || this === null) { throw new Error("unknown instance"); } diff --git a/dist/csslint.js b/dist/csslint.js index 4508ea5a..5a47e29b 100644 --- a/dist/csslint.js +++ b/dist/csslint.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 @@ -7492,7 +7492,7 @@ var CSSLint = (function() { embeddedRuleset = /\/\*\s*csslint([^\*]*)\*\//, api = new parserlib.util.EventTarget(); - api.version = "0.10.0"; + api.version = "1.0.0"; //------------------------------------------------------------------------- // Rule Management @@ -7656,8 +7656,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$"); @@ -7682,7 +7686,7 @@ 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; } @@ -7690,14 +7694,14 @@ var CSSLint = (function() { 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]); } @@ -8160,7 +8164,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)) { @@ -8433,8 +8441,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: [] }; } @@ -8576,7 +8584,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 + }; } }); @@ -8620,8 +8632,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); } } @@ -8771,11 +8782,9 @@ CSSLint.addRule({ "border-bottom": 1, "border-left": 1, "background-color": 1 - }, - properties; + }; function startRule() { - properties = {}; lastProperty = null; } @@ -9365,7 +9374,10 @@ CSSLint.addRule({ if (!classes[modifier]) { classes[modifier] = []; } - classes[modifier].push({ modifier: modifier, part: part }); + classes[modifier].push({ + modifier: modifier, + part: part + }); } } } @@ -9464,7 +9476,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); } } @@ -10055,18 +10067,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 @@ -10123,7 +10135,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); @@ -10193,7 +10209,7 @@ CSSLint.addRule({ return ""; } - return str.replace(/[\"&><]/g, function(match) { + return str.replace(/["&><]/g, function(match) { switch (match) { case "\"": return """; @@ -10264,7 +10280,6 @@ CSSLint.addRule({ }; - if (messages.length > 0) { output.push(""); CSSLint.Util.forEach(messages, function (message) { @@ -10396,7 +10411,7 @@ CSSLint.addFormatter({ if (!str || str.constructor !== String) { return ""; } - return str.replace(/\"/g, "'").replace(/&/g, "&").replace(//g, ">"); + return str.replace(/"/g, "'").replace(/&/g, "&").replace(//g, ">"); }; if (messages.length > 0) { @@ -10540,7 +10555,7 @@ CSSLint.addFormatter({ return ""; } - return str.replace(/\"/g, "'").replace(//g, ">"); + return str.replace(/"/g, "'").replace(//g, ">"); }; @@ -10628,7 +10643,7 @@ CSSLint.addFormatter({ if (!str || str.constructor !== String) { return ""; } - return str.replace(/\"/g, "'").replace(/&/g, "&").replace(//g, ">"); + return str.replace(/"/g, "'").replace(/&/g, "&").replace(//g, ">"); }; if (messages.length > 0) { diff --git a/src/cli/wsh.js b/src/cli/wsh.js index cf3f5a8b..9b3bf0fa 100644 --- a/src/cli/wsh.js +++ b/src/cli/wsh.js @@ -63,7 +63,7 @@ var wshapi = (function() { } if (!Array.prototype.indexOf) { - Array.prototype.indexOf = function (searchElement /*, fromIndex */ ) { + Array.prototype.indexOf = function (searchElement /*, fromIndex */) { if (this === void 0 || this === null) { throw new Error("unknown instance"); } diff --git a/src/core/CSSLint.js b/src/core/CSSLint.js index 578f60bb..4ebbfa15 100644 --- a/src/core/CSSLint.js +++ b/src/core/CSSLint.js @@ -180,8 +180,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$"); @@ -206,7 +210,7 @@ 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; } @@ -214,14 +218,14 @@ var CSSLint = (function() { 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]); } diff --git a/src/formatters/checkstyle-xml.js b/src/formatters/checkstyle-xml.js index f04bdc40..43a951bc 100644 --- a/src/formatters/checkstyle-xml.js +++ b/src/formatters/checkstyle-xml.js @@ -18,7 +18,7 @@ return ""; } - return str.replace(/[\"&><]/g, function(match) { + return str.replace(/["&><]/g, function(match) { switch (match) { case "\"": return """; @@ -89,7 +89,6 @@ }; - if (messages.length > 0) { output.push(""); CSSLint.Util.forEach(messages, function (message) { diff --git a/src/formatters/csslint-xml.js b/src/formatters/csslint-xml.js index 7783ee5a..3df5595f 100644 --- a/src/formatters/csslint-xml.js +++ b/src/formatters/csslint-xml.js @@ -49,7 +49,7 @@ CSSLint.addFormatter({ if (!str || str.constructor !== String) { return ""; } - return str.replace(/\"/g, "'").replace(/&/g, "&").replace(//g, ">"); + return str.replace(/"/g, "'").replace(/&/g, "&").replace(//g, ">"); }; if (messages.length > 0) { diff --git a/src/formatters/junit-xml.js b/src/formatters/junit-xml.js index 992b8200..7a0a1390 100644 --- a/src/formatters/junit-xml.js +++ b/src/formatters/junit-xml.js @@ -69,7 +69,7 @@ CSSLint.addFormatter({ return ""; } - return str.replace(/\"/g, "'").replace(//g, ">"); + return str.replace(/"/g, "'").replace(//g, ">"); }; diff --git a/src/formatters/lint-xml.js b/src/formatters/lint-xml.js index 0fd28c9c..4066ecc9 100644 --- a/src/formatters/lint-xml.js +++ b/src/formatters/lint-xml.js @@ -49,7 +49,7 @@ CSSLint.addFormatter({ if (!str || str.constructor !== String) { return ""; } - return str.replace(/\"/g, "'").replace(/&/g, "&").replace(//g, ">"); + return str.replace(/"/g, "'").replace(/&/g, "&").replace(//g, ">"); }; if (messages.length > 0) { diff --git a/src/rules/box-model.js b/src/rules/box-model.js index 30b5d94f..09e02197 100644 --- a/src/rules/box-model.js +++ b/src/rules/box-model.js @@ -80,7 +80,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)) { diff --git a/src/rules/compatible-vendor-prefixes.js b/src/rules/compatible-vendor-prefixes.js index ce960c97..125e4388 100644 --- a/src/rules/compatible-vendor-prefixes.js +++ b/src/rules/compatible-vendor-prefixes.js @@ -151,8 +151,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: [] }; } diff --git a/src/rules/display-property-grouping.js b/src/rules/display-property-grouping.js index c710b57b..5832d2d9 100644 --- a/src/rules/display-property-grouping.js +++ b/src/rules/display-property-grouping.js @@ -105,7 +105,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 + }; } }); diff --git a/src/rules/duplicate-background-images.js b/src/rules/duplicate-background-images.js index ad6c743f..eafdfd92 100644 --- a/src/rules/duplicate-background-images.js +++ b/src/rules/duplicate-background-images.js @@ -27,8 +27,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); } } diff --git a/src/rules/fallback-colors.js b/src/rules/fallback-colors.js index e16162cf..b835070c 100644 --- a/src/rules/fallback-colors.js +++ b/src/rules/fallback-colors.js @@ -26,11 +26,9 @@ CSSLint.addRule({ "border-bottom": 1, "border-left": 1, "background-color": 1 - }, - properties; + }; function startRule() { - properties = {}; lastProperty = null; } diff --git a/src/rules/overqualified-elements.js b/src/rules/overqualified-elements.js index a36246f9..9f247e38 100644 --- a/src/rules/overqualified-elements.js +++ b/src/rules/overqualified-elements.js @@ -39,7 +39,10 @@ CSSLint.addRule({ if (!classes[modifier]) { classes[modifier] = []; } - classes[modifier].push({ modifier: modifier, part: part }); + classes[modifier].push({ + modifier: modifier, + part: part + }); } } } diff --git a/src/rules/regex-selectors.js b/src/rules/regex-selectors.js index a24240af..d0c6c2c5 100644 --- a/src/rules/regex-selectors.js +++ b/src/rules/regex-selectors.js @@ -31,7 +31,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); } } diff --git a/src/rules/vendor-prefix.js b/src/rules/vendor-prefix.js index 2e1fb7ff..91e1e84d 100644 --- a/src/rules/vendor-prefix.js +++ b/src/rules/vendor-prefix.js @@ -64,18 +64,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-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-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-box-sizing": "box-sizing", + "-webkit-box-sizing": "box-sizing" }; // event handler for beginning of rules @@ -132,7 +132,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); diff --git a/tasks/changelog.js b/tasks/changelog.js index 58f4f3df..4bea26c8 100644 --- a/tasks/changelog.js +++ b/tasks/changelog.js @@ -50,12 +50,16 @@ module.exports = function(grunt) { grunt.verbose.write("Last tag: " + lastTag).writeln(); - // grunt.util.spawn({ cmd: "git", args: ["log", "--pretty=format:'* %s (%an)'", lastTag + "..HEAD"] }, function(error, result) { - var prettyPrint = result.stdout.split("'\n'").join("\n").replace(/\"$/, "").replace(/^\"/, "").replace(/^\'/, "").replace(/\'$/, ""); + var prettyPrint = result.stdout.split("'\n'") + .join("\n") + .replace(/"$/, "") + .replace(/^"/, "") + .replace(/^'/, "") + .replace(/'$/, ""); grunt.verbose.writeln().write(prettyPrint).writeln(); diff --git a/tasks/yuitest.js b/tasks/yuitest.js index 1829c9d5..328f9cc6 100644 --- a/tasks/yuitest.js +++ b/tasks/yuitest.js @@ -37,7 +37,7 @@ module.exports = function(grunt) { grunt.log.writeln("Total tests: " + results.total + ", " + ("Failures: " + results.failed).red + ", " + ("Skipped: " + results.ignored).yellow + - ", Time: " + (results.duration/1000) + " seconds\n"); + ", Time: " + results.duration / 1000 + " seconds\n"); if (failures.length) { grunt.log.writeln("Tests failed:");