lib/scss_lint/linter/bang_format.rb in scss-lint-0.31.0 vs lib/scss_lint/linter/bang_format.rb in scss-lint-0.32.0
- old
+ new
@@ -1,10 +1,12 @@
module SCSSLint
# Checks spacing of ! declarations, like !important and !default
class Linter::BangFormat < Linter
include LinterRegistry
+ STOPPING_CHARACTERS = ['!', "'", '"', nil]
+
def visit_prop(node)
return unless node.to_sass.include?('!')
return unless check_spacing(node)
before_qualifier = config['space_before_bang'] ? '' : 'not '
@@ -19,12 +21,11 @@
# Start from the back and move towards the front so that any !important or
# !default !'s will be found *before* quotation marks. Then we can
# stop at quotation marks to protect against linting !'s within strings
# (e.g. `content`)
def find_bang_offset(range)
- stopping_characters = ['!', '\'', '"']
offset = 0
- offset -= 1 until stopping_characters.include?(character_at(range.end_pos, offset))
+ offset -= 1 until STOPPING_CHARACTERS.include?(character_at(range.end_pos, offset))
offset
end
def is_before_wrong?(range, offset)
before_expected = config['space_before_bang'] ? / / : /[^ ]/