Skip to content

Commit

Permalink
Create --format option to lint, phetsims/phet-info#150
Browse files Browse the repository at this point in the history
  • Loading branch information
zepumph committed Jul 21, 2022
1 parent 08d60d7 commit c94a6bd
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions js/grunt/lint.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ const lint = async ( patterns, options ) => {

options = _.assignIn( {
cache: true,
format: false, // Use a separate set of rules purely for formatting code.
fix: false, // whether fixes should be written to disk
warn: true // whether errors should reported with grunt.warn
}, options );
Expand All @@ -51,7 +52,7 @@ const lint = async ( patterns, options ) => {
fs.existsSync( pattern ) );

// 1. Create an instance with the `fix` option.
const eslint = new ESLint( {
const eslintConfig = {

// optional auto-fix
fix: options.fix,
Expand All @@ -70,7 +71,15 @@ const lint = async ( patterns, options ) => {

// Our custom rules live here
rulePaths: [ '../chipper/eslint/rules' ]
} );
};

if ( options.format ) {
eslintConfig.baseConfig = {
extends: [ '../chipper/eslint/format_eslintrc.js' ]
};
}

const eslint = new ESLint( eslintConfig );

grunt.verbose.writeln( `linting: ${patterns.join( ', ' )}` );

Expand Down

0 comments on commit c94a6bd

Please sign in to comment.