jetlint/jetlint

GitHub: jetlint/jetlint

jetlint 是一个用 Go 构建的高性能 TypeScript 类型感知 linter,通过 daemon 模式实现毫秒级增量检查,与 typescript-eslint 的 67 条规则达到 100% 测试兼容。

Stars: 1 | Forks: 0

# jetlint **网站及文档:** https://jetlint.github.io jetlint 是一个基于 Go 构建的 linter,底层使用了 TypeScript 7 原生编译器 ([microsoft/typescript-go][tsgo])。它将 typescript-eslint 的 类型感知规则移植到了一个长驻的 daemon 模型中,只需付出一次加载 TypeScript 的代价,即可在几毫秒内返回后续的 lint 结果。 **状态:** pre-1.0。诊断结果真实有效,并已根据 typescript-eslint 发布的测试夹具进行了验证(目前为 6193/6193 用例, 100%)。CLI 接口和配置 schema 可能仍会发生变动。 ## 亮点 - **67 条规则**:61 条移植自 typescript-eslint 的类型感知规则,外加 6 条 非类型感知的正确性规则(移植自 ESLint 核心:`no-dupe-keys`、`no-duplicate-case`、`no-self-assign`、`no-self-compare`、 `use-isnan`、`valid-typeof`)。 - **6193/6193 个 typescript-eslint 测试夹具通过** — 提供与 typescript-eslint 完全一致的 诊断结果,字节级精确。 - **原生检查器:** 基于 TypeScript 7 原生 构建,而非 用于替代类型查询的 AST 启发式算法。 - **长驻 daemon:** 程序和检查器在多次运行期间保持活跃状态;重新 lint 可在几毫秒内返回结果。 - **可预测的配置:** 出现未知选项键时,将以代码 `2` 退出并附带一条 结构化错误信息。 ## 安装(从源码) 需要 **Go 1.26+**。 ``` go install github.com/jetlint/jetlint/cmd/jetlint@latest ``` 预构建的二进制分发版将在接近 1.0 版本发布时提供。 `go.mod` 通过 `replace` 指令固定使用 [jetlint/typescript-go][tsgo-fork],因为 jetlint 所依赖的包装器 API 尚未合入 [microsoft/typescript-go][tsgo]。该固定使用的是带有标签的发布版本,而 不是本地 checkout,因此 `go install` 和全新克隆无需额外 设置即可完成构建。 ## 运行 ``` jetlint --project ./tsconfig.json ``` **5 条 MVP 规则**默认为 `error`。其余 **56 条规则**默认为 `off` — 可通过 [`.jetlintrc.json`](https://jetlint.github.io/config/) 按需启用。 ## 配置 项目根目录下的 `.jetlintrc.json`: ``` { "rules": { "no-array-delete": "error", "only-throw-error": ["error", { "allowThrowingAny": false }] } } ``` 完整 schema 请参阅[配置文档](https://jetlint.github.io/config/)。 ## 兼容性 针对 typescript-eslint 已发布测试夹具的每条规则得分位于 [`docs/TSEC-COMPAT-OVERVIEW.md`](docs/TSEC-COMPAT-OVERVIEW.md)。所有 61 条 typescript-eslint 移植规则目前均达到了 100%。六条 ESLint 核心 移植规则(`no-dupe-keys`、`no-duplicate-case`、`no-self-assign`、 `no-self-compare`、`use-isnan`、`valid-typeof`)附带了手工编写的 单元测试,因为 ESLint 核心并未发布机器可读的 测试夹具格式。 复现单条规则的得分: ``` go test -count=1 -run TypescriptEslintCompatibility -v \ ./internal/rules// ``` ## 仓库结构 ``` cmd/ jetlint/ CLI entrypoint probe/ diagnostic helper internal/ engine/ single AST walk, dispatches to rules rules/ 67 rule implementations (one package each) daemon/ long-lived sidecar (JSON-RPC over stdio) transport/ JSON-RPC framing cli/ argv parsing, exit codes config/ .jetlintrc.json parser format/ diagnostic output formatters project/ tsconfig resolution bootstrap/ Program loading architecture/ cross-package layering checks tselintcompat/ upstream test-fixture loader (the 6193 cases) toolerr/ exit-code-bearing error types testdata/ vendored typescript-eslint fixtures docs/ per-rule compat notes plans/ plan files (historical record) features/ living Gherkin specs ``` ## 许可证 MIT — 详见 [LICENSE](LICENSE)。
标签:DNS解析, eslint, EVTX分析, Go语言, Linter, pptx, TypeScript, TypeScript 7, typescript-eslint, 代码审查, 代码检查工具, 代码规范, 后端服务, 威胁情报, 守护进程, 安全插件, 开发者工具, 开源项目, 日志审计, 程序破解, 类型感知, 类型检查, 编译器, 脚本检测, 错误基检测, 静态代码分析, 静态检查