@gitlab-formatters/eslint-formatter-gitlab
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

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/

    Package Sidebar

    Install

    npm i @gitlab-formatters/eslint-formatter-gitlab

    Weekly Downloads

    2,973

    Version

    1.0.1

    License

    MIT

    Unpacked Size

    16.6 kB

    Total Files

    8

    Last publish

    Collaborators

    • zavoloklom