Class: GLRubocop::GLCops::UniqueIdentifier
- Inherits:
-
RuboCop::Cop::Base
- Object
- RuboCop::Cop::Base
- GLRubocop::GLCops::UniqueIdentifier
- Defined in:
- lib/gl_rubocop/gl_cops/unique_identifier.rb
Constant Summary collapse
- MSG =
This cop ensures that view components include a data-test-id attribute.
Good:
data-test-id="unique-id"Bad:
data-testid="unique-id" data-testId="unique-id" data-test_id="unique-id" 'View components must include a data-test-id attribute'.freeze
- EMPTY_MSG =
'data-test-id attribute must not be empty'.freeze
- UNIQUE_IDENTIFIER =
'data-test-id='.freeze
Instance Method Summary collapse
Instance Method Details
#on_send(node) ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/gl_rubocop/gl_cops/unique_identifier.rb', line 17 def on_send(node) return unless file_exists? && valid_file_name? && valid_method_name?(node) return add_offense(node) unless raw_content.include?(UNIQUE_IDENTIFIER) add_offense(node, message: EMPTY_MSG) if test_id_value.strip.empty? end |