-
Notifications
You must be signed in to change notification settings - Fork 267
fix(prettier): respect prettier config field in "package.json" #570
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
Conversation
b763bae to
ec4d274
Compare
| -- @param self conform.FormatterConfig | ||
| -- @param ctx conform.Context|conform.RangeContext | ||
| -- @return string[]|nil args the arguments for setting a `prettier` parser if they exist in the options, nil otherwise | ||
| M.prettier_cwd = function(self, ctx) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a gut feeling it should be a part of some external dependency, so it could be shared between other plugins like nvim-lint, etc. Until then this is only used by 2 formatters, so this does not seem to be the best to share it via a general utils file that is used everywhere. I'm considering to move this into the lua/conform/util/prettier-cwd or smth like that now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As we share the logic between 2 formatters I'd avoid duplicating tests for the second formatter, so I'd test the prettier_cwd( util instead
ec4d274 to
0da505e
Compare
stevearc
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this could be a lot simpler. In general the util functions are general enough that they might be shared by a lot of different formatters. What if for the prettier formatter you just did
cwd = require("conform.formatters.prettierd").cwd
TLDR; OK, this is definitely easier (not simpler though) to do, so I'll stop overthinking it and make a step back. Thanks. I've tried it initially, but then I could not decide which of both formatters should really own the cwd logic. IMO neither of them should, cause in my "ideal world"(it's beyond the scope of this project, I know!) this logic could be shared out of the conform, for instance with nvim-lint. That's why I feel keeping this as a shared util(via |
|
close in favour of #573 |
continues #564
addresses #567