@@ -26,9 +26,8 @@ function cli(api){
26
26
* @param options {Object} The CLI options.
27
27
* @return {Object } A ruleset object.
28
28
*/
29
- function gatherRules ( options ) {
30
- var ruleset ,
31
- warnings = options . rules || options . warnings ,
29
+ function gatherRules ( options , ruleset ) {
30
+ var warnings = options . rules || options . warnings ,
32
31
errors = options . errors ;
33
32
34
33
if ( warnings ) {
@@ -44,6 +43,24 @@ function cli(api){
44
43
ruleset [ value ] = 2 ;
45
44
} ) ;
46
45
}
46
+
47
+ return ruleset ;
48
+ }
49
+
50
+ /**
51
+ * Filters out rules using the ignore command line option.
52
+ * @param options {Object} the CLI options
53
+ * @return {Object } A ruleset object.
54
+ */
55
+ function filterRules ( options ) {
56
+ var ignore = options . ignore ,
57
+ ruleset = CSSLint . getRuleset ( ) ;
58
+
59
+ if ( ignore ) {
60
+ ignore . split ( "," ) . forEach ( function ( value ) {
61
+ delete ruleset [ value ] ;
62
+ } ) ;
63
+ }
47
64
48
65
return ruleset ;
49
66
}
@@ -68,7 +85,8 @@ function cli(api){
68
85
*/
69
86
function processFile ( relativeFilePath , options ) {
70
87
var input = api . readFile ( relativeFilePath ) ,
71
- result = CSSLint . verify ( input , gatherRules ( options ) ) ,
88
+ ruleset = filterRules ( options ) ,
89
+ result = CSSLint . verify ( input , gatherRules ( options , ruleset ) ) ,
72
90
formatter = CSSLint . getFormatter ( options . format || "text" ) ,
73
91
messages = result . messages || [ ] ,
74
92
output ,
@@ -113,6 +131,7 @@ function cli(api){
113
131
" --quiet Only output when errors are present." ,
114
132
" --errors=<rule[,rule]+> Indicate which rules to include as errors." ,
115
133
" --warnings=<rule[,rule]+> Indicate which rules to include as warnings." ,
134
+ " --ignore=<rule,[,rule]+> Indicate which rules to ignore completely." ,
116
135
" --version Outputs the current version number."
117
136
] . join ( "\n" ) + "\n" ) ;
118
137
}
0 commit comments