Skip to content

Commit 326c27b

Browse files
fix(markdown-validator): use global markdownlint config with MD013=160 (#11)
* fix(markdown-validator): use global markdownlint config with MD013=160 Update markdown-validator plugin to use global markdownlint configuration with 160-character line length instead of default 80-character limit. Changes: - Update validate-markdown.sh to use --config ~/.markdownlint-cli2.yaml - Document global config requirement in README - Update .markdownlint.json with MD013 settings and MD060 disabled Configuration: - line_length: 160 (regular text, prevents mid-sentence breaks) - heading_line_length: 120 (headings) - code_block_line_length: 160 (code blocks) - tables: false (disable table length checks) - MD060: false (version mismatch workaround) Users must create ~/.markdownlint-cli2.yaml with these settings (deployed automatically via nix-config for nix users). Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> * fix: address PR review feedback on config handling and docs Changes made: - Use $HOME instead of ~ for better portability - Add config file existence check with user-friendly error message - Update documentation to clarify config requirement and failure behavior - Add note explaining YAML vs JSON config format differences Addresses review threads on PR #11: - Thread PRRT_kwDOQx7E5c5qZyRI: Config check and $HOME usage - Thread PRRT_kwDOQx7E5c5qZzxw: Config file existence validation - Thread PRRT_kwDOQx7E5c5qZzyF: YAML/JSON format clarification - Thread PRRT_kwDOQx7E5c5qZzyW: Config requirement language Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent 18a39a5 commit 326c27b

3 files changed

Lines changed: 50 additions & 3 deletions

File tree

.markdownlint.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
{
22
"MD013": {
3-
"line_length": 160
4-
}
3+
"line_length": 160,
4+
"heading_line_length": 120,
5+
"code_block_line_length": 160,
6+
"tables": false
7+
},
8+
"MD060": false
59
}

markdown-validator/README.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,44 @@ npm install -g cspell
4040

4141
## Configuration
4242

43+
### Global Markdownlint Configuration
44+
45+
This plugin uses a global markdownlint configuration file at `~/.markdownlint-cli2.yaml`. The configuration
46+
defines the validation rules used by this plugin. If this file is missing, the validation hook will fail with
47+
a clear error message prompting you to create it.
48+
49+
**Recommended configuration** (`~/.markdownlint-cli2.yaml`):
50+
51+
```yaml
52+
config:
53+
default: true
54+
MD013:
55+
line_length: 160
56+
heading_line_length: 120
57+
code_block_line_length: 160
58+
tables: false
59+
MD060: false
60+
fix: true
61+
```
62+
63+
> **Note:** The YAML format shown above uses markdownlint-cli2's structure with a `config:` wrapper for rules
64+
> and a top-level `fix:` option. If using JSON format (`.markdownlint.json`), use a flat structure without
65+
> the `config` wrapper and omit the `fix` property, as shown in this repository's `.markdownlint.json`.
66+
67+
**Key settings:**
68+
69+
- **MD013**: Line length limits configured for readability
70+
- `line_length: 160`: Regular text lines (default 80 breaks sentences mid-sentence)
71+
- `heading_line_length: 120`: Heading lines
72+
- `code_block_line_length: 160`: Code block lines
73+
- `tables: false`: Disable table line length checks
74+
- **MD060**: Disabled due to version mismatch between GitHub Actions and nixpkgs
75+
- **fix: true**: Auto-fix issues where possible during validation
76+
77+
If you don't have this file, create it with the above configuration.
78+
79+
### Hook Configuration
80+
4381
The hook is configured in `hooks/hooks.json`:
4482

4583
```json
@@ -73,6 +111,7 @@ The hook is configured in `hooks/hooks.json`:
73111
## Customization
74112

75113
Edit `scripts/validate-markdown.sh` to:
114+
76115
- Add more validation tools
77116
- Change validation rules
78117
- Skip certain file patterns

markdown-validator/scripts/validate-markdown.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,11 @@ errors=()
3333

3434
# Run markdownlint-cli2
3535
if command -v markdownlint-cli2 &>/dev/null; then
36-
if ! markdownlint_output=$(markdownlint-cli2 "$file_path" 2>&1); then
36+
config_file="$HOME/.markdownlint-cli2.yaml"
37+
if [[ ! -f "$config_file" ]]; then
38+
errors+=("markdownlint-cli2 config not found: $config_file")
39+
errors+=("Please create this file as documented in the plugin README.")
40+
elif ! markdownlint_output=$(markdownlint-cli2 --config "$config_file" "$file_path" 2>&1); then
3741
errors+=("markdownlint-cli2 failed:")
3842
errors+=("$markdownlint_output")
3943
fi

0 commit comments

Comments
 (0)