1
1
/*!
2
- CSSLint v0.10 .0
2
+ CSSLint v1.0 .0
3
3
Copyright (c) 2016 Nicole Sullivan and Nicholas C. Zakas. All rights reserved.
4
4
5
5
Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -41,7 +41,7 @@ var CSSLint = (function() {
41
41
embeddedRuleset = / \/ \* \s * c s s l i n t ( [ ^ \* ] * ) \* \/ / ,
42
42
api = new parserlib . util . EventTarget ( ) ;
43
43
44
- api . version = "0.10 .0" ;
44
+ api . version = "1.0 .0" ;
45
45
46
46
//-------------------------------------------------------------------------
47
47
// Rule Management
@@ -205,8 +205,12 @@ var CSSLint = (function() {
205
205
allow = { } ,
206
206
ignore = [ ] ,
207
207
report ,
208
- parser = new parserlib . css . Parser ( { starHack : true , ieFilters : true ,
209
- underscoreHack : true , strict : false } ) ;
208
+ parser = new parserlib . css . Parser ( {
209
+ starHack : true ,
210
+ ieFilters : true ,
211
+ underscoreHack : true ,
212
+ strict : false
213
+ } ) ;
210
214
211
215
// normalize line endings
212
216
lines = text . replace ( / \n \r ? / g, "$split$" ) . split ( "$split$" ) ;
@@ -231,22 +235,22 @@ var CSSLint = (function() {
231
235
ignoreEnd = null ;
232
236
CSSLint . Util . forEach ( lines , function ( line , lineno ) {
233
237
// 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) ) {
238
+ if ( ignoreStart === null && 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
239
ignoreStart = lineno ;
236
240
}
237
241
238
242
if ( line . match ( / \/ \* [ \t ] * c s s l i n t [ \t ] + i g n o r e : e n d [ \t ] * \* \/ / i) ) {
239
243
ignoreEnd = lineno ;
240
244
}
241
245
242
- if ( null !== ignoreStart && null !== ignoreEnd ) {
246
+ if ( ignoreStart !== null && ignoreEnd !== null ) {
243
247
ignore . push ( [ ignoreStart , ignoreEnd ] ) ;
244
248
ignoreStart = ignoreEnd = null ;
245
249
}
246
250
} ) ;
247
251
248
252
// Close remaining ignore block, if any
249
- if ( null !== ignoreStart ) {
253
+ if ( ignoreStart !== null ) {
250
254
ignore . push ( [ ignoreStart , lines . length ] ) ;
251
255
}
252
256
@@ -709,7 +713,11 @@ CSSLint.addRule({
709
713
710
714
if ( heightProperties [ name ] || widthProperties [ name ] ) {
711
715
if ( ! / ^ 0 \S * $ / . test ( event . value ) && ! ( name === "border" && event . value . toString ( ) === "none" ) ) {
712
- properties [ name ] = { line : event . property . line , col : event . property . col , value : event . value } ;
716
+ properties [ name ] = {
717
+ line : event . property . line ,
718
+ col : event . property . col ,
719
+ value : event . value
720
+ } ;
713
721
}
714
722
} else {
715
723
if ( / ^ ( w i d t h | h e i g h t ) / i. test ( name ) && / ^ ( l e n g t h | p e r c e n t a g e ) / . test ( event . value . parts [ 0 ] . type ) ) {
@@ -982,8 +990,8 @@ CSSLint.addRule({
982
990
if ( CSSLint . Util . indexOf ( variations , name . text ) > - 1 ) {
983
991
if ( ! propertyGroups [ prop ] ) {
984
992
propertyGroups [ prop ] = {
985
- full : variations . slice ( 0 ) ,
986
- actual : [ ] ,
993
+ full : variations . slice ( 0 ) ,
994
+ actual : [ ] ,
987
995
actualNodes : [ ]
988
996
} ;
989
997
}
@@ -1125,7 +1133,11 @@ CSSLint.addRule({
1125
1133
var name = event . property . text . toLowerCase ( ) ;
1126
1134
1127
1135
if ( propertiesToCheck [ name ] ) {
1128
- properties [ name ] = { value : event . value . text , line : event . property . line , col : event . property . col } ;
1136
+ properties [ name ] = {
1137
+ value : event . value . text ,
1138
+ line : event . property . line ,
1139
+ col : event . property . col
1140
+ } ;
1129
1141
}
1130
1142
} ) ;
1131
1143
@@ -1169,8 +1181,7 @@ CSSLint.addRule({
1169
1181
if ( value . parts [ i ] . type === "uri" ) {
1170
1182
if ( typeof stack [ value . parts [ i ] . uri ] === "undefined" ) {
1171
1183
stack [ value . parts [ i ] . uri ] = event ;
1172
- }
1173
- else {
1184
+ } else {
1174
1185
reporter . report ( "Background image '" + value . parts [ i ] . uri + "' was used multiple times, first declared at line " + stack [ value . parts [ i ] . uri ] . line + ", col " + stack [ value . parts [ i ] . uri ] . col + "." , event . line , event . col , rule ) ;
1175
1186
}
1176
1187
}
@@ -1320,11 +1331,9 @@ CSSLint.addRule({
1320
1331
"border-bottom" : 1 ,
1321
1332
"border-left" : 1 ,
1322
1333
"background-color" : 1
1323
- } ,
1324
- properties ;
1334
+ } ;
1325
1335
1326
1336
function startRule ( ) {
1327
- properties = { } ;
1328
1337
lastProperty = null ;
1329
1338
}
1330
1339
@@ -1914,7 +1923,10 @@ CSSLint.addRule({
1914
1923
if ( ! classes [ modifier ] ) {
1915
1924
classes [ modifier ] = [ ] ;
1916
1925
}
1917
- classes [ modifier ] . push ( { modifier : modifier , part : part } ) ;
1926
+ classes [ modifier ] . push ( {
1927
+ modifier : modifier ,
1928
+ part : part
1929
+ } ) ;
1918
1930
}
1919
1931
}
1920
1932
}
@@ -2013,7 +2025,7 @@ CSSLint.addRule({
2013
2025
for ( k = 0 ; k < part . modifiers . length ; k ++ ) {
2014
2026
modifier = part . modifiers [ k ] ;
2015
2027
if ( modifier . type === "attribute" ) {
2016
- if ( / ( [ \ ~\| \^ \$ \* ] = ) / . test ( modifier ) ) {
2028
+ if ( / ( [ ~ \| \^ \$ \* ] = ) / . test ( modifier ) ) {
2017
2029
reporter . report ( "Attribute selectors with " + RegExp . $1 + " are slow!" , modifier . line , modifier . col , rule ) ;
2018
2030
}
2019
2031
}
@@ -2604,18 +2616,18 @@ CSSLint.addRule({
2604
2616
"-moz-box-shadow" : "box-shadow" ,
2605
2617
"-webkit-box-shadow" : "box-shadow" ,
2606
2618
2607
- "-moz-transform" : "transform" ,
2608
- "-webkit-transform" : "transform" ,
2609
- "-o-transform" : "transform" ,
2610
- "-ms-transform" : "transform" ,
2619
+ "-moz-transform" : "transform" ,
2620
+ "-webkit-transform" : "transform" ,
2621
+ "-o-transform" : "transform" ,
2622
+ "-ms-transform" : "transform" ,
2611
2623
2612
- "-moz-transform-origin" : "transform-origin" ,
2613
- "-webkit-transform-origin" : "transform-origin" ,
2614
- "-o-transform-origin" : "transform-origin" ,
2615
- "-ms-transform-origin" : "transform-origin" ,
2624
+ "-moz-transform-origin" : "transform-origin" ,
2625
+ "-webkit-transform-origin" : "transform-origin" ,
2626
+ "-o-transform-origin" : "transform-origin" ,
2627
+ "-ms-transform-origin" : "transform-origin" ,
2616
2628
2617
- "-moz-box-sizing" : "box-sizing" ,
2618
- "-webkit-box-sizing" : "box-sizing"
2629
+ "-moz-box-sizing" : "box-sizing" ,
2630
+ "-webkit-box-sizing" : "box-sizing"
2619
2631
} ;
2620
2632
2621
2633
// event handler for beginning of rules
@@ -2672,7 +2684,11 @@ CSSLint.addRule({
2672
2684
properties [ name ] = [ ] ;
2673
2685
}
2674
2686
2675
- properties [ name ] . push ( { name : event . property , value : event . value , pos :num ++ } ) ;
2687
+ properties [ name ] . push ( {
2688
+ name : event . property ,
2689
+ value : event . value ,
2690
+ pos : num ++
2691
+ } ) ;
2676
2692
} ) ;
2677
2693
2678
2694
parser . addListener ( "endrule" , endRule ) ;
@@ -2742,7 +2758,7 @@ CSSLint.addRule({
2742
2758
return "" ;
2743
2759
}
2744
2760
2745
- return str . replace ( / [ \ "& > < ] / g, function ( match ) {
2761
+ return str . replace ( / [ " & > < ] / g, function ( match ) {
2746
2762
switch ( match ) {
2747
2763
case "\"" :
2748
2764
return """ ;
@@ -2813,7 +2829,6 @@ CSSLint.addRule({
2813
2829
} ;
2814
2830
2815
2831
2816
-
2817
2832
if ( messages . length > 0 ) {
2818
2833
output . push ( "<file name=\"" + filename + "\">" ) ;
2819
2834
CSSLint . Util . forEach ( messages , function ( message ) {
@@ -2945,7 +2960,7 @@ CSSLint.addFormatter({
2945
2960
if ( ! str || str . constructor !== String ) {
2946
2961
return "" ;
2947
2962
}
2948
- return str . replace ( / \ "/ g, "'" ) . replace ( / & / g, "&" ) . replace ( / < / g, "<" ) . replace ( / > / g, ">" ) ;
2963
+ return str . replace ( / " / g, "'" ) . replace ( / & / g, "&" ) . replace ( / < / g, "<" ) . replace ( / > / g, ">" ) ;
2949
2964
} ;
2950
2965
2951
2966
if ( messages . length > 0 ) {
@@ -3089,7 +3104,7 @@ CSSLint.addFormatter({
3089
3104
return "" ;
3090
3105
}
3091
3106
3092
- return str . replace ( / \ "/ g, "'" ) . replace ( / < / g, "<" ) . replace ( / > / g, ">" ) ;
3107
+ return str . replace ( / " / g, "'" ) . replace ( / < / g, "<" ) . replace ( / > / g, ">" ) ;
3093
3108
3094
3109
} ;
3095
3110
@@ -3177,7 +3192,7 @@ CSSLint.addFormatter({
3177
3192
if ( ! str || str . constructor !== String ) {
3178
3193
return "" ;
3179
3194
}
3180
- return str . replace ( / \ "/ g, "'" ) . replace ( / & / g, "&" ) . replace ( / < / g, "<" ) . replace ( / > / g, ">" ) ;
3195
+ return str . replace ( / " / g, "'" ) . replace ( / & / g, "&" ) . replace ( / < / g, "<" ) . replace ( / > / g, ">" ) ;
3181
3196
} ;
3182
3197
3183
3198
if ( messages . length > 0 ) {
0 commit comments