From f77c9585290d8e3a3ad3c17e0635f890c3479228 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=94=AF=E7=84=B6?= Date: Mon, 29 Aug 2022 16:13:02 +0800 Subject: [PATCH] chore: fix `npm run perf` crashes it was crashing as eslint treat the `.eslintrc.yml` to be js. this commit changes the generated configs to `eslint.config.js`. refs: https://github.com/eslint/eslint/issues/16255#issuecomment-1229817918 --- Makefile.js | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/Makefile.js b/Makefile.js index a9c527df557b..a9b8b830906e 100644 --- a/Makefile.js +++ b/Makefile.js @@ -76,7 +76,7 @@ const NODE = "node ", // intentional extra space MARKDOWNLINT_IGNORE_INSTANCE = ignore().add(fs.readFileSync(path.join(__dirname, ".markdownlintignore"), "utf-8")), MARKDOWN_FILES_ARRAY = MARKDOWNLINT_IGNORE_INSTANCE.filter(find("docs/").concat(ls(".")).filter(fileType("md"))), TEST_FILES = "\"tests/{bin,conf,lib,tools}/**/*.js\"", - PERF_ESLINTRC = path.join(PERF_TMP_DIR, "eslintrc.yml"), + PERF_ESLINTRC = path.join(PERF_TMP_DIR, "eslint.config.js"), PERF_MULTIFILES_TARGET_DIR = path.join(PERF_TMP_DIR, "eslint"), PERF_MULTIFILES_TARGETS = `"${PERF_MULTIFILES_TARGET_DIR + path.sep}{lib,tests${path.sep}lib}${path.sep}**${path.sep}*.js"`, @@ -911,19 +911,20 @@ function downloadMultifilesTestTarget(cb) { * @returns {void} */ function createConfigForPerformanceTest() { - const content = [ - "root: true", - "env:", - " node: true", - " es6: true", - "rules:" - ]; + let rules = ""; for (const [ruleId] of builtinRules) { - content.push(` ${ruleId}: 1`); + rules += (` "${ruleId}": 1,\n`); } - content.join("\n").to(PERF_ESLINTRC); + const content = `module.exports = [{ + "languageOptions": {sourceType: "commonjs"}, + "rules": { + ${rules} + } +}];`; + + content.to(PERF_ESLINTRC); } /** @@ -983,7 +984,7 @@ function time(cmd, runs, runNumber, results, cb) { function runPerformanceTest(title, targets, multiplier, cb) { const cpuSpeed = os.cpus()[0].speed, max = multiplier / cpuSpeed, - cmd = `${ESLINT}--config "${PERF_ESLINTRC}" --no-eslintrc --no-ignore ${targets}`; + cmd = `${ESLINT}--config "${PERF_ESLINTRC}" --no-config-lookup --no-ignore ${targets}`; echo(""); echo(title);