Skip to content

Commit

Permalink
Ignore maps and lists in color-named
Browse files Browse the repository at this point in the history
  • Loading branch information
mmase committed Dec 15, 2016
1 parent 13b99a6 commit 0375fb0
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
15 changes: 15 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, blue: #00f);",
description: "ignore non-standard list and map syntax",
} ],

reject: [ {
Expand Down Expand Up @@ -93,6 +96,11 @@ testRule(rule, {
message: messages.rejected("white"),
line: 1,
column: 24,
}, {
code: "a { background: color(green); }",
message: messages.rejected("green"),
line: 1,
column: 23,
} ],
})

Expand Down Expand Up @@ -255,6 +263,11 @@ testRule(rule, {
message: messages.expected("black", "rgb(0,0,0)"),
line: 1,
column: 23,
}, {
code: "a { color: color(#000 a(50%)) }",
message: messages.expected("black", "#000"),
line: 1,
column: 12,
} ],
})

Expand Down Expand Up @@ -300,6 +313,8 @@ testRule(rule, {
code: "a { color: map-get($colour, blue(60%)); }",
}, {
code: "a { color: map-get($colour, blue); }",
}, {
code: "a { background: color(blue); }",
} ],

reject: [ {
Expand Down
5 changes: 5 additions & 0 deletions lib/rules/color-named/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

const _ = require("lodash")
const declarationValueIndex = require("../../utils/declarationValueIndex")
const isStandardSyntaxFunction = require("../../utils/isStandardSyntaxFunction")
const isStandardSyntaxValue = require("../../utils/isStandardSyntaxValue")
const keywordSets = require("../../reference/keywordSets")
const namedColorData = require("../../reference/namedColorData")
Expand Down Expand Up @@ -70,6 +71,10 @@ const rule = function (expectation, options) {
return false
}

if (!isStandardSyntaxFunction(node)) {
return false
}

if (!isStandardSyntaxValue(value)) {
return
}
Expand Down

0 comments on commit 0375fb0

Please sign in to comment.