Skip to content

Commit

Permalink
Add stylelint_ignore_path option to support --ignore-path option
Browse files Browse the repository at this point in the history
  • Loading branch information
rokoucha committed Sep 19, 2023
1 parent 548276a commit 39e0eda
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,15 @@ It's same as `[input]` of stylelint.

Optional. It's same as `--config` flag of stylelint.

### `stylelint_ignore_path`

Optional. Default: `.stylelintignore`.
It's same as `--ignore-path` flag of stylelint.

### `stylelint_ignore`

Optional. Files or glob. It's same as `--ignore-pattern` flag of stylelint.

### `workdir`

Optional. The directory from which to look for and run stylelint. Default '.'
Expand Down
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ inputs:
default: '**/*.css'
stylelint_config:
description: "It's same as `--config` flag of stylelint."
stylelint_ignore_path:
description: "It's same as `--ignore-path` flag of stylelint."
default: '.stylelintignore'
stylelint_ignore:
description: "Files or glob. It's the same as `--ignore-pattern` of stylelint"
workdir:
Expand All @@ -53,6 +56,7 @@ runs:
INPUT_REPORTER: ${{ inputs.reporter }}
INPUT_STYLELINT_INPUT: ${{ inputs.stylelint_input }}
INPUT_STYLELINT_CONFIG: ${{ inputs.stylelint_config }}
INPUT_STYLELINT_IGNORE_PATH: ${{ inputs.stylelint_ignore_path }}
INPUT_STYLELINT_IGNORE: ${{ inputs.stylelint_ignore }}
INPUT_WORKDIR: ${{ inputs.workdir }}
branding:
Expand Down
4 changes: 2 additions & 2 deletions script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ echo "stylelint version: $(npx --no-install -c 'stylelint --version')"
echo '::group:: Running stylelint with reviewdog 🐶 ...'
if [ "${INPUT_REPORTER}" = 'github-pr-review' ]; then
# Use jq and github-pr-review reporter to format result to include link to rule page.
npx --no-install -c "stylelint '${INPUT_STYLELINT_INPUT}' --config='${INPUT_STYLELINT_CONFIG}' --ignore-pattern='${INPUT_STYLELINT_IGNORE}' -f json" \
npx --no-install -c "stylelint '${INPUT_STYLELINT_INPUT}' --config='${INPUT_STYLELINT_CONFIG}' --ignore-path='${INPUT_STYLELINT_IGNORE_PATH}' --ignore-pattern='${INPUT_STYLELINT_IGNORE}' -f json" \
| jq -r '.[] | {source: .source, warnings:.warnings[]} | "\(.source):\(.warnings.line):\(.warnings.column):\(.warnings.severity): \(.warnings.text) [\(.warnings.rule)](\(if .warnings.rule | startswith("scss/") then "https://github.com/stylelint-scss/stylelint-scss/blob/master/src/rules/\(.warnings.rule | split("scss/") | .[1])/README.md" else "https://stylelint.io/user-guide/rules/\(.warnings.rule)" end))"' \
| reviewdog -efm="%f:%l:%c:%t%*[^:]: %m" -name="${INPUT_NAME}" -reporter="${INPUT_REPORTER}" -level="${INPUT_LEVEL}" -filter-mode="${INPUT_FILTER_MODE}" -fail-on-error="${INPUT_FAIL_ON_ERROR}"
else
npx --no-install -c "stylelint '${INPUT_STYLELINT_INPUT}' --config='${INPUT_STYLELINT_CONFIG}' --ignore-pattern='${INPUT_STYLELINT_IGNORE}' -f json" \
npx --no-install -c "stylelint '${INPUT_STYLELINT_INPUT}' --config='${INPUT_STYLELINT_CONFIG}' --ignore-path='${INPUT_STYLELINT_IGNORE_PATH}' --ignore-pattern='${INPUT_STYLELINT_IGNORE}' -f json" \
| jq -r '.[] | {source: .source, warnings:.warnings[]} | "\(.source):\(.warnings.line):\(.warnings.column):\(.warnings.severity): \(.warnings.text)"' \
| reviewdog -efm="%f:%l:%c:%t%*[^:]: %m" -name="${INPUT_NAME}" -reporter="${INPUT_REPORTER}" -level="${INPUT_LEVEL}" -filter-mode="${INPUT_FILTER_MODE}" -fail-on-error="${INPUT_FAIL_ON_ERROR}"
fi
Expand Down

0 comments on commit 39e0eda

Please sign in to comment.