Skip to main content

lint

Function lint 

Source
pub fn lint(lua: &Lua, code: &str, chunk_name: &str) -> LuaResult<LintResult>
Expand description

Lint code against an existing VM’s environment.

Convenience wrapper that calls register and then LintEngine::lint.

use mlua::prelude::*;

let lua = Lua::new();
lua.globals().set("custom_fn",
    lua.create_function(|_, ()| Ok(42)).unwrap()
).unwrap();

let result = mlua_check::lint(&lua, "custom_fn()", "@test.lua").unwrap();
assert_eq!(result.diagnostics.len(), 0);