From 6171a51720bfd8505a5b770c2f2badfabf3001a1 Mon Sep 17 00:00:00 2001 From: Sven Weidauer Date: Tue, 7 Jun 2022 10:34:12 +0200 Subject: [PATCH 01/11] Add explanation why Ruby --- README.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/README.md b/README.md index c204339..bcf923c 100644 --- a/README.md +++ b/README.md @@ -94,3 +94,16 @@ must read file content via `stdin`. Anything that the lint command outputs to option to tell it to read content from `stdin` instead of reading files from disk, and messages from `eslint` are redirected to `stderr` (using the `>&2` notation) so that you can see them. + +### Why the Ruby port if there already is a fine Python implementation? + +I don’t like Python ;) + +But jokes aside, I am already setting up a Ruby environment (using [rbenv][]) for my +projects to run [cocoapods][] and [fastlane][] and our git hooks. By using this port +we don’t need to ensure to have python available as well. + + +[rbenv]: https://github.com/rbenv/rbenv/ +[cocoapods]: https://cocoapods.org/ +[fastlane]: https://fastlane.tools/ From d092c3650fc53fbb8c3556822eaa3ee190693def Mon Sep 17 00:00:00 2001 From: Sven Date: Sun, 7 Aug 2022 11:18:22 +0200 Subject: [PATCH 02/11] Remove schedule from Rubocop workflow --- .github/workflows/rubocop.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/rubocop.yml b/.github/workflows/rubocop.yml index d442459..732cf2b 100644 --- a/.github/workflows/rubocop.yml +++ b/.github/workflows/rubocop.yml @@ -12,8 +12,6 @@ on: pull_request: # The branches below must be a subset of the branches above branches: [ main ] - schedule: - - cron: '20 4 * * 5' jobs: rubocop: From 672ad20150a3ba617866585026e96d3670cc6331 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 16 May 2024 19:55:42 +0000 Subject: [PATCH 03/11] Bump rexml from 3.2.5 to 3.2.8 Bumps [rexml](https://github.com/ruby/rexml) from 3.2.5 to 3.2.8. - [Release notes](https://github.com/ruby/rexml/releases) - [Changelog](https://github.com/ruby/rexml/blob/master/NEWS.md) - [Commits](https://github.com/ruby/rexml/compare/v3.2.5...v3.2.8) --- updated-dependencies: - dependency-name: rexml dependency-type: indirect ... Signed-off-by: dependabot[bot] --- Gemfile.lock | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 9bd2244..bfe6880 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -18,7 +18,8 @@ GEM rainbow (3.1.1) rake (13.0.6) regexp_parser (2.4.0) - rexml (3.2.5) + rexml (3.2.8) + strscan (>= 3.0.9) rspec (3.11.0) rspec-core (~> 3.11.0) rspec-expectations (~> 3.11.0) @@ -50,6 +51,7 @@ GEM rubocop-rspec (2.11.1) rubocop (~> 1.19) ruby-progressbar (1.11.0) + strscan (3.1.0) unicode-display_width (2.1.0) PLATFORMS From 40fe55854a4dd0d70cbe4952e512639a9863d940 Mon Sep 17 00:00:00 2001 From: Sven Weidauer Date: Sun, 16 Jun 2024 17:51:45 +0200 Subject: [PATCH 04/11] Update dependencies --- Gemfile.lock | 66 +++++++++++++++++++++++++++++----------------------- 1 file changed, 37 insertions(+), 29 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 9bd2244..1877d4e 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -10,47 +10,55 @@ GEM ast (2.4.2) code-scanning-rubocop (0.6.1) rubocop (~> 1.0) - colorize (0.8.1) - diff-lcs (1.5.0) - parallel (1.22.1) - parser (3.1.2.0) + colorize (1.1.0) + diff-lcs (1.5.1) + json (2.7.2) + language_server-protocol (3.17.0.3) + parallel (1.25.1) + parser (3.3.3.0) ast (~> 2.4.1) + racc + racc (1.8.0) rainbow (3.1.1) - rake (13.0.6) - regexp_parser (2.4.0) - rexml (3.2.5) - rspec (3.11.0) - rspec-core (~> 3.11.0) - rspec-expectations (~> 3.11.0) - rspec-mocks (~> 3.11.0) - rspec-core (3.11.0) - rspec-support (~> 3.11.0) - rspec-expectations (3.11.0) + rake (13.2.1) + regexp_parser (2.9.2) + rexml (3.3.0) + strscan + rspec (3.13.0) + rspec-core (~> 3.13.0) + rspec-expectations (~> 3.13.0) + rspec-mocks (~> 3.13.0) + rspec-core (3.13.0) + rspec-support (~> 3.13.0) + rspec-expectations (3.13.1) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.11.0) - rspec-mocks (3.11.1) + rspec-support (~> 3.13.0) + rspec-mocks (3.13.1) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.11.0) - rspec-support (3.11.0) - rspec_junit_formatter (0.5.1) + rspec-support (~> 3.13.0) + rspec-support (3.13.1) + rspec_junit_formatter (0.6.0) rspec-core (>= 2, < 4, != 2.12.0) - rubocop (1.29.1) + rubocop (1.64.1) + json (~> 2.3) + language_server-protocol (>= 3.17.0) parallel (~> 1.10) - parser (>= 3.1.0.0) + 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.17.0, < 2.0) + rubocop-ast (>= 1.31.1, < 2.0) ruby-progressbar (~> 1.7) - unicode-display_width (>= 1.4.0, < 3.0) - rubocop-ast (1.18.0) - parser (>= 3.1.1.0) + unicode-display_width (>= 2.4.0, < 3.0) + rubocop-ast (1.31.3) + parser (>= 3.3.1.0) rubocop-rake (0.6.0) rubocop (~> 1.0) - rubocop-rspec (2.11.1) - rubocop (~> 1.19) - ruby-progressbar (1.11.0) - unicode-display_width (2.1.0) + rubocop-rspec (3.0.1) + rubocop (~> 1.61) + ruby-progressbar (1.13.0) + strscan (3.1.0) + unicode-display_width (2.5.0) PLATFORMS ruby From 8fa719df7ae4fb4140a525f084954bd3344b9b04 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 2 Aug 2024 16:42:11 +0000 Subject: [PATCH 05/11] Bump rexml from 3.3.0 to 3.3.3 Bumps [rexml](https://github.com/ruby/rexml) from 3.3.0 to 3.3.3. - [Release notes](https://github.com/ruby/rexml/releases) - [Changelog](https://github.com/ruby/rexml/blob/master/NEWS.md) - [Commits](https://github.com/ruby/rexml/compare/v3.3.0...v3.3.3) --- updated-dependencies: - dependency-name: rexml dependency-type: indirect ... Signed-off-by: dependabot[bot] --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 1877d4e..a9fa1ce 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -22,7 +22,7 @@ GEM rainbow (3.1.1) rake (13.2.1) regexp_parser (2.9.2) - rexml (3.3.0) + rexml (3.3.3) strscan rspec (3.13.0) rspec-core (~> 3.13.0) From 120bb4b79adcbbc91aaf83b69bd70fca8f370b23 Mon Sep 17 00:00:00 2001 From: Sven Weidauer Date: Sat, 3 Aug 2024 19:21:16 +0200 Subject: [PATCH 06/11] Update dependencies --- Gemfile.lock | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index a9fa1ce..f16d3e1 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -15,14 +15,14 @@ GEM json (2.7.2) language_server-protocol (3.17.0.3) parallel (1.25.1) - parser (3.3.3.0) + parser (3.3.4.0) ast (~> 2.4.1) racc - racc (1.8.0) + racc (1.8.1) rainbow (3.1.1) rake (13.2.1) regexp_parser (2.9.2) - rexml (3.3.3) + rexml (3.3.4) strscan rspec (3.13.0) rspec-core (~> 3.13.0) @@ -39,13 +39,13 @@ GEM rspec-support (3.13.1) rspec_junit_formatter (0.6.0) rspec-core (>= 2, < 4, != 2.12.0) - rubocop (1.64.1) + rubocop (1.65.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) + regexp_parser (>= 2.4, < 3.0) rexml (>= 3.2.5, < 4.0) rubocop-ast (>= 1.31.1, < 2.0) ruby-progressbar (~> 1.7) @@ -54,7 +54,7 @@ GEM parser (>= 3.3.1.0) rubocop-rake (0.6.0) rubocop (~> 1.0) - rubocop-rspec (3.0.1) + rubocop-rspec (3.0.3) rubocop (~> 1.61) ruby-progressbar (1.13.0) strscan (3.1.0) From 604fe35be60d16c9a97535eb0b62b54be58d3a77 Mon Sep 17 00:00:00 2001 From: Sven Weidauer Date: Sat, 3 Aug 2024 19:23:03 +0200 Subject: [PATCH 07/11] autocorrect --- bin/git-format-staged | 2 +- lib/format-staged/job.rb | 2 +- spec/test_spec.rb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/bin/git-format-staged b/bin/git-format-staged index 41d0829..2111bcc 100755 --- a/bin/git-format-staged +++ b/bin/git-format-staged @@ -17,7 +17,7 @@ parser = OptionParser.new do |opt| <<~DOC Shell command to format files, will run once per file. Occurrences of the placeholder `{}` will \ be replaced with a path to the file being formatted. \ - (Example: "prettier --stdin-filepath \'{}\'") + (Example: "prettier --stdin-filepath '{}'") DOC ) do |o| parameters[:formatter] = o diff --git a/lib/format-staged/job.rb b/lib/format-staged/job.rb index 18bacc8..176b099 100644 --- a/lib/format-staged/job.rb +++ b/lib/format-staged/job.rb @@ -39,7 +39,7 @@ module FormatStaged return false unless formatted.size == files.size quiet = @verbose ? [] : ['--quiet'] - return !write || get_status('git', 'diff-index', '--cached', '--exit-code', *quiet, 'HEAD') != 0 + !write || get_status('git', 'diff-index', '--cached', '--exit-code', *quiet, 'HEAD') != 0 end def repo_root diff --git a/spec/test_spec.rb b/spec/test_spec.rb index ce53719..26fc0ff 100644 --- a/spec/test_spec.rb +++ b/spec/test_spec.rb @@ -132,7 +132,7 @@ describe FormatStaged do repo.set_content 'test.test', 'a=b' repo.stage 'test.test' - expect(repo.run_formatter write: false).to be_truthy + expect(repo.run_formatter(write: false)).to be_truthy expect(repo.get_content('test.test')).to eq 'a=b' expect(repo.get_staged('test.test')).to eq 'a=b' end From 567198c1827dce911f5c98ab9753061f2c7895ad Mon Sep 17 00:00:00 2001 From: Sven Weidauer Date: Sat, 3 Aug 2024 19:28:01 +0200 Subject: [PATCH 08/11] add dev gems to Gemfile instead of gemspec --- Gemfile | 7 +++++++ format-staged.gemspec | 6 ------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/Gemfile b/Gemfile index 26ea26a..7cfcf2a 100644 --- a/Gemfile +++ b/Gemfile @@ -8,3 +8,10 @@ group :ci do gem 'code-scanning-rubocop' gem 'rspec_junit_formatter' end + + +gem 'rake', '~> 13.0' +gem 'rspec' +gem 'rubocop', '~> 1.29' +gem 'rubocop-rake', '~> 0.6' +gem 'rubocop-rspec' diff --git a/format-staged.gemspec b/format-staged.gemspec index d8fd383..ddde6c8 100644 --- a/format-staged.gemspec +++ b/format-staged.gemspec @@ -19,12 +19,6 @@ Gem::Specification.new do |s| s.add_dependency 'colorize' - s.add_development_dependency 'rake', '~> 13.0' - s.add_development_dependency 'rspec' - s.add_development_dependency 'rubocop', '~> 1.29' - s.add_development_dependency 'rubocop-rake', '~> 0.6' - s.add_development_dependency 'rubocop-rspec' - s.metadata = { 'rubygems_mfa_required' => 'true' } From e894f65f304aafe515994d3b4e998c3e25f071c1 Mon Sep 17 00:00:00 2001 From: Sven Weidauer Date: Sat, 3 Aug 2024 19:43:09 +0200 Subject: [PATCH 09/11] Remove rubocop-rspec for now --- .rubocop.yml | 3 +++ Gemfile | 1 - Gemfile.lock | 3 --- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 72f47ae..f3d5561 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,3 +1,6 @@ +require: + - rubocop-rake + AllCops: NewCops: enable TargetRubyVersion: 2.7 diff --git a/Gemfile b/Gemfile index 7cfcf2a..c57d2a7 100644 --- a/Gemfile +++ b/Gemfile @@ -14,4 +14,3 @@ gem 'rake', '~> 13.0' gem 'rspec' gem 'rubocop', '~> 1.29' gem 'rubocop-rake', '~> 0.6' -gem 'rubocop-rspec' diff --git a/Gemfile.lock b/Gemfile.lock index f16d3e1..0280dfa 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -54,8 +54,6 @@ GEM parser (>= 3.3.1.0) rubocop-rake (0.6.0) rubocop (~> 1.0) - rubocop-rspec (3.0.3) - rubocop (~> 1.61) ruby-progressbar (1.13.0) strscan (3.1.0) unicode-display_width (2.5.0) @@ -71,7 +69,6 @@ DEPENDENCIES rspec_junit_formatter rubocop (~> 1.29) rubocop-rake (~> 0.6) - rubocop-rspec BUNDLED WITH 2.1.4 From 0af937edac5c913e2d89ab104ab606ccb1f90ce5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 22 Aug 2024 20:55:01 +0000 Subject: [PATCH 10/11] Bump rexml from 3.3.4 to 3.3.6 Bumps [rexml](https://github.com/ruby/rexml) from 3.3.4 to 3.3.6. - [Release notes](https://github.com/ruby/rexml/releases) - [Changelog](https://github.com/ruby/rexml/blob/master/NEWS.md) - [Commits](https://github.com/ruby/rexml/compare/v3.3.4...v3.3.6) --- updated-dependencies: - dependency-name: rexml dependency-type: indirect ... Signed-off-by: dependabot[bot] --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 0280dfa..d145a96 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -22,7 +22,7 @@ GEM rainbow (3.1.1) rake (13.2.1) regexp_parser (2.9.2) - rexml (3.3.4) + rexml (3.3.6) strscan rspec (3.13.0) rspec-core (~> 3.13.0) From 04c243009688068d46228aaaf34483688adf20a1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 28 Oct 2024 18:52:26 +0000 Subject: [PATCH 11/11] Bump rexml from 3.3.6 to 3.3.9 Bumps [rexml](https://github.com/ruby/rexml) from 3.3.6 to 3.3.9. - [Release notes](https://github.com/ruby/rexml/releases) - [Changelog](https://github.com/ruby/rexml/blob/master/NEWS.md) - [Commits](https://github.com/ruby/rexml/compare/v3.3.6...v3.3.9) --- updated-dependencies: - dependency-name: rexml dependency-type: indirect ... Signed-off-by: dependabot[bot] --- Gemfile.lock | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index d145a96..9344382 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -22,8 +22,7 @@ GEM rainbow (3.1.1) rake (13.2.1) regexp_parser (2.9.2) - rexml (3.3.6) - strscan + rexml (3.3.9) rspec (3.13.0) rspec-core (~> 3.13.0) rspec-expectations (~> 3.13.0) @@ -55,7 +54,6 @@ GEM rubocop-rake (0.6.0) rubocop (~> 1.0) ruby-progressbar (1.13.0) - strscan (3.1.0) unicode-display_width (2.5.0) PLATFORMS