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 +4 -4
- data/default.yml +6 -0
- data/lib/gl_rubocop/gl_cops/view_component_initialize_keyword_args.rb +30 -0
- data/lib/gl_rubocop/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8d0d6882bfbd2fb93c58c4c0e3a9302e4f98ac4977aa469e0b40a57856a7cfd0
|
|
4
|
+
data.tar.gz: 86ea3ab20f3b8899e6b8806ad1daabf561d732c6ad26c80017102e57c8f67bf1
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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
|
data/lib/gl_rubocop/version.rb
CHANGED
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.
|
|
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-
|
|
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
|