输出格式
Oxlint 支持多种输出格式,用于输出语法检查结果。这些格式可用于与各种 CI 系统或其他工具集成。
您可以在通过 CLI 运行 Oxlint 时,使用 --format(或 -f)选项指定所需的格式。
可用格式
--format=default
如果未指定任何格式,则此为默认输出格式。
x eslint(no-debugger): `debugger` 语句不允许使用
╭─[test.js:5:1]
4 │
5 │ debugger;
· ─────────
6 │
╰────
help: 移除 debugger 语句
找到 0 个警告和 1 个错误。
在 1 个文件上使用 2 条规则和 1 个线程,耗时 6ms。--format=checkstyle
输出 Checkstyle XML 格式,可被某些 CI 工具解析。
xml
<?xml version="1.0" encoding="utf-8"?>
<checkstyle version="4.3">
<file name="test.js">
<error line="5" column="1" severity="error" message="`debugger` 语句不允许使用" source="eslint(no-debugger)" />
</file>
</checkstyle>--format=github
此格式专为 GitHub Actions 及 GitHub 的 注释功能 设计。
::error file=test.js,line=5,endLine=5,col=1,endColumn=10,title=eslint(no-debugger)::`debugger` 语句不允许使用--format=gitlab
此格式专为 GitLab CI 及 GitLab 的代码质量功能 设计。
json
[
{
"description": "`debugger` 语句不允许使用",
"check_name": "eslint(no-debugger)",
"fingerprint": "9333a3278325994",
"severity": "critical",
"location": {
"path": "test.js",
"lines": {
"begin": 5,
"end": 5
}
}
}
]--format=json
通用的 JSON 输出格式,也可与 --rules 一起使用,以获取所有 Oxlint 规则的 JSON 格式列表。
json
{
"diagnostics": [
{
"message": "`debugger` 语句不允许使用",
"code": "eslint(no-debugger)",
"severity": "error",
"causes": [],
"url": "https://oxc.rs/docs/guide/usage/linter/rules/eslint/no-debugger.html",
"help": "移除 debugger 语句",
"filename": "test.js",
"labels": [
{
"span": {
"offset": 38,
"length": 9,
"line": 5,
"column": 1
}
}
],
"related": []
}
],
"number_of_files": 1,
"number_of_rules": 2,
"threads_count": 1,
"start_time": 0.018611917
}--format=junit
输出 JUnit XML 格式,适用于支持 JUnit 报告的 CI 系统,例如 GitLab CI 或 Bitbucket Pipelines。
xml
<?xml version="1.0" encoding="UTF-8"?>
<testsuites name="Oxlint" tests="1" failures="0" errors="1">
<testsuite name="test.js" tests="1" disabled="0" errors="1" failures="0">
<testcase name="eslint(no-debugger)">
<error message="`debugger` 语句不允许使用">line 5, column 1, `debugger` 语句不允许使用</error>
</testcase>
</testsuite>
</testsuites>--format=stylish
Stylish 是 ESLint 的默认输出格式,适合紧凑且易于阅读的人类可读输出。
test.js
5:1 error `debugger` 语句不允许使用 eslint(no-debugger)
✖ 1 个问题(1 个错误,0 个警告)--format=unix
一种基础的单行格式。
test.js:5:1: `debugger` 语句不允许使用 [Error/eslint(no-debugger)]
1 个问题