https://github.com/mpeterv/luacheck http://luacheck.readthedocs.io/en/stable/index.html
brew install lua51
sudo luarocks-5.1 install luacheck
I run luacheck as a commit hook and only run it on files that are going to be committed so I provide a list of specific files. I also add a config file that have Defold globals defined.
luacheck project/main/my_file.lua project/main/my_other_file.script --config project/tool/luacheck/luacheck_std.luacheckrc
I use these additional flags
--no-unused-args
I want allow not using all arguments
--no-color
I don't want color because I have it hooked up to commithook and sourcetree doesn't support it
--no-max-line-length
I don't care about the line length
--ignore 61.
I don't care about whitespace errors
The commit hook will run on commit and exit the commit if errors are found
- Place
pre-commit
in your /.git/hooks folder (pro tip: Symlink in a hooks folder from somewhere else in your repository, to make sure people doesn't have to update the hooks scripts manually) - Place
verify_lua.py
relative to thepre-commit
file, in the example below I assume it is in a subfolder called tests
Just wanted to say that this was super helpful, thanks!
I found this flag also very helpful:
--allow-defined
. Otherwise it seems I have to define all my functions in the luacheck config.