class ERBLint::Linters::RightTrim
this linter will force one or the other.
In ERB, right trim can be either =%> or -%>
def autocorrect(_processed_source, offense)
def autocorrect(_processed_source, offense) lambda do |corrector| corrector.replace(offense.source_range, @config.enforced_style) end end
def run(processed_source)
def run(processed_source) processed_source.ast.descendants(:erb).each do |erb_node| _, _, _, trim_node = *erb_node next if trim_node.nil? || trim_node.loc.source == @config.enforced_style add_offense( trim_node.loc, "Prefer #{@config.enforced_style}%> instead of #{trim_node.loc.source}%> for trimming on the right.", ) end end