Skip to content

Commit

Permalink
Merge pull request #9 from TelosLabs/4-configure-linters
Browse files Browse the repository at this point in the history
 Add rubocop, erb-lint, and auto-corrections
  • Loading branch information
Sergio-e authored Jul 5, 2024
2 parents e1f66c6 + d44d205 commit 362d9d9
Show file tree
Hide file tree
Showing 27 changed files with 249 additions and 88 deletions.
14 changes: 14 additions & 0 deletions .erb-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
glob: "**/*.{html}{+*,}.erb"
exclude:
- '**/vendor/**/*'
EnableDefaultLinters: true
linters:
PartialInstanceVariable:
enabled: true
ErbSafety:
enabled: true
Rubocop:
enabled: false
rubocop_config:
inherit_from:
- .rubocop.yml
35 changes: 35 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
require:
- rubocop-capybara
- rubocop-performance
- rubocop-rails
- rubocop-rspec
- rubocop-rspec_rails
- standard

inherit_gem:
standard: config/base.yml

AllCops:
TargetRubyVersion: 3.3.3
NewCops: enable
Exclude:
- "bin/**"
- "db/schema.rb"
- "vendor/**/*"

RSpec/ExampleLength:
Enabled: false
RSpec/MultipleExpectations:
Enabled: false
RSpec/LetSetup:
Enabled: false
RSpec/MultipleMemoizedHelpers:
Enabled: false
RSpecRails/InferredSpecType:
Enabled: false
Bundler/OrderedGems:
Enabled: true
Rails/HasAndBelongsToMany:
Enabled: false
Rails/UnknownEnv:
Environments: ["development", "test", "staging", "production"]
21 changes: 15 additions & 6 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,39 +5,48 @@ ruby "3.3.3"
gem "rails", "~> 7.1.3", ">= 7.1.3.4"

# Database
gem "sqlite3", "~> 1.4"
gem "activerecord-enhancedsqlite3-adapter", "~> 0.8.0"
gem "sqlite3", "~> 1.4"

# Jobs
gem "solid_queue"
gem "mission_control-jobs"
gem "solid_queue"

# Assets
gem "propshaft"
gem "importmap-rails"
gem "propshaft"
gem "tailwindcss-rails", "~> 2.6"

# Hotwire
gem "turbo-rails"
gem "stimulus-rails"
gem "turbo-rails"

# Authorization
gem "action_policy", "~> 0.7.0"

# Other
gem "bootsnap", require: false
gem "puma", ">= 5.0"
gem "tzinfo-data", platforms: %i[windows jruby]
gem "bootsnap", require: false

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 "dotenv"
gem "erb_lint", require: false
gem "pry-byebug"
gem "rspec-rails"
gem "rubocop-capybara", require: false
gem "rubocop-performance", require: false
gem "rubocop-rails", require: false
gem "rubocop-rspec", require: false
gem "rubocop-rspec_rails", require: false
gem "standard"
end

group :development do
gem "web-console"
gem "rack-mini-profiler"
gem "web-console"
end

group :test do
Expand Down
110 changes: 79 additions & 31 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,15 @@ GEM
tzinfo (~> 2.0)
addressable (2.8.7)
public_suffix (>= 2.0.2, < 7.0)
ast (2.4.2)
base64 (0.2.0)
better_html (2.1.1)
actionview (>= 6.0)
activesupport (>= 6.0)
ast (~> 2.0)
erubi (~> 1.4)
parser (>= 2.4)
smart_properties
bigdecimal (3.1.8)
bindex (0.8.1)
bootsnap (1.18.3)
Expand All @@ -106,9 +114,19 @@ GEM
capybara (~> 3.0)
ferrum (~> 0.15.0)
date (3.3.4)
debug (1.9.2)
irb (~> 1.10)
reline (>= 0.3.8)
diff-lcs (1.5.1)
dotenv (3.1.2)
drb (2.2.1)
erb_lint (0.5.0)
activesupport
better_html (>= 2.0.1)
parser (>= 2.7.1.4)
rainbow
rubocop
smart_properties
erubi (1.13.0)
et-orbi (1.2.11)
tzinfo
Expand All @@ -135,6 +153,9 @@ GEM
irb (1.13.2)
rdoc (>= 4.0.0)
reline (>= 0.4.2)
json (2.7.2)
language_server-protocol (3.17.0.3)
lint_roller (1.1.0)
loofah (2.22.0)
crass (~> 1.0.2)
nokogiri (>= 1.12.0)
Expand Down Expand Up @@ -165,18 +186,12 @@ GEM
net-smtp (0.5.0)
net-protocol
nio4r (2.7.3)
nokogiri (1.16.6-aarch64-linux)
racc (~> 1.4)
nokogiri (1.16.6-arm-linux)
racc (~> 1.4)
nokogiri (1.16.6-arm64-darwin)
racc (~> 1.4)
nokogiri (1.16.6-x86-linux)
racc (~> 1.4)
nokogiri (1.16.6-x86_64-darwin)
racc (~> 1.4)
nokogiri (1.16.6-x86_64-linux)
racc (~> 1.4)
parallel (1.25.1)
parser (3.3.3.0)
ast (~> 2.4.1)
racc
propshaft (0.9.0)
actionpack (>= 7.0.0)
activesupport (>= 7.0.0)
Expand Down Expand Up @@ -234,12 +249,15 @@ GEM
rake (>= 12.2)
thor (~> 1.0, >= 1.2.2)
zeitwerk (~> 2.6)
rainbow (3.1.1)
rake (13.2.1)
rdoc (6.7.0)
psych (>= 4.0.0)
regexp_parser (2.9.2)
reline (0.5.9)
io-console (~> 0.5)
rexml (3.3.1)
strscan
rspec (3.13.0)
rspec-core (~> 3.13.0)
rspec-expectations (~> 3.13.0)
Expand All @@ -265,35 +283,62 @@ GEM
rspec-retry (0.6.2)
rspec-core (> 3.3)
rspec-support (3.13.1)
rubocop (1.64.1)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
parallel (~> 1.10)
parser (>= 3.3.0.2)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml (>= 3.2.5, < 4.0)
rubocop-ast (>= 1.31.1, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.31.3)
parser (>= 3.3.1.0)
rubocop-capybara (2.21.0)
rubocop (~> 1.41)
rubocop-performance (1.21.1)
rubocop (>= 1.48.1, < 2.0)
rubocop-ast (>= 1.31.1, < 2.0)
rubocop-rails (2.25.0)
activesupport (>= 4.2.0)
rack (>= 1.1)
rubocop (>= 1.33.0, < 2.0)
rubocop-ast (>= 1.31.1, < 2.0)
rubocop-rspec (3.0.1)
rubocop (~> 1.61)
rubocop-rspec_rails (2.30.0)
rubocop (~> 1.61)
rubocop-rspec (~> 3, >= 3.0.1)
ruby-next-core (1.0.3)
ruby-progressbar (1.13.0)
smart_properties (1.17.0)
solid_queue (0.3.3)
activejob (>= 7.1)
activerecord (>= 7.1)
concurrent-ruby (>= 1.3.1)
fugit (~> 1.11.0)
railties (>= 7.1)
sqlite3 (1.7.3-aarch64-linux)
sqlite3 (1.7.3-arm-linux)
sqlite3 (1.7.3-arm64-darwin)
sqlite3 (1.7.3-x86-linux)
sqlite3 (1.7.3-x86_64-darwin)
sqlite3 (1.7.3-x86_64-linux)
standard (1.39.0)
language_server-protocol (~> 3.17.0.2)
lint_roller (~> 1.0)
rubocop (~> 1.64.0)
standard-custom (~> 1.0.0)
standard-performance (~> 1.4)
standard-custom (1.0.2)
lint_roller (~> 1.0)
rubocop (~> 1.50)
standard-performance (1.4.0)
lint_roller (~> 1.1)
rubocop-performance (~> 1.21.0)
stimulus-rails (1.3.3)
railties (>= 6.0.0)
stringio (3.1.1)
tailwindcss-rails (2.6.1)
railties (>= 7.0.0)
tailwindcss-rails (2.6.1-aarch64-linux)
railties (>= 7.0.0)
tailwindcss-rails (2.6.1-arm-linux)
railties (>= 7.0.0)
strscan (3.1.0)
tailwindcss-rails (2.6.1-arm64-darwin)
railties (>= 7.0.0)
tailwindcss-rails (2.6.1-x86_64-darwin)
railties (>= 7.0.0)
tailwindcss-rails (2.6.1-x86_64-linux)
railties (>= 7.0.0)
thor (1.3.1)
timeout (0.4.1)
turbo-rails (2.0.5)
Expand All @@ -302,6 +347,7 @@ GEM
railties (>= 6.0.0)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
unicode-display_width (2.5.0)
web-console (4.2.1)
actionview (>= 6.0.0)
activemodel (>= 6.0.0)
Expand All @@ -316,22 +362,18 @@ GEM
zeitwerk (2.6.16)

PLATFORMS
aarch64-linux
arm-linux
arm64-darwin-21
arm64-darwin-22
arm64-darwin-23
x86-linux
x86_64-darwin
x86_64-linux

DEPENDENCIES
action_policy (~> 0.7.0)
activerecord-enhancedsqlite3-adapter (~> 0.8.0)
bootsnap
capybara
cuprite
debug
dotenv
erb_lint
fuubar
importmap-rails
mission_control-jobs
Expand All @@ -343,8 +385,14 @@ DEPENDENCIES
rspec-instafail
rspec-rails
rspec-retry
rubocop-capybara
rubocop-performance
rubocop-rails
rubocop-rspec
rubocop-rspec_rails
solid_queue
sqlite3 (~> 1.4)
standard
stimulus-rails
tailwindcss-rails (~> 2.6)
turbo-rails
Expand Down
32 changes: 32 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,38 @@
1. Run `bin/setup` (needs to be run only once)
2. Run `bin/dev`

## Linting & Formatting

#### Ruby

We use [Standard Ruby](https://github.com/standardrb/standard) for linting and formatting.
- Run `bundle exec rubocop` to check all ruby files
- Run `bundle exec rubocop -a` to auto-correct offenses
- [How do I run RuboCop in my editor?](https://docs.rubocop.org/rubocop/1.25/integration_with_other_tools.html#editor-integration)

#### ERB

We use [ERB Lint](https://github.com/Shopify/erb-lint) to lint our ERB files.
- Run `bundle exec erblint --lint-all` to check all ERB files
- Run `bundle exec erblint --lint-all -a` to auto-correct offenses. WARNING: This command isn't safe and can break your code.

#### JavaScript

We use [StandardJS](https://standardjs.com/) to lint our JavaScript files.
- Install by running `npm install standard --global`
- Run `standard` to check all JavaScript files
- Run `standard --fix` to auto-correct offenses
- [How do I run StandardJS in my editor?](https://standardjs.com/#are-there-text-editor-plugins)
- [How do I make the output more readable?](https://github.com/standard/standard?tab=readme-ov-file#how-do-i-make-the-output-all-colorful-and-pretty)

#### Spelling

We use [Typos](https://github.com/crate-ci/typos) as a spell checker.
- Install by running `brew install typos-cli`
- Run `typos` to check all files
- Run `typos -w` to auto-correct offenses
- For false positives and other configuration, see the `_typos.yml` file

## Testing

Run tests by using `bundle exec rspec`.
Expand Down
15 changes: 15 additions & 0 deletions _typos.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# https://github.com/crate-ci/typos/blob/master/docs/reference.md

[default.extend-words]
# Don't correct the following words

[files]
extend-exclude = [
"app/assets/stylesheets/**",
"app/assets/fonts/**",
"vendor/**",
"/spec/fixtures/**",
"/lib/assets/**",
"*.css",
"*.pdf",
]
4 changes: 2 additions & 2 deletions app/javascript/application.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
// Configure your import map in config/importmap.rb. Read more: https://github.com/rails/importmap-rails
import "@hotwired/turbo-rails"
import "controllers"
import '@hotwired/turbo-rails'
import 'controllers'
4 changes: 2 additions & 2 deletions app/javascript/controllers/application.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Application } from "@hotwired/stimulus"
import { Application } from '@hotwired/stimulus'

const application = Application.start()

// Configure Stimulus development experience
application.debug = false
window.Stimulus = application
window.Stimulus = application

export { application }
Loading

0 comments on commit 362d9d9

Please sign in to comment.