Sha256: ea6fd22767d208b97778313e8c85d723c628f3468f194c9cf5a9c79963178e4a

Contents?: true

Size: 773 Bytes

Versions: 2

Compression:

Stored size: 773 Bytes

Contents

# frozen_string_literal: true

require "rubocop"
require "yattho/view_components/statuses"
require_relative "../../../../app/lib/yattho/view_helper"

module RuboCop
  module Cop
    module Yattho
      # :nodoc:
      class BaseCop < RuboCop::Cop::Cop
        # We only verify SystemArguments if it's a `.new` call on a component or
        # a ViewHeleper call.
        def valid_node?(node)
          return if node.nil?

          view_helpers.include?(node.method_name) || (node.method_name == :new && !node.receiver.nil? && ::Yattho::ViewComponents::STATUSES.key?(node.receiver.const_name))
        end

        private

        def view_helpers
          ::Yattho::ViewHelper::HELPERS.keys.map { |key| "yattho_#{key}".to_sym }
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
yattho_view_components-0.1.1 lib/rubocop/cop/yattho/base_cop.rb
yattho_view_components-0.0.1 lib/rubocop/cop/yattho/base_cop.rb