Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@

// Set *default* container specific settings.json values on container create.
"settings": {
"[erb]": {
"editor.defaultFormatter": "marcoroth.herb-lsp",
"editor.formatOnSave": true
},
"sqltools.connections": [
{
"name": "Rails Development Database",
Expand Down Expand Up @@ -38,6 +42,7 @@
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"rebornix.Ruby",
"marcoroth.herb-lsp",
"mtxr.sqltools",
"mtxr.sqltools-driver-pg"
],
Expand All @@ -46,7 +51,7 @@
// "forwardPorts": [3000, 5432],

// Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": "script/replicate-bug",
"postCreateCommand": "npm ci && script/replicate-bug",

// Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
"remoteUser": "vscode"
Expand Down
7 changes: 2 additions & 5 deletions .erb_lint.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
---
EnableDefaultLinters: true
EnableDefaultLinters: false
exclude:
- '**/vendor/**/*'
- 'test/sandbox/app/components/content_security_policy_nonce_component.html.erb'
linters:
ErbSafety:
enabled: true
FinalNewline:
enabled: true
# Herb handles HTML and ERB rules; keep Standard's embedded Ruby checks.
Rubocop:
enabled: true
rubocop_config:
Expand Down
15 changes: 14 additions & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,27 @@ jobs:
with:
path: vendor/bundle
key: gems-build-rails-8-ruby-3.2-${{ hashFiles('**/Gemfile.lock') }}
- name: Lint with Standard and ERB Lint
- name: Lint Ruby, including Ruby embedded in ERB
run: |
bundle config path vendor/bundle
bundle update
bundle exec standardrb -r "rubocop-md"
bundle exec erb_lint --lint-all
env:
RAILS_VERSION: '~> 8'
herb:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
with:
persist-credentials: false
- uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5
with:
node-version: 22
cache: npm
- run: npm ci
- run: npm run herb:lint
- run: npm run herb:format:check
yard-lint:
runs-on: ubuntu-latest
steps:
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,6 @@ build-iPhoneSimulator/

# Appraisal
/gemfiles/.bundle/

# Template development tools
/node_modules/
67 changes: 67 additions & 0 deletions .herb.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
version: 0.11.2
framework: actionview

files:
include:
- "**/*.erb"
exclude:
- "**/*.tt"
- "**/*.text.erb"
- "**/*.json.erb"
- "**/*.css.erb"
# Jekyll processes this file as Liquid, not Action View.
- "docs/404.html"

linter:
enabled: true
failLevel: hint
rules:
all:
enabled: true
actionview-no-implicit-partial:
exclude:
# These render ViewComponent instances, not implicit Active Record partials.
- "app/views/view_components/preview.html.erb"
- "test/sandbox/app/components/cacheable_explicit_dependency_component.html.erb"
- "test/sandbox/app/components/cacheable_method_built_component.html.erb"
actionview-prefer-form-with:
exclude:
# Compatibility fixtures must continue exercising form_for.
- "test/sandbox/app/components/form_for_component.html.erb"
- "test/sandbox/app/components/form_partial_component.html.erb"
- "test/sandbox/app/components/incompatible_form_component.html.erb"
actionview-no-local-assigns:
exclude:
# The preview security regression demonstrates access to arbitrary locals.
- "test/sandbox/app/views/internal/secret.html.erb"
erb-require-template-format:
exclude:
# These fixtures test templates without a format suffix.
- "test/sandbox/app/components/no_format_component.erb"
- "test/sandbox/app/components/format_less_parent_component.erb"
- "test/sandbox/app/components/format_less_child_component.erb"
erb-no-silent-statement:
exclude:
# Slot setters register content without emitting their return value.
- "performance/components/slots_wrapper_component.html.erb"
erb-strict-locals-required:
exclude:
# Object rendering supplies implicit locals to this compatibility fixture.
- "test/sandbox/app/views/integration_examples/_test_partial.html.erb"
html-no-inline-script-elements:
exclude:
# System tests render these as standalone HTML, without an asset server.
- "test/sandbox/app/components/simple_javascript_interaction_with_js_included_component.html.erb"
- "test/sandbox/app/views/layouts/application.html.erb"

formatter:
enabled: true
indentWidth: 2
indentStyle: space
maxLineLength: 80
exclude:
# This template emits Markdown, where indentation and line breaks are syntax.
- "lib/docs/docs_builder_component.html.erb"
rewriter:
pre:
- tailwind-class-sorter
3 changes: 3 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"recommendations": ["marcoroth.herb-lsp"]
}
6 changes: 6 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"[erb]": {
"editor.defaultFormatter": "marcoroth.herb-lsp",
"editor.formatOnSave": true
}
}
9 changes: 7 additions & 2 deletions app/views/view_components/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
<% @previews.each do |preview| %>
<h3><%= link_to preview.preview_name.titleize, preview_view_component_path(preview.preview_name) %></h3>
<h3>
<%= link_to preview.preview_name.titleize, preview_view_component_path(preview.preview_name) %>
</h3>

<ul>
<% preview.examples.each do |preview_example| %>
<li><%= link_to preview_example, preview_view_component_path("#{preview.preview_name}/#{preview_example}") %></li>
<li>
<%= link_to preview_example, preview_view_component_path("#{preview.preview_name}/#{preview_example}") %>
</li>
<% end %>
</ul>
<% end %>
5 changes: 4 additions & 1 deletion app/views/view_components/previews.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<h3><%= @preview.preview_name.titleize %></h3>

<ul>
<% @preview.examples.each do |example| %>
<li><%= link_to example, preview_view_component_path("#{@preview.preview_name}/#{example}") %></li>
<li>
<%= link_to example, preview_view_component_path("#{@preview.preview_name}/#{example}") %>
</li>
<% end %>
</ul>
4 changes: 4 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ nav_order: 6

## main

* Enable all Herb lint rules, template formatting, Tailwind class sorting, and editor support for development.

*Joel Hawksley*

* Adopt rubyfmt for Ruby formatting while retaining compatible Standard lint rules.

*Joel Hawksley*
Expand Down
Loading
Loading