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

fix(js): test on node 20-22; format TS with biomejs #1987 #1995 #1988

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

yesudeep
Copy link
Contributor

@yesudeep yesudeep commented Feb 14, 2025

fix(js): test on node 20-22; format TS with biomejs #1987 #1995

This speeds up formatting by 4-12x and fixes several formatting related
issues whether they have to do with the commit message, source code, or
license headers. This means faster CI and pre-commits.

Also updates GitHub actions configuration to run tests for these node
versions:

ISSUE: #1987
ISSUE: #1995

CHANGELOG:

  • Update pnpm run format to use biomejs
  • Update pnpm run format:check to use biomejs
  • Use bin/add_license to add license headers.
  • Exclude the py/ and go/ runtimes from the formatter.
  • Fix Import attributes cannot be used with a type-only import error
  • Update all the TypeScript files to use Google-style formatting.
  • Re-enable pre-commit formatting for TypeScript.
  • Update the JavaScript GitHub action workflows so that JS
    tests run on node version 20-23.
  • Update bin/setup to default to node 22.

BENCHMARKS:

zsh❯ hyperfine -i "pnpm run format:biome" "pnpm run format:prettier"
Benchmark 1: pnpm run format:biome
  Time (mean ± σ):     453.6 ms ±   5.6 ms    [User: 679.3 ms, System: 92.5 ms]
  Range (min … max):   447.9 ms … 465.3 ms    10 runs

  Warning: Ignoring non-zero exit code.

Benchmark 2: pnpm run format:prettier
  Time (mean ± σ):      5.715 s ±  0.285 s    [User: 9.578 s, System: 0.739 s]
  Range (min … max):    5.506 s …  6.426 s    10 runs

Summary
  pnpm run format:biome ran
   12.60 ± 0.65 times faster than pnpm run format:prettier

A sample run follows:

zsh❯ pnpm run format

> genkit@ format /Users/yesudeep/code/github.com/firebase/genkit
> pnpm dlx @biomejs/biome format --write . && (tsx scripts/copyright.ts)

Formatted 663 files in 86ms. Fixed 217 files.
Checking copyright in sources...
Updated copyright headers in 0 files

REFERENCES:

The configuration for the formatting is more or less based on the Google
TypeScript formatting guidelines at:

Checklist (if applicable):

@yesudeep yesudeep marked this pull request as draft February 14, 2025 17:06
@yesudeep yesudeep force-pushed the yesudeep/fix/biome branch 4 times, most recently from fa677b9 to 7aab58c Compare February 14, 2025 17:39
@yesudeep yesudeep changed the title [WIP] Use biome for formatting faster. [WIP] fix(js): format TypeScript files using the faster biomejs formatter and Google style #1987 Feb 14, 2025
@yesudeep yesudeep self-assigned this Feb 14, 2025
@yesudeep yesudeep force-pushed the yesudeep/fix/biome branch 8 times, most recently from 0194928 to 7bfd67f Compare February 15, 2025 04:06
@yesudeep yesudeep changed the title [WIP] fix(js): format TypeScript files using the faster biomejs formatter and Google style #1987 fix(js): test on node 20-22; format TS with biomejs #1987 #1995 Feb 15, 2025
@yesudeep yesudeep mentioned this pull request Feb 15, 2025
5 tasks
@yesudeep yesudeep requested review from pavelgj and mbleigh February 15, 2025 04:22
@yesudeep yesudeep marked this pull request as ready for review February 15, 2025 04:40
This speeds up formatting by 4-12x and fixes several formatting related
issues whether they have to do with the commit message, source code, or
license headers. This means faster CI and pre-commits.

Also updates GitHub actions configuration to run tests for these node
versions:
- 20
- 21
- 22
- 23 (temporarily disabled since it is failing #1995)

ISSUE: #1987
ISSUE: #1995

CHANGELOG:
- [ ] Update `pnpm run format` to use biomejs
- [ ] Update `pnpm run format:check` to use biomejs
- [ ] Use `bin/add_license` to add license headers.
- [ ] Exclude the `py/` and `go/` runtimes from the formatter.
- [ ] Fix Import attributes cannot be used with a type-only import error
- [ ] Update all the TypeScript files to use Google-style formatting.
- [ ] Re-enable pre-commit formatting for TypeScript.
- [ ] Update the JavaScript GitHub action workflows so that JS
  tests run on node version 20-23.
- [ ] Update `bin/setup` to default to node 22.

BENCHMARKS:

```
zsh❯ hyperfine -i "pnpm run format:biome" "pnpm run format:prettier"
Benchmark 1: pnpm run format:biome
  Time (mean ± σ):     453.6 ms ±   5.6 ms    [User: 679.3 ms, System: 92.5 ms]
  Range (min … max):   447.9 ms … 465.3 ms    10 runs

  Warning: Ignoring non-zero exit code.

Benchmark 2: pnpm run format:prettier
  Time (mean ± σ):      5.715 s ±  0.285 s    [User: 9.578 s, System: 0.739 s]
  Range (min … max):    5.506 s …  6.426 s    10 runs

Summary
  pnpm run format:biome ran
   12.60 ± 0.65 times faster than pnpm run format:prettier
```

A sample run follows:

```
zsh❯ pnpm run format

> genkit@ format /Users/yesudeep/code/github.com/firebase/genkit
> pnpm dlx @biomejs/biome format --write . && (tsx scripts/copyright.ts)

Formatted 663 files in 86ms. Fixed 217 files.
Checking copyright in sources...
Updated copyright headers in 0 files
```

REFERENCES:

The configuration for the formatting is more or less based on the Google
TypeScript formatting guidelines at:

- [ ] https://google.github.io/styleguide/tsguide.html#string-literals
- [ ] https://google.github.io/styleguide/jsguide.html
- [ ] https://google.github.io/styleguide/tsguide.html#arrow-function-bodies
- [ ] https://google.github.io/styleguide/tsguide.html#automatic-semicolon-insertion
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

1 participant