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 interpolation and shorthand in font-family-name-quotes #6335

Merged
merged 4 commits into from Sep 11, 2022
Merged
Show file tree
Hide file tree
Changes from 3 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
31 changes: 31 additions & 0 deletions lib/rules/font-family-name-quotes/__tests__/index.js
Expand Up @@ -25,6 +25,13 @@ const variablePositiveTests = [
},
];

const scssPositiveTests = [
{
code: 'a { font: #{customFunc($some-length)} "Times", "Arial"; }',
description: 'ignores Sass function with interpolation',
},
];

testRule({
ruleName,
config: ['always-unless-keyword'],
Expand Down Expand Up @@ -203,6 +210,14 @@ testRule({
],
});

testRule({
ruleName,
customSyntax: 'postcss-scss',
config: ['always-unless-keyword'],

accept: [...scssPositiveTests],
});

testRule({
ruleName,
config: ['always-where-recommended'],
Expand Down Expand Up @@ -378,6 +393,14 @@ testRule({
],
});

testRule({
ruleName,
customSyntax: 'postcss-scss',
config: ['always-where-recommended'],

accept: [...scssPositiveTests],
});

testRule({
ruleName,
config: ['always-where-required'],
Expand Down Expand Up @@ -503,6 +526,14 @@ testRule({
],
});

testRule({
ruleName,
customSyntax: 'postcss-scss',
config: ['always-where-required'],

accept: [...scssPositiveTests],
});

testRule({
ruleName,
config: ['always-unless-keyword'],
Expand Down
8 changes: 4 additions & 4 deletions lib/rules/font-family-name-quotes/index.js
Expand Up @@ -141,6 +141,10 @@ const rule = (primary, _secondary, context) => {
}

root.walkDecls(/^font(-family)?$/i, (decl) => {
if (!isStandardSyntaxValue(decl.value)) {
return;
}

let fontFamilyNodes = makeMutableFontFamilies(findFontFamily(decl.value), decl);

if (fontFamilyNodes.length === 0) {
Expand All @@ -159,10 +163,6 @@ const rule = (primary, _secondary, context) => {
function checkFamilyName(fontFamilyNode, decl) {
const { name: family, rawName: rawFamily, hasQuotes } = fontFamilyNode;

if (!isStandardSyntaxValue(rawFamily)) {
return;
}

if (isVariable(rawFamily)) {
return;
}
Expand Down