@a11y-lens/cli 0.4.0 → 0.4.1
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/README.md +10 -0
- package/package.json +1 -1
- package/src/staged.mjs +11 -5
package/README.md
CHANGED
|
@@ -31,6 +31,16 @@ husky - pre-commit hook exited with code 1
|
|
|
31
31
|
|
|
32
32
|
**Infrastructure never blocks a commit.** No agent CLI, no network, agent crash → a11y-lens warns and exits 0. Only real accessibility findings gate.
|
|
33
33
|
|
|
34
|
+
## It samples; it does not audit
|
|
35
|
+
|
|
36
|
+
a11y-lens is an AI reviewer, not a deterministic linter. The same files reviewed twice can return different findings — even zero on a run that flagged issues a moment earlier. Read the output with that in mind:
|
|
37
|
+
|
|
38
|
+
- **A clean run ≠ zero issues.** It means nothing surfaced *in that sample*, not that the code is fully accessible.
|
|
39
|
+
- **Findings don't converge to zero.** Re-running to "clear" every last warning is the wrong mental model; a later run may raise something new.
|
|
40
|
+
- **The intended job is gating `--staged` diffs** — catching problems as they're *introduced*. It is not a full-audit tool for an existing codebase; for that, pair it with a human accessibility review.
|
|
41
|
+
|
|
42
|
+
This is deliberate: only clear `error`-severity violations gate and warnings never block, precisely because AI output varies run to run. (This note belongs here, in the tool's own README — not in the `AGENTS.md` rules block that `init` injects into a consuming project, which is reserved for the accessibility rules themselves.)
|
|
43
|
+
|
|
34
44
|
## Install
|
|
35
45
|
|
|
36
46
|
a11y-lens has two layers — install either or both:
|
package/package.json
CHANGED
package/src/staged.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { execFileSync } from 'node:child_process';
|
|
2
|
+
import { readFileSync } from 'node:fs';
|
|
2
3
|
|
|
3
4
|
const UI_EXTENSIONS = new Set([
|
|
4
5
|
'.jsx', '.tsx', '.html', '.htm', '.vue', '.svelte', '.astro', '.mdx',
|
|
@@ -72,12 +73,17 @@ export function collectPathArgs(paths) {
|
|
|
72
73
|
for (const path of paths) {
|
|
73
74
|
let content;
|
|
74
75
|
try {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
});
|
|
76
|
+
// readFileSync (not a `cat` shell-out): portable to Windows, and filenames
|
|
77
|
+
// that start with `-` are never mistaken for flags.
|
|
78
|
+
content = readFileSync(path, 'utf8');
|
|
79
79
|
} catch {
|
|
80
|
-
|
|
80
|
+
// An unreadable argument that contains whitespace is almost always several
|
|
81
|
+
// paths the shell never word-split (e.g. an unquoted joined variable in zsh)
|
|
82
|
+
// delivered as one argument. Surface that instead of silently skipping.
|
|
83
|
+
const skipped = /\s/.test(path)
|
|
84
|
+
? 'looks like several paths passed as one argument — pass each file as a separate, unquoted argument (in zsh, check array/glob expansion)'
|
|
85
|
+
: 'unreadable';
|
|
86
|
+
files.push({ path, skipped });
|
|
81
87
|
continue;
|
|
82
88
|
}
|
|
83
89
|
if (Buffer.byteLength(content, 'utf8') > MAX_FILE_BYTES) {
|