]> git.proxmox.com Git - pve-eslint.git/commitdiff
add --output-config CLI option
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Sat, 6 Jun 2020 10:49:55 +0000 (12:49 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Sat, 6 Jun 2020 11:29:24 +0000 (13:29 +0200)
can help to get the default config for adaption

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
src/app.js

index 7e919b1167ecd16d585337a5a529747ed62b5378..88f8fc3302cce7c42183896a6f7248b10b8cbd5b 100644 (file)
@@ -9,7 +9,9 @@ program
     .usage('[options] [<file(s) ...>]')
     .option('-c, --config <configfile>', 'uses <configfile> for eslint config instead.')
     .option('-e, --extend <configfile>', 'uses <configfile> 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,