Skip to content

Linter

Wippy includes a built-in linter that performs type checking and static analysis on Lua code. Run it with wippy lint.

Terminal window
wippy lint # Check all Lua entries
wippy lint --level hint # Show all diagnostics including hints
wippy lint --json # Output in JSON format
wippy lint --ns app # Check only the app namespace
wippy lint --summary # Group results by error code

The linter validates all Lua entry kinds:

  • function.lua - Functions
  • library.lua - Libraries
  • process.lua - Processes
  • workflow.lua - Workflows

Bytecode entries hold compiled bytecode (fs/path/hash), not source, so they cannot be parsed or type-checked; the linter only checks source-bearing Lua entries (their .bc variants are skipped, though they may still appear in the total entry count).

Each entry is parsed, type-checked, and analyzed for correctness issues.

Diagnostics have three severity levels:

LevelDescription
errorType errors and correctness issues that must be fixed
warningLikely bugs or problematic patterns
hintStyle suggestions and informational notes

Control which levels appear with --level:

Terminal window
wippy lint --level error # Errors only
wippy lint --level warning # Warnings and errors (default)
wippy lint --level hint # Everything
CodeDescription
P0001Lua syntax error - source cannot be parsed

Type checker errors (E0001+) report issues found by the type system: type mismatches, undefined variables, invalid operations, and similar correctness problems. These are always reported as errors.

local x: number = "hello" -- E: string not assignable to number
local function add(a: number, b: number): number
return a + b
end
add("one", "two") -- E: string not assignable to number

Lint rules provide style and quality checks. Enable them with --rules:

Terminal window
wippy lint --rules
CodeRuleDescription
W0001no-empty-blocksEmpty block statements
W0002no-global-assignAssignment to global variables
W0003no-self-compareComparison of a value with itself
W0004no-unused-varsUnused local variables
W0005no-unused-paramsUnused function parameters
W0006no-unused-importsUnused import statements
W0007no-shadowed-varsVariable shadowing outer scope

Without --rules, only type checking (P and E codes) is performed.

Check specific namespaces using --ns:

Terminal window
wippy lint --ns app # Exact namespace match
wippy lint --ns "app.*" # All under app
wippy lint --ns app --ns lib # Multiple namespaces

Dependencies of selected entries are loaded for type checking but their diagnostics are not reported.

Filter diagnostics by code:

Terminal window
wippy lint --code E0001
wippy lint --code E0001 --code E0004

Limit the number of diagnostics shown:

Terminal window
wippy lint --limit 10 # Show first 10 issues

Each diagnostic is displayed with source context, file location, and the error message. Results are sorted by entry, severity, and line number.

A summary line shows totals:

Checked 42 entries: 5 errors, 12 warnings

Group diagnostics by namespace and error code:

Terminal window
wippy lint --summary
By namespace:
app 15 issues (5 errors, 10 warnings)
lib 2 issues (2 warnings)
By error code:
E0001 [error ] 5 occurrences
E0004 [error ] 3 occurrences
Checked 42 entries: 5 errors, 12 warnings

Machine-readable output for CI/CD integration:

Terminal window
wippy lint --json
{
"diagnostics": [
{
"entry_id": "app:handler",
"code": "E0001",
"severity": "error",
"message": "string not assignable to number",
"line": 10,
"column": 5
}
],
"total_entries": 42,
"error_count": 5,
"warning_count": 12,
"hint_count": 0
}

The linter caches results to speed up repeated runs. Cache keys are based on source code hash, method name, dependencies, and type system configuration.

Clear the cache if results seem stale:

Terminal window
wippy lint --cache-reset

Use JSON output and exit codes for automated checks:

Terminal window
wippy lint --json --level error > lint-results.json

The linter exits with code 0 when no errors are found, and non-zero when there are errors.

Example GitHub Actions step:

- name: Lint
run: wippy lint --level warning
FlagShortDefaultDescription
--levelwarningMinimum severity level (error, warning, hint)
--jsonfalseOutput in JSON format
--nsFilter by namespace patterns
--codeFilter by error codes
--limit0Max diagnostics to show (0 = unlimited)
--summaryfalseGroup by error code
--no-colorfalseDisable colored output
--rulesfalseEnable lint rules (W-series style/quality checks)
--cache-resetfalseClear cache before linting
--lock-file-lwippy.lockPath to lock file
  • CLI - Full CLI reference
  • Types - Type system documentation
  • LSP - Editor integration with live diagnostics