mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-09-03 04:38:33 +00:00
chore(lint): keep the fallow audit gate green
Extract rootClassStyledSelectors so the subcomposition_root_styled_by_class rule drops below the complexity threshold, and ignore the music-to-video reference HTML (template + motion-primitive materials forked by path, not import-graph reachable) — same treatment as motion-graphics/grounding. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
119284d377
commit
4a8e2f1cd0
@@ -1,4 +1,4 @@
|
||||
import type { LintContext, HyperframeLintFinding } from "../context";
|
||||
import type { LintContext, HyperframeLintFinding, ExtractedBlock } from "../context";
|
||||
import { findHtmlTag, readAttr, readJsonAttr, stripJsComments, truncateSnippet } from "../utils";
|
||||
import { COMPOSITION_VARIABLE_TYPES } from "../../core.types";
|
||||
|
||||
@@ -63,6 +63,19 @@ function leftmostCompoundClasses(selector: string): string[] {
|
||||
return (leftmost.match(/\.([\w-]+)/g) ?? []).map((c) => c.slice(1));
|
||||
}
|
||||
|
||||
// Distinct selectors across all <style> blocks whose leftmost compound keys off one
|
||||
// of the root element's own classes — the ones that break under id-scoping.
|
||||
function rootClassStyledSelectors(styles: ExtractedBlock[], rootClasses: string[]): string[] {
|
||||
const offenders: string[] = [];
|
||||
for (const style of styles) {
|
||||
for (const selector of extractCssSelectors(style.content)) {
|
||||
const hitsRoot = leftmostCompoundClasses(selector).some((c) => rootClasses.includes(c));
|
||||
if (hitsRoot && !offenders.includes(selector)) offenders.push(selector);
|
||||
}
|
||||
}
|
||||
return offenders;
|
||||
}
|
||||
|
||||
export const compositionRules: Array<(ctx: LintContext) => HyperframeLintFinding[]> = [
|
||||
// invalid_capture_path — catches ../capture/ in src/href attributes and scripts.
|
||||
// Sub-compositions live in compositions/ but are served relative to the project
|
||||
@@ -624,13 +637,7 @@ export const compositionRules: Array<(ctx: LintContext) => HyperframeLintFinding
|
||||
const rootClasses = (readAttr(rootTag.raw, "class") || "").split(/\s+/).filter(Boolean);
|
||||
if (rootClasses.length === 0) return [];
|
||||
|
||||
const offenders: string[] = [];
|
||||
for (const style of styles) {
|
||||
for (const selector of extractCssSelectors(style.content)) {
|
||||
const hitsRoot = leftmostCompoundClasses(selector).some((c) => rootClasses.includes(c));
|
||||
if (hitsRoot && !offenders.includes(selector)) offenders.push(selector);
|
||||
}
|
||||
}
|
||||
const offenders = rootClassStyledSelectors(styles, rootClasses);
|
||||
if (offenders.length === 0) return [];
|
||||
|
||||
const example = offenders.slice(0, 3).join(", ");
|
||||
|
||||
Reference in New Issue
Block a user