gl_rubocop 0.2.20 → 0.3.1

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: e5cfeeb9c783874509854ab8f98e6c8f1d17284f81e16193666d99e49b2a7d0b
4
- data.tar.gz: 295a40eae88db48e09a7a03026e89744f511d57748e0591565f0767e3ab80257
3
+ metadata.gz: 41e19e076964ffc1a05ef167302c8bafae7cb60d1ea97eda7aed7d1d18dc1f9a
4
+ data.tar.gz: 255a28e9d265048423bb9d8b6631df100e9323a69a2396efe2a7ce4f3d725969
5
5
  SHA512:
6
- metadata.gz: 8344a4c809b323cdcc4c4a7d15441aa08346a8a6964237d4efc1e9fc9895293e098960d60268e74274720cc5f56c0472aea24b30c75abc8bbcad93b0b48e79f7
7
- data.tar.gz: 496e86ca9704c2329455f7f001dbd8fe89405dda81b23a9b6a0067b6d0760f9b49d202e4db532d97626673508ab8814a53f0d0dce5b0a6dd2fe4ece5ca85d930
6
+ metadata.gz: 17ba3a6abd931a45acf825da8a91dba45a0c267b881dc1b0d023991909e85594e58b74922c5204e4f39e306b74458cd28843edbbcee02b15918be67000d9c3b1
7
+ data.tar.gz: 3ffec237316d0fd6f301465a3bbd7d67f4ce2b80ec71b2a8d36e086c77d7c41a04a5a1f9b42c47374fece9fccd07b01f7e2fbe1ad03459f819eaeadfc23ba9cc
data/default.yml CHANGED
@@ -3,6 +3,7 @@ require:
3
3
  - rubocop-rails
4
4
  - rubocop-rspec
5
5
  - rubocop-magic_numbers
6
+ - rubocop-erb
6
7
  - rubocop-haml
7
8
  - rubocop-i18n
8
9
  - rubocop-rake
@@ -11,7 +12,7 @@ require:
11
12
  - ./lib/gl_rubocop/gl_cops/interactor_inherits_from_interactor_base.rb
12
13
  - ./lib/gl_rubocop/gl_cops/limit_flash_options.rb
13
14
  - ./lib/gl_rubocop/gl_cops/no_stubbing_perform_async.rb
14
- - ./lib/gl_rubocop/gl_cops/prevent_erb_files.rb
15
+ - ./lib/gl_rubocop/gl_cops/prevent_haml_files.rb
15
16
  - ./lib/gl_rubocop/gl_cops/rails_cache.rb
16
17
  - ./lib/gl_rubocop/gl_cops/sidekiq_inherits_from_sidekiq_job.rb
17
18
  - ./lib/gl_rubocop/gl_cops/unique_identifier.rb
@@ -54,7 +55,7 @@ GLCops/NoStubbingPerformAsync:
54
55
  Include:
55
56
  - "**/*spec.rb"
56
57
 
57
- GLCops/PreventErbFiles:
58
+ GLCops/PreventHamlFiles:
58
59
  Enabled: true
59
60
 
60
61
  GLCops/RailsCache:
@@ -68,7 +69,7 @@ GLCops/SidekiqInheritsFromSidekiqJob:
68
69
  GLCops/UniqueIdentifier:
69
70
  Enabled: true
70
71
  Include:
71
- - "app/components/**/*.haml"
72
+ - "app/components/**/*.erb"
72
73
 
73
74
  I18n/GetText:
74
75
  Enabled: false
data/gl_rubocop.gemspec CHANGED
@@ -2,8 +2,6 @@
2
2
 
3
3
  require_relative 'lib/gl_rubocop/version'
4
4
 
5
- NON_GEM_FILES = ['Gemfile', 'Gemfile.lock', 'Guardfile', 'bin/lint'].freeze
6
-
7
5
  Gem::Specification.new do |spec|
8
6
  spec.name = 'gl_rubocop'
9
7
  spec.version = GLRubocop::VERSION
@@ -26,7 +24,8 @@ Gem::Specification.new do |spec|
26
24
  spec.require_paths = ['lib']
27
25
 
28
26
  spec.add_dependency 'rubocop', '~> 1.62.1'
29
- spec.add_dependency 'rubocop-haml', '~> 0.2.4'
27
+ spec.add_dependency 'rubocop-erb'
28
+ spec.add_dependency 'rubocop-haml'
30
29
  spec.add_dependency 'rubocop-i18n'
31
30
  spec.add_dependency 'rubocop-magic_numbers'
32
31
  spec.add_dependency 'rubocop-performance'
@@ -1,11 +1,11 @@
1
1
  module GLRubocop
2
2
  module GLCops
3
- class PreventErbFiles < RuboCop::Cop::Cop
4
- MSG = 'File name should not end with .erb'.freeze
3
+ class PreventHamlFiles < RuboCop::Cop::Cop
4
+ MSG = 'File name should not end with .haml'.freeze
5
5
 
6
6
  def investigate(processed_source)
7
7
  file_path = processed_source.buffer.name
8
- return unless File.extname(file_path) == '.erb'
8
+ return unless File.extname(file_path) == '.haml'
9
9
 
10
10
  range = processed_source.buffer.source_range
11
11
  add_offense(nil, location: range, message: MSG)
@@ -4,20 +4,15 @@ module GLRubocop
4
4
  # This cop ensures that view components include a data-test-id attribute.
5
5
  #
6
6
  # Good:
7
- # {data-test-id: 'unique-id'}
8
- # {data-test-id: @unique_id }
9
- # {'data-test-id': 'unique-id'}
10
- # {"data-test-id": "unique-id"}
11
- # {data: {test-id: 'unique-id'}}
12
- # {data: {'test-id': 'unique-id'}}
7
+ # data-test-id="unique-id"
13
8
  #
14
9
  # Bad:
15
- # {data: {testId: "unique-id"}}
16
- # {data: {test: {id: "unique-id"}}
17
-
10
+ # data-testid="unique-id"
11
+ # data-testId="unique-id"
12
+ # data-test_id="unique-id"
18
13
  MSG = 'View components must include a data-test-id attribute'.freeze
19
14
  EMPTY_MSG = 'data-test-id attribute must not be empty'.freeze
20
- UNIQUE_IDENTIFIER = 'test-id'.freeze
15
+ UNIQUE_IDENTIFIER = 'data-test-id='.freeze
21
16
 
22
17
  def on_send(node)
23
18
  return unless file_exists? && valid_method_name?(node)
@@ -42,18 +37,12 @@ module GLRubocop
42
37
  @raw_content ||= File.read(processed_source.file_path)
43
38
  end
44
39
 
45
- def regex_for_indentifier_and_value
46
- key = Regexp.quote(UNIQUE_IDENTIFIER)
47
- /(?:["']?data-#{key}["']?|data:.?\{["']?#{key}["']?):\s*(["']([^"']*)["']|@\w+)/
48
- end
49
-
50
40
  def test_id_value
51
- match = identifiable_line.match(regex_for_indentifier_and_value)
41
+ str_match = identifiable_line[/data-test-id=('|")[^'|"]*/]
52
42
 
53
- return '' unless match
43
+ return '' unless str_match
54
44
 
55
- value = match[1]
56
- value.start_with?('"', "'") ? value[1..-2] : value
45
+ str_match.gsub(/data-test-id=./, '')
57
46
  end
58
47
 
59
48
  def valid_method_name?(node)
@@ -1,3 +1,3 @@
1
1
  module GLRubocop
2
- VERSION = '0.2.20'.freeze
2
+ VERSION = '0.3.1'.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.2.20
4
+ version: 0.3.1
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-10-31 00:00:00.000000000 Z
11
+ date: 2025-11-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubocop
@@ -24,20 +24,34 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: 1.62.1
27
+ - !ruby/object:Gem::Dependency
28
+ name: rubocop-erb
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: rubocop-haml
29
43
  requirement: !ruby/object:Gem::Requirement
30
44
  requirements:
31
- - - "~>"
45
+ - - ">="
32
46
  - !ruby/object:Gem::Version
33
- version: 0.2.4
47
+ version: '0'
34
48
  type: :runtime
35
49
  prerelease: false
36
50
  version_requirements: !ruby/object:Gem::Requirement
37
51
  requirements:
38
- - - "~>"
52
+ - - ">="
39
53
  - !ruby/object:Gem::Version
40
- version: 0.2.4
54
+ version: '0'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: rubocop-i18n
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -152,7 +166,7 @@ files:
152
166
  - lib/gl_rubocop/gl_cops/interactor_inherits_from_interactor_base.rb
153
167
  - lib/gl_rubocop/gl_cops/limit_flash_options.rb
154
168
  - lib/gl_rubocop/gl_cops/no_stubbing_perform_async.rb
155
- - lib/gl_rubocop/gl_cops/prevent_erb_files.rb
169
+ - lib/gl_rubocop/gl_cops/prevent_haml_files.rb
156
170
  - lib/gl_rubocop/gl_cops/rails_cache.rb
157
171
  - lib/gl_rubocop/gl_cops/sidekiq_inherits_from_sidekiq_job.rb
158
172
  - lib/gl_rubocop/gl_cops/tailwind_no_contradicting_class_name.rb
@@ -180,7 +194,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
180
194
  - !ruby/object:Gem::Version
181
195
  version: '0'
182
196
  requirements: []
183
- rubygems_version: 3.3.7
197
+ rubygems_version: 3.4.19
184
198
  signing_key:
185
199
  specification_version: 4
186
200
  summary: A shareable configuration of Give Lively's rubocop rules.