Skip to content

Latest commit

 

History

History
54 lines (44 loc) · 1.19 KB

File metadata and controls

54 lines (44 loc) · 1.19 KB

Coding Convention

This is the convention that we agreed to use on this project.
This is not yet fixed, it may change if we see fit until the first release.

GLOBAL

GLOBAL_VAR = "" -- UpperCase
function GlobalFunc() end -- PascalCase

LOCAL

local someVariable = "" -- camelCase
local function someFunction() end -- camelCase

OBJECT

local MyObject = {} -- PascalCase
function MyObject.StaticMethod() end -- PascalCase 
function MyObject:instanceMethod() end -- camelCase

PARAMETERS

local function func(requiredParam) end -- camelCase
local function func(_optionalParam) end -- camelCase prefixed with underscore

MULTI PARAMETERS

Separate parameters with a space after the comma.

-- Wrong
function(param1,param2)
-- Good
function(param1, param2)

ANNOTATIONS

---@class MyClass Description of the class
local MyClass = {}

--- Short description of the usage of this method
---@param param1 string   Description of this parameter
---@return string
function MyClass:setName(param1)
    return param1
end

View Emmylua docs for more information about annotations.