Skip to content

refactor(markdown-parser): replace remaining magic numbers with named constants#9264

Merged
ematipico merged 1 commit intobiomejs:mainfrom
jfmcdowell:refactor/md-parser-named-constants
Feb 27, 2026
Merged

refactor(markdown-parser): replace remaining magic numbers with named constants#9264
ematipico merged 1 commit intobiomejs:mainfrom
jfmcdowell:refactor/md-parser-named-constants

Conversation

@jfmcdowell
Copy link
Contributor

Note

AI Assistance Disclosure: This PR was developed with assistance from Claude Code.

Summary

Follow-up to #9228 — three hardcoded literals were missed before that PR merged.

  • count_leading_indent in parser.rs: 4TAB_STOP_SPACES
  • consume_indent_prefix in syntax/mod.rs: 4TAB_STOP_SPACES
  • render_fenced_code_block in to_html.rs: .min(3).min(MAX_BLOCK_PREFIX_INDENT)

No user-facing behavior change. All 652 CommonMark conformance tests pass.

Test Plan

  • just test-markdown-conformance — 652/652 pass, 100% coverage
  • cargo check -p biome_markdown_parser — compiles cleanly

Docs

N/A — internal refactor only.

… constants

Replace three missed hardcoded literals with their corresponding named
constants for consistency with the rest of the codebase:
- count_leading_indent: 4 → TAB_STOP_SPACES
- consume_indent_prefix: 4 → TAB_STOP_SPACES
- render_fenced_code_block: .min(3) → .min(MAX_BLOCK_PREFIX_INDENT)
@changeset-bot
Copy link

changeset-bot bot commented Feb 27, 2026

⚠️ No Changeset found

Latest commit: ecf0df8

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@github-actions github-actions bot added the A-Parser Area: parser label Feb 27, 2026
@jfmcdowell jfmcdowell marked this pull request as ready for review February 27, 2026 16:13
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 27, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 59e33fb and ecf0df8.

📒 Files selected for processing (3)
  • crates/biome_markdown_parser/src/parser.rs
  • crates/biome_markdown_parser/src/syntax/mod.rs
  • crates/biome_markdown_parser/src/to_html.rs

Walkthrough

This pull request replaces hard-coded magic numbers with named constants across the markdown parser. Specifically, the value 4 is replaced with TAB_STOP_SPACES in indentation counting logic, and the value 3 is replaced with MAX_BLOCK_PREFIX_INDENT for fence indentation calculations. Changes span three files with no modifications to public APIs or control flow logic.

Possibly related PRs

Suggested reviewers

  • dyc3
  • ematipico
🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarises the main change: replacing magic numbers with named constants across the markdown parser.
Description check ✅ Passed The description clearly relates to the changeset, explaining the specific replacements made and providing test results confirming no behaviour changes.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@jfmcdowell
Copy link
Contributor Author

@ematipico missed a few

@ematipico ematipico merged commit 9a23352 into biomejs:main Feb 27, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Parser Area: parser

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants