The best way to control Claude Code, Codex and more from any computer or phone
| 1 | import { describe } from "@effect/vitest"; |
| 2 | |
| 3 | import { createOxlintRuleHarness } from "../test/utils.ts"; |
| 4 | |
| 5 | const rule = createOxlintRuleHarness("t3code/no-raw-resize-observer"); |
| 6 | |
| 7 | describe("t3code/no-raw-resize-observer", () => { |
| 8 | rule.valid( |
| 9 | "allows ResizeObserver types and feature detection", |
| 10 | ` |
| 11 | let observer: ResizeObserver | null = null; |
| 12 | export const supported = typeof ResizeObserver !== "undefined"; |
| 13 | export const entries: ResizeObserverEntry[] = []; |
| 14 | `, |
| 15 | ); |
| 16 | |
| 17 | rule.valid( |
| 18 | "allows other DOM observers", |
| 19 | `export const observer = new MutationObserver(() => {});`, |
| 20 | ); |
| 21 | |
| 22 | rule.invalid( |
| 23 | "reports a direct ResizeObserver construction", |
| 24 | `export const observer = new ResizeObserver(() => {});`, |
| 25 | ); |
| 26 | |
| 27 | rule.invalid( |
| 28 | "reports construction through a global object", |
| 29 | `export const observer = new window.ResizeObserver(() => {});`, |
| 30 | ); |
| 31 | |
| 32 | rule.invalid( |
| 33 | "reports computed construction through a global object", |
| 34 | `export const observer = new globalThis["ResizeObserver"](() => {});`, |
| 35 | ); |
| 36 | }); |