@hyperframes/lint 0.7.55 → 0.7.57

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -61,6 +61,6 @@ interface ProjectLintResult {
61
61
  totalWarnings: number;
62
62
  totalInfos: number;
63
63
  }
64
- declare function lintProject(projectDir: string): Promise<ProjectLintResult>;
64
+ declare function lintProject(projectDir: string, entryFile?: string): Promise<ProjectLintResult>;
65
65
 
66
66
  export { type HyperframeLintFinding, type HyperframeLintResult, type HyperframeLintSeverity, type HyperframeLinterOptions, type ProjectLintResult, lintHyperframeHtml, lintMediaUrls, lintProject, shouldBlockRender };
package/dist/index.js CHANGED
@@ -3879,8 +3879,13 @@ function resolveCssAssetCandidates(projectDir, url, htmlCompSrcPath, cssRootRela
3879
3879
  }
3880
3880
  return resolveLocalAssetCandidates(projectDir, url);
3881
3881
  }
3882
- async function lintProject(projectDir) {
3883
- const indexPath = resolve(projectDir, "index.html");
3882
+ async function lintProject(projectDir, entryFile) {
3883
+ const indexPath = entryFile ? resolve(entryFile) : resolve(projectDir, "index.html");
3884
+ if (entryFile && !isWithinProjectRoot(projectDir, indexPath)) {
3885
+ throw new Error(`Explicit lint entry is outside the project directory: ${entryFile}`);
3886
+ }
3887
+ const rootFile = relative(resolve(projectDir), indexPath).replace(/\\/g, "/") || "index.html";
3888
+ const rootCompSrcPath = rootFile === "index.html" ? void 0 : rootFile;
3884
3889
  const results = [];
3885
3890
  let totalErrors = 0;
3886
3891
  let totalWarnings = 0;
@@ -3888,15 +3893,15 @@ async function lintProject(projectDir) {
3888
3893
  const rootHtml = readFileSync(indexPath, "utf-8");
3889
3894
  const rootResult = await lintHyperframeHtml(rootHtml, {
3890
3895
  filePath: indexPath,
3891
- externalStyles: collectExternalStyles(projectDir, rootHtml)
3896
+ externalStyles: collectExternalStyles(projectDir, rootHtml, rootCompSrcPath)
3892
3897
  });
3893
- results.push({ file: "index.html", result: rootResult });
3898
+ results.push({ file: rootFile, result: rootResult });
3894
3899
  totalErrors += rootResult.errorCount;
3895
3900
  totalWarnings += rootResult.warningCount;
3896
3901
  totalInfos += rootResult.infoCount;
3897
- const allHtmlSources = [{ html: rootHtml }];
3902
+ const allHtmlSources = [{ html: rootHtml, compSrcPath: rootCompSrcPath }];
3898
3903
  const compositionsDir = resolve(projectDir, "compositions");
3899
- if (existsSync(compositionsDir)) {
3904
+ if (!entryFile && existsSync(compositionsDir)) {
3900
3905
  const collectHtmlFiles = (dir, rel) => {
3901
3906
  const out = [];
3902
3907
  for (const entry of readdirSync(dir, { withFileTypes: true })) {
@@ -3931,7 +3936,7 @@ async function lintProject(projectDir) {
3931
3936
  ...lintAudioSrcNotFound(projectDir, allHtmlSources),
3932
3937
  ...lintMissingLocalAsset(projectDir, allHtmlSources),
3933
3938
  ...lintTextureMaskAssetNotFound(projectDir, allHtmlSources),
3934
- ...lintMultipleRootCompositions(projectDir),
3939
+ ...!entryFile ? lintMultipleRootCompositions(projectDir) : [],
3935
3940
  ...lintDuplicateAudioTracks(allHtmlSources),
3936
3941
  ...lintMissingOrEmptySubComposition(projectDir, rootHtml)
3937
3942
  ];