css/require-font-display
Require font-display in @font-face rules.
| Default severity | Presets | Automatic fix | Options |
|---|---|---|---|
warning |
opinionated, nuxt |
No | None |
Applies to: CSS, SCSS, Sass, Less and Stylus style blocks, as written (not preprocessed). Within one Stylus block, use either braced or indented syntax consistently; mixed syntax is read as braced Stylus.
Bad
The font-face declaration defines the font source but omits its font-display policy.
<style>
@font-face {
font-family: "Inter";
src: url("/inter.woff2") format("woff2");
}
</style>
Good
font-display: swap explicitly selects the fallback-to-font display policy.
<style>
@font-face {
font-family: "Inter";
src: url("/inter.woff2") format("woff2");
font-display: swap;
}
</style>
Configuration (Vite+)
import { defineConfig } from "@vizejs/vite-plugin/vite-plus";
export default defineConfig({}).withVue({
linter: {
"preset": "incremental",
"rules": {
"css/require-font-display": "warn"
}
},
});
Then run vp run lint.