Skip to content

varar.lock.json churns against the project formatter; init should add it to .prettierignore #122

Description

@aslakhellesoy

stringifyLockFile writes varar.lock.json with two-space indentation, deliberately and byte-stably ("so a clean re-run produces no git diff"). That guarantee holds only if nothing else formats the file — and in a project where prettier formats JSON with tabs, the two tools overwrite each other indefinitely.

Every vitest run rewrites it two-space. Every prettier --write . rewrites it tabbed. In my repo that is a 924-line diff each way, on a file nobody reads, appearing in every review.

I found it because main had a commit titled "Formatting" containing exactly one file — varar.lock.json, 924 insertions, 924 deletions — someone mopping up the churn by hand without realising it would come straight back.

The fix is trivial, finding it is not

# .prettierignore
varar.lock.json

It just needs to occur to you that the lock file is generated, which is easy to miss because it is committed and JSON and sitting in the repo root looking editable.

Suggestions

  1. Have varar init add it to .prettierignore (and .editorconfig / .gitattributes where relevant) when it finds one. This is the kind of thing a scaffolder should just do.
  2. Say so in reference/configuration — one line: "varar.lock.json is generated on every run; add it to your formatter's ignore file." Cheap, and sufficient on its own.
  3. Possibly match the file's existing indentation on write. Tempting, but it trades a stable canonical format for a format that depends on what happened to be there, and the ports would all have to agree. I'd take (1)+(2) over this.

Somewhat related to #61, which was also about a markdown/JSON formatter and Varar disagreeing over the same bytes — there may be a general "Varar and your formatter" section worth writing.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions