Linters
What is Luacheck? An introduction to the Luacheck project's static analyzer and linter for Lua
Luacheck is a static analyzer and linter for Lua code. It detects issues such as undefined globals, unused variables, uninitialized variable access and unreachable code. It supports Lua 5.1 - 5.4 and LuaJIT syntax.
- Tool
- Luacheck
- Made by
- Luacheck project
- Official site
- github.com/lunarmodules/luacheck
- Category
- Linters
Who makes Luacheck
Luacheck is developed by the Luacheck project. The official website, which is the project's GitHub repository, is linked below.
Official website: github.com/lunarmodules/luacheck
What Luacheck is for
Luacheck examines Lua source code without running it and reports likely problems. Typical findings include undefined globals, unused variables, uninitialized variable access and unreachable code.
Checking is highly configurable, including custom globals and standard library selection. This lets a project describe the environment its Lua code runs in, so that the results reflect how the code is actually used.
Who Luacheck is for
The vendor does not state a specific audience. Luacheck suits anyone writing Lua who wants automated checks, whether they work in an editor, a terminal or a CI workflow.
Because it supports Lua 5.1 - 5.4 and LuaJIT syntax, it can be used on code targeting any of those versions.
Notable capabilities
Luacheck combines a set of detection checks with flexible configuration and several ways to run it.
- Issue detection: it finds undefined globals, unused variables, uninitialized variable access and unreachable code.
- Flexible configuration: options can be set on the command line, in a config file, or in comments within checked files.
- Version coverage: it supports Lua 5.1 - 5.4 and LuaJIT syntax.
- Input options: it can check files, rockspecs or directories passed on the command line.
- Parallel checking: this is available, and it requires LuaLanes.
- Editor plugins: plugins exist for Vim, Sublime Text, Atom, Emacs, Brackets, VS Code, Nova and Geany.
- Docker: it can be run as a standalone Docker container, with prebuilt images on GitHub Container Registry.
- CI integration: a GitHub Action is available for running Luacheck in CI workflows.
How Luacheck fits linters
Luacheck is a language-specific linter. It is dedicated to Lua and combines linting with static analysis in one tool, such as finding unreachable code and uninitialized variable access.
In Linthelm's wider niche of linters, static analysis and code quality, it plays the same role for Lua that other single-language tools play elsewhere. It is itself written in Lua and runs on all supported Lua versions.
Luacheck is installed via LuaRocks, and a single-file 64-bit binary distribution is available for Windows. It is released under the MIT license.
Frequently asked questions
What is Luacheck used for?
Luacheck is a static analyzer and linter for Lua. It detects issues such as undefined globals, unused variables, uninitialized variable access and unreachable code.
Which Lua versions does Luacheck support?
It supports Lua 5.1 - 5.4 and LuaJIT syntax. Luacheck is itself written in Lua and runs on all supported Lua versions.
How do I install Luacheck?
Luacheck is installed via LuaRocks. A single-file 64-bit binary distribution is available for Windows, and it can also run as a Docker container.
Does Luacheck have editor plugins?
Yes. Plugins exist for Vim, Sublime Text, Atom, Emacs, Brackets, VS Code, Nova and Geany.
Can Luacheck run in CI?
Yes. A GitHub Action is available for running Luacheck in CI workflows.
Linthelm is independent and is not affiliated with Luacheck project. Product names belong to their owners. Features change; confirm details on the official website.