Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accepts different rules and presets #55

Merged
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@ jobs:

**Optional**. The directory to run remark-lint in. Defaults to `.`.

#### `remark_args`
### `remark_args`

**Optional**. Additional remark-lint input arguments. Defaults to `""`.
**Optional**. Additional remark-lint input arguments. Defaults to `"--use=remark-preset-lint-recommended"`.

### `annotate`

**Optional**. Annotate remark-lint changes using reviewdog. Defaults to `true`.

#### `tool_name`
### `tool_name`

**Optional**. Tool name to use for reviewdog reporter. Defaults to `remark-lint`.

Expand All @@ -66,14 +66,18 @@ jobs:

**Optional**. Filtering mode for the reviewdog command `[added, diff_context, file, nofilter]`. Defaults to `added`.

#### `fail_on_error`
### `fail_on_error`

**Optional**. Exit code for when reviewdog when errors are found `[true, false]`. Defaults to `false`.

### `reviewdog_flags`

**Optional**. Additional reviewdog flags. Defaults to `""`.

### `rules_and_presets`

**Optional**. Extra rules and presets that need to be installed. Defaults to `""`.

## Format your code

This action is meant to annotate any possible changes that would need to be made to make your code adhere to the [remark-lint linting guidelines](https://github.com/remarkjs/remark-lint). It does not apply these changes to your codebase. If you also want to apply the changes to your repository, you can use the [reviewdog/action-suggester](https://github.com/reviewdog/action-suggester). You can find examples of how this is done can be found in [rickstaa/action-remark-lint](https://github.com/rickstaa/action-remark-lint/)
6 changes: 5 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ inputs:
remark_args:
description: "Additional remark-lint input arguments."
required: false
default: ""
default: "--use=remark-preset-lint-recommended"
rickstaa marked this conversation as resolved.
Show resolved Hide resolved
# Reviewdog related inputs
github_token:
description: "GITHUB_TOKEN."
Expand Down Expand Up @@ -39,6 +39,10 @@ inputs:
description: "Additional reviewdog flags."
required: false
default: ""
rules_and_presets:
description: "Extra rules and presets that need to be installed"
required: false
default: ""
runs:
using: "docker"
image: "Dockerfile"
Expand Down
10 changes: 8 additions & 2 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,21 @@ export REVIEWDOG_GITHUB_API_TOKEN="${INPUT_GITHUB_TOKEN}"

echo "[action-remark-lint] Versions: $(remark --version), remark-lint: $(npm remark-lint --version)"

# Install plugins if package.sjon file is present
# Install plugins if package.json file is present
if [[ -f "package.json" ]]; then
echo "[action-remark-lint] Installing npm dependencies..."
npm install
fi

# Install additional plugins
if [[ -n "${INPUT_RULES_AND_PRESETS}" ]]; then
rickstaa marked this conversation as resolved.
Show resolved Hide resolved
echo "[action-remark-lint] Installing npm dependencies..."
npm install ${INPUT_RULES_AND_PRESETS}
fi

# NOTE: ${VAR,,} Is bash 4.0 syntax to make strings lowercase.
echo "[action-remark-lint] Checking markdown code with the remark-lint linter and reviewdog..."
remark --use=remark-preset-lint-recommended . ${INPUT_REMARK_ARGS} 2>&1 |
remark . ${INPUT_REMARK_ARGS} 2>&1 |
sed 's/\x1b\[[0-9;]*m//g' | # Removes ansi codes see https://github.com/reviewdog/errorformat/issues/51
reviewdog -f=remark-lint \
-name="${INPUT_TOOL_NAME}" \
Expand Down