Repository navigation
feat(lint): warn when a url() in a linked stylesheet does not resolve beside it - #6844
Conversation
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Automations to automatically generate PRs for you. |
There was a problem hiding this comment.
Verdict: REQUEST CHANGES · 1 blocker · 0 important · 0 nits · head 6d8c8765
The new rule warns about a percent-encoded url() that resolves fine and tells the author the file will 404. ↓ inline
Scope
Read lintLinkedStylesheetAssets / nearestAncestorMatch. Compared them with the bundler (inlineCssFile → rebaseCssUrls rebases against the stylesheet folder, so the premise holds) and with the sibling texture_mask_asset_not_found rule. Ran project.test.ts: 82/82 pass at head, and 82/82 still pass with the suggested change, which also clears the probe. CI was still running when I posted; the verdict doesn't depend on it.
…ke the browser does
Edit accuracy: accurate 271 (base branch 271), smooth 125 of thoseThe gate passes. Quarantined, measured but not gated (0) Unstable (1)
|
What
hyperframes lintnow warns (missing_stylesheet_asset) when aurl()in a linked local stylesheet does not resolve beside that stylesheet. The message names the path it tried; if the file exists in a parent folder, the hint gives the working relative path (for example../assets/fonts/x.ttf).Why
A project with
styles/main.csscontainingsrc: url("assets/fonts/x.ttf")and the font atassets/fonts/x.ttflinted clean (ok: true, no findings). Browsers resolveurl()from the stylesheet's folder, so the font 404s.checkreports the 404, butrenderexits 0 and silently falls back to a default font (frame 1 differs from the same project with the corrected path). Lint is the one place that can say so before a render.Related work
Same area as the linked-stylesheet reads in the font and external-script lint PRs.
mask-imageurls keep their existing error rule and are skipped here.How
lintLinkedStylesheetAssetswalks the declarations of each linked local stylesheet (reusingcollectLocalStylesheets,CSS_URL_RE,cleanAssetUrl), skips remote, data, fragment, absolute and placeholder urls, and resolves against the stylesheet's own folder.nearestAncestorMatchlooks up parent folders for the hint. One finding per stylesheet and url.Size
About 125 added lines (64 code, 56 tests, 5 docs).
Test plan
missing_stylesheet_assettests inpackages/lint/src/project.test.ts, 3 runs in a row green. Full lint package: 23 files, 1238 tests green.tsc --noEmitand the comment ratchet clean.fails without the fix: "names the path that exists when a url() is relative to the wrong folder" and "asks for the file when it exists nowhere" fail with the rule switched off (the call removed, confirmed to match one line).
What I measured
Lint on a project with the wrong-base font url (before:
ok: true, 0 findings, on 0.8.221); render of it vs the corrected path (different frame 1). Tests above, run on a Linux dev box.What I did NOT execute
Warning only inside linked local stylesheets:
<style>blocks and inline styles are not checked.@import url()is not checked. Did not run the CLI end to end on the new build after this change; the CLI calls the samelintProject.