← Files Meme Marketing AgentARCHIVED FILE
tools/oxlint/anti-slop/rules/no-reflect-get.ts
939 Bytes · Oct 4, 2026 · 12:36 UTC
import { defineRule } from "@oxlint/plugins";
import { isGlobalReflectMethodCall } from "../shared/reflect-method.ts";
/** Ban Reflect.get, which bypasses ordinary property access and useful type evidence. */
export const noReflectGetRule = defineRule({
meta: {
type: "problem",
docs: {
description:
"Disallow Reflect.get; use typed property access or parse dynamic input into a domain type.",
},
messages: {
reflectGet:
"Replace `Reflect.get` with typed property access. Parse dynamic input into a named domain type before reading it.",
},
},
createOnce(context) {
return {
CallExpression(node) {
if (node.callee.type === "Super" || node.callee.type === "V8IntrinsicExpression") return;
if (isGlobalReflectMethodCall(context.sourceCode, node.callee, "get")) {
context.report({ node, messageId: "reflectGet" });
}
},
};
},
});
SHA-256: 95c5aa0f8e23b10d9345b1776082e08704ec6590298176a8ede8dfdb6e7cb56f