Skip to content
This repository was archived by the owner on May 15, 2023. It is now read-only.
This repository was archived by the owner on May 15, 2023. It is now read-only.

Project file naming convention #7

@Cassolette

Description

@Cassolette

Lua

  1. Files that export a singular Class type, similar to ES modules default export, will use CamelCase.lua.
  2. Files that export a regular table, similar to ES modules named exports, will use camelCase.lua.
  3. Files should not execute code within the root-level that will affect external runtime environment or behavior during the course of inclusion. The exception is made for files named bt-init.lua.

Wrong

-- module.lua
local exports = {}

-- this chunk is okay because it only changes internal vars
local names = {}
for ... do
  names[#names+1] =...
end

-- this chunk is NOT okay because it touches external vars
tfm.exec.chatMessage("test")
_G.print = nil

return exports 

Correct

-- module.lua
local exports = {}

-- this chunk is also okay because it does not touch external vars in the course of inclusion
exports.btInit = function ()
  tfm.exec.chatMessage("test")
  _G.print = nil
end

return exports 
-- bt-init.lua
local module = require("module")

-- allow touching external vars in the course of inclusion for bt-init.lua
module.btInit()
_G.hello = 0

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentation

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions