gl_rubocop 0.3.2 → 0.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c142a90b62896eea7a2ef83f59c565463529eb5eec02d5f7e3d1f5c892f7ae4e
4
- data.tar.gz: 2539a4287220284a0b69200f3a86b42d213bec3f8950667560f34fe37ca7a389
3
+ metadata.gz: 8d0d6882bfbd2fb93c58c4c0e3a9302e4f98ac4977aa469e0b40a57856a7cfd0
4
+ data.tar.gz: 86ea3ab20f3b8899e6b8806ad1daabf561d732c6ad26c80017102e57c8f67bf1
5
5
  SHA512:
6
- metadata.gz: 3d7b1e1bbea93e8fb6427c79d16636f6a58ba376ee233189bdd18351cc6597f3b71338163e5d23477c2566c3ac3c91f7086cf5db819c6f6de9f429261f2bd8d0
7
- data.tar.gz: a2739ce3a9419792deb3e42362e8f8ae454b7551c64695ac92e6859075db7927a9fc83409c5f854d079d966e829d2fed3bea87ac18adb29a29bed55c9e8841d0
6
+ metadata.gz: bac9a336b0f9e60517d727a5791f8cf909d824ce978e30dff1bb3a4788d22ed358fff0106e14db757c64c3079a0fa7df7b7cb632df258bce529a963b3d6763d4
7
+ data.tar.gz: 7b84eda9ac0ea8feddc5996f499b36c4d0408d729f764b95b882dbdcfdf5fe7a44e08d1e1eaa6dec5e726bfcfd75e45ad88e157d017afc3497ea4e43378ef5a4
data/default.yml CHANGED
@@ -17,6 +17,7 @@ require:
17
17
  - ./lib/gl_rubocop/gl_cops/sidekiq_inherits_from_sidekiq_job.rb
18
18
  - ./lib/gl_rubocop/gl_cops/unique_identifier.rb
19
19
  - ./lib/gl_rubocop/gl_cops/tailwind_no_contradicting_class_name.rb
20
+ - ./lib/gl_rubocop/gl_cops/view_component_initialize_keyword_args.rb
20
21
 
21
22
  AllCops:
22
23
  SuggestExtensions: false
@@ -75,6 +76,11 @@ GLCops/UniqueIdentifier:
75
76
  Include:
76
77
  - "app/components/**/*.erb"
77
78
 
79
+ GLCops/ViewComponentInitializeKeywordArgs:
80
+ Enabled: true
81
+ Include:
82
+ - "app/components/**/component.rb"
83
+
78
84
  I18n/GetText:
79
85
  Enabled: false
80
86
 
@@ -0,0 +1,30 @@
1
+ # rubocop:disable I18n/RailsI18n/DecorateString
2
+ module GLRubocop
3
+ module GLCops
4
+ # This cop ensures that ViewComponent initialize methods use keyword arguments only.
5
+ #
6
+ # Good:
7
+ # def initialize(name:, age:)
8
+ # def initialize(name:, age: 18)
9
+ # def initialize(**options)
10
+ #
11
+ # Bad:
12
+ # def initialize(name, age)
13
+ # def initialize(name, age:)
14
+ class ViewComponentInitializeKeywordArgs < RuboCop::Cop::Cop
15
+ MSG = 'ViewComponent initialize methods must use keyword arguments only.'.freeze
16
+
17
+ def on_def(node)
18
+ return unless node.method_name == :initialize
19
+ return if node.arguments.empty?
20
+
21
+ has_positional_args = node.arguments.any? do |arg|
22
+ arg.arg_type? || arg.optarg_type? || arg.restarg_type?
23
+ end
24
+
25
+ add_offense(node, message: MSG) if has_positional_args
26
+ end
27
+ end
28
+ end
29
+ end
30
+ # rubocop:enable I18n/RailsI18n/DecorateString
@@ -1,3 +1,3 @@
1
1
  module GLRubocop
2
- VERSION = '0.3.2'.freeze
2
+ VERSION = '0.3.3'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gl_rubocop
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Give Lively
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-11-05 00:00:00.000000000 Z
11
+ date: 2025-11-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubocop
@@ -171,6 +171,7 @@ files:
171
171
  - lib/gl_rubocop/gl_cops/sidekiq_inherits_from_sidekiq_job.rb
172
172
  - lib/gl_rubocop/gl_cops/tailwind_no_contradicting_class_name.rb
173
173
  - lib/gl_rubocop/gl_cops/unique_identifier.rb
174
+ - lib/gl_rubocop/gl_cops/view_component_initialize_keyword_args.rb
174
175
  - lib/gl_rubocop/helpers/erb_content_helper.rb
175
176
  - lib/gl_rubocop/helpers/haml_content_helper.rb
176
177
  - lib/gl_rubocop/version.rb