Skip to content

Commit 398d3a8

Browse files
authored
Fix benchmark script (#7504)
This fixes the broken benchmark script (`npm run benchmark`) The error reason is that `rules[ruleName]` has returned a `Promise` since 16.0.0. ```sh-session $ npm run benchmark-rule -- value-keyword-case lower ... const rule = ruleFunc(primary, secondary, context); ^ TypeError: ruleFunc is not a function ... ``` Also, this changes `parserOptions.ecmaVersion` in the ESLint config to allow top-level `await`.
1 parent 3de4eba commit 398d3a8

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

package.json

+3
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@
8080
},
8181
"prettier": "@stylelint/prettier-config",
8282
"eslintConfig": {
83+
"parserOptions": {
84+
"ecmaVersion": 2023
85+
},
8386
"extends": [
8487
"stylelint",
8588
"stylelint/jest"

scripts/benchmark-rule.mjs

+2-4
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ const { bold, yellow } = picocolors;
1212

1313
const [, , ruleName, ruleOptions, ruleContext] = argv;
1414

15-
const ruleFunc = rules[ruleName];
16-
1715
function printHelp() {
1816
const script = 'node benchmark-rule.mjs';
1917

@@ -32,7 +30,7 @@ function printHelp() {
3230
);
3331
}
3432

35-
if (!ruleFunc || !ruleOptions) {
33+
if (!ruleName || !(ruleName in rules) || !ruleOptions) {
3634
printHelp();
3735
exit(-1);
3836
}
@@ -65,7 +63,7 @@ const ruleSettings = normalizeRuleSettings(parsedOptions);
6563
const [primary, secondary] = ruleSettings;
6664
const context = ruleContext ? JSON.parse(ruleContext) : {};
6765

68-
const rule = ruleFunc(primary, secondary, context);
66+
const rule = (await rules[ruleName])(primary, secondary, context);
6967

7068
const processor = postcss().use(rule);
7169

0 commit comments

Comments
 (0)