Skip to content

输出格式

🌐 Output formats

Oxlint 支持多种输出格式来输出 lint 结果。这些格式可用于与各种 CI 系统或其他工具集成。

🌐 Oxlint supports multiple output formats for emitting lint results. These can be used to integrate with various CI systems or other tools.

在从命令行运行 Oxlint 时,你可以使用 --format(或 -f)选项来指定所需的格式。

🌐 You can specify the desired format using the --format (or -f) option when running Oxlint from the CLI.

可用格式

🌐 Available formats

--format=default

如果没有指定输出格式,这就是默认的输出格式。

🌐 This is the default output format if none is specified.

  x eslint(no-debugger): `debugger` statement is not allowed
    ╭─[test.js:5:1]
  4 │
  5 │ debugger;
    · ─────────
  6 │
    ╰────
  help: Remove the debugger statement

Found 0 warnings and 1 error.
Finished in 6ms on 1 file with 2 rules using 1 threads.

--format=checkstyle

输出 Checkstyle XML 格式,可以被一些 CI 工具使用。

🌐 Outputs Checkstyle XML format, which can be ingested by some CI tools.

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` statement is not allowed" source="eslint(no-debugger)" />
  </file>
</checkstyle>

--format=github

此格式旨在用于 GitHub Actions 以及 GitHub 的注释功能

🌐 This format is intended for use with GitHub Actions and GitHub's annotations feature.

::error file=test.js,line=5,endLine=5,col=1,endColumn=10,title=eslint(no-debugger)::`debugger` statement is not allowed

--format=gitlab

此格式旨在与 GitLab CI 及 GitLab 的代码质量功能 一起使用。

🌐 This format is intended for use with GitLab CI and GitLab's Code Quality feature.

json
[
  {
    "description": "`debugger` statement is not allowed",
    "check_name": "eslint(no-debugger)",
    "fingerprint": "9333a3278325994",
    "severity": "critical",
    "location": {
      "path": "test.js",
      "lines": {
        "begin": 5,
        "end": 5
      }
    }
  }
]

--format=json

通用的 JSON 输出格式也可与 '--rules' 一起使用,以获取所有 Oxlint 规则的 JSON 格式列表。

🌐 A general JSON output format, can also be used with --rules to get a list of all Oxlint rules in JSON format.

json
{
  "diagnostics": [
    {
      "message": "`debugger` statement is not allowed",
      "code": "eslint(no-debugger)",
      "severity": "error",
      "causes": [],
      "url": "https://oxc.rs/docs/guide/usage/linter/rules/eslint/no-debugger.html",
      "help": "Remove the debugger statement",
      "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 CIBitbucket Pipelines

🌐 Outputs JUnit XML format, useful for CI systems that support JUnit reports, such as GitLab CI or 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` statement is not allowed">line 5, column 1, `debugger` statement is not allowed</error>
    </testcase>
  </testsuite>
</testsuites>

--format=stylish

Stylish 是 ESLint 的默认输出格式,适合紧凑且易于人类阅读的输出。

🌐 Stylish is the default output format of ESLint, and is good for compact human-readable output.

test.js
5:1   error `debugger` statement is not allowed  eslint(no-debugger)

✖ 1 problem (1 error, 0 warnings)

--format=unix

一个基本的单行格式。

🌐 A basic, single-line format.

test.js:5:1: `debugger` statement is not allowed [Error/eslint(no-debugger)]

1 problem