Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix false positives for system fonts in font-family-no-missing-generic-family-keyword #3794

Merged
merged 1 commit into from
Nov 12, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 9 additions & 0 deletions lib/reference/keywordSets.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,15 @@ keywordSets.camelCaseFunctionNames = new Set([

keywordSets.basicKeywords = new Set(["initial", "inherit", "unset"]);

keywordSets.systemFontValues = uniteSets(keywordSets.basicKeywords, [
"caption",
"icon",
"menu",
"message-box",
"small-caption",
"status-bar"
]);

keywordSets.fontFamilyKeywords = uniteSets(keywordSets.basicKeywords, [
"serif",
"sans-serif",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,13 @@ a { font-family: Helvetica, Arial, Verdana, Tahoma, sans-serif; }
a { font: 1em/1.3 Times, serif; }
```

It's also *not* a violation to use a keyword related to property inheritance.
It's also *not* a violation to use a keyword related to property inheritance or a system font value.

```css
a { font: inherit; }
b { font: initial; }
i { font: unset; }
input { font: caption; }
```

It's also *not* a violation to use a generic font family anywhere in the list. In other words, the generic font name doesn't need to be the last.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,27 @@ testRule(rule, {
},
{
code: "@FONT-FACE { font-family: Gentium; }"
},
{
code: "a { font: inherit; }"
},
{
code: "a { font: caption; }"
},
{
code: "a { font: icon; }"
},
{
code: "a { font: menu; }"
},
{
code: "a { font: message-box; }"
},
{
code: "a { font: small-caption; }"
},
{
code: "a { font: status-bar; }"
}
],

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@ const rule = function(actual) {
return;
}

if (
decl.prop === "font" &&
keywordSets.systemFontValues.has(decl.value.toLowerCase())
) {
return;
}

const fontFamilies = findFontFamily(decl.value);

if (fontFamilies.length === 0) {
Expand Down