Skip to content

fix: allow CSS-wide keywords in font-family-fallbacks#391

Open
sethamus wants to merge 2 commits intoeslint:mainfrom
sethamus:font-family-fallbacks-css-wide-keywords
Open

fix: allow CSS-wide keywords in font-family-fallbacks#391
sethamus wants to merge 2 commits intoeslint:mainfrom
sethamus:font-family-fallbacks-css-wide-keywords

Conversation

@sethamus
Copy link
Contributor

@sethamus sethamus commented Mar 4, 2026

Prerequisites checklist

AI acknowledgment

  • I did not use AI to generate this PR.
  • (If the above is not checked) I have reviewed the AI-generated content before submitting.

What is the purpose of this pull request?

This PR fixes false positives in css/font-family-fallbacks by allowing CSS-wide keywords (e.g. inherit, initial, unset, revert, revert-layer) for font-family/font, since they shouldn’t be required to include fallback/generic fonts.

What changes did you make? (Give an overview)

  • Updated the rule to treat CSS-wide keywords as always valid (including when they come from var() values).
  • Added tests covering font-family and shorthand font CSS-wide keyword cases.
  • Updated the rule docs to mention CSS-wide keywords are allowed.

Related Issues

Fixes #387

Is there anything you'd like reviewers to focus on?

@github-project-automation github-project-automation bot moved this to Needs Triage in Triage Mar 4, 2026
@eslint-github-bot eslint-github-bot bot added the bug Something isn't working label Mar 4, 2026
Copy link
Contributor

@Tanujkanti4441 Tanujkanti4441 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR, looks good, just a suggestion regarding docs.

@Tanujkanti4441 Tanujkanti4441 moved this from Needs Triage to Implementing in Triage Mar 4, 2026
@Tanujkanti4441 Tanujkanti4441 added the accepted There is consensus among the team that this change meets the criteria for inclusion label Mar 4, 2026
"fangsong",
]);

const cssWideKeywords = new Set([
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we use sourceCode.lexer.cssWideKeywordsSyntax.map instead of this set?
This would allow users to fork the syntax and add css-wide keyword.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What’s the motivating use case for extending cssWideKeywords?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is a good idea for maintenance purposes. It gives us one less spot to update should things change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

accepted There is consensus among the team that this change meets the criteria for inclusion bug Something isn't working

Projects

Status: Implementing

Development

Successfully merging this pull request may close these issues.

Bug: font-family-fallbacks reports an error for font-family: inherit

4 participants