Skip to content

fix: ignore comment lines starting with # or ; in parse - #195

Closed
feritcemkahraman wants to merge 1 commit into
unjs:mainfrom
feritcemkahraman:fix/ignore-comment-lines-with-equals
Closed

feritcemkahraman wants to merge 1 commit into
unjs:mainfrom
feritcemkahraman:fix/ignore-comment-lines-with-equals

Conversation

@feritcemkahraman

@feritcemkahraman feritcemkahraman commented Oct 25, 2026 •

Copy link
Copy Markdown

Summary

In configuration files (.rc / .conf / INI files), comments are denoted by # or ;. Previously, if a commented-out line contained an equals sign without whitespace (e.g. #key=value or ;key=value), the regular expression matched #key or ;key as the property name and parsed it into the resulting config object.

Changes

  • Skip lines starting with # or ; (ignoring leading whitespace) in parse().
  • Add test coverage in test/index.test.ts verifying that # and ; comment lines containing = are ignored.

Summary by CodeRabbit

  • Bug Fixes
    • Parsing now handles lines with leading whitespace, including indented entries. Blank lines and full-line comments beginning with # or ; are skipped, so they no longer interfere with parsing. Existing parsed results remain unchanged when these lines are present.

@coderabbitai

coderabbitai Bot commented Oct 25, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: b434a667-1807-4a66-bfb1-da19000e5093
Commits

Reviewing files that changed from the base of the PR and between b95fe6a and b62df9c.

Files selected for processing: 2
  • src/index.ts
  • test/index.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 1 remain after this review.

Walkthrough

parse now skips blank lines and comment lines beginning with # or ;, after leading whitespace. It matches other lines after removing leading whitespace. The parser test adds comment-line cases.

Changes: Parser line handling

Layer / File(s) Summary
Parse and test line handling
src/index.ts, test/index.test.ts
parse skips blank lines and lines whose first non-whitespace character is # or ;. It matches other lines after trimming leading whitespace. The test covers indented and unindented comments.

Priority: Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Low

Suggested reviewers: pi0

Merge Risk: Minimal · up to b62df

The comment-line parsing change is covered by the added tests and is ready to merge.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: making parse ignore comment lines that start with # or ;.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@pi0 pi0 closed this Oct 26, 2026
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.

2 participants