# Lint warnings

> What each `vidmake validate` warning code means (`offCanvas`, `textOverflow`, `invisible`, `zeroDuration`, `afterEnd`), how the checks pick their frame, and how to silence intended warnings with the `lint` field.

A project can compile and still be wrong: a title that slid off the canvas, a caption too wide for the frame,
a layer that fades in and never fully appears, a scene that starts after the video has ended. After compiling,
`vidmake validate` *lints* the composition: it computes each layer's real bounding box and opacity at a
representative frame and reports anything that looks like a mistake.

```output
✓ main — 90 frames (3.00s)
  warning: layer `zero` has zero visible duration [zeroDuration]
  warning: layer `late` starts at 4.00s, after the composition ends (3.00s) [afterEnd]
  warning: layer `off` is entirely off-canvas at frame 45 (bbox [-350,310,-250,410]) [offCanvas]
  warning: text layer `big` overflows the canvas at frame 45 (bbox [-442,288,1723,432]); consider maxWidth or a smaller fontSize [textOverflow]
  warning: layer `ghost` is invisible (opacity 0.00) at its midpoint, frame 45 [invisible]
```

Warnings never fail validation: the exit status stays 0 and `render` still works. They are there to be read.
Each one ends with a code in brackets. When a warning describes something you did on purpose, silence that code on
that layer so the next `validate` is clean again and real problems stand out.

> [!AGENT]
> Treat every warning as a bug until you have looked at the frame it names (`vidmake still project.json -f <frame>`
> or `inspect -f <frame> -l <id>`). Only then either fix the layer or add a `lint` ignore. A clean `validate` is
> the bar for "done".

## Warning codes

| code | triggered when | typical cause | typical fix |
|---|---|---|---|
| `offCanvas` | the layer's bounding box is entirely outside the canvas at its check frame | wrong `x`/`y` units (frames vs %), anchor confusion, a group offset, a slide that never arrives | fix the position; `inspect` shows the bbox |
| `textOverflow` | a `text` or `captions` layer is partly outside the canvas (by more than 1 px) | long text, large `fontSize`, no `maxWidth` | add `maxWidth`, reduce `fontSize`, or move it |
| `invisible` | the layer's effective opacity (with its parents') is below 0.01 at its check frame | a fade that never finishes, `opacity: 0` left in, a tween in frames where seconds were meant | fix the opacity animation |
| `zeroDuration` | the layer's time window is empty (`end` ≤ `start`) | `duration: 0`, `end` before `start`, a child clipped away by its parent | fix the timing; `vidmake timeline` shows it |
| `afterEnd` | the layer starts at or after the end of the composition | a `start` in frames where seconds were meant, a scene added after the last one | extend `duration` or move the layer |

`afterEnd` and `zeroDuration` are timing checks and apply to every layer, audio included. The other three are
visual checks; they skip `audio` layers, and they skip `group` and `use` layers themselves (their children are
checked instead).

### The check frame

Visual checks look at one frame per layer:

- the layer's **midpoint**, or the frame its `enter` preset has finished, whichever is later,
- but never past the layer's last frame.

That is why a layer that slides in from off-screen doesn't warn (it has arrived by its midpoint), while one that is
still fading at that point does. In this example the fade takes 2.5 s, so the check happens at frame 75, after it:

```output
  warning: layer `fadein` is invisible (opacity 0.01) at its midpoint, frame 75 [invisible]
```

Copies made by [`repeat`](https://vidmake.app/docs/repeat.md) are checked individually (`spark.0`, `spark.1`, ...). Each layer id is
reported once. The visual checks run at most 80 distinct check frames per composition; layers whose check frame
falls beyond those are not linted visually.

> [!NOTE]
> The check frame is a heuristic. A layer that is on-canvas at its midpoint can still be off-canvas at other
> times, and a layer hidden only at its midpoint will warn even if it looks fine elsewhere. For anything that
> moves, confirm with a [storyboard](https://vidmake.app/docs/inspecting.md#storyboard) or a [trace](https://vidmake.app/docs/inspecting.md#trace).

## Silencing warnings: the `lint` field

Every layer accepts a `lint` field:

| value | effect |
|---|---|
| `{ "ignore": ["offCanvas", "invisible"] }` | silence these codes |
| `{ "ignore": "offCanvas" }` | a single code also works without the array |
| `{ "ignore": ["all"] }` | silence every code |
| `false` | same as `{ "ignore": ["all"] }` |
| `true` or no `lint` | lint normally |

Codes are checked when the project compiles, so a typo is an error rather than a silent no-op:

```output
✗ main: layer `bad` (main > layers[3]): unknown lint code `offscreen` (all, offCanvas, textOverflow, invisible, zeroDuration, afterEnd)
```

Other shapes fail too: ``unknown lint field `skip` (allowed: ignore)`` and
``lint codes must be strings``.

### Inheritance

A `lint` setting on a [group](https://vidmake.app/docs/groups.md) applies to the group and everything inside it, at any depth.
Children add their own codes to the inherited ones; they can't re-enable a code their group ignores. The same
holds for `repeat`: the copies inherit the original layer's `lint`.

```json
{ "id": "particles-scene", "type": "group", "lint": false, "children": [ ... ] }
```

Prefer the narrowest form: a specific code on the specific layer. `"lint": false` on a whole scene also hides
the mistakes you didn't intend.

## Example: intended warnings

This demo has two things that look like mistakes to the linter. The sparks fly off the canvas (by their midpoint
they are all outside it), and the recording dot blinks (it is at opacity 0 on its check frame). Both are
intended, so the sparks ignore `offCanvas`, and the `rec` group ignores `invisible` for its children:

**Demo: Intended warnings, silenced: sparks that fly off-canvas and a recording dot that blinks** (rendered video: https://vidmake.app/media/lint-intended.mp4)

```json
{
  "fonts": [
    { "family": "Schibsted Grotesk", "path": "fonts/SchibstedGrotesk.ttf" },
    { "family": "JetBrains Mono", "path": "fonts/JetBrainsMono.ttf" }
  ],
  "compositions": [{
    "id": "burst", "description": "Intended warnings, silenced: sparks that fly off-canvas and a recording dot that blinks",
    "width": 1280, "height": 720, "fps": 30, "duration": "4s", "background": "#f4f1ea",
    "layers": [
      { "id": "spark", "type": "ellipse", "width": 10, "repeat": 24, "fill": "=pick(i, ['#161412', '#c92a26', '#1f5fb0'])",
        "x": "=640 + sin(i * tau / n) * (60 + 520 * t)", "y": "=360 - cos(i * tau / n) * (60 + 520 * t)",
        "lint": { "ignore": ["offCanvas"] } },
      { "id": "title", "type": "text", "text": "Off-canvas on purpose", "font": "Schibsted Grotesk", "fontWeight": 860, "fontSize": 76,
        "letterSpacing": -3.2, "fill": "#161412", "enter": "pop" },
      { "id": "rec", "type": "group", "x": 96, "y": 72, "width": 120, "height": 40, "anchor": "left",
        "lint": { "ignore": ["invisible"] },
        "children": [
          { "id": "rec-dot", "type": "ellipse", "width": 18, "x": 9, "fill": "#c92a26", "opacity": "=floor(t * 2) % 2" },
          { "id": "rec-label", "type": "text", "text": "REC", "font": "JetBrains Mono", "fontSize": 20, "fontWeight": 700,
            "letterSpacing": 3, "fill": "#161412", "anchor": "left", "x": 30 }
        ] }
    ]
  }]
}
```

```console
$ vidmake validate lint-intended.json
✓ burst — 120 frames (4.00s)
```

Without the two `lint` fields, the same file produces 25 warnings (24 sparks, shortened here):

```output
✓ burst — 120 frames (4.00s)
  warning: layer `spark.0` is entirely off-canvas at frame 60 (bbox [635,-745,645,-735]) [offCanvas]
  warning: layer `spark.1` is entirely off-canvas at frame 60 (bbox [920,-708,930,-698]) [offCanvas]
  warning: layer `spark.2` is entirely off-canvas at frame 60 (bbox [1185,-598,1195,-588]) [offCanvas]
  warning: layer `spark.23` is entirely off-canvas at frame 60 (bbox [350,-708,360,-698]) [offCanvas]
  warning: layer `rec-dot` is invisible (opacity 0.00) at its midpoint, frame 60 [invisible]
```

Other common intended cases:

- **Particles, confetti and debris** that start or end outside the frame: `"lint": { "ignore": ["offCanvas"] }` on
  the [particles](https://vidmake.app/docs/particles.md) layer or the repeated shape.
- **Blinking cursors and strobes**: `invisible`. A typing cursor that is solid while typing and blinks afterwards
  may not need it; see the [typewriter recipe](https://vidmake.app/docs/recipes.md#typewriter-code-with-a-cursor).
- **Layers that enter from or exit to off-screen** and are timed so the midpoint falls outside: `offCanvas`.
- **Text that is cropped on purpose** (a giant word bleeding off the edges): `textOverflow`.
- **A placeholder scene** kept at the end while you work: `afterEnd`.

## Warnings without a code

A few warnings describe the composition rather than a layer. They have no code and can't be silenced with `lint`;
fix the cause instead:

| warning | meaning |
|---|---|
| ``composition `main`: unknown prop `{{titel}}` `` | a `{{name}}` placeholder has no matching prop; it is left in the text as written. See [props](https://vidmake.app/docs/props.md) |
| `expressions use amp/bass/beat/beats but the composition has no audio; they stay 0` | [audio-reactive](https://vidmake.app/docs/audio-reactive.md) variables need an audio or (unmuted) video layer in the composition |
| `composition size 1281x720 is odd; H.264/H.265 need even dimensions` | MP4 rendering at scale 1 will fail; use even `width`/`height` (see [troubleshooting](https://vidmake.app/docs/troubleshooting.md#odd-dimensions-with-h-264)) |
| ``use `card`: fps 25 differs from parent 30; ...`` | a [component](https://vidmake.app/docs/components.md) runs at a different frame rate; times convert, frame-based expressions may not |

`vidmake timeline` prints the composition-level warnings too.

## Machine-readable output

`validate --json` returns warnings as strings in `compositions[].warnings`; the code is always the bracketed suffix,
so an agent can group them with a regular expression like `\[(\w+)\]$`:

```json
{ "ok": true, "compositions": [ { "composition": "main", "ok": true, "frames": 90.0, "duration": 3.0,
  "warnings": ["layer `ghost` is invisible (opacity 0.00) at its midpoint, frame 45 [invisible]"] } ] }
```

The list of codes is also in the [JSON Schema](https://vidmake.app/docs/schema.md) (`$defs.lintCode`), so editors autocomplete them.
