| name | lint-xaml |
| description | Use when the user asks to lint XAML, check a view, validate XAML markup, audit XAML for issues, or mentions XAML analysis. Invokes xaml-lint on the target file(s) and reports diagnostics. |
Lint XAML
Run xaml-lint lint <path> to analyze one or more XAML files. The tool emits compact JSON with an array of diagnostics. Each diagnostic has ruleId, severity, message, file, and start/end line+column fields.
How to invoke
- Single file:
xaml-lint lint path/to/View.xaml
- Multiple files / glob:
xaml-lint lint "src/**/*.xaml"
- Explicit format:
xaml-lint lint --format compact-json path/to/View.xaml
If xaml-lint isn't on PATH, install with dotnet tool install -g xaml-lint and retry.
Dialect selection
Some rules are gated to specific XAML dialects (WPF, WinUI 3, UWP, MAUI, Avalonia, Uno). Detection order:
xaml-lint.config.json at or above the repo root with defaultDialect — use it when present.
dialect="..." pragma at the top of the XAML file — honored per-file.
- Tool default — WPF.
If the target project isn't WPF and no config is set, pass --dialect <name> explicitly (winui3, uwp, maui, avalonia, uno). Otherwise the user's dialect-specific rules (e.g. LX0201 for x:Bind, LX0301 for x:Uid casing) won't fire.
Interpreting output
The envelope always has the shape:
{
"version": "1",
"tool": { "name": "xaml-lint", "version": "<tool-version>" },
"results": [ ... ]
}
Empty results means clean. For each diagnostic, read ruleId, message, file, and startLine to locate the issue. Use helpUri (when present) to look up the rule's documentation before deciding how to fix.
Severity meaning
error — almost certainly a bug; fix before shipping.
warning — likely issue worth fixing; review case-by-case.
info — suggestion; apply if it improves the code.
Suppressing a diagnostic
If the diagnostic is a false positive in this specific spot, suppress with a XAML comment immediately before the offending element:
<Button x:Name="myButton" />
For broader suppression, edit xaml-lint.config.json:
{ "rules": { "LX0300": "off" } }