This repository was archived by the owner on Sep 28, 2020. It is now read-only.
File tree 2 files changed +30
-4
lines changed
2 files changed +30
-4
lines changed Original file line number Diff line number Diff line change @@ -113,10 +113,12 @@ export default class Linter {
113
113
114
114
parseResults ( { results } ) {
115
115
// add filename for each results so formatter can have relevant filename
116
- results . forEach ( ( r ) => {
117
- // eslint-disable-next-line no-param-reassign
118
- r . filePath = this . loaderContext . resourcePath ;
119
- } ) ;
116
+ if ( results ) {
117
+ results . forEach ( ( r ) => {
118
+ // eslint-disable-next-line no-param-reassign
119
+ r . filePath = this . loaderContext . resourcePath ;
120
+ } ) ;
121
+ }
120
122
121
123
return results ;
122
124
}
Original file line number Diff line number Diff line change
1
+ import Linter from '../src/Linter' ;
2
+
3
+ const loaderContext = { resourcePath : 'test' } ;
4
+ const options = {
5
+ eslintPath : 'eslint' ,
6
+ ignore : false ,
7
+ formatter : jest . fn ( ) ,
8
+ } ;
9
+ const res = { results : [ { filePath : '' } ] } ;
10
+
11
+ describe ( 'Linter' , ( ) => {
12
+ let linter ;
13
+ beforeAll ( ( ) => {
14
+ linter = new Linter ( loaderContext , options ) ;
15
+ } ) ;
16
+
17
+ it ( 'should parse undefined results without error' , ( ) => {
18
+ expect ( linter . parseResults ( { } ) ) . toBeUndefined ( ) ;
19
+ } ) ;
20
+
21
+ it ( 'should parse results correctly' , ( ) => {
22
+ expect ( linter . parseResults ( res ) ) . toEqual ( [ { filePath : 'test' } ] ) ;
23
+ } ) ;
24
+ } ) ;
You can’t perform that action at this time.
0 commit comments