preferSingleGetMultiple world.get() calls on the same entity should be combined into a single call for better performance. Suggested fix: {{fixedCode}}small-rules/prefer-single-world-queryEnforce combining multiple world.get() or world.has() calls into a single call for better Jecs performance.
Jecs lets you ask world for multiple components in one get() or has() call. Writing one query per
component against the same entity is just leaving performance on the table, and it reads like a shopping
list instead of one coherent request.
This rule finds consecutive queries on the same world and entity and collapses them into a single call. It auto-fixes, so you don’t have to hand-merge anything. I’d turn this on anywhere you use Jecs.
preferSingleGetMultiple world.get() calls on the same entity should be combined into a single call for better performance. Suggested fix: {{fixedCode}}preferSingleHasMultiple world.has() calls on the same entity should be combined into a single call for better performance. Suggested fix: {{fixedCode}}This rule does not accept options.
const componentA = world.get(entity, ComponentA);const componentB = world.get(entity, ComponentB);After auto-fix
const [componentA, componentB] = world.get(entity, ComponentA, ComponentB);const componentA = world.get(entity, ComponentA);