|
| 1 | +# Markdown Linting Configuration |
| 2 | + |
| 3 | +## Overview |
| 4 | +This directory contains markdown linting configuration for the Ignite UI for Angular documentation. |
| 5 | + |
| 6 | + |
| 7 | +## TODO |
| 8 | + |
| 9 | +Add devDependencies: |
| 10 | + |
| 11 | +- "markdownlint-cli": "^0.45.0", |
| 12 | +- "cspell": "^9.2.2", |
| 13 | + |
| 14 | +## Rules Configuration |
| 15 | + |
| 16 | +The `.markdownlint.json` file configures markdown-lint with relaxed rules suitable for technical documentation: |
| 17 | + |
| 18 | +### Enabled Rules |
| 19 | +- **MD001**: Heading levels should only increment by one level at a time |
| 20 | +- **MD003**: Heading style (ATX style with #) |
| 21 | +- **MD004**: Unordered list style (dash) |
| 22 | +- **MD007**: Unordered list indentation (2 spaces) |
| 23 | +- **MD009**: Trailing spaces (allow 2 for line breaks) |
| 24 | +- **MD010**: Hard tabs |
| 25 | +- **MD012**: Multiple consecutive blank lines (max 2) |
| 26 | +- **MD014**: Dollar signs used before commands without showing output |
| 27 | +- **MD018**: No space after hash on atx style heading |
| 28 | +- **MD019**: Multiple spaces after hash on atx style heading |
| 29 | +- **MD022**: Headings should be surrounded by blank lines |
| 30 | +- **MD023**: Headings must start at the beginning of the line |
| 31 | +- **MD024**: Multiple headings with the same content (siblings only) |
| 32 | +- **MD025**: Multiple top-level headings in the same document |
| 33 | +- **MD026**: Trailing punctuation in heading |
| 34 | +- **MD027**: Multiple spaces after blockquote symbol |
| 35 | +- **MD028**: Blank line inside blockquote |
| 36 | +- **MD029**: Ordered list item prefix (ordered style) |
| 37 | +- **MD030**: Spaces after list markers |
| 38 | +- **MD031**: Fenced code blocks should be surrounded by blank lines |
| 39 | +- **MD032**: Lists should be surrounded by blank lines |
| 40 | +- **MD035**: Horizontal rule style (---) |
| 41 | +- **MD037**: Spaces inside emphasis markers |
| 42 | +- **MD038**: Spaces inside code span elements |
| 43 | +- **MD039**: Spaces inside link text |
| 44 | +- **MD042**: No empty links |
| 45 | +- **MD045**: Images should have alternate text (alt text) |
| 46 | +- **MD046**: Code block style (fenced) |
| 47 | +- **MD047**: Files should end with a single newline character |
| 48 | +- **MD048**: Code fence style (backtick) |
| 49 | +- **MD049**: Emphasis style (underscore) |
| 50 | +- **MD050**: Strong style (asterisk) |
| 51 | + |
| 52 | +### Disabled Rules |
| 53 | +- **MD013**: Line length (disabled for technical docs with long URLs/code) |
| 54 | +- **MD033**: Inline HTML (allowed for component demos) |
| 55 | +- **MD034**: Bare URLs (allowed as we use many reference links) |
| 56 | +- **MD036**: Emphasis used instead of heading (allowed for styling) |
| 57 | +- **MD040**: Fenced code blocks should have a language specified (would be noisy) |
| 58 | +- **MD041**: First line in a file should be a top-level heading (not always applicable) |
| 59 | +- **MD043**: Required heading structure (too restrictive) |
| 60 | +- **MD044**: Proper names should have the correct capitalization (would require extensive config) |
| 61 | + |
| 62 | +## Usage |
| 63 | + |
| 64 | +### Run linting on all component docs |
| 65 | +```bash |
| 66 | +npx markdownlint "en/components/**/*.md" |
| 67 | +``` |
| 68 | + |
| 69 | +### Run linting on specific file |
| 70 | +```bash |
| 71 | +npx markdownlint en/components/grid/grid.md |
| 72 | +``` |
| 73 | + |
| 74 | +### Fix auto-fixable issues |
| 75 | +```bash |
| 76 | +npx markdownlint --fix "en/components/**/*.md" |
| 77 | +``` |
| 78 | + |
| 79 | +### Run with custom config |
| 80 | +```bash |
| 81 | +npx markdownlint --config .markdownlint.json "en/components/**/*.md" |
| 82 | +``` |
| 83 | + |
| 84 | +## Common Issues and Fixes |
| 85 | + |
| 86 | +### MD001 - Heading increment |
| 87 | +**Issue**: Jumping from `##` to `####` |
| 88 | +**Fix**: Use `###` instead |
| 89 | + |
| 90 | +### MD009 - Trailing spaces |
| 91 | +**Issue**: Unnecessary trailing spaces at end of line |
| 92 | +**Fix**: Remove trailing spaces (except when intentional for line breaks) |
| 93 | + |
| 94 | +### MD022 - Headings surrounded by blank lines |
| 95 | +**Issue**: No blank line before/after heading |
| 96 | +**Fix**: Add blank lines around headings |
| 97 | + |
| 98 | +### MD031 - Code blocks surrounded by blank lines |
| 99 | +**Issue**: No blank line before/after code fence |
| 100 | +**Fix**: Add blank lines around code blocks |
| 101 | + |
| 102 | +### MD047 - File should end with newline |
| 103 | +**Issue**: No newline at end of file |
| 104 | +**Fix**: Add single newline at end of file |
| 105 | + |
| 106 | +## Integration with CI/CD |
| 107 | + |
| 108 | +Add to package.json scripts: |
| 109 | +```json |
| 110 | +{ |
| 111 | + "scripts": { |
| 112 | + "lint:md": "markdownlint 'en/components/**/*.md'", |
| 113 | + "lint:md:fix": "markdownlint --fix 'en/components/**/*.md'" |
| 114 | + } |
| 115 | +} |
| 116 | +``` |
| 117 | + |
| 118 | +## VS Code Integration |
| 119 | + |
| 120 | +Install the "markdownlint" extension by David Anson for real-time linting in VS Code: |
| 121 | +- Extension ID: `DavidAnson.vscode-markdownlint` |
| 122 | +- The `.markdownlint.json` file will be automatically detected |
| 123 | + |
| 124 | +## Related Tools |
| 125 | + |
| 126 | +- **cspell**: Spell checking (configured in `cspell.json`) |
| 127 | +- **prettier**: Code formatting (if configured) |
| 128 | +- **remark-lint**: Alternative markdown linter with different rule set |
0 commit comments