Sha256: c5202dd304dc5bc4c919481ae10735b50273d1c416c4bb2b5ef4a8b6d4c45e49
Contents?: true
Size: 1.23 KB
Versions: 1
Compression:
Stored size: 1.23 KB
Contents
module SCSSLint # Checks spacing of ! declarations, like !important and !default class Linter::BangFormat < Linter include LinterRegistry def visit_prop(node) return unless node.to_sass.include?('!') return unless check_spacing(node) before_qualifier = config['space_before_bang'] ? '' : 'not ' after_qualifier = config['space_after_bang'] ? '' : 'not ' add_lint(node, "! should #{before_qualifier}be preceeded by a space, " \ "and should #{after_qualifier}be followed by a space") end private def find_bang_offset(range) offset = 0 offset += 1 while character_at(range.start_pos, offset) != '!' offset end def check_spacing(node) range = node.value_source_range offset = find_bang_offset(range) before_expected = config['space_before_bang'] ? / / : /[^ ]/ before_actual = character_at(range.start_pos, offset - 1) before_is_wrong = (before_actual =~ before_expected).nil? after_expected = config['space_after_bang'] ? / / : /[^ ]/ after_actual = character_at(range.start_pos, offset + 1) after_is_wrong = (after_actual =~ after_expected).nil? before_is_wrong || after_is_wrong end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
scss-lint-0.30.0 | lib/scss_lint/linter/bang_format.rb |