@@ -112,24 +112,26 @@ export default function linter(key, options, compilation) {
112112 */
113113 async function generateReportAsset ( { compiler } ) {
114114 const { outputReport } = options ;
115- // @ts -ignore
115+ /**
116+ * @param {string } name
117+ * @param {string | Buffer } content
118+ */
116119 const save = ( name , content ) =>
117- new Promise ( ( finish , bail ) => {
120+ /** @type { Promise<void> } */ ( new Promise ( ( finish , bail ) => {
118121 const { mkdir, writeFile } = compiler . outputFileSystem ;
119122 // ensure directory exists
120123 // @ts -ignore - the types for `outputFileSystem` are missing the 3 arg overload
121124 mkdir ( dirname ( name ) , { recursive : true } , ( err ) => {
122125 /* istanbul ignore if */
123126 if ( err ) bail ( err ) ;
124- // @ts -ignore
125127 else
126128 writeFile ( name , content , ( err2 ) => {
127129 /* istanbul ignore if */
128130 if ( err2 ) bail ( err2 ) ;
129131 else finish ( ) ;
130132 } ) ;
131133 } ) ;
132- } ) ;
134+ } ) ) ;
133135
134136 if ( ! outputReport || ! outputReport . filePath ) {
135137 return ;
@@ -185,14 +187,9 @@ function parseResults(options, results) {
185187
186188 results . forEach ( ( file ) => {
187189 if ( fileHasErrors ( file ) ) {
188- const messages = file . messages . filter ( ( message ) => {
189- if ( options . emitError === undefined ) {
190- return true ;
191- } else if ( options . emitError ) {
192- return message . severity === 2 ;
193- }
194- return false ;
195- } ) ;
190+ const messages = file . messages . filter (
191+ ( message ) => options . emitError && message . severity === 2
192+ ) ;
196193
197194 if ( messages . length > 0 ) {
198195 errors . push ( {
@@ -203,14 +200,9 @@ function parseResults(options, results) {
203200 }
204201
205202 if ( fileHasWarnings ( file ) ) {
206- const messages = file . messages . filter ( ( message ) => {
207- if ( options . emitWarning === undefined ) {
208- return true ;
209- } else if ( options . emitWarning ) {
210- return message . severity === 1 ;
211- }
212- return false ;
213- } ) ;
203+ const messages = file . messages . filter (
204+ ( message ) => options . emitWarning && message . severity === 1
205+ ) ;
214206
215207 if ( messages . length > 0 ) {
216208 warnings . push ( {
0 commit comments