fix(cli): error when --viewport is passed without configured [viewports] - #124
Conversation
…ts] (#119) Previously, running `plumb lint <url> --viewport NAME` in a fresh checkout (or any directory without a `[viewports]` section in `plumb.toml`) silently dropped the flag and ran a single 1280x800 desktop viewport. The user got no signal that their flag was ignored — inconsistent with the populated-config path, which errors via `LintError::UnknownViewports`. `resolve_targets` now returns a new `LintError::ViewportFlagWithoutConfig` variant whenever `config.viewports` is empty AND `viewports_arg` is non-empty. The empty-flag, empty-config quickstart path (`plumb lint plumb-fake://hello`) is unchanged: it still falls back to the default desktop target. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
All context collected. Here is the structured review: PR #124 —
|
Closes #119.
Summary
plumb lint <url> --viewport NAMEnow errors with exit code 2 whenconfig.viewportsis empty (noplumb.toml, or one without[viewports.*]), instead of silently discarding the flag and falling back to a singledesktop1280×800 target.plumb lint plumb-fake://hellowith no--viewport) is unchanged — still falls back to default desktop.Why error vs. warn vs. magic
Issue #119 listed three options: error, magic-default sizes, or stderr warning. Picked error because:
LintError::UnknownViewportsalready errors on bad names) — no more inconsistency between the two paths.--viewport mobile --viewport desktopruns against exactly those two viewports") fails silently under the old behavior; under the new behavior it fails loudly.Error message
Actionable: tells the user both how to opt in (add config) and how to opt out (drop the flag).
Test plan
lint_with_viewport_flag_and_no_config_exits_input_error— TempDir with noplumb.toml, asserts exit 2 + stderr matches.LintError::ViewportFlagWithoutConfigvariant and preserves input order.empty_config_yields_single_default_desktop_targetstill passes — no regression on the no-flag path.just validateclean locally (fmt + clippy-Dwarnings+ nextest + determinism + cargo-deny).