@webto-id/variant-check 0.1.3 → 0.1.4
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/cli.js +9 -1
- package/dist/index.js +9 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -1153,6 +1153,13 @@ function lintNodes(nodes, ctx, ariaHidden = false) {
|
|
|
1153
1153
|
const hidden = ariaHidden || staticValue(n.attrs["aria-hidden"]) === "true";
|
|
1154
1154
|
for (const [k, v] of Object.entries(n.attrs)) lintAttr(k, v, tag, ctx);
|
|
1155
1155
|
if (tag === "img" && !("alt" in n.attrs)) push(ctx, "warning", "img-alt", "<img> without alt");
|
|
1156
|
+
if (/^h[1-4]$/.test(tag)) {
|
|
1157
|
+
const cls = staticValue(n.attrs.class);
|
|
1158
|
+
const style = staticValue(n.attrs.style);
|
|
1159
|
+
const pinned = typeof style === "string" && /font-size\s*:/i.test(style);
|
|
1160
|
+
const inert = typeof cls === "string" && !pinned ? cls.split(/\s+/).filter((c) => HEADING_SIZE_CLASS.test(c)) : [];
|
|
1161
|
+
if (inert.length) push(ctx, "warning", "heading-size-inert", `${inert.join(" ")} on <${tag}> has no effect: h1-h4 sizes follow the site theme (Style tab). Keep it as intent, or force a fixed size with !${inert[0]}, an inline style, or a non-heading tag`);
|
|
1162
|
+
}
|
|
1156
1163
|
if (tag === "a") {
|
|
1157
1164
|
const target = staticValue(n.attrs.target);
|
|
1158
1165
|
if (target === "_blank" && !("rel" in n.attrs)) n.attrs.rel = "noopener";
|
|
@@ -1207,6 +1214,7 @@ function checkUrl(name, v, tag, ctx) {
|
|
|
1207
1214
|
if (/^https?:\/\//i.test(s) && (name === "src" || name === "poster")) push(ctx, "warning", "hardcoded-image", `<${tag} ${name}> hardcodes an external URL \u2014 images should come from a content field`);
|
|
1208
1215
|
}
|
|
1209
1216
|
__name(checkUrl, "checkUrl");
|
|
1217
|
+
var HEADING_SIZE_CLASS = /^(?:[\w-]+:)*text-(?:xs|sm|base|lg|xl|\dxl|\[[^\]]+\])$/;
|
|
1210
1218
|
function lintHtml(root, sectionType2) {
|
|
1211
1219
|
const ctx = { lint: [], sectionType: sectionType2, inButton: 0, inSvg: 0 };
|
|
1212
1220
|
lintNodes(root, ctx);
|
|
@@ -1758,7 +1766,7 @@ function deriveSchema(fields, props, base2) {
|
|
|
1758
1766
|
__name(deriveSchema, "deriveSchema");
|
|
1759
1767
|
|
|
1760
1768
|
// ../variant-compiler/src/index.ts
|
|
1761
|
-
var COMPILER_VERSION = "0.1.
|
|
1769
|
+
var COMPILER_VERSION = "0.1.4";
|
|
1762
1770
|
var IR_MAX_BYTES = 256 * 1024;
|
|
1763
1771
|
var CSS_MAX_BYTES = 64 * 1024;
|
|
1764
1772
|
var STRICT_CODES = /* @__PURE__ */ new Set(["dead-text", "hardcoded-color", "hardcoded-radius", "hardcoded-font", "hardcoded-image", "img-alt", "props-optional", "tailwind-skipped"]);
|
package/dist/index.js
CHANGED
|
@@ -1150,6 +1150,13 @@ function lintNodes(nodes, ctx, ariaHidden = false) {
|
|
|
1150
1150
|
const hidden = ariaHidden || staticValue(n.attrs["aria-hidden"]) === "true";
|
|
1151
1151
|
for (const [k, v] of Object.entries(n.attrs)) lintAttr(k, v, tag, ctx);
|
|
1152
1152
|
if (tag === "img" && !("alt" in n.attrs)) push(ctx, "warning", "img-alt", "<img> without alt");
|
|
1153
|
+
if (/^h[1-4]$/.test(tag)) {
|
|
1154
|
+
const cls = staticValue(n.attrs.class);
|
|
1155
|
+
const style = staticValue(n.attrs.style);
|
|
1156
|
+
const pinned = typeof style === "string" && /font-size\s*:/i.test(style);
|
|
1157
|
+
const inert = typeof cls === "string" && !pinned ? cls.split(/\s+/).filter((c) => HEADING_SIZE_CLASS.test(c)) : [];
|
|
1158
|
+
if (inert.length) push(ctx, "warning", "heading-size-inert", `${inert.join(" ")} on <${tag}> has no effect: h1-h4 sizes follow the site theme (Style tab). Keep it as intent, or force a fixed size with !${inert[0]}, an inline style, or a non-heading tag`);
|
|
1159
|
+
}
|
|
1153
1160
|
if (tag === "a") {
|
|
1154
1161
|
const target = staticValue(n.attrs.target);
|
|
1155
1162
|
if (target === "_blank" && !("rel" in n.attrs)) n.attrs.rel = "noopener";
|
|
@@ -1204,6 +1211,7 @@ function checkUrl(name, v, tag, ctx) {
|
|
|
1204
1211
|
if (/^https?:\/\//i.test(s) && (name === "src" || name === "poster")) push(ctx, "warning", "hardcoded-image", `<${tag} ${name}> hardcodes an external URL \u2014 images should come from a content field`);
|
|
1205
1212
|
}
|
|
1206
1213
|
__name(checkUrl, "checkUrl");
|
|
1214
|
+
var HEADING_SIZE_CLASS = /^(?:[\w-]+:)*text-(?:xs|sm|base|lg|xl|\dxl|\[[^\]]+\])$/;
|
|
1207
1215
|
function lintHtml(root, sectionType) {
|
|
1208
1216
|
const ctx = { lint: [], sectionType, inButton: 0, inSvg: 0 };
|
|
1209
1217
|
lintNodes(root, ctx);
|
|
@@ -1755,7 +1763,7 @@ function deriveSchema(fields, props, base) {
|
|
|
1755
1763
|
__name(deriveSchema, "deriveSchema");
|
|
1756
1764
|
|
|
1757
1765
|
// ../variant-compiler/src/index.ts
|
|
1758
|
-
var COMPILER_VERSION = "0.1.
|
|
1766
|
+
var COMPILER_VERSION = "0.1.4";
|
|
1759
1767
|
var IR_MAX_BYTES = 256 * 1024;
|
|
1760
1768
|
var CSS_MAX_BYTES = 64 * 1024;
|
|
1761
1769
|
var STRICT_CODES = /* @__PURE__ */ new Set(["dead-text", "hardcoded-color", "hardcoded-radius", "hardcoded-font", "hardcoded-image", "img-alt", "props-optional", "tailwind-skipped"]);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webto-id/variant-check",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"description": "Lint, compile and preview a Webto Variant Format (.astro subset) section variant with the exact compiler the webto.id marketplace uses.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|