Skip to content

Prefer Single World Query

SuggestionAuto-fixableRoblox
small-rules/prefer-single-world-query

Enforce combining multiple world.get() or world.has() calls into a single call for better Jecs performance.

Diagnostic Messages

preferSingleGet
Multiple world.get() calls on the same entity should be combined into a single call for better performance. Suggested fix: {{fixedCode}}
preferSingleHas
Multiple world.has() calls on the same entity should be combined into a single call for better performance. Suggested fix: {{fixedCode}}

Configuration

This rule does not accept options.

{
"jsPlugins": [
"@pobammer-ts/small-rules"
],
"rules": {
"small-rules/prefer-single-world-query": "error"
}
}

Examples

repeated world get calls
const componentA = world.get(entity, ComponentA);
const componentB = world.get(entity, ComponentB);

After auto-fix

const [componentA, componentB] = world.get(entity, ComponentA, ComponentB);
single world get call
const componentA = world.get(entity, ComponentA);