@accesslint/cli

中文文档
0.13.0发布于 2026/08/23MITES Module构建来源已验证近 30 天下载 7917

使用 @ accesslint/ core 来审计 HTML 访问的 CLI 工具

中文使用文档
文档目录6 节
  1. scan ——审计
  2. 来源
  3. 选项
  4. 退出代码
  5. 实例
  6. init 脚手架配置

@ accesslint/ cli (英语)

使用 CLI 来审计 HTML 访问工具 @ accesslint/ 核心。 。 。 .

npx -y @accesslint/cli scan [source] [options]   # audit a URL, HTML file, or stdin
npx -y @accesslint/cli init                       # scaffold accesslint.config.json

v0.8 — 突破变化. 审计现以 scan 子命令 : 运行 accesslint scan <source> (先前为 accesslint <source>) (中文(简体) ).

scan ——审计

来源

# Audit a local file
npx -y @accesslint/cli scan index.html

# Audit a URL (requires a debuggable Chrome; start one first)
npx @accesslint/chrome ensure
npx -y @accesslint/cli scan https://example.com

# Pipe HTML via stdin
curl -s https://example.com | npx -y @accesslint/cli scan

# Audit a named target from accesslint.config.json (see `init` below)
npx -y @accesslint/cli scan dev

非URL、非文件论证作为 目标名称 从 accesslint.config.json (地方重叠优先),扩大到目标 url 和选项; 明确 旗帜覆盖目标。 与 没有 参数,配置 default 目标被审计。 一个 未知名称列出可用的目标 。 在有配置的工程中管道 HTML, 通过 --stdin。 。 。 .

选项

-f, --format <fmt>    Output format: text, json, sarif (default: text)
--pretty              Pretty-print json/sarif output (default: single line)
--include-aaa         Include AAA-level rules
-d, --disable <ids>   Comma-separated rule IDs to disable
-h, --help            Show help
--version             Show version

URL审计连接到 CDP 上的可调试的 Chrome. 开始一个 npx @accesslint/chrome ensure,然后通过与默认不同的端口.

-p, --port <n>          CDP port (URL audits only, default: 9222)
--host <host>           CDP host (URL audits only, default: 127.0.0.1)
-s, --selector <sel>    CSS selector to scope the audit; auto-waits for element (URL only)
--wait-for <s>          Selector or visible text to wait for before auditing (URL only)
--wait-timeout <ms>     Max ms to wait for --wait-for or --selector (default: 10000)
--attach                Only attach to an existing tab matching the URL; fail if not found
--snapshot <name>       Snapshot name — fail only on violations new since baseline (URL only)
--snapshot-dir <dir>    Directory for snapshot files (default: ./accessibility-snapshots)
--update-snapshot       Force-overwrite the snapshot baseline (also: ACCESSLINT_UPDATE=1)

退出代码

代码含义
0 个无违反规定行为
1个查明的侵犯行为
2个错误

实例

# Text output with colors
echo '<img src="photo.jpg">' | npx -y @accesslint/cli scan

# JSON output
npx -y @accesslint/cli scan --format json index.html

# SARIF for GitHub code scanning (upload via github/codeql-action/upload-sarif)
npx -y @accesslint/cli scan --format sarif https://localhost:3000 > accesslint.sarif

# Audit a fragment — page-level rules (document-title, html-has-lang) are skipped automatically
echo '<button></button>' | npx -y @accesslint/cli scan

# Disable specific rules
npx -y @accesslint/cli scan -d "landmarks/region,navigable/bypass" index.html

# Snapshot mode — capture a baseline; fail only on new violations
npx -y @accesslint/cli scan --snapshot main https://example.com

init 脚手架配置

npx -y @accesslint/cli init        # interactive, framework-aware defaults
npx -y @accesslint/cli init --yes  # accept the defaults (CI / non-interactive)

写作 accesslint.config.json 审计名称 目标,加一个被点缀 accesslint.config.local.json 叠接/粘接。 默认从您的 package.json: 框架设置了 dev 端口(一个明确的 -p编号 :--port 输入 dev 脚本 ) (中文(简体). 没有端口扫描 。 故事书目标 没有 默认添加-通过 --storybook (或在检测到"故事本"时在提示时选择加入);其URL在发现时被预填.

// accesslint.config.json
{
  "default": "dev",
  "targets": {
    "dev": { "url": "http://localhost:5173" },
    "storybook": { "url": "http://localhost:6006" },
  },
}

每一个目标都带有与 scan 旗帜(url, (中文(简体) ), selector, (中文(简体) ), waitFor, (中文(简体) ), includeAAA, (中文(简体) ), disable, (中文(简体) ), snapshotDir因此,目标是一个充分具体的审计背景.

-y, --yes               Accept framework-aware defaults without prompting
--dev-url <url>         Override the inferred dev URL
--storybook             Add a Storybook target
--skip-storybook        Do not add a Storybook target
--prod-url <url>        Prod/staging URL (written to the gitignored overlay)
--default <name>        Name of the default target (default: dev)
--force                 Overwrite an existing accesslint.config.json
--cwd <dir>             Project directory (default: current directory)

版本与发布记录

@accesslint/cli 共发布 27 个版本,首次发布于 2026/02/24;过去 12 个月发布了 27 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.13.0latest2026/08/232 个月前
0.12.02026/07/213 个月前
0.11.12026/07/213 个月前
0.11.02026/07/203 个月前
0.10.02026/06/055 个月前
0.9.02026/06/045 个月前

关于 @accesslint/cli 的常见问题

@accesslint/cli 是什么?

使用 @ accesslint/ core 来审计 HTML 访问的 CLI 工具

如何安装 @accesslint/cli?

在项目目录运行 npm install @accesslint/cli,或使用 pnpm add / yarn add / bun add。它还提供命令行工具 accesslint,可以用 npx accesslint 直接运行。

@accesslint/cli 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/accesslint__cli 是否存在。

@accesslint/cli 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@accesslint/cli 可以商用吗?

@accesslint/cli 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@accesslint/cli 的下载量有多少?

根据 npm 官方下载统计,@accesslint/cli 在 2026/10/05 – 2026/11/03 这 30 天内被下载 7,917 次,日均约 264 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@accesslint/cli 还在维护吗?

最新版本 0.13.0 发布于 2026/08/23(2 个月前);至今共发布 27 个版本,其中过去 12 个月发布了 27 个;首次发布于 2026/02/24。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。