prefer-module-level-constant
Hoist literal-only constant collections and regexes out of function bodies to module scope so they are allocated once.
Why
Recreating immutable lookup data on every call wastes allocations and obscures its constant nature.
Fix
Declare immutable literal collections and non-stateful regular expressions once at module scope.
Examples
function isAllowed(key: string) { const KEYS = ["a", "b", "c"]; return KEYS.includes(key);}const KEYS = ["a", "b", "c"] as const;function isAllowed(key: string) { return KEYS.includes(key);}