Skip to content

U0006 ui-destructive-unconfirmed

Rule: A control that throws work away asks first or can be undone.

Code U0006 (stable, never reused)
Id ui-destructive-unconfirmed
Category ui
Source spirit_level
Fix by hand

Level per tier

Tier Level Reason
small off
small-workspace off
medium off
big off
ai off
embedded off
ui warn one tap must not throw work away; an estimate, since the confirmation may live elsewhere
egui warn one tap must not throw work away: an egui::Modal asks first, or the edit can be undone
units-strict off
units-paranoid off

Parameters

Name Type Default Meaning
calls list of strings [] calls that make a button from a label
verbs list of strings ["delete", "remove", "erase", "wipe", "reset", "format", "discard", "purge", "destroy", "overwrite", "uninstall", "kill", "revoke", "forget"] first words of a label that throws work away
confirm-words list of strings ["confirm", "undo", "modal", "dialog"] words in a name of the same function that show a confirmation or an undo
toolkits list of strings ["egui", "eframe", "iced", "slint", "gtk4", "relm4", "dioxus", "leptos", "yew", "floem", "xilem", "makepad-widgets"] UI toolkits: a crate that depends on one directly is a UI crate, unless the crate map says ui = false

Why

A tap that throws work away (delete, reset, wipe) must ask first, saying what will be lost, or be undoable for a few seconds. A button that does it at once turns a slip of the mouse into lost work.

The lint reads the labels of calls (egui: button, Button::new, danger_button). A label whose first word is one of verbs is reported unless the function that makes it names a confirmation or an undo (an identifier containing one of confirm-words: confirm, undo, modal, dialog), or the label ends in "…", which says it opens a dialog. Findings are estimates: a confirmation built in another function is not seen.

if ui.button("Reset settings").clicked() { self.settings = Settings::default(); } // reported
if ui.button("Reset settings…").clicked() { self.confirm_reset = true; }          // passes

How to fix

Open a confirmation that says what will be lost, with the safe choice as the default (egui: an egui::Modal), and end the label in "…"; or keep the old state for an undo. Where the action loses nothing (a filter, a selection), waive the finding with that reason.

Configure

[lints.ui-destructive-unconfirmed]
level = "deny"
calls = []
verbs = ["delete", "remove", "erase", "wipe", "reset", "format", "discard", "purge", "destroy", "overwrite", "uninstall", "kill", "revoke", "forget"]
confirm-words = ["confirm", "undo", "modal", "dialog"]
toolkits = ["egui", "eframe", "iced", "slint", "gtk4", "relm4", "dioxus", "leptos", "yew", "floem", "xilem", "makepad-widgets"]
reason = "why this project wants it at this level"

Allow one finding in the code with // spirit-level: allow(ui-destructive-unconfirmed) <reason> (waivers); the code works there too, as in [lints.U0006].