reviewdog / action-eslint

Run eslint with reviewdog
https://github.com/marketplace?type=actions&query=reviewdog
MIT License
237 stars 64 forks source link

How do you use this action in a folder not in the root directory? #18

Closed ChadTaljaardt closed 4 years ago

ChadTaljaardt commented 4 years ago

Hello,

I am new to working with Github actions.

I am trying to run this action on a "user_interface" sub directory, can anyone explain to me how to do this?

Thanks!

jiro4989 commented 4 years ago

@ChadTaljaardt

  1. Please try to put this YAML file to .github/workflows/reviewdog.yml .
name: reviewdog
on: [pull_request]
jobs:
  eslint:
    name: runner / eslint
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v1
      - name: eslint
        uses: reviewdog/action-eslint@v1
        with:
          github_token: ${{ secrets.github_token }}
          reporter: github-pr-review # Change reporter.
          eslint_flags: 'user_interface/' # <-- Target source directory
  1. Create a new branch
  2. Add your source code
  3. Create a pull request
  4. See pull request, or github actions (https://github.com/<your_name>/<your_repo>/actions)

See also:

ChadTaljaardt commented 4 years ago

@jiro4989 Thanks for your response, i already tried to do what you suggested. This is the error i'm getting which i think is caused because the command isn't being run in the user_interface folder.

npm WARN saveError ENOENT: no such file or directory, open '/github/workspace/package.json'
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN enoent ENOENT: no such file or directory, open '/github/workspace/package.json'
npm WARN workspace No description
npm WARN workspace No repository field.
npm WARN workspace No README data
npm WARN workspace No license field.

up to date in 0.561s
found 0 vulnerabilities

/entrypoint.sh: line 11: /github/workspace/node_modules/.bin/eslint: not found
/entrypoint.sh: line 15: /github/workspace/node_modules/.bin/eslint: not found
LaurenceGA commented 4 years ago

Having the same issue. The script goes in GITHUB_WORKSPACE, then starts running the commands from there. It looks for eslint in this folder here. eslint_flags isn't used until eslint is actually run, but it needs to find eslint in the right directory before it can run it...