@@ -57,10 +57,8 @@ export default {
57
57
const filePath = activeEditor . getPath ( ) ;
58
58
const [ projectPath , projectRelativeFilePath ] = atom . project . relativizePath ( filePath ) ;
59
59
60
- // With the custom format the puppet-int ouput looks like this:
61
- // error mongodb::service not in autoload module layout 3 7
62
- const regexLine = / ^ ( w a r n i n g | e r r o r ) \s ( .* ) \s ( \d + ) \s ( \d + ) $ / ;
63
- const args = [ '--relative' , '--log-format' , '%{kind} %{message} %{line} %{column}' , '--error-level' , errorLevel ] ;
60
+ // Setup args
61
+ const args = [ '--relative' , '--json' , '--error-level' , errorLevel ] ;
64
62
65
63
const optionsMap = require ( './flags.js' ) ;
66
64
@@ -82,23 +80,27 @@ export default {
82
80
}
83
81
const toReturn = [ ] ;
84
82
83
+ // Parse JSON output and immediately access zeroth element of redundant outer array
84
+ const info = JSON . parse ( output ) [ 0 ] ;
85
+
85
86
// Check for proper warnings and errors from stdout
86
- output . split ( / \r ? \n / ) . forEach ( ( line ) => {
87
- const matches = regexLine . exec ( line ) ;
88
- if ( matches != null ) {
89
- const errLine = Number . parseInt ( matches [ 3 ] , 10 ) - 1 ;
90
- const errCol = Number . parseInt ( matches [ 4 ] , 10 ) - 1 ;
87
+ if ( info . length > 0 ) {
88
+ info . forEach ( ( issue ) => {
89
+ // bypass char line limit
90
+ const line = issue . line - 1 ;
91
+ const col = issue . column - 1 ;
91
92
92
93
toReturn . push ( {
93
- severity : matches [ 1 ] ,
94
- excerpt : matches [ 2 ] ,
94
+ severity : issue . kind ,
95
+ excerpt : issue . message ,
95
96
location : {
97
+ // bug in atom-linter cannot use issue.path
96
98
file : filePath ,
97
- position : helpers . generateRange ( activeEditor , errLine , errCol ) ,
99
+ position : helpers . generateRange ( activeEditor , line , col ) ,
98
100
} ,
99
101
} ) ;
100
- }
101
- } ) ;
102
+ } ) ;
103
+ }
102
104
return toReturn ;
103
105
} ) ;
104
106
} ,
0 commit comments