dx fmt ignores .rustfmt.toml when formatting whole project
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 74/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Quiet
- Tech stack
- rust
- Domain
- cli, developer-experience
Research direction
Start in packages/cli/src/cli/autoformat.rs at the indentation_for calls on lines 56 and 90, then compare them with the whole-project path around line 175. Reproduce the behavior with a project-level .rustfmt.toml and the cargo fmt -- --print-config current commands shown in the issue. Done means dx fmt respects the project's configuration in --raw, -f file, and whole-project modes.
Written by the indexing model from the issue text.
Description
Problem
dx fmt does not pick up settings from .rustfmt.toml. RSX blocks are formatted using rustfmt defaults instead of the project's configuration.
In two places, indentation_for is called with the hardcoded string ".":
- autoformat.rs#L56 (
--rawmode) - autoformat.rs#L90 (
-f filemode)
Internally, indentation_for runs cargo fmt -- --print-config current <path>. When <path> is a directory, rustfmt does not walk up to find .rustfmt.toml and falls back to defaults. When <path> is an actual file (as on L175 for the whole-project case), it works correctly.
This can be verified. For example, with hard_tabs = true in .rustfmt.toml:
# Does NOT pick up .rustfmt.toml:
cargo fmt -- --print-config current .
# → hard_tabs = false
# Correctly picks up .rustfmt.toml:
cargo fmt -- --print-config current src/main.rs
# → hard_tabs = true
May also be related to #3433.
Steps To Reproduce
- Create a project with a
.rustfmt.tomlcontaining any non-default setting (e.g.hard_tabs = true) - Add a component using
rsx! - Run
dx fmt -f src/main.rsordx fmt --raw "div {}" - Observe that RSX is formatted using rustfmt defaults, ignoring
.rustfmt.toml
Expected behavior
dx fmt should respect .rustfmt.toml when formatting RSX blocks in all modes.
Screenshots
N/A
Environment:
- Dioxus version: 0.7.9
- Rust version: 1.87
- OS info: Linux
- App platform: web
Questionnaire
I don't have time to fix this right now, but maybe later.
- Dominant language
- Rust
- Stars
- 39.2k
- Forks
- 1.9k
- Avg merge
- 3d 12h
- Merged PRs (30d)
- 6
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from DioxusLabs/dioxus
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
DioxusLabs/dioxus#5835 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
DioxusLabs/dioxus#5821 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
DioxusLabs/dioxus#5792 · 1 reaction ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
DioxusLabs/dioxus#5744 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
DioxusLabs/dioxus#5710 ·
All issues in DioxusLabs/dioxus
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Eynzof/Hermes-CN-Desktop#610 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
gitbutlerapp/gitbutler#15998 · 1 comment ·
-
bug triage:deciding
Difficulty 1/5 Under an hour Newbie friendliness 88/100
open-telemetry/otel-arrow#4132 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100