Skip to content
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

Run ESLint and Prettier formatting in process #539

Merged
merged 32 commits into from
Sep 24, 2021
Merged

Conversation

72636c
Copy link
Member

@72636c 72636c commented Sep 21, 2021

This took an eternity because I went down a rabbit hole of parallelising Prettier and had little to show for it based on very rudimentary benchmarking of skuba itself; it seemed the overhead of spinning up multiple worker processes was significant. I may give this another shot with worker threads in future.

While this is undeniably more code that using the ESLint and Prettier CLIs out of the box, it presents a few opportunities:

  • Customising logging output, particularly for --debugging.
  • Taking the above point further: supporting Buildkite annotations, particularly when linting.
  • A marginally faster execution and smaller resource footprint.
  • Likelier compatibility with alternative module resolution approaches like Yarn PnP, which can make it harder to reliably locate other .bin tools when execing.

This took an eternity because I went down a rabbit hole of parallelising
Prettier and had little to show for it based on very rudimentary
benchmarking of skuba itself; it seemed the overhead of spinning up
multiple worker processes was significant. I may give this another shot
with worker threads in future.

While this is undeniably more code that using the ESLint and Prettier
CLIs out of the box, it presents a few opportunities:

- Customising logging output, particularly for `--debug`ging.
- Taking the above point further: supporting Buildkite annotations,
  particularly when `lint`ing.
- A marginally faster execution and smaller resource footprint.
- Likelier compatibility with alternative module resolution approaches
  like Yarn PnP, which can make it harder to reliably locate other
  `.bin` tools when `exec`ing.
@changeset-bot
Copy link

changeset-bot bot commented Sep 21, 2021

🦋 Changeset detected

Latest commit: fde6bbc

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
skuba Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@72636c 72636c added the dino:snooze Snooze in Review Dino label Sep 21, 2021
Base automatically changed from no-fs-extra to master September 21, 2021 23:33
@72636c 72636c marked this pull request as ready for review September 23, 2021 09:54
@72636c 72636c requested a review from a team as a code owner September 23, 2021 09:54
@72636c 72636c removed the dino:snooze Snooze in Review Dino label Sep 23, 2021
We'd rather get feedback on a snapshot diff first.
integration/base/fixable/a/a/a.ts Show resolved Hide resolved
integration/base/ok/a/a/a.ts Show resolved Hide resolved
) => {
logger.debug(filepath);

const [config, data, fileInfo] = await Promise.all([
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’m guessing this is using lower level helpers instead of prettier.format to give better user feedback? Is it worth leaving a comment to that effect?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

prettier.format is fairly low level itself actually and is synchronous. I've tried to clarify this a little in the file.


const start = process.hrtime.bigint();

for (const filepath of filepaths) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What’s the performance difference of using Promise.all here? We could presumably overlap some I/O with the actual Prettier computation.

Copy link
Member Author

@72636c 72636c Sep 24, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've gone with a staged read->process->write approach in b13e729 so the debug logs remain in order.

src/cli/adapter/prettier.ts Outdated Show resolved Hide resolved
72636c and others added 6 commits September 24, 2021 11:25
This gracefully backs off upon file descriptor exhaustion.
This isn't used anywhere as `--debug` already logs each file.

Co-authored-by: Ryan Cumming <[email protected]>
Co-authored-by: Ryan Cumming <[email protected]>
@72636c 72636c merged commit fe09538 into master Sep 24, 2021
@72636c 72636c deleted the format-in-process branch September 24, 2021 02:19
@github-actions github-actions bot mentioned this pull request Sep 24, 2021
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

Successfully merging this pull request may close these issues.

2 participants