Log inGet started
World

Builtin Library

Branchmain
Branchesmainpublish
Commit95280a384c

README.md

scriptValidator

Per-file Luau / Lua script validator. Wraps lsp.check(path) to get the engine's embedded Luau LSP diagnostics — full parser pass + type check + every lint rule — and combines them with two cheap textual checks (script.read_failed, script.empty).

Exports

  • M.validate(script, opts?) -> { Problem } — validate a single script entry ({ path, name } from vfsScanner).
  • M.validateBatch(scripts, opts?) -> { Problem } — flatten validation over a list.

opts is currently unused — reserved for future LSP option pass-through.

Checks performed

CodeSeverityWhat it catches
script.read_failederrorvfs.read returned nil for the file (deleted between scan and read, binary, or unreadable). When this fires, the LSP pass is skipped — there's no source to give it.
script.emptywarningThe file exists but has zero non-whitespace content.
lsp.<code>error / warning / infoForwarded from lsp.check. The LSP's stable diagnostic codes (parse-error, unknown-global, type-error, every lint code) are passed through verbatim under the lsp. prefix so callers can filter by them. Severity, line, column, message, and suggestion are taken from the diagnostic.

The path field on LSP-derived problems is augmented with :<line>:<col> so direct path-string editor jumps work.

Behaviour notes

  • The LSP runs in whatever mode the engine has it configured for — no per-script options are forwarded today. Run-once diagnostics include parse errors, type errors, and lint warnings the engine reports.
  • When lsp is not present in the Luau environment (e.g. a unit-test runner without the full engine), the script validator silently degrades to the read / empty checks only. The validator does not crash on missing globals.
  • File-level encoding / UTF-8 checks are not run here; the engine's source loader rejects invalid encodings before the validator sees them.

Removed (now real)

Earlier revisions of this module emitted placeholder.luau_syntax / placeholder.luau_typecheck info problems because no engine-side parser was exposed at runtime. Both are obsolete now that the embedded lsp.* namespace is available — the LSP delivers both syntax errors and type-check diagnostics in one pass.