eslint-formatter-gitlab

Show ESLint results directly in the GitLab code quality results

Usage no npm install needed!

<script type="module">
  import eslintFormatterGitlab from 'https://cdn.skypack.dev/eslint-formatter-gitlab';
</script>

README

ESLint Formatter for GitLab

Show ESLint results directly in the GitLab code quality results

Requirements

This requires at least GitLab Bronze or Starter 11.5 and at least ESLint 5.

Installation

Install eslint and eslint-formatter-gitlab using your package manager.

npm install --save-dev eslint eslint-formatter-gitlab

Define a GitLab job to run eslint.

.gitlab-ci.yml:

eslint:
  image: node:14-alpine
  script:
    - npm ci
    - npx eslint --format gitlab .
  artifacts:
    reports:
      codequality: gl-codequality.json

The formatter will automatically detect a GitLab CI environment. It will detect where to output the code quality report based on the GitLab configuration file.

Example

An example of the results can be seen in Merge Request !1 of eslint-formatter-gitlab itself.

Configuration Options

ESLint formatters don’t take any configuration options. In order to still allow some way of configuration, options are passed using environment variables.

Environment Variable Description
ESLINT_CODE_QUALITY_REPORT The location to store the code quality report. By default it will detect the location of the codequality artifact defined in the GitLab CI configuration file.

Upgrading

to v3

  • Support for the environment variable ESLINT_FORMATTER has been removed, console output now always uses a builtin formatter.