Skip to main content

Naming

File header

Every .lua file starts with the license header, then one blank line:

Typing

  • Every function has LuaLS annotations: ---@param, ---@return.
  • Namespaces are plain tables with a ---@class. The source is the type source of truth.
  • To define functions through a local, the local is the class declaration:
  • Enums use ---@enum directly on the field.
  • Multiple returns keep one type per slot: ok, value, errorCode, never ok, valueOrMessage.
  • Gaps in the CfxLua types go in types/cfx.lua, never in ---@diagnostic comments.

Errors

  • Mutating functions return ok, value or ok, errorCode with codes from UgCore.Enums.Errors.
  • Programmer errors raise with UgCore.Internal.Utils.Raise(level, message, ...), never error. Messages never include the [ug-core] prefix.
  • Stack traces never reach clients.

Comments

Short sentences. RFC 2119 keywords for obligations. Comment only where the code needs clarification. Never narrate.

Performance

Cache globals and natives in locals only on hot paths: per request, per item or per tick. Everything else calls them directly.

Commits

Conventional Commits. Imperative, lowercase subject, no period, 72 characters max.
Scopes: core, players, characters, accounts, jobs, gangs, permissions, identity, sessions, modules, callback, network, events, lifecycle, hooks, database, exports, config, locale, ci, deps.