Skip to content

Apply Markdown formatting options through Prettier config - #5882

Merged
Eugene (OEvgeny) merged 3 commits into
mainfrom
OEvgeny/dev-markdown-prettier
Oct 17, 2026
Merged

Eugene (OEvgeny) merged 3 commits into
mainfrom
OEvgeny/dev-markdown-prettier

Conversation

@OEvgeny

Copy link
Copy Markdown
Collaborator

Changelog Entry

Not required, development only.

Description

Markdown uses 3-space indentation, but that rule only lived in lint-staged.config.js (prettier --write <file> --tab-width 3 --single-quote true). Plain Prettier and editors read .prettierrc.yml, which says tabWidth: 2. So npx prettier --check CHANGELOG.md fails on main, while the pre-commit hook formats the same file without changes. Contributors and agents repeatedly spent time proving that this failure was "pre-existing" before they could commit.

This PR moves the Markdown option into the Prettier config, so Prettier, editors, and the pre-commit hook agree. No Markdown file is reformatted.

Design

  • .prettierrc.yml gets an overrides entry for *.md with tabWidth: 3. singleQuote is already true, so the second CLI flag was redundant.
  • The 11 nested .prettierrc.yml files (samples/ and 10 packages) are identical copies of the root config. Prettier uses the nearest config file, so they get the same override. Without it, Markdown files in those folders would still format with 2 spaces under plain Prettier.
  • lint-staged now runs plain prettier --write for Markdown, like it does for code.

Formatting output is unchanged. For each of the 137 tracked Markdown files, the old hook command on main and plain prettier on this branch produce byte-identical output. The same 49 files pass prettier --check, including CHANGELOG.md.

Many Markdown files (85, e.g. README.md, AGENTS.md, most of docs/ and samples/) already fail both the old hook form and plain Prettier, because they predate it or were committed without the hook. This PR leaves them as they are; the hook will format them when they are next edited, as it does today.

Specific Changes

  • Added a *.md override with tabWidth: 3 to .prettierrc.yml, samples/.prettierrc.yml, and packages/*/.prettierrc.yml

  • lint-staged.config.js: Markdown uses prettierCode, and the prettierMarkdown function and its CLI flags are removed

  • I have added tests and executed them locally

  • I have updated CHANGELOG.md

  • I have updated documentation

Review Checklist

This section is for contributors to review your work.

  • Accessibility reviewed (tab order, content readability, alt text, color contrast)
  • Browser and platform compatibilities reviewed
  • CSS styles reviewed (minimal rules, no z-index)
  • Documents reviewed (docs, samples, live demo)
  • Internationalization reviewed (strings, unit formatting)
  • package.json and package-lock.json reviewed
  • Security reviewed (no data URIs, check for nonce leak)
  • Tests reviewed (coverage, legitimacy)

lint-staged formatted Markdown with `--tab-width 3 --single-quote true`, so
plain `prettier --check` and editors (2-space) disagreed with the pre-commit
hook on nested lists, e.g. CHANGELOG.md. Add a `*.md` override with
`tabWidth: 3` to the root and the 11 nested `.prettierrc.yml` copies, and let
lint-staged run plain `prettier --write` for Markdown. `singleQuote` is already
`true` in every config.

Formatting output is unchanged for all tracked Markdown files.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The configuration changes consistently replace the hook-specific options, with no blocking issues identified in static review.

No open issues 🎉

What changed in this PR

Aligns Markdown formatting across Prettier, editors, and pre-commit hooks without reformatting Markdown files.

Changes:

  • Adds three-space Markdown indentation to all 12 Prettier configurations.
  • Reuses the standard lint-staged formatter, removing redundant command-line options.
File Description
samples/​.prettierrc.yml Adds Markdown indentation override.
packages/​playground/​.prettierrc.yml Adds Markdown indentation override.
packages/​isomorphic-react/​.prettierrc.yml Adds Markdown indentation override.
packages/​isomorphic-react-dom/​.prettierrc.yml Adds Markdown indentation override.
packages/​fluent-theme/​.prettierrc.yml Adds Markdown indentation override.
packages/​embed/​.prettierrc.yml Adds Markdown indentation override.
packages/​directlinespeech/​.prettierrc.yml Adds Markdown indentation override.
packages/​core/​.prettierrc.yml Adds Markdown indentation override.
packages/​component/​.prettierrc.yml Adds Markdown indentation override.
packages/​bundle/​.prettierrc.yml Adds Markdown indentation override.
packages/​api/​.prettierrc.yml Adds Markdown indentation override.
lint-staged.config.js Uses the shared formatter for Markdown.
.prettierrc.yml Sets repository-wide Markdown indentation.

Review effort: Balanced

@OEvgeny
Eugene (OEvgeny) enabled auto-merge (squash) October 17, 2026 03:49
@OEvgeny
Eugene (OEvgeny) merged commit d74d153 into main Oct 17, 2026
87 of 88 checks passed
@OEvgeny
Eugene (OEvgeny) deleted the OEvgeny/dev-markdown-prettier branch October 17, 2026 06:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants