selene
Selene is a blazing-fast modern Lua linter written in Rust that provides comprehensive static analysis for Lua code. It offers extensive configurability and can be tailored to specific Lua environments like Roblox, World of Warcraft addons, or standard Lua.
Key Features:
- Rust-powered performance for extremely fast static analysis
- Environment-specific configurations for Roblox, WoW addons, and standard Lua
- Comprehensive lint rules covering code quality, style, and correctness
- Custom rule creation for project-specific requirements
- TOML configuration files for easy project setup and sharing
- Detailed error messages with context and suggestions for fixes
- Multiple output formats including JSON for tool integration
- Incremental analysis for fast checking of large codebases
- Standard library definitions for accurate global variable validation
- Inline rule filtering using comments to disable specific checks
- Performance suggestions to optimize Lua code execution
selene documentation
- Version in MegaLinter: 0.28.0
- Visit Official Web Site
- See How to configure selene rules
- See How to disable selene rules in files
- See Index of problems detected by selene
Configuration in MegaLinter
- Enable selene by adding
LUA_SELENE
in ENABLE_LINTERS variable - Disable selene by adding
LUA_SELENE
in DISABLE_LINTERS variable
Variable | Description | Default value |
---|---|---|
LUA_SELENE_ARGUMENTS | User custom arguments to add in linter CLI call Ex: -s --foo "bar" |
|
LUA_SELENE_COMMAND_REMOVE_ARGUMENTS | User custom arguments to remove from command line before calling the linter Ex: -s --foo "bar" |
|
LUA_SELENE_FILTER_REGEX_INCLUDE | Custom regex including filter Ex: (src\|lib) |
Include every file |
LUA_SELENE_FILTER_REGEX_EXCLUDE | Custom regex excluding filter Ex: (test\|examples) |
Exclude no file |
LUA_SELENE_CLI_LINT_MODE | Override default CLI lint mode - file : Calls the linter for each file- project : Call the linter from the root of the project |
file |
LUA_SELENE_FILE_EXTENSIONS | Allowed file extensions. "*" matches any extension, "" matches empty extension. Empty list excludes all filesEx: [".py", ""] |
[".lua"] |
LUA_SELENE_FILE_NAMES_REGEX | File name regex filters. Regular expression list for filtering files by their base names using regex full match. Empty list includes all files Ex: ["Dockerfile(-.+)?", "Jenkinsfile"] |
Include every file |
LUA_SELENE_PRE_COMMANDS | List of bash commands to run before the linter | None |
LUA_SELENE_POST_COMMANDS | List of bash commands to run after the linter | None |
LUA_SELENE_UNSECURED_ENV_VARIABLES | List of env variables explicitly not filtered before calling LUA_SELENE and its pre/post commands | None |
LUA_SELENE_CONFIG_FILE | selene configuration file nameUse LINTER_DEFAULT to let the linter find it |
selene.toml |
LUA_SELENE_RULES_PATH | Path where to find linter configuration file | Workspace folder, then MegaLinter default rules |
LUA_SELENE_DISABLE_ERRORS | Run linter but consider errors as warnings | false |
LUA_SELENE_DISABLE_ERRORS_IF_LESS_THAN | Maximum number of errors allowed | 0 |
LUA_SELENE_CLI_EXECUTABLE | Override CLI executable | ['selene'] |
IDE Integration
Use selene in your favorite IDE to catch errors before MegaLinter !
IDE | Extension Name | Install | |
---|---|---|---|
neovim | ['nvim-lint', 'none-ls'] | Visit Web Site | |
Sublime Text | SublimeLinter-contrib-selene | Visit Web Site | |
Visual Studio Code | selene-vscode | ![]() |
MegaLinter Flavors
This linter is available in the following flavors
Flavor | Description | Embedded linters | Info | |
---|---|---|---|---|
![]() |
all | Default MegaLinter Flavor | 127 |
Behind the scenes
How are identified applicable files
- File extensions:
.lua
How the linting is performed
- selene is called one time by identified file (
file
CLI lint mode)
Example calls
selene myfile.lua
selene --config chktexrc.toml myfile.lua
Help content
selene 0.28.0
USAGE:
selene [FLAGS] [OPTIONS] <files>...
selene <SUBCOMMAND>
FLAGS:
--allow-warnings Pass when only warnings occur
-h, --help Prints help information
--no-exclude
-n, --no-summary Suppress summary information
-q, --quiet Display only the necessary information. Equivalent to --display-style="quiet"
-V, --version Prints version information
OPTIONS:
--color <color> [default: auto] [possible values: Always, Auto, Never]
--config <config> A toml file to configure the behavior of selene [default: selene.toml]
--display-style <display-style> Sets the display method [possible values: Json, Json2, Rich, Quiet]
--num-threads <num-threads> Number of threads to run on, default to the numbers of logical cores on your
system [default: 4]
--pattern <pattern>... A glob to match files with to check
ARGS:
<files>...
SUBCOMMANDS:
capabilities Prints the capabilities of the current build
generate-roblox-std
help Prints this message or the help of the given subcommand(s)
update-roblox-std
upgrade-std
validate-config
Installation on mega-linter Docker image
- Dockerfile commands :
# Parent descriptor install
RUN wget --tries=5 https://www.lua.org/ftp/lua-5.3.5.tar.gz -O - -q | tar -xzf - \
&& cd lua-5.3.5 \
&& make linux \
&& make install \
&& cd .. && rm -r lua-5.3.5/
# Linter install
# renovate: datasource=crate depName=selene
ARG CARGO_SELENE_VERSION=0.28.0
- Cargo packages (Rust):