From 6692c20ea585986b913d2f5f21fcaa6bd764bf13 Mon Sep 17 00:00:00 2001 From: Calvin Walzel Date: Sat, 10 Feb 2024 17:30:35 +0100 Subject: [PATCH] Setup linting, tooling & formatting - A project-specific VS Code settings file - Suggested VS Code extensions - Rubocop with the Shopify style guide - `ruby-lsp-rails` addon for RubyLSP Co-authored-by: Gitta van der Pol --- .rubocop.yml | 13 +++++++++++++ .vscode/extensions.json | 6 ++++++ .vscode/settings.json | 22 ++++++++++++++++++++++ Gemfile | 12 ++++++++++-- Gemfile.lock | 40 ++++++++++++++++++++++++++++++++++++++++ 5 files changed, 91 insertions(+), 2 deletions(-) create mode 100644 .rubocop.yml create mode 100644 .vscode/extensions.json create mode 100644 .vscode/settings.json diff --git a/.rubocop.yml b/.rubocop.yml new file mode 100644 index 0000000..a970986 --- /dev/null +++ b/.rubocop.yml @@ -0,0 +1,13 @@ +# The behavior of RuboCop can be controlled via the .rubocop.yml +# configuration file. It makes it possible to enable/disable +# certain cops (checks) and to alter their behavior if they accept +# any parameters. The file can be placed either in your home +# directory or in some project directory. +# +# RuboCop will start looking for the configuration file in the directory +# where the inspected file is and continue its way up to the root directory. +# +# See https://docs.rubocop.org/rubocop/configuration + +inherit_gem: + rubocop-shopify: rubocop.yml diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 0000000..f17d6d3 --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,6 @@ +{ + "recommendations": [ + "shopify.ruby-lsp", + "esbenp.prettier-vscode" + ] +} diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..a5f5d08 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,22 @@ +{ + "editor.formatOnSave": true, + "editor.defaultFormatter": "esbenp.prettier-vscode", + "rubyLsp.enabledFeatures": { + "codeActions": true, + "diagnostics": true, + "documentHighlights": true, + "documentLink": true, + "documentSymbols": true, + "foldingRanges": true, + "formatting": true, + "hover": true, + "inlayHint": true, + "onTypeFormatting": true, + "selectionRanges": true, + "semanticHighlighting": true, + "completion": true, + "codeLens": true + }, + "rubyLsp.enableExperimentalFeatures": true, + "[ruby]": { "editor.defaultFormatter": "Shopify.ruby-lsp" } +} diff --git a/Gemfile b/Gemfile index 05a10e9..6e6e38b 100644 --- a/Gemfile +++ b/Gemfile @@ -1,3 +1,5 @@ +# frozen_string_literal: true + source "https://rubygems.org" ruby "3.2.3" @@ -39,7 +41,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: [:windows, :jruby] # Reduces boot times through caching; required in config/boot.rb gem "bootsnap", require: false @@ -49,7 +51,7 @@ 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 "debug", platforms: [:mri, :windows] end group :development do @@ -68,3 +70,9 @@ group :test do gem "capybara" gem "selenium-webdriver" end + +gem "rubocop", require: false + +gem "rubocop-shopify", require: false + +gem "ruby-lsp-rails", "~> 0.2.9", :group => :development diff --git a/Gemfile.lock b/Gemfile.lock index 9ef32a1..f52c932 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -77,6 +77,7 @@ GEM tzinfo (~> 2.0) addressable (2.8.6) public_suffix (>= 2.0.2, < 6.0) + ast (2.4.2) base64 (0.2.0) bigdecimal (3.1.6) bindex (0.8.1) @@ -117,6 +118,8 @@ GEM jbuilder (2.11.5) actionview (>= 5.0.0) activesupport (>= 5.0.0) + json (2.7.1) + language_server-protocol (3.17.0.3) loofah (2.22.0) crass (~> 1.0.2) nokogiri (>= 1.12.0) @@ -153,7 +156,12 @@ GEM racc (~> 1.4) nokogiri (1.16.2-x86_64-linux) racc (~> 1.4) + parallel (1.24.0) + parser (3.3.0.5) + ast (~> 2.4.1) + racc pg (1.5.4) + prism (0.19.0) psych (5.1.2) stringio public_suffix (5.0.4) @@ -197,6 +205,7 @@ GEM rake (>= 12.2) thor (~> 1.0, >= 1.2.2) zeitwerk (~> 2.6) + rainbow (3.1.1) rake (13.1.0) rdoc (6.6.2) psych (>= 4.0.0) @@ -208,6 +217,32 @@ GEM reline (0.4.2) io-console (~> 0.5) rexml (3.2.6) + rubocop (1.60.2) + 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.30.0, < 2.0) + ruby-progressbar (~> 1.7) + unicode-display_width (>= 2.4.0, < 3.0) + rubocop-ast (1.30.0) + parser (>= 3.2.1.0) + rubocop-shopify (2.14.0) + rubocop (~> 1.51) + ruby-lsp (0.13.4) + language_server-protocol (~> 3.17.0) + prism (>= 0.19.0, < 0.20) + sorbet-runtime (>= 0.5.10782) + ruby-lsp-rails (0.2.9) + actionpack (>= 6.0) + activerecord (>= 6.0) + railties (>= 6.0) + ruby-lsp (>= 0.13.0, < 0.14.0) + sorbet-runtime (>= 0.5.9897) + ruby-progressbar (1.13.0) ruby2_keywords (0.0.5) rubyzip (2.3.2) selenium-webdriver (4.17.0) @@ -215,6 +250,7 @@ GEM rexml (~> 3.2, >= 3.2.5) rubyzip (>= 1.2.2, < 3.0) websocket (~> 1.0) + sorbet-runtime (0.5.11247) sprockets (4.2.1) concurrent-ruby (~> 1.0) rack (>= 2.2.4, < 4) @@ -245,6 +281,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) @@ -277,6 +314,9 @@ DEPENDENCIES puma (>= 5.0) rails (~> 7.1.3) redis (>= 4.0.1) + rubocop + rubocop-shopify + ruby-lsp-rails (~> 0.2.9) selenium-webdriver sprockets-rails stimulus-rails