From c94a6bde53f292e46a0ad3a060aa4d7d4f10ed02 Mon Sep 17 00:00:00 2001 From: zepumph Date: Thu, 18 Feb 2021 21:10:39 -0900 Subject: [PATCH] Create --format option to lint, https://github.com/phetsims/phet-info/issues/150 --- js/grunt/lint.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/js/grunt/lint.js b/js/grunt/lint.js index a5e645b1..d3697451 100644 --- a/js/grunt/lint.js +++ b/js/grunt/lint.js @@ -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 ); @@ -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, @@ -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( ', ' )}` );