Skip to content

Commit

Permalink
Ignore function nodes in color-named
Browse files Browse the repository at this point in the history
  • Loading branch information
mmase committed Dec 12, 2016
1 parent bf60e46 commit a676271
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/rules/color-named/__tests__/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ testRule(rule, {
}, {
code: "a { font: 10px/14px Brown, sans-serif; }",
description: "ignore font family names that are colors",
}, {
code: "colors: (white: #fff);",
description: "ignore color names in non-standard syntax",
} ],

reject: [ {
Expand Down
12 changes: 12 additions & 0 deletions lib/rules/color-named/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,23 @@ const rule = function (expectation, options) {
return
}

const functionNodes = []

valueParser(decl.value).walk(node => {
const value = node.value,
type = node.type,
sourceIndex = node.sourceIndex

if (type === "function") {
node.nodes.forEach((node) => {
functionNodes.push(node.sourceIndex)
})
}

if (functionNodes.indexOf(sourceIndex) > -1) {
return
}

if (
optionsMatches(options, "ignore", "inside-function")
&& type === "function"
Expand Down

0 comments on commit a676271

Please sign in to comment.