Vize

css/require-font-display

Exiger font-display dans les règles @font-face.

Gravité par défaut Préréglages Correction automatique Options
warning opinionated, nuxt Non Aucune

Champ d’application : Blocs style CSS, SCSS, Sass, Less et Stylus, tels qu’écrits (sans préprocesseur). Dans un même bloc Stylus, utilisez soit la syntaxe à accolades, soit la syntaxe indentée ; une syntaxe mixte est lue comme du Stylus à accolades.

Mauvais

La déclaration font-face définit la source de la police, mais omet sa politique font-display.

<style>
@font-face {
  font-family: "Inter";
  src: url("/inter.woff2") format("woff2");
}
</style>

Bon

font-display: swap sélectionne explicitement la politique d’affichage passant d’une police de repli à la police chargée.

<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"
    }
  },
});

Lancez ensuite vp run lint.

Voir aussi