prefer-sequence-overloads
Replaces simple two-keypoint ColorSequence and NumberSequence arrays with the shorter constructor overloads.
Rule details Problem
Section titled “Rule details ”ProblemThis rule only reports new ColorSequence([...]) and new NumberSequence([...]) when all of these are true:
- the constructor gets exactly one argument, and that argument is an array
- the array has exactly two elements
- both elements are
new ColorSequenceKeypoint(...)ornew NumberSequenceKeypoint(...) - the keypoint times are exactly
0and1 - each keypoint has exactly two arguments, so envelope keypoints are skipped
If both endpoint values are the same, the fixer uses the single-argument overload. Otherwise it uses the two-argument overload.
Examples
Section titled “Examples” Incorrect
new ColorSequence([ new ColorSequenceKeypoint(0, Color3.fromRGB(255, 0, 0)), new ColorSequenceKeypoint(1, Color3.fromRGB(0, 0, 255)),]);
new NumberSequence([ new NumberSequenceKeypoint(0, 0), new NumberSequenceKeypoint(1, 1),]); Correct
new ColorSequence(Color3.fromRGB(255, 0, 0), Color3.fromRGB(0, 0, 255));
new NumberSequence(0, 1);new NumberSequence(42);
new NumberSequence([ new NumberSequenceKeypoint(0, 10, 0.2), new NumberSequenceKeypoint(1, 90, 0.8),]);Related rules
Section titled “Related rules” prefer-udim2-shorthand Uses the shorter Roblox constructor form when the full constructor is redundant
prefer-pattern-replacements Applies configurable constructor and method rewrites