FiveM Lua Linter action
A GitHub action that you can setup for your code repositories to check for errors / issues on code pushes / pull requests
Credits to the original author for making it in the first place: Profile - GoatGeek - Cfx.re Community
Although the original linter was capable of linting normal Lua code and some part of FiveM LuaGLM globals, it didn’t support a lot of the crucial syntax that luagm offers as an extension to Lua. This was a limitation of the actual linter (luacheck). I extended the linter to support LuaGLM syntax and have started to maintain it as well.
What is this? Who is this for?
It detects syntax / logical (most of them) errors as well as non-standard / unused variables / functions / conditions etc that you add to the code but never use it, and much more! (Cyclomatic complexity and what not)
- Are you a server owner and want to ensure that your server devs are using the best practices when working on scripts?
- Are you a developer who makes your own resources and want to make sure that you’re pushing the best quality resources?
Then this linter is for you.
Features
My version supports the following
- Backtick strings (
`I am a backtick string`
) - LuaGLM Globals
- Vectors/Quaternions
- Matrices
- Safe Navigation (Both variable and table syntax)
- Compound Operators
- +=, -=, *=, /=, &=, |=, and ^=
In addition to the ones supported by the original resource:
- Dynamic FiveM Natives (You don’t need to update the linter every time a new Native is introduced)
Who is using it currently?
- All the official qb-core resources use it to ensure that the code quality is top notch
- esx-legacy recently added it to their resources but haven’t resolved the issues reported by the linter yet.
- ChatDisabled, me and other qb-core devs use it for their own scripts
How to use it?
Simply add the following contents to your .github/workflows/lint.yml file of your repository:
name: Lint
on: [push, pull_request]
jobs:
lint:
name: Lint Resource
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Lint
uses: iLLeniumStudios/fivem-lua-lint-action@v2
with:
capture: "junit.xml"
args: "-t --formatter JUnit"
- name: Generate Lint Report
if: always()
uses: mikepenz/action-junit-report@v3
with:
report_paths: "**/junit.xml"
check_name: Linting Report
fail_on_failure: false
Once added, it will report all the errors in a JUnit style report that looks like this:
For detailed and advanced instructions, take a look at the readme here: GitHub - iLLeniumStudios/fivem-lua-lint-action: A GitHub action for linting FiveM / Cfx Lua scripts
For now there are instructions only for setting it up for your repositories, not for setting it up locally.
In case someone is interested in looking at the actual linter (luacheck) changes, take a look here: GitHub - iLLeniumStudios/luacheck at fivem-lua