-
-
Notifications
You must be signed in to change notification settings - Fork 6.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Biome.js for local linting #5587
base: develop
Are you sure you want to change the base?
Conversation
✅ Deploy Preview for mermaid-js ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
We should replace this with Biome as well, but it's a bit complicated.
The latest updates on your projects. Learn more about Argos notifications ↗︎
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #5587 +/- ##
==========================================
- Coverage 5.73% 5.73% -0.01%
==========================================
Files 278 280 +2
Lines 42019 42038 +19
Branches 516 492 -24
==========================================
Hits 2409 2409
- Misses 39610 39629 +19
Flags with carried forward coverage won't be shown. Click here to find out more.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think making two separate PRs for changing linting and changing prettier/formatting would be easier to understand.
But, I'm also not a big fan of having Biome linting overlapping with ESLint's linting, e.g. us having to both add biome-ignore lint/suspicious/noFallthroughSwitchClause
and eslint-disable no-fallthrough
.
Would it be better to instead use Oxlint for linting? It's literally designed for our use-case https://oxc.rs/docs/guide/usage/linter.html:
At the current stage, oxlint is not intended to fully replace ESLint; it serves as an enhancement when ESLint's slowness becomes a bottleneck in your workflow.
We recommend running oxlint before ESLint in your lint-staged or CI setup for a quicker feedback loop, considering it only takes a few seconds to run on large codebases.
There's an eslint-plugin-oxlint
that automatically disables all ESLint rules that oxlint handles for you.
Biome still seems pretty nice for styling/formatting, though, so I think it can probably replace prettier. And I love the import sorting ability too.
Co-authored-by: Alois Klink <[email protected]>
* develop: chore: update browsers list chore(deps): update all patch dependencies docs: Added demo diagram of bidirectional arrows for sequence diagrams fix(deps): update all patch dependencies
Thanks for the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The linting aspect seems okay to me (although I'd rather keep pnpm lint
and pnpm lint:fix
doing everything, to prevent confusion with CI failing).
For the formatting conversion, I still think there's some stuff to do.
- Are we're still keeping
prettier
for markdown and HTML files, since biome doesn't support them yet. Can we update the lint commands for this?
I think we also need to describe the changes in the PR description before merging it, e.g. summarizing what has changed, and what the new workflow is for contributors.
Something like:
Add
biome
as an additional linter, and replaceprettier
withbiome
's formatter for JavaScript, TypeScript, and JSON files.Git pre-commit hooks will now only run biome, to speed up git commits.
ESLint will still be ran in CI and can be manually run withpnpm xxxxxxxxxxx
.Some info about prettier here, depending on what we do with it.
"lint": "pnpm biome check && pnpm lint:jison", | ||
"lint:fix": "pnpm biome check --write", | ||
"lint:ci": "pnpm lint && cross-env NODE_OPTIONS=--max_old_space_size=16384 eslint --cache --cache-strategy content .", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not a big fan of making the CI linting different from local linting. It also means people will have to manually fix ESLint issues/CSpell issues.
Having git commit
be fast is nice, but if I'm running pnpm run lint
, it's usually because I want to check if something is going to pass CI or not.
Would it be better to make a lint:fast
or lint:slow
script?
"lint": "pnpm biome check && pnpm lint:jison", | |
"lint:fix": "pnpm biome check --write", | |
"lint:ci": "pnpm lint && cross-env NODE_OPTIONS=--max_old_space_size=16384 eslint --cache --cache-strategy content .", | |
"lint:fast": "pnpm biome check && pnpm lint:jison", | |
"lint:fast:fix": "pnpm biome check --write", | |
"lint": "pnpm lint:fast && cross-env NODE_OPTIONS=--max_old_space_size=16384 eslint --cache --cache-strategy content .", | |
"lint:fix": "pnpm lint:fast:fix && cross-env NODE_OPTIONS=--max_old_space_size=8192 eslint --cache --cache-strategy content --fix . && tsx scripts/fixCSpell.ts", |
If pnpm lint
skips running eslint
by default, I'd recommend adding something like: `echo 'Skipping slow eslint-ing, run 'pnpm lint:slow' if you want to test this'.
Whichever option you pick, please update all mentions of lint:fix
, e.g. in like:
Lines 80 to 81 in 4a7489a
$(bold ./$name pnpm -w run lint:fix) | |
Run prettier and ES lint |
and
mermaid/.github/workflows/lint.yml
Lines 43 to 47 in 3a5793f
ERROR_MESSAGE+=' Running `pnpm -w run lint:fix` may fix this issue. ' | |
ERROR_MESSAGE+=" If this error doesn't occur on your local machine," | |
ERROR_MESSAGE+=' make sure your packages are up-to-date by running `pnpm install`.' | |
ERROR_MESSAGE+=' You may also need to delete your prettier cache by running' | |
ERROR_MESSAGE+=' `rm ./node_modules/.cache/prettier/.prettier-cache`.' |
@@ -1,10 +1,6 @@ | |||
export default { | |||
'!(docs/**/*)*.{ts,js,html,md,mts}': [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It sounds like biome
doesn't yet support HTML and MD files:
@@ -1,10 +1,6 @@ | |||
export default { | |||
'!(docs/**/*)*.{ts,js,html,md,mts}': [ | |||
'eslint --cache --cache-strategy content --fix', | |||
// don't cache prettier yet, since we use `prettier-plugin-jsdoc`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can probably remove prettier-plugin-jsdoc
, if prettier
will no longer be used for linting JS code.
📑 Summary
Adds Biome.js for local linting and formatting.
📏 Design Decisions
ESLint has been causing memory issues, and the pre-commit hook is really slow.
Replacing pre-commit hook with biome enhances the productivity.
Pros:
Cons:
TODO:
📋 Tasks
Make sure you
MERMAID_RELEASE_VERSION
is used for all new features.develop
branch