diff --git a/docs/packages/cli.mdx b/docs/packages/cli.mdx index 5d0c5e3dfa..ae0ffd2cc7 100644 --- a/docs/packages/cli.mdx +++ b/docs/packages/cli.mdx @@ -1209,6 +1209,12 @@ unless you pass `--verbose`, which keeps output clean for agents and CI. `--lint-verbose`, which `render`, `preview` and `publish` use for the same wish, works here and on `check` too. `--json` adds `errorCount`, `warningCount`, `infoCount`, and a `findings` array. +Only the compositions the project uses are linted: `index.html` and every file it mounts through +`data-composition-src`, followed through the files they mount. A file under `compositions/` that +nothing mounts (an installed block you have not placed yet) is left out, and one line says how +many were; `--include-unmounted` lints them too. `--json` lists them in `unmountedCompositions`. +`check` lints the same way and takes the same flag. + The linter catches missing attributes, missing adapter libraries (GSAP, Lottie, Three.js), and structural problems. [Troubleshooting](/help) explains each rule. @@ -1253,6 +1259,7 @@ cover every finding from the full check. | -------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------- | | `--json` | One aggregated envelope. Every finding carries a selector, `data-*` identity, source file, bbox, and sample time. | | `--snapshots` | Save the five audited frames under `.hyperframes/artifacts/snapshots/`, plus a `finding-NN-.png` crop per finding | +| `--include-unmounted` | Also lint `compositions/` files that `index.html` never mounts (left out by default, with one line saying how many) | | `--samples` | Midpoint samples across the duration (default 9) | | `--at` | Explicit timestamps in seconds, comma-separated | | `--at-transitions` | Also sample every tween start and end, to catch transient overlaps at transition seams | diff --git a/packages/cli/src/commands/check.ts b/packages/cli/src/commands/check.ts index edcf385229..a747d47453 100644 --- a/packages/cli/src/commands/check.ts +++ b/packages/cli/src/commands/check.ts @@ -266,6 +266,11 @@ const CHECK_COMMAND_ARGS = { description: "Save contrast-pass PNGs under .hyperframes/artifacts/snapshots/", default: false, }, + "include-unmounted": { + type: "boolean", + description: "Also lint compositions/ files that index.html never mounts", + default: false, + }, "caption-zone": { type: "string", description: @@ -456,6 +461,7 @@ function parseCheckOptions(args: Record): CheckOptions { layout: parseLayout(args.layout), autoProxy: args.proxy as boolean | undefined, browserGpuMode: resolveLocalBrowserGpuMode(args["browser-gpu"] as boolean | undefined), + includeUnmounted: args["include-unmounted"] === true, }; } diff --git a/packages/cli/src/commands/lint.test.ts b/packages/cli/src/commands/lint.test.ts index 51d2bce0e8..c527ec608d 100644 --- a/packages/cli/src/commands/lint.test.ts +++ b/packages/cli/src/commands/lint.test.ts @@ -128,3 +128,42 @@ describe("lint --lint-verbose", () => { expect(await codes({ "lint-verbose": true })).toEqual(["warn", "note"]); }); }); + +describe("lint and compositions the project never mounts", () => { + beforeEach(() => { + consumeCommandResult(); + lintProjectMock.mockReset(); + lintProjectMock.mockResolvedValue({ + results: [{ file: "index.html", result: { findings: [] } }], + totalErrors: 0, + totalWarnings: 0, + totalInfos: 0, + unmountedCompositions: ["compositions/a.html", "compositions/b.html"], + }); + }); + afterEach(() => vi.restoreAllMocks()); + + it("says once how many it left out, and lints them with --include-unmounted", async () => { + const log = vi.spyOn(console, "log").mockImplementation(() => {}); + await run({ _: [] }); + const lines = log.mock.calls.map((call) => String(call[0])); + expect(lines.filter((line) => line.includes("not mounted from index.html"))).toEqual([ + expect.stringContaining( + "2 files in compositions/ are not mounted from index.html, so not checked; --include-unmounted adds them.", + ), + ]); + expect(lintProjectMock.mock.calls[0]?.[3]).toEqual({ includeUnmounted: false }); + + await run({ _: [], "include-unmounted": true }); + expect(lintProjectMock.mock.calls[1]?.[3]).toEqual({ includeUnmounted: true }); + }); + + it("names them in the JSON report", async () => { + const log = vi.spyOn(console, "log").mockImplementation(() => {}); + await run({ _: [], json: true }); + expect(JSON.parse(String(log.mock.calls[0]?.[0])).unmountedCompositions).toEqual([ + "compositions/a.html", + "compositions/b.html", + ]); + }); +}); diff --git a/packages/cli/src/commands/lint.ts b/packages/cli/src/commands/lint.ts index bc98713245..3c3a93ef5f 100644 --- a/packages/cli/src/commands/lint.ts +++ b/packages/cli/src/commands/lint.ts @@ -12,6 +12,7 @@ export const examples: Example[] = [ ["Include info-level findings", "hyperframes lint --verbose"], ]; import { formatLintFindings } from "../utils/lintFormat.js"; +import { unmountedNotice } from "@hyperframes/lint"; import { lintProject } from "../utils/lintProject.js"; import { isUnderCompositions, resolveLintTarget } from "../utils/project.js"; import { trackLintRun } from "../telemetry/lintRun.js"; @@ -39,6 +40,11 @@ export default defineCommand({ description: "Show info-level findings (hidden by default)", default: false, }, + "include-unmounted": { + type: "boolean", + description: "Also lint compositions/ files that index.html never mounts", + default: false, + }, "lint-verbose": { type: "boolean", description: "Same as --verbose (render, preview and publish spell it --lint-verbose)", @@ -62,7 +68,9 @@ export default defineCommand({ entryFile && isUnderCompositions(project.dir, entryFile) ? { isSubComposition: true } : undefined, + { includeUnmounted: Boolean(args["include-unmounted"]) }, ); + const unmounted = lintResult.unmountedCompositions ?? []; trackLintRun(project.dir, lintResult, { command: "lint", durationMs: Date.now() - startedAt, @@ -78,6 +86,7 @@ export default defineCommand({ infoCount: lintResult.totalInfos, findings: verbose ? allFindings : allFindings.filter((f) => f.severity !== "info"), filesScanned: lintResult.results.length, + unmountedCompositions: unmounted, }; console.log(JSON.stringify(withMeta(combined), null, 2)); setCommandExitCode(combined.ok ? 0 : 1); @@ -88,6 +97,7 @@ export default defineCommand({ const fileLabel = fileCount === 1 ? (lintResult.results[0]?.file ?? "index.html") : `${fileCount} files`; console.log(`${c.accent("◆")} Linting ${c.accent(`${project.name}/${fileLabel}`)}`); + if (unmounted.length > 0) console.log(c.dim(unmountedNotice(unmounted.length))); console.log(); if (lintResult.totalErrors === 0 && lintResult.totalWarnings === 0) { diff --git a/packages/cli/src/utils/checkPipeline.ts b/packages/cli/src/utils/checkPipeline.ts index 1c79516b2d..ffc1aba874 100644 --- a/packages/cli/src/utils/checkPipeline.ts +++ b/packages/cli/src/utils/checkPipeline.ts @@ -32,6 +32,7 @@ import { trackLintRun } from "../telemetry/lintRun.js"; import { getRunId } from "../telemetry/runId.js"; import type { ProjectDir } from "./project.js"; import { lintProject, type ProjectLintResult } from "./lintProject.js"; +import { unmountedNotice } from "@hyperframes/lint"; import { buildLayoutSampleTimes, buildTransitionSampleTimes, @@ -1693,7 +1694,11 @@ export async function runCheckPipeline( let lintResult: ProjectLintResult; const lintStartedAt = Date.now(); try { - lintResult = await dependencies.lintProject(project.dir); + lintResult = await dependencies.lintProject(project.dir, { + includeUnmounted: options.includeUnmounted === true, + }); + const unmounted = lintResult.unmountedCompositions?.length ?? 0; + if (unmounted > 0) console.error(`[hyperframes] check: ${unmountedNotice(unmounted)}`); } catch (error) { // The linter itself crashed (unreadable file, internal error) — distinct // from lint findings; a runtime-failure code would send the agent hunting @@ -2269,7 +2274,7 @@ function emptyBrowserResult(): CheckBrowserResult { }; } -export const STOP_CODES = [ +const STOP_CODES = [ "media_copies_unfinished", "check_budget_reached", "check_runtime_failure", @@ -2435,7 +2440,7 @@ function audioCheckFailure(project: ProjectDir, error: unknown): CheckFinding[] } const DEFAULT_DEPENDENCIES: CheckDependencies = { - lintProject, + lintProject: (projectDir, options) => lintProject(projectDir, undefined, {}, options), resolveMotionSpec, runBrowserCheck, prelaunchBrowser, diff --git a/packages/cli/src/utils/checkTypes.ts b/packages/cli/src/utils/checkTypes.ts index 92c2823c24..2c09d2675a 100644 --- a/packages/cli/src/utils/checkTypes.ts +++ b/packages/cli/src/utils/checkTypes.ts @@ -1,6 +1,6 @@ import type { CheckDeadline } from "./checkDeadline.js"; import type { CheckProgress } from "./checkProgress.js"; -import type { ProjectLintResult } from "./lintProject.js"; +import type { ProjectLintOptions, ProjectLintResult } from "./lintProject.js"; import type { LayoutIssue, LayoutOverflow, LayoutRect } from "./layoutAudit.js"; import type { Canvas, MotionFrame } from "./motionAudit.js"; import type { MotionSpec } from "./motionSpec.js"; @@ -37,6 +37,7 @@ export interface CheckOptions { /** Explicit --proxy/--no-proxy override; undefined preserves project config. */ autoProxy?: boolean; browserGpuMode?: BrowserGpuMode; + includeUnmounted?: boolean; } export interface CaptionZoneOptions { @@ -422,7 +423,7 @@ export interface CheckReport { } export interface CheckDependencies { - lintProject(projectDir: string): Promise; + lintProject(projectDir: string, options?: ProjectLintOptions): Promise; resolveMotionSpec(projectDir: string): MotionSpecResolution; runBrowserCheck( project: ProjectDir, diff --git a/packages/cli/src/utils/lintProject.test.ts b/packages/cli/src/utils/lintProject.test.ts index f6c131c4f7..a586b2972f 100644 --- a/packages/cli/src/utils/lintProject.test.ts +++ b/packages/cli/src/utils/lintProject.test.ts @@ -112,7 +112,7 @@ describe("lintProject", () => { `; writeFileSync(join(framesDir, "04-mechanism.html"), frameHtml); - const { results } = await lintProject(dir); + const { results } = await lintProject(dir, undefined, {}, { includeUnmounted: true }); const frameResult = results.find((r) => r.file === "compositions/frames/04-mechanism.html"); expect(frameResult).toBeDefined(); @@ -126,7 +126,12 @@ describe("lintProject", () => { const project = makeProject(validHtml(), { "captions.html": htmlWithMissingMediaId(), }); - const { totalErrors, results } = await lintProject(project); + const { totalErrors, results } = await lintProject( + project, + undefined, + {}, + { includeUnmounted: true }, + ); expect(results).toHaveLength(2); const second = results[1]; @@ -149,7 +154,7 @@ describe("lintProject", () => { '[data-composition-id="no-such-comp"] .title { opacity: 0; }', ); - const { results } = await lintProject(project); + const { results } = await lintProject(project, undefined, {}, { includeUnmounted: true }); const subResult = results.find((result) => result.file === "compositions/scene.html"); // The linked stylesheet scopes CSS to a composition id that has no wrapper // here, so this finding can only come from the linked file being read. @@ -174,7 +179,7 @@ describe("lintProject", () => { '[data-composition-id="no-such-comp"] .title { opacity: 0; }', ); - const { results } = await lintProject(project); + const { results } = await lintProject(project, undefined, {}, { includeUnmounted: true }); const subResult = results.find((result) => result.file === "compositions/scene.html"); // The linked stylesheet scopes CSS to a composition id that has no wrapper // here, so this finding can only come from the linked file being read. @@ -190,7 +195,12 @@ describe("lintProject", () => { const project = makeProject(htmlWithMissingMediaId(), { "overlay.html": htmlWithMissingMediaId(), }); - const { totalErrors, results } = await lintProject(project); + const { totalErrors, results } = await lintProject( + project, + undefined, + {}, + { includeUnmounted: true }, + ); expect(results).toHaveLength(2); const first = results[0]; @@ -207,7 +217,12 @@ describe("lintProject", () => { const project = makeProject(validHtml(), { "captions.html": htmlWithPreloadNone(), }); - const { totalWarnings, results } = await lintProject(project); + const { totalWarnings, results } = await lintProject( + project, + undefined, + {}, + { includeUnmounted: true }, + ); expect(results).toHaveLength(2); expect(totalWarnings).toBeGreaterThan(0); @@ -247,7 +262,7 @@ describe("lintProject", () => { // Add a non-HTML file writeFileSync(join(project, "compositions", "readme.txt"), "not html"); - const { results } = await lintProject(project); + const { results } = await lintProject(project, undefined, {}, { includeUnmounted: true }); expect(results).toHaveLength(2); // index.html + captions.html, not readme.txt }); @@ -390,7 +405,7 @@ describe("audio_file_without_element", () => { }); writeFileSync(join(project, "song.mp3"), "fake"); - const { results } = await lintProject(project); + const { results } = await lintProject(project, undefined, {}, { includeUnmounted: true }); const first = results[0]; expect(first).toBeDefined(); @@ -444,7 +459,12 @@ describe("audio_src_not_found", () => { }); // song.mp3 referenced in sub-comp but not on disk - const { totalErrors, results } = await lintProject(project); + const { totalErrors, results } = await lintProject( + project, + undefined, + {}, + { includeUnmounted: true }, + ); expect(totalErrors).toBeGreaterThan(0); const finding = allFindings(results).find((f) => f.code === "audio_src_not_found"); @@ -510,7 +530,7 @@ describe("audio_src_not_found", () => { }); // Both reference song.mp3 which doesn't exist - const { results } = await lintProject(project); + const { results } = await lintProject(project, undefined, {}, { includeUnmounted: true }); const findings = results .flatMap((entry) => entry.result.findings) @@ -551,7 +571,7 @@ describe("audio_src_not_found", () => { const project = makeProject(validHtml(), { "captions.html": subComp }); // No assets/ directory at all. - const { results } = await lintProject(project); + const { results } = await lintProject(project, undefined, {}, { includeUnmounted: true }); const finding = allFindings(results).find((f) => f.code === "audio_src_not_found"); expect(finding).toBeDefined(); @@ -725,7 +745,7 @@ describe("missing_local_asset", () => { }, ); - const { results } = await lintProject(project); + const { results } = await lintProject(project, undefined, {}, { includeUnmounted: true }); const findings = results .flatMap((entry) => entry.result.findings) @@ -867,7 +887,7 @@ describe("texture_mask_asset_not_found", () => { '.hf-texture-lava { mask-image: url("masks/missing.png"); }', ); - const { results } = await lintProject(project); + const { results } = await lintProject(project, undefined, {}, { includeUnmounted: true }); const finding = allFindings(results).find( (item) => item.code === "texture_mask_asset_not_found", ); diff --git a/packages/cli/src/utils/lintProject.ts b/packages/cli/src/utils/lintProject.ts index 04e1cccd95..375a52f2d4 100644 --- a/packages/cli/src/utils/lintProject.ts +++ b/packages/cli/src/utils/lintProject.ts @@ -1,6 +1,6 @@ // CLI facade: the linter stays reusable without the CLI, while command-specific gates live here. export { lintProject, shouldBlockRender } from "@hyperframes/lint"; -export type { ProjectLintResult } from "@hyperframes/lint"; +export type { ProjectLintOptions, ProjectLintResult } from "@hyperframes/lint"; import type { ProjectLintResult } from "@hyperframes/lint"; diff --git a/packages/lint/src/index.ts b/packages/lint/src/index.ts index 7752ca4334..8ea6db38b8 100644 --- a/packages/lint/src/index.ts +++ b/packages/lint/src/index.ts @@ -11,7 +11,7 @@ export { LINT_RULE_COUNT, LINT_RULE_GROUP_COUNTS, } from "./hyperframeLinter.js"; -export { linkedSources, lintProject, shouldBlockRender } from "./project.js"; -export type { ProjectLintResult } from "./project.js"; +export { linkedSources, lintProject, shouldBlockRender, unmountedNotice } from "./project.js"; +export type { ProjectLintOptions, ProjectLintResult } from "./project.js"; export { projectIgnore } from "./projectIgnore.js"; export { audioAttributeShapeError, type AudioAttribute } from "./rules/audioAttributes.js"; diff --git a/packages/lint/src/project.test.ts b/packages/lint/src/project.test.ts index b30fd41d0e..2e3d9a8ddd 100644 --- a/packages/lint/src/project.test.ts +++ b/packages/lint/src/project.test.ts @@ -4,7 +4,7 @@ import { mkdirSync, mkdtempSync, writeFileSync, rmSync, symlinkSync } from "node import { dirname, join } from "node:path"; import { tmpdir } from "node:os"; import type { HyperframeLintFinding } from "./types.js"; -import { lintProject } from "./project.js"; +import { lintProject, unmountedNotice } from "./project.js"; // Keep project lint tests independent of the host's ffprobe installation. vi.mock("node:child_process", () => { @@ -676,7 +676,7 @@ describe("sub-composition stylesheet links", () => { } async function fontFaceFindings(project: string): Promise { - const { results } = await lintProject(project); + const { results } = await lintProject(project, undefined, {}, { includeUnmounted: true }); return results .flatMap((entry) => entry.result.findings) .filter((finding) => finding.code === "font_family_without_font_face"); @@ -1395,8 +1395,9 @@ describe("audio-aware project rules", () => { describe("sub-composition files", () => { const sceneFindings = async (project: string) => - (await lintProject(project)).results.find((result) => result.file === "compositions/scene.html") - ?.result.findings ?? []; + (await lintProject(project, undefined, {}, { includeUnmounted: true })).results.find( + (result) => result.file === "compositions/scene.html", + )?.result.findings ?? []; it("resolves a scene's ../assets/ path from its own folder, as preview and render do", async () => { const project = makeProject(validHtml(), { @@ -1437,7 +1438,7 @@ describe("sub-composition files", () => { join(project, "styles", "escape.css"), ".a { background: url('../../outside.png'); }", ); - const { results } = await lintProject(project); + const { results } = await lintProject(project, undefined, {}, { includeUnmounted: true }); const traversal = (file: string) => results .find((result) => result.file === file) @@ -1514,3 +1515,65 @@ describe("a page saved as UTF-16", () => { expect(await codes(utf16)).toEqual(await codes(utf8)); }); }); + +describe("compositions the entry never mounts", () => { + const mounting = (src: string) => ` +
+
+
+ + +`; + const broken = + '
'; + + it("are not linted and are named in unmountedCompositions", async () => { + const project = makeProject(mounting("compositions/used.html"), { + "used.html": validHtml("scene"), + "unused.html": broken, + "nested/also-unused.html": broken, + }); + + const result = await lintProject(project); + + expect(result.results.map((entry) => entry.file)).toEqual([ + "index.html", + "compositions/used.html", + ]); + expect(result.unmountedCompositions).toEqual([ + "compositions/nested/also-unused.html", + "compositions/unused.html", + ]); + }); + + it("are linted again with includeUnmounted", async () => { + const project = makeProject(mounting("compositions/used.html"), { + "used.html": validHtml("scene"), + "unused.html": broken, + }); + + const result = await lintProject(project, undefined, {}, { includeUnmounted: true }); + + expect(result.results.map((entry) => entry.file)).toContain("compositions/unused.html"); + expect(result.unmountedCompositions).toEqual([]); + }); + + it("follows mounts made by a mounted composition", async () => { + const project = makeProject(mounting("compositions/outer.html"), { + "outer.html": `
`, + "inner.html": validHtml("inner"), + }); + + const result = await lintProject(project); + + expect(result.results.map((entry) => entry.file)).toContain("compositions/inner.html"); + expect(result.unmountedCompositions).toEqual([]); + }); +}); + +it("names the unmounted count in one line", () => { + expect(unmountedNotice(1)).toBe( + "1 file in compositions/ is not mounted from index.html, so not checked; --include-unmounted adds them.", + ); + expect(unmountedNotice(3)).toContain("3 files in compositions/ are not mounted"); +}); diff --git a/packages/lint/src/project.ts b/packages/lint/src/project.ts index d1c57a339b..4bcbafd9ee 100644 --- a/packages/lint/src/project.ts +++ b/packages/lint/src/project.ts @@ -89,6 +89,18 @@ export interface ProjectLintResult { totalErrors: number; totalWarnings: number; totalInfos: number; + unmountedCompositions?: string[]; +} + +/** The one line a run prints when it left unmounted compositions out. */ +export function unmountedNotice(count: number): string { + const skipped = + count === 1 ? "1 file in compositions/ is" : `${count} files in compositions/ are`; + return `${skipped} not mounted from index.html, so not checked; --include-unmounted adds them.`; +} + +export interface ProjectLintOptions { + includeUnmounted?: boolean; } /** @@ -294,6 +306,7 @@ export async function lintProject( projectDir: string, entryFile?: string, hostOptions: Pick = {}, + { includeUnmounted = false }: ProjectLintOptions = {}, ): Promise { const indexPath = entryFile ? resolve(entryFile) : resolve(projectDir, "index.html"); if (entryFile && !isWithinProjectRoot(projectDir, indexPath)) { @@ -307,10 +320,11 @@ export async function lintProject( let totalInfos = 0; const rootHtml = readTextFile(indexPath); - const projectFontFamilies = declaredProjectFontFamilies( - projectDir, - mountedSources(projectDir, rootHtml, rootCompSrcPath), - ); + const mounted = mountedSources(projectDir, rootHtml, rootCompSrcPath); + const mountedPaths = new Set(mounted.map((source) => source.compSrcPath)); + const unmountedCompositions: string[] = []; + const unmountedSources: HtmlSource[] = []; + const projectFontFamilies = declaredProjectFontFamilies(projectDir, mounted); const rootResult = await lintHyperframeHtml(rootHtml, { ...hostOptions, filePath: indexPath, @@ -349,6 +363,11 @@ export async function lintProject( const filePath = join(compositionsDir, file); const html = readTextFile(filePath); const compSrcPath = `compositions/${file}`; + if (!includeUnmounted && !mountedPaths.has(compSrcPath)) { + unmountedSources.push({ html, compSrcPath }); + if (!isSnippetFragment(html)) unmountedCompositions.push(compSrcPath); + continue; + } allHtmlSources.push({ html, compSrcPath }); // Mountable fragments (figma component imports, registry snippets) are // not standalone compositions — composition-root rules don't apply. @@ -382,7 +401,9 @@ export async function lintProject( ...lintTextureMaskAssetNotFound(projectDir, allHtmlSources), ...lintLinkedStylesheetAssets(projectDir, allHtmlSources), ...(!entryFile ? lintMultipleRootCompositions(projectDir) : []), - ...(!entryFile ? lintBlankRootWithStandaloneComposition(rootHtml, allHtmlSources) : []), + ...(!entryFile + ? lintBlankRootWithStandaloneComposition(rootHtml, [...allHtmlSources, ...unmountedSources]) + : []), ...lintDuplicateAudioTracks(projectDir, rootHtml), ...lintMissingOrEmptySubComposition(projectDir, rootHtml), ...(await lintVideoMediaStartPastEof(projectDir, allHtmlSources)), @@ -406,7 +427,7 @@ export async function lintProject( } } - return { results, totalErrors, totalWarnings, totalInfos }; + return { results, totalErrors, totalWarnings, totalInfos, unmountedCompositions }; } function lintBlankRootWithStandaloneComposition( @@ -624,6 +645,14 @@ function lintMissingLocalAsset( return findings; } +function localCssUrl(match: RegExpMatchArray): string | undefined { + const rawUrl = match[1] ?? match[2] ?? match[3] ?? ""; + // Placeholder check runs on the RAW value: cleanAssetUrl() splits on ?/# and would chop inside a ${...} token. + if (isUnresolvedAssetPlaceholder(rawUrl)) return undefined; + const url = cleanAssetUrl(rawUrl); + return url && !isRemoteOrInlineUrl(url) ? url : undefined; +} + function lintTextureMaskAssetNotFound( projectDir: string, htmlSources: HtmlSource[], @@ -643,11 +672,8 @@ function lintTextureMaskAssetNotFound( matches = [...cssSource.content.matchAll(MASK_IMAGE_URL_RE)]; } for (const match of matches) { - const rawUrl = match[1] ?? match[2] ?? match[3] ?? ""; - // Placeholder check runs on the RAW value: cleanAssetUrl() splits on ?/# and would chop inside a ${...} token. - if (isUnresolvedAssetPlaceholder(rawUrl)) continue; - const url = cleanAssetUrl(rawUrl); - if (!url || isRemoteOrInlineUrl(url)) continue; + const url = localCssUrl(match); + if (!url) continue; const candidates = resolveCssAssetCandidates( projectDir, @@ -712,10 +738,8 @@ function lintLinkedStylesheetAssets( root.walkDecls((declaration) => { if (/^(?:-webkit-)?mask-image$/i.test(declaration.prop)) return; for (const match of declaration.value.matchAll(CSS_URL_RE)) { - const rawUrl = match[1] ?? match[2] ?? match[3] ?? ""; - if (isUnresolvedAssetPlaceholder(rawUrl)) continue; - const url = cleanAssetUrl(rawUrl); - if (!url || isRemoteOrInlineUrl(url) || url.startsWith("/")) continue; + const url = localCssUrl(match); + if (!url || url.startsWith("/")) continue; if ( resolveCssAssetCandidates(projectDir, url, undefined, rootRelativePath).some(existsSync) ) diff --git a/packages/lint/src/projectShaders.test.ts b/packages/lint/src/projectShaders.test.ts index 6a27bb06fb..2629940184 100644 --- a/packages/lint/src/projectShaders.test.ts +++ b/packages/lint/src/projectShaders.test.ts @@ -23,7 +23,7 @@ function project(files: Record) { } async function warnings(root: string) { - const report = await lintProject(root); + const report = await lintProject(root, undefined, {}, { includeUnmounted: true }); return report.results .flatMap(({ result }) => result.findings) .filter((finding) => finding.code === "shader_unbounded_cosine_pow"); diff --git a/packages/lint/src/snippetFragment.test.ts b/packages/lint/src/snippetFragment.test.ts index 5997af8ae6..83d995a3b3 100644 --- a/packages/lint/src/snippetFragment.test.ts +++ b/packages/lint/src/snippetFragment.test.ts @@ -21,7 +21,7 @@ async function lintWithFragment(name: string, html: string) { writeFileSync(join(dir, "index.html"), INDEX); mkdirSync(join(dir, "compositions"), { recursive: true }); writeFileSync(join(dir, "compositions", name), html); - const result = await lintProject(dir); + const result = await lintProject(dir, undefined, {}, { includeUnmounted: true }); return result.results.filter((r) => r.file.includes(name.replace(".html", ""))); }