Skip to content
This repository was archived by the owner on Aug 8, 2023. It is now read-only.

Commit 9058389

Browse files
committed
Initial take on markdown linting.
- Basic .remarkrc configuration. - Cleanup package.json adding … - A test for our remark config.
1 parent 21e7294 commit 9058389

File tree

8 files changed

+244
-6
lines changed

8 files changed

+244
-6
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
.idea/
2+
node_modules

.remarkrc

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
{
2+
"presets": ["lint-recommended"],
3+
"plugins": {
4+
"lint": {
5+
"code-block-style": "fenced",
6+
"fenced-code-marker": "`",
7+
"fenced-code-flag": {
8+
"allowEmpty": false
9+
},
10+
"heading-increment": true,
11+
"heading-style": "atx",
12+
"link-title-style": "\"",
13+
"list-item-bullet-indent": true,
14+
"list-item-content-indent": true,
15+
"list-item-indent": "space",
16+
"maximum-heading-length": 60,
17+
"maximum-line-length": 80,
18+
"no-consecutive-blank-lines": true,
19+
"no-duplicate-headings": true,
20+
"no-file-name-articles": true,
21+
"no-file-name-articles": true,
22+
"no-file-name-consecutive-dashes": true,
23+
"no-file-name-consecutive-dashes": true,
24+
"no-file-name-irregular-characters": true,
25+
"no-file-name-irregular-characters": true,
26+
"no-file-name-mixed-case": true,
27+
"no-file-name-mixed-case": true,
28+
"no-file-name-outer-dashes": true,
29+
"no-file-name-outer-dashes": true,
30+
"no-heading-content-indent": true,
31+
"no-heading-content-indent": true,
32+
"no-heading-indent": true,
33+
"no-heading-indent": true,
34+
"no-multiple-toplevel-headings": 0,
35+
"no-table-indentation": true,
36+
"no-tabs": true,
37+
"no-undefined-references": true,
38+
"ordered-list-marker-style": ".",
39+
"ordered-list-marker-value": "ordered",
40+
"unordered-list-marker-style": "-"
41+
}
42+
}
43+
}

docs/test/bad.expected.md

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
Used to test violations of style.
2+
3+
## BAD: Starting with wrong level heading.
4+
5+
# BAD: Higher level second heading.
6+
7+
### BAD: Skipping levels between headings.
8+
9+
# BAD: Two first level headings.
10+
11+
## BAD: Repeated Headings.
12+
13+
## BAD: Repeated Headings.
14+
15+
BAD: Really, really long lines of text that should probably be wrapped to a more sane length that this.
16+
17+
BAD: List immedidately following text.
18+
19+
- list
20+
21+
BAD: One space indents in lists.
22+
23+
- list
24+
25+
BAD: Two space indents in lists.
26+
27+
- list
28+
29+
BAD: Non-standard list bullet.
30+
31+
- Star
32+
33+
BAD: A non-ordered numbered list.
34+
35+
1. Number
36+
2. List
37+
38+
BAD: Fenced code-block with no language.
39+
40+
# Fenced code block
41+
42+
BAD: Indented code-block.
43+
44+
# Indented code block
45+
46+
BAD: Missing newline at end of file.
47+
docs/test/bad.md
48+
1:1 warning Missing newline character at end of file final-newline remark-lint
49+
7:1-7:43 warning Heading levels should increment by one level at a time heading-increment remark-lint
50+
9:1-9:33 warning Don’t use multiple top level headings (9:1) no-multiple-toplevel-headings remark-lint
51+
13:1-13:27 warning Do not use headings with similar content (11:1) no-duplicate-headings remark-lint
52+
15:104 warning Line must be at most 80 characters maximum-line-length remark-lint
53+
18:5 warning Incorrect list-item indent: remove 2 spaces list-item-indent remark-lint
54+
26:4 warning Incorrect list-item indent: remove 1 space list-item-indent remark-lint
55+
30:1-30:8 warning Marker style should be `-` unordered-list-marker-style remark-lint
56+
30:4 warning Incorrect list-item indent: remove 1 space list-item-indent remark-lint
57+
34:5 warning Incorrect list-item indent: remove 1 space list-item-indent remark-lint
58+
35:1-35:9 warning Marker should be `2`, was `1` ordered-list-marker-value remark-lint
59+
35:5 warning Incorrect list-item indent: remove 1 space list-item-indent remark-lint
60+
38:1 warning Remove 1 line before node no-consecutive-blank-lines remark-lint
61+
40:1-42:4 warning Missing code-language flag fenced-code-flag remark-lint
62+
46:1-46:26 warning Code blocks should be fenced code-block-style remark-lint
63+
64+
⚠ 15 warnings

docs/test/bad.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
Used to test violations of style.
2+
3+
## BAD: Starting with wrong level heading.
4+
5+
# BAD: Higher level second heading.
6+
7+
### BAD: Skipping levels between headings.
8+
9+
# BAD: Two first level headings.
10+
11+
## BAD: Repeated Headings.
12+
13+
## BAD: Repeated Headings.
14+
15+
BAD: Really, really long lines of text that should probably be wrapped to a more sane length that this.
16+
17+
BAD: List immedidately following text.
18+
- list
19+
20+
BAD: One space indents in lists.
21+
22+
- list
23+
24+
BAD: Two space indents in lists.
25+
26+
- list
27+
28+
BAD: Non-standard list bullet.
29+
30+
* Star
31+
32+
BAD: A non-ordered numbered list.
33+
34+
1. Number
35+
1. List
36+
37+
38+
BAD: Fenced code-block with no language.
39+
40+
```
41+
# Fenced code block
42+
```
43+
44+
BAD: Indented code-block.
45+
46+
# Indented code block
47+
48+
BAD: Missing newline at end of file.

docs/test/good.expected.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
Used to test style.
2+
3+
# GOOD: Starting level one heading.
4+
5+
## GOOD: One level step down headings.
6+
7+
<!--lint disable no-duplicate-headings -->
8+
9+
### GOOD: Repeated Content when rule is disabled
10+
11+
### GOOD: Repeated Content when rule is disabled
12+
13+
<!--lint enable no-duplicate-headings -->
14+
15+
GOOD: Sentences that are just long enough that they don't need to be wrapped!!!
16+
17+
GOOD: Bullet lists with correct bullet.
18+
19+
- A list!
20+
21+
GOOD: Ordered lists with correct numbers.
22+
23+
1. Numbered
24+
2. Listed
25+
26+
GOOD: Fenced code-blocks with langauge.
27+
28+
```python
29+
print 'Hello Mobify'
30+
```
31+
docs/test/good.md: no issues found

docs/test/good.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
Used to test style.
2+
3+
# GOOD: Starting level one heading.
4+
5+
## GOOD: One level step down headings.
6+
7+
<!--lint disable no-duplicate-headings -->
8+
9+
### GOOD: Repeated Content when rule is disabled
10+
11+
### GOOD: Repeated Content when rule is disabled
12+
13+
<!--lint enable no-duplicate-headings -->
14+
15+
GOOD: Sentences that are just long enough that they don't need to be wrapped!!!
16+
17+
GOOD: Bullet lists with correct bullet.
18+
19+
- A list!
20+
21+
GOOD: Ordered lists with correct numbers.
22+
23+
1. Numbered
24+
2. Listed
25+
26+
GOOD: Fenced code-blocks with langauge.
27+
28+
```python
29+
print 'Hello Mobify'
30+
```

docs/test/test.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/bash -eu
2+
# To test the remark configuration, we use two test fixtures files:
3+
# `good.md` and `bad.md`
4+
#
5+
# The result of running our remark configuration on them is commited as
6+
# `.expected` files. If we change our configuration, a new output will be
7+
# expected and these files must be re-generated.
8+
NPM_BIN=$(npm bin)
9+
TEST_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
10+
11+
# Re-generate `.expected` files with current configuration.
12+
# "$NPM_BIN/remark" "$TEST_DIR/good.md" --no-color > "$TEST_DIR/good.expected.md" 2>&1
13+
# "$NPM_BIN/remark" "$TEST_DIR/bad.md" --no-color > "$TEST_DIR/bad.expected.md" 2>&1
14+
15+
# Compare remark output with expected output. Fail on diff.
16+
diff <("$NPM_BIN/remark" "$TEST_DIR/good.md" --no-color 2>&1) "$TEST_DIR/good.expected.md"
17+
diff <("$NPM_BIN/remark" "$TEST_DIR/bad.md" --no-color 2>&1) "$TEST_DIR/bad.expected.md"

package.json

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@
22
"name": "mobify-code-style",
33
"version": "2.4.3",
44
"description": "Code style guide and linting tools for Mobify",
5-
"main": "index.js",
6-
"scripts": {
7-
"test": "grunt test"
8-
},
95
"repository": {
106
"type": "git",
117
"url": "git://github.com/mobify/mobify-code-style.git"
@@ -15,5 +11,13 @@
1511
"bugs": {
1612
"url": "https://github.com/mobify/mobify-code-style/issues"
1713
},
18-
"homepage": "https://github.com/mobify/mobify-code-style"
19-
}
14+
"homepage": "https://github.com/mobify/mobify-code-style",
15+
"scripts": {
16+
"test": "bash docs/test/test.sh"
17+
},
18+
"dependencies": {
19+
"remark-cli": "2.0.0",
20+
"remark-lint": "5.0.1",
21+
"remark-preset-lint-recommended": "1.0.0"
22+
}
23+
}

0 commit comments

Comments
 (0)