@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 +12 -10
- package/dist/browser.js.map +1 -1
- package/dist/index.js +12 -10
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -96,13 +96,7 @@ function readDecodedAttr(tagSource, attr) {
|
|
|
96
96
|
return value;
|
|
97
97
|
}
|
|
98
98
|
function readJsonAttr(tagSource, attr) {
|
|
99
|
-
|
|
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();
|
|
@@ -782,6 +776,14 @@ function hasAttrName(tagSource, attr) {
|
|
|
782
776
|
const attrs = tagSource.replace(/^<\s*[a-z][\w:-]*/i, "");
|
|
783
777
|
return new RegExp(`(?:^|\\s)${escaped}(?:\\s*=|\\s|/?>)`, "i").test(attrs);
|
|
784
778
|
}
|
|
779
|
+
function mediaHasResolvableSrc(tag, tags) {
|
|
780
|
+
if (readAttr(tag.raw, "src")) return true;
|
|
781
|
+
const end = tag.closeIndex ?? tag.endIndex;
|
|
782
|
+
if (end == null) return false;
|
|
783
|
+
return tags.some(
|
|
784
|
+
(child) => child.name === "source" && child.index > tag.index && child.index < end && Boolean(readAttr(child.raw, "src"))
|
|
785
|
+
);
|
|
786
|
+
}
|
|
785
787
|
function classNamesFromAttr(classAttr) {
|
|
786
788
|
if (!classAttr) return [];
|
|
787
789
|
return classAttr.split(/\s+/).filter(Boolean);
|
|
@@ -1180,7 +1182,7 @@ var mediaRules = [
|
|
|
1180
1182
|
if (tag.name !== "video" && tag.name !== "audio") continue;
|
|
1181
1183
|
const hasDataStart = readAttr(tag.raw, "data-start");
|
|
1182
1184
|
const hasId = readAttr(tag.raw, "id");
|
|
1183
|
-
const hasSrc =
|
|
1185
|
+
const hasSrc = mediaHasResolvableSrc(tag, tags);
|
|
1184
1186
|
if (hasSrc && !hasDataStart) {
|
|
1185
1187
|
findings.push({
|
|
1186
1188
|
code: "media_missing_data_start",
|
|
@@ -1215,9 +1217,9 @@ var mediaRules = [
|
|
|
1215
1217
|
findings.push({
|
|
1216
1218
|
code: "media_missing_src",
|
|
1217
1219
|
severity: "error",
|
|
1218
|
-
message: `<${tag.name} id="${hasId}"> has data-start but no src
|
|
1220
|
+
message: `<${tag.name} id="${hasId}"> has data-start but no src (on the element or a <source> child). The renderer cannot load this media.`,
|
|
1219
1221
|
elementId: hasId,
|
|
1220
|
-
fixHint: `Add
|
|
1222
|
+
fixHint: `Add src on the <${tag.name}> element, or a <source src="..."> child.`,
|
|
1221
1223
|
snippet: truncateSnippet(tag.raw)
|
|
1222
1224
|
});
|
|
1223
1225
|
}
|