mustBeModuleLevel'{{className}}' from '{{importSource}}' must be instantiated at module level only.small-rules/require-module-level-instantiationRequire configured classes to be instantiated at module level only.
Some classes should only ever exist once per file, and Log from @rbxts/rbxts-sleitnick-log is the one I
care about: one logger per file, not a fresh instance every time a function runs. Let a class get
instantiated inside a loop or a helper and you end up with a pile of them doing the same job.
You tell the rule which classes matter through the classes option (class name mapped to its import
source). Anything you configure has to be created at module scope, or it reports. Keeps the expensive or
stateful stuff exactly where it belongs.
mustBeModuleLevel'{{className}}' from '{{importSource}}' must be instantiated at module level only.This rule accepts one options object after the severity.
import Log from "@rbxts/rbxts-sleitnick-log";
function useStoryModesState() { const log = new Log(); log.Info("test");}import Log from "@rbxts/rbxts-sleitnick-log";
const log = new Log();
function useStoryModesState() { log.Info("test");}