-
Notifications
You must be signed in to change notification settings - Fork 58
Styleguide
Adrian L Lange edited this page May 25, 2020
·
2 revisions
- Readability above all
- Use whitespace generously
- Descriptive variable and function names
- Tabs, not spaces
- With the exception of in documentation
- Local functions should be defined as
local function foo() end
- Local functions should be named in "mixed case"
- e.g
oneTwoThree
- With the exception of in elements where they should be named alike global functions
- e.g
- Global functions (methods) should be named in "pascal case"
- e.g
OneTwoThree
- e.g
- Constants should be named in all uppercase
- Blizzard-provided constants used should be upvalued and contain fallback values
- Local references to global API (upvalues) should be named the same as the original
- With the exception of libraries, e.g
math.abs
becomesmath_abs
- With the exception of libraries, e.g
- Use single quotes (') for strings
- With the exception in XML files where double quotes (") should be used
- Call libraries by the library reference, e.g
string.match('foo', 'bar')
- With the exception of on variables, e.g
foo:match('bar')
- With the exception of on variables, e.g
- Multiline comment should use
--
, as--[[ ]]
is reserved for documentation - Define local variables for table references when referring more than twice