@@ -51,6 +51,28 @@ const eslintLoopMatcher = {
5151 ]
5252} ;
5353
54+ const loopMatcherWithDefaultSeverity = {
55+ owner : "test-matcher-loop" ,
56+ severity : 'error' ,
57+ pattern : [
58+ {
59+ // Matches the 1st line in the output
60+ regexp : "^([^\\s].*)$" ,
61+ file : 1
62+ } ,
63+ {
64+ // Matches the 2nd and 3rd line in the output
65+ regexp : "^\\s+(\\d+):(\\d+)\\s+\\s+(.*)\\s\\s+(.*)$" ,
66+ // File is carried through from above, so we define the rest of the groups
67+ line : 1 ,
68+ column : 2 ,
69+ message : 3 ,
70+ code : 4 ,
71+ loop : true
72+ }
73+ ]
74+ } ;
75+
5476test ( "throws an error if the matcher is missing" , ( ) => {
5577 actual = ( ) => matcher ( undefined , "error::Something went wrong" ) ;
5678 expect ( actual ) . toThrow ( "No matcher provided" ) ;
@@ -168,6 +190,54 @@ foo.js
168190 ] ) ;
169191} ) ;
170192
193+ test ( "loop line matcher with default severity, does match" , ( ) => {
194+ const input = `test.js
195+ 1:0 Missing "use strict" statement strict
196+ 5:10 'addOne' is defined but never used no-unused-vars
197+
198+ foo.js
199+ 36:10 Expected parentheses around arrow function argument arrow-parens
200+ 37:13 Expected parentheses around arrow function argument arrow-parens
201+
202+ ✖ 4 problems (4 errors, 0 warnings)` ;
203+
204+ actual = matcher ( loopMatcherWithDefaultSeverity , input ) ;
205+ expect ( actual ) . toEqual ( [
206+ {
207+ file : "test.js" ,
208+ line : "1" ,
209+ column : "0" ,
210+ severity : "error" ,
211+ message : 'Missing "use strict" statement' ,
212+ code : "strict"
213+ } ,
214+ {
215+ file : "test.js" ,
216+ line : "5" ,
217+ column : "10" ,
218+ severity : "error" ,
219+ message : "'addOne' is defined but never used" ,
220+ code : "no-unused-vars"
221+ } ,
222+ {
223+ file : "foo.js" ,
224+ line : "36" ,
225+ column : "10" ,
226+ severity : "error" ,
227+ message : "Expected parentheses around arrow function argument" ,
228+ code : "arrow-parens"
229+ } ,
230+ {
231+ file : "foo.js" ,
232+ line : "37" ,
233+ column : "13" ,
234+ severity : "error" ,
235+ message : "Expected parentheses around arrow function argument" ,
236+ code : "arrow-parens"
237+ }
238+ ] ) ;
239+ } ) ;
240+
171241test ( "uses default severity" , ( ) => {
172242 const input = "Some Message:/path/to/file.js:12" ;
173243 actual = matcher ( validMatcher , input ) ;
0 commit comments