hujsonfmt: -w rewrites already formatted files and -l lists them
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 78/100
Research direction
Read cmd/hujsonfmt/hujsonfmt.go, especially processFile and processSrc. Compare the original src with the formatted output for both -l and -w, then check that an already formatted file is neither listed nor rewritten while an unformatted file is updated. The issue gives a reproducible command sequence to verify the behavior.
Written by the indexing model from the issue text.
Description
hujsonfmt -w rewrites a file that is already formatted, and hujsonfmt -l lists it as unformatted.
Steps, with hujsonfmt 0-unstable-2025-06-05 from nixpkgs on Linux; cmd/hujsonfmt/hujsonfmt.go at b80ff77 has the same code:
printf '{\n\t"a": 1,\n}\n' > policy.hujson
hujsonfmt -w policy.hujson # formats it
hujsonfmt policy.hujson | diff - policy.hujson # no output: already formatted
hujsonfmt -w policy.hujson # mtime changes again
hujsonfmt -l policy.hujson # prints policy.hujson
processFile passes input to processSrc, which can modify it in place, so the -l case compares the modified input with the output instead of src. The -w case calls writeFile without comparing at all, so every run writes a backup copy and rewrites the file. Formatters such as treefmt then report the file as changed on every run.
Would a fix that compares src with the output in both cases, and skips the write when they are equal, be welcome?
- Dominant language
- Go
- Stars
- 892
- Forks
- 40
- PR merge metrics
- No merged PRs in 30d
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
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 tailscale/hujson
-
Standardize modifies its input slice; the doc comment does not say soPossibly taken @jihtsan claimed this 28 days ago. Open
Difficulty 1/5 Under an hour Newbie friendliness 60/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
Value.Patch: "add" with an out-of-range array index appends instead of failingPossibly taken @SashaMIT claimed this 32 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Value.Patch: "test" operation always fails for a null valuePossibly taken @RaphaelFakhri claimed this 34 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
-
Patching with commentsPossibly taken @Shubham-Padkonde claimed this 47 days ago. Open
Difficulty 4/5 3-5 days Newbie friendliness 45/100
All issues in tailscale/hujson
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
oxc-project/tsgolint#1362 ·
Maintainers usually reply within 1 day
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
hashicorp/terraform-provider-google#30703 ·
Maintainers usually reply within 1 day
-
UpdateSchema.BuildUpdates should select newly added schemas with schema-id: -1Possibly taken @nisan1101 claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
apache/iceberg-go#2586 · 1 comment ·
Maintainers usually reply within 2 days
-
FR: update golang.org/x/sys to v0.50.0Possibly taken @wrenix claimed this today. Openfr needs-triage
Difficulty 2/5 Under an hour Newbie friendliness 62/100
Maintainers usually reply within 1 day
-
[Docs] Four internal links return 404 (Models concept, Contributing to Docs, Providers reference)Possibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
meshery/meshery#23520 · 1 comment ·
Maintainers usually reply within 1 day