Fix File
•
/
home
/
sportsfe...
/
httpdocs
/
wp-inclu...
/
js
/
codemirr...
•
File:
csslint.js
•
Content:
parser.addListener("endstylesheet", function() { var prop, messages = []; for (prop in headings) { if (headings.hasOwnProperty(prop)) { if (headings[prop] > 1) { messages.push(headings[prop] + " " + prop + "s"); } } } if (messages.length) { reporter.rollupWarn("You have " + messages.join(", ") + " defined in this stylesheet.", rule); } }); } }); /* * Rule: Don't use universal selector because it's slow. */ CSSLint.addRule({ // rule information id: "universal-selector", name: "Disallow universal selector", desc: "The universal selector (*) is known to be slow.", url: "https://github.com/CSSLint/csslint/wiki/Disallow-universal-selector", browsers: "All", // initialization init: function(parser, reporter) { "use strict"; var rule = this; parser.addListener("startrule", function(event) { var selectors = event.selectors, selector, part, i; for (i=0; i < selectors.length; i++) { selector = selectors[i]; part = selector.parts[selector.parts.length-1]; if (part.elementName === "*") { reporter.report(rule.desc, part.line, part.col, rule); } } }); } }); /* * Rule: Don't use unqualified attribute selectors because they're just like universal selectors. */ CSSLint.addRule({ // rule information id: "unqualified-attributes", name: "Disallow unqualified attribute selectors", desc: "Unqualified attribute selectors are known to be slow.", url: "https://github.com/CSSLint/csslint/wiki/Disallow-unqualified-attribute-selectors", browsers: "All", // initialization init: function(parser, reporter) { "use strict"; var rule = this; parser.addListener("startrule", function(event) { var selectors = event.selectors, selectorContainsClassOrId = false, selector, part, modifier, i, k; for (i=0; i < selectors.length; i++) { selector = selectors[i]; part = selector.parts[selector.parts.length-1]; if (part.type === parser.SELECTOR_PART_TYPE) { for (k=0; k < part.modifiers.length; k++) { modifier = part.modifiers[k]; if (modifier.type === "class" || modifier.type === "id") { selectorContainsClassOrId = true; break; } } if (!selectorContainsClassOrId) { for (k=0; k < part.modifiers.length; k++) { modifier = part.modifiers[k]; if (modifier.type === "attribute" && (!part.elementName || part.elementName === "*")) { reporter.report(rule.desc, part.line, part.col, rule); } } } } } }); } }); /* * Rule: When using a vendor-prefixed property, make sure to * include the standard one. */ CSSLint.addRule({ // rule information id: "vendor-prefix", name: "Require standard property with vendor prefix", desc: "When using a vendor-prefixed property, make sure to include the standard one.", url: "https://github.com/CSSLint/csslint/wiki/Require-standard-property-with-vendor-prefix", browsers: "All", // initialization init: function(parser, reporter) { "use strict"; var rule = this, properties, num, propertiesToCheck = { "-webkit-border-radius": "border-radius", "-webkit-border-top-left-radius": "border-top-left-radius", "-webkit-border-top-right-radius": "border-top-right-radius", "-webkit-border-bottom-left-radius": "border-bottom-left-radius", "-webkit-border-bottom-right-radius": "border-bottom-right-radius", "-o-border-radius": "border-radius", "-o-border-top-left-radius": "border-top-left-radius", "-o-border-top-right-radius": "border-top-right-radius", "-o-border-bottom-left-radius": "border-bottom-left-radius", "-o-border-bottom-right-radius": "border-bottom-right-radius", "-moz-border-radius": "border-radius", "-moz-border-radius-topleft": "border-top-left-radius", "-moz-border-radius-topright": "border-top-right-radius", "-moz-border-radius-bottomleft": "border-bottom-left-radius", "-moz-border-radius-bottomright": "border-bottom-right-radius", "-moz-column-count": "column-count", "-webkit-column-count": "column-count", "-moz-column-gap": "column-gap", "-webkit-column-gap": "column-gap", "-moz-column-rule": "column-rule", "-webkit-column-rule": "column-rule", "-moz-column-rule-style": "column-rule-style", "-webkit-column-rule-style": "column-rule-style", "-moz-column-rule-color": "column-rule-color", "-webkit-column-rule-color": "column-rule-color", "-moz-column-rule-width": "column-rule-width", "-webkit-column-rule-width": "column-rule-width", "-moz-column-width": "column-width", "-webkit-column-width": "column-width", "-webkit-column-span": "column-span", "-webkit-columns": "columns", "-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" }; // event handler for beginning of rules function startRule() { properties = {}; num = 1; } // event handler for end of rules function endRule() { var prop, i, len, needed, actual, needsStandard = []; for (prop in properties) { if (propertiesToCheck[prop]) { needsStandard.push({ actual: prop, needed: propertiesToCheck[prop] }); } } for (i=0, len=needsStandard.length; i < len; i++) { needed = needsStandard[i].needed; actual = needsStandard[i].actual; if (!properties[needed]) { reporter.report("Missing standard property '" + needed + "' to go along with '" + actual + "'.", properties[actual][0].name.line, properties[actual][0].name.col, rule); } else { // make sure standard property is last if (properties[needed][0].pos < properties[actual][0].pos) { reporter.report("Standard property '" + needed + "' should come after vendor-prefixed property '" + actual + "'.", properties[actual][0].name.line, properties[actual][0].name.col, rule); } } } } parser.addListener("startrule", startRule); parser.addListener("startfontface", startRule); parser.addListener("startpage", startRule); parser.addListener("startpagemargin", startRule); parser.addListener("startkeyframerule", startRule); parser.addListener("startviewport", startRule); parser.addListener("property", function(event) { var name = event.property.text.toLowerCase(); if (!properties[name]) { properties[name] = []; } properties[name].push({ name: event.property, value: event.value, pos: num++ }); }); parser.addListener("endrule", endRule); parser.addListener("endfontface", endRule); parser.addListener("endpage", endRule); parser.addListener("endpagemargin", endRule); parser.addListener("endkeyframerule", endRule); parser.addListener("endviewport", endRule); } }); /* * Rule: You don't need to specify units when a value is 0. */ CSSLint.addRule({ // rule information id: "zero-units", name: "Disallow units for 0 values", desc: "You don't need to specify units when a value is 0.", url: "https://github.com/CSSLint/csslint/wiki/Disallow-units-for-zero-values", browsers: "All", // initialization init: function(parser, reporter) { "use strict"; var rule = this; // count how many times "float" is used parser.addListener("property", function(event) { var parts = event.value.parts, i = 0, len = parts.length; while (i < len) { if ((parts[i].units || parts[i].type === "percentage") && parts[i].value === 0 && parts[i].type !== "time") { reporter.report("Values of 0 shouldn't have units specified.", parts[i].line, parts[i].col, rule); } i++; } }); } }); (function() { "use strict"; /** * Replace special characters before write to output. * * Rules: * - single quotes is the escape sequence for double-quotes * - & is the escape sequence for & * - < is the escape sequence for < * - > is the escape sequence for > * * @param {String} message to escape * @return escaped message as {String} */ var xmlEscape = function(str) { if (!str || str.constructor !== String) { return ""; } return str.replace(/["&><]/g, function(match) { switch (match) { case "\"": return """; case "&": return "&"; case "<": return "<"; case ">": return ">"; } }); }; CSSLint.addFormatter({ // format information id: "checkstyle-xml", name: "Checkstyle XML format", /** * Return opening root XML tag. * @return {String} to prepend before all results */ startFormat: function() { return "<?xml version=\"1.0\" encoding=\"utf-8\"?><checkstyle>"; }, /** * Return closing root XML tag. * @return {String} to append after all results */ endFormat: function() { return "</checkstyle>"; }, /** * Returns message when there is a file read error. * @param {String} filename The name of the file that caused the error. * @param {String} message The error message * @return {String} The error message. */ readError: function(filename, message) { return "<file name=\"" + xmlEscape(filename) + "\"><error line=\"0\" column=\"0\" severty=\"error\" message=\"" + xmlEscape(message) + "\"></error></file>"; }, /** * Given CSS Lint results for a file, return output for this format. * @param results {Object} with error and warning messages * @param filename {String} relative file path * @param options {Object} (UNUSED for now) specifies special handling of output * @return {String} output for results */ formatResults: function(results, filename/*, options*/) { var messages = results.messages, output = []; /** * Generate a source string for a rule. * Checkstyle source strings usually resemble Java class names e.g * net.csslint.SomeRuleName * @param {Object} rule * @return rule source as {String} */ var generateSource = function(rule) { if (!rule || !("name" in rule)) { return ""; } return "net.csslint." + rule.name.replace(/\s/g, ""); }; if (messages.length > 0) { output.push("<file name=\""+filename+"\">"); CSSLint.Util.forEach(messages, function (message) { // ignore rollups for now if (!message.rollup) { output.push("<error line=\"" + message.line + "\" column=\"" + message.col + "\" severity=\"" + message.type + "\"" + " message=\"" + xmlEscape(message.message) + "\" source=\"" + generateSource(message.rule) +"\"/>"); } }); output.push("</file>"); } return output.join(""); } }); }()); CSSLint.addFormatter({ // format information id: "compact", name: "Compact, 'porcelain' format", /** * Return content to be printed before all file results. * @return {String} to prepend before all results */ startFormat: function() { "use strict"; return ""; }, /** * Return content to be printed after all file results. * @return {String} to append after all results */ endFormat: function() { "use strict"; return ""; }, /** * Given CSS Lint results for a file, return output for this format. * @param results {Object} with error and warning messages * @param filename {String} relative file path * @param options {Object} (Optional) specifies special handling of output * @return {String} output for results */ formatResults: function(results, filename, options) { "use strict"; var messages = results.messages, output = ""; options = options || {}; /** * Capitalize and return given string. * @param str {String} to capitalize * @return {String} capitalized */ var capitalize = function(str) { return str.charAt(0).toUpperCase() + str.slice(1); }; if (messages.length === 0) { return options.quiet ? "" : filename + ": Lint Free!"; } CSSLint.Util.forEach(messages, function(message) { if (message.rollup) { output += filename + ": " + capitalize(message.type) + " - " + message.message + " (" + message.rule.id + ")\n"; } else { output += filename + ": line " + message.line + ", col " + message.col + ", " + capitalize(message.type) + " - " + message.message + " (" + message.rule.id + ")\n"; } }); return output; } }); CSSLint.addFormatter({ // format information id: "csslint-xml", name: "CSSLint XML format", /** * Return opening root XML tag. * @return {String} to prepend before all results */ startFormat: function() { "use strict"; return "<?xml version=\"1.0\" encoding=\"utf-8\"?><csslint>"; }, /** * Return closing root XML tag. * @return {String} to append after all results */ endFormat: function() { "use strict"; return "</csslint>"; }, /** * Given CSS Lint results for a file, return output for this format. * @param results {Object} with error and warning messages * @param filename {String} relative file path * @param options {Object} (UNUSED for now) specifies special handling of output * @return {String} output for results */ formatResults: function(results, filename/*, options*/) { "use strict"; var messages = results.messages, output = []; /** * Replace special characters before write to output. * * Rules: * - single quotes is the escape sequence for double-quotes * - & is the escape sequence for & * - < is the escape sequence for < * - > is the escape sequence for > * * @param {String} message to escape * @return escaped message as {String} */ var escapeSpecialCharacters = function(str) { if (!str || str.constructor !== String) { return ""; } return str.replace(/"/g, "'").replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">"); }; if (messages.length > 0) { output.push("<file name=\""+filename+"\">"); CSSLint.Util.forEach(messages, function (message) { if (message.rollup) { output.push("<issue severity=\"" + message.type + "\" reason=\"" + escapeSpecialCharacters(message.message) + "\" evidence=\"" + escapeSpecialCharacters(message.evidence) + "\"/>"); } else { output.push("<issue line=\"" + message.line + "\" char=\"" + message.col + "\" severity=\"" + message.type + "\"" + " reason=\"" + escapeSpecialCharacters(message.message) + "\" evidence=\"" + escapeSpecialCharacters(message.evidence) + "\"/>"); } }); output.push("</file>"); } return output.join(""); } }); /* globals JSON: true */ CSSLint.addFormatter({ // format information id: "json", name: "JSON", /** * Return content to be printed before all file results. * @return {String} to prepend before all results */ startFormat: function() { "use strict"; this.json = []; return ""; }, /** * Return content to be printed after all file results. * @return {String} to append after all results */ endFormat: function() { "use strict"; var ret = ""; if (this.json.length > 0) { if (this.json.length === 1) { ret = JSON.stringify(this.json[0]); } else { ret = JSON.stringify(this.json); } } return ret; }, /** * Given CSS Lint results for a file, return output for this format. * @param results {Object} with error and warning messages * @param filename {String} relative file path (Unused) * @return {String} output for results */ formatResults: function(results, filename, options) { "use strict"; if (results.messages.length > 0 || !options.quiet) { this.json.push({ filename: filename, messages: results.messages, stats: results.stats }); } return ""; } }); CSSLint.addFormatter({ // format information id: "junit-xml", name: "JUNIT XML format", /** * Return opening root XML tag. * @return {String} to prepend before all results */ startFormat: function() { "use strict"; return "<?xml version=\"1.0\" encoding=\"utf-8\"?><testsuites>"; }, /** * Return closing root XML tag. * @return {String} to append after all results */ endFormat: function() { "use strict"; return "</testsuites>"; }, /** * Given CSS Lint results for a file, return output for this format. * @param results {Object} with error and warning messages * @param filename {String} relative file path * @param options {Object} (UNUSED for now) specifies special handling of output * @return {String} output for results */ formatResults: function(results, filename/*, options*/) { "use strict"; var messages = results.messages, output = [], tests = { "error": 0, "failure": 0 }; /** * Generate a source string for a rule. * JUNIT source strings usually resemble Java class names e.g * net.csslint.SomeRuleName * @param {Object} rule * @return rule source as {String} */ var generateSource = function(rule) { if (!rule || !("name" in rule)) { return ""; } return "net.csslint." + rule.name.replace(/\s/g, ""); }; /** * Replace special characters before write to output. * * Rules: * - single quotes is the escape sequence for double-quotes * - < is the escape sequence for < * - > is the escape sequence for > * * @param {String} message to escape * @return escaped message as {String} */ var escapeSpecialCharacters = function(str) { if (!str || str.constructor !== String) { return ""; } return str.replace(/"/g, "'").replace(/</g, "<").replace(/>/g, ">"); }; if (messages.length > 0) { messages.forEach(function (message) { // since junit has no warning class // all issues as errors var type = message.type === "warning" ? "error" : message.type; // ignore rollups for now if (!message.rollup) { // build the test case separately, once joined // we'll add it to a custom array filtered by type output.push("<testcase time=\"0\" name=\"" + generateSource(message.rule) + "\">"); output.push("<" + type + " message=\"" + escapeSpecialCharacters(message.message) + "\"><![CDATA[" + message.line + ":" + message.col + ":" + escapeSpecialCharacters(message.evidence) + "]]></" + type + ">"); output.push("</testcase>"); tests[type] += 1; } }); output.unshift("<testsuite time=\"0\" tests=\"" + messages.length + "\" skipped=\"0\" errors=\"" + tests.error + "\" failures=\"" + tests.failure + "\" package=\"net.csslint\" name=\"" + filename + "\">"); output.push("</testsuite>"); } return output.join(""); } }); CSSLint.addFormatter({ // format information id: "lint-xml", name: "Lint XML format", /** * Return opening root XML tag. * @return {String} to prepend before all results */ startFormat: function() { "use strict"; return "<?xml version=\"1.0\" encoding=\"utf-8\"?><lint>"; }, /** * Return closing root XML tag. * @return {String} to append after all results */ endFormat: function() { "use strict"; return "</lint>"; }, /** * Given CSS Lint results for a file, return output for this format. * @param results {Object} with error and warning messages * @param filename {String} relative file path * @param options {Object} (UNUSED for now) specifies special handling of output * @return {String} output for results */ formatResults: function(results, filename/*, options*/) { "use strict"; var messages = results.messages, output = []; /** * Replace special characters before write to output. * * Rules: * - single quotes is the escape sequence for double-quotes * - & is the escape sequence for & * - < is the escape sequence for < * - > is the escape sequence for > * * @param {String} message to escape * @return escaped message as {String} */ var escapeSpecialCharacters = function(str) { if (!str || str.constructor !== String) { return ""; } return str.replace(/"/g, "'").replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">"); }; if (messages.length > 0) { output.push("<file name=\""+filename+"\">"); CSSLint.Util.forEach(messages, function (message) { if (message.rollup) { output.push("<issue severity=\"" + message.type + "\" reason=\"" + escapeSpecialCharacters(message.message) + "\" evidence=\"" + escapeSpecialCharacters(message.evidence) + "\"/>"); } else { var rule = ""; if (message.rule && message.rule.id) { rule = "rule=\"" + escapeSpecialCharacters(message.rule.id) + "\" "; } output.push("<issue " + rule + "line=\"" + message.line + "\" char=\"" + message.col + "\" severity=\"" + message.type + "\"" + " reason=\"" + escapeSpecialCharacters(message.message) + "\" evidence=\"" + escapeSpecialCharacters(message.evidence) + "\"/>"); } }); output.push("</file>"); } return output.join(""); } }); CSSLint.addFormatter({ // format information id: "text", name: "Plain Text", /** * Return content to be printed before all file results. * @return {String} to prepend before all results */ startFormat: function() { "use strict"; return ""; }, /** * Return content to be printed after all file results. * @return {String} to append after all results */ endFormat: function() { "use strict"; return ""; }, /** * Given CSS Lint results for a file, return output for this format. * @param results {Object} with error and warning messages * @param filename {String} relative file path * @param options {Object} (Optional) specifies special handling of output * @return {String} output for results */ formatResults: function(results, filename, options) { "use strict"; var messages = results.messages, output = ""; options = options || {}; if (messages.length === 0) { return options.quiet ? "" : "\n\ncsslint: No errors in " + filename + "."; } output = "\n\ncsslint: There "; if (messages.length === 1) { output += "is 1 problem"; } else { output += "are " + messages.length + " problems"; } output += " in " + filename + "."; var pos = filename.lastIndexOf("/"), shortFilename = filename; if (pos === -1) { pos = filename.lastIndexOf("\\"); } if (pos > -1) { shortFilename = filename.substring(pos+1); } CSSLint.Util.forEach(messages, function (message, i) { output = output + "\n\n" + shortFilename; if (message.rollup) { output += "\n" + (i+1) + ": " + message.type; output += "\n" + message.message; } else { output += "\n" + (i+1) + ": " + message.type + " at line " + message.line + ", col " + message.col; output += "\n" + message.message; output += "\n" + message.evidence; } }); return output; } }); return CSSLint; })();
•
Search:
•
Replace:
1
2
Function
Edit by line
Download
Information
Rename
Copy
Move
Delete
Chmod
List