From 42bfbd7b7b91106e5f279a05f40c20769e3cd29f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=94=AF=E7=84=B6?= Date: Wed, 31 Aug 2022 19:43:29 +0800 Subject: [PATCH] chore: fix `npm run perf` crashes (#16258) * 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 * fix: windows compat * Update Makefile.js Co-authored-by: Milos Djermanovic Co-authored-by: Milos Djermanovic --- Makefile.js | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/Makefile.js b/Makefile.js index a9c527df557..1f353687398 100644 --- a/Makefile.js +++ b/Makefile.js @@ -76,9 +76,14 @@ 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"`, + + /* + * glob arguments with Windows separator `\` don't work: + * https://github.com/eslint/eslint/issues/16259 + */ + PERF_MULTIFILES_TARGETS = `"${TEMP_DIR}eslint/performance/eslint/{lib,tests/lib}/**/*.js"`, // Settings MOCHA_TIMEOUT = parseInt(process.env.ESLINT_MOCHA_TIMEOUT, 10) || 10000; @@ -911,19 +916,21 @@ 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`); + } + + const content = ` +module.exports = [{ + "languageOptions": {sourceType: "commonjs"}, + "rules": { + ${rules} } +}];`; - content.join("\n").to(PERF_ESLINTRC); + content.to(PERF_ESLINTRC); } /** @@ -983,7 +990,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);