Skip to content

Commit c944cad

Browse files
authored
Add Markdown Linting (#726)
* feat: add markdownlint with most rules disabled to pass checks * style: enable initial markdownlint rules; enables all rules that do not currently trigger any warnings or issues * build: enable markdownlint in github actions * style: enable ul-style rule to test ci * fix: change linting glob to check nested *.md files * style: use consistent unordered list marker * style(markdown): enforce no-trailing-spaces - There should be 0 or 2 trailing spaces. * style(markdown): enforce no-hard-tabs * style(markdown): enforce no-multiple-blanks * style(markdown): enforce commands-show-output * style(markdown): enforce blanks-around-headings * style(markdown): enable no-inline-html with allowed elements * style(markdown): enforce no-bare-urls * style(markdown): enforce fenced-code-language * style(markdown): enforce first-line-heading * style(markdown): enforce code-block-style * style(markdown): enforce link-image-reference-definitions - fixes a broken link in the graphql guides - fixes a duplicate url reference in the Git guides * style(markdown): enforce no-trailing-punctuation; also removes an extraneous url reference * style(markdown): enable no-duplicate-heading with siblings only option * feat: add lefthook and pre-commit hook for markdownlint * chore: update markdownlint config file * ci: lint only on pull request * config: add .tool-versions file
1 parent b4cf871 commit c944cad

24 files changed

+1631
-45
lines changed

.github/workflows/linting.yml

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
on: [pull_request]
2+
3+
jobs:
4+
lint:
5+
runs-on: ubuntu-latest
6+
steps:
7+
- uses: actions/checkout@v4
8+
- uses: DavidAnson/markdownlint-cli2-action@v19
9+
with:
10+
globs: |
11+
./**/*.md

.github/workflows/main.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: update-templates
22

3-
on:
3+
on:
44
push:
55
branches:
66
- main

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.obsidian
2+
3+
node_modules

.markdownlint-cli2.jsonc

+161
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
{
2+
// https://github.com/DavidAnson/markdownlint/blob/v0.32.1/README.md#rules--aliases
3+
// https://github.com/DavidAnson/markdownlint-cli2/blob/main/test/markdownlint-cli2-jsonc-example/.markdownlint-cli2.jsonc
4+
// https://github.com/DavidAnson/markdownlint-cli2/blob/main/schema/markdownlint-config-schema.json
5+
"$schema": "https://raw.githubusercontent.com/DavidAnson/markdownlint-cli2/refs/heads/main/schema/markdownlint-cli2-config-schema.json",
6+
"gitignore": true,
7+
"config": {
8+
/* MD001 - Heading levels should only increment by one level at a time */
9+
"heading-increment": true,
10+
11+
/* MD003 - Heading style */
12+
"heading-style": true,
13+
14+
/* MD004 - Unordered list style */
15+
"ul-style": true,
16+
17+
/* MD005 - Inconsistent indentation for list items at the same level */
18+
"list-indent": true,
19+
20+
/* MD007 - Unordered list indentation */
21+
"ul-indent": true,
22+
// { "indent": 2, "start_indented": false },
23+
24+
/* MD009 - Trailing spaces */
25+
"no-trailing-spaces": true,
26+
27+
/* MD010 - Hard tabs */
28+
"no-hard-tabs": true,
29+
30+
/* MD011 - Reversed link syntax */
31+
"no-reversed-links": true,
32+
33+
/* MD012 - Multiple consecutive blank lines */
34+
"no-multiple-blanks": true,
35+
36+
/* MD013 - Line length */
37+
// NOTE: Disabled to allow lines of any length; could be enabled in a separate PR after discussion
38+
"line-length": false,
39+
40+
/* MD014 - Dollar signs used before commands without showing output */
41+
"commands-show-output": true,
42+
43+
/* MD018 - No space after hash on atx style heading */
44+
"no-missing-space-atx": true,
45+
46+
47+
/* MD019 - Multiple spaces after hash on atx style heading */
48+
"no-multiple-space-atx": true,
49+
50+
/* MD020 - No space inside hashes on closed atx style heading */
51+
"no-missing-space-closed-atx": true,
52+
53+
/* MD021 - Multiple spaces inside hashes on closed atx style heading */
54+
"no-multiple-space-closed-atx": true,
55+
56+
/* MD022 - Headings should be surrounded by blank lines */
57+
"blanks-around-headings": true,
58+
59+
/* MD023 - Headings must start at the beginning of the line */
60+
"heading-start-left": true,
61+
62+
/* MD024 - Multiple headings with the same content */
63+
"no-duplicate-heading": {
64+
"siblings_only": true
65+
},
66+
67+
/* MD025 - Multiple top-level headings in the same document */
68+
"single-title": true,
69+
70+
/* MD026 - Trailing punctuation in heading */
71+
"no-trailing-punctuation": true,
72+
73+
/* MD027 - Multiple spaces after blockquote symbol */
74+
"no-multiple-space-blockquote": true,
75+
76+
/* MD028 - Blank line inside blockquote */
77+
"no-blanks-blockquote": true,
78+
79+
/* MD029 - Ordered list item prefix */
80+
"ol-prefix": true,
81+
82+
/* MD030 - Spaces after list markers */
83+
"list-marker-space": true,
84+
85+
/* MD031 - Fenced code blocks should be surrounded by blank lines */
86+
"blanks-around-fences": true,
87+
88+
/* MD032 - Lists should be surrounded by blank lines */
89+
"blanks-around-lists": true,
90+
91+
/* MD033 - Inline HTML */
92+
"no-inline-html": {
93+
"allowed_elements": ["dl", "dt", "dd", "kbd", "details"]
94+
},
95+
96+
/* MD034 - Bare URL used */
97+
"no-bare-urls": true,
98+
99+
/* MD035 - Horizontal rule style */
100+
"hr-style": true,
101+
102+
/* MD036 - Emphasis used instead of a heading */
103+
"no-emphasis-as-heading": true,
104+
105+
/* MD037 - Spaces inside emphasis markers */
106+
"no-space-in-emphasis": true,
107+
108+
/* MD038 - Spaces inside code span elements */
109+
"no-space-in-code": true,
110+
111+
/* MD039 - Spaces inside link text */
112+
"no-space-in-links": true,
113+
114+
/* MD040 - Fenced code blocks should have a language specified */
115+
"fenced-code-language": true,
116+
117+
/* MD041 - First line in a file should be a top-level heading */
118+
"first-line-heading": true,
119+
120+
/* MD042 - No empty links */
121+
"no-empty-links": true,
122+
123+
/* MD043 - Required heading structure */
124+
"required-headings": true,
125+
126+
/* MD044 - Proper names should have the correct capitalization */
127+
"proper-names": true,
128+
129+
/* MD045 - Images should have alternate text (alt text) */
130+
"no-alt-text": true,
131+
132+
/* MD046 - Code block style */
133+
"code-block-style": true,
134+
135+
/* MD047 - Files should end with a single newline character */
136+
"single-trailing-newline": true,
137+
138+
/* MD048 - Code fence style */
139+
"code-fence-style": true,
140+
141+
/* MD049 - Emphasis style */
142+
"emphasis-style": true,
143+
144+
/* MD050 - Strong style */
145+
"strong-style": true,
146+
147+
/* MD051 - Link fragments should be valid */
148+
"link-fragments": true,
149+
150+
/* MD052 - Reference links and images should use a label that is defined */
151+
"reference-links-images": {
152+
"shortcut_syntax": true
153+
},
154+
155+
/* MD053 - Link and image reference definitions should be needed */
156+
"link-image-reference-definitions": true,
157+
158+
/* MD054 - Link and image style */
159+
"link-image-style": true
160+
}
161+
}

.tool-versions

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node latest

CONTRIBUTING.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ to abide by the [thoughtbot Code Of Conduct].
55

66
We expect everyone to follow the code of conduct anywhere in thoughtbot's
77
project codebases, issue trackers, chatrooms, mailing lists, meetups, at other events, and in-person.
8-
Violators will be warned by the core team.
8+
Violators will be warned by the core team.
99
Repeat violations will result in being blocked or banned by the core team at or before the 3rd violation.
1010

1111
[thoughtbot code of conduct]: https://thoughtbot.com/open-source-code-of-conduct

README.md

-1
Original file line numberDiff line numberDiff line change
@@ -114,5 +114,4 @@ We are [available for hire][hire].
114114
[community]: https://thoughtbot.com/community?utm_source=github
115115
[hire]: https://thoughtbot.com/hire-us?utm_source=github
116116

117-
118117
<!-- END /templates/footer.md -->

_template/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ This typically takes one of three forms:
1616
2. Primarily textual sections
1717
3. A combination of both
1818

19-
## How to...
19+
## How To Guides
2020

2121
This section, if applicable, should index a list of "How-to" guides for this
2222
guide's topic. These should be stored relative to this `README.md` file in a

_template/how-to/do-something-else.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
## How to Do Something Else
1+
# How to Do Something Else
22

33
This is an example how-to guide. Write anything you want here!

_template/how-to/do-something.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
## How to Do Something
1+
# How to Do Something
22

33
This is an example how-to guide. Write anything you want here!

code-review/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ Watch a presentation that covers this material from [Derek Prior at RailsConf 20
6969
- You may want to consider before/after screenshots or screencasts whenever applicable.
7070

7171
- **Link to the code review from the ticket/story**
72-
- "Ready for review: https://github.com/organization/project/pull/1"
72+
- "Ready for review: `https://github.com/organization/project/pull/1`
7373

7474
- **Push commits based on earlier rounds of feedback as isolated commits to the branch**
7575
- Do not squash until the branch is ready to merge.

data/README.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ A guide for managing a series of tubes.
2424
messages from different partitions to be processed out of order.
2525

2626
## Glossary
27+
2728
<dl>
2829
<dt>Data Engineering</dt>
2930
<dd>
@@ -174,6 +175,6 @@ A guide for managing a series of tubes.
174175
<dt>Consumer</dt>
175176
<dd>An application or process that reads from a data stream.</dd>
176177

177-
<dt>Producer</dt>
178+
<dt>Producer</dt>
178179
<dd>An application or process that writes to a data stream.</dd>
179-
</dl>
180+
</dl>

git/README.md

+6-5
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,14 @@ git commit --verbose
5454

5555
Write a [good commit message]. Example format:
5656

57-
Present-tense summary under 50 characters
57+
```text
58+
Present-tense summary under 50 characters
5859
59-
- More information about commit (under 72 characters).
60-
- More information about commit (under 72 characters).
60+
- More information about commit (under 72 characters).
61+
- More information about commit (under 72 characters).
6162
62-
http://project.management-system.com/ticket/123
63+
http://project.management-system.com/ticket/123
64+
```
6365

6466
If you've created more than one commit, [use `git rebase` interactively] to squash them into cohesive commits with good
6567
messages:
@@ -78,7 +80,6 @@ Submit a [GitHub pull request].
7880

7981
Ask for a code review in the project's chat room.
8082

81-
[good commit message]: http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html
8283
[use `git rebase` interactively]: https://help.github.com/articles/about-git-rebase/
8384
[github pull request]: https://help.github.com/articles/using-pull-requests/
8485

graphql/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,4 @@ be used.
6565
- Avoid returning null from operations. [#630]
6666

6767
[graphql specification]: https://graphql.github.io/graphql-spec/
68+
[#630]: https://github.com/thoughtbot/guides/pull/630

javascript/README.md

+7-8
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,18 @@
2727

2828
- Use [Prettier defaults](https://prettier.io/docs/en/options.html) with the following additional configuration (.prettierrc):
2929

30-
```json
31-
{
32-
"singleQuote": true
33-
}
34-
```
30+
```json
31+
{
32+
"singleQuote": true
33+
}
34+
```
3535

3636
This configuration includes:
3737
- Use semicolons at the end of each statement ([sample](/javascript/sample.js#L5))
3838
- Prefer single quotes ([sample](/javascript/sample.js#L11))
39-
- Use a trailing comma after each item in a multi-line array or object literal, including the last item. ([sample](/javascript/sample.js#L11))
40-
41-
If ESLint is used along with Prettier, the ESLInt plugin [eslint-config-prettier](https://github.com/prettier/eslint-config-prettier) should also be used to turn off all ESLint style rules that are already handled by Prettier.
39+
- Use a trailing comma after each item in a multi-line array or object literal, including the last item. ([sample](/javascript/sample.js#L11))
4240

41+
If ESLint is used along with Prettier, the ESLInt plugin [eslint-config-prettier](https://github.com/prettier/eslint-config-prettier) should also be used to turn off all ESLint style rules that are already handled by Prettier.
4342

4443
[babel]: https://babeljs.io/
4544
[eslint]: https://eslint.org/

lefthook.yml

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# EXAMPLE USAGE:
2+
#
3+
# Refer for explanation to following link:
4+
# https://lefthook.dev/configuration/
5+
#
6+
# pre-push:
7+
# jobs:
8+
# - name: packages audit
9+
# tags:
10+
# - frontend
11+
# - security
12+
# run: yarn audit
13+
#
14+
# - name: gems audit
15+
# tags:
16+
# - backend
17+
# - security
18+
# run: bundle audit
19+
#
20+
# pre-commit:
21+
# parallel: true
22+
# jobs:
23+
# - run: yarn eslint {staged_files}
24+
# glob: "*.{js,ts,jsx,tsx}"
25+
#
26+
# - name: rubocop
27+
# glob: "*.rb"
28+
# exclude:
29+
# - config/application.rb
30+
# - config/routes.rb
31+
# run: bundle exec rubocop --force-exclusion {all_files}
32+
#
33+
# - name: govet
34+
# files: git ls-files -m
35+
# glob: "*.go"
36+
# run: go vet {files}
37+
#
38+
# - script: "hello.js"
39+
# runner: node
40+
#
41+
# - script: "hello.go"
42+
# runner: go run
43+
pre-commit:
44+
parallel: true
45+
jobs:
46+
- name: Lint Markdown
47+
glob: "*.md"
48+
group:
49+
parallel: true
50+
jobs:
51+
- name: Markdownlint
52+
run: npx markdownlint-cli2 {staged_files}

mise.toml

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[tools]
2+
node = "latest"

0 commit comments

Comments
 (0)