Package: akitainu-reporter-github-pr-review

npm

Reporter package for reporting lint errors as review comments on GitHub pull requests.

It posts one review comment for one lint error. It does not repost a same lint error multiple times. Visit the playground repository to learn how it works.

Example

{
  rules: {
    source: ["akitainu:source-static", {
      files: ["./src/**/*.ts"]
    }],
    checker: ["akitainu-checker-typescript", {
      tsconfig: "./tsconfig.json"
    }]
  },
  reporters: [
    ["akitainu-reporter-github-pr-review", {
      // This reporter requires a GitHub token.
      // If you are using GitHub Actions to trigger akitainu, token is provided by Github Actions.
      githubToken: process.env.GITHUB_TOKEN,
      // Below information is needed to determine which pull requests to post reviews.
      repository: process.env.GITHUB_REPOSITORY,
      prNumber: Number(process.env.PR_NUMBER)
    }]
  ]
}

With GitHub Actions

The example above requires some environment variables. Here is an example of GitHub Actions definition to run akitainu against a pull request:

name: Lint with akitainu

on:
  pull_request:
    types: [opened, synchronize, reopened]

jobs:
  lint:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-node@v2
        with:
          node-version: '14'
      - run: npm ci
      - run: npx akitainu
        env:
          # Need to provide GITHUB_TOKEN and PR_NUMBER manually.
          # GITHUB_REPOSITORY is automatically provided by GitHub Actions.
          GITHUB_TOKEN: ${{ github.token }}
          PR_NUMBER: ${{ github.event.pull_request.number }}

Options

githubToken

githubToken: string;

GitHub token for the account that posts reviews.

repository

repository: string; // Example: "uhyo/akitainu"

Repository to post review comments.

prNumber

prNumber: number;

The number of the pull request to post review comments.

githubApiUrl

githubApiUrl?: string;

GitHub API URL. Defaults to "https://api.github.com". Needs to be properly set when using akitainu with GitHub Enterprise.

metadataTag

metadataTag?: string;

By default, each review comment posted by this reporter has a metadata line of following form:

<!-- akitainu: {"some": "metadata", ...} -->

Passing a string to this option changes the akitainu part accordingly.

octokitOptions

octokitOptions?: OctokitOptions;

This reporter internally uses Octokit to request to GitHub API. An object passed to this option is forwarded to the Octokit constructor.