From 1bacf79052340d8880ebb0525fa8222a25f70670 Mon Sep 17 00:00:00 2001 From: Stan Lo Date: Sat, 14 Mar 2026 15:44:03 +0000 Subject: [PATCH] Fix herb linter offenses in ERB templates (#1645) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Summary - Remove `then` keyword from all ERB control flow tags (52 offenses) - Move duplicated HTML elements outside conditional branches (14 offenses) - Add `.herb.yml` config to disable rules not applicable to RDoc: - `erb-no-instance-variables-in-partials` — RDoc templates aren't Rails partials - `erb-no-unsafe-script-interpolation` — templates render trusted RDoc data - `erb-no-output-in-attribute-position` — same reason Fixes CI failure caused by `@herb-tools/linter` 0.9.0 introducing new rules. --- .herb.yml | 21 ++++++++++++ lib/rdoc/generator/template/aliki/_head.rhtml | 2 +- .../template/aliki/_sidebar_extends.rhtml | 14 ++++---- .../template/aliki/_sidebar_includes.rhtml | 14 ++++---- .../template/aliki/_sidebar_installed.rhtml | 2 +- .../template/aliki/_sidebar_pages.rhtml | 2 +- .../template/aliki/_sidebar_sections.rhtml | 2 +- lib/rdoc/generator/template/aliki/class.rhtml | 34 +++++++++---------- .../template/aliki/servlet_root.rhtml | 2 +- .../template/darkfish/_sidebar_extends.rhtml | 14 ++++---- .../template/darkfish/_sidebar_includes.rhtml | 14 ++++---- .../darkfish/_sidebar_installed.rhtml | 2 +- .../template/darkfish/_sidebar_pages.rhtml | 2 +- .../template/darkfish/_sidebar_sections.rhtml | 2 +- .../darkfish/_sidebar_table_of_contents.rhtml | 10 +++--- .../generator/template/darkfish/class.rhtml | 34 +++++++++---------- .../template/darkfish/table_of_contents.rhtml | 6 ++-- 17 files changed, 103 insertions(+), 74 deletions(-) create mode 100644 .herb.yml diff --git a/.herb.yml b/.herb.yml new file mode 100644 index 0000000000..398bee965d --- /dev/null +++ b/.herb.yml @@ -0,0 +1,21 @@ +version: 0.9.0 + +linter: + enabled: true + + rules: + # RDoc templates are not Rails partials — instance variables are the + # standard way to pass data from the generator to templates. + erb-no-instance-variables-in-partials: + enabled: false + + # Template output is generated from trusted RDoc data, not user input. + erb-no-unsafe-script-interpolation: + enabled: false + + # Same: attribute values come from trusted RDoc data. + erb-no-output-in-attribute-position: + enabled: false + +formatter: + enabled: false diff --git a/lib/rdoc/generator/template/aliki/_head.rhtml b/lib/rdoc/generator/template/aliki/_head.rhtml index c46f0b94e7..c6c238d26c 100644 --- a/lib/rdoc/generator/template/aliki/_head.rhtml +++ b/lib/rdoc/generator/template/aliki/_head.rhtml @@ -28,7 +28,7 @@ <%- elsif @title %> <%- if @options.main_page and - main_page = @files.find { |f| f.full_name == @options.main_page } then %> + main_page = @files.find { |f| f.full_name == @options.main_page } %> " diff --git a/lib/rdoc/generator/template/aliki/_sidebar_extends.rhtml b/lib/rdoc/generator/template/aliki/_sidebar_extends.rhtml index 1544b83778..a6086639e6 100644 --- a/lib/rdoc/generator/template/aliki/_sidebar_extends.rhtml +++ b/lib/rdoc/generator/template/aliki/_sidebar_extends.rhtml @@ -1,4 +1,4 @@ -<%- unless klass.extends.empty? then %> +<%- unless klass.extends.empty? %>