// How the front matter reader grows on the inputs @changesets/parse's own // mdRegex backtracks quadratically on: a long run of whitespace or newlines // with no closing fence. `frontMatter.test.ts` holds what it answers. import { describe, it } from "@effect/vitest"; import { Growth } from "@effected/testing"; import { ChangesetFile } from "../src/ChangesetFile.js"; import { ChangesetLint } from "../src/ChangesetLint.js"; describe("the front matter reader on unclosed whitespace runs", () => { it("reads an opening fence and a run of newlines and spaces in linear time", () => { Growth.assertOrder( (count) => { const text = `---${"\n ".repeat(count)}x`; return () => ChangesetFile.parseResult(text); }, { from: 20_000, order: 1 }, ); }); it("reads a long run of spaces before any fence in linear time", () => { Growth.assertOrder( (count) => { const text = `${" ".repeat(count)}x`; return () => ChangesetFile.parseResult(text); }, { from: 20_000, order: 1 }, ); }); it("lints an opening fence and a run of newlines in linear time", () => { Growth.assertOrder( (count) => { const text = `---${"\n".repeat(count)}x`; return () => ChangesetLint.lint(text); }, { from: 5_000, order: 1 }, ); }); });