reviewdog / action-stylelint

Run stylelint with reviewdog
https://github.com/marketplace?type=actions&query=reviewdog
MIT License
47 stars 25 forks source link

multiple lint runners #13

Closed tadjohnston closed 4 years ago

tadjohnston commented 4 years ago

I'd love to be able to do something like the following as we are transitioning to TailwindCss.

name: stylelint
on: [pull_request]
jobs:
  stylelint:
    name: runner / stylelint
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - name: 'stylelint tailwind'
        uses: reviewdog/action-stylelint@v1
        with:
          github_token: ${{ secrets.github_token }}
          stylelint_input: 'src/**/*.tw.{css,scss}'
  stylelint-themed:
    needs: stylelint
    name: runner / stylelint / themed
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - name: 'stylelint react-themed'
        uses: reviewdog/action-stylelint@v1
        with:
          github_token: ${{ secrets.github_token }}
          stylelint_input: 'src/**/_home.{css,scss}'

Unfortunately when I add a file in each input that I know will fail, I do not get all failures. Instead, whatever runner runs last trumps the first and only reports the errors from the one runner and not both. When I only run one of these at a time, it does what it's supposed to.

Example:

These are errors from stylelint tailwind Screen Shot 2020-05-07 at 10 01 30 AM

I also get the errors I should for stylelint react-themed, but they never show up in the report. Here is the file that I've forced to have errors:

Screen Shot 2020-05-07 at 10 03 01 AM

Is this something that can be adjusted with action-stylelint here or is this a restriction of reviewdog itself?

haya14busa commented 4 years ago

We need to change -name for each run. https://github.com/reviewdog/action-stylelint/blob/8727f560b63fa3fddee4da00472d84a9210c4884/entrypoint.sh#L17

tadjohnston commented 4 years ago

Oh, I thought the name told reviewdog which linter to run. I will give it a try on a forked version to test, thanks!

tadjohnston commented 4 years ago

OK, I added a name input and it seems to be directly related to the parser.

reviewdog: fail to create parser. use either -f or -efm: "stylelint-react-themed" is not supported. consider to add new errrorformat to https://github.com/reviewdog/errorformat
events.js:292
      throw er; // Unhandled 'error' event
      ^

Error: write EPIPE
    at afterWriteDispatched (internal/stream_base_commons.js:154:25)
    at writeGeneric (internal/stream_base_commons.js:145:3)
    at Socket._writeGeneric (net.js:783:11)
    at Socket._write (net.js:795:8)
if [ "${INPUT_REPORTER}" == 'github-pr-review' ]; then
  # Use jq and github-pr-review reporter to format result to include link to rule page.
  $(npm bin)/stylelint "${INPUT_STYLELINT_INPUT:-'**/*.css'}" --config="${INPUT_STYLELINT_CONFIG}" -f json \
    | jq -r '.[] | {source: .source, warnings:.warnings[]} | "\(.source):\(.warnings.line):\(.warnings.column):\(.warnings.severity): \(.warnings.text) [\(.warnings.rule)](https://stylelint.io/user-guide/rules/\(.warnings.rule))"' \
    | reviewdog -efm="%f:%l:%c:%t%*[^:]: %m" -name=="${INPUT_NAME}:-stylelint}"  -reporter=github-pr-review -level="${INPUT_LEVEL}"
else
  $(npm bin)/stylelint "${INPUT_STYLELINT_INPUT:-'**/*.css'}" --config="${INPUT_STYLELINT_CONFIG}" \
    | reviewdog -f="${INPUT_NAME:-stylelint}" -reporter="${INPUT_REPORTER:-github-pr-check}" -level="${INPUT_LEVEL}"
fi
  stylelint-themed:
    name: runner / stylelint / themed
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - name: 'stylelint react-themed'
        uses: rentpath/action-stylelint@tj2
        with:
          name: 'stylelint-react-themed'
          github_token: ${{ secrets.github_token }}
          stylelint_input: 'src/**/*.{css,scss}'
          stylelint_config: '.themed-stylelintrc'
          stylelint_ignore: 'src/**/*.tw.{css,scss}'
haya14busa commented 4 years ago

-f (format) should still use 'stylelint' and you need to add -name flag.

tadjohnston commented 4 years ago

Whoops! I edited the wrong one! 🤦

tadjohnston commented 4 years ago

Screen Shot 2020-05-07 at 10 51 39 AM

Works great! Is it worth it for me to put in a PR?

haya14busa commented 4 years ago

:+1:

Yes, can you create a PR?

tadjohnston commented 4 years ago

https://github.com/reviewdog/action-stylelint/pull/14