Skip to content

deno fmt <path> in a workspace applies members' options to wrong paths #29057

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
0x009922 opened this issue Apr 26, 2025 · 1 comment
Open

Comments

@0x009922
Copy link

Version: Deno 2.2.5

Steps to reproduce

Create the following workspace:

// deno.json
{ "fmt": { "singleQuote": true, "semiColons": true }, "workspace": ["sub"] }
// sub/deno.json
{ "fmt": { "singleQuote": false, "semiColons": false } }
// test.ts
console.log(   "test")
// sub/test.ts
console.log(   "sub/test")

Then run deno fmt . (the . is crucial here)

Expected result

  • test.ts must have console.log('test');
  • sub/test.ts must have console.log("sub/test")
  • Deno must report Checked 4 files

Actual result

  • test.ts has console.log("test")
    • Note: It is formatted using not deno.json, but sub/deno.json
  • sub/test.ts has console.log("sub/test")
  • Deno reports Checked 6 files

Research

I spent some time debugging it. It seems the additional CLI argument paths are added as include set to each workspace member FilePatterns. Thus, when Deno formats the root, it includes deno.json and test.ts; then, when Deno formats the sub workspace member, it includes sub/deno.json, sub/test.ts, and_ also . i.e. deno.json and test.ts again. Hence Checked 6 files message.

Note that deno fmt (without paths) works as expected.

@0x009922
Copy link
Author

I would like to work on this.

I have already spent some time working on some fmt and --watch enhancements locally (which led to discovering this bug). Hopefully I can open a PR that addresses this issue targetly, or maybe it will be a larger one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant