@hyperframes/lint 0.8.196 → 0.8.197
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 +31 -0
- package/dist/index.js +31 -0
- package/package.json +2 -2
package/dist/browser.js
CHANGED
|
@@ -5788,6 +5788,37 @@ ${other.raw}`)
|
|
|
5788
5788
|
}
|
|
5789
5789
|
return findings;
|
|
5790
5790
|
},
|
|
5791
|
+
// svg_round_cap_hidden_dash — a round or square cap hides a path with dash == gap == pathLength and
|
|
5792
|
+
// offset == dash. The next dash then starts exactly at the path end, and Chrome's float rounding
|
|
5793
|
+
// leaves a sliver there that the cap paints as a dot, on some curves and not others.
|
|
5794
|
+
({ tags }) => {
|
|
5795
|
+
const findings = [];
|
|
5796
|
+
for (const tag of tags) {
|
|
5797
|
+
const style = readAttr(tag.raw, "style") ?? "";
|
|
5798
|
+
const read = (name) => readAttr(tag.raw, name) ?? readStyleProperty(style, name);
|
|
5799
|
+
const cap = read("stroke-linecap");
|
|
5800
|
+
if (cap !== "round" && cap !== "square") continue;
|
|
5801
|
+
const pathLength = Number(readAttr(tag.raw, "pathLength"));
|
|
5802
|
+
const offset = Number(read("stroke-dashoffset"));
|
|
5803
|
+
const dashes = (read("stroke-dasharray") ?? "").split(/[\s,]+/).map(Number);
|
|
5804
|
+
const [dash, gap = dash] = dashes;
|
|
5805
|
+
if (dashes.length > 2 || dash === void 0 || gap === void 0) continue;
|
|
5806
|
+
if (![pathLength, offset, dash, gap].every(Number.isFinite) || pathLength <= 0) continue;
|
|
5807
|
+
const period = dash + gap;
|
|
5808
|
+
if (period <= 0 || offset < 0) continue;
|
|
5809
|
+
const nextDashAt = period - offset % period;
|
|
5810
|
+
if (offset % period < dash || Math.abs(nextDashAt - pathLength) > pathLength * 1e-6) continue;
|
|
5811
|
+
findings.push({
|
|
5812
|
+
code: "svg_round_cap_hidden_dash",
|
|
5813
|
+
severity: "warning",
|
|
5814
|
+
message: `<${tag.name}> is hidden with stroke-dasharray ${dash}${dashes.length > 1 ? ` ${gap}` : ""} and stroke-dashoffset ${offset} on pathLength ${pathLength}, but its ${cap} cap can still paint a dot at the end of the path (Chrome rounds the zero-length dash differently per curve).`,
|
|
5815
|
+
elementId: readAttr(tag.raw, "id") ?? void 0,
|
|
5816
|
+
fixHint: `Make the gap longer than the path (stroke-dasharray "${pathLength} ${+(pathLength * 1.2).toFixed(3)}" with stroke-dashoffset ${+(pathLength * 1.1).toFixed(3)}), or keep the element visibility:hidden until its draw tween starts.`,
|
|
5817
|
+
snippet: truncateSnippet(tag.raw)
|
|
5818
|
+
});
|
|
5819
|
+
}
|
|
5820
|
+
return findings;
|
|
5821
|
+
},
|
|
5791
5822
|
// svg_measure_before_path_d — getTotalLength() on a <path> that has no static `d`
|
|
5792
5823
|
// attribute in the HTML. In Chrome getTotalLength() on a d-less path returns 0,
|
|
5793
5824
|
// silently killing dash animations (offset 0 == length 0 == nothing to draw). If a
|
package/dist/index.js
CHANGED
|
@@ -5794,6 +5794,37 @@ ${other.raw}`)
|
|
|
5794
5794
|
}
|
|
5795
5795
|
return findings;
|
|
5796
5796
|
},
|
|
5797
|
+
// svg_round_cap_hidden_dash — a round or square cap hides a path with dash == gap == pathLength and
|
|
5798
|
+
// offset == dash. The next dash then starts exactly at the path end, and Chrome's float rounding
|
|
5799
|
+
// leaves a sliver there that the cap paints as a dot, on some curves and not others.
|
|
5800
|
+
({ tags }) => {
|
|
5801
|
+
const findings = [];
|
|
5802
|
+
for (const tag of tags) {
|
|
5803
|
+
const style = readAttr(tag.raw, "style") ?? "";
|
|
5804
|
+
const read = (name) => readAttr(tag.raw, name) ?? readStyleProperty(style, name);
|
|
5805
|
+
const cap = read("stroke-linecap");
|
|
5806
|
+
if (cap !== "round" && cap !== "square") continue;
|
|
5807
|
+
const pathLength = Number(readAttr(tag.raw, "pathLength"));
|
|
5808
|
+
const offset = Number(read("stroke-dashoffset"));
|
|
5809
|
+
const dashes = (read("stroke-dasharray") ?? "").split(/[\s,]+/).map(Number);
|
|
5810
|
+
const [dash, gap = dash] = dashes;
|
|
5811
|
+
if (dashes.length > 2 || dash === void 0 || gap === void 0) continue;
|
|
5812
|
+
if (![pathLength, offset, dash, gap].every(Number.isFinite) || pathLength <= 0) continue;
|
|
5813
|
+
const period = dash + gap;
|
|
5814
|
+
if (period <= 0 || offset < 0) continue;
|
|
5815
|
+
const nextDashAt = period - offset % period;
|
|
5816
|
+
if (offset % period < dash || Math.abs(nextDashAt - pathLength) > pathLength * 1e-6) continue;
|
|
5817
|
+
findings.push({
|
|
5818
|
+
code: "svg_round_cap_hidden_dash",
|
|
5819
|
+
severity: "warning",
|
|
5820
|
+
message: `<${tag.name}> is hidden with stroke-dasharray ${dash}${dashes.length > 1 ? ` ${gap}` : ""} and stroke-dashoffset ${offset} on pathLength ${pathLength}, but its ${cap} cap can still paint a dot at the end of the path (Chrome rounds the zero-length dash differently per curve).`,
|
|
5821
|
+
elementId: readAttr(tag.raw, "id") ?? void 0,
|
|
5822
|
+
fixHint: `Make the gap longer than the path (stroke-dasharray "${pathLength} ${+(pathLength * 1.2).toFixed(3)}" with stroke-dashoffset ${+(pathLength * 1.1).toFixed(3)}), or keep the element visibility:hidden until its draw tween starts.`,
|
|
5823
|
+
snippet: truncateSnippet(tag.raw)
|
|
5824
|
+
});
|
|
5825
|
+
}
|
|
5826
|
+
return findings;
|
|
5827
|
+
},
|
|
5797
5828
|
// svg_measure_before_path_d — getTotalLength() on a <path> that has no static `d`
|
|
5798
5829
|
// attribute in the HTML. In Chrome getTotalLength() on a d-less path returns 0,
|
|
5799
5830
|
// silently killing dash animations (offset 0 == length 0 == nothing to draw). If a
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hyperframes/lint",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.197",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/heygen-com/hyperframes",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"linkedom": "^0.18.12",
|
|
36
36
|
"postcss": "^8.5.8",
|
|
37
37
|
"postcss-selector-parser": "^7.1.4",
|
|
38
|
-
"@hyperframes/parsers": "0.8.
|
|
38
|
+
"@hyperframes/parsers": "0.8.197"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@types/node": "^25.0.10",
|