@gitlab-formatters/eslint-formatter-gitlab

中文文档
1.0.1发布于 2024/06/07MITTypeScriptESM + CJS零依赖近 30 天下载 14万

Formatter that transforms ESLint reports into a format suitable for use with GitLab widgets.

原始使用文档
文档目录6 节
  1. Usage
  2. Report Example
  3. Contributing
  4. Changelog
  5. License
  6. Contact

Eslint Gitlab Codequality Formatter

Latest Release Coverage Badge Codacy Code Quality Badge Conventional Commits

Formatter that transforms ESLint reports into a format suitable for use with GitLab widgets.

The source code is hosted on GitLab. Although there is an automatic mirror of this repository on GitHub, all bug reports, feature requests, and merge requests should be submitted through GitLab.

Usage

Install eslint and @gitlab-formatters/eslint-formatter-gitlab using your package manager:

npm install --save-dev eslint @gitlab-formatters/eslint-formatter-gitlab
yarn add --dev eslint @gitlab-formatters/eslint-formatter-gitlab

To use in your project, simply run:

npx eslint . --format=@gitlab-formatters/gitlab

For integration with GitLab CI, add the following to your .gitlab-ci.yml:

eslint:
  image: node:20.14.0-alpine3.20
  stage: codequality
  script:
    - npm ci
    - npx eslint . --format=@gitlab-formatters/gitlab --output-file=gl-codequality.json
  artifacts:
    reports:
      codequality: gl-codequality.json

Report Example

Below is a JSON example of how the formatter reports issues.

This particular example outputs a detailed report that goes beyond the minimal fields required by GitLab's code quality widgets.

While GitLab requires only a subset of fields according to the Gitlab Code Quality specification, this formatter implements the full set of fields as outlined in the Code Climate Issue Data Type specification.

This comprehensive implementation enhances the depth of information available and facilitates better issue tracking and resolution.

[
  {
    "type": "issue",
    "check_name": "import/order",
    "description": "`./app.module` import should occur after import of `@nestjs/mongoose/dist/mongoose-core.module`",
    "content": {
      "body": "Error found in import/order"
    },
    "categories": [
      "Style"
    ],
    "location": {
      "path": "src/cli.ts",
      "lines": {
        "begin": 2,
        "end": 2
      },
      "positions": {
        "begin": {
          "line": 2,
          "column": 1
        },
        "end": {
          "line": 2,
          "column": 42
        }
      }
    },
    "severity": "major",
    "fingerprint": "9209a8c4e2408f83d9dd5063891f4e96"
  }
]

You can see an example of the widget and how errors are displayed in Merge Request #2.

This merge request includes detailed examples and explanations of the widget's functionality, showcasing how it integrates with GitLab to display code quality issues reported by ESLint.

Reviewing this merge request can provide insights into the formatter's capabilities and how it enhances error reporting within GitLab.

Contributing

If you'd like to contribute to this project, please read through CONTRIBUTING.md file.

Changelog

Changelog is automatically generated based on semantic-release and conventional commits.

See the CHANGELOG.md file for detailed lists of changes for each version.

License

MIT License. See the License File for more information.

Contact

If you have any questions or suggestions, feel free to reach out by

版本与发布记录

@gitlab-formatters/eslint-formatter-gitlab 共发布 4 个版本,首次发布于 2024/06/07;过去 12 个月发布了 0 个版本。

版本发布日期距今
1.0.1latest2024/06/072 年前
1.0.02024/06/052 年前
0.0.22024/06/052 年前
0.0.12024/06/042 年前

关于 @gitlab-formatters/eslint-formatter-gitlab 的常见问题

@gitlab-formatters/eslint-formatter-gitlab 是什么?

Formatter that transforms ESLint reports into a format suitable for use with GitLab widgets.

如何安装 @gitlab-formatters/eslint-formatter-gitlab?

在项目目录运行 npm install @gitlab-formatters/eslint-formatter-gitlab,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:eslint(>=8 <10)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@gitlab-formatters/eslint-formatter-gitlab 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@gitlab-formatters/eslint-formatter-gitlab 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@gitlab-formatters/eslint-formatter-gitlab 可以商用吗?

@gitlab-formatters/eslint-formatter-gitlab 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@gitlab-formatters/eslint-formatter-gitlab 的下载量有多少?

根据 npm 官方下载统计,@gitlab-formatters/eslint-formatter-gitlab 在 2026/10/17 – 2026/11/15 这 30 天内被下载 139,519 次,日均约 4,651 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@gitlab-formatters/eslint-formatter-gitlab 还在维护吗?

最新版本 1.0.1 发布于 2024/06/07(2 年前);至今共发布 4 个版本,其中过去 12 个月发布了 0 个;首次发布于 2024/06/07。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。