Skip to content

Commit

Permalink
Add Standard and ERB Lint
Browse files Browse the repository at this point in the history
  • Loading branch information
marcoroth committed Oct 12, 2023
1 parent a9b023a commit 138cd91
Show file tree
Hide file tree
Showing 83 changed files with 261 additions and 184 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Lint

on:
push:
pull_request:

jobs:
build:
runs-on: ubuntu-latest
name: Ruby

steps:
- uses: actions/checkout@v3

- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
bundler-cache: true

- name: Run Standard
run: bundle exec standardrb

- name: Run ERB Lint
run: bundle exec erblint --lint-all
10 changes: 8 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ gem "redis", ">= 4.0.1"
# gem "bcrypt", "~> 3.1.7"

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem "tzinfo-data", platforms: %i[ windows jruby ]
gem "tzinfo-data", platforms: %i[windows jruby]

# Reduces boot times through caching; required in config/boot.rb
gem "bootsnap", require: false
Expand Down Expand Up @@ -71,9 +71,15 @@ gem "frozen_record", "~> 0.27.0"
# Library to create, read and manipulate Git repositories
gem "git", "~> 1.18"

# Ruby's bikeshed-proof linter and formatter
gem "standard", "~> 1.31"

# Lint your ERB or HTML files
gem "erb_lint", "~> 0.5.0"

group :development, :test do
# See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem
gem "debug", platforms: %i[ mri windows ]
gem "debug", platforms: %i[mri windows]
end

group :development do
Expand Down
57 changes: 57 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,15 @@ GEM
tzinfo (~> 2.0)
addressable (2.8.5)
public_suffix (>= 2.0.2, < 6.0)
ast (2.4.2)
base64 (0.1.1)
better_html (2.0.2)
actionview (>= 6.0)
activesupport (>= 6.0)
ast (~> 2.0)
erubi (~> 1.4)
parser (>= 2.4)
smart_properties
bigdecimal (3.1.4)
bindex (0.8.1)
bootsnap (1.16.0)
Expand All @@ -101,6 +109,13 @@ GEM
drb (2.1.1)
ruby2_keywords
dry-cli (1.0.0)
erb_lint (0.5.0)
activesupport
better_html (>= 2.0.1)
parser (>= 2.7.1.4)
rainbow
rubocop
smart_properties
error_highlight (0.5.1)
erubi (1.12.0)
frozen_record (0.27.0)
Expand All @@ -121,6 +136,9 @@ GEM
activesupport (>= 5.0.0)
jsbundling-rails (1.2.1)
railties (>= 6.0.0)
json (2.6.3)
language_server-protocol (3.17.0.3)
lint_roller (1.1.0)
loofah (2.21.3)
crass (~> 1.0.2)
nokogiri (>= 1.12.0)
Expand Down Expand Up @@ -156,6 +174,10 @@ GEM
racc (~> 1.4)
nokogiri (1.15.4-x86_64-linux)
racc (~> 1.4)
parallel (1.23.0)
parser (3.2.2.4)
ast (~> 2.4.1)
racc
pg (1.5.4)
psych (5.1.0)
stringio
Expand Down Expand Up @@ -202,6 +224,7 @@ GEM
rake (>= 12.2)
thor (~> 1.0, >= 1.2.2)
zeitwerk (~> 2.6)
rainbow (3.1.1)
rake (13.0.6)
rchardet (1.8.0)
rdiscount (2.2.7.1)
Expand All @@ -217,6 +240,24 @@ GEM
io-console (~> 0.5)
rexml (3.2.6)
rouge (4.1.3)
rubocop (1.56.4)
base64 (~> 0.1.1)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
parallel (~> 1.10)
parser (>= 3.2.2.3)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml (>= 3.2.5, < 4.0)
rubocop-ast (>= 1.28.1, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.29.0)
parser (>= 3.2.1.0)
rubocop-performance (1.19.1)
rubocop (>= 1.7.0, < 2.0)
rubocop-ast (>= 0.4.0)
ruby-progressbar (1.13.0)
ruby2_keywords (0.0.5)
rubyzip (2.3.2)
selenium-webdriver (4.12.0)
Expand All @@ -230,13 +271,26 @@ GEM
railties (>= 6.0)
sitepress-core (= 3.2.2)
sprockets-rails (>= 2.0.0)
smart_properties (1.17.0)
sprockets (4.2.1)
concurrent-ruby (~> 1.0)
rack (>= 2.2.4, < 4)
sprockets-rails (3.4.2)
actionpack (>= 5.2)
activesupport (>= 5.2)
sprockets (>= 3.0.0)
standard (1.31.2)
language_server-protocol (~> 3.17.0.2)
lint_roller (~> 1.0)
rubocop (~> 1.56.4)
standard-custom (~> 1.0.0)
standard-performance (~> 1.2)
standard-custom (1.0.2)
lint_roller (~> 1.0)
rubocop (~> 1.50)
standard-performance (1.2.1)
lint_roller (~> 1.1)
rubocop-performance (~> 1.19.1)
stimulus-rails (1.2.2)
railties (>= 6.0.0)
stringio (3.0.8)
Expand All @@ -248,6 +302,7 @@ GEM
railties (>= 6.0.0)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
unicode-display_width (2.5.0)
view_component (3.6.0)
activesupport (>= 5.2.0, < 8.0)
concurrent-ruby (~> 1.0)
Expand Down Expand Up @@ -281,6 +336,7 @@ DEPENDENCIES
bootsnap
capybara
debug
erb_lint (~> 0.5.0)
error_highlight (>= 0.4.0)
frozen_record (~> 0.27.0)
git (~> 1.18)
Expand All @@ -296,6 +352,7 @@ DEPENDENCIES
selenium-webdriver
sitepress-rails
sprockets-rails
standard (~> 1.31)
stimulus-rails
turbo-rails
tzinfo-data
Expand Down
8 changes: 3 additions & 5 deletions app/components/page/authors_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@

class Page::AuthorsComponent < ViewComponent::Base
def initialize(path:)
@path = path.gsub("#{Rails.root.to_s}/", "")
@path = path.gsub("#{Rails.root}/", "")
end

def git
@git ||= begin
GitRepo.with_cloned_repo do
Git.open(GitRepo.path)
end
@git ||= GitRepo.with_cloned_repo do
Git.open(GitRepo.path)
end
end

Expand Down
2 changes: 1 addition & 1 deletion app/components/page/contribute_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

class Page::ContributeComponent < ViewComponent::Base
def initialize(file:)
@file = file.gsub("#{Rails.root.to_s}/", "")
@file = file.gsub("#{Rails.root}/", "")
end

def github_edit_file_url
Expand Down
2 changes: 1 addition & 1 deletion app/components/ui/code_block.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def language

def lexer
"Rouge::Lexers::#{language}".constantize.new
rescue StandardError
rescue
Rouge::Lexers::PlainText.new
end

Expand Down
1 change: 0 additions & 1 deletion app/components/ui/container_component.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# frozen_string_literal: true

class UI::ContainerComponent < ViewComponent::Base

end
4 changes: 2 additions & 2 deletions app/content/helpers/page_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def with(*args, &block)

# Render a block within a layout. This is a useful, and prefered way, to handle
# nesting layouts, within Sitepress.
def render_layout(layout, **kwargs, &block)
render html: capture(&block), layout: "layouts/#{layout}", **kwargs
def render_layout(layout, **, &block)
render(html: capture(&block), layout: "layouts/#{layout}", **)
end
end
2 changes: 1 addition & 1 deletion app/content/pages/community/blogs.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ subtitle: Blogs publishing Hotwire content
<% page.with_title(title: current_page.data.fetch("subtitle")) %>
<% Blog.order(name: :asc).each do |blog| %>
<%= link_to blog.name, blog.url, target: '_blank' %><br/>
<%= link_to blog.name, blog.url, target: :_blank %><br>
<% end %>
<% end %>
2 changes: 1 addition & 1 deletion app/content/pages/community/books.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ title: Books
<% page.with_title(title: current_page.data.fetch("title")) %>
<% Book.order(name: :asc).each do |book| %>
<%= link_to book.name, book.url, target: '_blank' %><br/>
<%= link_to book.name, book.url, target: :_blank %><br>
<% end %>
<% end %>
2 changes: 1 addition & 1 deletion app/content/pages/community/channels.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ subtitle: Channels publishing Hotwire content
<% page.with_title(title: current_page.data.fetch("subtitle")) %>
<% Channel.order(name: :asc).each do |channel| %>
<%= link_to channel.name, channel.url, target: '_blank' %><br/>
<%= link_to channel.name, channel.url, target: :_blank %><br>
<% end %>
<% end %>
6 changes: 3 additions & 3 deletions app/content/pages/community/jobs.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ title: Jobs
<%= render Page::ContainerComponent.new(page: current_page) do |page| %>
<% page.with_title(title: current_page.data.fetch("title")) %>

https://railshotwirejobs.com/jobs<br/>
https://rubyonremote.com/remote-hotwire-jobs/<br/>
https://gorails.com/jobs<br/>
https://railshotwirejobs.com/jobs<br>
https://rubyonremote.com/remote-hotwire-jobs/<br>
https://gorails.com/jobs<br>
<% end %>
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ library: turbo
<%= render Page::ContainerComponent.new(page: current_page) do |page| %>
<% page.with_title(title: current_page.data.fetch("title")) %>

* After submitting a form<br/>
* After clicking a button<br/>
* After navigating a frame<br/>
* From the server-side<br/>
* ...<br/>
* After submitting a form<br>
* After clicking a button<br>
* After navigating a frame<br>
* From the server-side<br>
* ...<br>

<%= render Page::ContributeComponent.new(file: current_page.asset.path.path) %>
<% end %>
4 changes: 2 additions & 2 deletions app/content/pages/ecosystem/components.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ order: 7
<%= render Page::ContainerComponent.new(page: current_page) do |page| %>
<% page.with_title(title: current_page.data.fetch("title")) %>

https://github.com/excid3/tailwindcss-stimulus-components<br/>
https://www.stimulus-components.com<br/>
https://github.com/excid3/tailwindcss-stimulus-components<br>
https://www.stimulus-components.com<br>

<%= render Page::CardSectionComponent.new(
title: current_page.data.fetch("title"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ title: Stimulus Components
<%= render Page::ContainerComponent.new(page: current_page) do |page| %>
<% page.with_title(title: current_page.data.fetch("title")) %>
<%= link_to "stimulus-components", "https://github.com/stimulus-components", target: '_blank' %><br/>
<%= link_to "Documentation", "https://www.stimulus-components.com", target: '_blank' %><br/>
<%= link_to "stimulus-components", "https://github.com/stimulus-components", target: :_blank %><br>
<%= link_to "Documentation", "https://www.stimulus-components.com", target: :_blank %><br>
<% end %>
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ title: Tailwindcss Stimulus Components
<%= render Page::ContainerComponent.new(page: current_page) do |page| %>
<% page.with_title(title: current_page.data.fetch("title")) %>
<%= link_to "excid3/tailwindcss-stimulus-components", "https://github.com/excid3/tailwindcss-stimulus-components", target: '_blank' %><br/>
<%= link_to "Documentation", "https://excid3.github.io/tailwindcss-stimulus-components/", target: '_blank' %><br/>
<%= link_to "excid3/tailwindcss-stimulus-components", "https://github.com/excid3/tailwindcss-stimulus-components", target: :_blank %><br>
<%= link_to "Documentation", "https://excid3.github.io/tailwindcss-stimulus-components/", target: :_blank %><br>
<% end %>
4 changes: 2 additions & 2 deletions app/content/pages/ecosystem/deployment/fly.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ title: Fly.io
<%= render Page::ContainerComponent.new(page: current_page) do |page| %>
<% page.with_title(title: current_page.data.fetch("title")) %>
<%= link_to "Website", "https://fly.io", target: '_blank' %><br/>
<%= link_to "Documentation", "https://fly.io/docs/languages-and-frameworks/ruby", target: '_blank' %><br/>
<%= link_to "Website", "https://fly.io", target: :_blank %><br>
<%= link_to "Documentation", "https://fly.io/docs/languages-and-frameworks/ruby", target: :_blank %><br>
<% end %>
4 changes: 2 additions & 2 deletions app/content/pages/ecosystem/deployment/kamal.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ title: Kamal
<%= render Page::ContainerComponent.new(page: current_page) do |page| %>
<% page.with_title(title: current_page.data.fetch("title")) %>
<%= link_to "basecamp/kamal", "https://github.com/basecamp/kamal", target: '_blank' %><br/>
<%= link_to "Website", "https://kamal-deploy.org", target: '_blank' %><br/>
<%= link_to "basecamp/kamal", "https://github.com/basecamp/kamal", target: :_blank %><br>
<%= link_to "Website", "https://kamal-deploy.org", target: :_blank %><br>
<% end %>
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ title: Scaling Websockets with AnyCable
<%= render Page::ContainerComponent.new(page: current_page) do |page| %>
<% page.with_title(title: current_page.data.fetch("title")) %>
<%= link_to "anycable/anycable", "https://github.com/anycable/anycable", target: '_blank' %><br/>
<%= link_to "anycable.io", "https://anycable.io", target: '_blank' %><br/>
<%= link_to "Documentation", "https://docs.anycable.io/guides/hotwire", target: '_blank' %><br/>
<%= link_to "anycable/anycable", "https://github.com/anycable/anycable", target: :_blank %><br>
<%= link_to "anycable.io", "https://anycable.io", target: :_blank %><br>
<%= link_to "Documentation", "https://docs.anycable.io/guides/hotwire", target: :_blank %><br>
<% end %>
4 changes: 2 additions & 2 deletions app/content/pages/ecosystem/extensions/stimulus-use.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ title: Stimulus Use
<%= render Page::ContainerComponent.new(page: current_page) do |page| %>
<% page.with_title(title: current_page.data.fetch("title")) %>
<%= link_to "stimulus-use/stimulus-use", "https://github.com/stimulus-use/stimulus-use", target: '_blank' %><br/>
<%= link_to "Documentation", "https://stimulus-use.github.io/stimulus-use", target: '_blank' %>
<%= link_to "stimulus-use/stimulus-use", "https://github.com/stimulus-use/stimulus-use", target: :_blank %><br>
<%= link_to "Documentation", "https://stimulus-use.github.io/stimulus-use", target: :_blank %>
<% end %>
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ image: morph.png
<%= render Page::ContainerComponent.new(page: current_page) do |page| %>
<% page.with_title(title: current_page.data.fetch("title")) %>
<%= link_to "marcoroth/turbo-morph", "https://github.com/marcoroth/turbo-morph", target: '_blank' %><br/>
<%= link_to "marcoroth/turbo-morph", "https://github.com/marcoroth/turbo-morph", target: :_blank %><br>
<% end %>
4 changes: 2 additions & 2 deletions app/content/pages/ecosystem/extensions/turbo-power.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ image: power.png
<%= render Page::ContainerComponent.new(page: current_page) do |page| %>
<% page.with_title(title: current_page.data.fetch("title")) %>
<%= link_to "marcoroth/turbo_power", "https://github.com/marcoroth/turbo_power", target: '_blank' %><br/>
<%= link_to "marcoroth/turbo_power-rails", "https://github.com/marcoroth/turbo_power-rails", target: '_blank' %><br/>
<%= link_to "marcoroth/turbo_power", "https://github.com/marcoroth/turbo_power", target: :_blank %><br>
<%= link_to "marcoroth/turbo_power-rails", "https://github.com/marcoroth/turbo_power-rails", target: :_blank %><br>
<% end %>
2 changes: 1 addition & 1 deletion app/content/pages/ecosystem/gems/kredis.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ title: Kredis
<%= render Page::ContainerComponent.new(page: current_page) do |page| %>
<% page.with_title(title: current_page.data.fetch("title")) %>
<%= link_to "rails/kredis", "https://github.com/rails/kredis", target: '_blank' %><br/>
<%= link_to "rails/kredis", "https://github.com/rails/kredis", target: :_blank %><br>
<% end %>
4 changes: 2 additions & 2 deletions app/content/pages/ecosystem/gems/phlex.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ title: Phlex
<%= render Page::ContainerComponent.new(page: current_page) do |page| %>
<% page.with_title(title: current_page.data.fetch("title")) %>
<%= link_to "phlex-ruby/phlex", "https://github.com/phlex-ruby/phlex", target: '_blank' %><br/>
<%= link_to "phlex-ruby/phlex-rails", "https://github.com/phlex-ruby/phlex-rails", target: '_blank' %><br/>
<%= link_to "phlex-ruby/phlex", "https://github.com/phlex-ruby/phlex", target: :_blank %><br>
<%= link_to "phlex-ruby/phlex-rails", "https://github.com/phlex-ruby/phlex-rails", target: :_blank %><br>
<% end %>
2 changes: 1 addition & 1 deletion app/content/pages/ecosystem/gems/turbo-ruby.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ title: Turbo Ruby
<%= render Page::ContainerComponent.new(page: current_page) do |page| %>
<% page.with_title(title: current_page.data.fetch("title")) %>
<%= link_to "marcoroth/turbo-ruby", "https://github.com/marcoroth/turbo-ruby", target: '_blank' %><br/>
<%= link_to "marcoroth/turbo-ruby", "https://github.com/marcoroth/turbo-ruby", target: :_blank %><br>
<% end %>

0 comments on commit 138cd91

Please sign in to comment.