Skip to content

Commit 0c51e59

Browse files
committed
GH Actions: add new check for consistency in markdown files
This new check uses the NPM MarkdownLint package via the NPM MarkdownLint-CLI2 package. It executes a loose check for consistency and some common errors. Some of the more annoying rules/rules which could impact display of markdown files on GitHub have been disabled. All necessary configuration is contained in the `.markdownlint-cli2.yaml` file. To run locally, install via: ```bash npm install -g markdownlint-cli2 ``` ... and then run via: ```bash markdownlint-cli2 ``` Includes a problem matcher in the reusable workflow, which _should_ allow for displaying the results inline in GitHub PR code review view. Includes adding the config file to `.gitattributes`. Includes adding `node_modules` to the `.gitignore` in case anyone would install these tools locally (to prevent them committing them). Refs: * https://github.com/DavidAnson/markdownlint * https://github.com/DavidAnson/markdownlint-cli2
1 parent 2b3fd8b commit 0c51e59

File tree

4 files changed

+137
-10
lines changed

4 files changed

+137
-10
lines changed

.gitattributes

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,17 @@
55
# https://www.reddit.com/r/PHP/comments/2jzp6k/i_dont_need_your_tests_in_my_production
66
# https://blog.madewithlove.be/post/gitattributes/
77
#
8-
/.gitattributes export-ignore
9-
/.gitignore export-ignore
10-
/.github export-ignore
11-
/phpcs.xml.dist export-ignore
12-
/phpstan.neon.dist export-ignore
13-
/phpunit.xml.dist export-ignore
14-
/phpunitlte9.xml.dist export-ignore
15-
/phpunit-bootstrap.php export-ignore
16-
/PHPCSDebug/Tests export-ignore
17-
/Tests export-ignore
8+
/.gitattributes export-ignore
9+
/.gitignore export-ignore
10+
/.github export-ignore
11+
/.markdownlint-cli2.yaml export-ignore
12+
/phpcs.xml.dist export-ignore
13+
/phpstan.neon.dist export-ignore
14+
/phpunit.xml.dist export-ignore
15+
/phpunitlte9.xml.dist export-ignore
16+
/phpunit-bootstrap.php export-ignore
17+
/PHPCSDebug/Tests export-ignore
18+
/Tests export-ignore
1819

1920
#
2021
# Auto detect text files and perform LF normalization

.github/workflows/cs.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,3 +142,7 @@ jobs:
142142

143143
phpstan:
144144
uses: PHPCSStandards/.github/.github/workflows/reusable-phpstan.yml@main
145+
146+
markdownlint:
147+
name: 'Lint Markdown'
148+
uses: PHPCSStandards/.github/.github/workflows/reusable-markdownlint.yml@main

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
build/
22
deploy/
3+
node_modules/
34
vendor/
45
composer.lock
56
.phpcs.xml

.markdownlint-cli2.yaml

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
#
2+
# Configuration file for MarkdownLint-CLI2.
3+
#
4+
# Example file with all options:
5+
# https://github.com/DavidAnson/markdownlint-cli2/blob/main/test/markdownlint-cli2-yaml-example/.markdownlint-cli2.yaml
6+
#
7+
8+
# Do not fix any fixable errors.
9+
fix: false
10+
11+
# Define glob expressions to use (only valid at root).
12+
globs:
13+
- "**/*.md"
14+
- ".github/**/*.md"
15+
16+
# Show found files on stdout (only valid at root)
17+
showFound: true
18+
19+
# Define glob expressions to ignore.
20+
ignores:
21+
- "node_modules/"
22+
- "vendor/"
23+
24+
# Disable inline config comments.
25+
noInlineConfig: true
26+
27+
# Disable progress on stdout (only valid at root).
28+
noProgress: false
29+
30+
# Adjust the configuration for some built-in rules.
31+
# For full information on the options and defaults, see:
32+
# https://github.com/DavidAnson/markdownlint/blob/main/schema/.markdownlint.yaml
33+
config:
34+
######################
35+
# Disable a few rules.
36+
######################
37+
# MD031/blanks-around-fences - Fenced code blocks should be surrounded by blank lines.
38+
MD031: false
39+
# MD032/blanks-around-lists - Lists should be surrounded by blank lines.
40+
MD032: false
41+
42+
##############################
43+
# Customize a few other rules.
44+
##############################
45+
# MD003/heading-style/header-style - Heading style.
46+
MD003:
47+
# Heading style - Always use hashes.
48+
style: "atx"
49+
50+
# MD004/ul-style - Unordered list style.
51+
MD004:
52+
# List style - each level has a different, but consistent symbol.
53+
style: "sublist"
54+
55+
# MD007/ul-indent - Unordered list indentation.
56+
MD007:
57+
indent: 4
58+
# Whether to indent the first level of the list.
59+
start_indented: false
60+
61+
# MD012/no-multiple-blanks - Multiple consecutive blank lines.
62+
MD012:
63+
maximum: 2
64+
65+
# MD013/line-length - Line length.
66+
MD013:
67+
# Number of characters. No need for being too fussy.
68+
line_length: 1000
69+
# Number of characters for headings.
70+
heading_line_length: 100
71+
# Number of characters for code blocks.
72+
code_block_line_length: 140
73+
# Stern length checking (applies to tables, code blocks etc which have their own max line length).
74+
stern: true
75+
76+
# MD022/blanks-around-headings : Headings should be surrounded by blank lines.
77+
MD022:
78+
# Blank lines above heading
79+
lines_above: [2, 1, 1, 1, 1]
80+
# Blank lines below heading
81+
lines_below: [1, 1, -1, -1, -1]
82+
83+
# MD024/no-duplicate-heading/no-duplicate-header - Multiple headings with the same content.
84+
MD024:
85+
# Only check sibling headings.
86+
siblings_only: true
87+
88+
# MD033/no-inline-html - Inline HTML.
89+
MD033:
90+
# Allowed elements.
91+
allowed_elements:
92+
- div
93+
- details
94+
- summary
95+
- b
96+
- code
97+
- ul
98+
- li
99+
100+
# MD044/proper-names - Proper names should have the correct capitalization.
101+
MD044:
102+
# List of proper names.
103+
names: ["PHPDevTools", "PHPCSUtils", "PHP", "PHP_CodeSniffer", "CodeSniffer", "PHPUnit"]
104+
# Include code blocks.
105+
code_blocks: false
106+
107+
# MD046/code-block-style - Code block style
108+
MD046:
109+
style: "fenced"
110+
111+
# MD048/code-fence-style - Code fence style
112+
MD048:
113+
style: "backtick"
114+
115+
# MD049/emphasis-style - Emphasis style should be consistent
116+
MD049:
117+
style: "underscore"
118+
119+
# MD050/strong-style - Strong style should be consistent
120+
MD050:
121+
style: "asterisk"

0 commit comments

Comments
 (0)