Skip to content

Commit

Permalink
Fix false positives for hashes in URLs in color-no-invalid-hex (#4035)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeddy3 committed Apr 16, 2019
1 parent 108edd2 commit 3bf38ca
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
12 changes: 12 additions & 0 deletions lib/rules/color-no-invalid-hex/__tests__/index.js
Expand Up @@ -39,6 +39,18 @@ testRule(rule, {
code: "a { box-sizing: #$type-box; }",
description: "ignore sass-like interpolation"
},
{
code: "a { background-image: svg-load('x.svg', fill=url(#a)); }",
description: "svg-load url with fill"
},
{
code: "a { background-image: url(#a); }",
description: "url standalone hash"
},
{
code: "a { background-image: url(x.svg#a); }",
description: "url with hash"
},
{
code:
"@font-face {\n" +
Expand Down
2 changes: 2 additions & 0 deletions lib/rules/color-no-invalid-hex/index.js
Expand Up @@ -23,6 +23,8 @@ const rule = function(actual) {

root.walkDecls(decl => {
valueParser(decl.value).walk(({ value, type, sourceIndex }) => {
if (type === "function" && value.endsWith("url")) return false;

if (type !== "word") return;

const hexMatch = /^#[0-9A-Za-z]+/.exec(value);
Expand Down

0 comments on commit 3bf38ca

Please sign in to comment.