Skip to content

No Has Before Remove In Jecs

ErrorAuto-fixableRoblox
small-rules/no-has-before-remove-in-jecs

Disallow redundant Jecs World.has guards around World.remove calls.

Rationale

Jecs already allows World.remove when the entity doesn’t have the component. A matching World.has guard adds branching without changing that result.

The rule follows world() imports from @rbxts/jecs; it doesn’t infer a World from a variable named world. It reports matching guards even when repeated argument evaluation prevents a safe fix.

Diagnostic Messages

removeWithoutHas
Jecs World.remove already handles an absent component.

Configuration

This rule does not accept options.

{
"jsPlugins": [
"@pobammer-ts/small-rules"
],
"rules": {
"small-rules/no-has-before-remove-in-jecs": "error"
}
}

Examples

guarded Jecs component removal
import { world } from "@rbxts/jecs";
const gameWorld = world();
if (gameWorld.has(entity, Component)) {
gameWorld.remove(entity, Component);
}

After auto-fix

import { world } from "@rbxts/jecs";
const gameWorld = world();
gameWorld.remove(entity, Component);
direct Jecs component removal
import { world } from "@rbxts/jecs";
const gameWorld = world();
gameWorld.remove(entity, Component);