-
-
Couldn't load subscription status.
- Fork 732
feat(cli): enhance init command #7753
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
🦋 Changeset detectedLatest commit: 52827ad The changes in this PR will be included in the next version bump. This PR includes changesets to release 14 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
CodSpeed Performance ReportMerging #7753 will not alter performanceComparing Summary
Footnotes
|
WalkthroughThe init command now detects VCS ignore files (.gitignore or .ignore) and a dist/ folder and assembles Configuration::init() accordingly: VCS is enabled via a new VcsConfiguration::new_git_ignore(), and files.includes uses a double-exclude to ignore dist/. Init output is produced via a new InitDiagnostic. In-memory FS path_exists now checks map key existence. Tests: added init test for VCS/dist handling; adjusted a format test expectation. No public API changes beyond the new VcsConfiguration constructor. Suggested reviewers
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ 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). (8)
Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (6)
crates/biome_fs/src/fs/memory.rs (1)
203-206: path_exists ignores directories; align behaviour with real FScontains_key() returns false for folders that only exist via child entries (e.g. "dist/index.js"). This can cause false negatives versus an OS FS. Consider treating a path as existing if any key starts with it.
- fn path_exists(&self, path: &Utf8Path) -> bool { - let files = self.files.0.read(); - files.contains_key(path) - } + fn path_exists(&self, path: &Utf8Path) -> bool { + let files = self.files.0.read(); + files.contains_key(path) || files.keys().any(|p| p.starts_with(path)) + }This also lets init detect a “dist” directory when only files under it are present.
crates/biome_configuration/src/vcs.rs (1)
68-76: Add rustdoc to the new constructorPublic helper lacks rustdoc. Add a brief comment to aid discoverability and keep API docs complete.
- pub fn new_git_ignore() -> Self { + /// Convenience constructor enabling VCS integration with Git and using the ignore file. + /// Sets `enabled = true`, `clientKind = "git"`, and `useIgnoreFile = true`. + pub fn new_git_ignore() -> Self { Self { enabled: Some(true.into()), client_kind: Some(VcsClientKind::Git), use_ignore_file: Some(true.into()), root: None, default_branch: None, } } ```<!-- review_comment_end --> </blockquote></details> <details> <summary>crates/biome_cli/tests/commands/format.rs (1)</summary><blockquote> `3432-3432`: **HTML default now errors — confirm behaviour and rename test** Expectation flips to error. Is HTML formatting now disabled by default? If intentional, consider renaming the test to reflect the new default, e.g. html_disabled_by_default, and ensure docs mention this. <!-- review_comment_end --> </blockquote></details> <details> <summary>crates/biome_cli/tests/commands/init.rs (1)</summary><blockquote> `43-61`: **Model dist as a directory for realism** The test inserts "dist" as an empty file to trigger detection. Once MemoryFS.path_exists recognises directories (see separate comment), prefer inserting a child file instead: ```diff - fs.insert("dist".into(), "".as_bytes()); + fs.insert("dist/index.js".into(), b"");This mirrors real projects better and aligns MemoryFS with OS semantics.
crates/biome_cli/src/commands/init.rs (2)
23-34: Consider broadening generated-folder detectionToday only “dist” is handled. You might want a small list (e.g. build, out, coverage, .next, public, target) and generate corresponding double-excludes.
Happy to draft a tiny helper that builds includes = ["**", ...excludes].
47-51: Prefer Console.message/diagnostic for consistencyYou’re logging a diagnostic via PrintDiagnostic inside log(). For consistency with biome_console usage, prefer message() for plain markup or diagnostic() for diagnostics output.
Example:
session.app.console.message(markup! { {PrintDiagnostic::simple(&diagnostic)} });Based on learnings.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (6)
crates/biome_cli/tests/snapshots/main_commands_format/html_enabled_by_default.snapis excluded by!**/*.snapand included by**crates/biome_cli/tests/snapshots/main_commands_init/creates_config_file.snapis excluded by!**/*.snapand included by**crates/biome_cli/tests/snapshots/main_commands_init/creates_config_file_when_biome_installed_via_package_manager.snapis excluded by!**/*.snapand included by**crates/biome_cli/tests/snapshots/main_commands_init/creates_config_jsonc_file.snapis excluded by!**/*.snapand included by**crates/biome_cli/tests/snapshots/main_commands_init/enables_vcs_and_ignore_dist.snapis excluded by!**/*.snapand included by**crates/biome_diagnostics_categories/src/categories.rsis excluded by!**/categories.rsand included by**
📒 Files selected for processing (6)
.changeset/busy-pens-send.md(1 hunks)crates/biome_cli/src/commands/init.rs(2 hunks)crates/biome_cli/tests/commands/format.rs(1 hunks)crates/biome_cli/tests/commands/init.rs(1 hunks)crates/biome_configuration/src/vcs.rs(1 hunks)crates/biome_fs/src/fs/memory.rs(1 hunks)
🧰 Additional context used
📓 Path-based instructions (6)
crates/biome_*/**
📄 CodeRabbit inference engine (CLAUDE.md)
Place core crates under /crates/biome_*/
Files:
crates/biome_fs/src/fs/memory.rscrates/biome_cli/tests/commands/init.rscrates/biome_configuration/src/vcs.rscrates/biome_cli/tests/commands/format.rscrates/biome_cli/src/commands/init.rs
**/*.{rs,toml}
📄 CodeRabbit inference engine (CONTRIBUTING.md)
Before committing, format Rust and TOML files (e.g., via
just f/just format)
Files:
crates/biome_fs/src/fs/memory.rscrates/biome_cli/tests/commands/init.rscrates/biome_configuration/src/vcs.rscrates/biome_cli/tests/commands/format.rscrates/biome_cli/src/commands/init.rs
**/*.rs
📄 CodeRabbit inference engine (CONTRIBUTING.md)
Document rules, assists, and options via inline rustdoc in Rust source
Files:
crates/biome_fs/src/fs/memory.rscrates/biome_cli/tests/commands/init.rscrates/biome_configuration/src/vcs.rscrates/biome_cli/tests/commands/format.rscrates/biome_cli/src/commands/init.rs
**/tests/**
📄 CodeRabbit inference engine (CLAUDE.md)
Place test files under a tests/ directory in each crate
Files:
crates/biome_cli/tests/commands/init.rscrates/biome_cli/tests/commands/format.rs
crates/biome_configuration/src/**
📄 CodeRabbit inference engine (CLAUDE.md)
Keep configuration sources under biome_configuration/src/
Files:
crates/biome_configuration/src/vcs.rs
.changeset/**/*.md
📄 CodeRabbit inference engine (CONTRIBUTING.md)
.changeset/**/*.md: Create changesets using thejust new-changesetcommand; do not author them manually
In changeset markdown, only use headers #### or #####
Changeset descriptions must end every sentence with a full stop (.)
For bug fixes, start the changeset description with a linked issue reference like “Fixed #1234”
Prefer past tense for what was done and present tense for current behavior in changesets
Files:
.changeset/busy-pens-send.md
🧠 Learnings (4)
📚 Learning: 2025-10-02T12:58:46.845Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-10-02T12:58:46.845Z
Learning: Applies to crates/biome_formatter/biome_html_formatter/tests/language.rs : Create `HtmlTestFormatLanguage` and implement the `TestFormatLanguage` trait
Applied to files:
crates/biome_cli/tests/commands/format.rs
📚 Learning: 2025-10-02T12:58:46.845Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-10-02T12:58:46.845Z
Learning: Applies to crates/biome_formatter/biome_html_formatter/tests/spec_tests.rs : Configure test generation using `tests_macros::gen_tests! {"tests/specs/html/**/*.html", crate::spec_test::run, ""}` inside a formatter::html_module module
Applied to files:
crates/biome_cli/tests/commands/format.rs
📚 Learning: 2025-08-17T08:55:30.118Z
Learnt from: CR
PR: biomejs/biome#0
File: CLAUDE.md:0-0
Timestamp: 2025-08-17T08:55:30.118Z
Learning: Applies to crates/biome_html_formatter/benches/html_formatter.rs : Maintain the HTML formatter benchmark at benches/html_formatter.rs within the biome_html_formatter crate
Applied to files:
crates/biome_cli/tests/commands/format.rs
📚 Learning: 2025-10-02T12:58:46.845Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-10-02T12:58:46.845Z
Learning: Applies to crates/biome_formatter/biome_html_formatter/tests/spec_test.rs : Provide a `run` function that builds a SpecSnapshot with HtmlFormatLanguage and HtmlTestFormatLanguage and calls `snapshot.test()`
Applied to files:
crates/biome_cli/tests/commands/format.rs
🧬 Code graph analysis (3)
crates/biome_cli/tests/commands/init.rs (3)
crates/biome_fs/src/fs/memory.rs (1)
default(37-49)crates/biome_cli/tests/main.rs (1)
run_cli(332-347)crates/biome_cli/tests/snap_test.rs (1)
assert_cli_snapshot(407-409)
crates/biome_configuration/src/vcs.rs (1)
packages/@biomejs/backend-jsonrpc/src/workspace.ts (1)
VcsClientKind(863-863)
crates/biome_cli/src/commands/init.rs (4)
crates/biome_service/src/configuration.rs (1)
create_config(380-430)crates/biome_fs/src/fs/memory.rs (1)
working_directory(199-201)crates/biome_configuration/src/vcs.rs (1)
new_git_ignore(68-76)crates/biome_diagnostics/src/display.rs (1)
simple(47-53)
⏰ 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). (8)
- GitHub Check: Test (depot-windows-2022-16)
- GitHub Check: Documentation
- GitHub Check: Test (depot-ubuntu-24.04-arm-16)
- GitHub Check: Lint project (depot-ubuntu-24.04-arm-16)
- GitHub Check: Check Dependencies
- GitHub Check: Lint project (depot-windows-2022)
- GitHub Check: autofix
- GitHub Check: Bench (biome_configuration)
🔇 Additional comments (1)
crates/biome_cli/src/commands/init.rs (1)
16-22: VCS detection looks goodEnables VCS when either ignore file is present and uses the new helper. Nice and tidy.
WalkthroughThe init command now computes configuration based on project state: it detects VCS ignore files (.gitignore/.ignore) to enable VCS with useIgnoreFile, and auto-excludes dist/ via scanning includes with a double-exclude for dist. A new InitDiagnostic logs dynamic messages for VCS and dist detection and the created config file. VcsConfiguration gains new_git_ignore(). MemoryFileSystem::path_exists now checks map membership directly. Tests add coverage for VCS/dist handling and flip an expectation in html_enabled_by_default. A changeset introduces a minor version bump for @biomejs/biome. Suggested reviewers
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🧹 Nitpick comments (6)
crates/biome_cli/tests/commands/format.rs (1)
3432-3432: Test name no longer matches behaviourThe test asserts an error by default. Consider renaming to html_disabled_by_default to avoid confusion.
crates/biome_fs/src/fs/memory.rs (1)
203-206: Make path_exists detect directories tooCurrent implementation returns true only for files. To align with typical “exists” semantics (file or directory), consider delegating to path_kind:
- fn path_exists(&self, path: &Utf8Path) -> bool { - let files = self.files.0.read(); - files.contains_key(path) - } + fn path_exists(&self, path: &Utf8Path) -> bool { + self.path_kind(path).is_ok() + }This keeps tests working and makes dist/ checks more realistic.
crates/biome_configuration/src/vcs.rs (1)
68-76: Add rustdoc for the new public constructornew_git_ignore is a public convenience API; please add a brief rustdoc explaining intent and defaults it sets.
As per coding guidelines
crates/biome_cli/tests/commands/init.rs (1)
43-61: Simulate dist as a directory for realismTo better mirror real projects, insert a file under dist (e.g. dist/index.js) rather than a bare "dist" entry. This will continue to pass if MemoryFileSystem::path_exists is later upgraded to detect directories.
crates/biome_cli/src/commands/init.rs (2)
23-34: Glob pattern and unwraps
- Consider using expect(...) over unwrap() to aid debugging if patterns ever change.
- Please confirm that "!!/dist" excludes files under dist as intended; if the grammar expects a directory glob, "!!/dist/**" may be clearer.
- "**".parse::<biome_glob::NormalizedGlob>().unwrap(), - "!!**/dist".parse::<biome_glob::NormalizedGlob>().unwrap(), + "**" + .parse::<biome_glob::NormalizedGlob>() + .expect("hard-coded glob must be valid"), + "!!**/dist" + .parse::<biome_glob::NormalizedGlob>() + .expect("hard-coded glob must be valid"),If the engine requires a directory suffix, switch to "!!/dist/".
80-121: Minor copy tweaks in the init messagePolish the UX copy:
- “Setup an editor extension” → “Set up an editor extension”.
- “Seek for help on Discord” → “Seek help on Discord”.
- "<Dim>"1."</Dim>" "<Emphasis>"Setup an editor extension"</Emphasis>" + "<Dim>"1."</Dim>" "<Emphasis>"Set up an editor extension"</Emphasis>" @@ - Seek for help on Discord: "<Hyperlink href="https://biomejs.dev/chat">"https://biomejs.dev/chat"</Hyperlink>" + Seek help on Discord: "<Hyperlink href="https://biomejs.dev/chat">"https://biomejs.dev/chat"</Hyperlink>"
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (7)
crates/biome_cli/tests/snapshots/main_commands_format/html_enabled_by_default.snapis excluded by!**/*.snapand included by**crates/biome_cli/tests/snapshots/main_commands_init/creates_config_file.snapis excluded by!**/*.snapand included by**crates/biome_cli/tests/snapshots/main_commands_init/creates_config_file_when_biome_installed_via_package_manager.snapis excluded by!**/*.snapand included by**crates/biome_cli/tests/snapshots/main_commands_init/creates_config_jsonc_file.snapis excluded by!**/*.snapand included by**crates/biome_cli/tests/snapshots/main_commands_init/enables_vcs_and_ignore_dist.snapis excluded by!**/*.snapand included by**crates/biome_diagnostics_categories/src/categories.rsis excluded by!**/categories.rsand included by**packages/@biomejs/backend-jsonrpc/src/workspace.tsis excluded by!**/backend-jsonrpc/src/workspace.tsand included by**
📒 Files selected for processing (6)
.changeset/busy-pens-send.md(1 hunks)crates/biome_cli/src/commands/init.rs(2 hunks)crates/biome_cli/tests/commands/format.rs(1 hunks)crates/biome_cli/tests/commands/init.rs(1 hunks)crates/biome_configuration/src/vcs.rs(1 hunks)crates/biome_fs/src/fs/memory.rs(1 hunks)
🧰 Additional context used
📓 Path-based instructions (6)
crates/biome_*/**
📄 CodeRabbit inference engine (CLAUDE.md)
Place core crates under /crates/biome_*/
Files:
crates/biome_fs/src/fs/memory.rscrates/biome_cli/tests/commands/init.rscrates/biome_cli/tests/commands/format.rscrates/biome_configuration/src/vcs.rscrates/biome_cli/src/commands/init.rs
**/*.{rs,toml}
📄 CodeRabbit inference engine (CONTRIBUTING.md)
Before committing, format Rust and TOML files (e.g., via
just f/just format)
Files:
crates/biome_fs/src/fs/memory.rscrates/biome_cli/tests/commands/init.rscrates/biome_cli/tests/commands/format.rscrates/biome_configuration/src/vcs.rscrates/biome_cli/src/commands/init.rs
**/*.rs
📄 CodeRabbit inference engine (CONTRIBUTING.md)
Document rules, assists, and options via inline rustdoc in Rust source
Files:
crates/biome_fs/src/fs/memory.rscrates/biome_cli/tests/commands/init.rscrates/biome_cli/tests/commands/format.rscrates/biome_configuration/src/vcs.rscrates/biome_cli/src/commands/init.rs
.changeset/**/*.md
📄 CodeRabbit inference engine (CONTRIBUTING.md)
.changeset/**/*.md: Create changesets using thejust new-changesetcommand; do not author them manually
In changeset markdown, only use headers #### or #####
Changeset descriptions must end every sentence with a full stop (.)
For bug fixes, start the changeset description with a linked issue reference like “Fixed #1234”
Prefer past tense for what was done and present tense for current behavior in changesets
Files:
.changeset/busy-pens-send.md
**/tests/**
📄 CodeRabbit inference engine (CLAUDE.md)
Place test files under a tests/ directory in each crate
Files:
crates/biome_cli/tests/commands/init.rscrates/biome_cli/tests/commands/format.rs
crates/biome_configuration/src/**
📄 CodeRabbit inference engine (CLAUDE.md)
Keep configuration sources under biome_configuration/src/
Files:
crates/biome_configuration/src/vcs.rs
🧠 Learnings (4)
📚 Learning: 2025-10-02T12:58:46.845Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-10-02T12:58:46.845Z
Learning: Applies to crates/biome_formatter/biome_html_formatter/tests/spec_tests.rs : Configure test generation using `tests_macros::gen_tests! {"tests/specs/html/**/*.html", crate::spec_test::run, ""}` inside a formatter::html_module module
Applied to files:
crates/biome_cli/tests/commands/format.rs
📚 Learning: 2025-10-02T12:58:46.845Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-10-02T12:58:46.845Z
Learning: Applies to crates/biome_formatter/biome_html_formatter/tests/language.rs : Create `HtmlTestFormatLanguage` and implement the `TestFormatLanguage` trait
Applied to files:
crates/biome_cli/tests/commands/format.rs
📚 Learning: 2025-08-17T08:55:30.118Z
Learnt from: CR
PR: biomejs/biome#0
File: CLAUDE.md:0-0
Timestamp: 2025-08-17T08:55:30.118Z
Learning: Applies to crates/biome_html_formatter/benches/html_formatter.rs : Maintain the HTML formatter benchmark at benches/html_formatter.rs within the biome_html_formatter crate
Applied to files:
crates/biome_cli/tests/commands/format.rs
📚 Learning: 2025-10-02T12:58:46.845Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-10-02T12:58:46.845Z
Learning: Applies to crates/biome_formatter/biome_html_formatter/tests/spec_test.rs : Provide a `run` function that builds a SpecSnapshot with HtmlFormatLanguage and HtmlTestFormatLanguage and calls `snapshot.test()`
Applied to files:
crates/biome_cli/tests/commands/format.rs
🧬 Code graph analysis (3)
crates/biome_cli/tests/commands/init.rs (3)
crates/biome_fs/src/fs/memory.rs (1)
default(37-49)crates/biome_cli/tests/main.rs (1)
run_cli(332-347)crates/biome_cli/tests/snap_test.rs (1)
assert_cli_snapshot(407-409)
crates/biome_configuration/src/vcs.rs (1)
packages/@biomejs/backend-jsonrpc/src/workspace.ts (1)
VcsClientKind(863-863)
crates/biome_cli/src/commands/init.rs (6)
packages/@biomejs/backend-jsonrpc/src/workspace.ts (3)
VcsConfiguration(347-370)FilesConfiguration(146-165)NormalizedGlob(381-381)crates/biome_service/src/configuration.rs (1)
create_config(380-430)crates/biome_fs/src/fs/memory.rs (1)
working_directory(199-201)crates/biome_configuration/src/vcs.rs (1)
new_git_ignore(68-76)crates/biome_fs/src/fs.rs (2)
biome_jsonc(28-30)biome_json(24-26)crates/biome_diagnostics/src/display.rs (1)
simple(47-53)
⏰ 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). (7)
- GitHub Check: Documentation
- GitHub Check: Test (depot-windows-2022-16)
- GitHub Check: Test (depot-ubuntu-24.04-arm-16)
- GitHub Check: Check Dependencies
- GitHub Check: Lint project (depot-ubuntu-24.04-arm-16)
- GitHub Check: Lint project (depot-windows-2022)
- GitHub Check: Bench (biome_configuration)
🔇 Additional comments (1)
crates/biome_cli/src/commands/init.rs (1)
16-21: VCS detection looks goodClean, straightforward use of VcsConfiguration::new_git_ignore() when an ignore file is present. LGTM.
Summary
I think we're almost there regarding the release of v2.3. This is the last enhancement I can think of (we discussed this enhancement before).
This PR checks for ignore files and dist folder, and updates the configuration file accordingly.
Are there any other built folders that you can think of?
Test Plan
Added new test. Updated existing tests
Docs
I wanted to add a link for the double-exclude syntax, and I realised that it's very hidden inside our docs, which isn't very intuitive. Since the doule-exclude syntax is stabilised, it should be part of the guides, even though it's an advanced concept.
I think we should update our docs, particularly this section: https://next.biomejs.dev/guides/configure-biome/#control-files-via-configuration