mirror of
https://github.com/stablyai/orca.git
synced 2026-10-07 08:02:21 +00:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user