ux icon indicating copy to clipboard operation
ux copied to clipboard

Drop ESLint and Prettier for Biome

Open Kocal opened this issue 1 year ago • 7 comments

Q A
Bug fix? no
New feature? no
Issues Fix #...
License MIT

Hi everyone,

Biome is a new modern tool for code linting and formatting. It supports TypeScript out-of-the-box, lint and format does not conflict each-other (like ESLint and Prettier can do), and it's super fast! With Biome, we can easily replace:

  • ESLint
  • ESLint's TypeScript plugin
  • Prettier
  • ESLint's Prettier plugin

There is a lot of modifications, but 99% of them are:

  • use import type ... / import { type ... } when necessary
  • removing 'use strict', since we have type: 'module' in package.json files, but I'm not 100% confidente here and I may add them back
  • using template string interpolation instead of + operator

I've disabled the following linting rules in order to reduce the number of modifications, but later we can start to enable them:

  • complexity/noStaticOnlyClass
  • complexity/noForEach
  • style/noParameterAssign
  • performance/noDelete

The yarn scripts lint, format, check-lint and check-format have been modified in consequences.

For performance comparisons, you can check those two CI jobs:

  • https://github.com/symfony/ux/actions/runs/9063481176/job/24899508211, ESLint took ~19s and Prettier took ~2s
  • https://github.com/symfony/ux/actions/runs/9091422430/job/24985996787, Biome took ~5s for linting and ~0s for formatting

For the number of commits, I wanted to ease the review by doing many atomic commits, but feel free to squash if necessary.

WDYT?

Kocal avatar May 15 '24 06:05 Kocal

Failures are unrelated

Kocal avatar May 15 '24 07:05 Kocal

I cannot resist to answer with: https://dayssincelastjavascriptframework.com/

(and now more seriously i'll look at your post 😅 )

smnandre avatar May 15 '24 07:05 smnandre

(first read: you know how to speak to me :) )

smnandre avatar May 15 '24 07:05 smnandre

Yeah I know about the 0 day since the last JS framework/tools meme... and trust me it's not for nothing my TN is "JS hate account" :trollface:

Biome is a community-fork from Rome (started 3 years ago), it's a tool I was really looking forward to because of the over-fragmentation of JavaScript tools and the unnecessarily complex configurations to make them work together. I love having a tool that does a lot, but mostly well. ... <troll>Next PR, Bun to replace Yarn/Vitest/Rollup? :eyes: </troll>)

I consider Biome enough "production-ready", to nicely and quickly lint and format our JS(X)/TS(X) files.

Kocal avatar May 15 '24 08:05 Kocal

What about editor integration? Did you tried the PHPstorm extension? Do you think it's mature enough?

WebMamba avatar May 15 '24 09:05 WebMamba

I didn't know an extension existed, and so I didn't try it. But I'm not a big fan of ESLint/Prettier integration in IDEs, I prefer relying on CLI / CI / pre-commit hook :D

Kocal avatar May 15 '24 10:05 Kocal

I'll try it next week (late in the week) !

smnandre avatar May 17 '24 03:05 smnandre

This looks like a nice addition. Do you think this is ready for merge or would you like to wait for more feedback and/or changes? Thanks!

javiereguiluz avatar Jul 30 '24 11:07 javiereguiluz

Hey, I think this PR would need a last rebase on main before merging. I will do it this afternoon

Kocal avatar Jul 30 '24 11:07 Kocal

The PR has been rebased and CI checks are passing, feel free to merge it if you like it :eyes:

Kocal avatar Jul 30 '24 12:07 Kocal

Let's merge this now so we can fully test it for real in the project and see how it goes.

Thanks Hugo!

javiereguiluz avatar Jul 30 '24 16:07 javiereguiluz