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)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id DBC21831B2 for ; Thu, 2 Dec 2021 13:54:50 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id C67BD19919 for ; Thu, 2 Dec 2021 13:54:20 +0100 (CET) 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 id 5B3391990E for ; Thu, 2 Dec 2021 13:54:19 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 2F05C44DA0 for ; Thu, 2 Dec 2021 13:54:19 +0100 (CET) From: Dominik Csapak To: pve-devel@lists.proxmox.com Date: Thu, 2 Dec 2021 13:54:18 +0100 Message-Id: <20211202125418.41303-1-d.csapak@proxmox.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.178 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% 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 Subject: [pve-devel] [PATCH eslint] change from CLIEngine to ESLint 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: Thu, 02 Dec 2021 12:54:50 -0000 8.0 officialy removed CLIEngine (though it's still in git) so use the current and supported API. Necessary changes: * use 'ESLint' instead of 'CLIEngine' * use 'lintFiles' instead of 'executeOnFiles' (thats async now) * adapt to the change of return value of 'lintFiles' Signed-off-by: Dominik Csapak --- after appliying this, we have to 'make buildupstream' again, since the included code changes (CLIEngine -> ESLint) patches/0001-adapt-webpack-config.patch | 2 +- src/bin/app.js | 4 ++-- src/lib/worker.js | 12 +++++++----- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/patches/0001-adapt-webpack-config.patch b/patches/0001-adapt-webpack-config.patch index b0201e1..a1235d3 100644 --- a/patches/0001-adapt-webpack-config.patch +++ b/patches/0001-adapt-webpack-config.patch @@ -22,7 +22,7 @@ index a22c99b..9209159 100644 + target: "node", entry: { - eslint: ["core-js/stable", "regenerator-runtime/runtime", "./lib/linter/linter.js"] -+ eslint: ["core-js/stable", "regenerator-runtime/runtime", "./lib/linter/linter.js", "./lib/cli-engine/index.js"] ++ eslint: ["core-js/stable", "regenerator-runtime/runtime", "./lib/linter/linter.js", "./lib/eslint/index.js"] }, output: { filename: "[name].js", diff --git a/src/bin/app.js b/src/bin/app.js index 10e7e6a..a1ba89f 100644 --- a/src/bin/app.js +++ b/src/bin/app.js @@ -313,7 +313,7 @@ promises.push(eslint.createWorker({ files: paths })); -let results = (await Promise.all(promises)).map(res => res.results).flat(1); +let results = (await Promise.all(promises)).flat(1); let exitcode = 0; let files_err = [], files_warn = [], files_ok = []; @@ -390,7 +390,7 @@ console.log('------------------------------------------------------------'); if (program.fix) { if (fixes > 0) { console.log(`Writing ${color.bold(fixes)} fixed files...`); - eslint.CLIEngine.outputFixes({ results }); + eslint.ESLint.outputFixes({ results }); console.log('Done'); } else { console.log("No fixable Errors/Warnings found."); diff --git a/src/lib/worker.js b/src/lib/worker.js index 9a8c955..000209e 100644 --- a/src/lib/worker.js +++ b/src/lib/worker.js @@ -3,11 +3,13 @@ const worker = require('worker_threads'); if (!worker.isMainThread) { - const eslint = require('pve-eslint'); - const data = worker.workerData; - const cli = new eslint.CLIEngine(data.cliOptions); - const report = cli.executeOnFiles(data.files); - worker.parentPort.postMessage(report); + (async function() { + const eslint = require('pve-eslint'); + const data = worker.workerData; + const cli = new eslint.ESLint(data.cliOptions); + const report = await cli.lintFiles(data.files); + worker.parentPort.postMessage(report); + })(); } else { module.exports = async function createWorker(workerData) { return new Promise((resolve, reject) => { -- 2.30.2