mirror of
https://github.com/DavidAnson/markdownlint-cli2-action.git
synced 2026-11-30 14:27:46 +01:00
Add tests for custom rules (markdown-it and micromark) with no errors and errors.
This commit is contained in:
1 parent
51527aa3e5
commit
1d17f9bb81
5 files changed
+77
-5
No files matched your search
@@ -51,7 +51,7 @@ jobs:
|
||||
with:
|
||||
globs: |
|
||||
*.md
|
||||
test/*
|
||||
test/*.md
|
||||
continue-on-error: true
|
||||
id: test
|
||||
- run: exit 1
|
||||
@@ -63,7 +63,7 @@ jobs:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: ./
|
||||
with:
|
||||
globs: '*.md,test/*'
|
||||
globs: '*.md,test/*.md'
|
||||
separator: ','
|
||||
continue-on-error: true
|
||||
id: test
|
||||
@@ -78,7 +78,7 @@ jobs:
|
||||
- uses: ./
|
||||
with:
|
||||
config: 'config/test.markdownlint.jsonc'
|
||||
globs: 'test/*'
|
||||
globs: 'test/*.md'
|
||||
continue-on-error: true
|
||||
id: test
|
||||
- run: exit 1
|
||||
@@ -91,7 +91,7 @@ jobs:
|
||||
- uses: ./
|
||||
with:
|
||||
config: 'invalid.markdownlint.jsonc'
|
||||
globs: 'test/*'
|
||||
globs: 'test/*.md'
|
||||
continue-on-error: true
|
||||
id: test
|
||||
- run: exit 1
|
||||
@@ -104,4 +104,28 @@ jobs:
|
||||
- uses: ./
|
||||
with:
|
||||
fix: true
|
||||
globs: 'test/*'
|
||||
globs: 'test/*.md'
|
||||
rules-pass:
|
||||
name: custom rules (README.md, 0 errors)
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- run: rm .markdownlint.json
|
||||
- uses: ./
|
||||
with:
|
||||
config: 'config/custom-rules-pass.markdownlint-cli2.jsonc'
|
||||
globs: 'README.md'
|
||||
rules-fail:
|
||||
name: custom rules (README.md, 2 errors)
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- run: rm .markdownlint.json
|
||||
- uses: ./
|
||||
with:
|
||||
config: 'config/custom-rules-fail.markdownlint-cli2.jsonc'
|
||||
globs: 'README.md'
|
||||
continue-on-error: true
|
||||
id: test
|
||||
- run: exit 1
|
||||
if: steps.test.outcome != 'failure'
|
||||
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"config": {
|
||||
"custom-rule-markdown-it": {
|
||||
"error": true
|
||||
},
|
||||
"custom-rule-micromark": {
|
||||
"error": true
|
||||
}
|
||||
},
|
||||
"customRules": [
|
||||
"../test/custom-rule-markdown-it.cjs",
|
||||
"../test/custom-rule-micromark.cjs"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"customRules": [
|
||||
"../test/custom-rule-markdown-it.cjs",
|
||||
"../test/custom-rule-micromark.cjs"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
// @ts-check
|
||||
|
||||
/** @type {import("markdownlint").Rule} */
|
||||
module.exports = {
|
||||
"names": [ "custom-rule-markdown-it" ],
|
||||
"description": "Custom rule using markdown-it",
|
||||
"tags": [ "test" ],
|
||||
"parser": "markdownit",
|
||||
"function": (params, onError) => {
|
||||
if (params.config.error) {
|
||||
onError({ "lineNumber": 1 });
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
// @ts-check
|
||||
|
||||
/** @type {import("markdownlint").Rule} */
|
||||
module.exports = {
|
||||
"names": [ "custom-rule-micromark" ],
|
||||
"description": "Custom rule using micromark",
|
||||
"tags": [ "test" ],
|
||||
"parser": "micromark",
|
||||
"function": (params, onError) => {
|
||||
if (params.config.error) {
|
||||
onError({ "lineNumber": 1 });
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user