gl_rubocop 0.3.0 → 0.3.2

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: cfa3a041b813576c82945878a3a5b712cddc171ee7e490a562c8186c8a078122
4
- data.tar.gz: 59c4a3a19c71605f920bb21ca0b76ef965385e94836d8965b9735164cf227b7c
3
+ metadata.gz: c142a90b62896eea7a2ef83f59c565463529eb5eec02d5f7e3d1f5c892f7ae4e
4
+ data.tar.gz: 2539a4287220284a0b69200f3a86b42d213bec3f8950667560f34fe37ca7a389
5
5
  SHA512:
6
- metadata.gz: 240a0d83e8b317ef314783c0ff96c3f56cc1af17f144dda86d9048d791ecadb41d3408776831a5130ea8396467def9d65d524c778846539f32828565a742d2cc
7
- data.tar.gz: d4870f2db16c75c7843df195c9a4f0a3b96e412ffedd20489368e7ad634a46933253ee56bd0f61f649edd35465b997d561d2f20618e8b1bcabae2977e7a1bcfe
6
+ metadata.gz: 3d7b1e1bbea93e8fb6427c79d16636f6a58ba376ee233189bdd18351cc6597f3b71338163e5d23477c2566c3ac3c91f7086cf5db819c6f6de9f429261f2bd8d0
7
+ data.tar.gz: a2739ce3a9419792deb3e42362e8f8ae454b7551c64695ac92e6859075db7927a9fc83409c5f854d079d966e829d2fed3bea87ac18adb29a29bed55c9e8841d0
data/default.yml CHANGED
@@ -66,6 +66,10 @@ GLCops/SidekiqInheritsFromSidekiqJob:
66
66
  - "app/**/*_worker.rb"
67
67
  - "app/**/*_job.rb"
68
68
 
69
+ GLCops/TailwindNoContradictingClassName:
70
+ # Disabling the tailwind no contradicting class name for some fixes
71
+ Enabled: false
72
+
69
73
  GLCops/UniqueIdentifier:
70
74
  Enabled: true
71
75
  Include:
@@ -4,23 +4,18 @@ 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
- return unless file_exists? && valid_method_name?(node)
18
+ return unless file_exists? && valid_file_name? && valid_method_name?(node)
24
19
 
25
20
  return add_offense(node) unless raw_content.include?(UNIQUE_IDENTIFIER)
26
21
 
@@ -33,6 +28,10 @@ module GLRubocop
33
28
  File.exist?(processed_source.file_path)
34
29
  end
35
30
 
31
+ def valid_file_name?
32
+ File.basename(processed_source.file_path) == 'component.html.erb'
33
+ end
34
+
36
35
  def identifiable_line
37
36
  line_number = raw_content.lines.find_index { |line| line.include?(UNIQUE_IDENTIFIER) }
38
37
  raw_content.lines[line_number]
@@ -42,18 +41,12 @@ module GLRubocop
42
41
  @raw_content ||= File.read(processed_source.file_path)
43
42
  end
44
43
 
45
- def regex_for_indentifier_and_value
46
- key = Regexp.quote(UNIQUE_IDENTIFIER)
47
- /(?:["']?data-#{key}["']?|data:.?\{["']?#{key}["']?):\s*(["']([^"']*)["']|@\w+)/
48
- end
49
-
50
44
  def test_id_value
51
- match = identifiable_line.match(regex_for_indentifier_and_value)
45
+ str_match = identifiable_line[/data-test-id=('|")[^'|"]*/]
52
46
 
53
- return '' unless match
47
+ return '' unless str_match
54
48
 
55
- value = match[1]
56
- value.start_with?('"', "'") ? value[1..-2] : value
49
+ str_match.gsub(/data-test-id=./, '')
57
50
  end
58
51
 
59
52
  def valid_method_name?(node)
@@ -1,3 +1,3 @@
1
1
  module GLRubocop
2
- VERSION = '0.3.0'.freeze
2
+ VERSION = '0.3.2'.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.0
4
+ version: 0.3.2
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-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubocop