periderm-cli 0.1.38 → 0.1.40
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/constants.js +7 -8
- package/dist/index.js +0 -0
- package/dist/scanner/checks.js +41 -5
- package/package.json +1 -1
package/dist/constants.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
export const PERIDERM_ASCII = String.raw `
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|__/ \_______/|__/ |__/ \_______/ \_______/|__/ |__/ |__/ |__/
|
|
2
|
+
░▒▓███████▓▒░░▒▓████████▓▒░▒▓███████▓▒░░▒▓█▓▒░▒▓███████▓▒░░▒▓████████▓▒░▒▓███████▓▒░░▒▓██████████████▓▒░
|
|
3
|
+
░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░░▒▓█▓▒░
|
|
4
|
+
░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░░▒▓█▓▒░
|
|
5
|
+
░▒▓███████▓▒░░▒▓██████▓▒░ ░▒▓███████▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓██████▓▒░ ░▒▓███████▓▒░░▒▓█▓▒░░▒▓█▓▒░░▒▓█▓▒░
|
|
6
|
+
░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░░▒▓█▓▒░
|
|
7
|
+
░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░░▒▓█▓▒░
|
|
8
|
+
░▒▓█▓▒░ ░▒▓████████▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░▒▓███████▓▒░░▒▓████████▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░░▒▓█▓▒░
|
|
10
9
|
`;
|
package/dist/index.js
CHANGED
|
File without changes
|
package/dist/scanner/checks.js
CHANGED
|
@@ -756,12 +756,48 @@ const formInputNoLabel = (source, file) => {
|
|
|
756
756
|
return out;
|
|
757
757
|
if (isInternalSurface(file))
|
|
758
758
|
return out;
|
|
759
|
-
|
|
759
|
+
// Match opening tag start positions, then extract attrs from the raw source window
|
|
760
|
+
const tagStartRe = /<(input|select|textarea)\b/g;
|
|
760
761
|
let m;
|
|
761
762
|
let reported = 0;
|
|
762
|
-
while ((m =
|
|
763
|
+
while ((m = tagStartRe.exec(source)) && reported < 3) {
|
|
763
764
|
const tag = m[1];
|
|
764
|
-
|
|
765
|
+
// Walk forward char-by-char, skipping over quoted attribute values so we
|
|
766
|
+
// don't confuse the > inside `(e) => ...` with the tag's closing >.
|
|
767
|
+
let i = m.index + m[0].length;
|
|
768
|
+
let inStr = null;
|
|
769
|
+
let closeIdx = -1;
|
|
770
|
+
while (i < source.length && i < m.index + 1200) {
|
|
771
|
+
const ch = source[i];
|
|
772
|
+
if (inStr) {
|
|
773
|
+
if (ch === inStr && source[i - 1] !== '\\')
|
|
774
|
+
inStr = null;
|
|
775
|
+
}
|
|
776
|
+
else if (ch === '"' || ch === "'" || ch === '`') {
|
|
777
|
+
inStr = ch;
|
|
778
|
+
}
|
|
779
|
+
else if (ch === '{') {
|
|
780
|
+
// Skip balanced braces (JSX expression attributes like onChange={...})
|
|
781
|
+
let depth = 1;
|
|
782
|
+
i++;
|
|
783
|
+
while (i < source.length && depth > 0) {
|
|
784
|
+
if (source[i] === '{')
|
|
785
|
+
depth++;
|
|
786
|
+
else if (source[i] === '}')
|
|
787
|
+
depth--;
|
|
788
|
+
i++;
|
|
789
|
+
}
|
|
790
|
+
continue;
|
|
791
|
+
}
|
|
792
|
+
else if (ch === '>') {
|
|
793
|
+
closeIdx = i;
|
|
794
|
+
break;
|
|
795
|
+
}
|
|
796
|
+
i++;
|
|
797
|
+
}
|
|
798
|
+
if (closeIdx < 0)
|
|
799
|
+
continue;
|
|
800
|
+
const attrs = source.slice(m.index, closeIdx + 1);
|
|
765
801
|
if (/type\s*=\s*["'](hidden|submit|button|image|reset)["']/.test(attrs))
|
|
766
802
|
continue;
|
|
767
803
|
if (/aria-label\s*=|aria-labelledby\s*=/.test(attrs))
|
|
@@ -775,13 +811,13 @@ const formInputNoLabel = (source, file) => {
|
|
|
775
811
|
}
|
|
776
812
|
// wrapping <label> ... <input .../> ... </label>
|
|
777
813
|
const before = source.slice(Math.max(0, m.index - 400), m.index);
|
|
778
|
-
const after = source.slice(
|
|
814
|
+
const after = source.slice(closeIdx + 1, closeIdx + 1 + 300);
|
|
779
815
|
if (/<label\b[^>]*>[^<]*$/.test(before) && /^[^<]*<\/label>/.test(after))
|
|
780
816
|
continue;
|
|
781
817
|
out.push(mkFinding({
|
|
782
818
|
id: "input-no-label",
|
|
783
819
|
category: "Accessibility",
|
|
784
|
-
severity: "
|
|
820
|
+
severity: "medium",
|
|
785
821
|
file, line: lineOf(source, m.index),
|
|
786
822
|
message: `<${tag}> has no associated <label> or aria-label.`,
|
|
787
823
|
why: "Screen readers announce the field with no name. Disabled users have no idea what to type. Violates WCAG 2.1 SC 1.3.1 & 3.3.2.",
|
package/package.json
CHANGED