Skip to content

Prefer Sequence Overloads

SuggestionAuto-fixableRoblox
small-rules/prefer-sequence-overloads

Prefer direct ColorSequence and NumberSequence overloads over identical direct arguments and two-keypoint arrays.

Rationale

new ColorSequence(a, a) is just new ColorSequence(a) with extra typing and overhead. Same for NumberSequence. And new ColorSequence([a, b]) is the two-keypoint array form when new ColorSequence(a, b) exists and is FAR cheaper to run AND type.

This collapses both cases into the shorter overload. Auto-fixes when the keypoint values match what the overload expects. Works for ColorSequence and NumberSequence – anything with a Keypoint type.

Diagnostic Messages

preferSingleOverload
Use the single-value sequence overload instead of two identical keypoints.
preferTwoPointOverload
Use the two-value sequence overload instead of constructing a two-keypoint array.

Configuration

This rule does not accept options.

{
"jsPlugins": [
"@pobammer-ts/small-rules"
],
"rules": {
"small-rules/prefer-sequence-overloads": "error"
}
}

Examples

redundant sequence overload
const gradient = new ColorSequence(new Color3(), new Color3());

After auto-fix

const gradient = new ColorSequence(new Color3());
single-point ColorSequence overload
new ColorSequence(Color3.fromRGB(100, 200, 255));