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
Add postprocess
config file option (useful for applying prettier formatting)
#285
Conversation
Awesome! This is much better / more flexible than the built-in prettier formatting I had implemented in a previous version (removed in #188). Aside from tests, it will need to be mentioned in the README.md of course. And do you think the single-word spelling Also as a heads up, I'll be releasing v1.0.0 very soon (days). This isn't a breaking change so it doesn't block anything. |
I favored |
@bmish I'd appreciate any pointers you might have on what tests you'd like and where to put them :) |
Since this is a new option, you can create |
For the README, we can add an example config file using this option to the prettier section. We can mention and link to that section from the Configuration options section. |
hmm @bmish I'm having some trouble which might be related to #288, where my new test file just hangs indefinitely apparently due to
Results in:
I was having this earlier with the CLI tests but they seemed to have come right - it feels like maybe something is trying to compile or load every single file on disk or in the project (including node_modules), though I can't rule that out easily due to the heavy use of I'll try and dig into it a bit further, but would be good to have your eyes on it too. |
A few things:
|
hmm right ok looks like this was the issue, thanks. |
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.
Thank you! This is great.
postprocess
option for applying formatters like prettier
postprocess
config file option (useful for applying prettier formatting)
This makes it easy to efficiently apply formatters like
prettier
after docs have been updated but before they're written to disk - this saves having to run such formatters across more files than necessary which on large codebases can be a decent time save.Since it requires a function, you have to use a js-based config file i.e.:
The function is expected to return a promise to future-proof, since
prettier
is making all its public APIs async in v3, and it's all being done in an async function so there's not a strong downside.This should be fully implemented (its working well locally with
eslint-plugin-jest
), but I've not had a chance to write any tests (I'm actually having some trouble with the cli tests not completing) so am opening as a draft to get an initial review and check that you're interested in this feature.Also a possible extension to this could be to support a path to a file that exports a function when being used from the command line, though that might be overkill and should be landable in a followup PR anyway.