@@ -16,6 +16,7 @@ describe('ESLintParser', () => {
1616 column : 8 ,
1717 } ,
1818 ] ,
19+ suppressedMessages : [ ] ,
1920 errorCount : 1 ,
2021 warningCount : 0 ,
2122 fixableErrorCount : 0 ,
@@ -38,6 +39,19 @@ describe('ESLintParser', () => {
3839 endColumn : 30 ,
3940 } ,
4041 ] ,
42+ suppressedMessages : [
43+ {
44+ ruleId : '@typescript-eslint/no-unused-vars' ,
45+ severity : 1 ,
46+ message : "'content' is defined but never used." ,
47+ line : 24 ,
48+ column : 15 ,
49+ nodeType : 'Identifier' ,
50+ messageId : 'unusedVar' ,
51+ endLine : 24 ,
52+ endColumn : 30 ,
53+ } ,
54+ ] ,
4155 errorCount : 1 ,
4256 warningCount : 1 ,
4357 fixableErrorCount : 0 ,
@@ -51,7 +65,7 @@ describe('ESLintParser', () => {
5165
5266 it ( 'Should parse correctly' , ( ) => {
5367 const result = new ESLintParser ( cwd ) . parse ( mockedContentString ) ;
54- expect ( result ) . toHaveLength ( 2 ) ;
68+ expect ( result ) . toHaveLength ( 3 ) ;
5569
5670 expect ( result [ 0 ] ) . toEqual ( {
5771 ruleId : '' ,
@@ -76,6 +90,18 @@ describe('ESLintParser', () => {
7690 valid : true ,
7791 type : 'eslint' ,
7892 } ) ;
93+
94+ expect ( result [ 2 ] ) . toEqual ( {
95+ ruleId : '@typescript-eslint/no-unused-vars' ,
96+ source : `src/app.ts` ,
97+ severity : LintSeverity . ignore ,
98+ line : 24 ,
99+ lineOffset : 15 ,
100+ msg : `'content' is defined but never used.` ,
101+ log : JSON . stringify ( { ...mockedContent [ 1 ] . messages [ 0 ] , severity : 0 } ) ,
102+ valid : true ,
103+ type : 'eslint' ,
104+ } ) ;
79105 } ) ;
80106
81107 it ( 'Should do nothing if put empty string' , ( ) => {
@@ -87,10 +113,20 @@ describe('ESLintParser', () => {
87113 const result = new ESLintParser ( cwd ) . parse ( mockedContentString ) ;
88114 const valid = result . filter ( ( el ) => el . valid ) ;
89115 const invalid = result . filter ( ( el ) => ! el . valid ) ;
90- expect ( valid ) . toHaveLength ( 1 ) ;
116+ expect ( valid ) . toHaveLength ( 2 ) ;
91117 expect ( invalid ) . toHaveLength ( 1 ) ;
92118 } ) ;
93119
120+ it ( 'Should parse with severity correctly' , ( ) => {
121+ const result = new ESLintParser ( cwd ) . parse ( mockedContentString ) ;
122+ const resultWithError = result . filter ( ( el ) => el . severity === LintSeverity . error ) ;
123+ const resultWithWarning = result . filter ( ( el ) => el . severity === LintSeverity . warning ) ;
124+ const ignoredResult = result . filter ( ( el ) => el . severity === LintSeverity . ignore ) ;
125+ expect ( resultWithError ) . toHaveLength ( 1 ) ;
126+ expect ( resultWithWarning ) . toHaveLength ( 1 ) ;
127+ expect ( ignoredResult ) . toHaveLength ( 1 ) ;
128+ } ) ;
129+
94130 it ( 'Should throw error if the line not match the rule' , ( ) => {
95131 expect ( ( ) => new ESLintParser ( cwd ) . parse ( ':' ) ) . toThrow ( ) ;
96132 } ) ;
0 commit comments