TypeScript + ESLint ESLint + Node.js+ npm+ @typescript-eslint/parser+ @typescript-eslint/eslint-plugin+ @typescript-eslint/typescript-estree

让 ESLint 获得解析与检查 TypeScript 代码的静态分析能力

parser 负责把 TS 解析为 ESTree AST,estree 提供底层解析,plugin 提供规则,三者使 ESLint 支持 TS

✓ MIT 宽松许可✓ 文档齐全持续维护

方案简介

typescript-eslint 是一个 monorepo,汇集了让 ESLint 支持 TypeScript 所需的全部工具。它的目标是让开发者可以在 TypeScript 项目中继续使用 ESLint 这一通行的静态分析工具,对 JavaScript 和 TypeScript 代码进行强大的静态分析。对于已经在使用 ESLint 的 JavaScript 团队、以及希望对 TS 代码做 lint 检查的工程团队来说,这套方案是标准选择。项目采用宽松的 MIT 许可证发布,文档托管在 typescript-eslint.io,最新版本与 canary 版本文档均可在线查阅。

亮点与能力

  • 对 JavaScript 和 TypeScript 都提供强大的静态分析
  • 通过 parser 使 ESLint 能解析 TypeScript 语法
  • 通过 eslint-plugin 提供 TS 专用检查规则
  • monorepo 形式拆分为 parser / plugin / utils / scope-manager / typescript-estree 等多个可独立使用的包
  • 提供最新版本与 canary 版本的在线文档
  • 采用 MIT 宽松许可

组成与分工

  • ESLint:静态分析引擎,负责规则的调度与代码检查
  • TypeScript:被支持的目标语言,同时项目本身也依赖 typescript
  • @typescript-eslint/parser:ESLint 解析器,让 ESLint 能解析 TS 代码
  • @typescript-eslint/typescript-estree:底层解析能力,把 TS 转成 ESTree 兼容 AST
  • @typescript-eslint/eslint-plugin:提供 TS 专用 lint 规则
  • @typescript-eslint/utils / scope-manager / types:支撑 parser 与 plugin 的工具与类型包

注意事项与常见问题

  • 项目使用 versioning 机制区分 latest released version 与 canary release,使用时注意文档版本对应关系
  • 许可证为 MIT,typescript-eslint 继承该许可
  • 社区支持通过 OpenCollective 接受财务贡献

优缺点

  • ✓ MIT 宽松许可
  • ✓ 文档齐全持续维护

出处

本方案挖掘自开源项目 typescript-eslint/typescript-eslint,方案内容与实施命令均来自其 README 原文。

方案出处
typescript-eslint/typescript-eslint::sparkles: Monorepo for all the tooling which enables ESLint to support TypeScri
16390 star :sparkles: Monorepo for all the tooling which enables ESLint to support TypeScript

本方案由真实开源项目挖掘整理,实施命令均来自其 README 原文,安装使用请遵循项目开源协议。