# 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: Make sure !important is not overused, this could lead to specificity # * war. Display a warning on !important declarations, an error if it's # * used more at least 10 times. # */ # /*global CSSLint*/ # CSSLint.addRule({ # # //rule information # id: "important", # name: "Disallow !important", # desc: "Be careful when using !important declaration", # browsers: "All", # # //initialization # init: function(parser, reporter){ # var rule = this, # count = 0; # # //warn that important is used and increment the declaration counter # parser.addListener("property", function(event){ # if (event.important === true){ # count++; # reporter.report("Use of !important", event.line, event.col, rule); # } # }); # # //if there are more than 10, show an error # parser.addListener("endstylesheet", function(){ # reporter.stat("important", count); # if (count >= 10){ # reporter.rollupWarn("Too many !important declarations (" + count + "), try to use less than 10 to avoid specificity issues.", rule); # } # }); # } # # });