diff
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseDefault branch: !
git symbolic-ref refs/remotes/origin/HEAD --short 2>/dev/null | sed 's|.*/||' || echo mainReport only what changed. Locate; don't fix. If no URL in , ask for one.
$ARGUMENTSParse : strip if present → branch mode. If has no value, use the default branch above. Remainder is the URL.
$ARGUMENTS--branch <name>--branch默认分支:!
git symbolic-ref refs/remotes/origin/HEAD --short 2>/dev/null | sed 's|.*/||' || echo main仅报告变更内容。定位问题;不自动修复。如果中未包含URL,则提示用户输入。
$ARGUMENTS解析:如果存在参数则移除该部分,进入分支模式。如果未指定值,则使用上述默认分支。剩余部分即为URL。
$ARGUMENTS--branch <name>--branch1. Audit
1. 审计
bash
PORT=$(npx -y @accesslint/chrome@latest ensure | node -e 'process.stdin.on("data",d=>process.stdout.write(""+JSON.parse(d).port))')Stash mode (default — uncommitted changes). Tell the user first: "Running in diff mode — stashing your changes to capture a baseline, then restoring. Your working tree will be fully restored." If fails, warn and exit.
git stash pushbash
git stash push -u -m "accesslint-diff-baseline"
npx -y @accesslint/cli@latest "<url>" --port "$PORT" --snapshot accesslint-diff --snapshot-dir /tmp --update-snapshot
git stash pop && sleep 2
npx -y @accesslint/cli@latest "<url>" --port "$PORT" --snapshot accesslint-diff --snapshot-dir /tmp --format jsonBranch mode (). Tell the user first: "Diffing against — checking out that branch to capture a baseline, then restoring. Your working tree will be fully restored."
--branch <name><name>Branch switching triggers a rebuild but not a browser reload — the CLI opens a fresh tab each time so it always reads the current build. Use to gate the audit until the rebuild is ready; without it, warn the user that a slow build may yield a stale baseline.
--wait-for "<selector>"bash
git diff --quiet && git diff --cached --quiet || git stash push -u -m "accesslint-diff-branch"
git checkout <branch>
npx -y @accesslint/cli@latest "<url>" --port "$PORT" --snapshot accesslint-diff --snapshot-dir /tmp --update-snapshot [--wait-for "<selector>"]
git checkout - && git stash pop 2>/dev/null
npx -y @accesslint/cli@latest "<url>" --port "$PORT" --snapshot accesslint-diff --snapshot-dir /tmp --format json [--wait-for "<selector>"]Pass , to both runs.
--selector--include-aaabash
PORT=$(npx -y @accesslint/chrome@latest ensure | node -e 'process.stdin.on("data",d=>process.stdout.write(""+JSON.parse(d).port))')暂存模式(默认——针对未提交的更改)。首先告知用户:「正在运行对比模式——将暂存您的更改以获取基线,之后会恢复您的工作区。您的工作树将完全恢复。」如果执行失败,则发出警告并退出。
git stash pushbash
git stash push -u -m "accesslint-diff-baseline"
npx -y @accesslint/cli@latest "<url>" --port "$PORT" --snapshot accesslint-diff --snapshot-dir /tmp --update-snapshot
git stash pop && sleep 2
npx -y @accesslint/cli@latest "<url>" --port "$PORT" --snapshot accesslint-diff --snapshot-dir /tmp --format json分支模式()。首先告知用户:「正在与分支进行对比——将检出该分支以获取基线,之后会恢复您的工作区。您的工作树将完全恢复。」
--branch <name><name>分支切换会触发重建,但不会刷新浏览器——CLI每次都会打开一个新标签页,以确保始终读取当前构建结果。使用参数来等待重建完成后再执行审计;如果未使用该参数,则需提醒用户:构建速度过慢可能会导致基线数据过时。
--wait-for "<selector>"bash
git diff --quiet && git diff --cached --quiet || git stash push -u -m "accesslint-diff-branch"
git checkout <branch>
npx -y @accesslint/cli@latest "<url>" --port "$PORT" --snapshot accesslint-diff --snapshot-dir /tmp --update-snapshot [--wait-for "<selector>"]
git checkout - && git stash pop 2>/dev/null
npx -y @accesslint/cli@latest "<url>" --port "$PORT" --snapshot accesslint-diff --snapshot-dir /tmp --format json [--wait-for "<selector>"]将、参数传递给两次审计运行。
--selector--include-aaa2. Report
2. 报告
Accessibility diff — http://localhost:3000/ vs main (94 rules, live DOM)
2 new · 1 fixed · 4 pre-existing hidden
New — Critical
- color-contrast — 2.1:1 (needs 4.5:1), #bbb on #fff
where: main > p.subtitle fix: darken to #767676
Fixed
- img-alt — <img src="old.jpg"> (no longer present)Each new violation: where (selector verbatim + if present — never fabricate), evidence, fix (mechanical change or ).
file:line (symbol)sourceNEEDS HUMANDon't edit. For fixes: apply mechanical ones then re-run to verify; for bulk work hand off to .
accesslint:diffaccesslint:auditAccessibility diff — http://localhost:3000/ vs main (94 rules, live DOM)
2 new · 1 fixed · 4 pre-existing hidden
New — Critical
- color-contrast — 2.1:1 (needs 4.5:1), #bbb on #fff
where: main > p.subtitle fix: darken to #767676
Fixed
- img-alt — <img src="old.jpg"> (no longer present)每个新增违规需包含:位置(原始选择器 + 若存在则添加——切勿编造)、证据、修复方案(自动修复建议或(需人工处理))。
sourcefile:line (symbol)NEEDS HUMAN请勿编辑结果。对于修复:先应用自动修复建议,然后重新运行进行验证;对于批量修复工作,请使用。
accesslint:diffaccesslint:audit3. Tear down
3. 清理
bash
npx -y @accesslint/chrome@latest stop --all # skip if ensure reported "managed":falsebash
npx -y @accesslint/chrome@latest stop --all # skip if ensure reported "managed":falseGotchas
注意事项
- always determines the port — never hardcode 9222.
ensure - CLI exit 2 = bad URL or page never loaded; check the dev server.
- Stash mode: covers most HMR cases; if baseline looks identical to current, add
sleep 2.--wait-for "<selector>" - Branch mode: no HMR — CLI opens a fresh tab each run. is the rebuild gate.
--wait-for - Heavy DOM changes between runs cause selector drift — re-run with for the full picture.
accesslint:scan
- 命令会自动确定端口——切勿硬编码为9222。
ensure - CLI退出码2表示URL无效或页面未加载;请检查开发服务器。
- 暂存模式:可覆盖大多数HMR(热模块替换)场景;如果基线与当前页面看起来完全一致,请添加
sleep 2参数。--wait-for "<selector>" - 分支模式:无HMR——CLI每次运行都会打开一个新标签页。是等待重建完成的关键参数。
--wait-for - 两次运行之间DOM发生大量变更会导致选择器偏移——请使用重新运行以获取完整结果。
accesslint:scan