@hyperframes/lint 0.8.14 → 0.8.16

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/browser.js CHANGED
@@ -96,13 +96,7 @@ function readDecodedAttr(tagSource, attr) {
96
96
  return value;
97
97
  }
98
98
  function readJsonAttr(tagSource, attr) {
99
- if (!tagSource) return null;
100
- const escaped = attr.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
101
- const match = tagSource.match(
102
- new RegExp(`(?<![\\w-])${escaped}\\s*=\\s*(?:"([^"]*)"|'([^']*)')`, "i")
103
- );
104
- if (!match) return null;
105
- return match[1] ?? match[2] ?? null;
99
+ return readDecodedAttr(tagSource, attr);
106
100
  }
107
101
  function collectCompositionIds(tags) {
108
102
  const ids = /* @__PURE__ */ new Set();
@@ -779,6 +773,14 @@ function hasAttrName(tagSource, attr) {
779
773
  const attrs = tagSource.replace(/^<\s*[a-z][\w:-]*/i, "");
780
774
  return new RegExp(`(?:^|\\s)${escaped}(?:\\s*=|\\s|/?>)`, "i").test(attrs);
781
775
  }
776
+ function mediaHasResolvableSrc(tag, tags) {
777
+ if (readAttr(tag.raw, "src")) return true;
778
+ const end = tag.closeIndex ?? tag.endIndex;
779
+ if (end == null) return false;
780
+ return tags.some(
781
+ (child) => child.name === "source" && child.index > tag.index && child.index < end && Boolean(readAttr(child.raw, "src"))
782
+ );
783
+ }
782
784
  function classNamesFromAttr(classAttr) {
783
785
  if (!classAttr) return [];
784
786
  return classAttr.split(/\s+/).filter(Boolean);
@@ -1177,7 +1179,7 @@ var mediaRules = [
1177
1179
  if (tag.name !== "video" && tag.name !== "audio") continue;
1178
1180
  const hasDataStart = readAttr(tag.raw, "data-start");
1179
1181
  const hasId = readAttr(tag.raw, "id");
1180
- const hasSrc = readAttr(tag.raw, "src");
1182
+ const hasSrc = mediaHasResolvableSrc(tag, tags);
1181
1183
  if (hasSrc && !hasDataStart) {
1182
1184
  findings.push({
1183
1185
  code: "media_missing_data_start",
@@ -1212,9 +1214,9 @@ var mediaRules = [
1212
1214
  findings.push({
1213
1215
  code: "media_missing_src",
1214
1216
  severity: "error",
1215
- message: `<${tag.name} id="${hasId}"> has data-start but no src attribute. The renderer cannot load this media.`,
1217
+ message: `<${tag.name} id="${hasId}"> has data-start but no src (on the element or a <source> child). The renderer cannot load this media.`,
1216
1218
  elementId: hasId,
1217
- fixHint: `Add a src attribute to the <${tag.name}> element directly. If using <source> children, the renderer still requires src on the parent element.`,
1219
+ fixHint: `Add src on the <${tag.name}> element, or a <source src="..."> child.`,
1218
1220
  snippet: truncateSnippet(tag.raw)
1219
1221
  });
1220
1222
  }