The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 03:37 UTC
| 1 | import { assert, describe } from "@effect/vitest"; |
| 2 | |
| 3 | import { createOxlintRuleHarness } from "../test/utils.ts"; |
| 4 | |
| 5 | const rule = createOxlintRuleHarness("t3code/no-mobile-pull-request-glyph-literals", { |
| 6 | filename: "apps/mobile/src/features/threads/PullRequestBadge.tsx", |
| 7 | }); |
| 8 | |
| 9 | describe("t3code/no-mobile-pull-request-glyph-literals", () => { |
| 10 | rule.valid( |
| 11 | "allows glyphs picked from the module", |
| 12 | ` |
| 13 | import { PullRequestGlyph } from "../pull-requests/pullRequestGlyphs"; |
| 14 | |
| 15 | const badge = <SymbolView name={merged ? PullRequestGlyph.merged : PullRequestGlyph.pullRequest} />; |
| 16 | `, |
| 17 | ); |
| 18 | |
| 19 | rule.valid( |
| 20 | "allows unrelated symbols and copy that mentions pull requests", |
| 21 | ` |
| 22 | const branch = <SymbolView name="arrow.triangle.branch" />; |
| 23 | const label = "Merge pull request"; |
| 24 | `, |
| 25 | ); |
| 26 | |
| 27 | rule.invalid( |
| 28 | "reports a pull request glyph in a JSX attribute", |
| 29 | `const badge = <SymbolView name="arrow.triangle.pull" />;`, |
| 30 | (output) => { |
| 31 | assert.match(output, /PullRequestGlyph/); |
| 32 | }, |
| 33 | ); |
| 34 | |
| 35 | rule.invalid( |
| 36 | "reports state glyphs chosen inline", |
| 37 | `const name = state === "closed" ? "git.pull-request.closed" : "git.pull-request.draft";`, |
| 38 | ); |
| 39 | |
| 40 | rule.invalid( |
| 41 | "reports glyphs in platform symbol objects", |
| 42 | `const icon = { ios: "arrow.triangle.merge", android: "merge" };`, |
| 43 | ); |
| 44 | |
| 45 | rule.invalid( |
| 46 | "reports an Android-only pull request glyph", |
| 47 | `const icon = { ios: "arrow.triangle.branch", android: "merge" };`, |
| 48 | ); |
| 49 | |
| 50 | rule.valid( |
| 51 | "allows merge as an ordinary string outside an android symbol slot", |
| 52 | `const action = { kind: "merge", label: "Merge" };`, |
| 53 | ); |
| 54 | |
| 55 | rule.valid( |
| 56 | "allows merge in an android key outside a platform symbol object", |
| 57 | `const command = { id: "pr.merge", android: "merge" };`, |
| 58 | ); |
| 59 | |
| 60 | rule.invalid( |
| 61 | "reports an Android-only pull request glyph written as a template literal", |
| 62 | 'const icon = { ios: "arrow.triangle.branch", android: `merge` };', |
| 63 | ); |
| 64 | |
| 65 | rule.invalid("reports glyphs in template literals", "const name = `square.3.layers.3d`;"); |
| 66 | }); |