@@ -203,6 +203,7 @@ var CSSLint = (function() {
203203 reporter ,
204204 lines ,
205205 allow = { } ,
206+ ignore = [ ] ,
206207 report ,
207208 parser = new parserlib . css . Parser ( { starHack : true , ieFilters : true ,
208209 underscoreHack : true , strict : false } ) ;
@@ -226,6 +227,29 @@ var CSSLint = (function() {
226227 }
227228 } ) ;
228229
230+ var ignoreStart = null ,
231+ ignoreEnd = null ;
232+ CSSLint . Util . forEach ( lines , function ( line , lineno ) {
233+ // Keep oldest, "unclosest" ignore:start
234+ if ( null === ignoreStart && line . match ( / \/ \* [ \t ] * c s s l i n t [ \t ] + i g n o r e : s t a r t [ \t ] * \* \/ / i) ) {
235+ ignoreStart = lineno ;
236+ }
237+
238+ if ( line . match ( / \/ \* [ \t ] * c s s l i n t [ \t ] + i g n o r e : e n d [ \t ] * \* \/ / i) ) {
239+ ignoreEnd = lineno ;
240+ }
241+
242+ if ( null !== ignoreStart && null !== ignoreEnd ) {
243+ ignore . push ( [ ignoreStart , ignoreEnd ] ) ;
244+ ignoreStart = ignoreEnd = null ;
245+ }
246+ } ) ;
247+
248+ // Close remaining ignore block, if any
249+ if ( null !== ignoreStart ) {
250+ ignore . push ( [ ignoreStart , lines . length ] ) ;
251+ }
252+
229253 if ( ! ruleset ) {
230254 ruleset = this . getRuleset ( ) ;
231255 }
@@ -236,7 +260,7 @@ var CSSLint = (function() {
236260 ruleset = applyEmbeddedRuleset ( text , ruleset ) ;
237261 }
238262
239- reporter = new Reporter ( lines , ruleset , allow ) ;
263+ reporter = new Reporter ( lines , ruleset , allow , ignore ) ;
240264
241265 ruleset . errors = 2 ; //always report parsing errors as errors
242266 for ( i in ruleset ) {
@@ -259,7 +283,8 @@ var CSSLint = (function() {
259283 messages : reporter . messages ,
260284 stats : reporter . stats ,
261285 ruleset : reporter . ruleset ,
262- allow : reporter . allow
286+ allow : reporter . allow ,
287+ ignore : reporter . ignore
263288 } ;
264289
265290 //sort by line numbers, rollups at the bottom
@@ -292,8 +317,10 @@ var CSSLint = (function() {
292317 * @param {String[] } lines The text lines of the source.
293318 * @param {Object } ruleset The set of rules to work with, including if
294319 * they are errors or warnings.
320+ * @param {Object } explicitly allowed lines
321+ * @param {[][] } ingore list of line ranges to be ignored
295322 */
296- function Reporter ( lines , ruleset , allow ) {
323+ function Reporter ( lines , ruleset , allow , ignore ) {
297324 "use strict" ;
298325
299326 /**
@@ -335,6 +362,16 @@ function Reporter(lines, ruleset, allow) {
335362 if ( ! this . allow ) {
336363 this . allow = { } ;
337364 }
365+
366+ /**
367+ * Linesets not to include in the report.
368+ * @property ignore
369+ * @type [][]
370+ */
371+ this . ignore = ignore ;
372+ if ( ! this . ignore ) {
373+ this . ignore = [ ] ;
374+ }
338375}
339376
340377Reporter . prototype = {
@@ -392,6 +429,16 @@ Reporter.prototype = {
392429 return ;
393430 }
394431
432+ var ignore = false ;
433+ CSSLint . Util . forEach ( this . ignore , function ( range ) {
434+ if ( range [ 0 ] <= line && line <= range [ 1 ] ) {
435+ ignore = true ;
436+ }
437+ } ) ;
438+ if ( ignore ) {
439+ return ;
440+ }
441+
395442 this . messages . push ( {
396443 type : this . ruleset [ rule . id ] === 2 ? "error" : "warning" ,
397444 line : line ,
@@ -542,6 +589,7 @@ CSSLint.addRule({
542589 id : "adjoining-classes" ,
543590 name : "Disallow adjoining classes" ,
544591 desc : "Don't use adjoining classes." ,
592+ url : "https://github.com/CSSLint/csslint/wiki/Disallow-adjoining-classes" ,
545593 browsers : "IE6" ,
546594
547595 //initialization
@@ -588,6 +636,7 @@ CSSLint.addRule({
588636 id : "box-model" ,
589637 name : "Beware of broken box size" ,
590638 desc : "Don't use width or height when using padding or border." ,
639+ url : "https://github.com/CSSLint/csslint/wiki/Beware-of-box-model-size" ,
591640 browsers : "All" ,
592641
593642 //initialization
@@ -692,6 +741,7 @@ CSSLint.addRule({
692741 id : "box-sizing" ,
693742 name : "Disallow use of box-sizing" ,
694743 desc : "The box-sizing properties isn't supported in IE6 and IE7." ,
744+ url : "https://github.com/CSSLint/csslint/wiki/Disallow-box-sizing" ,
695745 browsers : "IE6, IE7" ,
696746 tags : [ "Compatibility" ] ,
697747
@@ -722,6 +772,7 @@ CSSLint.addRule({
722772 id : "bulletproof-font-face" ,
723773 name : "Use the bulletproof @font-face syntax" ,
724774 desc : "Use the bulletproof @font-face syntax to avoid 404's in old IE (http://www.fontspring.com/blog/the-new-bulletproof-font-face-syntax)." ,
775+ url : "https://github.com/CSSLint/csslint/wiki/Bulletproof-font-face" ,
725776 browsers : "All" ,
726777
727778 //initialization
@@ -789,6 +840,7 @@ CSSLint.addRule({
789840 id : "compatible-vendor-prefixes" ,
790841 name : "Require compatible vendor prefixes" ,
791842 desc : "Include all compatible vendor prefixes to reach a wider range of users." ,
843+ url : "https://github.com/CSSLint/csslint/wiki/Require-compatible-vendor-prefixes" ,
792844 browsers : "All" ,
793845
794846 //initialization
@@ -980,6 +1032,7 @@ CSSLint.addRule({
9801032 id : "display-property-grouping" ,
9811033 name : "Require properties appropriate for display" ,
9821034 desc : "Certain properties shouldn't be used with certain display property values." ,
1035+ url : "https://github.com/CSSLint/csslint/wiki/Require-properties-appropriate-for-display" ,
9831036 browsers : "All" ,
9841037
9851038 //initialization
@@ -1097,6 +1150,7 @@ CSSLint.addRule({
10971150 id : "duplicate-background-images" ,
10981151 name : "Disallow duplicate background images" ,
10991152 desc : "Every background-image should be unique. Use a common class for e.g. sprites." ,
1153+ url : "https://github.com/CSSLint/csslint/wiki/Disallow-duplicate-background-images" ,
11001154 browsers : "All" ,
11011155
11021156 //initialization
@@ -1137,6 +1191,7 @@ CSSLint.addRule({
11371191 id : "duplicate-properties" ,
11381192 name : "Disallow duplicate properties" ,
11391193 desc : "Duplicate properties must appear one after the other." ,
1194+ url : "https://github.com/CSSLint/csslint/wiki/Disallow-duplicate-properties" ,
11401195 browsers : "All" ,
11411196
11421197 //initialization
@@ -1185,6 +1240,7 @@ CSSLint.addRule({
11851240 id : "empty-rules" ,
11861241 name : "Disallow empty rules" ,
11871242 desc : "Rules without any properties specified should be removed." ,
1243+ url : "https://github.com/CSSLint/csslint/wiki/Disallow-empty-rules" ,
11881244 browsers : "All" ,
11891245
11901246 //initialization
@@ -1242,6 +1298,7 @@ CSSLint.addRule({
12421298 id : "fallback-colors" ,
12431299 name : "Require fallback colors" ,
12441300 desc : "For older browsers that don't support RGBA, HSL, or HSLA, provide a fallback color." ,
1301+ url : "https://github.com/CSSLint/csslint/wiki/Require-fallback-colors" ,
12451302 browsers : "IE6,IE7,IE8" ,
12461303
12471304 //initialization
@@ -1325,6 +1382,7 @@ CSSLint.addRule({
13251382 id : "floats" ,
13261383 name : "Disallow too many floats" ,
13271384 desc : "This rule tests if the float property is used too many times" ,
1385+ url : "https://github.com/CSSLint/csslint/wiki/Disallow-too-many-floats" ,
13281386 browsers : "All" ,
13291387
13301388 //initialization
@@ -1362,6 +1420,7 @@ CSSLint.addRule({
13621420 id : "font-faces" ,
13631421 name : "Don't use too many web fonts" ,
13641422 desc : "Too many different web fonts in the same stylesheet." ,
1423+ url : "https://github.com/CSSLint/csslint/wiki/Don%27t-use-too-many-web-fonts" ,
13651424 browsers : "All" ,
13661425
13671426 //initialization
@@ -1394,6 +1453,7 @@ CSSLint.addRule({
13941453 id : "font-sizes" ,
13951454 name : "Disallow too many font sizes" ,
13961455 desc : "Checks the number of font-size declarations." ,
1456+ url : "https://github.com/CSSLint/csslint/wiki/Don%27t-use-too-many-font-size-declarations" ,
13971457 browsers : "All" ,
13981458
13991459 //initialization
@@ -1430,6 +1490,7 @@ CSSLint.addRule({
14301490 id : "gradients" ,
14311491 name : "Require all gradient definitions" ,
14321492 desc : "When using a vendor-prefixed gradient, make sure to use them all." ,
1493+ url : "https://github.com/CSSLint/csslint/wiki/Require-all-gradient-definitions" ,
14331494 browsers : "All" ,
14341495
14351496 //initialization
@@ -1496,6 +1557,7 @@ CSSLint.addRule({
14961557 id : "ids" ,
14971558 name : "Disallow IDs in selectors" ,
14981559 desc : "Selectors should not contain IDs." ,
1560+ url : "https://github.com/CSSLint/csslint/wiki/Disallow-IDs-in-selectors" ,
14991561 browsers : "All" ,
15001562
15011563 //initialization
@@ -1590,6 +1652,7 @@ CSSLint.addRule({
15901652 id : "import" ,
15911653 name : "Disallow @import" ,
15921654 desc : "Don't use @import, use <link> instead." ,
1655+ url : "https://github.com/CSSLint/csslint/wiki/Disallow-%40import" ,
15931656 browsers : "All" ,
15941657
15951658 //initialization
@@ -1617,6 +1680,7 @@ CSSLint.addRule({
16171680 id : "important" ,
16181681 name : "Disallow !important" ,
16191682 desc : "Be careful when using !important declaration" ,
1683+ url : "https://github.com/CSSLint/csslint/wiki/Disallow-%21important" ,
16201684 browsers : "All" ,
16211685
16221686 //initialization
@@ -1655,6 +1719,7 @@ CSSLint.addRule({
16551719 id : "known-properties" ,
16561720 name : "Require use of known properties" ,
16571721 desc : "Properties should be known (listed in CSS3 specification) or be a vendor-prefixed property." ,
1722+ url : "https://github.com/CSSLint/csslint/wiki/Require-use-of-known-properties" ,
16581723 browsers : "All" ,
16591724
16601725 //initialization
@@ -1740,6 +1805,7 @@ CSSLint.addRule({
17401805 id : "outline-none" ,
17411806 name : "Disallow outline: none" ,
17421807 desc : "Use of outline: none or outline: 0 should be limited to :focus rules." ,
1808+ url : "https://github.com/CSSLint/csslint/wiki/Disallow-outline%3Anone" ,
17431809 browsers : "All" ,
17441810 tags : [ "Accessibility" ] ,
17451811
@@ -1816,6 +1882,7 @@ CSSLint.addRule({
18161882 id : "overqualified-elements" ,
18171883 name : "Disallow overqualified elements" ,
18181884 desc : "Don't use classes or IDs with elements (a.foo or a#foo)." ,
1885+ url : "https://github.com/CSSLint/csslint/wiki/Disallow-overqualified-elements" ,
18191886 browsers : "All" ,
18201887
18211888 //initialization
@@ -1881,6 +1948,7 @@ CSSLint.addRule({
18811948 id : "qualified-headings" ,
18821949 name : "Disallow qualified headings" ,
18831950 desc : "Headings should not be qualified (namespaced)." ,
1951+ url : "https://github.com/CSSLint/csslint/wiki/Disallow-qualified-headings" ,
18841952 browsers : "All" ,
18851953
18861954 //initialization
@@ -1921,6 +1989,7 @@ CSSLint.addRule({
19211989 id : "regex-selectors" ,
19221990 name : "Disallow selectors that look like regexs" ,
19231991 desc : "Selectors that look like regular expressions are slow and should be avoided." ,
1992+ url : "https://github.com/CSSLint/csslint/wiki/Disallow-selectors-that-look-like-regular-expressions" ,
19241993 browsers : "All" ,
19251994
19261995 //initialization
@@ -2102,6 +2171,7 @@ CSSLint.addRule({
21022171 id : "shorthand" ,
21032172 name : "Require shorthand properties" ,
21042173 desc : "Use shorthand properties where possible." ,
2174+ url : "https://github.com/CSSLint/csslint/wiki/Require-shorthand-properties" ,
21052175 browsers : "All" ,
21062176
21072177 //initialization
@@ -2190,6 +2260,7 @@ CSSLint.addRule({
21902260 id : "star-property-hack" ,
21912261 name : "Disallow properties with a star prefix" ,
21922262 desc : "Checks for the star property hack (targets IE6/7)" ,
2263+ url : "https://github.com/CSSLint/csslint/wiki/Disallow-star-hack" ,
21932264 browsers : "All" ,
21942265
21952266 //initialization
@@ -2219,6 +2290,7 @@ CSSLint.addRule({
22192290 id : "text-indent" ,
22202291 name : "Disallow negative text-indent" ,
22212292 desc : "Checks for text indent less than -99px" ,
2293+ url : "https://github.com/CSSLint/csslint/wiki/Disallow-negative-text-indent" ,
22222294 browsers : "All" ,
22232295
22242296 //initialization
@@ -2274,6 +2346,7 @@ CSSLint.addRule({
22742346 id : "underscore-property-hack" ,
22752347 name : "Disallow properties with an underscore prefix" ,
22762348 desc : "Checks for the underscore property hack (targets IE6)" ,
2349+ url : "https://github.com/CSSLint/csslint/wiki/Disallow-underscore-hack" ,
22772350 browsers : "All" ,
22782351
22792352 //initialization
@@ -2302,6 +2375,7 @@ CSSLint.addRule({
23022375 id : "unique-headings" ,
23032376 name : "Headings should only be defined once" ,
23042377 desc : "Headings should be defined only once." ,
2378+ url : "https://github.com/CSSLint/csslint/wiki/Headings-should-only-be-defined-once" ,
23052379 browsers : "All" ,
23062380
23072381 //initialization
@@ -2378,6 +2452,7 @@ CSSLint.addRule({
23782452 id : "universal-selector" ,
23792453 name : "Disallow universal selector" ,
23802454 desc : "The universal selector (*) is known to be slow." ,
2455+ url : "https://github.com/CSSLint/csslint/wiki/Disallow-universal-selector" ,
23812456 browsers : "All" ,
23822457
23832458 //initialization
@@ -2414,6 +2489,7 @@ CSSLint.addRule({
24142489 id : "unqualified-attributes" ,
24152490 name : "Disallow unqualified attribute selectors" ,
24162491 desc : "Unqualified attribute selectors are known to be slow." ,
2492+ url : "https://github.com/CSSLint/csslint/wiki/Disallow-unqualified-attribute-selectors" ,
24172493 browsers : "All" ,
24182494
24192495 //initialization
@@ -2472,6 +2548,7 @@ CSSLint.addRule({
24722548 id : "vendor-prefix" ,
24732549 name : "Require standard property with vendor prefix" ,
24742550 desc : "When using a vendor-prefixed property, make sure to include the standard one." ,
2551+ url : "https://github.com/CSSLint/csslint/wiki/Require-standard-property-with-vendor-prefix" ,
24752552 browsers : "All" ,
24762553
24772554 //initialization
@@ -2614,6 +2691,7 @@ CSSLint.addRule({
26142691 id : "zero-units" ,
26152692 name : "Disallow units for 0 values" ,
26162693 desc : "You don't need to specify units when a value is 0." ,
2694+ url : "https://github.com/CSSLint/csslint/wiki/Disallow-units-for-zero-values" ,
26172695 browsers : "All" ,
26182696
26192697 //initialization
@@ -2801,7 +2879,7 @@ CSSLint.addFormatter({
28012879
28022880 CSSLint . Util . forEach ( messages , function ( message ) {
28032881 if ( message . rollup ) {
2804- output += filename + ": " + capitalize ( message . type ) + " - " + message . message + "\n" ;
2882+ output += filename + ": " + capitalize ( message . type ) + " - " + message . message + " (" + message . rule . id + ") \n";
28052883 } else {
28062884 output += filename + ": line " + message . line +
28072885 ", col " + message . col + ", " + capitalize ( message . type ) + " - " + message . message + " (" + message . rule . id + ")\n" ;
0 commit comments