no-events-in-events-callback
Disallow calling Events for the same player inside an Events.connect() callback.
Rule details Problem
Section titled “Rule details ”ProblemThis rule looks for Flamework Events imports from the paths you configure in eventsImportPaths.
Inside an Events.connect() callback, it tracks the first callback parameter as the current player. If you call any
method on the tracked Events object and pass that same player as the first argument, the rule reports it.
That includes simple aliases such as const samePlayer = player, destructuring from objects or arrays that hold the
player, and later assignments. Calls inside nested functions are ignored.
Options
Section titled “Options”eventsImportPaths is required by the schema and defaults to an empty array.
import plugin from "eslint-plugin-cease-nonsense";
export default [ { plugins: { "cease-nonsense": plugin }, rules: { "cease-nonsense/no-events-in-events-callback": [ "error", { eventsImportPaths: ["server/networking", "shared/networking"] }, ], }, },];Examples
Section titled “Examples” Incorrect
import { Events } from "server/networking";
Events.units.unequipUnit.connect((player, unitKey) => { if (unitKey.size() > 0) { Events.promptNotification.fire(player, "error"); }});
Events.someEvent.connect((player) => { const samePlayer = player; Events.someEvent.fire(samePlayer, data);}); Correct
import { Events, Functions } from "server/networking";
Events.units.unequipUnit.connect((player, unitKey) => { if (unitKey.size() > 0) { Functions.units.notifyPlayer(player, "error"); }});
Events.someEvent.connect((player, otherPlayer) => { Events.someEvent.fire(otherPlayer, data);});
function later(player: Player) { Events.someEvent.fire(player, data);}Related rules
Section titled “Related rules” Flamework documentation Flamework docs for networking patterns and APIs.