-
-
Notifications
You must be signed in to change notification settings - Fork 60
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
feat: run biome check on src files #556
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
src/components/ScopedTheme.tsx
Outdated
{mappedChildren} | ||
</React.Fragment> | ||
) | ||
return <>{mappedChildren}</> |
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.
Only line where I fixed a biome lint warning
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.
Can we force <React.Fragment>, I'm not a big fan of <></>
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.
Alright, in this case the warning was because the fragment was unnecessary so I removed it
Hey @jeremybarbet thanks for the PR. I'm not sure I want this to be implemented as I'm not a big fan of how it formats the code. I'm not sure if this should be configured further, but i will point the places. |
src/components/ScopedTheme.tsx
Outdated
{mappedChildren} | ||
</React.Fragment> | ||
) | ||
return <>{mappedChildren}</> |
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.
Can we force <React.Fragment>, I'm not a big fan of <></>
UnistylesShadowRegistry.add(ref, imageClassNames?.hash) | ||
}} | ||
ref={ | ||
isServer() |
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.
what about it ? Can we tweak it? Looks bad
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.
Same as comment below, related to ternary formatting biomejs/biome#2388
const unistyles = typeof style === 'function' | ||
? style({ pressed: false }) | ||
: style | ||
const unistyles = typeof style === 'function' ? style({ pressed: false }) : style |
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.
why it's once in multiple lines and sometimes in single line?
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.
This is the default Biome's formatting for ternary, there is a discussion opened about it but no away at the moment to configure it
? style(state) | ||
: getStyles(style as unknown as Record<string, any>) | ||
const unistyles = | ||
typeof style === 'function' ? style(state) : getStyles(style as unknown as Record<string, any>) |
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.
can we increase line width?
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 increased it to 130
but it may happen if it goes over that limit
// @ts-expect-error hidden from TS | ||
UnistylesShadowRegistry.add(storedRef, classNames?.hash) | ||
ref={ | ||
isServer() |
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.
same here
import { isServer } from '../../web/utils' | ||
|
||
type Variants = Record<string, string | boolean | undefined> | ||
type WebPressableState = { | ||
pressed: boolean, | ||
hovered: boolean, | ||
pressed: boolean |
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.
can we have commas
in types?
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 did change trailingCommas: 'none'
to fix one of your comment below, but it then removes commas for both types and interfaces
} | ||
}} | ||
ref={ | ||
isServer() |
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.
as above
src/core/warn.ts
Outdated
const unistylesKeys = Object | ||
.keys(style) | ||
.filter(key => key.startsWith('unistyles-')) | ||
const unistylesKeys = Object.keys(style).filter(key => key.startsWith('unistyles-')) |
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.
what if I prefer my style?
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 added an example, you can do // biome-ignore format: I like it better this way
but it's a bit cumbersome to do
src/hooks/useMedia.ts
Outdated
@@ -42,6 +44,6 @@ export const useMedia = (config: { mq: symbol }) => { | |||
useEffect(() => () => disposeRef.current(), []) | |||
|
|||
return { | |||
isVisible | |||
isVisible, |
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.
im not sure about trailing commas
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.
Fixed it with trailingCommas: 'none'
As stated in Biome documentation, their formatter is very opinionated, similar to how prettier works. Unfortunately (or fortunately), it can't be configured in many ways. Which make sense, the goal is to create/follow an industry standard. If you prefer to follow your own formatting, I would then suggest disabling the formatter all together. It would be too much of an hassle to use Alternative, is to not think about it, and let the formatter take all these decisions for you and let it handle for you. I used to be like you before and having a very strong opinion on how things should be formatted; then I tried prettier and never looked back. Feel free to close this PR if you are not happy with the latest configuration changes. I'll be happy to open another PR to remove the formatter instead. |
I really appreciate your contribution, @jeremybarbet, as you've already submitted a few great PRs. I think I'm going to skip this one since we don't use any code formatters in Codemask. We have our own rules that neither Prettier nor Biome can support. Of course, we might miss some spots, but that's okay. I hope you won't be upset, as I know this took you some time. |
No worries, I understand! Thanks for taking the time to look at it! Cheers |
Summary
So there is already a
biome lint
command, but nocheck --write
command to format following the json config.yarn check
alias ofbiome check --write
src
filesI am not sure what's your preferences for the formatter config.
Originally it was:
However, all the files were manually formatted with spaces instead so I run the
check --write
with:Let me know if you want to change that config to whatever you prefer. Just thinking formatting javascript/json with the same config makes the DX easier.
Edit:
biome check
on the CI to make sure it's correctly formatted?