Skip to content
Browse files

Whitespace cleanup.

Remove trailing spaces and use 4 spaces consistently for indentation.
  • Loading branch information...
1 parent a0bce62 commit 0f43dda129cc967e408ea760f26ab793b2534bfb @XhmikosR XhmikosR committed
Showing with 2,415 additions and 2,415 deletions.
  1. +22 −22 Gruntfile.js
  2. +1 −1 demos/demo.css
  3. +133 −133 release/csslint-node.js
  4. +447 −447 release/csslint-rhino.js
  5. +97 −97 release/csslint-tests.js
  6. +444 −444 release/csslint-worker.js
  7. +443 −443 release/csslint-wsh.js
  8. +443 −443 release/csslint.js
  9. +7 −7 release/npm/cli.js
  10. +133 −133 release/npm/lib/csslint-node.js
  11. +7 −7 src/cli/node.js
  12. +4 −4 src/cli/rhino.js
  13. +1 −1 src/core/Reporter.js
  14. +3 −3 src/formatters/checkstyle-xml.js
  15. +2 −2 src/formatters/compact.js
  16. +1 −1 src/formatters/csslint-xml.js
  17. +2 −2 src/formatters/lint-xml.js
  18. +2 −2 src/formatters/text.js
  19. +9 −9 src/rules/box-model.js
  20. +2 −2 src/rules/box-sizing.js
  21. +5 −5 src/rules/compatible-vendor-prefixes.js
  22. +5 −5 src/rules/display-property-grouping.js
  23. +11 −11 src/rules/duplicate-properties.js
  24. +14 −14 src/rules/fallback-colors.js
  25. +3 −3 src/rules/gradients.js
  26. +2 −2 src/rules/import.js
  27. +9 −9 src/rules/outline-none.js
  28. +6 −6 src/rules/overqualified-elements.js
  29. +2 −2 src/rules/selector-max-approaching.js
  30. +2 −2 src/rules/selector-max.js
  31. +15 −15 src/rules/shorthand.js
  32. +6 −6 src/rules/unique-headings.js
  33. +1 −1 src/rules/universal-selector.js
  34. +5 −5 src/rules/unqualified-attributes.js
  35. +24 −24 src/rules/vendor-prefix.js
  36. +1 −1 src/rules/zero-units.js
  37. +1 −1 src/worker/Worker.js
  38. +6 −6 tests/core/Reporter.js
  39. +3 −3 tests/css/width-100.html
  40. +2 −2 tests/formatters/compact.js
  41. +1 −1 tests/formatters/csslint-xml.js
  42. +1 −1 tests/formatters/junit-xml.js
  43. +1 −1 tests/formatters/lint-xml.js
  44. +2 −2 tests/formatters/text.js
  45. +1 −1 tests/rules/adjoining-classes.js
  46. +8 −8 tests/rules/box-model.js
  47. +10 −10 tests/rules/compatible-vendor-prefixes.js
  48. +1 −1 tests/rules/display-property-grouping.js
  49. +5 −5 tests/rules/duplicate-properties.js
  50. +16 −16 tests/rules/fallback-colors.js
  51. +1 −1 tests/rules/font-sizes.js
  52. +3 −3 tests/rules/gradients.js
  53. +1 −1 tests/rules/import.js
  54. +3 −3 tests/rules/known-properties.js
  55. +2 −2 tests/rules/outline-none.js
  56. +2 −2 tests/rules/overqualified-elements.js
  57. +7 −7 tests/rules/selector-max-approaching.js
  58. +7 −7 tests/rules/selector-max.js
  59. +2 −2 tests/rules/shorthand.js
  60. +1 −1 tests/rules/unique-headings.js
  61. +2 −2 tests/rules/universal-selector.js
  62. +4 −4 tests/rules/unqualified-attributes.js
  63. +5 −5 tests/rules/vendor-prefix.js
  64. +3 −3 tests/rules/zero-units.js
View
44 Gruntfile.js
@@ -217,25 +217,25 @@ module.exports = function(grunt) {
});
// These plugins provide necessary tasks.
+ grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-concat');
+ grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-watch');
- grunt.loadNpmTasks('grunt-contrib-clean');
- grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-include-replace');
// Default task.
grunt.registerTask('default', ['test']);
-
- //Alias for
+
+ //Alias for
grunt.registerTask('lint', ['jshint']);
-
+
//Testing
grunt.registerTask('test', ['clean:build', 'jshint', 'concat', 'yuitest']);
grunt.registerTask('rhino', ['clean:build', 'jshint', 'concat', 'test_rhino']);
grunt.registerTask('release', ['test', 'clean:release', 'copy:release', 'includereplace:release', 'changelog']);
-
+
//Run the YUITest suite
grunt.registerMultiTask('yuitest', 'Run the YUITests for the project', function() {
/*jshint evil:true, node: true */
@@ -249,12 +249,12 @@ module.exports = function(grunt) {
var errors = [],
failures = [],
stack = [];
-
+
//Eval each file so the tests are brought into this scope where CSSLint and YUITest are loaded already
files.forEach(function(filepath) {
eval(grunt.file.read(filepath));
});
-
+
// From YUITest Node CLI
function filterStackTrace(stackTrace){
if (stackTrace){
@@ -276,7 +276,7 @@ module.exports = function(grunt) {
return "Unavailable.";
}
}
-
+
// From YUITest Node CLI with minor colourization changes
function handleEvent(event){
@@ -387,8 +387,8 @@ module.exports = function(grunt) {
var done = this.async();
var lastTag;
var files = this.filesSrc;
-
-
+
+
grunt.util.spawn({
cmd: 'git',
args: ['tag']
@@ -399,26 +399,26 @@ module.exports = function(grunt) {
major = parseInt(semver[0], 10),
minor = parseInt(semver[1], 10),
patch = parseInt(semver[2], 10);
-
- //A simple array sort can't be used because of the comparison of
+
+ //A simple array sort can't be used because of the comparison of
//the strings '0.9.9' > '0.9.10'
for (var i = 1, len = tags.length; i < len; i++) {
semver = tags[i].replace('v','').split('.');
-
+
var currentMajor = parseInt(semver[0], 10);
if (currentMajor < major) {
continue;
} else if (currentMajor > major) {
major = currentMajor;
}
-
+
var currentMinor = parseInt(semver[1], 10);
if (currentMinor < minor) {
continue;
} else if (currentMinor > minor) {
minor = currentMinor;
}
-
+
var currentPatch = parseInt(semver[2], 10);
if (currentPatch < patch) {
continue;
@@ -428,9 +428,9 @@ module.exports = function(grunt) {
}
lastTag = 'v' + major + '.' + minor + '.' + patch;
-
+
grunt.verbose.write('Last tag: ' + lastTag).writeln();
-
+
//
grunt.util.spawn({
cmd: 'git',
@@ -445,9 +445,9 @@ module.exports = function(grunt) {
grunt.file.read(files[0]);
grunt.file.write(files[0], grunt.template.process(template));
-
+
done();
- });
+ });
});
});
@@ -457,13 +457,13 @@ module.exports = function(grunt) {
var done = this.async();
var files = this.filesSrc;
var progress = files.length;
-
+
files.forEach(function(filepath) {
grunt.util.spawn({
cmd: 'java',
args: ['-jar', 'lib/js.jar', 'lib/yuitest-rhino-cli.js', 'build/csslint.js', filepath],
opts: {stdio: 'inherit'}
- }, function(error, result, code) {
+ }, function(error, result, code) {
progress--;
if (progress === 0) {
done();
View
2 demos/demo.css
@@ -28,7 +28,7 @@ li.last.first {
}
-@charset "UTF-8";
+@charset "UTF-8";
@page {
margin: 10%;
View
266 release/csslint-node.js
@@ -294,7 +294,7 @@ function Reporter(lines, ruleset){
* @type String[]
*/
this.lines = lines;
-
+
/**
* Information about the rules. Used to determine whether an issue is an
* error or warning.
@@ -532,7 +532,7 @@ CSSLint.addRule({
/*global CSSLint*/
/*
- * Rule: Don't use width or height when using padding or border.
+ * Rule: Don't use width or height when using padding or border.
*/
CSSLint.addRule({
@@ -571,7 +571,7 @@ CSSLint.addRule({
function endRule(){
var prop, value;
-
+
if (!boxSizing) {
if (properties.height){
for (prop in heightProperties){
@@ -589,25 +589,25 @@ CSSLint.addRule({
for (prop in widthProperties){
if (widthProperties.hasOwnProperty(prop) && properties[prop]){
value = properties[prop].value;
-
+
if (!(prop == "padding" && value.parts.length === 2 && value.parts[1].value === 0)){
reporter.report("Using width with " + prop + " can sometimes make elements larger than you expect.", properties[prop].line, properties[prop].col, rule);
}
}
}
- }
- }
+ }
+ }
}
parser.addListener("startrule", startRule);
parser.addListener("startfontface", startRule);
parser.addListener("startpage", startRule);
parser.addListener("startpagemargin", startRule);
- parser.addListener("startkeyframerule", startRule);
+ parser.addListener("startkeyframerule", startRule);
parser.addListener("property", function(event){
var name = event.property.text.toLowerCase();
-
+
if (heightProperties[name] || widthProperties[name]){
if (!/^0\S*$/.test(event.value) && !(name == "border" && event.value == "none")){
properties[name] = { line: event.property.line, col: event.property.col, value: event.value };
@@ -619,14 +619,14 @@ CSSLint.addRule({
boxSizing = true;
}
}
-
+
});
parser.addListener("endrule", endRule);
parser.addListener("endfontface", endRule);
parser.addListener("endpage", endRule);
parser.addListener("endpagemargin", endRule);
- parser.addListener("endkeyframerule", endRule);
+ parser.addListener("endkeyframerule", endRule);
}
});
@@ -650,11 +650,11 @@ CSSLint.addRule({
parser.addListener("property", function(event){
var name = event.property.text.toLowerCase();
-
+
if (name == "box-sizing"){
reporter.report("The box-sizing property isn't supported in IE6 and IE7.", event.line, event.col, rule);
}
- });
+ });
}
});
@@ -728,7 +728,7 @@ CSSLint.addRule({
* Rule: Include all compatible vendor prefixes to reach a wider
* range of users.
*/
-/*global CSSLint*/
+/*global CSSLint*/
CSSLint.addRule({
//rule information
@@ -824,7 +824,7 @@ CSSLint.addRule({
arrayPush.apply(applyTo, variations);
}
}
-
+
parser.addListener("startrule", function () {
properties = [];
});
@@ -840,9 +840,9 @@ CSSLint.addRule({
parser.addListener("property", function (event) {
var name = event.property;
if (CSSLint.Util.indexOf(applyTo, name.text) > -1) {
-
+
// e.g., -moz-transform is okay to be alone in @-moz-keyframes
- if (!inKeyFrame || typeof inKeyFrame != "string" ||
+ if (!inKeyFrame || typeof inKeyFrame != "string" ||
name.text.indexOf("-" + inKeyFrame + "-") !== 0) {
properties.push(name);
}
@@ -900,7 +900,7 @@ CSSLint.addRule({
item = full[i];
if (CSSLint.Util.indexOf(actual, item) === -1) {
propertiesSpecified = (actual.length === 1) ? actual[0] : (actual.length == 2) ? actual.join(" and ") : actual.join(", ");
- reporter.report("The property " + item + " is compatible with " + propertiesSpecified + " and should be included as well.", value.actualNodes[0].line, value.actualNodes[0].col, rule);
+ reporter.report("The property " + item + " is compatible with " + propertiesSpecified + " and should be included as well.", value.actualNodes[0].line, value.actualNodes[0].col, rule);
}
}
@@ -911,7 +911,7 @@ CSSLint.addRule({
}
});
/*
- * Rule: Certain properties don't play well with certain display values.
+ * Rule: Certain properties don't play well with certain display values.
* - float should not be used with inline-block
* - height, width, margin-top, margin-bottom, float should not be used with inline
* - vertical-align should not be used with block
@@ -956,7 +956,7 @@ CSSLint.addRule({
}
}
}
-
+
function startRule(){
properties = {};
}
@@ -973,7 +973,7 @@ CSSLint.addRule({
reportProperty("width", display);
reportProperty("margin", display);
reportProperty("margin-top", display);
- reportProperty("margin-bottom", display);
+ reportProperty("margin-bottom", display);
reportProperty("float", display, "display:inline has no effect on floated elements (but may be used to fix the IE6 double-margin bug).");
break;
@@ -1001,7 +1001,7 @@ CSSLint.addRule({
//otherwise do nothing
}
}
-
+
}
parser.addListener("startrule", startRule);
@@ -1014,7 +1014,7 @@ 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 };
}
});
@@ -1081,32 +1081,32 @@ CSSLint.addRule({
init: function(parser, reporter){
var rule = this,
properties,
- lastProperty;
-
+ lastProperty;
+
function startRule(event){
- properties = {};
+ properties = {};
}
-
+
parser.addListener("startrule", startRule);
parser.addListener("startfontface", startRule);
parser.addListener("startpage", startRule);
parser.addListener("startpagemargin", startRule);
- parser.addListener("startkeyframerule", startRule);
-
+ parser.addListener("startkeyframerule", startRule);
+
parser.addListener("property", function(event){
var property = event.property,
name = property.text.toLowerCase();
-
+
if (properties[name] && (lastProperty != name || properties[name] == event.value.text)){
reporter.report("Duplicate property '" + event.property + "' found.", event.line, event.col, rule);
}
-
+
properties[name] = event.value.text;
lastProperty = name;
-
+
});
-
-
+
+
}
});
@@ -1197,35 +1197,35 @@ CSSLint.addRule({
"background-color": 1
},
properties;
-
+
function startRule(event){
- properties = {};
- lastProperty = null;
+ properties = {};
+ lastProperty = null;
}
-
+
parser.addListener("startrule", startRule);
parser.addListener("startfontface", startRule);
parser.addListener("startpage", startRule);
parser.addListener("startpagemargin", startRule);
- parser.addListener("startkeyframerule", startRule);
-
+ parser.addListener("startkeyframerule", startRule);
+
parser.addListener("property", function(event){
var property = event.property,
name = property.text.toLowerCase(),
parts = event.value.parts,
- i = 0,
+ i = 0,
colorType = "",
- len = parts.length;
-
+ len = parts.length;
+
if(propertiesToCheck[name]){
while(i < len){
if (parts[i].type == "color"){
if ("alpha" in parts[i] || "hue" in parts[i]){
-
+
if (/([^\)]+)\(/.test(parts[i])){
colorType = RegExp.$1.toUpperCase();
}
-
+
if (!lastProperty || (lastProperty.property.text.toLowerCase() != name || lastProperty.colorType != "compat")){
reporter.report("Fallback " + name + " (hex or RGB) should precede " + colorType + " " + name + ".", event.line, event.col, rule);
}
@@ -1233,14 +1233,14 @@ CSSLint.addRule({
event.colorType = "compat";
}
}
-
+
i++;
}
}
lastProperty = event;
- });
-
+ });
+
}
});
@@ -1391,7 +1391,7 @@ CSSLint.addRule({
if (!gradients.webkit){
missing.push("Webkit (Safari 5+, Chrome)");
}
-
+
if (!gradients.oldWebkit){
missing.push("Old Webkit (Safari 4+, Chrome)");
}
@@ -1400,8 +1400,8 @@ CSSLint.addRule({
missing.push("Opera 11.1+");
}
- if (missing.length && missing.length < 4){
- reporter.report("Missing vendor-prefixed CSS gradients for " + missing.join(", ") + ".", event.selectors[0].line, event.selectors[0].col, rule);
+ if (missing.length && missing.length < 4){
+ reporter.report("Missing vendor-prefixed CSS gradients for " + missing.join(", ") + ".", event.selectors[0].line, event.selectors[0].col, rule);
}
});
@@ -1475,8 +1475,8 @@ CSSLint.addRule({
//initialization
init: function(parser, reporter){
var rule = this;
-
- parser.addListener("import", function(event){
+
+ parser.addListener("import", function(event){
reporter.report("@import prevents parallel downloads, use <link> instead.", event.line, event.col, rule);
});
@@ -1581,14 +1581,14 @@ CSSLint.addRule({
lastRule = null;
}
}
-
+
function endRule(event){
if (lastRule){
if (lastRule.outline){
if (lastRule.selectors.toString().toLowerCase().indexOf(":focus") == -1){
reporter.report("Outlines should only be modified using :focus.", lastRule.line, lastRule.col, rule);
} else if (lastRule.propCount == 1) {
- reporter.report("Outlines shouldn't be hidden unless other visual changes are made.", lastRule.line, lastRule.col, rule);
+ reporter.report("Outlines shouldn't be hidden unless other visual changes are made.", lastRule.line, lastRule.col, rule);
}
}
}
@@ -1598,26 +1598,26 @@ CSSLint.addRule({
parser.addListener("startfontface", startRule);
parser.addListener("startpage", startRule);
parser.addListener("startpagemargin", startRule);
- parser.addListener("startkeyframerule", startRule);
+ parser.addListener("startkeyframerule", startRule);
parser.addListener("property", function(event){
var name = event.property.text.toLowerCase(),
- value = event.value;
-
+ value = event.value;
+
if (lastRule){
lastRule.propCount++;
if (name == "outline" && (value == "none" || value == "0")){
lastRule.outline = true;
- }
+ }
}
-
+
});
-
+
parser.addListener("endrule", endRule);
parser.addListener("endfontface", endRule);
parser.addListener("endpage", endRule);
parser.addListener("endpagemargin", endRule);
- parser.addListener("endkeyframerule", endRule);
+ parser.addListener("endkeyframerule", endRule);
}
@@ -1638,7 +1638,7 @@ CSSLint.addRule({
init: function(parser, reporter){
var rule = this,
classes = {};
-
+
parser.addListener("startrule", function(event){
var selectors = event.selectors,
selector,
@@ -1657,7 +1657,7 @@ CSSLint.addRule({
if (part.elementName && modifier.type == "id"){
reporter.report("Element (" + part + ") is overqualified, just use " + modifier + " without element name.", part.line, part.col, rule);
} else if (modifier.type == "class"){
-
+
if (!classes[modifier]){
classes[modifier] = [];
}
@@ -1668,19 +1668,19 @@ CSSLint.addRule({
}
}
});
-
+
parser.addListener("endstylesheet", function(){
-
+
var prop;
for (prop in classes){
if (classes.hasOwnProperty(prop)){
-
+
//one use means that this is overqualified
if (classes[prop].length == 1 && classes[prop][0].part.elementName){
reporter.report("Element (" + classes[prop][0].part + ") is overqualified, just use " + classes[prop][0].modifier + " without element name.", classes[prop][0].part.line, classes[prop][0].part.col, rule);
}
}
- }
+ }
});
}
@@ -1796,7 +1796,7 @@ CSSLint.addRule({
});
/*
- * Rule: Warn people with approaching the IE 4095 limit
+ * Rule: Warn people with approaching the IE 4095 limit
*/
/*global CSSLint*/
CSSLint.addRule({
@@ -1817,7 +1817,7 @@ CSSLint.addRule({
parser.addListener("endstylesheet", function() {
if (count >= 3800) {
- reporter.report("You have " + count + " selectors. Internet Explorer supports a maximum of 4095 selectors per stylesheet. Consider refactoring.",0,0,rule);
+ reporter.report("You have " + count + " selectors. Internet Explorer supports a maximum of 4095 selectors per stylesheet. Consider refactoring.",0,0,rule);
}
});
}
@@ -1825,7 +1825,7 @@ CSSLint.addRule({
});
/*
- * Rule: Warn people past the IE 4095 limit
+ * Rule: Warn people past the IE 4095 limit
*/
/*global CSSLint*/
CSSLint.addRule({
@@ -1846,7 +1846,7 @@ CSSLint.addRule({
parser.addListener("endstylesheet", function() {
if (count > 4095) {
- reporter.report("You have " + count + " selectors. Internet Explorer supports a maximum of 4095 selectors per stylesheet. Consider refactoring.",0,0,rule);
+ reporter.report("You have " + count + " selectors. Internet Explorer supports a maximum of 4095 selectors per stylesheet. Consider refactoring.",0,0,rule);
}
});
}
@@ -1854,7 +1854,7 @@ CSSLint.addRule({
});
/*
* Rule: Use shorthand properties where possible.
- *
+ *
*/
/*global CSSLint*/
CSSLint.addRule({
@@ -1864,7 +1864,7 @@ CSSLint.addRule({
name: "Require shorthand properties",
desc: "Use shorthand properties where possible.",
browsers: "All",
-
+
//initialization
init: function(parser, reporter){
var rule = this,
@@ -1883,10 +1883,10 @@ CSSLint.addRule({
"padding-bottom",
"padding-left",
"padding-right"
- ]
+ ]
};
-
- //initialize propertiesToCheck
+
+ //initialize propertiesToCheck
for (prop in mapping){
if (mapping.hasOwnProperty(prop)){
for (i=0, len=mapping[prop].length; i < len; i++){
@@ -1894,35 +1894,35 @@ CSSLint.addRule({
}
}
}
-
+
function startRule(event){
properties = {};
}
-
+
//event handler for end of rules
function endRule(event){
-
+
var prop, i, len, total;
-
+
//check which properties this rule has
for (prop in mapping){
if (mapping.hasOwnProperty(prop)){
total=0;
-
+
for (i=0, len=mapping[prop].length; i < len; i++){
total += properties[mapping[prop][i]] ? 1 : 0;
}
-
+
if (total == mapping[prop].length){
reporter.report("The properties " + mapping[prop].join(", ") + " can be replaced by " + prop + ".", event.line, event.col, rule);
}
}
}
- }
-
+ }
+
parser.addListener("startrule", startRule);
parser.addListener("startfontface", startRule);
-
+
//check for use of "font-size"
parser.addListener("property", function(event){
var name = event.property.toString().toLowerCase(),
@@ -1934,7 +1934,7 @@ CSSLint.addRule({
});
parser.addListener("endrule", endRule);
- parser.addListener("endfontface", endRule);
+ parser.addListener("endfontface", endRule);
}
@@ -2083,14 +2083,14 @@ CSSLint.addRule({
part = selector.parts[selector.parts.length-1];
if (part.elementName && /(h[1-6])/i.test(part.elementName.toString())){
-
+
for (j=0; j < part.modifiers.length; j++){
if (part.modifiers[j].type == "pseudo"){
pseudo = true;
break;
}
}
-
+
if (!pseudo){
headings[RegExp.$1]++;
if (headings[RegExp.$1] > 1) {
@@ -2100,11 +2100,11 @@ CSSLint.addRule({
}
}
});
-
+
parser.addListener("endstylesheet", function(event){
var prop,
messages = [];
-
+
for (prop in headings){
if (headings.hasOwnProperty(prop)){
if (headings[prop] > 1){
@@ -2112,11 +2112,11 @@ CSSLint.addRule({
}
}
}
-
+
if (messages.length){
reporter.rollupWarn("You have " + messages.join(", ") + " defined in this stylesheet.", rule);
}
- });
+ });
}
});
@@ -2145,7 +2145,7 @@ CSSLint.addRule({
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);
@@ -2172,7 +2172,7 @@ CSSLint.addRule({
var rule = this;
parser.addListener("startrule", function(event){
-
+
var selectors = event.selectors,
selector,
part,
@@ -2181,18 +2181,18 @@ CSSLint.addRule({
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 == "attribute" && (!part.elementName || part.elementName == "*")){
- reporter.report(rule.desc, part.line, part.col, rule);
+ reporter.report(rule.desc, part.line, part.col, rule);
}
}
}
-
- }
+
+ }
});
}
@@ -2221,70 +2221,70 @@ CSSLint.addRule({
"-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-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",
-
+
"-moz-user-select" : "user-select",
"-khtml-user-select" : "user-select",
- "-webkit-user-select" : "user-select"
+ "-webkit-user-select" : "user-select"
};
//event handler for beginning of rules
function startRule(){
properties = {};
- num=1;
+ num=1;
}
-
+
//event handler for end of rules
function endRule(event){
var prop,
@@ -2304,7 +2304,7 @@ CSSLint.addRule({
needed = needsStandard[i].needed;
actual = needsStandard[i].actual;
- if (!properties[needed]){
+ 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
@@ -2314,13 +2314,13 @@ CSSLint.addRule({
}
}
- }
-
+ }
+
parser.addListener("startrule", startRule);
parser.addListener("startfontface", startRule);
parser.addListener("startpage", startRule);
parser.addListener("startpagemargin", startRule);
- parser.addListener("startkeyframerule", startRule);
+ parser.addListener("startkeyframerule", startRule);
parser.addListener("property", function(event){
var name = event.property.text.toLowerCase();
@@ -2336,7 +2336,7 @@ CSSLint.addRule({
parser.addListener("endfontface", endRule);
parser.addListener("endpage", endRule);
parser.addListener("endpagemargin", endRule);
- parser.addListener("endkeyframerule", endRule);
+ parser.addListener("endkeyframerule", endRule);
}
});
@@ -2359,7 +2359,7 @@ CSSLint.addRule({
//count how many times "float" is used
parser.addListener("property", function(event){
var parts = event.value.parts,
- i = 0,
+ i = 0,
len = parts.length;
while(i < len){
@@ -2393,7 +2393,7 @@ CSSLint.addRule({
if (!str || str.constructor !== String) {
return "";
}
-
+
return str.replace(/[\"&><]/g, function(match) {
switch (match) {
case "\"":
@@ -2403,7 +2403,7 @@ CSSLint.addRule({
case "<":
return "&lt;";
case ">":
- return "&gt;";
+ return "&gt;";
}
});
};
@@ -2428,7 +2428,7 @@ CSSLint.addRule({
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.
@@ -2534,11 +2534,11 @@ CSSLint.addFormatter({
if (message.rollup) {
output += filename + ": " + capitalize(message.type) + " - " + message.message + "\n";
} else {
- output += filename + ": " + "line " + message.line +
+ output += filename + ": " + "line " + message.line +
", col " + message.col + ", " + capitalize(message.type) + " - " + message.message + "\n";
}
});
-
+
return output;
}
});
@@ -2583,7 +2583,7 @@ CSSLint.addFormatter({
* - &amp; is the escape sequence for &
* - &lt; is the escape sequence for <
* - &gt; is the escape sequence for >
- *
+ *
* @param {String} message to escape
* @return escaped message as {String}
*/
@@ -2756,7 +2756,7 @@ CSSLint.addFormatter({
* - &amp; is the escape sequence for &
* - &lt; is the escape sequence for <
* - &gt; is the escape sequence for >
- *
+ *
* @param {String} message to escape
* @return escaped message as {String}
*/
@@ -2768,7 +2768,7 @@ CSSLint.addFormatter({
};
if (messages.length > 0) {
-
+
output.push("<file name=\""+filename+"\">");
CSSLint.Util.forEach(messages, function (message, i) {
if (message.rollup) {
@@ -2827,7 +2827,7 @@ CSSLint.addFormatter({
shortFilename = filename;
if (pos === -1){
- pos = filename.lastIndexOf("\\");
+ pos = filename.lastIndexOf("\\");
}
if (pos > -1){
shortFilename = filename.substring(pos+1);
@@ -2844,7 +2844,7 @@ CSSLint.addFormatter({
output += "\n" + message.evidence;
}
});
-
+
return output;
}
});
View
894 release/csslint-rhino.js
447 additions, 447 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
View
194 release/csslint-tests.js
@@ -40,27 +40,27 @@
YUITest.TestRunner.add(new YUITest.TestCase({
name: "Reporter Object Tests",
-
+
"Report should cause a warning": function(){
var reporter = new CSSLint._Reporter([], { "fake-rule": 1});
reporter.report("Foo", 1, 1, { id: "fake-rule" });
-
+
Assert.areEqual(1, reporter.messages.length);
Assert.areEqual("warning", reporter.messages[0].type);
},
-
+
"Report should cause an error": function(){
var reporter = new CSSLint._Reporter([], { "fake-rule": 2});
reporter.report("Foo", 1, 1, { id: "fake-rule" });
-
+
Assert.areEqual(1, reporter.messages.length);
Assert.areEqual("error", reporter.messages[0].type);
},
-
+
"Calling error() should cause an error": function(){
var reporter = new CSSLint._Reporter([], { "fake-rule": 1});
reporter.error("Foo", 1, 1, { id: "fake-rule" });
-
+
Assert.areEqual(1, reporter.messages.length);
Assert.areEqual("error", reporter.messages[0].type);
}
@@ -135,7 +135,7 @@
},
"File with problems should list them": function() {
- var result = { messages: [
+ var result = { messages: [
{ type: 'error', line: 2, col: 1, message: 'BOGUS ERROR', evidence: 'BOGUS', rule: [] },
{ type: 'warning', line: 1, col: 1, message: 'BOGUS WARNING', evidence: 'BOGUS', rule: [] }
], stats: [] },
@@ -147,7 +147,7 @@
},
"Should output relative file paths": function() {
- var result = { messages: [
+ var result = { messages: [
{ type: 'error', line: 2, col: 1, message: 'BOGUS ERROR', evidence: 'BOGUS', rule: [] },
{ type: 'warning', line: 1, col: 1, message: 'BOGUS WARNING', evidence: 'BOGUS', rule: [] }
], stats: [] },
@@ -169,7 +169,7 @@
YUITest.TestRunner.add(new YUITest.TestCase({
name: "CSSLint XML formatter test",
-
+
"File with no problems should say so": function(){
var result = { messages: [], stats: [] },
expected = "<?xml version=\"1.0\" encoding=\"utf-8\"?><csslint></csslint>";
@@ -236,7 +236,7 @@
actual = CSSLint.format(result, "FILE", "junit-xml");
Assert.areEqual(expected, actual);
-
+
},
"Formatter should escape special characters": function() {
@@ -268,7 +268,7 @@
YUITest.TestRunner.add(new YUITest.TestCase({
name: "Lint XML formatter test",
-
+
"File with no problems should say so": function(){
var result = { messages: [], stats: [] },
expected = "<?xml version=\"1.0\" encoding=\"utf-8\"?><lint></lint>";
@@ -312,7 +312,7 @@
YUITest.TestRunner.add(new YUITest.TestCase({
name: "Text formatter",
-
+
"File with no problems should say so": function() {
var result = { messages: [], stats: [] },
actual = CSSLint.getFormatter("text").formatResults(result, "path/to/FILE", {fullPath: "/absolute/path/to/FILE"});
@@ -326,7 +326,7 @@
},
"File with problems should list them": function() {
- var result = { messages: [
+ var result = { messages: [
{ type: 'warning', line: 1, col: 1, message: 'BOGUS', evidence: 'ALSO BOGUS', rule: [] },
{ type: 'error', line: 2, col: 1, message: 'BOGUS', evidence: 'ALSO BOGUS', rule: [] }
], stats: [] },
@@ -349,7 +349,7 @@
YUITest.TestRunner.add(new YUITest.TestCase({
name: "Adjoining Selector Rule Errors",
-
+
"Adjoining classes should result in a warning": function(){
var result = CSSLint.verify(".foo.bar { }", { "adjoining-classes": 1 });
Assert.areEqual(1, result.messages.length);
@@ -393,7 +393,7 @@
var result = CSSLint.verify(".foo { width: 100px; padding: 0; }", { "box-model": 1 });
Assert.areEqual(0, result.messages.length);
},
-
+
"Using width:auto with padding should not result in a warning": function(){
var result = CSSLint.verify(".foo { width: auto; padding: 10px; }", { "box-model": 1 });
Assert.areEqual(0, result.messages.length);
@@ -408,7 +408,7 @@
var result = CSSLint.verify(".foo { height: auto; padding: 10px; }", { "box-model": 1 });
Assert.areEqual(0, result.messages.length);
},
-
+
"Using width and padding-left should result in a warning": function(){
var result = CSSLint.verify(".foo { width: 100px; padding-left: 10px; }", { "box-model": 1 });
Assert.areEqual(1, result.messages.length);
@@ -442,11 +442,11 @@
var result = CSSLint.verify(".foo { width: 100px; padding-bottom: 10px; }", { "box-model": 1 });
Assert.areEqual(0, result.messages.length);
},
-
+
"Using width and padding-to-bottom should not result in a warning": function(){
var result = CSSLint.verify(".foo { width: 100px; padding: 10px 0; }", { "box-model": 1 });
Assert.areEqual(0, result.messages.length);
- },
+ },
"Using width and border should result in a warning": function(){
var result = CSSLint.verify(".foo { width: 100px; border: 10px; }", { "box-model": 1 });
@@ -454,12 +454,12 @@
Assert.areEqual("warning", result.messages[0].type);
Assert.areEqual("Using width with border can sometimes make elements larger than you expect.", result.messages[0].message);
},
-
+
"Using width and border with box-sizing should not result in a warning": function(){
var result = CSSLint.verify(".foo { box-sizing: border-box; width: 100px; border: 10px; }", { "box-model": 1 });
Assert.areEqual(0, result.messages.length);
},
-
+
"Using width and border-left should result in a warning": function(){
var result = CSSLint.verify(".foo { width: 100px; border-left: 10px; }", { "box-model": 1 });
Assert.areEqual(1, result.messages.length);
@@ -515,11 +515,11 @@
var result = CSSLint.verify(".foo { height: 100px; padding-right: 10px; }", { "box-model": 1 });
Assert.areEqual(0, result.messages.length);
},
-
+
"Using height and padding-left-right should not result in a warning": function(){
var result = CSSLint.verify(".foo { height: 100px; padding: 0 10px; }", { "box-model": 1 });
Assert.areEqual(0, result.messages.length);
- },
+ },
"Using height and padding-top should result in a warning": function(){
var result = CSSLint.verify(".foo { height: 100px; padding-top: 10px; }", { "box-model": 1 });
@@ -734,25 +734,25 @@
/*global YUITest, CSSLint*/
var Assert = YUITest.Assert;
-
+
YUITest.TestRunner.add(new YUITest.TestCase({
-
+
name: "Compatible Vendor Prefix Warnings",
"Using -webkit-border-radius should not warn to also include -moz-border-radius.": function(){
var result = CSSLint.verify("h1 { -webkit-border-radius: 5px; }", { "compatible-vendor-prefixes": 1 });
Assert.areEqual(0, result.messages.length);
},
-
+
"Using -webkit-transition and -moz-transition should warn to also include -o-transition.": function() {
var result = CSSLint.verify("h1 { -webkit-transition: height 20px 1s; -moz-transition: height 20px 1s; }", { "compatible-vendor-prefixes": 1 });
Assert.areEqual(1, result.messages.length);
Assert.areEqual("warning", result.messages[0].type);
Assert.areEqual("The property -o-transition is compatible with -webkit-transition and -moz-transition and should be included as well.", result.messages[0].message);
Assert.areEqual(6, result.messages[0].col);
- Assert.areEqual(1, result.messages[0].line);
+ Assert.areEqual(1, result.messages[0].line);
},
-
+
"Using -webkit-transform should warn to also include -moz-transform, -ms-transform, and -o-transform.": function() {
var result = CSSLint.verify("div.box { -webkit-transform: translate(50px, 100px); }", { "compatible-vendor-prefixes": 3 });
Assert.areEqual(3, result.messages.length);
@@ -763,23 +763,23 @@
Assert.areEqual("warning", result.messages[2].type);
Assert.areEqual("The property -o-transform is compatible with -webkit-transform and should be included as well.", result.messages[2].message);
},
-
+
"Using -webkit-transform inside of an @-webkit- block shouldn't cause a warning": function(){
var result = CSSLint.verify("@-webkit-keyframes spin {0%{ -webkit-transform: rotateX(-10deg) rotateY(0deg); } 100%{ -webkit-transform: rotateX(-10deg) rotateY(-360deg); } }", { "compatible-vendor-prefixes": 1 });
Assert.areEqual(0, result.messages.length);
},
-
+
"Using all compatible vendor prefixes for animation should be allowed with no warnings.": function(){
var result = CSSLint.verify(".next:focus { -moz-animation: 'diagonal-slide' 5s 10; -webkit-animation: 'diagonal-slide' 5s 10; -ms-animation: 'diagonal-slide' 5s 10; }", { "compatible-vendor-prefixes": 1 });
Assert.areEqual(0, result.messages.length);
},
-
+
"Using box-shadow with no vendor prefixes should be allowed with no warnings.": function(){
var result = CSSLint.verify("h1 { box-shadow: 5px 5px 5px #ccc; }", { "compatible-vendor-prefixes": 1 });
Assert.areEqual(0, result.messages.length);
}
-
- }));
+
+ }));
})();
@@ -890,7 +890,7 @@
"Padding-bottom with inline should result in a warning": function(){
var result = CSSLint.verify(".foo { padding-bottom: 100px; display: inline; }", { "display-property-grouping": 1 });
Assert.areEqual(0, result.messages.length);
- },
+ },
"Vertical-align with block should result in a warning": function(){
var result = CSSLint.verify(".foo { vertical-align: bottom; display: block; }", { "display-property-grouping": 1 });
@@ -1046,33 +1046,33 @@
var result = CSSLint.verify("@page :left { margin: 5px; margin: 4px; }", { "duplicate-properties": 1 });
Assert.areEqual(0, result.messages.length);
},
-
+
"Duplicate properties not back-to-back should result in a warning": function(){
var result = CSSLint.verify(".foo { float: left; margin: 0; float: right }", { "duplicate-properties": 1 });
Assert.areEqual(1, result.messages.length);
Assert.areEqual("warning", result.messages[0].type);
Assert.areEqual("Duplicate property 'float' found.", result.messages[0].message);
},
-
+
"Duplicate properties not back-to-back with same values should result in a warning": function(){
var result = CSSLint.verify(".foo { float: left; margin: 0; float: left }", { "duplicate-properties": 1 });
Assert.areEqual(1, result.messages.length);
Assert.areEqual("warning", result.messages[0].type);
Assert.areEqual("Duplicate property 'float' found.", result.messages[0].message);
},
-
+
"Duplicate properties back-to-back with same values should result in a warning": function(){
var result = CSSLint.verify(".foo { float: left; float: left }", { "duplicate-properties": 1 });
Assert.areEqual(1, result.messages.length);
Assert.areEqual("warning", result.messages[0].type);
Assert.areEqual("Duplicate property 'float' found.", result.messages[0].message);
},
-
+
"Duplicate properties in @keyframe rules should not result in a warning": function(){
var result = CSSLint.verify("@-webkit-keyframes slide_up { from { bottom:-91px; } to { bottom:0; } }", { "duplicate-properties": 1 });
Assert.areEqual(0, result.messages.length);
}
-
+
}));
@@ -1128,24 +1128,24 @@
var result = CSSLint.verify(".hex { color: red; }", { "fallback-colors": 1 });
Assert.areEqual(0, result.messages.length);
},
-
+
"Using only a hex color should not result in a warning": function(){
var result = CSSLint.verify(".hex { color: #fff; }", { "fallback-colors": 1 });
Assert.areEqual(0, result.messages.length);
},
-
+
"Using only rgb() should not result in a warning": function(){
var result = CSSLint.verify(".rgb { color: rgb(0, 0, 0); }", { "fallback-colors": 1 });
Assert.areEqual(0, result.messages.length);
},
-
+
"Using only rgba() should result in a warning": function(){
var result = CSSLint.verify(".rgba { color: rgba(0, 0, 0, 0.5); }", { "fallback-colors": 1 });
Assert.areEqual(1, result.messages.length);
Assert.areEqual("warning", result.messages[0].type);
Assert.areEqual("Fallback color (hex or RGB) should precede RGBA color.", result.messages[0].message);
},
-
+
"Using only hsl() should result in a warning": function(){
var result = CSSLint.verify(".hsl { color: hsl(0, 0%, 0%); }", { "fallback-colors": 1 });
Assert.areEqual(1, result.messages.length);
@@ -1164,7 +1164,7 @@
var result = CSSLint.verify(".rgba { color: #fff; color: rgba(0, 0, 0, 0.5); }", { "fallback-colors": 1 });
Assert.areEqual(0, result.messages.length);
},
-
+
"Using hsl() with a fallback should not result in a warning": function(){
var result = CSSLint.verify(".hsl { color: #fff; color: hsl(0, 0%, 0%); }", { "fallback-colors": 1 });
Assert.areEqual(0, result.messages.length);
@@ -1181,7 +1181,7 @@
Assert.areEqual("warning", result.messages[0].type);
Assert.areEqual("Fallback color (hex or RGB) should precede RGBA color.", result.messages[0].message);
},
-
+
"Using hsl() with fallback color afterwards should result in a warning": function(){
var result = CSSLint.verify(".hsl { color: hsl(0, 0%, 0%); color: #fff; }", { "fallback-colors": 1 });
Assert.areEqual(1, result.messages.length);
@@ -1195,30 +1195,30 @@
Assert.areEqual("warning", result.messages[0].type);
Assert.areEqual("Fallback color (hex or RGB) should precede HSLA color.", result.messages[0].message);
},
-
+
"Using only a named background-color should not result in a warning": function(){
var result = CSSLint.verify(".hex { background-color: red; }", { "fallback-colors": 1 });
Assert.areEqual(0, result.messages.length);
},
-
+
"Using only a hex background-color should not result in a warning": function(){
var result = CSSLint.verify(".hex { background-color: #fff; }", { "fallback-colors": 1 });
Assert.areEqual(0, result.messages.length);
},
-
+
"Using only rgb() background-color should not result in a warning": function(){
var result = CSSLint.verify(".rgb { background-color: rgb(0, 0, 0); }", { "fallback-colors": 1 });
Assert.areEqual(0, result.messages.length);
},
-
+
"Using only rgba() background-color should result in a warning": function(){
var result = CSSLint.verify(".rgba { background-color: rgba(0, 0, 0, 0.5); }", { "fallback-colors": 1 });
Assert.areEqual(1, result.messages.length);
Assert.areEqual("warning", result.messages[0].type);
Assert.areEqual("Fallback background-color (hex or RGB) should precede RGBA background-color.", result.messages[0].message);
},
-
+
"Using only hsl() background-color should result in a warning": function(){
var result = CSSLint.verify(".hsl { background-color: hsl(0, 0%, 0%); }", { "fallback-colors": 1 });
Assert.areEqual(1, result.messages.length);
@@ -1237,7 +1237,7 @@
var result = CSSLint.verify(".rgba { background-color: #fff; background-color: rgba(0, 0, 0, 0.5); }", { "fallback-colors": 1 });
Assert.areEqual(0, result.messages.length);
},
-
+
"Using hsl() with a fallback background-color should not result in a warning": function(){
var result = CSSLint.verify(".hsl { background-color: #fff; background-color: hsl(0, 0%, 0%); }", { "fallback-colors": 1 });
Assert.areEqual(0, result.messages.length);
@@ -1254,7 +1254,7 @@
Assert.areEqual("warning", result.messages[0].type);
Assert.areEqual("Fallback background-color (hex or RGB) should precede RGBA background-color.", result.messages[0].message);
},
-
+
"Using hsl() with fallback background-color afterwards should result in a warning": function(){
var result = CSSLint.verify(".hsl { background-color: hsl(0, 0%, 0%); background-color: #fff; }", { "fallback-colors": 1 });
Assert.areEqual(1, result.messages.length);
@@ -1416,7 +1416,7 @@
Assert.areEqual("warning", result.messages[0].type);
Assert.areEqual("Fallback border-top (hex or RGB) should precede HSLA border-top.", result.messages[0].message);
},
-
+
// border-right color tests
"Using only a named border-right should not result in a warning": function(){
@@ -1564,7 +1564,7 @@
Assert.areEqual("warning", result.messages[0].type);
Assert.areEqual("Fallback border-bottom (hex or RGB) should precede HSLA border-bottom.", result.messages[0].message);
},
-
+
// border-left color tests
"Using only a named border-left should not result in a warning": function(){
@@ -2008,7 +2008,7 @@
Assert.areEqual("warning", result.messages[0].type);
Assert.areEqual("Fallback border-left-color (hex or RGB) should precede HSLA border-left-color.", result.messages[0].message);
}
-
+
}));
})();
@@ -2084,7 +2084,7 @@
var Assert = YUITest.Assert;
YUITest.TestRunner.add(new YUITest.TestCase({
-
+
name: "font-size Rule Errors",
"10 font-sizes should result in a warning": function(){
@@ -2115,10 +2115,10 @@
var Assert = YUITest.Assert;
YUITest.TestRunner.add(new YUITest.TestCase({
-
+
/*
-background: -moz-linear-gradient(top, #1e5799 , #2989d8 , #207cca , #7db9e8 );
-background: -webkit-gradient(linear, left top, left bottom, color-stop(,#1e5799), color-stop(,#2989d8), color-stop(,#207cca), color-stop(10,#7db9e8));
+background: -moz-linear-gradient(top, #1e5799 , #2989d8 , #207cca , #7db9e8 );
+background: -webkit-gradient(linear, left top, left bottom, color-stop(,#1e5799), color-stop(,#2989d8), color-stop(,#207cca), color-stop(10,#7db9e8));
background: -webkit-linear-gradient(top, #1e5799 ,#2989d8 ,#207cca ,#7db9e8 );
background: -o-linear-gradient(top, #1e5799 ,#2989d8 ,#207cca ,#7db9e8 );
@@ -2196,7 +2196,7 @@ background: -o-linear-gradient(top, #1e5799 ,#2989d8 ,#207cca ,#7db9e8 );
YUITest.TestRunner.add(new YUITest.TestCase({
name: "Import Rule Errors",
-
+
"Using @import should result in a warning": function(){
var result = CSSLint.verify("@import url('foo.css');", { "import": 1 });
Assert.areEqual(1, result.messages.length);
@@ -2268,12 +2268,12 @@ background: -o-linear-gradient(top, #1e5799 ,#2989d8 ,#207cca ,#7db9e8 );
"Using a vendor-prefix property should not result in a warning": function(){
var result = CSSLint.verify("h2 { -moz-border-radius: 5px; }", { "known-properties": 1 });
- Assert.areEqual(0, result.messages.length);
+ Assert.areEqual(0, result.messages.length);
},
-
+
"Using src in @font-face should not result in a warning": function(){
var result = CSSLint.verify("@font-face { src: url(foo.otf); }", { "known-properties": 1 });
- Assert.areEqual(0, result.messages.length);
+ Assert.areEqual(0, result.messages.length);
}
}));
@@ -2302,7 +2302,7 @@ background: -o-linear-gradient(top, #1e5799 ,#2989d8 ,#207cca ,#7db9e8 );
Assert.areEqual("warning", result.messages[0].type);
Assert.areEqual("Outlines should only be modified using :focus.", result.messages[0].message);
},
-
+
"Using outline: none alone with :focus should result in a warning": function(){
var result = CSSLint.verify(".foo:focus { outline: none; }", { "outline-none": 1 });
Assert.areEqual(1, result.messages.length);
@@ -2316,7 +2316,7 @@ background: -o-linear-gradient(top, #1e5799 ,#2989d8 ,#207cca ,#7db9e8 );
Assert.areEqual("warning", result.messages[0].type);
Assert.areEqual("Outlines shouldn't be hidden unless other visual changes are made.", result.messages[0].message);
},
-
+
"Using outline: none with :focus and another property should not result in a warning": function(){
var result = CSSLint.verify(".foo:focus { outline: none; border: 1px solid black; }", { "outline-none": 1 });
Assert.areEqual(0, result.messages.length);
@@ -2351,14 +2351,14 @@ background: -o-linear-gradient(top, #1e5799 ,#2989d8 ,#207cca ,#7db9e8 );
var result = CSSLint.verify(".foo { float: left;}", { "overqualified-elements": 1 });
Assert.areEqual(0, result.messages.length);
},
-
+
"Using a class with an element should result in one warning": function(){
var result = CSSLint.verify("li.foo { float: left;}", { "overqualified-elements": 1 });
Assert.areEqual(1, result.messages.length);
Assert.areEqual("warning", result.messages[0].type);
Assert.areEqual("Element (li.foo) is overqualified, just use .foo without element name.", result.messages[0].message);
},
-
+
"Using a class with two different elements should not result in a warning": function(){
var result = CSSLint.verify("li.foo { float: left;} p.foo { float: right; }", { "overqualified-elements": 1 });
Assert.areEqual(0, result.messages.length);
@@ -2455,12 +2455,12 @@ background: -o-linear-gradient(top, #1e5799 ,#2989d8 ,#207cca ,#7db9e8 );
for (i = 1; i <= 4095; i++) {
css1 += ".selector" + i + " { background:red; } ";
}
-
+
// create css2, which has 4096 rules and 4096 selectors
for (i = 1; i <= 4096; i++) {
css2 += ".selector" + i + " { background:red; } ";
}
-
+
// create css3, which has 1024 and but only 4095 selectors
for (i = 0; i <= 1022; i++) {
j = i * 4;
@@ -2473,7 +2473,7 @@ background: -o-linear-gradient(top, #1e5799 ,#2989d8 ,#207cca ,#7db9e8 );
j = i * 4;
css4 += ".selector" + (j+1) + ", .selector" + (j+2) + ", .selector" + (j+3) + ", .selector" + (j+4) + " { background:red; } ";
}
-
+
YUITest.TestRunner.add(new YUITest.TestCase({
name: "Selector Max Errors Approaching",
@@ -2484,28 +2484,28 @@ background: -o-linear-gradient(top, #1e5799 ,#2989d8 ,#207cca ,#7db9e8 );
Assert.areEqual("warning", result.messages[0].type);
Assert.areEqual("You have 4095 selectors. Internet Explorer supports a maximum of 4095 selectors per stylesheet. Consider refactoring.", result.messages[0].message);
},
-
+
"Using 4096 or more single-selector rules should result in a warning": function(){
var result = CSSLint.verify(css2, { "selector-max-approaching": 1 });
Assert.areEqual(1, result.messages.length);
Assert.areEqual("warning", result.messages[0].type);
Assert.areEqual("You have 4096 selectors. Internet Explorer supports a maximum of 4095 selectors per stylesheet. Consider refactoring.", result.messages[0].message);
},
-
+
"Using 4095 or fewer selectors should not result in a warning": function(){
var result = CSSLint.verify(css3, { "selector-max-approaching": 1 });
Assert.areEqual(1, result.messages.length);
Assert.areEqual("warning", result.messages[0].type);
Assert.areEqual("You have 4095 selectors. Internet Explorer supports a maximum of 4095 selectors per stylesheet. Consider refactoring.", result.messages[0].message);
},
-
+
"Using 4096 or more selectors should result in a warning": function(){
var result = CSSLint.verify(css4, { "selector-max-approaching": 1 });
Assert.areEqual(1, result.messages.length);
Assert.areEqual("warning", result.messages[0].type);
Assert.areEqual("You have 4096 selectors. Internet Explorer supports a maximum of 4095 selectors per stylesheet. Consider refactoring.", result.messages[0].message);
},
-
+
"Using fewer than 3800 selectors should not result in a warning": function() {
var result = CSSLint.verify(".selector1 { background: red; }", { "selector-max-approaching": 1 });
Assert.areEqual(0, result.messages.length);
@@ -2523,12 +2523,12 @@ background: -o-linear-gradient(top, #1e5799 ,#2989d8 ,#207cca ,#7db9e8 );
for (i = 1; i <= 4095; i++) {
css1 += ".selector" + i + " { background:red; } ";
}
-
+
// create css2, which has 4096 rules and 4096 selectors
for (i = 1; i <= 4096; i++) {
css2 += ".selector" + i + " { background:red; } ";
}
-
+
// create css3, which has 1024 and but only 4095 selectors
for (i = 0; i <= 1022; i++) {
j = i * 4;
@@ -2541,7 +2541,7 @@ background: -o-linear-gradient(top, #1e5799 ,#2989d8 ,#207cca ,#7db9e8 );
j = i * 4;
css4 += ".selector" + (j+1) + ", .selector" + (j+2) + ", .selector" + (j+3) + ", .selector" + (j+4) + " { background:red; } ";
}
-
+
YUITest.TestRunner.add(new YUITest.TestCase({
name: "Selector Max Errors",
@@ -2550,26 +2550,26 @@ background: -o-linear-gradient(top, #1e5799 ,#2989d8 ,#207cca ,#7db9e8 );
var result = CSSLint.verify(css1, { "selector-max": 1 });
Assert.areEqual(0, result.messages.length);
},
-
+
"Using 4096 or more single-selector rules should result in a warning": function(){
var result = CSSLint.verify(css2, { "selector-max": 1 });
Assert.areEqual(1, result.messages.length);
Assert.areEqual("warning", result.messages[0].type);
Assert.areEqual("You have 4096 selectors. Internet Explorer supports a maximum of 4095 selectors per stylesheet. Consider refactoring.", result.messages[0].message);
},
-
+
"Using 4095 or fewer selectors should not result in a warning": function(){
var result = CSSLint.verify(css3, { "selector-max": 1 });
Assert.areEqual(0, result.messages.length);
},
-
+
"Using 4096 or more selectors should result in a warning": function(){
var result = CSSLint.verify(css4, { "selector-max": 1 });
Assert.areEqual(1, result.messages.length);
Assert.areEqual("warning", result.messages[0].type);
Assert.areEqual("You have 4096 selectors. Internet Explorer supports a maximum of 4095 selectors per stylesheet. Consider refactoring.", result.messages[0].message);
}
-
+
}));
})();
@@ -2579,7 +2579,7 @@ background: -o-linear-gradient(top, #1e5799 ,#2989d8 ,#207cca ,#7db9e8 );
var Assert = YUITest.Assert;
YUITest.TestRunner.add(new YUITest.TestCase({
-
+
name: "Shorthand Rule Errors",
"All padding properties should result in a warning": function(){
@@ -2605,7 +2605,7 @@ background: -o-linear-gradient(top, #1e5799 ,#2989d8 ,#207cca ,#7db9e8 );
var result = CSSLint.verify(".foo{ margin-top: 8px;} ", {"shorthand": 1 });
Assert.areEqual(0, result.messages.length);
}
-
+
}));
})();
@@ -2757,7 +2757,7 @@ background: -o-linear-gradient(top, #1e5799 ,#2989d8 ,#207cca ,#7db9e8 );
"Defining multiple rules that contain h1 should not result in a warning": function(){
var result = CSSLint.verify("h2 a, h2 a:active, h2 a:hover, h2 a:visited, h2 a:link { color: red;}", { "unique-headings": 1 });
- Assert.areEqual(0, result.messages.length);
+ Assert.areEqual(0, result.messages.length);
}
}));
@@ -2770,7 +2770,7 @@ background: -o-linear-gradient(top, #1e5799 ,#2989d8 ,#207cca ,#7db9e8 );
var Assert = YUITest.Assert;
YUITest.TestRunner.add(new YUITest.TestCase({
-
+
name: "Universal Selector Errors",
"Using a universal selector alone should result in a warning": function(){
@@ -2791,7 +2791,7 @@ background: -o-linear-gradient(top, #1e5799 ,#2989d8 ,#207cca ,#7db9e8 );
var result = CSSLint.verify("* .foo { font-size: 10px; } ", {"universal-selector": 1 });
Assert.areEqual(0, result.messages.length);
}
-
+
}));
})();
@@ -2802,7 +2802,7 @@ background: -o-linear-gradient(top, #1e5799 ,#2989d8 ,#207cca ,#7db9e8 );
var Assert = YUITest.Assert;
YUITest.TestRunner.add(new YUITest.TestCase({
-
+
name: "Unqualified Attributes Errors",
"Using an unqualified attribute selector alone should result in a warning": function(){
@@ -2823,13 +2823,13 @@ background: -o-linear-gradient(top, #1e5799 ,#2989d8 ,#207cca ,#7db9e8 );
var result = CSSLint.verify("[type=text] .foo { font-size: 10px; } ", {"unqualified-attributes": 1 });
Assert.areEqual(0, result.messages.length);
},
-
+
"Using a qualified attribute selector should not result in a warning": function(){
var result = CSSLint.verify("input[type=text] { font-size: 10px; } ", {"unqualified-attributes": 1 });
Assert.areEqual(0, result.messages.length);
}
-
-
+
+
}));
})();
@@ -2873,35 +2873,35 @@ background: -o-linear-gradient(top, #1e5799 ,#2989d8 ,#207cca ,#7db9e8 );
Assert.areEqual("Standard property 'border-radius' should come after vendor-prefixed property '-moz-border-radius'.", result.messages[0].message);
Assert.areEqual(3, result.messages[0].line);
Assert.areEqual(5, result.messages[0].col);
-
+
},
"Using -webkit-border-bottom-left-radius with border-bottom-left-radius should not result in a warning.": function(){
var result = CSSLint.verify("h1 { -webkit-border-bottom-left-radius: 4px; border-bottom-left-radius: 4px; }", { "vendor-prefix": 1 });
Assert.areEqual(0, result.messages.length);
},
-
+
"Using -moz-border-radius-bottomleft should result in a warning.": function(){
var result = CSSLint.verify("h1 { -moz-border-radius-bottomleft: 5px; }", { "vendor-prefix": 1 });
Assert.areEqual(1, result.messages.length);
Assert.areEqual("warning", result.messages[0].type);
Assert.areEqual("Missing standard property 'border-bottom-left-radius' to go along with '-moz-border-radius-bottomleft'.", result.messages[0].message);
},
-
+
"Using -moz-box-shadow should result in a warning.": function(){
var result = CSSLint.verify("h1 { -moz-box-shadow: 5px; }", { "vendor-prefix": 1</