File tree Expand file tree Collapse file tree 2 files changed +24
-1
lines changed Expand file tree Collapse file tree 2 files changed +24
-1
lines changed Original file line number Diff line number Diff line change @@ -51,7 +51,14 @@ module.exports = function (options) {
51
51
52
52
try {
53
53
var errors = checker . checkString ( file . contents . toString ( ) , file . relative ) ;
54
- errors . getErrorList ( ) . forEach ( function ( err ) {
54
+ var errorList = errors . getErrorList ( ) ;
55
+ file . jscs = { success : true , errorCount : 0 , errors : [ ] } ;
56
+ if ( errorList . length > 0 ) {
57
+ file . jscs . success = false ;
58
+ file . jscs . errorCount = errorList . length ;
59
+ file . jscs . errors = errorList ;
60
+ }
61
+ errorList . forEach ( function ( err ) {
55
62
out . push ( errors . explainError ( err , true ) ) ;
56
63
} ) ;
57
64
} catch ( err ) {
Original file line number Diff line number Diff line change @@ -27,6 +27,22 @@ gulp.task('default', function () {
27
27
```
28
28
29
29
30
+ ## Results
31
+
32
+ A ` jscs ` object will be attached to the file object which can be used for custom error reporting. An example with one error might look like this:
33
+
34
+ ``` js
35
+ { success: false , // or true if no errors
36
+ errorCount: 1 , // number of errors in the errors array
37
+ errors: [ // an array of jscs error objects
38
+ { filename: ' index.js' , // basename of the file
39
+ rule: ' requireCamelCaseOrUpperCaseIdentifiers' , // jscs rule which triggered the error
40
+ message: ' All identifiers must be camelCase or UPPER_CASE' , // error message returned by the rule
41
+ line: 32 , // error line number
42
+ column: 7 } // error column
43
+ ]};
44
+ ```
45
+
30
46
## API
31
47
32
48
### jscs(options)
You can’t perform that action at this time.
0 commit comments