whitehall lint
Style, idiom, and performance suggestions. Never a build error.
compile, build, run, install and dev already refuse a typo'd tag, an unknown Tailwind class, a loader field
with no default, and the rest, from the compiler itself. whitehall lint is a
separate pass over the same files for what is left: style, idiom, performance. It reports Warning/Info only and cannot fail a build by itself.Usage
whitehall lint [target] [options] target defaults to . and can also be a single .wh file:
whitehall lint
whitehall lint src/routes/+screen.wh warning[no-unused-import]: Import '$lib.stores.UserStore' is not used
--> src/routes/+screen.wh:1:1
|
1 | import $lib.stores.UserStore
|
= help: Remove unused import or use the imported symbol Options
| Flag | What it does |
|---|---|
--fix | Apply the fixes that are safe to apply automatically |
--format=json | Machine-readable output, for tooling. Text is the default |
--select=<cat,…> | Only these rule categories, or all |
--ignore=<rule,…> | Skip these rules by name |
--list-categories | Print the real category list and exit |
Categories
The real list — --select accepts exactly these, or all — is
whatever whitehall lint --list-categories prints today:
animation, component, correctness, crossfade, data, layout, morph, navigation,
notification, performance, prop_validation, state, style, transition, widget One module, one category — the docs and --select read from the same list, so
they cannot drift apart. Some checks have no category because they are not lint: an unknown $lib import, an unknown tag, a $navigate path no route matches.
Those are compiler errors and fail check and every
build.
whitehall lint --select=style
whitehall lint --select=morph,routing
whitehall lint --ignore=unused-prop,no-hardcoded-strings An unknown category refuses the run rather than silently dropping it:
$ whitehall lint --select=nonsense
error: unknown category 'nonsense' — `--select` accepts: animation, component,
correctness, ..., widget, or `all` Severity
| Level | Meaning | Exit code |
|---|---|---|
Warning | Should fix — printed, never stops the build | 0 |
Info | Suggestion only | 0 |
whitehall lint cannot exit 1 on its own findings. A build that fails does so
on a compiler error — a different diagnostic, from a different stage, that happens to
render through the same error[rule]: message shape.
Some rules you will see
| Rule | Category | Auto-fix | What it flags |
|---|---|---|---|
no-unused-import | style | Yes | An import nothing in the file uses |
prefer-bind | style | Yes | Manual two-way binding where bind:value would do |
prefer-gap | style | Yes | Arrangement.spacedBy where gap would do |
no-hardcoded-strings | style | No | A literal string in a <Text>, worth routing through $t |
missing-key-in-loop | component | No | A @for with no key, so state stays with position instead of the row |
no-empty-file | style | No | A .wh file with no root component |
unknown-color-name | prop_validation | No | A bare color name the project's theme does not have |
Example: prefer-bind
// Flagged
<TextField value={email} onValueChange={(v) => email = v} />
// Preferred
<TextField bind:value={email} /> Output formats
whitehall lint --format=json [
{
"file": "src/routes/+screen.wh",
"rule": "no-unused-import",
"message": "Import '$lib.stores.UserStore' is not used",
"severity": "warning",
"start": 0,
"end": 25,
"fix": { "start": 0, "end": 26, "replacement": "" }
}
] CI
name: Lint
on: [push, pull_request]
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install Whitehall
run: cargo install whitehall
- name: Lint
run: whitehall lint See Also
- whitehall check — the compiler's own checks, without a build
- whitehall format — format code style
- whitehall build — where a real mistake actually fails