Skip to content

Commit

Permalink
Improve lint() logic, phetsims/phet-info#150
Browse files Browse the repository at this point in the history
Only format the results if we actually are going to print them
  • Loading branch information
NickCrews committed Mar 3, 2021
1 parent 7f5d04e commit df2d9f0
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions js/grunt/lint.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,17 +91,14 @@ const lint = async ( patterns, options ) => {
await ESLint.outputFixes( results );
}

// 4. Format the results.
const formatter = await eslint.loadFormatter( 'stylish' );
const resultText = formatter.format( results );

// 4. Parse the results.
const totalWarnings = _.sum( results.map( result => result.warningCount ) );
const totalErrors = _.sum( results.map( result => result.errorCount ) );

const total = totalWarnings + totalErrors;

// 5. Output it.
if ( total > 0 ) {
// 5. Output results on errors.
if ( totalWarnings + totalErrors > 0 ) {
const formatter = await eslint.loadFormatter( 'stylish' );
const resultText = formatter.format( results );
console.log( resultText );
options.warn && grunt.fail.warn( `${totalErrors} errors and ${totalWarnings} warnings` );
}
Expand Down

0 comments on commit df2d9f0

Please sign in to comment.