Documentation

whitehall lint

Style, idiom, and performance suggestions. Never a build error.

Correctness — anything that can fail a build — is the compiler's job, not the linter's. 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

FlagWhat it does
--fixApply the fixes that are safe to apply automatically
--format=jsonMachine-readable output, for tooling. Text is the default
--select=<cat,…>Only these rule categories, or all
--ignore=<rule,…>Skip these rules by name
--list-categoriesPrint 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

LevelMeaningExit code
WarningShould fix — printed, never stops the build0
InfoSuggestion only0

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

RuleCategoryAuto-fixWhat it flags
no-unused-importstyleYesAn import nothing in the file uses
prefer-bindstyleYesManual two-way binding where bind:value would do
prefer-gapstyleYesArrangement.spacedBy where gap would do
no-hardcoded-stringsstyleNoA literal string in a <Text>, worth routing through $t
missing-key-in-loopcomponentNoA @for with no key, so state stays with position instead of the row
no-empty-filestyleNoA .wh file with no root component
unknown-color-nameprop_validationNoA 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