Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 10 additions & 20 deletions src/rules/use-baseline.js
Original file line number Diff line number Diff line change
Expand Up @@ -543,26 +543,16 @@ export default /** @satisfies {UseBaselineRuleDefinition} */ ({
},
allowPropertyValues: {
type: "object",
properties: Object.fromEntries(
Array.from(properties.keys()).map(prop => {
const values = new Set([

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we want to keep the values, we could not construct Set here as globalKeywords.keys and propertyValues.get(prop).keys() have no overlap.
This would also remove the conversion from Set to Array for the enum.
Unfortunately this would be not enough for the test case below with stack size 100.
For me this reliably works for node version 26.10 (unaffected from this bug) with a stack size of 400.

Unfortunately we cannot use iterator helpers (by removing "Array.from()" around "properties.keys()" as we support v20 which also should help with decreasing the required memory.

...globalKeywords.keys(),
...(propertyValues.get(prop)?.keys() ?? []),
]);

return [
prop,
{
type: "array",
items: {
enum: Array.from(values),
},
uniqueItems: true,
},
];
}),
),
additionalProperties: false,
propertyNames: {
enum: Array.from(properties.keys()),
},
additionalProperties: {
type: "array",
items: {
type: "string",
},
uniqueItems: true,
},
},
allowSelectors: {
type: "array",
Expand Down
40 changes: 40 additions & 0 deletions tests/plugin/eslint.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import ESLintAPI from "eslint";
const { ESLint } = ESLintAPI;

import assert from "node:assert";
import { execFileSync } from "node:child_process";

//-----------------------------------------------------------------------------
// Tests
Expand Down Expand Up @@ -71,6 +72,45 @@ describe("Plugin", () => {
);
assert.strictEqual(results[0].messages[0].messageId, "emptyBlock");
});

it("use-baseline config should compile with limited stack space", () => {
const pluginUrl = new URL("../../src/index.js", import.meta.url)
.href;
const nodeExecutable = process.versions.bun
? "node"
: process.execPath;
const output = execFileSync(
nodeExecutable,
[
"--stack_size=100",
"--input-type=module",
"--eval",
`
import css from ${JSON.stringify(pluginUrl)};
import ESLintAPI from "eslint";

const { ESLint } = ESLintAPI;
const eslint = new ESLint({
overrideConfigFile: true,
overrideConfig: {
files: ["**/*.css"],
plugins: { css },
language: "css/css",
rules: {
"css/use-baseline": "error",
},
},
});

await eslint.calculateConfigForFile("test.css");
process.stdout.write("ok");
`,
],
{ encoding: "utf8", cwd: process.cwd() },
);

assert.strictEqual(output, "ok");
});
});

describe("languageOptions", () => {
Expand Down
Loading