Linter Rule: Prefer data-turbo-confirm over the deprecated data-confirm
Rule: ujs-prefer-turbo-confirm
Description
Disallow the data-confirm attribute and the Action View helper option that renders it, data: { confirm: ... }. Use data-turbo-confirm or data: { turbo_confirm: ... } instead.
Rationale
Before Rails 7, Rails shipped @rails/ujs by default, which added JavaScript behavior to elements through helper options and data-* attributes. Rails 7 stopped including it, and Turbo covers the same behavior with its own attributes.
data-confirm made @rails/ujs prompt the user with the given question before proceeding, and cancel the action if the user declined. data-turbo-confirm is a drop-in replacement, so the migration is mechanical.
Once @rails/ujs is gone the attribute is inert, and the failure is silent rather than loud: the link or button still works, but the confirmation prompt simply stops appearing. A destructive action that was guarded now fires on the first click.
Examples
✅ Good
<a href="/posts/1" data-turbo-confirm="Are you sure?">Delete</a><%= link_to "Delete", post_path(@post), data: { turbo_confirm: "Are you sure?" } %><%= button_to "Delete", post_path(@post), data: { turbo_confirm: "Are you sure?" } %>🚫 Bad
<a href="/posts/1" data-confirm="Are you sure?">Delete</a><%= link_to "Delete", post_path(@post), data: { confirm: "Are you sure?" } %><%= button_to "Delete", post_path(@post), data: { confirm: "Are you sure?" } %>