bun
bun copied to clipboard
Bun implementing a Formatter and Linter
What is the problem this feature would solve?
instead of installing eslint or prettier (or even rome) used for linting and formatting purposes why not implement it
What is the feature you are proposing to solve the problem?
to have a way more performant dev exp. and even on the ci
What alternatives have you considered?
No response
now, there are other priorities but thanks for this feature request
The eslint
alternative would be the real killer tool to make me want to adopt bun
.
I want a cli tool that I can use to replace eslint
; prettier
; esbuild
; pnpm
; ava
etc. A single CLI tool to control them all ( minus tsc
which warrants not rewriting ).
Having a lint tool would be a huge boon for local development.
This would be great, ➕1
Would be interesting to see how far we can do in cleaning up the roots of our projects when using bun without additional user complexity (like vite --config config/vite.config.js
for example).
A boilerplatey eslint/prettier/vite project looks like:
as my entrypoint is an html file with <script src="src/main.ts"></script>
so I use bun run vite
and that build script to build main and move index and replace it with the hashes main filename.
I'm pretty happy rn tho, each tool has its ways to move/specify a config file path and bun, largely, doesn't have any config, so I can move any build scripts whever.
Bun should provide a formatter. I know its not priority, but it should have. The only thing we should consider when implementing it is to make it opnionated and universal, just like go fmt
:
I think everyone can agree that this was a right decision for golang, no more debates on where spaces or tabs should be used. We just run bun format
and our code follow a standard we can find on ALL bun projects out there...
Looking for same, found this request. Since bun is trying to solve all issues in js ecosystem this will a great addon, as most of recent languages are providing same kind of tooling to make dev life easier.
I highly recommend to use: https://biomejs.dev/ . It based on rust 💯 and the installation via bunx is available.
I highly recommend to use: https://biomejs.dev/ . It based on rust 💯 and the installation via bunx is available.
For users who didn't know, that is basically the rebrand of Rome as mentioned in their blog post: https://biomejs.dev/blog/annoucing-biome/
Biome is designed to eventually replace Babel, ESLint, webpack, Prettier, Jest, and others.
they seem to have very similar goals as Bun 😆
I highly recommend to use: https://biomejs.dev/ . It based on rust 💯 and the installation via bunx is available.
This is just another Prettier and ESLint. If I'm going to use this, I should just use Prettier and ESLint. All I need is the official internal tools of Bun.
Formatter shouldn't be opinionated because it's not a new language like go. It will prevent many teams from switching. Allow lots of customization so it works with any existing code so people can use bun instead of external tool.
This is just another Prettier and ESLint. If I'm going to use this, I should just use Prettier and ESLint. All I need is the official internal tools of Bun.
I completely disagree what you are saying. BiomeJS is super fast and built outside of the JS land, which makes it super fast and more prone to be implemented by Bun. And creating a formatter and linter is a project of its own, there's not way bun will have funds and time to do it by themselves, adopting a open source project is the only solution.
Formatter shouldn't be opinionated because it's not a new language like go. It will prevent many teams from switching. Allow lots of customization so it works with any existing code so people can use bun instead of external tool.
But bun is a new tech, teams will have to adopt it manually anyways...
But bun is a new tech, teams will have to adopt it manually anyways...
But javascript isn't a new tech.
Bun is a replacement for node.js. Teams won't change their runtime if they are forced to change their style for existing code.
Bun is a replacement for node.js. Teams won't change their runtime if they are forced to change their style for existing code.
They will not be forced, ONLY if they also want to change their internal linting/style system to a standardized one by removing their prettier/eslint/... to bun, then yes.
They will not be forced, ONLY if they also want to change their internal linting/style system to a standardized one by removing their prettier/eslint/... to bun, then yes.
Or can make configurable so teams can decide on their own format and still benefit from bun tools. Benefit is standardization within a repo with the tool formatting the code according to settings for that repo. Bun developers don't need to tell you exactly how your code should look only that it follows the settings you chose.
Just tried Biome rn. It rocks, even if it is still way too early.
I think it is not required to reinvent it.
I'm now using deno's formatter (deno fmt
) alongside bun.
I'm now using deno's formatter (
deno fmt
) alongside bun.
@borisdiakur I am also interested to use deno's formatter and linter for my bun project, could you please provide a tip on how do I do it? Like, what do I need to install and configure to get it working? thank you.
I'm now using deno's formatter (
deno fmt
) alongside bun.@borisdiakur I am also interested to use deno's formatter and linter for my bun project, could you please provide a tip on how do I do it? Like, what do I need to install and configure to get it working? thank you.
i think you just need deno, nothing more, nothing less
I do tend to use deno fmt
frequently for .js
and .json
files. But I use deno
, bun
, and node
regularly, and try to write code that runs in all three of those runtimes, at least, if possible including tjs
(txiki.js) and qjs
(QuickJS). So it's not uncommnon for me to use deno
for fmt
, bun
for build()
, tjs
for a TCP server that runs for 13 MB RSS versus bun
at 43 MB RSS.
Here's a Chromium extension to implement formatting when Chromium removed the formatter from DevTools https://github.com/guest271314/devtools_panel_code_formatter. js-beautify
from a CDN as a single .js
file is 72.6 KB. Chromium subsequently relanded the built-in formatter in Sources/Snippets panel.
Using bunx install -g <formatter>
works, too.
@borisdiakur I'm now using deno's formatter (
deno fmt
) alongside bun.@Barzi-Ahmed @borisdiakur I am also interested to use deno's formatter and linter for my bun project, could you please provide a tip on how do I do it? Like, what do I need to install and configure to get it working? thank you.
@xHyroM i think you just need deno, nothing more, nothing less
Yep, and the VS Code extension, settings, and config to make it behave the way would want, so you wouldn't have to install and configure eslint, stylistic, prettier, biome, and whatnot. See @alertbox/docsify-footer for a variant of minimal setup.
Ideally, we'd be able to just do bun fmt
and bun lint
or some variation of it.
@kosperera Never tried VS Code. I generally use a basic text editor. If I want an IDE all Chromium based browsers, e.g., Chrome, Brave, Edge are shipped with a built-in IDE in DevTools Snippets. deno fmt
works. Just be careful with larger files. Could cause deno
to panic, or freeze the entire system.
@borisdiakur I'm now using deno's formatter (
deno fmt
) alongside bun.@Barzi-Ahmed @borisdiakur I am also interested to use deno's formatter and linter for my bun project, could you please provide a tip on how do I do it? Like, what do I need to install and configure to get it working? thank you.
@xHyroM i think you just need deno, nothing more, nothing less
Yep, and the VS Code extension, settings, and config to make it behave the way would want, so you wouldn't have to install and configure eslint, stylistic, prettier, biome, and whatnot. See @alertbox/docsify-footer for a variant of minimal setup.
Ideally, we'd be able to just do
bun fmt
andbun lint
or some variation of it.
Hmm... No i discarded Deno Linter and Deno formatter, because I use Astro now and they neither lint nor format .astro files. Might go back to prettier and eslint.
Maybe it will be useful for nextjs projects as its just standard tsx, not specific file like .astro.
Also, I wanted to say that I've changed my mind, it is good for Bun project to NOT implement a formatter or linter, because I'm sure it might harm the project, the scope of project is already too wide (transpiler, unit test, bundler, etc). So i want them to focus on what's on the table, also more windows and nodejs compatibility.
I build a few in-company cli tooling with deno and love the experience of having an opinionated way to do everything all the way to formatting and linting with the runtime.
I certainly respect people loving their eslint and prettier setup and I sure setup those things for many years.
But for me it's just another thing that is fine out of the box. I don't care if I use airbnb or google for linting. I just need a consistent default way and have less config files and be done with it.
I'm suspecting lots of people are in the same situation so I'm all for an integrated experience. And if you still want a .prettierrc then go nuts. 😄👍
Be careful with this. Deno's deno fmt
can freeze the entire machine when the file is greater than an unknown arbitrary length.
I also use deno fmt
for bun...
Actually I use helix cli editor (it's amazing) with this language config, to format on save... and its blazingly fast! Very comfortable. And it's not a hack... its even one of the recommendations on the helix git wiki to use deno fmt
## ~/.config/helix/languages.toml
[[language]]
name = "typescript"
indent = { tab-width = 4, unit = " " } # to match the formater before auto-save
formatter = { command = 'deno', args = [ "fmt", "-", "--ext", "ts", "--indent-width", "4", ] }
auto-format = true
But yeah, it would be nice if I could run bun lint
out of the box. Or if bun had a language server that doesn't flag bun imports like tests as non-existent (currently using the recommended "typescript-language-server").
But detail. In general it's amazing how well bun fits in the default TS setup I already had and its very fast and comfortable to write.
I highly recommend to use: https://biomejs.dev/ . It based on rust 💯 and the installation via bunx is available.
For users who didn't know, that is basically the rebrand of Rome as mentioned in their blog post: https://biomejs.dev/blog/annoucing-biome/
Biome is designed to eventually replace Babel, ESLint, webpack, Prettier, Jest, and others.
they seem to have very similar goals as Bun 😆
It would appear the biome website was refreshed and now only mention Formatting and Linting, but no test/bundling/transpiling. Seems like a more reduced scope compared to the original vision for Rome, which bun basically has delivered all other areas of in the meantime. Using biome and bun together is such a bliss compared to what i had before. Bun might be able to outdo biome on performance, but anyone moving from eslint/prettier to biome will already be blown away by the perf, so might be a hard sell.
@birkskyum Hmm, nice, they even specify how to use it with helix (the only editor they mention there directly, lol) https://github.com/biomejs/biome/blob/main/editors/helix/manual.md I knew it in the past but forgot what specific formatter deno is using under the hood, somebody told me before, but I wonder if Biome is using the same formatter or if they really built their own?! For now, I will stay with the deno formater, I am glad that it is easy to update and that its installed properly as a binary, not as a global npm package. But I will keep biome in mind. It's nice they also provide a linter that integrates nicely.
@janos-r
I knew it in the past but forgot what specific formatter deno is using under the hood
Seems like under the hood deno fmt is using https://dprint.dev/
Keep in mind nothing is stopping any programmer from using bun
, deno
, and node
, and other JavaScript/TypeScript engines/runtimes at the same time. Use deno
for lint
, fmt
, import map support, full-duplex streaming, compiling to a standalone executable with denort
to ~78 MB. Use bun
for faster reading STDIN, writing to STDOUT, plugin
, bun install
, and so forth.
https://dprint.dev/
Ah yeah! dPrint! When it formats on crtl+s press, it is such a dramatic user experience improvement from prettier, it's night and day. That makes me hesitant to go back to npm packages (even though its biome) to do this, hehe. I wonder what biome used.