Linter Rule: Require the framework option
Rule: herb-config-framework-option
Description
Reports templates in a project that doesn't set framework in its .herb.yml. The rule stays quiet as soon as framework is set, whichever value it is set to.
When a template shows what it is rendered by, the offense says so and suggests that value. Otherwise it lists the values to choose from.
Rationale
Herb tailors itself to the framework option. It decides what Herb may assume about a template, which rules apply, and which optimizations it can take. Without it Herb falls back to ruby and treats every template as plain ERB, which is the most conservative behavior it has.
The option is a project-level setting, and the CLI warns about it once per run, but that warning never reaches an editor. This rule brings it to where templates are actually written.
Two signals tell Herb the project is likely Action View, and both only shape the message:
- a strict locals declaration, which only Action View reads
- a call to a helper whose name is unmistakably Action View, so
link_toandimage_tagcount whilerender,params, andtdon't
Neither is a requirement for the offense. A template with no Ruby in it at all still reports, because the option is still missing.
The rule reports once per file, on the first line, and a CLI run collapses those down to a single offense since one missing config key doesn't need one report per template.
Examples
✅ Good
Any value silences the rule, including the ruby default when that is what the project means:
framework: actionviewframework: ruby🚫 Bad
Without the option, every template reports:
<div class="card">
<h1>Hello</h1>
</div>Templates carrying an Action View signal get that value suggested:
<%= image_tag "logo.png", alt: "Logo" %><%# locals: (title:, subtitle: nil) %><h1><%= title %></h1>Configuration
Set the framework in your .herb.yml to resolve the offense:
framework: actionview # Options: ruby (default), actionview, hanami, sinatraOr disable the rule if you prefer to keep the option unset:
linter:
rules:
herb-config-framework-option:
enabled: false