From 4e679d18a277d596eb90d448d66918d8c9de53e4 Mon Sep 17 00:00:00 2001 From: Thomas Lamprecht Date: Sat, 6 Jun 2020 12:49:55 +0200 Subject: [PATCH] add --output-config CLI option can help to get the default config for adaption Signed-off-by: Thomas Lamprecht --- src/app.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/app.js b/src/app.js index 7e919b1..88f8fc3 100644 --- a/src/app.js +++ b/src/app.js @@ -9,7 +9,9 @@ program .usage('[options] []') .option('-c, --config ', 'uses for eslint config instead.') .option('-e, --extend ', 'uses ontop of default eslint config.') - .option('-f, --fix', 'if set, fixes will be applied.'); + .option('-f, --fix', 'if set, fixes will be applied.') + .option('--output-config', 'if set, only output the config as JSON and exit.') + ; program.on('--help', function() { console.log(''); @@ -26,7 +28,7 @@ if (program.config && program.extend) { process.exit(1); } -if (program.args.length < 1) { +if (program.args.length < 1 && !program.outputConfig) { program.help(); } @@ -246,6 +248,12 @@ if (program.config) { console.log(`Extend with path: ${config.extends}`); } +if (program.outputConfig) { + let cfg = JSON.stringify(config, null, 2); + console.log(cfg); + process.exit(0); +} + const cli = new eslint.CLIEngine({ baseConfig: config, useEslintrc: true,