mirror of
https://github.com/DavidAnson/markdownlint-cli2-action.git
synced 2024-11-21 13:51:28 +01:00
Add "config" and "fix" inputs, deprecate "command" input.
This commit is contained in:
parent
85978587f5
commit
f70c069572
8 changed files with 1097 additions and 905 deletions
2
.github/dictionary.txt
vendored
2
.github/dictionary.txt
vendored
|
@ -1,3 +1,5 @@
|
||||||
CommonMark
|
CommonMark
|
||||||
|
config
|
||||||
markdownlint-cli2-action
|
markdownlint-cli2-action
|
||||||
README
|
README
|
||||||
|
truthy
|
||||||
|
|
40
.github/workflows/test.yml
vendored
40
.github/workflows/test.yml
vendored
|
@ -33,7 +33,7 @@ jobs:
|
||||||
- run: exit 1
|
- run: exit 1
|
||||||
if: steps.test.outcome != 'failure'
|
if: steps.test.outcome != 'failure'
|
||||||
one-glob-pattern:
|
one-glob-pattern:
|
||||||
name: One glob (*.md, 0 errors)
|
name: One glob (README.md, 0 errors)
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
|
@ -72,6 +72,7 @@ jobs:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
|
- run: rm .markdownlint.json
|
||||||
- uses: ./
|
- uses: ./
|
||||||
with:
|
with:
|
||||||
command: config
|
command: config
|
||||||
|
@ -117,6 +118,7 @@ jobs:
|
||||||
- uses: ./
|
- uses: ./
|
||||||
with:
|
with:
|
||||||
command: fix
|
command: fix
|
||||||
|
globs: 'test/*'
|
||||||
command-unsupported:
|
command-unsupported:
|
||||||
name: Command = unsupported (fails)
|
name: Command = unsupported (fails)
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
@ -129,3 +131,39 @@ jobs:
|
||||||
id: test
|
id: test
|
||||||
- run: exit 1
|
- run: exit 1
|
||||||
if: steps.test.outcome != 'failure'
|
if: steps.test.outcome != 'failure'
|
||||||
|
config:
|
||||||
|
name: config (test/errors.md, 2 errors)
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- run: rm .markdownlint.json
|
||||||
|
- uses: ./
|
||||||
|
with:
|
||||||
|
config: 'config/test.markdownlint.jsonc'
|
||||||
|
globs: 'test/*'
|
||||||
|
continue-on-error: true
|
||||||
|
id: test
|
||||||
|
- run: exit 1
|
||||||
|
if: steps.test.outcome != 'failure'
|
||||||
|
config-invalid:
|
||||||
|
name: config (invalid configuration file, fails)
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- uses: ./
|
||||||
|
with:
|
||||||
|
config: 'invalid.markdownlint.jsonc'
|
||||||
|
globs: 'test/*'
|
||||||
|
continue-on-error: true
|
||||||
|
id: test
|
||||||
|
- run: exit 1
|
||||||
|
if: steps.test.outcome != 'failure'
|
||||||
|
fix:
|
||||||
|
name: fix (test/errors.md, 0 errors)
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- uses: ./
|
||||||
|
with:
|
||||||
|
fix: true
|
||||||
|
globs: 'test/*'
|
||||||
|
|
37
README.md
37
README.md
|
@ -15,17 +15,32 @@ information.
|
||||||
|
|
||||||
### command (optional)
|
### command (optional)
|
||||||
|
|
||||||
Command to run (unset, `fix`, or `config`)
|
> **Deprecated in favor of the "fix" and "config" inputs**
|
||||||
|
>
|
||||||
|
> Command to run (unset, `fix`, or `config`)
|
||||||
|
>
|
||||||
|
> If unspecified or `""`, the `markdownlint-cli2` command is run.
|
||||||
|
>
|
||||||
|
> If set to `fix`, the `markdownlint-cli2-fix` command is run and supported
|
||||||
|
> issues will be fixed automatically.
|
||||||
|
>
|
||||||
|
> If set to `config`, the `markdownlint-cli2-config` command is run and the
|
||||||
|
> first element of `globs` should specify a supported configuration file.
|
||||||
|
>
|
||||||
|
> For more detail: [documentation for `markdownlint-cli2`][command-line].
|
||||||
|
|
||||||
If unspecified or `""`, the `markdownlint-cli2` command is run.
|
### config (optional)
|
||||||
|
|
||||||
If set to `fix`, the `markdownlint-cli2-fix` command is run and supported issues
|
Path of a file to use for the base configuration object (defaults to none)
|
||||||
will be fixed automatically.
|
|
||||||
|
|
||||||
If set to `config`, the `markdownlint-cli2-config` command is run and the first
|
Equivalent to using the `--config` [command-line option][command-line] and
|
||||||
element of `globs` should specify a supported configuration file.
|
passing the specified configuration file.
|
||||||
|
|
||||||
For more detail: [documentation for `markdownlint-cli2`][command-line].
|
### fix (optional)
|
||||||
|
|
||||||
|
Whether to fix supported issues automatically (any truthy value enables)
|
||||||
|
|
||||||
|
Equivalent to specifying the `--fix` [command-line option][command-line].
|
||||||
|
|
||||||
### globs (optional)
|
### globs (optional)
|
||||||
|
|
||||||
|
@ -88,7 +103,7 @@ To fix supported issues when linting:
|
||||||
```yaml
|
```yaml
|
||||||
- uses: DavidAnson/markdownlint-cli2-action@v10
|
- uses: DavidAnson/markdownlint-cli2-action@v10
|
||||||
with:
|
with:
|
||||||
command: fix
|
fix: true
|
||||||
globs: '**/*.md'
|
globs: '**/*.md'
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -97,10 +112,8 @@ To specify a custom configuration file:
|
||||||
```yaml
|
```yaml
|
||||||
- uses: DavidAnson/markdownlint-cli2-action@v10
|
- uses: DavidAnson/markdownlint-cli2-action@v10
|
||||||
with:
|
with:
|
||||||
command: config
|
config: 'config/custom.markdownlint.jsonc'
|
||||||
globs: |
|
globs: '**/*.md'
|
||||||
config/custom.markdownlint.jsonc
|
|
||||||
**/*.md
|
|
||||||
```
|
```
|
||||||
|
|
||||||
To prevent linting issues from failing the workflow run:
|
To prevent linting issues from failing the workflow run:
|
||||||
|
|
|
@ -7,6 +7,15 @@ branding:
|
||||||
inputs:
|
inputs:
|
||||||
command:
|
command:
|
||||||
description: Command to run (unset, "fix", or "config")
|
description: Command to run (unset, "fix", or "config")
|
||||||
|
deprecationMessage: This input is deprecated in favor of the "fix" and "config" inputs
|
||||||
|
default: ''
|
||||||
|
required: false
|
||||||
|
config:
|
||||||
|
description: Path of a file to use for the base configuration object (defaults to none)
|
||||||
|
default: ''
|
||||||
|
required: false
|
||||||
|
fix:
|
||||||
|
description: Whether to fix supported issues automatically (any truthy value enables)
|
||||||
default: ''
|
default: ''
|
||||||
required: false
|
required: false
|
||||||
globs:
|
globs:
|
||||||
|
|
|
@ -1,18 +0,0 @@
|
||||||
{
|
|
||||||
"line-length": {
|
|
||||||
"strict": true,
|
|
||||||
"code_blocks": false
|
|
||||||
},
|
|
||||||
"proper-names": {
|
|
||||||
"code_blocks": false,
|
|
||||||
"names": [
|
|
||||||
"CommonMark",
|
|
||||||
"JavaScript",
|
|
||||||
"Markdown",
|
|
||||||
"markdown-it",
|
|
||||||
"markdownlint",
|
|
||||||
"markdownlint-cli2",
|
|
||||||
"Node.js"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
1804
dist/index.js
vendored
1804
dist/index.js
vendored
File diff suppressed because one or more lines are too long
|
@ -52,13 +52,15 @@ const argv =
|
||||||
split(separator).
|
split(separator).
|
||||||
filter(String);
|
filter(String);
|
||||||
|
|
||||||
const parameters = {
|
const config = core.getInput("config");
|
||||||
argv,
|
if (config) {
|
||||||
logMessage,
|
argv.push("--config", config);
|
||||||
"optionsOverride": {
|
|
||||||
"outputFormatters": [[outputFormatter]]
|
|
||||||
}
|
}
|
||||||
};
|
const fix = Boolean(core.getInput("fix"));
|
||||||
|
if (fix) {
|
||||||
|
argv.push("--fix");
|
||||||
|
}
|
||||||
|
|
||||||
let invoke = true;
|
let invoke = true;
|
||||||
const command = core.getInput("command");
|
const command = core.getInput("command");
|
||||||
switch (command) {
|
switch (command) {
|
||||||
|
@ -66,11 +68,10 @@ case "":
|
||||||
// Default behavior
|
// Default behavior
|
||||||
break;
|
break;
|
||||||
case "config":
|
case "config":
|
||||||
parameters.name = "markdownlint-cli2-config";
|
argv.unshift("--config");
|
||||||
break;
|
break;
|
||||||
case "fix":
|
case "fix":
|
||||||
parameters.name = "markdownlint-cli2-fix";
|
argv.unshift("--fix");
|
||||||
parameters.fixDefault = true;
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
core.setFailed(`Unsupported command: ${command}`);
|
core.setFailed(`Unsupported command: ${command}`);
|
||||||
|
@ -79,6 +80,13 @@ default:
|
||||||
}
|
}
|
||||||
|
|
||||||
if (invoke) {
|
if (invoke) {
|
||||||
|
const parameters = {
|
||||||
|
argv,
|
||||||
|
logMessage,
|
||||||
|
"optionsOverride": {
|
||||||
|
"outputFormatters": [[outputFormatter]]
|
||||||
|
}
|
||||||
|
};
|
||||||
markdownlintCli2(parameters).then(
|
markdownlintCli2(parameters).then(
|
||||||
(code) => code && core.setFailed(`Failed with exit code: ${code}`),
|
(code) => code && core.setFailed(`Failed with exit code: ${code}`),
|
||||||
(error) => core.setFailed(`Failed due to error: ${error}`)
|
(error) => core.setFailed(`Failed due to error: ${error}`)
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
"build": "ncc build markdownlint-cli2-action.js",
|
"build": "ncc build markdownlint-cli2-action.js",
|
||||||
"docker-npm-install": "docker run --rm --tty --name npm-install --volume $PWD:/home/workdir --workdir /home/workdir --user node node:16 npm install",
|
"docker-npm-install": "docker run --rm --tty --name npm-install --volume $PWD:/home/workdir --workdir /home/workdir --user node node:16 npm install",
|
||||||
"docker-npm-run-upgrade": "docker run --rm --tty --name npm-run-upgrade --volume $PWD:/home/workdir --workdir /home/workdir --user node node:16 npm run upgrade",
|
"docker-npm-run-upgrade": "docker run --rm --tty --name npm-run-upgrade --volume $PWD:/home/workdir --workdir /home/workdir --user node node:16 npm run upgrade",
|
||||||
"lint": "eslint *.js && markdownlint-cli2-config ./config/.markdownlint.jsonc *.md",
|
"lint": "eslint *.js && markdownlint-cli2 *.md",
|
||||||
"test": "npm run lint && npm run build && git diff --exit-code ':(exclude)dist/index.js'",
|
"test": "npm run lint && npm run build && git diff --exit-code ':(exclude)dist/index.js'",
|
||||||
"upgrade": "npx --yes npm-check-updates --upgrade"
|
"upgrade": "npx --yes npm-check-updates --upgrade"
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue