css/require-font-display
Require font-display in @font-face rules
Default severity: warning
Presets: opinionated, nuxt
Automatic fix: None; review the suggested change
Applies to: CSS inside SFC style blocks
Options: No rule-specific options. Severity and preset selection are configurable.
Configuration (Vite+)
import { defineConfig } from "@vizejs/vite-plugin/vite-plus";
export default defineConfig({
lint: {
vize: {
"preset": "incremental",
"rules": {
"css/require-font-display": "warn"
}
},
},
});
vp run lint
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>
Good avoids this rule's finding under the configuration above; other rules may still report diagnostics.