-
-
Notifications
You must be signed in to change notification settings - Fork 929
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
Add font-family-no-missing-generic #2929
Comments
This addresses issue stylelint#2929 ran $ npm test lib/rules/font-family-generic-fallback/__tests__/ Not sure how to improve the coverage of the tests. Results: Test Suites: 1 passed, 1 total Tests: 22 passed, 22 total Snapshots: 0 total Time: 2.609s Ran all test suites matching /lib\/rules\/font-family-generic-fallback\/__tests__\//i. =============================== Coverage summary =============================== Statements : 36.9% ( 2955/8008 ) Branches : 4.85% ( 184/3794 ) Functions : 5.15% ( 72/1398 ) Lines : 37.12% ( 2950/7947 ) ================================================================================ Jest: Coverage for statements (36.9%) does not meet global threshold (75%) Jest: Coverage for branches (4.85%) does not meet global threshold (75%) Jest: Coverage for lines (37.12%) does not meet global threshold (75%) Jest: Coverage for functions (5.15%) does not meet global threshold (75%) npm ERR! Test failed. See above for more details.
I like the idea, personally. I think it's also consistent with the goals of stylelint. |
Forgot to mention http://www.phpied.com/psa-always-add-a-generic-font-family-backup/ has some recent examples (e.g. Bing search) where not following the rule acts up. |
Agreed. I think it's an ideal candidate for a built-in rule.
To adhere to the naming conventions I think it should be called something like
|
Any objections to the rule name? If not, I'll add some additional feedback to the wip PR. |
hm, turns out there's a legitimate use of other fonts after a generic. before:AfterThe Emoji font takes precedence over the generic, probably because of the unicode range in the font. Actually you can test right here because github currently does this. Inspect this and delete all fonts preceding sans-serif: ♥ I wonder if we should keep the rule and let people opt out which is probably pretty rare. |
Interesting. I had no idea this was a thing.
All of the built-in rules are opt-in. I agree that whether it's included in the Two other approaches could be:
There's nothing in the spec stating a generic family must come last, only this:
So, it's not clear-cut which, if either, approach is best. What do you think? |
I think the first approach (check anywhere in the list) is the right one ... as a user nothing about |
Example 3Terminal generic (haha!) to me reads better and works the same (in this case). It's not like all the characters became emojis all of a sudden. Looks like it's all about the Unicode range defined in the font. But since, philosophically, Stylelint is unopinionated, if the spec is lax and the browsers are tolerant, the rule shouldn't enforce a preference. If you have competing fonts that both share a Unicode range, and yet differ (picture a Venn diagram) and you want to play with which one takes precedence over the shared part, you should certainly be free to do so. I'd vote #2. It's the same as #1 plus an opportunity to be more strict, if desired. Since the more relaxed check is the default, it cannot hurt, right? |
Until I came here and read the rule description it wasn’t clear to me the purpose of this rule based on its current |
Interesting stuff.
This makes sense to me.
Umm... any suggestions to what can be done about this? Would an extra |
How about |
It's equally verbose as However, we've consistently used the actual spec terminology elsewhere in stylelint and so I'm rather stick with
We could expand it to |
❤️ A little on the verbose side but clear and correct. And self-documenting. |
SGTM. Let's go with that. |
Done in #2930 |
This is a proposal for a new rule that always requires a generic font-family at the end of font-family list. Helps reduce various visual bugs when there's:
pull request coming in a minute
New rule called
font-family-generic-fallback
e.g.
fresh github branch
Clone the repo,
npm test
No non-standard CSS
Warnings to be flagged when using the new rule
Nothing yet.
The text was updated successfully, but these errors were encountered: