Skip to content

Add RuboCop support for Ruby in ERB templates - #2260

Open
joelhawksley wants to merge 5 commits into
marcoroth:mainfrom
joelhawksley:joelhawksley-add-erb-rubocop
Open

Add RuboCop support for Ruby in ERB templates#2260
joelhawksley wants to merge 5 commits into
marcoroth:mainfrom
joelhawksley:joelhawksley-add-erb-rubocop

Conversation

@joelhawksley

Copy link
Copy Markdown
Contributor

Herb currently validates Ruby syntax in ERB templates but cannot run a project's RuboCop cops against embedded Ruby. This adds an opt-in, Ruby-native herb rubocop command so projects can apply their existing Ruby style and correctness rules to templates without involving Herb's JavaScript linter.

The implementation extracts inspectable Ruby fragments from Herb lexer tokens, runs RuboCop in-process, and maps offenses and corrections back to template locations. It supports ERB Lint-compatible only, config_file_path, and inline rubocop_config settings, including custom cops, inherited configuration, exclusions, and safe or unsafe autocorrection.

The shared JavaScript config schema only preserves the new top-level rubocop block so existing Herb tools continue accepting .herb.yml; RuboCop execution remains an independent Ruby code path.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 7760dddc-b6a8-4f14-8cea-343a06bbcc39
@github-actions github-actions Bot added documentation Improvements or additions to documentation ruby Ruby source for the gem and its libraries typescript TypeScript source across the javascript/ packages rubygem The herb RubyGem and its packaging config Herb configuration file handling and config options labels Aug 17, 2026
Resolve the CLI conflict by preserving upstream tracking, slot, and timeout options alongside the ERB RuboCop autocorrection flags.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 7760dddc-b6a8-4f14-8cea-343a06bbcc39
Preserve the RuboCop block in the Rust config model and keep the optional adapter outside Steep's typed surface while declaring the shared Configuration methods.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 7760dddc-b6a8-4f14-8cea-343a06bbcc39
@github-actions github-actions Bot added rbs RBS type signatures in sig/ rust Rust bindings and the Herb Rust crate labels Aug 17, 2026
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 7760dddc-b6a8-4f14-8cea-343a06bbcc39
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 7760dddc-b6a8-4f14-8cea-343a06bbcc39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

config Herb configuration file handling and config options documentation Improvements or additions to documentation rbs RBS type signatures in sig/ ruby Ruby source for the gem and its libraries rubygem The herb RubyGem and its packaging rust Rust bindings and the Herb Rust crate typescript TypeScript source across the javascript/ packages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant