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 +4 -4
- data/default.yml +4 -0
- data/lib/gl_rubocop/gl_cops/unique_identifier.rb +13 -20
- data/lib/gl_rubocop/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c142a90b62896eea7a2ef83f59c565463529eb5eec02d5f7e3d1f5c892f7ae4e
|
|
4
|
+
data.tar.gz: 2539a4287220284a0b69200f3a86b42d213bec3f8950667560f34fe37ca7a389
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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
|
-
#
|
|
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
|
-
#
|
|
16
|
-
#
|
|
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
|
-
|
|
45
|
+
str_match = identifiable_line[/data-test-id=('|")[^'|"]*/]
|
|
52
46
|
|
|
53
|
-
return '' unless
|
|
47
|
+
return '' unless str_match
|
|
54
48
|
|
|
55
|
-
|
|
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)
|
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.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-
|
|
11
|
+
date: 2025-11-05 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rubocop
|