Skip to content

fix(config): set file extension based on style parameter#947

Merged
yamadashy merged 5 commits intoyamadashy:mainfrom
Ahmad8864:main
Nov 15, 2025
Merged

fix(config): set file extension based on style parameter#947
yamadashy merged 5 commits intoyamadashy:mainfrom
Ahmad8864:main

Conversation

@Ahmad8864
Copy link
Copy Markdown
Contributor

@Ahmad8864 Ahmad8864 commented Nov 11, 2025

Summary

This PR updates the logic in mergeConfigs to handle output file paths more consistently. The output file name now automatically matches the selected style, unless a specific file path is set in the config or via the CLI.

Changes

  • Config merging:
    Updated mergeConfigs in src/config/configLoad.ts so that when only a style is provided, the default output file path updates to match that style. If a file path is explicitly set, it stays unchanged.
  • Tests:
    Added new tests in tests/config/configLoad.test.ts to cover these scenarios and verify that the path updates correctly when it should, and stays the same when a file path is explicitly defined.

Checklist

  • Run npm run test
  • Run npm run lint

@Ahmad8864 Ahmad8864 requested a review from yamadashy as a code owner November 11, 2025 03:16
Copilot AI review requested due to automatic review settings November 11, 2025 03:16
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Nov 11, 2025

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

The PR updates the mergeConfigs function to automatically derive and adjust the output filepath based on the selected style when filepath is not explicitly provided by the user, while preserving any explicitly configured paths and maintaining backward compatibility.

Changes

Cohort / File(s) Summary
Configuration filepath mapping logic
src/config/configLoad.ts
Introduces style-based filepath derivation in mergeConfigs. When a filepath exists but was not explicitly set by the user and matches the base config's filepath, the function now computes the desired path from the current style and updates the output if different.
Configuration merge tests
tests/config/configLoad.test.ts
Adds four test cases covering style-based filepath mapping: CLI-provided style with default filename, explicitly provided CLI filepath preservation, explicitly provided file config filepath preservation, and file config style with default mapping.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Logic comprehension: The new filepath derivation logic requires understanding the interaction between style selection, explicit vs. implicit filepath configuration, and the base config state.
  • Test coverage verification: Ensure the four new test cases comprehensively cover the conditional branches in the updated mergeConfigs logic.
  • Edge cases: Verify handling of scenarios where style is provided through different configuration sources (CLI vs. file config) and interaction with existing default filepath behavior.

Possibly related PRs

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The PR title 'fix(config): set file extension based on style parameter' is directly related to the main change - updating mergeConfigs to align output file paths with the selected style.
Description check ✅ Passed The PR description covers the key changes, includes explanations of what was modified and why, provides test coverage details, and completes the required checklist items (npm run test and npm run lint marked as done).
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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.

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @Ahmad8864, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request refines the configuration merging process to ensure greater consistency in how output file paths are determined. The core change ensures that the output file extension aligns with the chosen style by default, while still respecting any explicitly defined file paths from either the configuration file or command-line arguments. This makes the system more intuitive by linking the output format directly to the file extension, unless overridden.

Highlights

  • Config merging logic: The mergeConfigs function in src/config/configLoad.ts has been updated. It now automatically sets the default output file path to match the selected style if no specific file path is provided. Explicitly set file paths, whether from the config file or CLI, will always take precedence and remain unchanged.
  • New tests: New test cases have been added to tests/config/configLoad.test.ts to validate the updated configuration merging behavior. These tests ensure that the output file path correctly updates to match the style when appropriate, and remains unchanged when an explicit path is defined.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request successfully updates the configuration merging logic to automatically set the output file extension based on the selected style, which is a great improvement for user experience. The new tests are comprehensive and correctly verify the intended behavior across different scenarios. I've identified an opportunity to simplify the new logic in src/config/configLoad.ts by removing some redundant conditions and dead code, which will enhance the code's readability and maintainability.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR enhances the configuration merging logic to automatically update the output file extension to match the selected style when no explicit file path is provided.

Key Changes:

  • Modified mergeConfigs function to intelligently adjust output file paths based on style selection
  • Added logic to detect whether a file path was explicitly set versus inherited from defaults
  • Added comprehensive test coverage for various style and file path combination scenarios

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/config/configLoad.ts Enhanced mergeConfigs to automatically set file extension based on style when filePath is not explicitly provided, while preserving explicit user-specified paths
tests/config/configLoad.test.ts Added four new test cases covering scenarios: style-only via CLI, explicit filePath with style, file config filePath with CLI style, and style in file config without filePath

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
tests/config/configLoad.test.ts (1)

305-343: Excellent test coverage for the new file path adjustment behavior!

The four new tests comprehensively validate the core scenarios:

  • Auto-adjusting filePath when only style is provided (CLI or file config)
  • Preserving explicit filePaths regardless of style changes
  • Correct handling of precedence between CLI and file config

The test assertions correctly match the defaultFilePathMap values and verify that user-provided paths are never overridden.

Optional enhancement: Consider adding a test where both style and filePath are provided in file config (not CLI) to explicitly verify that explicit file config paths are preserved. While this is implicitly covered by the filePathExplicit logic, it would make the test suite even more complete.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1dd30cd and e82c9d2.

📒 Files selected for processing (2)
  • src/config/configLoad.ts (1 hunks)
  • tests/config/configLoad.test.ts (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (2)
tests/config/configLoad.test.ts (1)
src/config/configLoad.ts (1)
  • mergeConfigs (170-243)
src/config/configLoad.ts (2)
src/config/configSchema.ts (1)
  • defaultFilePathMap (9-14)
src/shared/logger.ts (1)
  • logger (89-89)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Agent
🔇 Additional comments (2)
src/config/configLoad.ts (2)

198-199: Clean implementation of explicit filePath detection.

The filePathExplicit flag correctly identifies when the user has provided a filePath in either source (file config or CLI), preventing unwanted auto-adjustments. The style computation with fallback ensures we always have a valid style value.


204-210: Smart conditional logic for automatic filePath adjustment.

The implementation correctly identifies when a filePath should be auto-adjusted to match the style:

  1. Verifies the user didn't explicitly provide a path
  2. Confirms the current path came from base config defaults (not from elsewhere)
  3. Only adjusts when the desired path differs

This preserves user intent while providing convenient automatic file extension updates.

@Ahmad8864
Copy link
Copy Markdown
Contributor Author

@yamadashy Hi there, just wanted to check if I needed to do anything else to get a review.

@yamadashy
Copy link
Copy Markdown
Owner

Hi, @Ahmad8864!
Thank you so much for this fix PR!

It looks like there was a regression introduced in #923. I really appreciate you catching this and fixing it!

The code looks good. I just added a comment to explain the logic.

I'll merge this now. Thanks again!

@codecov
Copy link
Copy Markdown

codecov bot commented Nov 15, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.68%. Comparing base (6b84c36) to head (b42c643).
⚠️ Report is 11 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #947      +/-   ##
==========================================
+ Coverage   89.62%   89.68%   +0.05%     
==========================================
  Files         111      111              
  Lines        7839     7843       +4     
  Branches     1501     1504       +3     
==========================================
+ Hits         7026     7034       +8     
+ Misses        813      809       -4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@yamadashy yamadashy merged commit 0703787 into yamadashy:main Nov 15, 2025
52 of 53 checks passed
yamadashy added a commit that referenced this pull request Nov 15, 2025
Add release notes documenting:
- Bug fix for output file extension not matching style parameter (#947)
- Package size reduction by replacing tree-sitter-wasms (#942)
- Dependency updates (#944)

This release fixes an issue introduced in v1.9.0 where the output file
extension didn't automatically adjust when using --style option.
@coderabbitai coderabbitai bot mentioned this pull request Nov 16, 2025
2 tasks
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