Skip to content
Permalink
Browse files
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: #16255 (comment)

* fix: windows compat

* Update Makefile.js

Co-authored-by: Milos Djermanovic <milos.djermanovic@gmail.com>

Co-authored-by: Milos Djermanovic <milos.djermanovic@gmail.com>
  • Loading branch information
aladdin-add and mdjermanovic committed Aug 31, 2022
1 parent 279f0af commit 42bfbd7b7b91106e5f279a05f40c20769e3cd29f
Showing 1 changed file with 19 additions and 12 deletions.
@@ -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);

0 comments on commit 42bfbd7

Please sign in to comment.