@@ -4,7 +4,7 @@ const eslint = require('eslint');
4
4
5
5
module . exports = grunt => {
6
6
grunt . registerMultiTask ( 'eslint' , 'Validate files with ESLint' , function ( ) {
7
- const opts = this . options ( {
7
+ const options = this . options ( {
8
8
outputFile : false ,
9
9
quiet : false ,
10
10
maxWarnings : - 1 ,
@@ -16,47 +16,47 @@ module.exports = grunt => {
16
16
return true ;
17
17
}
18
18
19
- const formatter = eslint . CLIEngine . getFormatter ( opts . format ) ;
19
+ const formatter = eslint . CLIEngine . getFormatter ( options . format ) ;
20
20
21
21
if ( ! formatter ) {
22
- grunt . warn ( `Could not find formatter ${ opts . format } ` ) ;
22
+ grunt . warn ( `Could not find formatter ${ options . format } ` ) ;
23
23
return false ;
24
24
}
25
25
26
- const engine = new eslint . CLIEngine ( opts ) ;
26
+ const engine = new eslint . CLIEngine ( options ) ;
27
27
28
28
let report ;
29
29
try {
30
30
report = engine . executeOnFiles ( this . filesSrc ) ;
31
- } catch ( err ) {
32
- grunt . warn ( err ) ;
31
+ } catch ( error ) {
32
+ grunt . warn ( error ) ;
33
33
return false ;
34
34
}
35
35
36
- if ( opts . fix ) {
36
+ if ( options . fix ) {
37
37
eslint . CLIEngine . outputFixes ( report ) ;
38
38
}
39
39
40
40
let results = report . results ;
41
41
42
- if ( opts . quiet ) {
42
+ if ( options . quiet ) {
43
43
results = eslint . CLIEngine . getErrorResults ( results ) ;
44
44
}
45
45
46
46
const output = formatter ( results ) ;
47
47
48
- if ( opts . outputFile ) {
49
- grunt . file . write ( opts . outputFile , output ) ;
48
+ if ( options . outputFile ) {
49
+ grunt . file . write ( options . outputFile , output ) ;
50
50
} else if ( output ) {
51
51
console . log ( output ) ;
52
52
}
53
53
54
- const tooManyWarnings = opts . maxWarnings >= 0 && report . warningCount > opts . maxWarnings ;
54
+ const tooManyWarnings = options . maxWarnings >= 0 && report . warningCount > options . maxWarnings ;
55
55
56
56
if ( report . errorCount === 0 && tooManyWarnings ) {
57
- grunt . warn ( `ESLint found too many warnings (maximum: ${ opts . maxWarnings } )` ) ;
57
+ grunt . warn ( `ESLint found too many warnings (maximum: ${ options . maxWarnings } )` ) ;
58
58
}
59
59
60
- return opts . failOnError ? report . errorCount === 0 : 0 ;
60
+ return options . failOnError ? report . errorCount === 0 : 0 ;
61
61
} ) ;
62
62
} ;
0 commit comments