Skip to content

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

erb
<%= @user.name %>

🚫 Bad

erb
<% puts "hello" %>
Avoid using `puts "hello"` in ERB templates. Remove the debug output or use `<%= ... %>` to display content. (erb-no-debug-output)
erb
<% p @user %>
Avoid using `p @user` in ERB templates. Remove the debug output or use `<%= ... %>` to display content. (erb-no-debug-output)
erb
<% pp @user %>
Avoid using `pp @user` in ERB templates. Remove the debug output or use `<%= ... %>` to display content. (erb-no-debug-output)
erb
<% print "debug" %>
Avoid using `print "debug"` in ERB templates. Remove the debug output or use `<%= ... %>` to display content. (erb-no-debug-output)
erb
<%= puts "value" %>
Avoid using `puts "value"` in ERB templates. Remove the debug output or use `<%= ... %>` to display content. (erb-no-debug-output)
erb
<% warn "something went wrong" %>
Avoid using `warn "something went wrong"` in ERB templates. Remove the debug output or use `<%= ... %>` to display content. (erb-no-debug-output)
erb
<%= debug @user %>
Avoid using `debug @user` in ERB templates. Remove the debug output or use `<%= ... %>` to display content. (erb-no-debug-output)
erb
<% byebug %>
Avoid using `byebug` in ERB templates. Remove the debug output or use `<%= ... %>` to display content. (erb-no-debug-output)
erb
<% binding.pry %>
Avoid using `binding.pry` in ERB templates. Remove the debug output or use `<%= ... %>` to display content. (erb-no-debug-output)
erb
<% binding.irb %>
Avoid using `binding.irb` in ERB templates. Remove the debug output or use `<%= ... %>` to display content. (erb-no-debug-output)

References

Released under the MIT License.