From 0a9f0245294eb94c00a4d963c871d06b32b9be0f Mon Sep 17 00:00:00 2001 From: Sam Rawlins Date: Sun, 27 Sep 2015 17:23:51 -0700 Subject: [PATCH] Don't lint HexValidation on mid-word hex strings --- lib/scss_lint/linter/hex_validation.rb | 2 +- spec/scss_lint/linter/hex_validation_spec.rb | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/scss_lint/linter/hex_validation.rb b/lib/scss_lint/linter/hex_validation.rb index 58843781..65929ad4 100644 --- a/lib/scss_lint/linter/hex_validation.rb +++ b/lib/scss_lint/linter/hex_validation.rb @@ -6,7 +6,7 @@ class Linter::HexValidation < Linter def visit_script_string(node) return unless node.type == :identifier - node.value.scan(/(#\h+)/) do |match| + node.value.scan(/(?:\W|^)(#\h+)(?:\W|$)/) do |match| check_hex(match.first, node) end end diff --git a/spec/scss_lint/linter/hex_validation_spec.rb b/spec/scss_lint/linter/hex_validation_spec.rb index bc8a36cc..8fe88579 100644 --- a/spec/scss_lint/linter/hex_validation_spec.rb +++ b/spec/scss_lint/linter/hex_validation_spec.rb @@ -37,4 +37,15 @@ it { should report_lint line: 2 } it { should report_lint line: 3 } end + + context 'when rule contains hex codes in a longer string' do + let(:scss) { <<-SCSS } + p { + content: 'foo#bad'; + content: 'foo #ba'; + } + SCSS + + it { should report_lint line: 3 } + end end