+
Skip to content

Conversation

anaisbetts
Copy link

@anaisbetts anaisbetts commented Sep 26, 2025

Summary

Related to #7598, this implements suggestion 3, "auto" as a lineEnding format, without making it the default. Without this feature, it is very difficult to run Biome against cross-platform environments such as Electron apps, because biome check in CI will inevitably fail either macOS or Windows, there is no correct option other than completely disabling the formatter in CI, or using .gitattributes to force the repo to be checked out in LF

Test Plan

Unit tests

Copy link

changeset-bot bot commented Sep 26, 2025

🦋 Changeset detected

Latest commit: 65f309f

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 14 packages
Name Type
@biomejs/biome Minor
@biomejs/cli-win32-x64 Minor
@biomejs/cli-win32-arm64 Minor
@biomejs/cli-darwin-x64 Minor
@biomejs/cli-darwin-arm64 Minor
@biomejs/cli-linux-x64 Minor
@biomejs/cli-linux-arm64 Minor
@biomejs/cli-linux-x64-musl Minor
@biomejs/cli-linux-arm64-musl Minor
@biomejs/wasm-web Minor
@biomejs/wasm-bundler Minor
@biomejs/wasm-nodejs Minor
@biomejs/backend-jsonrpc Patch
@biomejs/js-api Major

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

@github-actions github-actions bot added A-Project Area: project A-Formatter Area: formatter L-JavaScript Language: JavaScript and super languages labels Sep 26, 2025
@anaisbetts anaisbetts changed the title Feat: Add 'auto' mode to lineEndings feat: Add 'auto' mode to lineEndings Sep 26, 2025
@anaisbetts anaisbetts changed the title feat: Add 'auto' mode to lineEndings feat: add 'auto' mode to lineEndings Sep 26, 2025
@anaisbetts anaisbetts force-pushed the lineendings-auto-mode branch from 544b595 to 1603f0f Compare September 26, 2025 16:24
@github-actions github-actions bot added the A-CLI Area: CLI label Sep 26, 2025
@joaohenriquesfr
Copy link

Thank you

@anaisbetts anaisbetts force-pushed the lineendings-auto-mode branch from 1603f0f to d85ad41 Compare September 26, 2025 17:15
Copy link

codspeed-hq bot commented Sep 26, 2025

CodSpeed Performance Report

Merging #7599 will not alter performance

Comparing anaisbetts:lineendings-auto-mode (255e8aa) with next (98ad5a9)

Summary

✅ 133 untouched

@anaisbetts anaisbetts marked this pull request as ready for review September 29, 2025 07:20
Copy link
Contributor

coderabbitai bot commented Sep 29, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

Adds a platform-aware LineEnding::Auto variant that resolves to CRLF on Windows and LF on other platforms. Updates LineEnding API (as_str made non‑const, adds is_auto), FromStr and Display to handle "auto". Expands formatter configuration and CLI parsing across formats to accept auto, conditions snapshot normalization on auto, and adds tests plus a JS spec and options.json for the auto case. Includes a changeset entry documenting the new auto option.

Possibly related PRs

Suggested labels

L-JSON, L-CSS, L-HTML

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Title Check ✅ Passed The title succinctly captures the core change by indicating the addition of an “auto” mode for line endings and follows conventional semantics with the “feat:” prefix, making it clear and specific without listing implementation details.
Description Check ✅ Passed The description clearly outlines the feature’s purpose, motivation, and reference discussion, and includes a test plan, demonstrating direct relevance to the changeset without being off-topic.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

📜 Recent 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 255e8aa and 65f309f.

📒 Files selected for processing (1)
  • .changeset/warm-insects-dress.md (1 hunks)

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.

Copy link
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: 1

🧹 Nitpick comments (3)
crates/biome_js_formatter/tests/specs/js/module/line-ending/auto/line_ending.js (1)

1-17: Fixture looks fine; tiny nit for robustness.

Consider ensuring there’s a terminal newline to make the line‑ending assertion unambiguous on all platforms, and keep the fixture minimal (one or two lines is enough) to avoid noisy diffs in future. Happy as-is if you prefer.

crates/biome_formatter/src/lib.rs (2)

150-173: Auto variant looks good; consider keeping as_str const to avoid needless breakage.

  • The new LineEnding::Auto and parsing/formatting are sensible. 👍
  • You dropped as_str from const to non‑const. If MSRV allows, you can keep it const even with Auto using cfg! or #[cfg] blocks, preserving any const‑context uses and reducing the surface of the major bump.

Suggested change:

-    pub fn as_str(&self) -> &'static str {
+    pub const fn as_str(&self) -> &'static str {
         match self {
             Self::Lf => "\n",
             Self::Crlf => "\r\n",
             Self::Cr => "\r",
-            Self::Auto => {
-                #[cfg(windows)]
-                {
-                    "\r\n"
-                }
-                #[cfg(not(windows))]
-                {
-                    "\n"
-                }
-            }
+            Self::Auto => {
+                if cfg!(windows) { "\r\n" } else { "\n" }
+            }
         }
     }

If MSRV or CI objects to const here, ignore this suggestion.

Also applies to: 190-194, 199-208, 211-219


141-149: Minor docs nit.

“inside git repos” → “inside Git repositories” for brand/style consistency.

-    ///  Line Feed only (\n), common on Linux and macOS as well as inside git repos
+    ///  Line Feed only (\n), common on Linux and macOS as well as inside Git repositories.
📜 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 5c3d542 and 2ef176d.

⛔ Files ignored due to path filters (6)
  • crates/biome_cli/tests/snapshots/main_commands_check/check_help.snap is excluded by !**/*.snap and included by **
  • crates/biome_cli/tests/snapshots/main_commands_ci/ci_help.snap is excluded by !**/*.snap and included by **
  • crates/biome_cli/tests/snapshots/main_commands_format/format_help.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_formatter/tests/specs/js/module/line-ending/auto/line_ending.js.snap is excluded by !**/*.snap and included by **
  • packages/@biomejs/backend-jsonrpc/src/workspace.ts is excluded by !**/backend-jsonrpc/src/workspace.ts and included by **
  • packages/@biomejs/biome/configuration_schema.json is excluded by !**/configuration_schema.json and included by **
📒 Files selected for processing (8)
  • .changeset/warm-insects-dress.md (1 hunks)
  • crates/biome_configuration/src/formatter.rs (1 hunks)
  • crates/biome_configuration/src/overrides.rs (1 hunks)
  • crates/biome_formatter/src/lib.rs (4 hunks)
  • crates/biome_formatter/src/printer/mod.rs (1 hunks)
  • crates/biome_formatter_test/src/spec.rs (1 hunks)
  • crates/biome_js_formatter/tests/specs/js/module/line-ending/auto/line_ending.js (1 hunks)
  • crates/biome_js_formatter/tests/specs/js/module/line-ending/auto/options.json (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_formatter/src/printer/mod.rs
  • crates/biome_js_formatter/tests/specs/js/module/line-ending/auto/options.json
  • crates/biome_js_formatter/tests/specs/js/module/line-ending/auto/line_ending.js
  • crates/biome_formatter_test/src/spec.rs
  • crates/biome_formatter/src/lib.rs
  • crates/biome_configuration/src/overrides.rs
  • crates/biome_configuration/src/formatter.rs
**/*.rs

📄 CodeRabbit inference engine (CONTRIBUTING.md)

Format all Rust source files before committing (just f)

Files:

  • crates/biome_formatter/src/printer/mod.rs
  • crates/biome_formatter_test/src/spec.rs
  • crates/biome_formatter/src/lib.rs
  • crates/biome_configuration/src/overrides.rs
  • crates/biome_configuration/src/formatter.rs
crates/biome_*_{syntax,parser,formatter,analyze,factory,semantic}/**

📄 CodeRabbit inference engine (CLAUDE.md)

Maintain the per-language crate structure: biome_{lang}_{syntax,parser,formatter,analyze,factory,semantic}

Files:

  • crates/biome_js_formatter/tests/specs/js/module/line-ending/auto/options.json
  • crates/biome_js_formatter/tests/specs/js/module/line-ending/auto/line_ending.js
**/tests/**

📄 CodeRabbit inference engine (CLAUDE.md)

Place test files under a tests/ directory in each crate

Files:

  • crates/biome_js_formatter/tests/specs/js/module/line-ending/auto/options.json
  • crates/biome_js_formatter/tests/specs/js/module/line-ending/auto/line_ending.js
crates/biome_configuration/src/**

📄 CodeRabbit inference engine (CLAUDE.md)

Keep configuration sources under biome_configuration/src/

Files:

  • crates/biome_configuration/src/overrides.rs
  • crates/biome_configuration/src/formatter.rs
.changeset/*.md

📄 CodeRabbit inference engine (CONTRIBUTING.md)

.changeset/*.md: In changeset files, only use #### or ##### headers; avoid other header levels
Changeset descriptions should use past tense for what you did (e.g., "Added...")
Describe current Biome behavior in present tense within changesets (e.g., "Biome now supports...")
For bug fixes in changesets, start with a link to the issue (e.g., "Fixed #1234: ...")
When referencing rules or assists in changesets, include links to their documentation pages
Include a minimal code block in the changeset when applicable to demonstrate the change
End every sentence in the changeset description with a period

Files:

  • .changeset/warm-insects-dress.md
🧠 Learnings (8)
📚 Learning: 2025-08-11T11:48:27.774Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-08-11T11:48:27.774Z
Learning: Applies to crates/biome_formatter/biome_html_formatter/tests/language.rs : Create tests/language.rs defining HtmlTestFormatLanguage and implement TestFormatLanguage for it

Applied to files:

  • crates/biome_formatter/src/printer/mod.rs
  • crates/biome_formatter_test/src/spec.rs
📚 Learning: 2025-08-11T11:48:27.774Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-08-11T11:48:27.774Z
Learning: Applies to crates/biome_formatter/biome_html_formatter/tests/spec_test.rs : Create tests/spec_test.rs implementing the run(spec_input_file, _expected_file, test_directory, _file_type) function as shown and include!("language.rs")

Applied to files:

  • crates/biome_formatter/src/printer/mod.rs
  • crates/biome_formatter_test/src/spec.rs
📚 Learning: 2025-09-13T16:16:06.459Z
Learnt from: ematipico
PR: biomejs/biome#7467
File: crates/biome_service/src/file_handlers/html.rs:456-466
Timestamp: 2025-09-13T16:16:06.459Z
Learning: In biome_formatter, consecutive LineMode::Hard elements are automatically collapsed to a single newline by the printer. The printer has a test "it_prints_consecutive_hard_lines_as_one" that demonstrates this behavior - multiple consecutive hard line breaks result in only one newline in the output, not extra blank lines.

Applied to files:

  • crates/biome_formatter/src/printer/mod.rs
📚 Learning: 2025-08-11T11:48:27.774Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-08-11T11:48:27.774Z
Learning: Applies to crates/biome_formatter/biome_html_formatter/tests/spec_tests.rs : Create tests/spec_tests.rs in the biome_html_formatter crate that generates tests via tests_macros::gen_tests! for all HTML files at tests/specs/html/**/*.html

Applied to files:

  • crates/biome_formatter/src/printer/mod.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_formatter/src/printer/mod.rs
📚 Learning: 2025-08-11T11:48:27.774Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-08-11T11:48:27.774Z
Learning: Applies to crates/biome_formatter/biome_html_formatter/tests/specs/html/**/options.json : When non-default formatting options are needed for a test group, place an options.json (biome.json format) alongside the .html files in that folder

Applied to files:

  • crates/biome_js_formatter/tests/specs/js/module/line-ending/auto/options.json
📚 Learning: 2025-08-05T14:43:29.581Z
Learnt from: dyc3
PR: biomejs/biome#7081
File: packages/@biomejs/biome/configuration_schema.json:7765-7781
Timestamp: 2025-08-05T14:43:29.581Z
Learning: The file `packages/biomejs/biome/configuration_schema.json` is auto-generated and should not be manually edited or reviewed for schema issues; any changes should be made at the code generation source.

Applied to files:

  • crates/biome_js_formatter/tests/specs/js/module/line-ending/auto/options.json
📚 Learning: 2025-09-07T17:35:00.517Z
Learnt from: CR
PR: biomejs/biome#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-09-07T17:35:00.517Z
Learning: Applies to .changeset/*.md : Describe current Biome behavior in present tense within changesets (e.g., "Biome now supports...")

Applied to files:

  • .changeset/warm-insects-dress.md
🧬 Code graph analysis (1)
crates/biome_formatter/src/printer/mod.rs (2)
crates/biome_formatter/src/lib.rs (1)
  • as_code (1018-1020)
crates/biome_formatter/src/builders.rs (2)
  • block_indent (1189-1194)
  • hard_line_break (99-101)
🔇 Additional comments (5)
crates/biome_js_formatter/tests/specs/js/module/line-ending/auto/options.json (1)

1-6: LGTM! Clean test configuration.

The test configuration correctly follows the established pattern for formatter test options and properly references the schema. Based on learnings.

crates/biome_configuration/src/formatter.rs (1)

43-43: LGTM! CLI argument extended correctly.

The addition of "auto" to the line-ending argument options is consistent with the new LineEnding::Auto variant.

crates/biome_formatter/src/printer/mod.rs (1)

1513-1544: LGTM! Comprehensive test for Auto line endings.

The test properly validates OS-dependent behaviour with appropriate conditional compilation. The structure follows existing patterns and expectations align with the Auto semantics.

crates/biome_configuration/src/overrides.rs (1)

145-145: LGTM! Override configuration consistency maintained.

The addition of "auto" to the override line-ending options maintains consistency with the main formatter configuration.

crates/biome_formatter_test/src/spec.rs (1)

273-281: LGTM! Sensible conditional normalisation.

The logic correctly preserves platform-specific behaviour in snapshots when auto line endings are used, whilst maintaining existing normalisation for explicit line ending choices. Clear comment explains the reasoning well.

@ematipico
Copy link
Member

Thank you @anaisbetts

We will review the PR soon. In the meantime, can you send the PR against the next branch? This is what we do when we add new features, and it's also covered by our contribution guide

@anaisbetts anaisbetts force-pushed the lineendings-auto-mode branch from 2ef176d to e7d1ea6 Compare September 29, 2025 10:21
@anaisbetts anaisbetts changed the base branch from main to next September 29, 2025 10:21
@anaisbetts anaisbetts force-pushed the lineendings-auto-mode branch 2 times, most recently from 72d28ff to 7a5cfb6 Compare September 29, 2025 10:24
@anaisbetts
Copy link
Author

@coderabbitai generate docstrings

Copy link
Contributor

coderabbitai bot commented Sep 29, 2025

✅ Actions performed

Docstrings generation started.

coderabbitai bot added a commit that referenced this pull request Sep 29, 2025
Docstrings generation was requested by @anaisbetts.

* #7599 (comment)

The following files were modified:

* `crates/biome_formatter/src/lib.rs`
* `crates/biome_formatter_test/src/spec.rs`
Copy link
Contributor

coderabbitai bot commented Sep 29, 2025

Note

Generated docstrings for this pull request at #7615

anaisbetts pushed a commit to anaisbetts/biome that referenced this pull request Sep 29, 2025
Docstrings generation was requested by @anaisbetts.

* biomejs#7599 (comment)

The following files were modified:

* `crates/biome_formatter/src/lib.rs`
* `crates/biome_formatter_test/src/spec.rs`
Copy link
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)
crates/biome_formatter/src/printer/mod.rs (1)

1526-1558: Nice coverage for AUTO; mirrors CRLF/CR tests cleanly.

The cfg‑gated assertions make this robust across OSes. Consider a tiny helper to avoid repeating the common “function main()” setup across the three line‑ending tests.

📜 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 2ef176d and 7a5cfb6.

⛔ Files ignored due to path filters (4)
  • crates/biome_cli/tests/snapshots/main_commands_check/check_help.snap is excluded by !**/*.snap and included by **
  • crates/biome_cli/tests/snapshots/main_commands_ci/ci_help.snap is excluded by !**/*.snap and included by **
  • crates/biome_cli/tests/snapshots/main_commands_format/format_help.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_formatter/tests/specs/js/module/line-ending/auto/line_ending.js.snap is excluded by !**/*.snap and included by **
📒 Files selected for processing (8)
  • .changeset/warm-insects-dress.md (1 hunks)
  • crates/biome_configuration/src/formatter.rs (1 hunks)
  • crates/biome_configuration/src/overrides.rs (1 hunks)
  • crates/biome_formatter/src/lib.rs (4 hunks)
  • crates/biome_formatter/src/printer/mod.rs (1 hunks)
  • crates/biome_formatter_test/src/spec.rs (1 hunks)
  • crates/biome_js_formatter/tests/specs/js/module/line-ending/auto/line_ending.js (1 hunks)
  • crates/biome_js_formatter/tests/specs/js/module/line-ending/auto/options.json (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • crates/biome_configuration/src/overrides.rs
  • crates/biome_configuration/src/formatter.rs
🧰 Additional context used
📓 Path-based instructions (5)
crates/biome_*_{syntax,parser,formatter,analyze,factory,semantic}/**

📄 CodeRabbit inference engine (CLAUDE.md)

Maintain the per-language crate structure: biome_{lang}_{syntax,parser,formatter,analyze,factory,semantic}

Files:

  • crates/biome_js_formatter/tests/specs/js/module/line-ending/auto/options.json
  • crates/biome_js_formatter/tests/specs/js/module/line-ending/auto/line_ending.js
crates/biome_*/**

📄 CodeRabbit inference engine (CLAUDE.md)

Place core crates under /crates/biome_*/

Files:

  • crates/biome_js_formatter/tests/specs/js/module/line-ending/auto/options.json
  • crates/biome_js_formatter/tests/specs/js/module/line-ending/auto/line_ending.js
  • crates/biome_formatter/src/printer/mod.rs
  • crates/biome_formatter_test/src/spec.rs
  • crates/biome_formatter/src/lib.rs
**/tests/**

📄 CodeRabbit inference engine (CLAUDE.md)

Place test files under a tests/ directory in each crate

Files:

  • crates/biome_js_formatter/tests/specs/js/module/line-ending/auto/options.json
  • crates/biome_js_formatter/tests/specs/js/module/line-ending/auto/line_ending.js
**/*.rs

📄 CodeRabbit inference engine (CONTRIBUTING.md)

Format all Rust source files before committing (just f)

Files:

  • crates/biome_formatter/src/printer/mod.rs
  • crates/biome_formatter_test/src/spec.rs
  • crates/biome_formatter/src/lib.rs
.changeset/*.md

📄 CodeRabbit inference engine (CONTRIBUTING.md)

.changeset/*.md: In changeset files, only use #### or ##### headers; avoid other header levels
Changeset descriptions should use past tense for what you did (e.g., "Added...")
Describe current Biome behavior in present tense within changesets (e.g., "Biome now supports...")
For bug fixes in changesets, start with a link to the issue (e.g., "Fixed #1234: ...")
When referencing rules or assists in changesets, include links to their documentation pages
Include a minimal code block in the changeset when applicable to demonstrate the change
End every sentence in the changeset description with a period

Files:

  • .changeset/warm-insects-dress.md
🧠 Learnings (9)
📚 Learning: 2025-08-11T11:48:27.774Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-08-11T11:48:27.774Z
Learning: Applies to crates/biome_formatter/biome_html_formatter/tests/specs/html/**/options.json : When non-default formatting options are needed for a test group, place an options.json (biome.json format) alongside the .html files in that folder

Applied to files:

  • crates/biome_js_formatter/tests/specs/js/module/line-ending/auto/options.json
📚 Learning: 2025-08-05T14:43:29.581Z
Learnt from: dyc3
PR: biomejs/biome#7081
File: packages/@biomejs/biome/configuration_schema.json:7765-7781
Timestamp: 2025-08-05T14:43:29.581Z
Learning: The file `packages/biomejs/biome/configuration_schema.json` is auto-generated and should not be manually edited or reviewed for schema issues; any changes should be made at the code generation source.

Applied to files:

  • crates/biome_js_formatter/tests/specs/js/module/line-ending/auto/options.json
📚 Learning: 2025-08-11T11:48:27.774Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-08-11T11:48:27.774Z
Learning: Applies to crates/biome_formatter/biome_html_formatter/tests/language.rs : Create tests/language.rs defining HtmlTestFormatLanguage and implement TestFormatLanguage for it

Applied to files:

  • crates/biome_formatter/src/printer/mod.rs
  • crates/biome_formatter_test/src/spec.rs
📚 Learning: 2025-08-11T11:48:27.774Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-08-11T11:48:27.774Z
Learning: Applies to crates/biome_formatter/biome_html_formatter/tests/spec_test.rs : Create tests/spec_test.rs implementing the run(spec_input_file, _expected_file, test_directory, _file_type) function as shown and include!("language.rs")

Applied to files:

  • crates/biome_formatter/src/printer/mod.rs
  • crates/biome_formatter_test/src/spec.rs
📚 Learning: 2025-08-11T11:48:27.774Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-08-11T11:48:27.774Z
Learning: Applies to crates/biome_formatter/biome_html_formatter/tests/spec_tests.rs : Create tests/spec_tests.rs in the biome_html_formatter crate that generates tests via tests_macros::gen_tests! for all HTML files at tests/specs/html/**/*.html

Applied to files:

  • crates/biome_formatter/src/printer/mod.rs
📚 Learning: 2025-08-11T11:53:15.299Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_service/CONTRIBUTING.md:0-0
Timestamp: 2025-08-11T11:53:15.299Z
Learning: Applies to crates/biome_service/../biome_lsp/src/server.tests.rs : Keep end-to-end LSP tests in biome_lsp’s server.tests.rs

Applied to files:

  • crates/biome_formatter/src/printer/mod.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_formatter/src/printer/mod.rs
📚 Learning: 2025-09-13T16:16:06.459Z
Learnt from: ematipico
PR: biomejs/biome#7467
File: crates/biome_service/src/file_handlers/html.rs:456-466
Timestamp: 2025-09-13T16:16:06.459Z
Learning: In biome_formatter, consecutive LineMode::Hard elements are automatically collapsed to a single newline by the printer. The printer has a test "it_prints_consecutive_hard_lines_as_one" that demonstrates this behavior - multiple consecutive hard line breaks result in only one newline in the output, not extra blank lines.

Applied to files:

  • crates/biome_formatter/src/printer/mod.rs
📚 Learning: 2025-09-07T17:35:00.517Z
Learnt from: CR
PR: biomejs/biome#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-09-07T17:35:00.517Z
Learning: Applies to .changeset/*.md : Describe current Biome behavior in present tense within changesets (e.g., "Biome now supports...")

Applied to files:

  • .changeset/warm-insects-dress.md
🔇 Additional comments (8)
crates/biome_js_formatter/tests/specs/js/module/line-ending/auto/line_ending.js (1)

1-17: LGTM for the spec.

Parsable, minimal, and fit for exercising line‑ending output with options.json.

crates/biome_formatter_test/src/spec.rs (1)

273-281: Skip normalisation for AUTO: good call—preserves real OS newlines.

This aligns with the feature’s intent. Please confirm your CI matrix (Windows + Linux/macOS) remains stable given the OS‑specific snapshots here.

.changeset/warm-insects-dress.md (1)

5-5: Polish the header to match guideline tense and key.

Use past tense and the fully‑qualified option path.

-#### lineEnding has a new option 'auto', that is CRLF on Windows, and LF on non-Windows
+#### Added a new 'auto' option to formatter.lineEnding.

The body text and examples look good. As per coding guidelines.

crates/biome_js_formatter/tests/specs/js/module/line-ending/auto/options.json (1)

2-2: Please verify the $schema relative depth.

From crates/biome_js_formatter/tests/specs/js/module/line-ending/auto/, reaching the repo root should require fewer “../” hops than shown; this path looks over‑elevated. Editors may fail to resolve the schema. Keep the key as is ("lineEnding": "auto")—that’s spot on.

Run to confirm the $schema resolves to an existing file:

crates/biome_formatter/src/lib.rs (4)

151-154: LGTM! Clean enum variant addition.

The new Auto variant is well-documented and aligns perfectly with the PR objectives for cross-platform line ending handling.


158-174: Platform-specific logic implemented correctly.

The conditional compilation for Windows/non-Windows is spot on, though the method signature necessarily changes from const fn to fn due to the runtime platform detection.


191-194: Consistent method implementation.

The is_auto method follows the established pattern of other is_* methods perfectly. Nice consistency!


205-206: Complete trait implementation coverage.

Both FromStr and Display implementations properly handle the new Auto variant. The string representations are consistent with the established patterns.

Also applies to: 218-219

@anaisbetts anaisbetts closed this Sep 29, 2025
@anaisbetts anaisbetts reopened this Sep 29, 2025
@ematipico
Copy link
Member

ematipico commented Sep 30, 2025

The line ending option is also available for each language, for example here the option for JavaScript: https://github.com/biomejs/biome/blob/main/crates%2Fbiome_configuration%2Fsrc%2Fjavascript%2Fformatter.rs#L78-L84

We should update the docstrings for each language: JavaScript, JSON, CSS, html and graphql

@anaisbetts
Copy link
Author

@ematipico I'll try to get to this today!

@anaisbetts anaisbetts force-pushed the lineendings-auto-mode branch from 61805d7 to 34532cd Compare October 1, 2025 07:36
anaisbetts pushed a commit to anaisbetts/biome that referenced this pull request Oct 1, 2025
Docstrings generation was requested by @anaisbetts.

* biomejs#7599 (comment)

The following files were modified:

* `crates/biome_formatter/src/lib.rs`
* `crates/biome_formatter_test/src/spec.rs`
@anaisbetts anaisbetts force-pushed the lineendings-auto-mode branch from 34532cd to ae98b6b Compare October 1, 2025 07:45
anaisbetts and others added 4 commits October 2, 2025 18:19
- Add 'auto' option to LineEnding enum that uses CRLF on Windows and LF on other platforms
- Update configuration schema to include auto line ending option
- Update CLI argument parsing to accept 'auto' value
- Update TypeScript workspace configuration
- Add helper method is_auto() to LineEnding enum
- Add test file with LF line endings
- Add test configuration using auto line ending option
- Add snapshot test for auto line ending behavior
Docstrings generation was requested by @anaisbetts.

* biomejs#7599 (comment)

The following files were modified:

* `crates/biome_formatter/src/lib.rs`
* `crates/biome_formatter_test/src/spec.rs`
@anaisbetts anaisbetts force-pushed the lineendings-auto-mode branch from ae98b6b to 16a5245 Compare October 2, 2025 16:25
@anaisbetts
Copy link
Author

@ematipico I fixed the snapshot failures but it looks like main is 🔴 on CI at the moment? I think I accidentally picked up that failure on the rebase

@github-actions github-actions bot added the L-Grit Language: GritQL label Oct 2, 2025
Copy link
Member

@ematipico ematipico left a comment

Choose a reason for hiding this comment

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

Thank you @anaisbetts ! Great feature 🙌 I left a couple of nits that I will apply

@ematipico ematipico merged commit 09445c8 into biomejs:next Oct 3, 2025
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-CLI Area: CLI A-Formatter Area: formatter A-Project Area: project L-Grit Language: GritQL L-JavaScript Language: JavaScript and super languages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载