CLI 目录 横向对比 FCRS-1.0 标准 /llms.txt
← 返回 CLI 目录

ESLint

$ eslint 基金会 低风险
OpenJS Foundation · 代码托管与研发协同 · MIT · macos / linux / windows

OpenJS 基金会旗下的标准可扩展 JavaScript 与 TypeScript 静态分析工具。为 Agent 提供结构化 --format json 诊断、不写盘的 --fix-dry-run 预演以及 --no-color 纯净输出。

FCRS-1.0 综合评分
88 /100
良好 (Good)
中置信度 (源码/文档)
零摩擦安装命令
npm install -D eslint
CLI vs MCP 选型建议 仅 CLI 可用

直接在仓库工作区运行本地 AST 与 TypeScript-ESLint 规则,无需 MCP。

Agent 友好度体检单

✓ 原生 JSON 输出
— 字段裁剪
✓ 无头非交互
✓ 支持 Dry-Run
— 只读模式开关
✓ 支持 NO_COLOR
✓ 自省/Schema 发现
— 官方 SKILL.md

当前为静态评估(本机尚未安装或尚未运行探针)。可在本地运行 npm run data:probe 并提交 data/probes/ 升级为实测证据。

FCRS-1.0 六维评分拆解

Agent 友好度 22 / 25

原生支持 --format json、--fix-dry-run、--no-color、--quiet 与清晰退出码。

  • eslint --format json and --fix-dry-run provide structured JSON output
安全与权限边界 22 / 25

默认严格只读;--fix-dry-run 可在不改盘的情况下预览修复结果。

  • --fix-dry-run verifies edits before writing
安装与运行摩擦 13 / 15

跨平台 npm 包,依赖 Node.js 与项目配置文件(eslint.config.* 或 .eslintrc*)。

  • Runs everywhere Node.js is installed
能力覆盖与边际价值 13 / 15

拥有无可匹敌的插件生态(包括 typescript-eslint 类型感知规则),但在超大仓库上速度慢于 Rust 工具。

  • Supports thousands of framework and type-aware plugins
维护与来源背书 9 / 10

OpenJS 基金会以 MIT 协议长期稳定维护。

  • Maintained under OpenJS Foundation (eslint/eslint)
文档与可验证性 9 / 10

eslint.org 提供详尽的 CLI 与 Flat Config 官方文档。

  • Official CLI reference at eslint.org

安全边界、鉴权与放权指南

鉴权方式
无需鉴权
凭证存储位置

纯本地静态分析工具,不存储也不需要任何凭证。

潜在副作用
只读查询 本地写入
费用与配额提示

MIT 开源免费 npm 包。

可复制到 CLAUDE.md / AGENTS.md 的安全护栏
# ESLint (eslint) Agent Rules
- Always pass `--format json --no-color` when collecting diagnostics.
- Prefer `--fix-dry-run --format json` before `--fix` on unfamiliar codebases.
- Avoid `--no-eslintrc` / `--no-config-lookup` unless isolating a single rule.

Agent 高频安全命令配方

只读查询(安全推荐)

以 JSON 格式输出代码检查诊断
npx eslint --format json --no-color .

以 JSON 输出各文件的报错详情、规则 ID 与行列范围,不改动文件。

不写盘预演自动修复结果
npx eslint --fix-dry-run --format json .

在内存中计算自动修复结果并以 JSON 返回,不修改源文件。

受控写入与预演

应用 ESLint 自动修复
npx eslint --fix --no-color .

就地修复匹配文件中可自动修复的规则问题。

核心优势

  • + --fix-dry-run --format json 让 Agent 在改写文件前先审查拟应用的修复。
  • + --quiet 可过滤警告噪音,聚焦阻断性错误。
  • + 支持深度的 TypeScript 类型感知规则与框架插件。

注意事项与踩坑点

  • ! 在大型 Monorepo 上耗时明显高于 Rust 工具(oxlint、biome)。
  • ! Flat Config(eslint.config.js)与旧式 .eslintrc 过渡期偶有配置加载差异。

已验证兼容的 Agent 宿主

Claude Code Codex CLI Gemini CLI