r/typescript 12d ago

Best TypeScript linter?

I'm dabbling with TypeScript again after some time away. What is the best way to lint .ts files these days? Is ESLint still the go-to, or is there a better method?

58 Upvotes

47 comments sorted by

29

u/gorilla-moe 12d ago

Pick your poison:

  • eslint with unicorn is still the 300 pound Gorilla in the room (IMHO)
  • biome a good contender
  • oxfmt and oxlint both trusted and the defaults for vite-plus

12

u/KnifeFed 12d ago

FYI, Unicorn is built into Oxlint, so no need to use ESLint just for that. It also supports ESLint plugins, so, yeah, no need to use ESLint at all. This, and the fact that it's faster than Biome, makes it the clear winner, IMO.

2

u/silv3rwind 12d ago edited 11d ago

Oxlint barely covers half of the unicorn rules, see https://github.com/oxc-project/oxc/issues/684.

9

u/Bicykwow 12d ago

We do not accept pull requests because of too much AI slop.

Haha, love this. 

71

u/rosebeuud 12d ago

oxlint seems to be on the rise, thanks to it being part of the Vite ecosystem

1

u/_Pho_ 7d ago

oxlint is genuinely 50x+ faster than eslint, highly recommend

11

u/Chef_G0ldblum 12d ago

I'm still on eslint 🤷‍♂️

20

u/jarzebowsky 12d ago

Went biome and migrated to oxlint. It’s faster and you can use eslint rules which biome can’t.

1

u/pjstanfield 11d ago

How was the migration? I wanted to migrate from biome but haven’t done a deep look yet

1

u/jarzebowsky 10d ago

It was way faster than going from eslint to biome

20

u/ehs5 12d ago

Oxlint by far. Wouldn’t start a project without that and oxfmt today.

1

u/pjstanfield 11d ago

I use biome now in most projects but if I was starting over I’d use oxlint

18

u/JATR1X 12d ago

biomejs, my personal favourite

9

u/anaveragedave 12d ago

I'm getting lazy in my old age. We are still on default eslint. I haven't even heard of oxlint or biome before seeing this post. Shame on me

3

u/prophase25 12d ago

Oxlint and Oxfmt are way, way better than I thought possible. I will never use ESLint again for a new project.

4

u/glandix 12d ago

I recently switched from eslint to oxlint and love it

2

u/root_om 12d ago

Oxlint and biome is pretty cool

2

u/imjuni 11d ago

I choose oxlint & oxfmt. They are nice coupled vscode

5

u/ongamenight 12d ago

I'm using Biome.

2

u/YeisonKirax 12d ago

Biome has linter and formatter. Oxlint and oxfmt will have a great future but for now is too buggy

2

u/dupontcyborg 12d ago

biome, by far. it's written in rust and between 10-100x faster than eslint on my projects. it's both a linter and formatter, so it replaces eslint and prettier, and is much faster than both.

1

u/realmauer01 12d ago

Depends if you use node, deno has its own linter that can be used.

1

u/keldamdigital 11d ago

if you haven't yet, you should be moving away from eslint and moving to oxlint with type aware.

1

u/TheMindLabor 11d ago

I use both oxlint and eslint, still significantly faster than just eslint (I use vue and oxlint/fmt doesnt have template support yet). Dropped from 30s linting with eslint only, to 8s linting with both (200ms for oxlint only which checks 80% of the rules)

1

u/GameRoMan 10d ago

oxlint

1

u/GameRoMan 10d ago

In some projects I use oxlint and in some Biome

1

u/OrigStuffOfInterest 10d ago

If speed is not a concern, which linting tool provides the best accuracy? I'm using eslint now, and the speed of it has not been an issue for me. Also, this is a React project, and I'm using the React plugins for eslint.

1

u/attentionwandered 9d ago

I like biome

1

u/LoadingALIAS 12d ago

It’s Oxlint. Let me save you the time.

1

u/green_03 12d ago

I am using a mix of biome with oxlint+oxlint-tsgolint to replace typescript-eslint. Though I might drop. Biome soon

2

u/DerTimonius 12d ago

same thing here. contributed some rules to Biome, but I think the inertia is more on the side of oxlint at the moment due to their speed with which they deliver

1

u/green_03 12d ago

Exactly. Biome were ahead but Oxlint got more traction then, and now Cloudflare money. They are ahead and have the type-aware rules. I love Biome, the DX is better, but releases are slower, tinier, but what is worse, lately they have a lot of regressions. I still love what they are doing though!

1

u/KnifeFed 12d ago

Oxlint/Oxfmt > Biome > ESLint

-1

u/ivy-apps 12d ago

I'm using Biome for linting and Deslop for architecture enforcement

0

u/VoidspawnRL 12d ago

Any linter that use TS to lint ts so all of them is broken with ts 7.0 and they will get a API in ts 7.1 for eslint it is still the best as there is so many plugins for it, in any case you need to install ts 6.0 for the linters and ts 7.0 for your projects for the next 3-6 months, as the linters need to rewrite they code and then all the plugins need a rewrite.

I try oxlint as a lot use it but it fail badly on a big project on work. So i stick with eslint.

2

u/rasekrodriguez 12d ago

typescript-eslint 8.67.0 declares its peer range as typescript >=4.8.4 <6.1.0. npm currently has typescript at 7.0.2 on latest, with 6.0.3 as the last release of the old line. So on a project that has already moved to 7, the type-aware ESLint path does not install cleanly, and pinning the linter's TypeScript to 6.0.x is a workaround rather than a preference.

The two kinds of rule are worth separating when picking, because that decides how much of this touches you at all. Syntactic rules never load the compiler, which is why the Rust linters are unaffected by any of it. Type-aware rules need a real checker, and that is the part waiting on the native port to expose an API.

So the question splits in two. For syntactic linting it is mostly a speed comparison. For type-aware rules it is a version compatibility question right now, and that is the axis worth checking against your own tsconfig before switching anything.

1

u/KnifeFed 12d ago

Oxlint works great with TS 7.

0

u/beavis07 12d ago

In a very very limited experiment recently I found that biome and oxlint are almost identically extremely fast, but oxfmt was a LOT slower than biome.

Do with that information what you will

0

u/maninas 12d ago

I made a plugnplay linter + formater that covers virtually everything, so that I'll never have to deal with that madness on any new repo. Try @maninak/eslint-config

0

u/passionate_carkey 12d ago

i am sorry.i am a starter to typescript.What is a linter?I have used eslint and oxlint in projects where i work.All i know them is they stop me from pushing my code to github until an unless i fix the typescript based practice or better practice like not having code complexity of more than 10 in a file,no unused variable,etc. So,are they the checker for typescript and overall code writing practices?

1

u/tbaklavas 10d ago

Yes, but this is not typescript specific terminology.

A linter is a tool that allows you to define a set of syntax rules (e.g. spaces vs tabs for indent, use of semi-colons to terminate commands, same-line or new line curly braces for if/function statements etc). Many teams use a linter to enforce consistency across their codebase and setup their deployment pipelines to fail if the linter flags anything.

A formatter is a very similar tool that will read the set of rules and attempt to correct any issues it flags - eg it will convert tabs to spaces, add/remove semicolons, move curly braces to same or new line etc.

Once you get used to a well-configured linter/formatter it is very difficult to go back to manually enforcing these rules.

1

u/passionate_carkey 10d ago

oh great.What is that makes oxlint better than oxlint?what are such features?

2

u/tbaklavas 10d ago

I assume you mean oxlint vs eslint? In general there is no simple A is better than B when it comes to comparing linters. One has more plugins, another one is faster, another one has smaller footprint, another one has better syntax etc.

People prefer Oxlint in general because it is pretty much a drop in replacement for eslint and it’s faster than eslint.

I prefer biome because it is similarly fast and lints and formats with the same binary.

Having said that, you should be comfortable with using any of them, these are very simple tools that overall achieve the same result in the end.

-1

u/AsterYujano 12d ago

Oxlint makes it fast and easy (cause eslint integration) Biome makes it fast.

Pick one of them 😅