Edit File by line
/home/barbar84/www/wp-inclu.../js/codemirr...
File: csslint.js
* @param results {Object} with error and warning messages
[10500] Fix | Delete
* @param filename {String} relative file path
[10501] Fix | Delete
* @param options {Object} (UNUSED for now) specifies special handling of output
[10502] Fix | Delete
* @return {String} output for results
[10503] Fix | Delete
*/
[10504] Fix | Delete
formatResults: function(results, filename/*, options*/) {
[10505] Fix | Delete
"use strict";
[10506] Fix | Delete
var messages = results.messages,
[10507] Fix | Delete
output = [];
[10508] Fix | Delete
[10509] Fix | Delete
/**
[10510] Fix | Delete
* Replace special characters before write to output.
[10511] Fix | Delete
*
[10512] Fix | Delete
* Rules:
[10513] Fix | Delete
* - single quotes is the escape sequence for double-quotes
[10514] Fix | Delete
* - & is the escape sequence for &
[10515] Fix | Delete
* - &lt; is the escape sequence for <
[10516] Fix | Delete
* - &gt; is the escape sequence for >
[10517] Fix | Delete
*
[10518] Fix | Delete
* @param {String} message to escape
[10519] Fix | Delete
* @return escaped message as {String}
[10520] Fix | Delete
*/
[10521] Fix | Delete
var escapeSpecialCharacters = function(str) {
[10522] Fix | Delete
if (!str || str.constructor !== String) {
[10523] Fix | Delete
return "";
[10524] Fix | Delete
}
[10525] Fix | Delete
return str.replace(/"/g, "'").replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
[10526] Fix | Delete
};
[10527] Fix | Delete
[10528] Fix | Delete
if (messages.length > 0) {
[10529] Fix | Delete
output.push("<file name=\""+filename+"\">");
[10530] Fix | Delete
CSSLint.Util.forEach(messages, function (message) {
[10531] Fix | Delete
if (message.rollup) {
[10532] Fix | Delete
output.push("<issue severity=\"" + message.type + "\" reason=\"" + escapeSpecialCharacters(message.message) + "\" evidence=\"" + escapeSpecialCharacters(message.evidence) + "\"/>");
[10533] Fix | Delete
} else {
[10534] Fix | Delete
output.push("<issue line=\"" + message.line + "\" char=\"" + message.col + "\" severity=\"" + message.type + "\"" +
[10535] Fix | Delete
" reason=\"" + escapeSpecialCharacters(message.message) + "\" evidence=\"" + escapeSpecialCharacters(message.evidence) + "\"/>");
[10536] Fix | Delete
}
[10537] Fix | Delete
});
[10538] Fix | Delete
output.push("</file>");
[10539] Fix | Delete
}
[10540] Fix | Delete
[10541] Fix | Delete
return output.join("");
[10542] Fix | Delete
}
[10543] Fix | Delete
});
[10544] Fix | Delete
[10545] Fix | Delete
/* globals JSON: true */
[10546] Fix | Delete
[10547] Fix | Delete
CSSLint.addFormatter({
[10548] Fix | Delete
// format information
[10549] Fix | Delete
id: "json",
[10550] Fix | Delete
name: "JSON",
[10551] Fix | Delete
[10552] Fix | Delete
/**
[10553] Fix | Delete
* Return content to be printed before all file results.
[10554] Fix | Delete
* @return {String} to prepend before all results
[10555] Fix | Delete
*/
[10556] Fix | Delete
startFormat: function() {
[10557] Fix | Delete
"use strict";
[10558] Fix | Delete
this.json = [];
[10559] Fix | Delete
return "";
[10560] Fix | Delete
},
[10561] Fix | Delete
[10562] Fix | Delete
/**
[10563] Fix | Delete
* Return content to be printed after all file results.
[10564] Fix | Delete
* @return {String} to append after all results
[10565] Fix | Delete
*/
[10566] Fix | Delete
endFormat: function() {
[10567] Fix | Delete
"use strict";
[10568] Fix | Delete
var ret = "";
[10569] Fix | Delete
if (this.json.length > 0) {
[10570] Fix | Delete
if (this.json.length === 1) {
[10571] Fix | Delete
ret = JSON.stringify(this.json[0]);
[10572] Fix | Delete
} else {
[10573] Fix | Delete
ret = JSON.stringify(this.json);
[10574] Fix | Delete
}
[10575] Fix | Delete
}
[10576] Fix | Delete
return ret;
[10577] Fix | Delete
},
[10578] Fix | Delete
[10579] Fix | Delete
/**
[10580] Fix | Delete
* Given CSS Lint results for a file, return output for this format.
[10581] Fix | Delete
* @param results {Object} with error and warning messages
[10582] Fix | Delete
* @param filename {String} relative file path (Unused)
[10583] Fix | Delete
* @return {String} output for results
[10584] Fix | Delete
*/
[10585] Fix | Delete
formatResults: function(results, filename, options) {
[10586] Fix | Delete
"use strict";
[10587] Fix | Delete
if (results.messages.length > 0 || !options.quiet) {
[10588] Fix | Delete
this.json.push({
[10589] Fix | Delete
filename: filename,
[10590] Fix | Delete
messages: results.messages,
[10591] Fix | Delete
stats: results.stats
[10592] Fix | Delete
});
[10593] Fix | Delete
}
[10594] Fix | Delete
return "";
[10595] Fix | Delete
}
[10596] Fix | Delete
});
[10597] Fix | Delete
[10598] Fix | Delete
CSSLint.addFormatter({
[10599] Fix | Delete
// format information
[10600] Fix | Delete
id: "junit-xml",
[10601] Fix | Delete
name: "JUNIT XML format",
[10602] Fix | Delete
[10603] Fix | Delete
/**
[10604] Fix | Delete
* Return opening root XML tag.
[10605] Fix | Delete
* @return {String} to prepend before all results
[10606] Fix | Delete
*/
[10607] Fix | Delete
startFormat: function() {
[10608] Fix | Delete
"use strict";
[10609] Fix | Delete
return "<?xml version=\"1.0\" encoding=\"utf-8\"?><testsuites>";
[10610] Fix | Delete
},
[10611] Fix | Delete
[10612] Fix | Delete
/**
[10613] Fix | Delete
* Return closing root XML tag.
[10614] Fix | Delete
* @return {String} to append after all results
[10615] Fix | Delete
*/
[10616] Fix | Delete
endFormat: function() {
[10617] Fix | Delete
"use strict";
[10618] Fix | Delete
return "</testsuites>";
[10619] Fix | Delete
},
[10620] Fix | Delete
[10621] Fix | Delete
/**
[10622] Fix | Delete
* Given CSS Lint results for a file, return output for this format.
[10623] Fix | Delete
* @param results {Object} with error and warning messages
[10624] Fix | Delete
* @param filename {String} relative file path
[10625] Fix | Delete
* @param options {Object} (UNUSED for now) specifies special handling of output
[10626] Fix | Delete
* @return {String} output for results
[10627] Fix | Delete
*/
[10628] Fix | Delete
formatResults: function(results, filename/*, options*/) {
[10629] Fix | Delete
"use strict";
[10630] Fix | Delete
[10631] Fix | Delete
var messages = results.messages,
[10632] Fix | Delete
output = [],
[10633] Fix | Delete
tests = {
[10634] Fix | Delete
"error": 0,
[10635] Fix | Delete
"failure": 0
[10636] Fix | Delete
};
[10637] Fix | Delete
[10638] Fix | Delete
/**
[10639] Fix | Delete
* Generate a source string for a rule.
[10640] Fix | Delete
* JUNIT source strings usually resemble Java class names e.g
[10641] Fix | Delete
* net.csslint.SomeRuleName
[10642] Fix | Delete
* @param {Object} rule
[10643] Fix | Delete
* @return rule source as {String}
[10644] Fix | Delete
*/
[10645] Fix | Delete
var generateSource = function(rule) {
[10646] Fix | Delete
if (!rule || !("name" in rule)) {
[10647] Fix | Delete
return "";
[10648] Fix | Delete
}
[10649] Fix | Delete
return "net.csslint." + rule.name.replace(/\s/g, "");
[10650] Fix | Delete
};
[10651] Fix | Delete
[10652] Fix | Delete
/**
[10653] Fix | Delete
* Replace special characters before write to output.
[10654] Fix | Delete
*
[10655] Fix | Delete
* Rules:
[10656] Fix | Delete
* - single quotes is the escape sequence for double-quotes
[10657] Fix | Delete
* - &lt; is the escape sequence for <
[10658] Fix | Delete
* - &gt; is the escape sequence for >
[10659] Fix | Delete
*
[10660] Fix | Delete
* @param {String} message to escape
[10661] Fix | Delete
* @return escaped message as {String}
[10662] Fix | Delete
*/
[10663] Fix | Delete
var escapeSpecialCharacters = function(str) {
[10664] Fix | Delete
[10665] Fix | Delete
if (!str || str.constructor !== String) {
[10666] Fix | Delete
return "";
[10667] Fix | Delete
}
[10668] Fix | Delete
[10669] Fix | Delete
return str.replace(/"/g, "'").replace(/</g, "&lt;").replace(/>/g, "&gt;");
[10670] Fix | Delete
[10671] Fix | Delete
};
[10672] Fix | Delete
[10673] Fix | Delete
if (messages.length > 0) {
[10674] Fix | Delete
[10675] Fix | Delete
messages.forEach(function (message) {
[10676] Fix | Delete
[10677] Fix | Delete
// since junit has no warning class
[10678] Fix | Delete
// all issues as errors
[10679] Fix | Delete
var type = message.type === "warning" ? "error" : message.type;
[10680] Fix | Delete
[10681] Fix | Delete
// ignore rollups for now
[10682] Fix | Delete
if (!message.rollup) {
[10683] Fix | Delete
[10684] Fix | Delete
// build the test case separately, once joined
[10685] Fix | Delete
// we'll add it to a custom array filtered by type
[10686] Fix | Delete
output.push("<testcase time=\"0\" name=\"" + generateSource(message.rule) + "\">");
[10687] Fix | Delete
output.push("<" + type + " message=\"" + escapeSpecialCharacters(message.message) + "\"><![CDATA[" + message.line + ":" + message.col + ":" + escapeSpecialCharacters(message.evidence) + "]]></" + type + ">");
[10688] Fix | Delete
output.push("</testcase>");
[10689] Fix | Delete
[10690] Fix | Delete
tests[type] += 1;
[10691] Fix | Delete
[10692] Fix | Delete
}
[10693] Fix | Delete
[10694] Fix | Delete
});
[10695] Fix | Delete
[10696] Fix | Delete
output.unshift("<testsuite time=\"0\" tests=\"" + messages.length + "\" skipped=\"0\" errors=\"" + tests.error + "\" failures=\"" + tests.failure + "\" package=\"net.csslint\" name=\"" + filename + "\">");
[10697] Fix | Delete
output.push("</testsuite>");
[10698] Fix | Delete
[10699] Fix | Delete
}
[10700] Fix | Delete
[10701] Fix | Delete
return output.join("");
[10702] Fix | Delete
[10703] Fix | Delete
}
[10704] Fix | Delete
});
[10705] Fix | Delete
[10706] Fix | Delete
CSSLint.addFormatter({
[10707] Fix | Delete
// format information
[10708] Fix | Delete
id: "lint-xml",
[10709] Fix | Delete
name: "Lint XML format",
[10710] Fix | Delete
[10711] Fix | Delete
/**
[10712] Fix | Delete
* Return opening root XML tag.
[10713] Fix | Delete
* @return {String} to prepend before all results
[10714] Fix | Delete
*/
[10715] Fix | Delete
startFormat: function() {
[10716] Fix | Delete
"use strict";
[10717] Fix | Delete
return "<?xml version=\"1.0\" encoding=\"utf-8\"?><lint>";
[10718] Fix | Delete
},
[10719] Fix | Delete
[10720] Fix | Delete
/**
[10721] Fix | Delete
* Return closing root XML tag.
[10722] Fix | Delete
* @return {String} to append after all results
[10723] Fix | Delete
*/
[10724] Fix | Delete
endFormat: function() {
[10725] Fix | Delete
"use strict";
[10726] Fix | Delete
return "</lint>";
[10727] Fix | Delete
},
[10728] Fix | Delete
[10729] Fix | Delete
/**
[10730] Fix | Delete
* Given CSS Lint results for a file, return output for this format.
[10731] Fix | Delete
* @param results {Object} with error and warning messages
[10732] Fix | Delete
* @param filename {String} relative file path
[10733] Fix | Delete
* @param options {Object} (UNUSED for now) specifies special handling of output
[10734] Fix | Delete
* @return {String} output for results
[10735] Fix | Delete
*/
[10736] Fix | Delete
formatResults: function(results, filename/*, options*/) {
[10737] Fix | Delete
"use strict";
[10738] Fix | Delete
var messages = results.messages,
[10739] Fix | Delete
output = [];
[10740] Fix | Delete
[10741] Fix | Delete
/**
[10742] Fix | Delete
* Replace special characters before write to output.
[10743] Fix | Delete
*
[10744] Fix | Delete
* Rules:
[10745] Fix | Delete
* - single quotes is the escape sequence for double-quotes
[10746] Fix | Delete
* - &amp; is the escape sequence for &
[10747] Fix | Delete
* - &lt; is the escape sequence for <
[10748] Fix | Delete
* - &gt; is the escape sequence for >
[10749] Fix | Delete
*
[10750] Fix | Delete
* @param {String} message to escape
[10751] Fix | Delete
* @return escaped message as {String}
[10752] Fix | Delete
*/
[10753] Fix | Delete
var escapeSpecialCharacters = function(str) {
[10754] Fix | Delete
if (!str || str.constructor !== String) {
[10755] Fix | Delete
return "";
[10756] Fix | Delete
}
[10757] Fix | Delete
return str.replace(/"/g, "'").replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
[10758] Fix | Delete
};
[10759] Fix | Delete
[10760] Fix | Delete
if (messages.length > 0) {
[10761] Fix | Delete
[10762] Fix | Delete
output.push("<file name=\""+filename+"\">");
[10763] Fix | Delete
CSSLint.Util.forEach(messages, function (message) {
[10764] Fix | Delete
if (message.rollup) {
[10765] Fix | Delete
output.push("<issue severity=\"" + message.type + "\" reason=\"" + escapeSpecialCharacters(message.message) + "\" evidence=\"" + escapeSpecialCharacters(message.evidence) + "\"/>");
[10766] Fix | Delete
} else {
[10767] Fix | Delete
var rule = "";
[10768] Fix | Delete
if (message.rule && message.rule.id) {
[10769] Fix | Delete
rule = "rule=\"" + escapeSpecialCharacters(message.rule.id) + "\" ";
[10770] Fix | Delete
}
[10771] Fix | Delete
output.push("<issue " + rule + "line=\"" + message.line + "\" char=\"" + message.col + "\" severity=\"" + message.type + "\"" +
[10772] Fix | Delete
" reason=\"" + escapeSpecialCharacters(message.message) + "\" evidence=\"" + escapeSpecialCharacters(message.evidence) + "\"/>");
[10773] Fix | Delete
}
[10774] Fix | Delete
});
[10775] Fix | Delete
output.push("</file>");
[10776] Fix | Delete
}
[10777] Fix | Delete
[10778] Fix | Delete
return output.join("");
[10779] Fix | Delete
}
[10780] Fix | Delete
});
[10781] Fix | Delete
[10782] Fix | Delete
CSSLint.addFormatter({
[10783] Fix | Delete
// format information
[10784] Fix | Delete
id: "text",
[10785] Fix | Delete
name: "Plain Text",
[10786] Fix | Delete
[10787] Fix | Delete
/**
[10788] Fix | Delete
* Return content to be printed before all file results.
[10789] Fix | Delete
* @return {String} to prepend before all results
[10790] Fix | Delete
*/
[10791] Fix | Delete
startFormat: function() {
[10792] Fix | Delete
"use strict";
[10793] Fix | Delete
return "";
[10794] Fix | Delete
},
[10795] Fix | Delete
[10796] Fix | Delete
/**
[10797] Fix | Delete
* Return content to be printed after all file results.
[10798] Fix | Delete
* @return {String} to append after all results
[10799] Fix | Delete
*/
[10800] Fix | Delete
endFormat: function() {
[10801] Fix | Delete
"use strict";
[10802] Fix | Delete
return "";
[10803] Fix | Delete
},
[10804] Fix | Delete
[10805] Fix | Delete
/**
[10806] Fix | Delete
* Given CSS Lint results for a file, return output for this format.
[10807] Fix | Delete
* @param results {Object} with error and warning messages
[10808] Fix | Delete
* @param filename {String} relative file path
[10809] Fix | Delete
* @param options {Object} (Optional) specifies special handling of output
[10810] Fix | Delete
* @return {String} output for results
[10811] Fix | Delete
*/
[10812] Fix | Delete
formatResults: function(results, filename, options) {
[10813] Fix | Delete
"use strict";
[10814] Fix | Delete
var messages = results.messages,
[10815] Fix | Delete
output = "";
[10816] Fix | Delete
options = options || {};
[10817] Fix | Delete
[10818] Fix | Delete
if (messages.length === 0) {
[10819] Fix | Delete
return options.quiet ? "" : "\n\ncsslint: No errors in " + filename + ".";
[10820] Fix | Delete
}
[10821] Fix | Delete
[10822] Fix | Delete
output = "\n\ncsslint: There ";
[10823] Fix | Delete
if (messages.length === 1) {
[10824] Fix | Delete
output += "is 1 problem";
[10825] Fix | Delete
} else {
[10826] Fix | Delete
output += "are " + messages.length + " problems";
[10827] Fix | Delete
}
[10828] Fix | Delete
output += " in " + filename + ".";
[10829] Fix | Delete
[10830] Fix | Delete
var pos = filename.lastIndexOf("/"),
[10831] Fix | Delete
shortFilename = filename;
[10832] Fix | Delete
[10833] Fix | Delete
if (pos === -1) {
[10834] Fix | Delete
pos = filename.lastIndexOf("\\");
[10835] Fix | Delete
}
[10836] Fix | Delete
if (pos > -1) {
[10837] Fix | Delete
shortFilename = filename.substring(pos+1);
[10838] Fix | Delete
}
[10839] Fix | Delete
[10840] Fix | Delete
CSSLint.Util.forEach(messages, function (message, i) {
[10841] Fix | Delete
output = output + "\n\n" + shortFilename;
[10842] Fix | Delete
if (message.rollup) {
[10843] Fix | Delete
output += "\n" + (i+1) + ": " + message.type;
[10844] Fix | Delete
output += "\n" + message.message;
[10845] Fix | Delete
} else {
[10846] Fix | Delete
output += "\n" + (i+1) + ": " + message.type + " at line " + message.line + ", col " + message.col;
[10847] Fix | Delete
output += "\n" + message.message;
[10848] Fix | Delete
output += "\n" + message.evidence;
[10849] Fix | Delete
}
[10850] Fix | Delete
});
[10851] Fix | Delete
[10852] Fix | Delete
return output;
[10853] Fix | Delete
}
[10854] Fix | Delete
});
[10855] Fix | Delete
[10856] Fix | Delete
return CSSLint;
[10857] Fix | Delete
})();
[10858] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function