Repository navigation
[ADD] checks_odoo_module_scss: new scss-font-display-missing and scss-css-import checks - #207
Merged
Merged
Conversation
moylop260
force-pushed
the
scss-css-import-moy
branch
3 times, most recently
from
November 30, 2026 18:22
1a1e135 to
0b86ec8
Compare
moylop260
force-pushed
the
scss-css-import-moy
branch
from
November 30, 2026 19:01
0b86ec8 to
558080a
Compare
…th autofix A @font-face without font-display makes the browser use auto, which in practice is block: the text that uses the font stays invisible while the font downloads (the flash of invisible text), and that delays the First and Largest Contentful Paint (GTmetrix: Ensure text remains visible during webfont load). The check reports it and recommends swap, optional for a decorative font and block for an icon font. The autofix adds font-display: swap as the last declaration, with the indentation of the first line of the previous declaration, the missing semicolon when needed, the line ending of the file and the trailing comment of its line, and it leaves the icon fonts alone because they need block. The stylesheets of the PDF report bundles are skipped, wkhtmltopdf does not paint the text progressively.
An @import url(...) of a stylesheet, or any @import inside a .css file, is left to the browser, which only discovers the imported file after it has downloaded and parsed the one that imports it: the two downloads are chained and the page cannot paint before both end (GTmetrix: Avoid CSS @import and Avoid chaining critical requests). When it is another site, as fonts.googleapis.com, it also costs a connection and shows every visitor to a third party. A quoted @import of a .css file or of an address, in a .scss file, never reaches the browser: Odoo removes the quoted imports whose path has a dot or starts with ., / or ~ and reports Local import is forbidden among the errors of the bundle. The check says which of the two cases it is and points to the assets of the manifest or to a self-hosted .woff2 with an @font-face. Every item of a comma list is checked and a semicolon inside the url() does not cut the reported text.
moylop260
force-pushed
the
scss-css-import-moy
branch
from
November 30, 2026 19:19
558080a to
b5f9d0a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds two checks for stylesheets, in two commits of one PR because the second one builds on the first (both extend the scss checker of #205 and its README and test counters):
scss-font-display-missing: a@font-facewithoutfont-display, with autofix.scss-css-import: an@importthat the browser has to resolve.This replaces #206 (the first commit), which is closed.
scss-font-display-missingWithout
font-displaythe browser usesauto, which in practice isblock: the text that uses the font stays invisible while the font downloads, for a short block period (about 3 s in the browsers that implement it), before the browser falls back (the "flash of invisible text"). That delays the First and Largest Contentful Paint of every page that has text in that font. GTmetrix and Lighthouse report it as "Ensure text remains visible during webfont load".swapoptionalfallbackblockauto)The autofix adds
font-display: swap;as the last declaration of the@font-face, with the indentation of the first line of the previous declaration (a multi-linesrcdoes not shift it), the missing;of the last one when needed, the line ending of the file (CRLF stays CRLF) and the trailing comment on the same line. It leaves icon fonts alone (afont-familywithicon,awesomeorglyph), because they needblock; the message still reports them. The stylesheets of the PDF report bundles (report_assets_*) are not reported: wkhtmltopdf does not paint the text progressively, sofont-displayhas no effect there (see #205 for how the bundle is read).scss-css-importIt reports an
@importof a stylesheet that is not part of the bundle:@import url(...), an@importof anhttp(s)://or//address, or of a.cssfile. Any other@importis a Sass partial that the compiler inlines, so@import "variables";is not reported. Every item of a comma list is checked, and a;inside theurl()(Google Fontscss2) does not cut the reported text.There are two cases, and the message says which one it is:
@import url(...), or any@importinside a.cssfile: resolved by the browser. Odoo keeps it and moves it to the top of the bundle. The browser only discovers the imported file after it has downloaded and parsed the one that imports it, so the two downloads are chained and the page cannot paint before both end (GTmetrix: "Avoid CSS @import" and "Avoid chaining critical requests"). When it is another site, asfonts.googleapis.com, it also costs a new connection (DNS, TCP and TLS), the stylesheet has a short cache lifetime that the project does not control, and every visitor is revealed to a third party.@import "..."of a.cssfile or of an address, in a.scssfile: dropped by Odoo.compile_cssremoves the quoted imports whose path has a dot or starts with.,/or~, and adds "Local import is forbidden for security reasons" to the errors of the bundle. The file is never loaded.What to do instead, also in the message: self-host a font (download the files as
.woff2, declare the@font-facein the module withfont-display: swapand delete the@import), or list the stylesheet in theassetsof the manifest. There is no autofix: the fonts have to be downloaded and reviewed.Tests
Full suite: 177 passed, 7 skipped. Each check has its fixture (4 reported cases each, plus accepted forms and the report bundle that must stay untouched) and its unit tests (CRLF, missing
;, case-insensitivefont-display, each import form, Sass partials, comments). The README is generated withtox -e update-readme(Python 3.14), which shows at most three examples per check.