Skip to content
Source
Sign inSign up

max-settings-description-length.test.ts

43 lines1.1 KB

1import { describe } from "@effect/vitest";
2​
3import { createOxlintRuleHarness } from "../test/utils.ts";
4​
5const rule = createOxlintRuleHarness("t3code/max-settings-description-length", {
6 filename: "apps/web/src/components/settings/Example.tsx",
7});
8​
9const long = "Agents ".repeat(30);
10​
11describe("t3code/max-settings-description-length", () => {
12 rule.valid(
13 "allows a short description",
14 `const row = <SettingsRow title="Theme" description="Choose how T3 Code looks." />;`,
15 );
16​
17 rule.valid(
18 "does not count dynamic text",
19 `const row = <SettingsRow title="Task" description={\`${long.slice(0, 150)}\${prompt}\`} />;`,
20 );
21​
22 rule.invalid(
23 "reports a long string description",
24 `const row = <SettingsRow title="Theme" description="${long}" />;`,
25 );
26​
27 rule.invalid(
28 "counts link text inside a JSX description",
29 `
30 const row = (
31 <SettingsRow
32 title="Guests"
33 description={
34 <>
35 ${long.slice(0, 150)}{" "}
36 <Link to="/docs">${long.slice(0, 60)}</Link>
37 </>
38 }
39 />
40 );
41 `,
42 );
43});