Skip to content

No Instance Methods Without This

ErrorRoblox
small-rules/no-instance-methods-without-this

Detect instance methods that do not use 'this' and suggest converting them to standalone functions for better performance in roblox-ts.

Diagnostic Messages

noInstanceMethodWithoutThis
Method '{{methodName}}' does not use 'this' and creates unnecessary metatable overhead in roblox-ts. Convert it to a standalone function for better performance.

Configuration

This rule accepts one options object after the severity.

checkPrivateOptional

Check private methods (default: true)

checkProtectedOptional

Check protected methods (default: true)

checkPublicOptional

Check public methods (default: true)

{
"jsPlugins": [
"@pobammer-ts/small-rules"
],
"rules": {
"small-rules/no-instance-methods-without-this": [
"error",
{
"checkPrivate": true,
"checkProtected": true,
"checkPublic": true
}
]
}
}

Examples

instance method without this
class MyClass {
private notifyChanges(value: number): void {
console.log(value);
}
}
static method without this
class MyClass {
static helper(): void {
console.log("static");
}
}