FluidFramework/scripts/formatting
Jason Hartman b70b836ee2
tools(client+build-tools): update Biome to 1.8.3 (#21869)
Changes:
1. Remove production dependency in
@fluid-example/bubblebench-shared-tree
2. Update versions to ~1.8.3 (and set config to want ~)
3. Handle deprecations
a. Replace "javascript.formatter.trailingComma" with "...trailingCommas"
   b. Replace cli argument `--apply` with `--write`
4. Apply formatting updates
5. Add Biome to npm-package-json-script-dep
6. Remove unused `--formatter-enabled=true` from commands
7. Add missing biome devDeps in build-tools

Under 1.7.3 VS Code extensions users could experience server connection failures and need 1.8 version to get support from Biome. See [biomejs/biome-vscode#261](https://github.com/biomejs/biome-vscode/issues/261)
2024-07-12 21:26:58 +00:00
..
README.md
add-biome.sh
enable-biome.sh
enable-prettier.sh
remove-prettier.sh

README.md

Enable/disable formatter scripts

The scripts in this folder can be used to switch a project between prettier and biome formatting.

THESE SCRIPTS DO NOT RUN ON WINDOWS.

Required dependencies

The scripts require the npe package be installed globally. To do that run pnpm add -g npe.

Scripts

These scripts are intended to be run in individual projects. To run on multiple projects at a time use flub exec or pnpm -r exec. For example:

flub exec -g client -- "~/code/FluidFramework/scripts/formatting/enable-biome.sh"

add-biome.sh

This script adds biome formatting scripts to a project. It also adds a local biome config file to the project if needed.

The format:prettier and check:prettier tasks are left intact, and the format task still calls prettier. This enables one to manually format using biome while leaving the overall build using prettier.

After running this script, you can clean up the package.json files by running pnpm policy-check:fix.

enable-biome.sh

This script enables biome formatting in a project. It updates the format and check:format scripts to call biome. It should only be run on projects that have already had biome added to it.

enable-prettier.sh

This script enables prettier formatting in a project. It updates the format and check:format scripts to call prettier. It's the opposite of the enable-biome.sh script.

remove-prettier.sh

Once a project is completely switched to biome and no longer needs prettier, this script will remove the prettier dependency and any related scripts and config files.

Converting a project

To convert a project to use prettier or biome, just run enable-prettier.sh or enable-biome.sh. After running the scripts, you may need to run policy-check:fix from the root of the repo to sort the package.json changes.

Commit the resulting changes and open a PR.

My project uses biome now, but I need to port a change to a branch that uses prettier

To do this more easily, format your local changes manually using the format:prettier script, and then create a commit from those changes to PR into the target branch.