GithubHelp home page GithubHelp logo

hipstersmoothie / eslint-formatter-github Goto Github PK

View Code? Open in Web Editor NEW
100.0 3.0 3.0 961 KB

See ESLint errors and warnings directly in pull requests.

License: MIT License

TypeScript 100.00%
eslint eslint-formatter github github-checks-api github-checks

eslint-formatter-github's Introduction

eslint-formatter-github

See ESLint errors and warnings directly in pull requests.

Highlights

Example of annotations being included in a pull request

Install

npm install --save-dev eslint-formatter-github
# or
yarn add -D eslint-formatter-github

Usage

You will need to install the github app to your repo.

Then just use the formatter and it will report errors and warnings on PRs!

eslint --format github file.js

Using you own GitHub App (recommended)

You might not want to use our github app for the formatter.

Reasons:

  1. You think they way we exposed the keys is bad
  2. You are on Github Enterprise and cannot use the public app

In these situations all you need to do is create a GitHub app and set a few environment variables.

1. Create a GitHub app

Go to this page to create a new GitHub app. You need to set the following fields:

  • name - The name that shows for your app in the checks reports
  • Homepage URL - You can set this to anything. Ours is set to https://github.com
  • Webhook URL - You can set this to anything. Ours is set to https://github.com

Then hit Save Changes and you're all done setting up your GitHub app.

You need to configure Permissions for your GitHub app. You need to set the following permissions:

  • Checks - Read & Write
  • Metadata - Read-only

2. Set ESLINT_APP_ID environment variable

Your GitHub application's ID. This can be found at the top of your GitHub app's edit page.

3. Set ESLINT_PRIVATE_KEY environment variable

The private RSA key for your application. The prompt to generate the RSA key is at the bottom of your GitHub app's edit page.

Once you have generated a key, open the file that is downloaded and copy to text into the PRIVATE_KEY environment variable.

When using GitHub Actions, you can use the environment variable ESLINT_PRIVATE_KEY_BASE64 to set the private key base64 encoded. This fix the issue with the new line characters in the private key.

To encode the private key, you can use the following command:

cat private-key.pem | base64

4. Set GH_API (enterprise only)

To get this package to work on github enterprise instances you will need to set the GH_API environment variable to a url pointing towards your enterprise GitHub's API.

5. (optional) Set GH_CHECK_NAME

If the default check name conflicts with something, you can override it by passing GH_CHECK_NAME environment variable.

Example for GitHub Actions

Warning It is strongly recommended to create your own GitHub app and never share your private key with third parties. Otherwise, unauthorized persons can read meta data and manipulate checks.

name: Lint
on: [pull_request]
jobs:
  lint:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-node@v3
        with:
          node-version: 18
      - run: npm install
      - run: eslint src --ext .ts,.js --format github
        env:
          ESLINT_APP_ID: ${{ secrets.ESLINT_APP_ID }}
          ESLINT_PRIVATE_KEY_BASE64: ${{ secrets.ESLINT_PRIVATE_KEY_BASE64 }}

eslint-formatter-github's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

eslint-formatter-github's Issues

Fails to run on self-hosted Github action runner?

This is failing to run on my selfhosted Linux Github action runner.

2020-05-12T00:54:49.6255155Z   routes/settings.js:10:27
2020-05-12T00:54:49.6256163Z   ✖   10:27   Please rename the variable res. Suggested names are: response, result. A more descriptive name will do too.                                                                 unicorn/prevent-abbreviations
2020-05-12T00:54:49.6256276Z 
2020-05-12T00:54:49.6256422Z   1 errors
2020-05-12T00:54:49.6256495Z 
2020-05-12T00:54:49.6256890Z 
2020-05-12T00:54:49.6257150Z Oops! Something went wrong! :(
2020-05-12T00:54:49.6257254Z 
2020-05-12T00:54:49.6257426Z ESLint: 7.0.0
2020-05-12T00:54:49.6257517Z 
2020-05-12T00:54:49.6258085Z Error: Command failed with exit code 128: git rev-parse HEAD^1
2020-05-12T00:54:49.6258697Z fatal: ambiguous argument 'HEAD^1': unknown revision or path not in the working tree.
2020-05-12T00:54:49.6259213Z Use '--' to separate paths from revisions, like this:
2020-05-12T00:54:49.6259686Z 'git <command> [<revision>...] -- [<file>...]'
2020-05-12T00:54:49.6259856Z HEAD^1
2020-05-12T00:54:49.6260132Z     at makeError (/home/runner/_work/timesheet/timesheet/node_modules/execa/lib/error.js:58:11)
2020-05-12T00:54:49.6260438Z     at handlePromise (/home/runner/_work/timesheet/timesheet/node_modules/execa/index.js:114:26)
2020-05-12T00:54:49.6260685Z     at processTicksAndRejections (internal/process/task_queues.js:97:5)
2020-05-12T00:54:49.6504410Z npm ERR! code ELIFECYCLE
2020-05-12T00:54:49.6505272Z npm ERR! errno 2
2020-05-12T00:54:49.6514823Z npm ERR! [email protected] lint:ci: `eslint --format github .`
2020-05-12T00:54:49.6515081Z npm ERR! Exit status 2
2020-05-12T00:54:49.6515243Z npm ERR! 
2020-05-12T00:54:49.6516012Z npm ERR! Failed at the [email protected] lint:ci script.
2020-05-12T00:54:49.6516462Z npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2020-05-12T00:54:49.6946007Z 
2020-05-12T00:54:49.6947026Z npm ERR! A complete log of this run can be found in:
2020-05-12T00:54:49.6948174Z npm ERR!     /root/.npm/_logs/2020-05-12T00_54_49_652Z-debug.log
2020-05-12T00:54:49.6983875Z ##[error]Process completed with exit code 2.
2020-05-12T00:54:49.7084575Z Post job cleanup.
2020-05-12T00:54:49.9640317Z [command]/usr/bin/git version
2020-05-12T00:54:49.9803430Z git version 2.20.1
2020-05-12T00:54:49.9932527Z [command]/usr/bin/git config --local --name-only --get-regexp core\.sshCommand
2020-05-12T00:54:50.0045392Z [command]/usr/bin/git submodule foreach --recursive git config --local --name-only --get-regexp 'core\.sshCommand' && git config --local --unset-all 'core.sshCommand' || :
2020-05-12T00:54:50.0706051Z [command]/usr/bin/git config --local --name-only --get-regexp http\.https\:\/\/github\.com\/\.extraheader
2020-05-12T00:54:50.0789504Z http.https://github.com/.extraheader
2020-05-12T00:54:50.0819524Z [command]/usr/bin/git config --local --unset-all http.https://github.com/.extraheader
2020-05-12T00:54:50.0930479Z [command]/usr/bin/git submodule foreach --recursive git config --local --name-only --get-regexp 'http\.https\:\/\/github\.com\/\.extraheader' && git config --local --unset-all 'http.https://github.com/.extraheader' || :
2020-05-12T00:54:50.1770095Z Cleaning up orphan processes

Note that this plugin is not needed when using setup-node-v2

Since this project seems a bit stale, I'd like to note that the setup-node github action configures matchers for the default eslint output, and so this project is no longer necessary I believe?

Maybe the readme could be changed accordingly?

Support base64-encoded env var for key

In CIrcleCI it seems to mangle the key when I put it into an environment variable, so I have to do some ugly workaround to make it work better.

It would be nice if this supports an env var like ESLINT_KEY_BASE64 which it would automatically base64 decode.

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Rate-Limited

These updates are currently rate-limited. Click on a checkbox below to force their creation now.

  • Update dependency @types/lru-cache to v5.1.1
  • Update dependency strip-ansi to v6.0.1
  • Update actions/checkout action to v4
  • Update actions/setup-node action to v4
  • Update dependency @types/eslint to v8
  • Update dependency @types/execa to v2
  • Update dependency @types/lru-cache to v7
  • Update dependency auto to v11
  • Update dependency eslint to v9
  • Update dependency eslint-config-airbnb to v19
  • Update dependency eslint-config-airbnb-base to v15
  • Update dependency eslint-config-prettier to v9
  • Update dependency eslint-formatter-pretty to v6
  • Update dependency eslint-plugin-jsdoc to v48
  • Update dependency eslint-plugin-prettier to v5
  • Update dependency execa to v8
  • Update dependency husky to v9
  • Update dependency lint-staged to v15
  • Update dependency prettier to v3
  • Update dependency strip-ansi to v7
  • Update dependency typescript to v5
  • Update typescript-eslint monorepo to v7 (major) (@typescript-eslint/eslint-plugin, @typescript-eslint/parser)
  • 🔐 Create all rate-limited PRs at once 🔐

Edited/Blocked

These updates have been manually edited so Renovate will no longer make changes. To discard all commits and start over, click on a checkbox.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

github-actions
.github/workflows/push.yml
  • actions/checkout v2
  • actions/setup-node v1
npm
package.json
  • create-check ^0.6.0
  • eslint-formatter-pretty ^3.0.0
  • execa ^1.0.0
  • @types/execa ^0.9.0
  • @types/env-ci 3.1.0
  • @types/eslint 6.8.0
  • @types/lru-cache 5.1.0
  • @typescript-eslint/eslint-plugin ^5.54.0
  • @typescript-eslint/parser ^5.54.0
  • auto ^10.43.0
  • auto-config-hipstersmoothie ^4.0.0
  • eslint ^7.1.0
  • eslint-config-airbnb 18.1.0
  • eslint-config-airbnb-base 14.1.0
  • eslint-config-prettier 6.11.0
  • eslint-config-xo 0.29.1
  • eslint-plugin-import 2.20.2
  • eslint-plugin-jsdoc 25.2.0
  • eslint-plugin-jsx-a11y 6.2.3
  • eslint-plugin-prettier 3.1.3
  • husky 3.1.0
  • lint-staged 9.5.0
  • prettier 1.19.1
  • strip-ansi 6.0.0
  • typescript ^4.9.5
  • eslint >= 5.x

  • Check this box to trigger a request for Renovate to run again on this repository

More clear instructions on setup

Hey, thanks for this app.

I am trying to integrate it into my repository so that it runs eslint in PR's but I am not sure what are the correct steps to install the app:

You will need to install the github app to your repo.

Then just use the formatter and it will report errors and warnings on PRs!

eslint --format github file.js

The usage section in the readme is very unclear about this. I installed the app on github, added the formatter to the repository and nothing is happening.

Then just use the formatter and it will report errors and warnings on PRs Where should I use this formatter? On CI? Locally when I run the eslint command :) ? Please point me in the right direction.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.