Linter Rule: Disallow debug output methods in ERB templates
Rule: erb-no-debug-output
Description
This rule disallows using p, pp, puts, print, warn, debug, byebug, binding.pry, and binding.irb in ERB templates. These are debug output methods and debugger breakpoints that should not appear in production templates.
Rationale
Debug output methods like p, pp, puts, print, warn, and debug are commonly used during development to inspect values, and debugger breakpoints like byebug, binding.pry, and binding.irb are used to pause execution. All of these should be removed before committing code. In ERB templates, p, pp, puts, print, and warn bypass the rendering pipeline and write directly to stdout/stderr, while debug renders a YAML dump into the HTML. None of these should appear in production templates.
Use <%= ... %> to display content in the rendered HTML, or use proper logging (e.g., Rails.logger) for debugging purposes.
Examples
✅ Good
<%= @user.name %>🚫 Bad
<% puts "hello" %><% p @user %><% pp @user %><% print "debug" %><%= puts "value" %><% warn "something went wrong" %><%= debug @user %><% byebug %><% binding.pry %><% binding.irb %>