LinuxCommandLibrary

luacheck

TLDR

Check Lua file

$ luacheck [file.lua]
copy
Check directory recursively
$ luacheck [directory]
copy
Check with specific standard
$ luacheck --std [lua53] [file.lua]
copy
Ignore specific warnings
$ luacheck --ignore [211] [file.lua]
copy
Output in different format
$ luacheck --formatter [TAP] [file.lua]
copy
Check from stdin
$ cat [file.lua] | luacheck -
copy

SYNOPSIS

luacheck [options] files...

DESCRIPTION

luacheck is a static analyzer and linter for Lua. It detects various issues including undefined globals, unused variables, unreachable code, and stylistic problems.
luacheck supports multiple Lua versions and can be configured per-project.

PARAMETERS

--std std

Lua version standard.
--ignore codes
Ignore warning codes.
--only codes
Show only specific codes.
--globals names
Allowed globals.
--formatter fmt
Output format (TAP, JUnit, plain).
--codes
Show warning codes.
-q, --quiet
Less verbose output.
--config file
Config file path.

CONFIGURATION

$ -- .luacheckrc
std = "lua53"
globals = {"myGlobal"}
ignore = {"212"}  -- unused argument
copy

CAVEATS

Static analysis only; won't catch runtime errors. May have false positives with dynamic code. Different standards for different Lua versions.

HISTORY

luacheck was created by Peter Melnichenko as a comprehensive Lua static analysis tool, filling the gap of linting tools for Lua.

SEE ALSO

lua(1), luac(1), selene(1)

Copied to clipboard