@@ -29,6 +29,21 @@ space_after_function_names = "Never"
2929enabled = false
3030```
3131
32+ ## Type checks with LuaCATS annotations
33+
34+ Lua is incredibly responsive when used for configuration or scripting, giving immediate feedback.
35+ But in the context of a project that needs to be maintained long-term, its dynamic typing casts
36+ shadows of unpredictability, making Lua projects susceptible to unexpected bugs at the wrong time.
37+
38+ To help mitigate this, Lux provides a ` lx check ` command, which uses [ emmylua_check] ( https://github.com/EmmyLuaLs/emmylua-analyzer-rust )
39+ to statically type-check your codebase based on [ LuaCATS annotations] ( https://github.com/EmmyLuaLs/emmylua-analyzer-rust ) .
40+
41+ The command will:
42+
43+ 1 . Build your project and its dependencies if not done already.
44+ 2 . Generate workspace library entries for a [ ` .luarc.json ` file] ( https://github.com/LuaLS/lua-language-server/wiki/Configuration-File ) .
45+ 3 . Run the static checker.
46+
3247## Linting with ` luacheck `
3348
3449Linting is the process of analyzing code for stylistic and logic error (lines too long, unused variables, etc.).
@@ -38,12 +53,12 @@ Lux comes with `luacheck`, a linter for Lua code, built-in. To run `luacheck` on
3853lx lint
3954```
4055
41- We recommend running this automatically through a git hook, or running it manually at the end of every significant
42- addition/refactor of your code.
56+ We recommend running checks and lints automatically through a git hook,
57+ or running them manually at the end of every significant addition/refactor of your code.
4358
4459## Git Hooks
4560
46- We recommend setting up a Git hook to run ` lx lint ` and ` lx fmt ` before
61+ We recommend setting up a Git hook to run ` lx check ` , ` lx lint` and ` lx fmt ` before
4762each commit to ensure that you never forget to lint and format your code.
4863
4964To set up a Git hook, create a file called ` .git/hooks/pre-commit ` in your
@@ -52,6 +67,7 @@ project directory with the following content:
5267``` sh
5368#! /bin/sh
5469
70+ lx check
5571lx lint
5672lx fmt
5773```
0 commit comments