glualint
glualint - Linter and pretty printer for Garry's Mod's variant of Lua.
Installing
- Download the latest version of
glualint
from the releases page OR compile it yourself. - Place the
glualint
executable inside some folder. - Add the folder you put
glualint
in to yourPATH
. How this is done differs per operating system. If you're not sure how to do this, please Google"Add to path <YOUR OS>"
. - Make sure you restart any terminals or text editors you currently have open.
After performing these steps, you can run glualint
from the terminal or let your text editor use it as your linter. Failing to specifically perform the third step will make glualint
very unlikely to work.
Command line parameters
Parameter | Description |
---|---|
--version |
Returns the version of glualint |
--config |
Set to a glualing.json file for glualint configuration. See "Configuring glualint" |
--pretty-print |
Will pretty-print (re-structure/re-indent) all code given in stdin. When entering code in terminal, press Ctrl+D to finish the input. |
--indentation='something' |
For pretty-print: indents all pretty-printed code with the given string. Four spaces by default, should probably some amount of tabs or spaces. |
Configuring glualint
glualint
Allows some configuration. This is done through a file called glualint.json
or .glualint.json
. glualint
looks for this file in three places (in order of priority)
- The file you give to the
--config
parameter (when using the terminal) - Any folder above the file you're working in (e.g. the root of your project)
- Your home folder, which is
C:\users\yourusername\.glualint.json
on Windows or/home/yourusername/.glualint.json
on Unix.
Note: The file must either be called glualint.json
or .glualint.json
.
Example glualint.json
with the default options:
{
"lint_maxScopeDepth": 7,
"lint_syntaxErrors": true,
"lint_syntaxInconsistencies": true,
"lint_deprecated": true,
"lint_whitespaceStyle": true,
"lint_beginnerMistakes": true,
"lint_emptyBlocks": true,
"lint_shadowing": true,
"lint_gotos": true,
"lint_doubleNegations": true,
"lint_duplicateTableKeys": true,
"lint_profanity": true,
"lint_unusedVars": true,
"lint_unusedParameters": false,
"lint_unusedLoopVars": false,
"prettyprint_spaceAfterParens": false,
"prettyprint_spaceAfterBrackets": false,
"prettyprint_spaceAfterBraces": false,
"prettyprint_spaceBeforeComma": false,
"prettyprint_spaceAfterComma": true,
"prettyprint_semicolons": false,
"prettyprint_cStyle": false,
"prettyprint_indentation": " "
}
All options explained:
Linter options
lint_maxScopeDepth
: Maximum depth of scopes in your code. Any terrible scripter can build the most atrocious sideways code pyramids, usually without knowing. The number here is at which step the linter will start calling you out on it. Set to0
if you're king Tut and want to disable it.lint_syntaxErrors
: Whether syntax errors should be reported. This is off by default becausegluac
shows nicer syntax errors.lint_syntaxInconsistencies
: Warn for syntax inconsistencies (using both&&
andand
, that kind of stuff)lint_deprecated
: Warn for deprecated functions. These functions are taken from the GMod wiki, don't blame me for the things that are on there.lint_whitespaceStyle
: Warn for shitty whitespace behaviour (e.g. lack of spaces around operators and keywords)lint_beginnerMistakes
: Warn for typical beginner mistakes (using self in non-metafunction,net.WriteEntity(LocalPlayer())
in a net message, using self.Weapon in a SWEP etc.)lint_emptyBlocks
: Warn for empty blockslint_shadowing
: Warn for variable shadowinglint_gotos
: Warn for inappropriate gotos (i.e. the ones not used to jump out of a double loop)lint_doubleNegations
: Warn for double negations (things likenot (a == b)
)lint_duplicateTableKeys
: Warn for duplicate table keys (e.g.{a = 1, a = 2}
)lint_profanity
: Warn for profanity (bitch, cock, cocks, cunt, dick, dicks, fuck, fucking, goddamnit, knob, knobs, motherfucker, nigger, niggers, niggertits, nipple, shit)lint_unusedVars
: Warn for variables that are never usedlint_unusedParameters
: Warn for function parameters that are never used. NOTE: Only has effect whenlint_unusedVars
is enabled!lint_unusedLoopVars
: Warn for loop variables that are never used (for k,v in ...
). NOTE: Only has effect whenlint_unusedVars
is enabled!
Pretty print options
These options affect the pretty printing functionality of glualint
.
prettyprint_spaceAfterParens
: Put a space between all parenthesesprettyprint_spaceAfterBrackets
: Put a space between all bracketsprettyprint_spaceAfterBraces
: Put a space between all curly bracesprettyprint_semicolons
: Clutter the script with semicolons after every damn statementprettyprint_cStyle
: Use C style operators and comments everywhereprettyprint_indentation
: What to use for indentation. Any string is valid, but some amount of spaces or"\t"
is recommendedprettyprint_spaceBeforeComma
: Whether to place a space before every commaprettyprint_spaceAfterComma
: Whether to place a space after every comma