Spike: Biome for linting and formatting #2561
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Draft to evaluate whether we should continue with Biome.
Biome is a super fast linter and formatter for web projects (written in Rust!). On my machine it can lint and format Abacus in about 130ms, whereas Prettier takes 3.8s and ESLint takes 13.7s.
The Biome configuration consists of formatting and linting configuration. The formatting configuration was created by automatically migrating from Prettier and some manual tweaks. The current configuration matches our Prettier config quite well,
npx @biomejs/biome formatonly reports 8 files that would be reformatted.Automatic migration of the linting configuration created a very verbose file, so I chose to write it by hand. I enabled the recommended rules and then disabled ones that report many errors.
npx @biomejs/biome lintcurrently reports 46 issues that we still need to fix or ignore (for now). Eventually most of the currently disabled lints should also be re-enabled to fix (potential) issues in our codebase.A disadvantage is that Biome doesn't (yet) support every lint rule that we have currently configured in ESLint, in particular the library-specific ones from the Storybook and Playwright plugins are not available. We could consider keeping ESLint around for just these rules.
To try out locally:
npm cito install Biomeconfig_pathasfrontend/biome.confignpx @biomejs/biome checkbiome.jsonto check out other findings that we missed with ESLintTo evaluate:
Remaining work if we want to continue with Biome:
Relates to #1008