ewdev/lute_std_lint
A Lute lint rule to check for disallowed standard library references
lute_std_lint
A Lute lint rule to check for disallowed standard library references
Why?
When using Luau packages it's nice to know what standard libraries the package depends on to tell if it will run under a specific Luau runtime without testing first. While package maintainers can document this, they might also want to enforce this list so they can guarantee it's accurate. This lint helps you achieve that.
Installation
pesde (recommended)
pesde add ewdev/lute_std_lint --dev --target luau
Manual
Just copy over the /src/init.luau file and store it somewhere.
Usage
Create a .config.luau file with the following contents:
return {
lute = {
lint = {
rulepaths = { "luau_packages/lute_std_lint.luau" }, -- assuming you're using pesde
},
},
}
Then run:
lute lint src
Lute will now warn you if you're using any std library that isn't explicitly allowed... But wait, how do you do that?
It's simple! Just add an "allow" option to the lint where you specify what std's want you want use:
return {
lute = {
lint = {
rulepaths = { "luau_packages/lute_std_lint.luau" },
ruleconfigs = {
["std"] = {
options = {
allow = {
"fs", -- allows @std/fs
"path", -- allows @std/path, but not @std/path/win32
"syntax.*", -- allows @std/syntax, @std/syntax/parser, and anything else under @std/syntax
},
},
},
},
},
},
}
More examples on how to configure Lute lints: https://lute.luau.org/cli/lint/#c-config-config
Options
- allow: A list of Lua patterns for allowed std libraries. If any match fully the std library is considered allowed. These patterns do not need to match the std alias (i.e
@std), and is instead configured with the option below. (default:{}) - std_prefix: The alias the std libraries are required under. (default:
"@std")