Skip to content

Commit c43a316

Browse files
Add markdown instructions aligned with markdownlint config (#12093)
## Description Adds `.github/instructions/markdown.instructions.md` describing Markdown formatting best practices based on markdownlint rules. The guidance is aligned with the markdownlint configuration used in `radius-project/wellknown`: - MD024 (duplicate heading content), MD036 (emphasis as heading), and MD041 (first-line heading) are noted as disabled. - MD013 (line length) is not enforced. - Configured options reflected: MD004 (dash), MD029 (one_or_ordered), MD033 (only `<br>` and `<pre>` allowed), and MD046 (fenced). ## Type of change - This pull request adds or changes features of Radius and has an approved issue (issue link required). - This pull request is a minor refactor, code cleanup, test improvement, or documentation update and doesn't change any functionality. --------- Signed-off-by: Brooke Hamilton <45323234+brooke-hamilton@users.noreply.github.com>
1 parent ba537a6 commit c43a316

8 files changed

Lines changed: 1035 additions & 5 deletions

File tree

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
---
2+
description: 'Conventions for authoring Markdown in this repository'
3+
applyTo: '**/*.md'
4+
---
5+
6+
# Markdown Guidelines
7+
8+
Formatting rules for Markdown are enforced by tooling. This file covers only the conventions the linters cannot check and points to the source of truth for everything else.
9+
10+
## Source of truth
11+
12+
Do not restate or duplicate lint rules here — change the configuration instead, otherwise this file will drift from what is actually enforced.
13+
14+
- **Rules:** `markdownlint-cli2`, configured by [`.github/linters/.markdownlint-cli2.yaml`](../linters/.markdownlint-cli2.yaml), which extends [`.github/linters/.markdownlint.yml`](../linters/.markdownlint.yml).
15+
- **Tables:** formatted by `markdown-table-formatter`.
16+
17+
Both tools are installed as dev dependencies in the root `package.json`. See the `markdown-lint` skill for how to run them.
18+
19+
## Conventions not enforced by tooling
20+
21+
- **Do not hard-wrap prose.** Write each paragraph as a single long line. The line-length rule (MD013) is intentionally disabled; manual line breaks create noisy diffs and break reflowing in editors. This applies to all prose — paragraphs, list item text, blockquote content, and image/link alt text. Code blocks and tables are excluded.
22+
23+
## Before committing
24+
25+
Run the Markdown linters (see the `markdown-lint` skill) on the files you changed and fix any reported issues.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# yaml-language-server: $schema=https://raw.githubusercontent.com/DavidAnson/markdownlint-cli2/main/schema/markdownlint-cli2-config-schema.json
2+
---
3+
config:
4+
extends: ./.markdownlint.yml
5+
gitignore: true
6+
ignores:
7+
- .git
8+
- "**/node_modules/**"
9+
- .copilot-tracking/**
10+
- venv/**
11+
- .venv/**

.github/linters/.markdownlint.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# yaml-language-server: $schema=https://raw.githubusercontent.com/DavidAnson/markdownlint/refs/heads/main/schema/markdownlint-config-schema-strict.json
2+
---
3+
# Markdownlint YAML configuration
4+
# Default source: https://github.com/DavidAnson/markdownlint/blob/main/schema/.markdownlint.yaml
5+
6+
# Default state for all rules
7+
default: true
8+
9+
# Path to configuration file to extend
10+
# extends: null
11+
12+
# MD004/ul-style - Unordered list style - https://github.com/DavidAnson/markdownlint/blob/main/doc/md004.md
13+
MD004:
14+
style: dash
15+
16+
# MD013/line-length - Line length - https://github.com/DavidAnson/markdownlint/blob/main/doc/md013.md
17+
MD013: false
18+
19+
# MD024/no-duplicate-heading - Multiple headings with the same content - https://github.com/DavidAnson/markdownlint/blob/main/doc/md024.md
20+
MD024: false
21+
22+
# MD025/single-title - Single title - https://github.com/DavidAnson/markdownlint/blob/main/doc/md025.md
23+
MD025:
24+
front_matter_title: ""
25+
26+
# MD029/ol-prefix - Ordered list item prefix - https://github.com/DavidAnson/markdownlint/blob/main/doc/md029.md
27+
MD029:
28+
style: one_or_ordered
29+
30+
# MD033/no-inline-html - Inline HTML - https://github.com/DavidAnson/markdownlint/blob/main/doc/md033.md
31+
MD033:
32+
# Allowed elements
33+
allowed_elements: [br, pre]
34+
35+
# MD036/no-emphasis-as-heading - Emphasis used instead of a heading - https://github.com/DavidAnson/markdownlint/blob/main/doc/md036.md
36+
MD036: false
37+
38+
# MD041/first-line-heading/first-line-h1 - First line in file should be a top level heading - https://github.com/DavidAnson/markdownlint/blob/main/doc/md041.md
39+
MD041: false
40+
41+
# MD046/code-block-style - Code block style - https://github.com/DavidAnson/markdownlint/blob/main/doc/md046.md
42+
MD046:
43+
# Block style
44+
style: fenced
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
---
2+
name: markdown-lint
3+
description: 'Lint and format Markdown files using markdownlint-cli2 and markdown-table-formatter. Use when checking or fixing Markdown formatting, table alignment, or markdownlint rule violations after editing .md files.'
4+
argument-hint: 'Optional: the path(s) or glob of Markdown files to lint — or leave blank to lint files you changed'
5+
user-invocable: true
6+
---
7+
8+
# Lint Markdown
9+
10+
Check and fix Markdown formatting using the repository's two Markdown tools, driven by `pnpm`.
11+
12+
## Overview
13+
14+
Markdown quality is enforced by two tools, both installed as dev dependencies in the root `package.json`:
15+
16+
- **`markdownlint-cli2`** — applies the markdownlint rules in [`.github/linters/.markdownlint-cli2.yaml`](../../linters/.markdownlint-cli2.yaml), which extends [`.github/linters/.markdownlint.yml`](../../linters/.markdownlint.yml). It honors the `ignores`/`gitignore` settings in that config (so `node_modules`, `.git`, etc. are skipped automatically).
17+
- **`markdown-table-formatter`** — normalizes Markdown table alignment and padding. It has no config file and only accepts CLI flags (`--check`, `--columnpadding`, `--verbose`). It does **not** read `.gitignore`, so scope it to specific files or directories rather than the whole tree.
18+
19+
## Prerequisites
20+
21+
1. **Node.js + pnpm**: pnpm is pinned via the `packageManager` field in `package.json`. If pnpm is missing, run `corepack enable pnpm`.
22+
2. **Install dependencies**: run `pnpm install --frozen-lockfile` from the repository root so the tool binaries are available.
23+
24+
## Procedure
25+
26+
### Step 1: Determine the scope
27+
28+
Prefer linting only the files you changed instead of the entire repository.
29+
30+
- For changed files: `git diff --name-only --diff-filter=d HEAD '*.md'`
31+
- For a directory: use a glob such as `"docs/**/*.md"`.
32+
- Avoid passing `"./**/*.md"` to `markdown-table-formatter` — it will traverse `node_modules` because it does not respect `.gitignore`.
33+
34+
### Step 2: Check (read-only)
35+
36+
Run both tools in check mode. Replace `<glob-or-paths>` with the scope from Step 1.
37+
38+
```bash
39+
# Check table formatting (exits non-zero if any table needs reformatting)
40+
pnpm exec markdown-table-formatter "<glob-or-paths>" --check
41+
42+
# Check markdownlint rules
43+
pnpm exec markdownlint-cli2 "<glob-or-paths>" --config "./.github/linters/.markdownlint-cli2.yaml"
44+
```
45+
46+
### Step 3: Fix
47+
48+
Apply automatic fixes, then re-run the checks in Step 2 to confirm a clean result.
49+
50+
```bash
51+
# Reformat tables in place
52+
pnpm exec markdown-table-formatter "<glob-or-paths>"
53+
54+
# Auto-fix markdownlint violations where possible
55+
pnpm exec markdownlint-cli2 "<glob-or-paths>" --config "./.github/linters/.markdownlint-cli2.yaml" --fix
56+
```
57+
58+
### Step 4: Resolve remaining issues
59+
60+
Not every markdownlint rule is auto-fixable. For violations that remain after Step 3, edit the Markdown manually following the rule messages. Do not hard-wrap prose to satisfy line length — the MD013 line-length rule is intentionally disabled (see the Markdown authoring guidelines in `.github/instructions/markdown.instructions.md`).
61+
62+
### Step 5: Report result
63+
64+
Summarize what was checked, what was fixed automatically, and any violations that require manual attention.
65+
66+
## Quick Reference
67+
68+
| Goal | Command |
69+
|-----------------------------|---------------------------------------------------------------------------------------------------|
70+
| Check table formatting | `pnpm exec markdown-table-formatter "<glob>" --check` |
71+
| Fix table formatting | `pnpm exec markdown-table-formatter "<glob>"` |
72+
| Check markdownlint rules | `pnpm exec markdownlint-cli2 "<glob>" --config "./.github/linters/.markdownlint-cli2.yaml"` |
73+
| Fix markdownlint rules | `pnpm exec markdownlint-cli2 "<glob>" --config "./.github/linters/.markdownlint-cli2.yaml" --fix` |
74+
| List changed Markdown files | `git diff --name-only --diff-filter=d HEAD '*.md'` |

.vscode/extensions.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{
2-
"recommendations": [
3-
"ms-azuretools.vscode-bicep",
4-
"golang.go",
5-
"GitHub.vscode-pull-request-github"
6-
]
2+
"recommendations": [
3+
"ms-azuretools.vscode-bicep",
4+
"golang.go",
5+
"GitHub.vscode-pull-request-github",
6+
"DavidAnson.vscode-markdownlint"
7+
]
78
}

.vscode/settings.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,14 @@
99
"*.yaml": "yaml",
1010
"*.yml": "yaml"
1111
},
12+
"files.trimTrailingWhitespace": true,
13+
"files.insertFinalNewline": true,
14+
"[markdown]": {
15+
"editor.defaultFormatter": "DavidAnson.vscode-markdownlint",
16+
"editor.formatOnSave": true,
17+
"editor.formatOnPaste": true
18+
},
19+
"markdownlint.configFile": "./.github/linters/.markdownlint.yml",
1220
"terminal.integrated.env.linux": {
1321
"RADIUS_DEV_ROOT": "${workspaceFolder}/debug_files"
1422
},

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
"private": true,
33
"packageManager": "pnpm@11.1.1",
44
"devDependencies": {
5+
"markdown-table-formatter": "1.7.0",
6+
"markdownlint-cli2": "0.22.1",
57
"prettier": "3.8.4"
68
}
79
}

0 commit comments

Comments
 (0)