Open SamueleBarbiera opened 1 year ago
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.
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.
I see the ecosystem evolving to something like:
Combined formatter/linter/type checker to replace Prettier/Typescript type checking/ESLint/Typescript-ESLint My money is on Biome.
New engine that does running/compiling/bundling to replace Node/Babel/Typescript compile etc. Deno looked good for a while but Bun is probably now the best bet.
So I don't think this is needed in Bun.
I don't understand the excitement for biome yet... but I tried to integrate it into helix with the official manual, tried to install globally with both npm and bun, but somehow formatting doesn't work right now. But will keep an open eye for it. It is surprisingly popular.
update: Ok, I got it working thanks to this post https://github.com/biomejs/biome/discussions/2263 Getting formatting and suggestions inside helix, pretty cool and it's not slow. Biome probably just kicked out deno from my laptop.
@janos-r I think Rome was blocked for a while. What Seb tried to create (a company around the toolchain so he could pay fulltime devs) was a worthy endeavour, but the market couldn't support that and along with their switch from JS to Rust the project got stuck and distracted for while.
But since Rome became Biome it's found a lot of new energy. Linting for CSS is coming soon (which can replace Stylelint in a lot of workflows), and they're working on improving built-in type analysis to (eventually, someday, down the road) replace Typescript too (probably around the same time we get native types in ECMAscript). In maybe 5-7 years it should all slot into place nicely.
I think the main reason to keep these things separate (in addition to a linter being a lot of work) is that while Bun is strongly tied to the JS ecosystem, a formatter/linter like Biome is more fundamentally language agnostic.
@janos-r I think Rome was blocked for a while. What Seb tried to create (a company around the toolchain so he could pay fulltime devs) was a worthy endeavour, but the market couldn't support that and along with their switch from JS to Rust the project got stuck and distracted for while.
But since Rome became Biome it's found a lot of new energy. Linting for CSS is coming soon (which can replace Stylelint in a lot of workflows), and they're working on improving built-in type analysis to (eventually, someday, down the road) replace Typescript too (probably around the same time we get native types in ECMAscript). In maybe 5-7 years it should all slot into place nicely.
I think the main reason to keep these things separate (in addition to a linter being a lot of work) is that while Bun is strongly tied to the JS ecosystem, a formatter/linter like Biome is more fundamentally language agnostic.
I also think that it is not worth implementing linter/formatter in Bun, but officially recommend something like biome or alternatives
Unnecessary work that will be nailed to the Bun
js: eslint, prettier, oxlint, biome, standard js, jshint, sonarts
meanwhile go: go fmt
js: eslint, prettier, oxlint, biome, standard js, jshint, sonarts
meanwhile go: go fmt
Don't forget deno fmt
;)
js: eslint, prettier, oxlint, biome, standard js, jshint, sonarts meanwhile go: go fmt
Don't forget
deno fmt
;)
and dprint xd
I think the main reason to keep these things separate (in addition to a linter being a lot of work) is that while Bun is strongly tied to the JS ecosystem, a formatter/linter like Biome is more fundamentally language agnostic.
@dhoulb Biome website says: Biome is a fast formatter for JavaScript, TypeScript, JSX, TSX and JSON that scores 97% compatibility with Prettier,
Even if CSS is added to Biome, to me that does look a lot like the JS/Web ecosystem. I don't know if the ambition for Biome is to go beyond that though, but it looks like a CSS parser is part of the Bun roadmap too, so the overlap in scope appear quite large at least for now. Not fully convinced yet that one is more fundamentally language agnostic than the other.
$ bun build fmt.js --no-bundle | bun -e 'Bun.write(Bun.file("fmt.js"), await Bun.file("/dev/stdin").text())'
The formatting capability exists now using bun build
.
Damn! Html was the last thing I still used prettier for. Now for formatting I will be all on deno (it is so much faster). For TS biome, and for svelte, the sveltserver lsp already defaults formatting to prettier under the hood, so maybe I will tweak helix to also use deno to format svelte...
@janos-r
Now for formatting I will be all on deno (it is so much faster). For TS biome
Did you miss the code here https://github.com/oven-sh/bun/issues/2246#issuecomment-2294636954?
Formatting build in to bun build
.
Re "faster", at least for reading standard input and writing to standard output Bun is faster than Deno, which is faster than Node.js, running the same file.
0 'nm_qjs' 0.08820000000298023
1 'nm_rust' 0.0955
2 'nm_tjs' 0.13920000000298025
3 'nm_wasm' 0.14060000000149012
4 'nm_bun' 0.19670000000298024
5 'nm_typescript' 0.19989999999850988
6 'nm_bash' 0.2191000000014901
7 'nm_deno' 0.24609999999403953
8 'nm_nodejs' 0.3611000000014901
9 'nm_d8' 0.42639999999850986
10 'nm_spidermonkey' 0.47840000000596045
11 'nm_llrt' 0.6023999999985099
@janos-r bun build
actually output two different styles of formatting when --no-bundle
is used and when that option is omitted.
Did you miss the code here #2246 (comment)?
I did see the
$ bun build fmt.js --no-bundle | bun -e 'Bun.write(Bun.file("fmt.js"), await Bun.file("/dev/stdin").text())'
comment, but... that looks like some unreadable hack. That is nowhere near some official bun format support. Not to mention that there were official comments above saying that bun is not in the business of formatting stuff and people should use biome or deno for formatting. Nothing wrong with that.
comment, but... that looks like some unreadable hack.
Just happens to work in one line. I try not to over-engineer code.
Bun has some excellent tooling in bun build
that people in the field can make use of.
Bun is already in the business of formatting, officially, per bun build
output. Good luck!
Another way to do this using a script rather than commandline
// bun run fmt.js gist-plugin.js
import { $ } from "bun";
const file = Bun.argv.at(-1);
await Bun.write(file, await $`bun build ${file} --no-bundle`.text());
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