# This rule is taken from https://github.com/stubbornella/csslint/tree/master/src/rules # # # Copyright (c) 2011 Nicole Sullivan and Nicholas C. Zakas. All rights reserved. # TODO: Paste the CSSLint LICENSE here. # # # /* # * Rule: When using a vendor-prefixed property, make sure to # * include the standard one. # */ # /*global CSSLint*/ # 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.", # browsers: "All", # # //initialization # init: function(parser, reporter){ # 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", # # "-moz-user-select" : "user-select", # "-khtml-user-select" : "user-select", # "-webkit-user-select" : "user-select" # }; # # //event handler for beginning of rules # function startRule(){ # properties = {}; # num=1; # } # # //event handler for end of rules # function endRule(event){ # var prop, # i, len, # standard, # 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("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); # } # # });