Skip to content

Commit f8e848d

Browse files
committed
feat(scaffold): emit canonical rustfmt.toml (max_width 120)
poly's Rust formatter now defers to rustfmt's own config discovery, so an explicit rustfmt.toml pins the width both poly and cargo fmt use. Every alef-managed repo standardizes on 120 to match poly's global line_length.
1 parent 5728b79 commit f8e848d

3 files changed

Lines changed: 43 additions & 5 deletions

File tree

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Added
11+
12+
- **scaffold**: the poly scaffold now also emits a canonical repo-root `rustfmt.toml`
13+
(`max_width = 120`, alef-managed). poly's Rust formatter defers to rustfmt's own
14+
config discovery (matching `cargo fmt`), so this pins the width both tools use;
15+
without it rustfmt falls back to its 100 default. Every alef-managed repo
16+
standardizes on 120 to match poly's global `line_length` default.
17+
1018
## [0.30.11] - 2026-07-02
1119

1220
### Added

src/scaffold/languages/poly.rs

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -254,9 +254,21 @@ pub(crate) fn scaffold_poly_config(config: &ResolvedCrateConfig, languages: &[La
254254
));
255255
}
256256

257-
vec![GeneratedFile {
258-
path: PathBuf::from("poly.toml"),
259-
content: out,
260-
generated_header: true,
261-
}]
257+
// Canonical rustfmt config. poly's Rust formatter defers to rustfmt's own
258+
// config discovery (matching `cargo fmt`), so an explicit `rustfmt.toml`
259+
// pins the width both tools use. Without it rustfmt falls back to its 100
260+
// default; every alef repo standardizes on 120 to match poly's global
261+
// `line_length` default and stay consistent across the polyglot ecosystem.
262+
vec![
263+
GeneratedFile {
264+
path: PathBuf::from("poly.toml"),
265+
content: out,
266+
generated_header: true,
267+
},
268+
GeneratedFile {
269+
path: PathBuf::from("rustfmt.toml"),
270+
content: "max_width = 120\n".to_string(),
271+
generated_header: true,
272+
},
273+
]
262274
}

src/scaffold/tests/poly.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,24 @@ fn emits_a_generated_poly_toml_replacing_precommit() {
7777
);
7878
}
7979

80+
#[test]
81+
fn emits_a_canonical_rustfmt_toml_at_width_120() {
82+
let config = test_config();
83+
let api = test_api();
84+
let files = scaffold(&api, &config, &[Language::Python, Language::Node]).unwrap();
85+
86+
let rustfmt = files
87+
.iter()
88+
.find(|f| f.path.to_string_lossy() == "rustfmt.toml")
89+
.expect("scaffold should emit a repo-root rustfmt.toml");
90+
assert!(rustfmt.generated_header, "rustfmt.toml must be alef-managed");
91+
assert!(
92+
rustfmt.content.contains("max_width = 120"),
93+
"rustfmt.toml must pin width 120 (poly defers to rustfmt discovery); got {:?}",
94+
rustfmt.content
95+
);
96+
}
97+
8098
#[test]
8199
fn poly_toml_drives_hooks_builtins_and_excludes() {
82100
let config = test_config();

0 commit comments

Comments
 (0)