fix(lint): drop Reflect.get from the native traps

main adopted anti-slop's `no-reflect-get` in #20874 and fixed the copy that lived
in `native-mounting-substitutes.ts`. This branch moved both traps into
`native-module-traps.ts`, so the rule lands here instead and the static-analysis
gate is red without the same narrowing.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
This commit is contained in:
Jinwoo-H
2026-09-15 18:27:13 -04:00
parent 0e2ffd7655
commit a7843b0dd9
@@ -24,10 +24,14 @@
export function partialNativeModule(module: string, members: Record<string, unknown>): unknown {
return new Proxy(members, {
get: (target, key) => {
if (typeof key === 'string' && key !== '__esModule' && !(key in target)) {
throw new Error(`Unsubstituted native member: ${module}.${key}`)
if (typeof key === 'string') {
if (key !== '__esModule' && !(key in target)) {
throw new Error(`Unsubstituted native member: ${module}.${key}`)
}
return target[key]
}
return Reflect.get(target, key)
// oxlint-disable-next-line typescript/consistent-type-assertions -- SAFETY: a symbol key cannot index the declared string record; the trap reads whatever the member object holds there.
return (target as Record<symbol, unknown>)[key]
}
})
}
@@ -45,7 +49,7 @@ export function nativeStoreModule(module: string, declared: Record<string, unkno
return undefined
}
if (typeof key === 'string' && key in target) {
return Reflect.get(target, key)
return target[key]
}
return (...args: unknown[]) => {
void args