lib/scss_lint/linter.rb in scss-lint-0.30.0 vs lib/scss_lint/linter.rb in scss-lint-0.31.0
- old
+ new
@@ -15,11 +15,13 @@
# @param engine [Engine]
# @param config [Config]
def run(engine, config)
@config = config
@engine = engine
+ @comment_processor = ControlCommentProcessor.new(self)
visit(engine.tree)
+ @lints = @comment_processor.filter_lints(@lints)
end
# Return the human-friendly name of this linter as specified in the
# configuration file and in lint descriptions.
def name
@@ -42,11 +44,11 @@
# Extract {SCSSLint::Location} from a {Sass::Source::Range}.
#
# @param range [Sass::Source::Range]
# @return [SCSSLint::Location]
- def location_from_range(range)
+ def location_from_range(range) # rubocop:disable Metrics/AbcSize
length = if range.start_pos.line == range.end_pos.line
range.end_pos.offset - range.start_pos.offset
else
line_source = engine.lines[range.start_pos.line - 1]
line_source.length - range.start_pos.offset + 1
@@ -67,11 +69,11 @@
# Extracts the original source code given a range.
#
# @param source_range [Sass::Source::Range]
# @return [String] the original source code
- def source_from_range(source_range)
+ def source_from_range(source_range) # rubocop:disable Metrics/AbcSize
current_line = source_range.start_pos.line - 1
last_line = source_range.end_pos.line - 1
start_pos = source_range.start_pos.offset - 1
if current_line == last_line
@@ -119,10 +121,12 @@
# Visit the selector of a rule if parsed rules are available
if node.is_a?(Sass::Tree::RuleNode) && node.parsed_rules
visit_selector(node.parsed_rules)
end
+ @comment_processor.before_node_visit(node)
super
+ @comment_processor.after_node_visit(node)
end
# Redefine so we can set the `node_parent` of each node
#
# @param parent [Sass::Tree::Node, Sass::Script::Tree::Node,