From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id AA8728180 for ; Wed, 30 Aug 2023 11:27:35 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 1FA6EF318 for ; Wed, 30 Aug 2023 11:24:53 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS for ; Wed, 30 Aug 2023 11:24:44 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 2262747779 for ; Wed, 30 Aug 2023 11:24:43 +0200 (CEST) From: Stefan Sterz To: pve-devel@lists.proxmox.com Date: Wed, 30 Aug 2023 11:24:29 +0200 Message-Id: <20230830092429.108551-1-s.sterz@proxmox.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.095 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [npmjs.com] Subject: [pve-devel] [PATCH pve-eslint] switch to using `Command.opts()` to access options X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 30 Aug 2023 09:27:35 -0000 this fixes an issue where the options where not properly passed to eslint, which rendered them useless. uses the `opts()` function to access them. see [1] for more on info on option parsing with commander. [1]: https://www.npmjs.com/package/commander#user-content-options Signed-off-by: Stefan Sterz --- not sure how we handle this, but might need a: Reported-by: Max Carrara src/bin/app.js | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/src/bin/app.js b/src/bin/app.js index 48ae043..7d0088f 100644 --- a/src/bin/app.js +++ b/src/bin/app.js @@ -27,13 +27,14 @@ program.on('--help', function() { }); program.parse(process.argv); +let options = program.opts(); -if (program.config && program.extend) { +if (options.config && options.extend) { console.error('Cannot use both, --config and --extend, at the same time!'); process.exit(1); } -if (program.args.length < 1 && !program.outputConfig) { +if (program.args.length < 1 && !options.outputConfig) { program.help(); } @@ -44,8 +45,8 @@ if (!paths.length) { } let threadCount = 4; -if (program.threads) { - threadCount = program.threads; +if (options.threads) { + threadCount = options.threads; } const defaultConfig = { @@ -274,16 +275,16 @@ let pathExpand = (p) => { }; let config = defaultConfig; -if (program.config) { +if (options.config) { config = { - "extends": pathExpand(program.config), + "extends": pathExpand(options.config), }; -} else if (program.extend) { - config.extends = pathExpand(program.extend); +} else if (options.extend) { + config.extends = pathExpand(options.extend); console.log(`Extend with path: ${config.extends}`); } -if (program.outputConfig) { +if (options.outputConfig) { let cfg = JSON.stringify(config, null, 2); console.log(cfg); process.exit(0); @@ -292,7 +293,7 @@ if (program.outputConfig) { const cliOptions = { baseConfig: config, useEslintrc: true, - fix: !!program.fix, + fix: !!options.fix, cwd: process.cwd(), }; @@ -322,7 +323,7 @@ results.forEach(function(result) { let filename = path.relative(process.cwd(), result.filePath); let msgs = result.messages; let max_sev = 0; - if (!!program.fix && result.output) { + if (!!options.fix && result.output) { fixes++; } if (msgs.length <= 0) { @@ -337,7 +338,7 @@ results.forEach(function(result) { let msg = `: line ${color.bold(e.line)} col ${color.bold(e.column)}: ${e.ruleId}`; if (e.severity === 1) { msg = color.yellow("WARN" + msg); - if (exitcode < 1 && !!program.strict) { + if (exitcode < 1 && !!options.strict) { exitcode = 1; } } else if (e.severity === 2) { @@ -351,7 +352,7 @@ results.forEach(function(result) { if (e.message) { msg += ` - ${e.message}`; } - if (!program.fix && e.fix) { + if (!options.fix && e.fix) { fixes++; msg += ' (*)'; } @@ -386,7 +387,7 @@ if (results.length > 1) { } console.log('------------------------------------------------------------'); -if (program.fix) { +if (options.fix) { if (fixes > 0) { console.log(`Writing ${color.bold(fixes)} fixed files...`); await eslint.ESLint.outputFixes(results); -- 2.39.2