class HamlLint::CommentConfiguration

Determines what linters are enabled or disabled via comments.

Attributes

directives[R]

The list of directives in order of precedence.

@api private @return [Array<HamlLint::Directive>]

Public Class Methods

new(node) click to toggle source

Instantiates a new {HamlLint::CommentConfiguration}.

@param node [HamlLint::Tree::Node] the node to configure

# File lib/haml_lint/comment_configuration.rb, line 8
def initialize(node)
  @directives = node.directives.reverse
end

Public Instance Methods

disabled?(linter_name) click to toggle source

Checks whether a linter is disabled for the node.

@api public @param linter_name [String] the name of the linter @return [true, false]

# File lib/haml_lint/comment_configuration.rb, line 17
def disabled?(linter_name)
  most_recent_disabled = directives_for(linter_name).map(&:disable?).first

  most_recent_disabled || false
end

Private Instance Methods

directives_for(linter_name) click to toggle source

Finds all directives applicable to the given linter name.

@api private @param linter_name [String] the name of the linter @return [Array<HamlLint::Directive>] the filtered directives

# File lib/haml_lint/comment_configuration.rb, line 36
def directives_for(linter_name)
  directives.select { |directive| (directive.linters & ['all', linter_name]).any? }
end