Use `globalThis` instead of bare `global` in utils (#4380)
## Description `isTestEnv` and `isRemoteDebuggingEnabled` read the bare `global`, which is React Native/Node-specific and doesn't exist in browsers — `utils.ts` is shared code that also runs on web. Both now use the standard `globalThis`, available in every runtime. To keep the pattern from coming back, a lint rule (`no-restricted-globals` scoped to `src/v3/**`, `src/web/**`, and root `src/*.ts`) now errors on any bare `global` reference in those files, with `globalThis` named in the message. `declare global` type-declaration blocks are unaffected (the rule counts scope references, not the TS keyword). ## Test plan - `yarn ts-check` clean; `yarn test` 103/103 (`isTestEnv` is exercised by every v3 hook test via the `disableReanimated` default; `isRemoteDebuggingEnabled` runs during handler creation) — no regression under RN/Node, where `globalThis === global` - Browser A/B probe (esbuild bundle of `src/utils.ts`, no bundler shims, WebKit): the new `globalThis` implementations return correct values; the old bare-`global` implementations throw `ReferenceError: Can't find variable: global` - Lint rule verified: baseline clean, fires with the actionable message on a violation, `declare global` blocks in `globals.ts`/`global.d.ts` unaffected
M
Michał Bert committed
fbcb989c3defc6ef862c991eb1714bf49b9a93bb
Parent: 1400f67
Committed by GitHub <noreply@github.com>
on 8/5/2026, 7:38:44 AM