no-useless-use-spring
errorSuggestion
Reports spring hook calls whose config is static and whose dependencies never update.
Rule details Suggestion
Section titled “Rule details Suggestion ”By default, this rule checks useSpring. It reports calls where the config object is fully static and the dependency
array is missing, omitted, or static. Empty dependency arrays are also reported by default.
Calls with both from and to in the config are skipped, because they can still represent a one-time mount animation.
Options
Section titled “Options”| Option | Type | Default | What it does |
|---|---|---|---|
springHooks |
string[] |
["useSpring"] |
Hook names treated as spring hooks |
staticGlobalFactories |
string[] |
Roblox value constructors such as Vector3, UDim2, Color3, and CFrame |
Names treated as static constructors |
treatEmptyDepsAsViolation |
boolean |
true |
Reports [] when the config is static |
Examples
Section titled “Examples”Incorrect
const spring = useSpring({ opacity: 1 });
const DEFAULT_SCALE = 1.5;const scale = useSpring({ scale: DEFAULT_SCALE }, [DEFAULT_SCALE]);Correct
const spring = useSpring({ opacity: isOpen ? 1 : 0 }, [isOpen]);
const intro = useSpring({ from: { scale: 0 }, to: { scale: 1 },}, []);Related rules
Section titled “Related rules”no-useless-use-memoMoves static memo values to module scope
use-exhaustive-dependenciesChecks hook dependency lists
no-identity-mapRemoves data transforms that do nothing
