Writing
I write short notes on tools and habits that help with day-to-day engineering.
2025
- Import JSON modules with import attributesUse the type: json import attribute to load a JSON module in Node or a browser, with static or dynamic imports.
- Build a dropdown with the popover attributeUse popover and popovertarget to build an account menu that opens, closes on Escape or an outside click, and needs no JavaScript.
- Give one Playwright step its own timeoutPass a timeout option to test.step so a slow step fails in seconds with its own name, instead of burning the whole test timeout.
- Fix origin/HEAD after a default branch renameAfter a default branch rename, repair a stale origin/HEAD with git remote set-head or configure fetch to follow the remote.
- Disable a submit button with useFormStatusRead a React 19 form's pending state from a child component to disable its submit button during the action.
- Animate gradients using @propertyA gradient jumps on hover because its custom property is untyped. Register it with @property and the browser interpolates the stop.
- Fix React Testing Library 16 install errorsDeclare the DOM peer dependency to fix React Testing Library 16’s missing module error.
2024
- Assert roles and names with toHaveRoleUse Playwright to check a button’s computed role, accessible name and description.
- Match files with fs.globFind test files by pattern using Node 22’s built-in glob and globSync functions.
- Measure INP in the field by phaseINP replaced FID as a Core Web Vital in 2024. Log it from real visits with web-vitals and read input delay, processing, and presentation delay.
- Validate a URL with URL.canParseUse URL.canParse to check whether a string parses and apply a separate protocol check for HTTP links.
- Narrow types inside switch (true)Use switch (true) to narrow values with different boolean checks in TypeScript 5.3 and later.
- Fix ECONNREFUSED ::1 on localhost in NodeDiagnose an IPv6 loopback connection failure and point the client at the address your Node server listens on.
2023
- Migrate to verbatimModuleSyntaxMigrate to verbatimModuleSyntax by marking type-only imports and matching your import syntax to your output format.
- Size text with container query unitsSet container-type on a wrapper and size headings in cqi so the same card scales in a wide column and a narrow one.
- Cancel and time out fetch requestsSet your own fetch deadline with AbortSignal.timeout or cancel an in-flight request with AbortController.
- Choose useTransition or useDeferredValueUse useDeferredValue to defer a value you receive and useTransition to mark a state update you control as non-urgent.
- Review a PR without stashing your workUse git worktree add to check out a second branch in its own folder, review it, and remove it, while your edits stay put.
- Read from the end with Array.atUse .at(-1) to read an array’s last item, with undefined as the result when the array is empty.
- Build a confirmation modal with dialogClose a native confirmation dialog with method=dialog and read the button choice from returnValue.